use of ca.uhn.hl7v2.model.v26.segment.PID in project openmrs-core by openmrs.
the class ORUR01HandlerTest method processNK1_shouldFailIfTheRelationshipIdentifierIsFormattedImproperly.
/**
* @see ORUR01Handler#processNK1(Patient,NK1)
*/
@Test(expected = HL7Exception.class)
public void processNK1_shouldFailIfTheRelationshipIdentifierIsFormattedImproperly() throws Exception {
// process a message with an invalid relationship identifier format
// the patient that is the focus of
Patient patient = new Patient(3);
// this hl7 message
String hl7String = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20090728170332||ORU^R01|gu99yBh4loLX2mh9cHaV|P|2.5|1||||||||4^AMRS.ELD.FORMID\r" + "PID|||3^^^^||Beren^John^Bondo||\r" + "NK1|1|Jones^Jane^Lee^^RN|3C^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;
List<NK1> nk1List = oruHandler.getNK1List(oru);
for (NK1 nk1 : nk1List) oruHandler.processNK1(patient, nk1);
}
use of ca.uhn.hl7v2.model.v26.segment.PID in project openmrs-core by openmrs.
the class ORUR01HandlerTest method processMessage_shouldCreateAnEncounterAndFindTheProviderByUuid.
/**
* @see ORUR01Handler#processMessage(Message)
*/
@Test
public void processMessage_shouldCreateAnEncounterAndFindTheProviderByUuid() throws Exception {
executeDataSet("org/openmrs/api/include/ProviderServiceTest-initial.xml");
int patientId = 2;
Patient patient = new Patient(patientId);
List<Encounter> encForPatient1 = Context.getEncounterService().getEncountersByPatient(patient);
ProviderService ps = Context.getProviderService();
Provider provider = ps.getProviderByIdentifier("8a760");
String hl7string = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080226102656||ORU^R01|JqnfhKKtouEz8kzTk6Zo|P|2.5|1||||||||16^AMRS.ELD.FORMID\r" + "PID|||" + patientId + "^^^^||Hornblower^Horatio^Test||\r" + "PV1||O|1^Unknown Location||||ba4781f4-6b94-11e0-93c3-18a905e044dc^name^^^^^^^&" + HL7Constants.PROVIDER_ASSIGNING_AUTH_PROV_UUID + "&L|||||||||||||||||||||||||||||||||||||20080212|||||||V\r" + "ORC|RE||||||||20080226102537|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT";
Message hl7message = parser.parse(hl7string);
router.processMessage(hl7message);
// check for the new encounter
List<Encounter> encForPatient2 = Context.getEncounterService().getEncountersByPatient(patient);
encForPatient2.removeAll(encForPatient1);
Assert.assertTrue(encForPatient2.size() == 1);
Provider newProvider = encForPatient2.get(0).getProvidersByRole(Context.getEncounterService().getEncounterRoleByUuid(EncounterRole.UNKNOWN_ENCOUNTER_ROLE_UUID)).iterator().next();
Assert.assertEquals(4, newProvider.getId().intValue());
}
use of ca.uhn.hl7v2.model.v26.segment.PID in project camel by apache.
the class AckExpressionTest method createADT01Message.
private static ADT_A01 createADT01Message() throws Exception {
ADT_A01 adt = new ADT_A01();
adt.initQuickstart("ADT", "A01", "P");
// Populate the PID Segment
PID pid = adt.getPID();
pid.getPatientName(0).getFamilyName().getSurname().setValue("Doe");
pid.getPatientName(0).getGivenName().setValue("John");
pid.getPatientIdentifierList(0).getID().setValue("123456");
return adt;
}
use of ca.uhn.hl7v2.model.v26.segment.PID in project camel by apache.
the class HL7RouteTest method createADR19Message.
// END SNIPPET: e2
private static Message createADR19Message() throws Exception {
ADR_A19 adr = new ADR_A19();
// Populate the MSH Segment
MSH mshSegment = adr.getMSH();
mshSegment.getFieldSeparator().setValue("|");
mshSegment.getEncodingCharacters().setValue("^~\\&");
mshSegment.getDateTimeOfMessage().getTimeOfAnEvent().setValue("200701011539");
mshSegment.getSendingApplication().getNamespaceID().setValue("MYSENDER");
mshSegment.getSequenceNumber().setValue("123");
mshSegment.getMessageType().getMessageType().setValue("ADR");
mshSegment.getMessageType().getTriggerEvent().setValue("A19");
// Populate the PID Segment
MSA msa = adr.getMSA();
msa.getAcknowledgementCode().setValue("AA");
msa.getMessageControlID().setValue("123");
QRD qrd = adr.getQRD();
qrd.getQueryDateTime().getTimeOfAnEvent().setValue("20080805120000");
return adr.getMessage();
}
use of ca.uhn.hl7v2.model.v26.segment.PID in project camel by apache.
the class MessageValidatorTest method doPreSetup.
@Override
protected void doPreSetup() throws Exception {
defaultValidationContext = ValidationContextFactory.defaultValidation();
defaultContext = new DefaultHapiContext(defaultValidationContext);
// we validate separately, not during parsing or rendering
defaultContext.getParserConfiguration().setValidating(false);
ValidationRuleBuilder builder = new ValidationRuleBuilder() {
private static final long serialVersionUID = 1L;
@Override
protected void configure() {
forVersion(Version.V24).message("ADT", "A01").terser("PID-8", not(empty()));
}
};
customValidationContext = ValidationContextFactory.fromBuilder(builder);
customContext = new DefaultHapiContext(customValidationContext);
// we validate separately, not during parsing or rendering
customContext.getParserConfiguration().setValidating(false);
}
Aggregations