use of ca.uhn.hl7v2.model.v26.segment.PID in project openmrs-core by openmrs.
the class ORUR01HandlerTest method parseObs_shouldAddCommentsToAnObservationFromNTESegments.
/**
* @see ORUR01Handler#parseObs(Encounter,OBX,OBR,String)
*/
@Test
public void parseObs_shouldAddCommentsToAnObservationFromNTESegments() 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";
// 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));
Obs newObservation = null;
for (Obs newObs : newList) {
if (!oldList.contains(newObs) && !newObs.isObsGrouping()) {
newObservation = newObs;
}
}
Assert.assertEquals("This is a comment", newObservation.getComment());
}
use of ca.uhn.hl7v2.model.v26.segment.PID in project openmrs-core by openmrs.
the class ORUR01HandlerTest method processMessage_shouldPreferFormIdIfUuidIsNotFound.
/**
* @see ORUR01Handler#processMessage(Message)
*/
@Test
public void processMessage_shouldPreferFormIdIfUuidIsNotFound() throws Exception {
// save original encounter count
List<Encounter> encounters = Context.getEncounterService().getEncountersByPatient(new Patient(3));
Integer originalEncounters = encounters.size();
// process message
String hl7String = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20090728170332||ORU^R01|gu99yBh4loLX2mh9cHaV|P|2.5|1||||||||1^AMRS.ELD.FORMID~oicu812^AMRS.ELD.FORMUUID^^\r" + "PID|||3^^^^||Beren^John^Bondo||\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";
Message hl7message = parser.parse(hl7String);
router.processMessage(hl7message);
// make sure an encounter was added
encounters = Context.getEncounterService().getEncountersByPatient(new Patient(3));
Assert.assertEquals(originalEncounters + 1, encounters.size());
// get last encounter
Encounter enc = encounters.get(encounters.size() - 1);
// check the form id
Form form = enc.getForm();
Assert.assertEquals(1, form.getId().intValue());
}
use of ca.uhn.hl7v2.model.v26.segment.PID in project openmrs-core by openmrs.
the class ORUR01HandlerTest method processMessage_shouldSetValue_NumericForObsIfQuestionDatatypeIsNumericAndTheAnswerIsEither0Or1.
/**
* @see ORUR01Handler#processMessage(Message)
*/
@Test
public void processMessage_shouldSetValue_NumericForObsIfQuestionDatatypeIsNumericAndTheAnswerIsEither0Or1() 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";
// 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));
Obs newObservation = null;
for (Obs newObs : newList) {
if (!oldList.contains(newObs) && !newObs.isObsGrouping()) {
newObservation = newObs;
}
}
Assert.assertEquals(1, newObservation.getValueNumeric().intValue());
}
use of ca.uhn.hl7v2.model.v26.segment.PID in project openmrs-core by openmrs.
the class ORUR01HandlerTest method parseObs_shouldAddCommentsToAnObservationGroup.
/**
* @see ORUR01Handler#parseObs(Encounter,OBX,OBR,String)
*/
@Test
public void parseObs_shouldAddCommentsToAnObservationGroup() 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|||23^FOOD CONSTRUCT^99DCT\r" + "NTE|1|L|This is a comment\r" + "OBX|1|NM|5497^CD4, BY FACS^99DCT||1|||||||||20080206\r" + "NTE|1|L|This should not be considered :-)";
List<Obs> oldList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(23));
Message hl7message = parser.parse(hl7string);
router.processMessage(hl7message);
List<Obs> newList = os.getObservationsByPersonAndConcept(new Person(7), new Concept(23));
Obs newObservation = null;
for (Obs newObs : newList) {
if (!oldList.contains(newObs) && newObs.isObsGrouping()) {
newObservation = newObs;
}
}
Assert.assertEquals("This is a comment", newObservation.getComment());
}
use of ca.uhn.hl7v2.model.v26.segment.PID in project openmrs-core by openmrs.
the class ORUR01HandlerTest method processMessage_shouldPreferFormUuidOverIdIfBothArePresent.
/**
* @see ORUR01Handler#processMessage(Message)
*/
@Test
public void processMessage_shouldPreferFormUuidOverIdIfBothArePresent() throws Exception {
// save original encounter count
List<Encounter> encounters = Context.getEncounterService().getEncountersByPatient(new Patient(3));
Integer originalEncounters = encounters.size();
// process message
String hl7String = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20090728170332||ORU^R01|gu99yBh4loLX2mh9cHaV|P|2.5|1||||||||4^AMRS.ELD.FORMID~c156e1a8-6731-4ebd-89ff-d0d1c45eb004^AMRS.ELD.FORMUUID\r" + "PID|||3^^^^||Beren^John^Bondo||\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";
Message hl7message = parser.parse(hl7String);
router.processMessage(hl7message);
// make sure an encounter was added
encounters = Context.getEncounterService().getEncountersByPatient(new Patient(3));
Assert.assertEquals(originalEncounters + 1, encounters.size());
// get last encounter
Encounter enc = encounters.get(encounters.size() - 1);
// check the form uuid
Form form = enc.getForm();
Assert.assertEquals("c156e1a8-6731-4ebd-89ff-d0d1c45eb004", form.getUuid());
}
Aggregations