use of ca.uhn.hl7v2.model.v24.segment.PID in project openmrs-core by openmrs.
the class HL7ServiceTest method getUuidFromIdentifiers_shouldNotFailIfMultipleSimilarUUIDsExistInIdentifiers.
/**
* @throws HL7Exception
* @see HL7Service#getUuidFromIdentifiers(null)
*/
@Test
public void getUuidFromIdentifiers_shouldNotFailIfMultipleSimilarUUIDsExistInIdentifiers() throws HL7Exception {
HL7Service hl7service = Context.getHL7Service();
Message message = hl7service.parseHL7String("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" + "NK1|1|Hornblower^Horatio^L|2B^Sibling^99REL||||||||||||M|19410501|||||||||||||||||2178037d-f86b-4f12-8d8b-be3ebc220022^^^UUID^v4~2178037d-f86b-4f12-8d8b-be3ebc220022^^^UUID^v4||||\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");
ORU_R01 oru = (ORU_R01) message;
List<NK1> nk1List = new ORUR01Handler().getNK1List(oru);
CX[] identifiers = nk1List.get(0).getNextOfKinAssociatedPartySIdentifiers();
String result = hl7service.getUuidFromIdentifiers(identifiers);
Assert.assertEquals("2178037d-f86b-4f12-8d8b-be3ebc220022", result);
}
use of ca.uhn.hl7v2.model.v24.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.v24.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.v24.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.v24.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());
}
Aggregations