use of ca.uhn.hl7v2.model.v25.message.ORU_R01 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");
}
use of ca.uhn.hl7v2.model.v25.message.ORU_R01 in project openmrs-core by openmrs.
the class HL7ServiceTest method processHL7InQueue_shouldParseOruR01MessageUsingOverriddenParserProvidedByAModule.
/**
* @see HL7Service#processHL7InQueue(HL7InQueue)
*/
@Test
@Ignore("TRUNK-3945")
public void processHL7InQueue_shouldParseOruR01MessageUsingOverriddenParserProvidedByAModule() throws Exception {
executeDataSet("org/openmrs/hl7/include/ORUTest-initialData.xml");
Properties props = super.getRuntimeProperties();
props.setProperty(ModuleConstants.RUNTIMEPROPERTY_MODULE_LIST_TO_LOAD, "org/openmrs/hl7/include/examplehl7handlers-0.1.omod");
// the above module provides a handler for messages of type "ADR" with trigger "A19"
ModuleUtil.startup(props);
// the application context cannot restart here to load in the moduleApplicationContext that
// calls the setHL7Handlers method so we're doing it manually here
Class<Application> c = (Class<Application>) Context.loadClass("org.openmrs.module.examplehl7handlers.AlternateORUR01Handler");
Application classInstance = c.newInstance();
HashMap<String, Application> map = new HashMap<>();
map.put("ORU_R01", classInstance);
HL7ServiceImpl.getInstance().setHL7Handlers(map);
HL7Service hl7service = Context.getHL7Service();
// a valid ORU_R01
HL7InQueue queueItem = hl7service.getHL7InQueue(1);
// this will create 1 HL7InError item
hl7service.processHL7InQueue(queueItem);
List<HL7InError> errors = hl7service.getAllHL7InErrors();
// get the last error, the one made by this test presumably
HL7InError error = errors.get(errors.size() - 1);
Assert.assertTrue(error.getErrorDetails().contains("In alternate oru r01 parser"));
ModuleUtil.shutdown();
}
use of ca.uhn.hl7v2.model.v25.message.ORU_R01 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.v25.message.ORU_R01 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);
}
Aggregations