Concept Class Hierarchy (Design Page)
Background
OpenMRS allows concepts to be placed in general categories called "concept classes." Â These include broad categories of concepts like:
Test
Procedure
Drug
Diagnosis
Finding
Anatomy
Question
Misc (miscellaneous)
Symptom
Symptom/Finding
Specimen
Misc Order
These were created somewhat arbitrarily from prior experience and were never assumed to represent the "complete" list of possible classifications.  As OpenMRS grows, we need a way not only to accommodate additional classes, but also increased granularity of these classifications.  Instead of losing the inherit relationship between increasingly granular classifications, we would prefer to create a simple (single inheritance) hierarchy of concept classes.  For example, "Test" can be broken into "Radiology Test", "Laboratory Test", etc.  "Laboratory Test" can be split into more specific classes like "Microbiology Lab Test", "Hematology Lab Test", and "Chemistry Lab Test".  Instead of having all of these as a flat list of concept classes without any notion of how they relate, we would prefer to define "Radiology Test" and "Laboratory Test" as children of "Test" as well as allowing "Microbiology Lab Test", "Hematology Lab Test", and "Chemistry Lab Test" to be recognized as more specific classes of "Laboratory Test" and all classes of "Test".
Requirements
A class cannot belong to more than one parent class (i.e., we define a single-inheritance hierarchy)
A concept can only be placed within a single class.
Design Ideas
The simplest way to introduce a hierarchy for classes would be to add a concept_class.parent_concept_class
attribute that links to the parent in the hierarchy – e.g., so "Laboratory Test" could point to a parent class of "Test".  Concepts could still be created and placed into any of these classes.
Add new service methods like:
interface ConceptService {
// Returns all classes at or below the provided level of specificity
public ConceptClass[] getConceptClasses(ConceptClass conceptClass);
// True if parent contains the provided concept class
public boolean conceptClassContains(ConceptClass parent, ConceptClass conceptClass);
}