use of ca.uhn.hl7v2.model.v25.datatype.NM in project openmrs-core by openmrs.
the class ORUR01HandlerTest method processMessage_shouldCreateEncounterAndObsFromHl7Message.
/**
* @see ORUR01Handler#processMessage(Message)
*/
@Test
public void processMessage_shouldCreateEncounterAndObsFromHl7Message() throws Exception {
ObsService obsService = Context.getObsService();
String hl7string = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080226102656||ORU^R01|JqnfhKKtouEz8kzTk6Zo|P|2.5|1||||||||16^AMRS.ELD.FORMID\r" + "PID|||3^^^^||John3^Doe^||\r" + "PV1||O|1^Unknown Location||||1^Super User (1-8)|||||||||||||||||||||||||||||||||||||20080212|||||||V\r" + "ORC|RE||||||||20080226102537|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBX|1|NM|5497^CD4, BY FACS^99DCT||450|||||||||20080206\r" + "OBX|2|DT|5096^RETURN VISIT DATE^99DCT||20080229|||||||||20080212";
Message hl7message = parser.parse(hl7string);
router.processMessage(hl7message);
Patient patient = new Patient(3);
// check for an encounter
List<Encounter> encForPatient3 = Context.getEncounterService().getEncountersByPatient(patient);
assertNotNull(encForPatient3);
assertTrue("There should be an encounter created", encForPatient3.size() == 1);
// check for any obs
List<Obs> obsForPatient3 = obsService.getObservationsByPerson(patient);
assertNotNull(obsForPatient3);
assertTrue("There should be some obs created for #3", obsForPatient3.size() > 0);
// check for the return visit date obs
Concept returnVisitDateConcept = new Concept(5096);
Calendar cal = Calendar.getInstance();
cal.set(2008, Calendar.FEBRUARY, 29, 0, 0, 0);
Date returnVisitDate = cal.getTime();
List<Obs> returnVisitDateObsForPatient3 = obsService.getObservationsByPersonAndConcept(patient, returnVisitDateConcept);
assertEquals("There should be a return visit date", 1, returnVisitDateObsForPatient3.size());
Obs firstObs = (Obs) returnVisitDateObsForPatient3.toArray()[0];
cal.setTime(firstObs.getValueDatetime());
Date firstObsValueDatetime = cal.getTime();
assertEquals("The date should be the 29th", returnVisitDate.toString(), firstObsValueDatetime.toString());
}
use of ca.uhn.hl7v2.model.v25.datatype.NM in project openmrs-core by openmrs.
the class ORUR01HandlerTest method processMessage_shouldFailIfQuestionDatatypeIsCodedAndABooleanIsNotAValidAnswer.
/**
* @see ORUR01Handler#processMessage(Message)
*/
@Test(expected = ApplicationException.class)
public void processMessage_shouldFailIfQuestionDatatypeIsCodedAndABooleanIsNotAValidAnswer() throws Exception {
GlobalProperty trueConceptGlobalProperty = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_TRUE_CONCEPT, "7", "Concept id of the concept defining the TRUE boolean concept");
GlobalProperty falseConceptGlobalProperty = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_FALSE_CONCEPT, "8", "Concept id of the concept defining the TRUE boolean concept");
Context.getAdministrationService().saveGlobalProperty(trueConceptGlobalProperty);
Context.getAdministrationService().saveGlobalProperty(falseConceptGlobalProperty);
String hl7string = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080226102656||ORU^R01|JqnfhKKtouEz8kzTk6Zo|P|2.5|1||||||||16^AMRS.ELD.FORMID\r" + "PID|||7^^^^||Collet^Test^Chebaskwony||\r" + "PV1||O|1^Unknown Location||||1^Super User (1-8)|||||||||||||||||||||||||||||||||||||20080212|||||||V\r" + "ORC|RE||||||||20080226102537|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBX|2|NM|4^CIVIL STATUS^99DCT||1|||||||||20080206";
Assert.assertEquals("Coded", Context.getConceptService().getConcept(4).getDatatype().getName());
Message hl7message = parser.parse(hl7string);
router.processMessage(hl7message);
}
use of ca.uhn.hl7v2.model.v25.datatype.NM in project openmrs-core by openmrs.
the class ORUR01HandlerTest method parseObs_shouldAddMultipleCommentsForAnObservationAsOneComment.
/**
* @see ORUR01Handler#parseObs(Encounter,OBX,OBR,String)
*/
@Test
public void parseObs_shouldAddMultipleCommentsForAnObservationAsOneComment() throws Exception {
ObsService os = Context.getObsService();
String hl7string = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080226102656||ORU^R01|JqnfhKKtouEz8kzTk6Zo|P|2.5|1||||||||16^AMRS.ELD.FORMID\r" + "PID|||7^^^^||Collet^Test^Chebaskwony||\r" + "PV1||O|1^Unknown Location||||1^Super User (1-8)|||||||||||||||||||||||||||||||||||||20080212|||||||V\r" + "ORC|RE||||||||20080226102537|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBX|1|NM|5497^CD4, BY FACS^99DCT||1|||||||||20080206\r" + "NTE|1|L|This is a comment\r" + "NTE|2|L|that spans two lines\r" + "OBX|2|NM|5497^CD4, BY FACS^99DCT||2|||||||||20080206";
// the expected question for the obs in the hl7 message has to be
// numeric
Assert.assertEquals("Numeric", Context.getConceptService().getConcept(5497).getDatatype().getName());
List<Obs> oldList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(5497));
Message hl7message = parser.parse(hl7string);
router.processMessage(hl7message);
List<Obs> newList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(5497));
// get the new observation with a not-null comment; not interested in
// the other one
Obs newObservation = null;
int thisIndex = 0;
while (newObservation == null && thisIndex < newList.size()) {
Obs newObs = newList.get(thisIndex++);
if (!oldList.contains(newObs) && !newObs.isObsGrouping() && newObs.getComment() != null)
newObservation = newObs;
}
Assert.assertEquals("This is a comment that spans two lines", newObservation.getComment());
}
use of ca.uhn.hl7v2.model.v25.datatype.NM in project openmrs-core by openmrs.
the class ORUR01HandlerTest method getForm_shouldPassIfReturnValueIsNotNullWhenUuidOrIdIsNotNull.
/**
* @see ORUR01Handler#getForm(MSH)
*/
@Test
public void getForm_shouldPassIfReturnValueIsNotNullWhenUuidOrIdIsNotNull() throws Exception {
String hl7String = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20090728170332||ORU^R01|gu99yBh4loLX2mh9cHaV|P|2.5|1||||||||16^AMRS.ELD.FORMID\r" + "PID|||3^^^^||Beren^John^Bondo||\r" + "NK1|1|Jones^Jane^Lee^^RN|3A^Parent^99REL||||||||||||F|19751016|||||||||||||||||2^^^L^PI\r" + "PV1||O|1^Unknown||||1^Super User (admin)|||||||||||||||||||||||||||||||||||||20090714|||||||V\r" + "ORC|RE||||||||20090728165937|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBX|2|NM|5497^CD4 COUNT^99DCT||123|||||||||20090714\r" + "OBR|3|||23^FOOD CONSTRUCT^99DCT\r" + "OBX|1|CWE|21^FOOD ASSISTANCE FOR ENTIRE FAMILY^99DCT||22^UNKNOWN^99DCT^2471^UNKNOWN^99NAM|||||||||20090714";
ORUR01Handler oruHandler = new ORUR01Handler();
Message hl7message = parser.parse(hl7String);
ORU_R01 oru = (ORU_R01) hl7message;
ca.uhn.hl7v2.model.v25.segment.MSH msh = oru.getMSH();
Form form = oruHandler.getForm(msh);
Assert.assertNotNull(form);
}
use of ca.uhn.hl7v2.model.v25.datatype.NM in project openmrs-core by openmrs.
the class ORUR01HandlerTest method processMessage_shouldFailIfQuestionDatatypeIsNeitherBooleanNorNumericNorCoded.
/**
* @see ORUR01Handler#processMessage(Message)
*/
@Test(expected = ApplicationException.class)
public void processMessage_shouldFailIfQuestionDatatypeIsNeitherBooleanNorNumericNorCoded() throws Exception {
String hl7string = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080226102656||ORU^R01|JqnfhKKtouEz8kzTk6Zo|P|2.5|1||||||||16^AMRS.ELD.FORMID\r" + "PID|||7^^^^||Collet^Test^Chebaskwony||\r" + "PV1||O|1^Unknown Location||||1^Super User (1-8)|||||||||||||||||||||||||||||||||||||20080212|||||||V\r" + "ORC|RE||||||||20080226102537|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBX|2|NM|19^FAVORITE FOOD, NON-CODED^99DCT||1|||||||||20080206";
Assert.assertEquals("Text", Context.getConceptService().getConcept(19).getDatatype().getName());
Message hl7message = parser.parse(hl7string);
router.processMessage(hl7message);
}
Aggregations