Search in sources :

Example 11 with CWE

use of ca.uhn.hl7v2.model.v25.datatype.CWE in project openmrs-core by openmrs.

the class ORUR01HandlerTest method processNK1_shouldCreateAPersonIfTheRelativeIsNotFound.

/**
 * @see ORUR01Handler#processNK1(Patient,NK1)
 */
@Test
public void processNK1_shouldCreateAPersonIfTheRelativeIsNotFound() throws Exception {
    // process a message with an invalid relative identifier
    PersonService personService = Context.getPersonService();
    // 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|3A^Parent^99REL||||||||||||F|19751016|||||||||||||||||2178037d-f86b-4f12-8d8b-be3ebc220029^^^UUID^v4\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);
    // find the relative in the database
    Person relative = personService.getPersonByUuid("2178037d-f86b-4f12-8d8b-be3ebc220029");
    Assert.assertNotNull("a new person was not created", relative);
    // see if the relative made it into the relationship properly
    List<Relationship> rels = personService.getRelationships(relative, patient, new RelationshipType(3));
    Assert.assertTrue("new relationship was not created", !rels.isEmpty() && rels.size() == 1);
}
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) PersonService(org.openmrs.api.PersonService) Relationship(org.openmrs.Relationship) RelationshipType(org.openmrs.RelationshipType) Patient(org.openmrs.Patient) Person(org.openmrs.Person) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 12 with CWE

use of ca.uhn.hl7v2.model.v25.datatype.CWE 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 13 with CWE

use of ca.uhn.hl7v2.model.v25.datatype.CWE in project openmrs-core by openmrs.

the class ORUR01Handler method getConceptName.

/**
 * Derive a concept name from the CWE component of an hl7 message.
 *
 * @param cwe
 * @return
 * @throws HL7Exception
 */
private ConceptName getConceptName(CWE cwe) throws HL7Exception {
    ST altIdentifier = cwe.getAlternateIdentifier();
    ID altCodingSystem = cwe.getNameOfAlternateCodingSystem();
    return getConceptName(altIdentifier, altCodingSystem);
}
Also used : ST(ca.uhn.hl7v2.model.v25.datatype.ST) ID(ca.uhn.hl7v2.model.v25.datatype.ID) PID(ca.uhn.hl7v2.model.v25.segment.PID)

Example 14 with CWE

use of ca.uhn.hl7v2.model.v25.datatype.CWE in project openmrs-core by openmrs.

the class ORUR01HandlerTest method processMessage_shouldNotCreateProblemListObservationWithConceptProposals.

/**
 * Tests that a ConceptProposal row can be written by the processor
 *
 * @see ORUR01Handler#processMessage(Message)
 */
@Test
public void processMessage_shouldNotCreateProblemListObservationWithConceptProposals() throws Exception {
    ObsService obsService = Context.getObsService();
    ConceptService conceptService = Context.getConceptService();
    EncounterService encService = Context.getEncounterService();
    String hl7String = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080630094800||ORU^R01|kgWdFt0SVwwClOfJm3pe|P|2.5|1||||||||15^AMRS.ELD.FORMID\r" + "PID|||3^^^^~d3811480^^^^||John3^Doe^||\r" + "PV1||O|1^Unknown||||1^Super User (admin)|||||||||||||||||||||||||||||||||||||20080208|||||||V\r" + "ORC|RE||||||||20080208000000|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBR|1|||1284^PROBLEM LIST^99DCT\r" + "OBX|1|CWE|6042^PROBLEM ADDED^99DCT||PROPOSED^SEVERO DOLOR DE CABEZA^99DCT|||||||||20080208";
    Message hl7message = parser.parse(hl7String);
    router.processMessage(hl7message);
    Patient patient = new Patient(3);
    // check for any obs
    assertEquals("There should not be any obs created for #3", 0, obsService.getObservationsByPerson(patient).size());
    // check for a new encounter
    assertEquals("There should be 1 new encounter created for #3", 1, encService.getEncountersByPatient(patient).size());
    // check for the proposed concept
    List<ConceptProposal> proposedConcepts = conceptService.getConceptProposals("SEVERO DOLOR DE CABEZA");
    assertEquals("There should be a proposed concept by this name", 1, proposedConcepts.size());
    assertEquals(encService.getEncountersByPatient(patient).get(0), proposedConcepts.get(0).getEncounter());
}
Also used : Message(ca.uhn.hl7v2.model.Message) ConceptProposal(org.openmrs.ConceptProposal) Patient(org.openmrs.Patient) ObsService(org.openmrs.api.ObsService) ConceptService(org.openmrs.api.ConceptService) EncounterService(org.openmrs.api.EncounterService) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 15 with CWE

use of ca.uhn.hl7v2.model.v25.datatype.CWE in project openmrs-core by openmrs.

the class ORUR01HandlerTest method processMessage_shouldCreateBasicConceptProposal.

/**
 * Should create a concept proposal because of the key string in the message
 *
 * @see ORUR01Handler#processMessage(Message)
 */
@Test
public void processMessage_shouldCreateBasicConceptProposal() throws Exception {
    // remember initial occurrence of proposal's text in the model
    int initialOccurrences = Context.getConceptService().getConceptProposals("PELVIC MASS").size();
    String hl7string = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080924022306||ORU^R01|Z185fTD0YozQ5kvQZD7i|P|2.5|1||||||||3^AMRS.ELD.FORMID\r" + "PID|||7^^^^||Joe^S^Mith||\r" + "PV1||O|1^Unknown Module 2||||1^Joe (1-1)|||||||||||||||||||||||||||||||||||||20080212|||||||V\r" + "ORC|RE||||||||20080219085345|1^Joe\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBX|18|DT|5096^RETURN VISIT DATE^99DCT||20080506|||||||||20080212\r" + "OBR|19|||1284^PROBLEM LIST^99DCT\r" + "OBX|1|CWE|6042^PROBLEM ADDED^99DCT||PROPOSED^PELVIC MASS^99DCT|||||||||20080212";
    Message hl7message = parser.parse(hl7string);
    router.processMessage(hl7message);
    // make sure that the proposal was added
    Assert.assertEquals("Processing of the HL7 message did not result in the new proposal being added to the model", initialOccurrences + 1, Context.getConceptService().getConceptProposals("PELVIC MASS").size());
}
Also used : Message(ca.uhn.hl7v2.model.Message) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

Message (ca.uhn.hl7v2.model.Message)16 Test (org.junit.Test)16 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)16 Patient (org.openmrs.Patient)10 ORU_R01 (ca.uhn.hl7v2.model.v25.message.ORU_R01)8 NK1 (ca.uhn.hl7v2.model.v25.segment.NK1)6 RelationshipType (org.openmrs.RelationshipType)5 Relationship (org.openmrs.Relationship)4 PersonService (org.openmrs.api.PersonService)4 Concept (org.openmrs.Concept)3 Obs (org.openmrs.Obs)3 ObsService (org.openmrs.api.ObsService)3 ST (ca.uhn.hl7v2.model.v25.datatype.ST)2 Date (java.util.Date)2 ConceptName (org.openmrs.ConceptName)2 Form (org.openmrs.Form)2 HL7Exception (ca.uhn.hl7v2.HL7Exception)1 Type (ca.uhn.hl7v2.model.Type)1 Varies (ca.uhn.hl7v2.model.Varies)1 CE (ca.uhn.hl7v2.model.v25.datatype.CE)1