Search in sources :

Example 16 with Provider

use of org.openmrs.Provider in project openmrs-core by openmrs.

the class ORUR01HandlerTest method processMessage_shouldCreateAnEncounterAndFindTheProviderByProviderId.

/**
 * @see ORUR01Handler#processMessage(Message)
 */
@Test
public void processMessage_shouldCreateAnEncounterAndFindTheProviderByProviderId() 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);
    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||||8^name^^^^^^^&" + HL7Constants.PROVIDER_ASSIGNING_AUTH_PROV_ID + "&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("1f9e8336-6b95-11e0-93c3-18a905e044dc", newProvider.getUuid());
}
Also used : 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 17 with Provider

use of org.openmrs.Provider in project openmrs-core by openmrs.

the class ORUR01HandlerTest method processMessage_shouldCreateAnEncounterAndFindTheProviderByIdentifier.

/**
 * @see ORUR01Handler#processMessage(Message)
 */
@Test
public void processMessage_shouldCreateAnEncounterAndFindTheProviderByIdentifier() 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);
    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||||8a760^name^^^^^^^&" + HL7Constants.PROVIDER_ASSIGNING_AUTH_IDENTIFIER + "&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);
    // retain only the new encounter
    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("a2c3868a-6b90-11e0-93c3-18a905e044dc", newProvider.getUuid());
}
Also used : 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 18 with Provider

use of org.openmrs.Provider 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 19 with Provider

use of org.openmrs.Provider in project openmrs-core by openmrs.

the class ProviderServiceTest method isProviderIdentifierUnique_shouldReturnTrueIfTheIdentifierIsNull.

/**
 * @see ProviderService#isProviderIdentifierUnique(Provider)
 */
@Test
public void isProviderIdentifierUnique_shouldReturnTrueIfTheIdentifierIsNull() {
    Provider provider = new Provider();
    Assert.assertTrue(service.isProviderIdentifierUnique(provider));
}
Also used : Provider(org.openmrs.Provider) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 20 with Provider

use of org.openmrs.Provider in project openmrs-core by openmrs.

the class ProviderServiceTest method purgeProvider_shouldDeleteAProvider.

/**
 * @see ProviderService#purgeProvider(Provider)
 */
@Test
public void purgeProvider_shouldDeleteAProvider() {
    Provider provider = service.getProvider(2);
    service.purgeProvider(provider);
    assertEquals(8, Context.getProviderService().getAllProviders().size());
}
Also used : Provider(org.openmrs.Provider) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

Provider (org.openmrs.Provider)49 Test (org.junit.Test)40 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)33 Encounter (org.openmrs.Encounter)16 Date (java.util.Date)12 Person (org.openmrs.Person)10 Patient (org.openmrs.Patient)9 EncounterType (org.openmrs.EncounterType)8 EncounterRole (org.openmrs.EncounterRole)7 Location (org.openmrs.Location)7 PersonName (org.openmrs.PersonName)6 TestOrder (org.openmrs.TestOrder)5 Message (ca.uhn.hl7v2.model.Message)4 Matchers.containsInAnyOrder (org.hamcrest.Matchers.containsInAnyOrder)4 DrugOrder (org.openmrs.DrugOrder)4 Order (org.openmrs.Order)4 OrderUtilTest (org.openmrs.order.OrderUtilTest)4 Criteria (org.hibernate.Criteria)3 Concept (org.openmrs.Concept)3 User (org.openmrs.User)3