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 15 15 16 16 import java.util.Calendar; 17 17 import java.util.Date; 18 import java.util.List; 19 import java.util.Vector; 18 20 19 21 import org.apache.commons.logging.Log; 20 22 import org.apache.commons.logging.LogFactory; … … 174 176 + "..."); 175 177 // we ignore all MEDICAL_RECORD_OBSERVATIONS that are OBRs. We do not 176 178 // create obs_groups for them 179 List<Concept> ignoredConcepts = new Vector<Concept>(); 177 180 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"); 179 186 if (ignoreOBRConceptId.length() > 0) 180 ignore OBRConcept = new Concept(Integer.valueOf(ignoreOBRConceptId));187 ignoredConcepts.add(new Concept(Integer.valueOf(ignoreOBRConceptId))); 181 188 182 189 ORU_R01_PATIENT_RESULT patientResult = oru.getPATIENT_RESULT(); 183 190 int numObr = patientResult.getORDER_OBSERVATIONReps(); … … 194 201 // Obs grouper object that the underlying obs objects will use 195 202 Obs obsGrouper = null; 196 203 Concept obrConcept = getConcept(obr); 197 if (obrConcept != null && ignoreOBRConcept != null && !ignoreOBRConcept.equals(obrConcept)) {204 if (obrConcept != null && !ignoredConcepts.contains(obrConcept)) { 198 205 // maybe check for a parent obs group from OBR-29 Parent ? 199 206 200 207 // create an obs for this obs group too … … 409 416 if (log.isDebugEnabled()) 410 417 log.debug("Proposing concept"); 411 418 proposeConcept(encounter, concept, valueName); 419 return null; //so that this obs is not saved 412 420 } else { 413 421 log.debug(" not proposal"); 414 422 try { -
/home/ben/workspace/openmrs-trunk/src/api/org/openmrs/util/OpenmrsConstants.java
old new 540 540 public static final String GLOBAL_PROPERTY_PATIENT_SEARCH_MAX_RESULTS = "patient.searchMaxResults"; 541 541 public static final String GLOBAL_PROPERTY_GZIP_ENABLED = "gzip.enabled"; 542 542 public static final String GLOBAL_PROPERTY_MEDICAL_RECORD_OBSERVATIONS = "concept.medicalRecordObservations"; 543 public static final String GLOBAL_PROPERTY_PROBLEM_LIST = "concept.problemList"; 543 544 public static final String GLOBAL_PROPERTY_REPORT_XML_MACROS = "report.xmlMacros"; 544 545 public static final String GLOBAL_PROPERTY_STANDARD_DRUG_REGIMENS = "dashboard.regimen.standardRegimens"; 545 546 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 50 50 51 51 <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"/> 52 52 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 53 58 </dataset> -
/home/ben/workspace/openmrs-trunk/test/api/org/openmrs/hl7/ORUR01HandlerTest.java
old new 17 17 import java.util.Date; 18 18 import java.util.GregorianCalendar; 19 19 import java.util.List; 20 import java.util.Set;21 20 import java.util.Vector; 22 21 23 22 import org.openmrs.Concept; 23 import org.openmrs.ConceptProposal; 24 import org.openmrs.Encounter; 24 25 import org.openmrs.Obs; 25 26 import org.openmrs.Patient; 27 import org.openmrs.api.ConceptService; 28 import org.openmrs.api.EncounterService; 26 29 import org.openmrs.api.ObsService; 27 30 import org.openmrs.api.context.Context; 28 31 import org.openmrs.hl7.handler.ORUR01Handler; … … 73 76 Patient patient = new Patient(3); 74 77 75 78 // check for any obs 76 Set<Obs> obsForPatient3 = obsService.getObservations(patient, false);79 List<Obs> obsForPatient3 = obsService.getObservationsByPerson(patient); 77 80 assertNotNull(obsForPatient3); 78 81 assertTrue("There should be some obs created for #3", obsForPatient3.size() > 0); 79 82 … … 82 85 Calendar cal = new GregorianCalendar(); 83 86 cal.set(2008, Calendar.FEBRUARY, 29, 0, 0, 0); 84 87 Date returnVisitDate = cal.getTime(); 85 Set<Obs> returnVisitDateObsForPatient3 = obsService.getObservations(patient, returnVisitDateConcept, false);88 List<Obs> returnVisitDateObsForPatient3 = obsService.getObservationsByPersonAndConcept(patient, returnVisitDateConcept); 86 89 assertEquals("There should be a return visit date", 1, returnVisitDateObsForPatient3.size()); 87 90 88 91 Obs firstObs = (Obs)returnVisitDateObsForPatient3.toArray()[0]; … … 119 122 Calendar cal = new GregorianCalendar(); 120 123 cal.set(2008, Calendar.FEBRUARY, 1, 0, 0, 0); 121 124 Date returnVisitDate = cal.getTime(); 122 Set<Obs> returnVisitDateObsForPatient2 = obsService.getObservations(patient, returnVisitDateConcept, false);125 List<Obs> returnVisitDateObsForPatient2 = obsService.getObservationsByPersonAndConcept(patient, returnVisitDateConcept); 123 126 assertEquals("There should be a return visit date", 1, returnVisitDateObsForPatient2.size()); 124 127 Obs firstObs = (Obs)returnVisitDateObsForPatient2.toArray()[0]; 125 128 … … 133 136 // check for the grouped obs 134 137 Concept contactMethod = new Concept(1558); 135 138 Concept phoneContact = Context.getConceptService().getConcept(1555); 136 Set<Obs> contactMethodObsForPatient2 = obsService.getObservations(patient, contactMethod, false);139 List<Obs> contactMethodObsForPatient2 = obsService.getObservationsByPersonAndConcept(patient, contactMethod); 137 140 assertEquals("There should be a contact method", 1, contactMethodObsForPatient2.size()); 138 141 Obs firstContactMethodObs = (Obs)contactMethodObsForPatient2.toArray()[0]; 139 142 assertEquals("The contact method should be phone", phoneContact, firstContactMethodObs.getValueCoded()); … … 165 168 assertEquals(3, groupedObsCount); 166 169 167 170 } 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 169 210 }
Download in other formats:
Powered by Trac 0.10.5
By Edgewall Software.
Visit the Trac open source project at
http://trac.edgewall.com/