Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Ticket #892: hl7processor.patch

File hl7processor.patch, 9.8 kB (added by bwolfe, 1 year ago)
  • /home/ben/workspace/openmrs-trunk/src/api/org/openmrs/hl7/handler/ORUR01Handler.java

    old new  
    1515 
    1616import java.util.Calendar; 
    1717import java.util.Date; 
     18import java.util.List; 
     19import java.util.Vector; 
    1820 
    1921import org.apache.commons.logging.Log; 
    2022import org.apache.commons.logging.LogFactory; 
     
    174176                                        + "..."); 
    175177                // we ignore all MEDICAL_RECORD_OBSERVATIONS that are OBRs.  We do not  
    176178                // create obs_groups for them 
     179                List<Concept> ignoredConcepts = new Vector<Concept>(); 
    177180                String ignoreOBRConceptId = Context.getAdministrationService().getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_MEDICAL_RECORD_OBSERVATIONS, "1238"); 
    178                 Concept ignoreOBRConcept = null; 
     181                if (ignoreOBRConceptId.length() > 0) 
     182                        ignoredConcepts.add(new Concept(Integer.valueOf(ignoreOBRConceptId))); 
     183                 
     184                // we also ignore all PROBLEM_LIST that are OBRs 
     185                ignoreOBRConceptId = Context.getAdministrationService().getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_MEDICAL_RECORD_OBSERVATIONS, "1284"); 
    179186                if (ignoreOBRConceptId.length() > 0) 
    180                         ignoreOBRConcept = new Concept(Integer.valueOf(ignoreOBRConceptId));  
     187                        ignoredConcepts.add(new Concept(Integer.valueOf(ignoreOBRConceptId))); 
    181188                 
    182189                ORU_R01_PATIENT_RESULT patientResult = oru.getPATIENT_RESULT(); 
    183190                int numObr = patientResult.getORDER_OBSERVATIONReps(); 
     
    194201                        // Obs grouper object that the underlying obs objects will use 
    195202                        Obs obsGrouper = null; 
    196203                        Concept obrConcept = getConcept(obr); 
    197                         if (obrConcept != null && ignoreOBRConcept != null && !ignoreOBRConcept.equals(obrConcept)) { 
     204                        if (obrConcept != null && !ignoredConcepts.contains(obrConcept)) { 
    198205                                // maybe check for a parent obs group from OBR-29 Parent ? 
    199206                                 
    200207                                // create an obs for this obs group too 
     
    409416                                if (log.isDebugEnabled()) 
    410417                                        log.debug("Proposing concept"); 
    411418                                proposeConcept(encounter, concept, valueName); 
     419                                return null; //so that this obs is not saved 
    412420                        } else { 
    413421                                log.debug("    not proposal"); 
    414422                                try { 
  • /home/ben/workspace/openmrs-trunk/src/api/org/openmrs/util/OpenmrsConstants.java

    old new  
    540540        public static final String GLOBAL_PROPERTY_PATIENT_SEARCH_MAX_RESULTS  = "patient.searchMaxResults"; 
    541541        public static final String GLOBAL_PROPERTY_GZIP_ENABLED                = "gzip.enabled"; 
    542542        public static final String GLOBAL_PROPERTY_MEDICAL_RECORD_OBSERVATIONS = "concept.medicalRecordObservations"; 
     543        public static final String GLOBAL_PROPERTY_PROBLEM_LIST                = "concept.problemList"; 
    543544        public static final String GLOBAL_PROPERTY_REPORT_XML_MACROS           = "report.xmlMacros"; 
    544545        public static final String GLOBAL_PROPERTY_STANDARD_DRUG_REGIMENS      = "dashboard.regimen.standardRegimens"; 
    545546        public static final String GLOBAL_PROPERTY_DEFAULT_PATIENT_IDENTIFIER_VALIDATOR = "patient.defaultPatientIdentifierValidator";   
  • /home/ben/workspace/openmrs-trunk/test/api/org/openmrs/hl7/include/ORUTest-initialData.xml

    old new  
    5050   
    5151  <obs obs_id="1" concept_id="905" value_numeric="100" obs_datetime="2007-05-01 00:00:00.0" person_id="2" location_id="1" creator="1" date_created="2005-03-01 00:00:00.0" voided="0"/> 
    5252   
     53  <concept concept_id="1284" retired="false" datatype_id="4" class_id="11" is_set="false" creator="1" date_created="2005-02-24 12:33:10.0" version=""/> 
     54  <concept concept_id="6042" retired="false" datatype_id="2" class_id="4" is_set="false" creator="1" date_created="2004-08-12 00:00:00.0" version="" changed_by="1" date_changed="2005-02-22 12:18:13.0"/> 
     55  <concept_name concept_id="1284" name="PROBLEM LIST" short_name="" description="List of problems for a given patient visit." locale="en" creator="1" date_created="2005-02-24 12:33:10.0" concept_name_id="1285"/> 
     56  <concept_name concept_id="6042" name="PROBLEM ADDED" short_name="" description="Diagnosis or problem noted on a patient encounter." locale="en" creator="1" date_created="2004-08-12 00:00:00.0" concept_name_id="2394"/> 
     57   
    5358</dataset> 
  • /home/ben/workspace/openmrs-trunk/test/api/org/openmrs/hl7/ORUR01HandlerTest.java

    old new  
    1717import java.util.Date; 
    1818import java.util.GregorianCalendar; 
    1919import java.util.List; 
    20 import java.util.Set; 
    2120import java.util.Vector; 
    2221 
    2322import org.openmrs.Concept; 
     23import org.openmrs.ConceptProposal; 
     24import org.openmrs.Encounter; 
    2425import org.openmrs.Obs; 
    2526import org.openmrs.Patient; 
     27import org.openmrs.api.ConceptService; 
     28import org.openmrs.api.EncounterService; 
    2629import org.openmrs.api.ObsService; 
    2730import org.openmrs.api.context.Context; 
    2831import org.openmrs.hl7.handler.ORUR01Handler; 
     
    7376                Patient patient = new Patient(3); 
    7477                 
    7578                // check for any obs 
    76                 Set<Obs> obsForPatient3 = obsService.getObservations(patient, false); 
     79                List<Obs> obsForPatient3 = obsService.getObservationsByPerson(patient); 
    7780                assertNotNull(obsForPatient3); 
    7881                assertTrue("There should be some obs created for #3", obsForPatient3.size() > 0); 
    7982                 
     
    8285                Calendar cal = new GregorianCalendar(); 
    8386                cal.set(2008, Calendar.FEBRUARY, 29, 0, 0, 0); 
    8487                Date returnVisitDate = cal.getTime(); 
    85                 Set<Obs> returnVisitDateObsForPatient3 = obsService.getObservations(patient, returnVisitDateConcept, false); 
     88                List<Obs> returnVisitDateObsForPatient3 = obsService.getObservationsByPersonAndConcept(patient, returnVisitDateConcept); 
    8689                assertEquals("There should be a return visit date", 1, returnVisitDateObsForPatient3.size()); 
    8790                 
    8891                Obs firstObs = (Obs)returnVisitDateObsForPatient3.toArray()[0]; 
     
    119122                Calendar cal = new GregorianCalendar(); 
    120123                cal.set(2008, Calendar.FEBRUARY, 1, 0, 0, 0); 
    121124                Date returnVisitDate = cal.getTime(); 
    122                 Set<Obs> returnVisitDateObsForPatient2 = obsService.getObservations(patient, returnVisitDateConcept, false); 
     125                List<Obs> returnVisitDateObsForPatient2 = obsService.getObservationsByPersonAndConcept(patient, returnVisitDateConcept); 
    123126                assertEquals("There should be a return visit date", 1, returnVisitDateObsForPatient2.size()); 
    124127                Obs firstObs = (Obs)returnVisitDateObsForPatient2.toArray()[0]; 
    125128                 
     
    133136                // check for the grouped obs 
    134137                Concept contactMethod = new Concept(1558); 
    135138                Concept phoneContact = Context.getConceptService().getConcept(1555); 
    136                 Set<Obs> contactMethodObsForPatient2 = obsService.getObservations(patient, contactMethod, false); 
     139                List<Obs> contactMethodObsForPatient2 = obsService.getObservationsByPersonAndConcept(patient, contactMethod); 
    137140                assertEquals("There should be a contact method", 1, contactMethodObsForPatient2.size()); 
    138141                Obs firstContactMethodObs = (Obs)contactMethodObsForPatient2.toArray()[0]; 
    139142                assertEquals("The contact method should be phone", phoneContact, firstContactMethodObs.getValueCoded()); 
     
    165168                assertEquals(3, groupedObsCount); 
    166169                 
    167170        } 
    168  
     171         
     172        /** 
     173         * Tests that a ConceptProposal row can be written by the processor 
     174         *  
     175         * @throws Exception 
     176         */ 
     177        public void testBasicConceptProposalCreate() throws Exception { 
     178                authenticate(); 
     179                ObsService obsService = Context.getObsService(); 
     180                ConceptService conceptService = Context.getConceptService(); 
     181                EncounterService encService = Context.getEncounterService(); 
     182                 
     183                String hl7String = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080630094800||ORU^R01|kgWdFt0SVwwClOfJm3pe|P|2.5|1||||||||15^AMRS.ELD.FORMID\rPID|||3^^^^~d3811480^^^^||John3^Doe^||\rPV1||O|1^Unknown||||1^Super User (admin)|||||||||||||||||||||||||||||||||||||20080208|||||||V\rORC|RE||||||||20080208000000|1^Super User\rOBR|1|||\rOBR|1|||1284^PROBLEM LIST^99DCT\rOBX|1|CWE|6042^PROBLEM ADDED^99DCT||PROPOSED^SEVERO DOLOR DE CABEZA^99DCT|||||||||20080208"; 
     184                Message hl7message = parser.parse(hl7String); 
     185                router.processMessage(hl7message); 
     186                 
     187                //System.out.println("obs size for pat 2: " + obsService.getObservations(new Patient(2), false)); 
     188                 
     189                Patient patient = new Patient(3); 
     190                 
     191                // check for any obs 
     192                List<Obs> obsForPatient3 = obsService.getObservationsByPerson(patient); 
     193                assertNotNull(obsForPatient3); 
     194                assertEquals("There should not be any obs created for #3", 0, obsForPatient3.size()); 
     195                 
     196                // check for a new encounter 
     197                List<Encounter> encsForPatient3 = encService.getEncountersByPatient(patient); 
     198                assertNotNull(encsForPatient3); 
     199                assertEquals("There should be 1 new encounter created for #3", 1, encsForPatient3.size()); 
     200                Encounter newEncounter = encsForPatient3.get(0); 
     201                 
     202                // check for the proposed concept 
     203                List<ConceptProposal> proposedConcepts = conceptService.getConceptProposals("SEVERO DOLOR DE CABEZA"); 
     204                assertNotNull(proposedConcepts); 
     205                assertEquals("There should be a proposed concept by this name", 1, proposedConcepts.size()); 
     206                assertEquals(newEncounter, proposedConcepts.get(0).getEncounter()); 
     207                 
     208        } 
     209         
    169210}