org.mitre.midiki.workshop
Class WorkshopDatabase

java.lang.Object
  |
  +--org.mitre.midiki.workshop.WorkshopDatabase
All Implemented Interfaces:
java.io.Serializable

public class WorkshopDatabase
extends java.lang.Object
implements java.io.Serializable

Simple medical diagnosis database to support the MITRE Dialogue Workshop. Primary usage is to identify possible diseases in database given a list of symptoms, either present or absent, and further symptoms which can be used to narrow a diagnosis if multiple diseases can be diagnosed. Not intended for use with a large number of diseases; the algorithms used were chosen for ease of implementation, not scalability.

Since:
1.0
See Also:
Serializable, Serialized Form

Field Summary
protected  java.util.ArrayList diseaseList
          Unsorted list of disease names.
protected  java.util.ArrayList diseases
          List of detailed records for diseases.
protected  DiseaseToSymptomMapping[] diseasesByHistory
          Column headers for the sparse matrix.
protected  DiseaseToSymptomMapping[] diseasesBySymptom
          Column headers for the sparse matrix.
protected  DiseaseToSymptomMapping[] diseasesByTest
          Column headers for the sparse matrix.
protected  DiseaseToSymptomMapping[] historyByDisease
          Row headers for the sparse matrix.
protected  java.util.List historyList
          Unsorted list of medical history item names.
protected  java.util.List symptomList
          Unsorted list of resolved symptom names.
protected  DiseaseToSymptomMapping[] symptomsByDisease
          Row headers for the sparse matrix.
protected  java.util.ArrayList synonymList
          List of synonym sets.
protected  java.util.List testList
          Unsorted list of test names.
protected  DiseaseToSymptomMapping[] testsByDisease
          Row headers for the sparse matrix.
protected  java.util.HashMap uniqueHistory
          Maps resolved names of all history to the appropriate record.
protected  java.util.HashMap uniqueSymptoms
          Maps resolved names of all symptoms to the appropriate record.
protected  java.util.HashMap uniqueTests
          Maps resolved names of all tests to the appropriate record.
 
Constructor Summary
WorkshopDatabase()
          Creates an empty WorkshopDatabase instance.
 
Method Summary
protected  boolean compatibleWithSymptoms(java.lang.String diseaseName, java.util.List symptoms, java.util.List tests, java.util.List history)
          Returns true if the specified disease is compatible with the observed symptoms.
protected  java.util.LinkedList discriminatingHistory(java.util.List diseases, java.util.List history)
          Calculates the history which can be used to discriminate between some of the specified diseases.
protected  java.util.LinkedList discriminatingSymptoms(java.util.List diseases, java.util.List symptoms)
          Calculates the symptoms which can be used to discriminate between some of the specified diseases.
protected  java.util.LinkedList discriminatingTests(java.util.List diseases, java.util.List tests)
          Calculates the tests which can be used to discriminate between some of the specified diseases.
protected  int diseaseIndex(java.lang.String diseaseName)
          Converts a disease name into a numeric index.
 java.util.List getAllDiseases()
          Returns a list containing the names of all the diseases in the database.
 java.util.List getAllHistoryItems()
          Returns the list of unique history items in the database.
 java.util.List getAllSymptoms()
          Returns the list of unique symptoms in the database.
 java.util.List getAllSymptomSynonyms()
          Returns all synonym sets specified in the database.
 java.util.List getAllTestNames()
          Returns the names of tests in the database.
 java.util.List getAllTests()
          Returns the list of unique tests in the database.
 QueryResponse getApplicableDiseases(java.util.List symptoms, java.util.List tests, java.util.List history)
          Searches the database for diseases matching the specified symptoms.
 Disease getDiseaseDescription(java.lang.String diseaseName)
          Locates the detailed record for the specified disease.
protected  int historyIndex(java.lang.String historyName)
          Converts a history name to a numeric index.
 void printDiseasesBySymptom()
          Prints a cross-reference listing of diseases by symptom on System.out.
protected  java.lang.String resolveSynonyms(java.lang.String s)
          Checks all known synonym sets for the specified string.
protected  int symptomIndex(java.lang.String symptomName)
          Converts a symptom name to a numeric index.
protected  int testIndex(java.lang.String testName)
          Converts a test name to a numeric index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

diseaseList

protected java.util.ArrayList diseaseList
Unsorted list of disease names.

synonymList

protected java.util.ArrayList synonymList
List of synonym sets.

symptomList

protected java.util.List symptomList
Unsorted list of resolved symptom names.

testList

protected java.util.List testList
Unsorted list of test names.

historyList

protected java.util.List historyList
Unsorted list of medical history item names.

diseases

protected java.util.ArrayList diseases
List of detailed records for diseases.

uniqueSymptoms

protected java.util.HashMap uniqueSymptoms
Maps resolved names of all symptoms to the appropriate record. Only the first occurrance of a symptom is considered.

uniqueTests

protected java.util.HashMap uniqueTests
Maps resolved names of all tests to the appropriate record. Only the first occurrance of a symptom is considered.

uniqueHistory

protected java.util.HashMap uniqueHistory
Maps resolved names of all history to the appropriate record. Only the first occurrance of a symptom is considered.

symptomsByDisease

protected DiseaseToSymptomMapping[] symptomsByDisease
Row headers for the sparse matrix.

diseasesBySymptom

protected DiseaseToSymptomMapping[] diseasesBySymptom
Column headers for the sparse matrix.

testsByDisease

protected DiseaseToSymptomMapping[] testsByDisease
Row headers for the sparse matrix.

diseasesByTest

protected DiseaseToSymptomMapping[] diseasesByTest
Column headers for the sparse matrix.

historyByDisease

protected DiseaseToSymptomMapping[] historyByDisease
Row headers for the sparse matrix.

diseasesByHistory

protected DiseaseToSymptomMapping[] diseasesByHistory
Column headers for the sparse matrix.
Constructor Detail

WorkshopDatabase

public WorkshopDatabase()
Creates an empty WorkshopDatabase instance. Use WorkshopDatabaseFactory.newDatabase() to populate it, or load it from an ObjectInputStream.
Method Detail

resolveSynonyms

protected java.lang.String resolveSynonyms(java.lang.String s)
Checks all known synonym sets for the specified string. If the string is not found, it is returned unchanged. If it is found in a synonym set, we return the default synonym that labels the set. The default synonym is the first one encountered when parsing the XML file for that synonym set.
Parameters:
s - a String value
Returns:
a String value

diseaseIndex

protected int diseaseIndex(java.lang.String diseaseName)
Converts a disease name into a numeric index. used internally for traversing the database.
Parameters:
diseaseName - a String value
Returns:
an int value

symptomIndex

protected int symptomIndex(java.lang.String symptomName)
Converts a symptom name to a numeric index. Used internally for traversing the database.
Parameters:
symptomName - a String value
Returns:
an int value

testIndex

protected int testIndex(java.lang.String testName)
Converts a test name to a numeric index. Used internally for traversing the database.
Parameters:
testName - a String value
Returns:
an int value

historyIndex

protected int historyIndex(java.lang.String historyName)
Converts a history name to a numeric index. Used internally for traversing the database.
Parameters:
historyName - a String value
Returns:
an int value

compatibleWithSymptoms

protected boolean compatibleWithSymptoms(java.lang.String diseaseName,
                                         java.util.List symptoms,
                                         java.util.List tests,
                                         java.util.List history)
Returns true if the specified disease is compatible with the observed symptoms.
Parameters:
diseaseName - a String value
symptoms - a List value
tests - a List value
history - a List value
Returns:
a boolean value

discriminatingSymptoms

protected java.util.LinkedList discriminatingSymptoms(java.util.List diseases,
                                                      java.util.List symptoms)
Calculates the symptoms which can be used to discriminate between some of the specified diseases. Symptoms which are already used in the diagnosis to this point should be passed in, and will not be included in the output.
Parameters:
diseases - a List of possible diseases
symptoms - a List of known symptoms
Returns:
a LinkedList of possible discriminators

discriminatingTests

protected java.util.LinkedList discriminatingTests(java.util.List diseases,
                                                   java.util.List tests)
Calculates the tests which can be used to discriminate between some of the specified diseases. Tests which are already used in the diagnosis to this point should be passed in, and will not be included in the output.
Parameters:
diseases - a List of possible diseases
tests - a List of known tests
Returns:
a LinkedList of possible discriminators

discriminatingHistory

protected java.util.LinkedList discriminatingHistory(java.util.List diseases,
                                                     java.util.List history)
Calculates the history which can be used to discriminate between some of the specified diseases. History which is already used in the diagnosis to this point should be passed in, and will not be included in the output.
Parameters:
diseases - a List of possible diseases
history - a List of known history
Returns:
a LinkedList of possible discriminators

printDiseasesBySymptom

public void printDiseasesBySymptom()
Prints a cross-reference listing of diseases by symptom on System.out. Not useful for querying, but may be informative.

getAllDiseases

public java.util.List getAllDiseases()
Returns a list containing the names of all the diseases in the database. getDiseaseDescription() is warranted to work for every name in this list.
Returns:
a List value

getAllSymptoms

public java.util.List getAllSymptoms()
Returns the list of unique symptoms in the database. There is one unique symptom for every synonym set, plus all symptoms whose names do not appear in synonym sets. Does not consider presence value when compiling the list, but that doesn't matter for the simple example we are using for the workshop because all disease descriptions include only those symptoms which must be present.
Returns:
a List value

getAllTestNames

public java.util.List getAllTestNames()
Returns the names of tests in the database.
Returns:
a List value

getAllTests

public java.util.List getAllTests()
Returns the list of unique tests in the database.
Returns:
a List value

getAllHistoryItems

public java.util.List getAllHistoryItems()
Returns the list of unique history items in the database.
Returns:
a List value

getAllSymptomSynonyms

public java.util.List getAllSymptomSynonyms()
Returns all synonym sets specified in the database.
Returns:
a List value

getApplicableDiseases

public QueryResponse getApplicableDiseases(java.util.List symptoms,
                                           java.util.List tests,
                                           java.util.List history)
Searches the database for diseases matching the specified symptoms. If no diseases are found, the lists of possible diseases and discriminating symptoms will be empty. If only one disease is found, the list of discriminating symptoms will be empty. Otherwise, the list of discriminating symptoms will hold all symptoms and thier associated tests which can narrow down the diagnosis. The symptoms are not ordered in any particular way.
Parameters:
symptoms - a List value
Returns:
a QueryResponse value

getDiseaseDescription

public Disease getDiseaseDescription(java.lang.String diseaseName)
Locates the detailed record for the specified disease. Case is not significant. Returns null if no matching disease found.
Parameters:
diseaseName - a String value
Returns:
a Disease value