Search in sources :

Example 66 with PID

use of ca.uhn.hl7v2.model.v24.segment.PID in project openmrs-core by openmrs.

the class HL7ServiceTest method getPersonFromNK1_shouldFailOnAnInvalidGender.

/**
 * @throws HL7Exception
 * @see HL7Service#createPersonFromNK1(NK1)
 */
@Test(expected = HL7Exception.class)
public void getPersonFromNK1_shouldFailOnAnInvalidGender() 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||||||||||||Q|19410501|||||||||||||||||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);
    hl7service.createPersonFromNK1(nk1List.get(0));
    Assert.fail("should have thrown an exception");
}
Also used : Message(ca.uhn.hl7v2.model.Message) ORUR01Handler(org.openmrs.hl7.handler.ORUR01Handler) ORU_R01(ca.uhn.hl7v2.model.v25.message.ORU_R01) NK1(ca.uhn.hl7v2.model.v25.segment.NK1) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 67 with PID

use of ca.uhn.hl7v2.model.v24.segment.PID in project openmrs-core by openmrs.

the class HL7ServiceTest method getUuidFromIdentifiers_shouldReturnNullIfNoUUIDFound.

/**
 * @throws HL7Exception
 * @see HL7Service#getUuidFromIdentifiers(null)
 */
@Test
public void getUuidFromIdentifiers_shouldReturnNullIfNoUUIDFound() 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|||||||||||||||||5^^^L^PN||||\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.assertNull("should have returned null", result);
}
Also used : Message(ca.uhn.hl7v2.model.Message) ORUR01Handler(org.openmrs.hl7.handler.ORUR01Handler) ORU_R01(ca.uhn.hl7v2.model.v25.message.ORU_R01) NK1(ca.uhn.hl7v2.model.v25.segment.NK1) CX(ca.uhn.hl7v2.model.v25.datatype.CX) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 68 with PID

use of ca.uhn.hl7v2.model.v24.segment.PID in project openmrs-core by openmrs.

the class HL7ServiceTest method getPersonFromNK1_shouldReturnASavedNewPerson.

/**
 * @throws HL7Exception
 * @see HL7Service#createPersonFromNK1(NK1)
 */
@Test
public void getPersonFromNK1_shouldReturnASavedNewPerson() 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||||\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);
    Person result = hl7service.createPersonFromNK1(nk1List.get(0));
    Assert.assertNotNull("should have returned a person", result);
    Assert.assertNotNull("the person should exist", Context.getPersonService().getPersonByUuid(result.getUuid()));
}
Also used : Message(ca.uhn.hl7v2.model.Message) ORUR01Handler(org.openmrs.hl7.handler.ORUR01Handler) ORU_R01(ca.uhn.hl7v2.model.v25.message.ORU_R01) NK1(ca.uhn.hl7v2.model.v25.segment.NK1) Person(org.openmrs.Person) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 69 with PID

use of ca.uhn.hl7v2.model.v24.segment.PID in project openmrs-core by openmrs.

the class HL7ServiceTest method getPersonFromNK1_shouldFailIfNoBirthdateSpecified.

/**
 * @throws HL7Exception
 * @see HL7Service#createPersonFromNK1(NK1)
 */
@Test(expected = HL7Exception.class)
public void getPersonFromNK1_shouldFailIfNoBirthdateSpecified() 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||||||||||||||||||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);
    hl7service.createPersonFromNK1(nk1List.get(0));
    Assert.fail("should have thrown an exception");
}
Also used : Message(ca.uhn.hl7v2.model.Message) ORUR01Handler(org.openmrs.hl7.handler.ORUR01Handler) ORU_R01(ca.uhn.hl7v2.model.v25.message.ORU_R01) NK1(ca.uhn.hl7v2.model.v25.segment.NK1) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 70 with PID

use of ca.uhn.hl7v2.model.v24.segment.PID in project openmrs-core by openmrs.

the class HL7ServiceTest method parseHL7String_shouldParseTheGivenStringIntoMessage.

/**
 * @throws HL7Exception
 * @see HL7Service#parseHL7String(String)
 */
@Test
public void parseHL7String_shouldParseTheGivenStringIntoMessage() 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" + "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");
    Assert.assertNotNull(message);
}
Also used : Message(ca.uhn.hl7v2.model.Message) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

Message (ca.uhn.hl7v2.model.Message)60 Test (org.junit.Test)60 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)60 ORU_R01 (ca.uhn.hl7v2.model.v25.message.ORU_R01)29 Patient (org.openmrs.Patient)26 NK1 (ca.uhn.hl7v2.model.v25.segment.NK1)22 Person (org.openmrs.Person)16 ORUR01Handler (org.openmrs.hl7.handler.ORUR01Handler)15 MSH (ca.uhn.hl7v2.model.v24.segment.MSH)14 Concept (org.openmrs.Concept)13 Obs (org.openmrs.Obs)13 ObsService (org.openmrs.api.ObsService)11 ADR_A19 (ca.uhn.hl7v2.model.v24.message.ADR_A19)10 MSA (ca.uhn.hl7v2.model.v24.segment.MSA)10 QRD (ca.uhn.hl7v2.model.v24.segment.QRD)10 Encounter (org.openmrs.Encounter)9 ADT_A01 (ca.uhn.hl7v2.model.v24.message.ADT_A01)8 PID (ca.uhn.hl7v2.model.v24.segment.PID)8 CX (ca.uhn.hl7v2.model.v25.datatype.CX)8 HL7Exception (ca.uhn.hl7v2.HL7Exception)7