Search in sources :

Example 11 with EncounterService

use of org.openmrs.api.EncounterService 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)

Aggregations

EncounterService (org.openmrs.api.EncounterService)11 Encounter (org.openmrs.Encounter)9 Patient (org.openmrs.Patient)6 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 Order (org.openmrs.Order)3 OrderService (org.openmrs.api.OrderService)3 EncounterSearchCriteria (org.openmrs.parameter.EncounterSearchCriteria)3 EncounterSearchCriteriaBuilder (org.openmrs.parameter.EncounterSearchCriteriaBuilder)3 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)3 EncounterType (org.openmrs.EncounterType)2 Person (org.openmrs.Person)2 User (org.openmrs.User)2 ConceptService (org.openmrs.api.ConceptService)2 PatientService (org.openmrs.api.PatientService)2 VisitService (org.openmrs.api.VisitService)2 Message (ca.uhn.hl7v2.model.Message)1 Date (java.util.Date)1 List (java.util.List)1 ConceptProposal (org.openmrs.ConceptProposal)1