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"));
}
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);*/
}
Aggregations