Search in sources :

Example 61 with Message

use of com.google.api.services.healthcare.v1.model.Message 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);
}
Also used : Message(ca.uhn.hl7v2.model.Message) ORU_R01(ca.uhn.hl7v2.model.v25.message.ORU_R01) NK1(ca.uhn.hl7v2.model.v25.segment.NK1) Patient(org.openmrs.Patient) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 62 with Message

use of com.google.api.services.healthcare.v1.model.Message 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());
}
Also used : ProviderService(org.openmrs.api.ProviderService) Message(ca.uhn.hl7v2.model.Message) Patient(org.openmrs.Patient) Encounter(org.openmrs.Encounter) Provider(org.openmrs.Provider) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 63 with Message

use of com.google.api.services.healthcare.v1.model.Message in project kripton by xcesco.

the class MessageListResponseBindMap method serializeOnJacksonAsString.

@Override
public int serializeOnJacksonAsString(MessageListResponse object, JsonGenerator jacksonSerializer) throws Exception {
    jacksonSerializer.writeStartObject();
    int fieldCount = 0;
    // field detailMessage (mapped with "detailMessage")
    if (object.getDetailMessage() != null) {
        fieldCount++;
        jacksonSerializer.writeStringField("detailMessage", object.getDetailMessage());
    }
    // field list (mapped with "list")
    if (object.getList() != null) {
        fieldCount++;
        int n = object.getList().size();
        Message item;
        // write wrapper tag
        jacksonSerializer.writeFieldName("list");
        if (n > 0) {
            jacksonSerializer.writeStartArray();
            for (int i = 0; i < n; i++) {
                item = object.getList().get(i);
                if (item == null) {
                    jacksonSerializer.writeString("null");
                } else {
                    if (messageBindMap.serializeOnJacksonAsString(item, jacksonSerializer) == 0) {
                        jacksonSerializer.writeNullField("list");
                    }
                }
            }
            jacksonSerializer.writeEndArray();
        } else {
            jacksonSerializer.writeString("");
        }
    }
    // field status (mapped with "status")
    if (object.getStatus() != null) {
        fieldCount++;
        jacksonSerializer.writeStringField("status", object.getStatus().toString());
    }
    jacksonSerializer.writeEndObject();
    return fieldCount;
}
Also used : Message(bind.feature.generichierarchy.case1.model.Message)

Example 64 with Message

use of com.google.api.services.healthcare.v1.model.Message in project beam by apache.

the class HL7v2IOTestUtil method testMessage.

static Message testMessage(String name) {
    Message msg = new Message();
    msg.setName(name);
    return msg;
}
Also used : Message(com.google.api.services.healthcare.v1.model.Message)

Example 65 with Message

use of com.google.api.services.healthcare.v1.model.Message in project beam by apache.

the class HL7v2MessageCoder method decode.

@Override
public HL7v2Message decode(InputStream inStream) throws CoderException, IOException {
    Message msg = new Message();
    msg.setName(STRING_CODER.decode(inStream));
    msg.setMessageType(STRING_CODER.decode(inStream));
    msg.setCreateTime(STRING_CODER.decode(inStream));
    msg.setSendTime(STRING_CODER.decode(inStream));
    msg.setData(STRING_CODER.decode(inStream));
    msg.setSendFacility(STRING_CODER.decode(inStream));
    msg.setLabels(MAP_CODER.decode(inStream));
    HL7v2Message out = HL7v2Message.fromModel(msg);
    out.setSchematizedData(STRING_CODER.decode(inStream));
    return out;
}
Also used : Message(com.google.api.services.healthcare.v1.model.Message)

Aggregations

Message (ca.uhn.hl7v2.model.Message)114 Test (org.junit.Test)81 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)60 ORU_R01 (ca.uhn.hl7v2.model.v25.message.ORU_R01)30 NK1 (ca.uhn.hl7v2.model.v25.segment.NK1)21 Patient (org.openmrs.Patient)21 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)17 ORUR01Handler (org.openmrs.hl7.handler.ORUR01Handler)15 Person (org.openmrs.Person)14 ArrayList (java.util.ArrayList)13 HL7Exception (ca.uhn.hl7v2.HL7Exception)12 Concept (org.openmrs.Concept)12 Obs (org.openmrs.Obs)12 ObsService (org.openmrs.api.ObsService)11 QRD (ca.uhn.hl7v2.model.v24.segment.QRD)9 IOException (java.io.IOException)8 Encounter (org.openmrs.Encounter)8 RouteBuilder (org.apache.camel.builder.RouteBuilder)7 Structure (ca.uhn.hl7v2.model.Structure)5 CX (ca.uhn.hl7v2.model.v25.datatype.CX)5