Search in sources :

Example 1 with RadiologyOrder

use of org.openmrs.module.radiologyapp.RadiologyOrder in project openmrs-module-mirebalais by PIH.

the class RadiologyOrderNumberGeneratorComponentTest method shouldGenerateRadiologyOrderNumber.

@Test
public void shouldGenerateRadiologyOrderNumber() {
    // new test order
    Order order = new RadiologyOrder();
    order.setEncounter(encounterService.getEncounter(6));
    order.setPatient(patientService.getPatient(7));
    order.setConcept(conceptService.getConcept(5497));
    order.setOrderer(providerService.getProvider(1));
    order.setCareSetting(orderService.getCareSetting(1));
    order.setOrderType(orderService.getOrderType(1001));
    order.setEncounter(encounterService.getEncounter(3));
    order.setDateActivated(new Date());
    OrderContext orderContext = new OrderContext();
    orderContext.setOrderType(orderService.getOrderType(1001));
    order = orderService.saveOrder(order, orderContext);
    assertThat(order.getOrderNumber(), is("0000000125"));
}
Also used : RadiologyOrder(org.openmrs.module.radiologyapp.RadiologyOrder) TestOrder(org.openmrs.TestOrder) Order(org.openmrs.Order) RadiologyOrder(org.openmrs.module.radiologyapp.RadiologyOrder) Date(java.util.Date) OrderContext(org.openmrs.api.OrderContext) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 2 with RadiologyOrder

use of org.openmrs.module.radiologyapp.RadiologyOrder in project openmrs-module-mirebalais by PIH.

the class MirthIT method testMirthChannelIntegration.

@Test
@DirtiesContext
public void testMirthChannelIntegration() throws Exception {
    authenticate();
    // if the test patient already exists, delete it and any existing orders
    if (patientService.getPatients("2ADMMN").size() > 0) {
        Patient patient = patientService.getPatients("2ADMMN").get(0);
        for (Order order : orderService.getAllOrdersByPatient(patient)) {
            orderService.purgeOrder(order);
        }
        for (Encounter encounter : encounterService.getEncountersByPatient(patient)) {
            encounterService.purgeEncounter(encounter);
        }
        for (Visit visit : visitService.getVisitsByPatient(patient)) {
            visitService.purgeVisit(visit);
        }
        patientService.purgePatient(patient);
    }
    // TODO: eventually we should make sure all the necessary fields are included here
    // first create and save a patient
    Patient patient = new Patient();
    patient.setGender("M");
    Calendar birthdate = Calendar.getInstance();
    birthdate.set(2000, 2, 23);
    patient.setBirthdate(birthdate.getTime());
    PersonName name = new PersonName();
    name.setFamilyName("Test Patient");
    name.setGivenName("Mirth Integration");
    patient.addName(name);
    PatientIdentifier identifier = new PatientIdentifier();
    identifier.setIdentifierType(emrApiProperties.getPrimaryIdentifierType());
    identifier.setIdentifier("2ADMMN");
    identifier.setPreferred(true);
    identifier.setLocation(locationService.getLocation("Unknown Location"));
    patient.addIdentifier(identifier);
    // save the patient
    patientService.savePatient(patient);
    /**
     *  Commenting this out because we are not currently sending ADT information to APCS
     *		String result = listenForResults();
     *
     *		System.out.println(result);
     *
     *		// make sure the appropriate message has been delivered
     *		TestUtils.assertContains("MSH|^~\\&|||||||ADT^A01||P|2.3", result);
     *		TestUtils.assertContains("PID|||2ADMMN||Test Patient^Mirth Integration||200003230000|M", result);
     *
     *		// now resave the patient and verify that a patient updated message is sent
     *		// save the patient to trigger an update event
     *		patientService.savePatient(patient);
     *
     *		result = listenForResults();
     *
     *		System.out.println(result);
     *
     *		TestUtils.assertContains("MSH|^~\\&|||||||ADT^A08||P|2.3", result);
     *		TestUtils.assertContains("PID|||2ADMMN||Test Patient^Mirth Integration||200003230000|M", result);
     */
    // TODO: eventually we should make sure all the necessary fields are concluded here
    // TODO: specifically: sending facility, device location, universal service id, universal service id text, and modality
    // ensure that there is a visit for the patient (so that the encounter visit handlers doesn't bomb)
    adtService.ensureActiveVisit(patient, locationService.getLocation("Mirebalais Hospital"));
    // now create and save the order for this patient
    RadiologyOrder order = new RadiologyOrder();
    order.setOrderType(orderService.getOrderTypeByUuid(administrationService.getGlobalProperty(RadiologyConstants.GP_RADIOLOGY_TEST_ORDER_TYPE)));
    order.setPatient(patient);
    // chest x-ray, one view
    order.setConcept(conceptService.getConceptByUuid("fc6de1c0-1a36-11e2-a310-aa00f871a3e1"));
    order.setAccessionNumber("ACCESSION NUMBER");
    order.setDateActivated(new SimpleDateFormat("MM-dd-yyyy").parse("09-09-2012"));
    order.setUrgency(Order.Urgency.STAT);
    order.setClinicalHistory("Patient fell off horse");
    order.setExamLocation(locationService.getLocation("Mirebalais Hospital"));
    Encounter encounter = new Encounter();
    encounter.setPatient(patient);
    encounter.setEncounterDatetime(new Date());
    encounter.setLocation(locationService.getLocation("Mirebalais Hospital"));
    encounter.setEncounterType(encounterService.getEncounterType(1));
    encounter.addOrder(order);
    encounter.addProvider(emrApiProperties.getOrderingProviderEncounterRole(), Context.getProviderService().getProvider(1));
    encounterService.saveEncounter(encounter);
// TODO: I've changed the configuration so that this sends the message directly to the PACS test server
// TODO: since we aren't getting messages send back from PACS yet, there is no good way to test this
/*String result = listenForResults();
		
		TestUtils.assertContains("MSH|^~\\&||Mirebalais|||||ORM^O01||P|2.3", result);
		TestUtils.assertContains("PID|||2ADMMN||Test Patient^Mirth Integration||200003230000|M", result);
		TestUtils.assertContains("PV1|||Mirebalais Hospital|||||^User^Super", result);
		TestUtils.assertContains("ORC|NW", result);
		TestUtils
		        .assertContains(
		            "OBR|||ACCESSION NUMBER|36554-4^X-ray of chest, 1 view|||||||||||||||CR||||||||^^^^^STAT||||^Patient fell off horse|||||201209090000",
		            result);*/
}
Also used : RadiologyOrder(org.openmrs.module.radiologyapp.RadiologyOrder) Order(org.openmrs.Order) PersonName(org.openmrs.PersonName) Visit(org.openmrs.Visit) Calendar(java.util.Calendar) RadiologyOrder(org.openmrs.module.radiologyapp.RadiologyOrder) Patient(org.openmrs.Patient) Encounter(org.openmrs.Encounter) SimpleDateFormat(java.text.SimpleDateFormat) PatientIdentifier(org.openmrs.PatientIdentifier) Date(java.util.Date) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Aggregations

Date (java.util.Date)2 Test (org.junit.Test)2 Order (org.openmrs.Order)2 RadiologyOrder (org.openmrs.module.radiologyapp.RadiologyOrder)2 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Calendar (java.util.Calendar)1 Encounter (org.openmrs.Encounter)1 Patient (org.openmrs.Patient)1 PatientIdentifier (org.openmrs.PatientIdentifier)1 PersonName (org.openmrs.PersonName)1 TestOrder (org.openmrs.TestOrder)1 Visit (org.openmrs.Visit)1 OrderContext (org.openmrs.api.OrderContext)1 DirtiesContext (org.springframework.test.annotation.DirtiesContext)1