use of org.openmrs.PatientIdentifier in project openmrs-module-mirebalais by PIH.
the class WristbandTemplateTest method testWristBandTemplate.
@Test
public void testWristBandTemplate() {
Date today = new Date();
visitLocation.setName("Hôpital Universitaire de Mirebalais");
Patient patient = new Patient();
patient.setGender("M");
patient.setBirthdate(new DateTime(1940, 7, 7, 5, 5, 5).toDate());
PatientIdentifier primaryIdentifier = new PatientIdentifier();
primaryIdentifier.setIdentifier("ZL1234");
primaryIdentifier.setIdentifierType(primaryIdentifierType);
primaryIdentifier.setVoided(false);
patient.addIdentifier(primaryIdentifier);
PatientIdentifier paperRecordIdentifier = new PatientIdentifier();
paperRecordIdentifier.setIdentifier("A000005");
paperRecordIdentifier.setIdentifierType(paperRecordIdentifierType);
paperRecordIdentifier.setVoided(false);
paperRecordIdentifier.setLocation(visitLocation);
patient.addIdentifier(paperRecordIdentifier);
PersonAddress address = new PersonAddress();
address.setAddress2("Avant Eglise Chretienne des perlerlerin de la siant tete de moliere");
address.setAddress1("Saut D'Eau");
address.setAddress3("1ere Riviere Canot");
address.setCityVillage("Saut d'Eau");
address.setStateProvince("Centre");
patient.addAddress(address);
PersonName name = new PersonName();
name.setGivenName("Ringo");
name.setFamilyName("Starr");
patient.addName(name);
when(messageSourceService.getMessage("coreapps.ageYears", Collections.singletonList(patient.getAge()).toArray(), locale)).thenReturn(patient.getAge() + " an(s)");
String output = wristbandTemplate.generateWristband(patient, visitLocation);
assertThat(output, containsString("^XA^CI28^MTD^FWB"));
assertThat(output, containsString("^FO050,200^FB2150,1,0,L,0^AS^FDHôpital Universitaire de Mirebalais " + df.format(today) + "^FS"));
assertThat(output, containsString("^FO100,200^FB2150,1,0,L,0^AU^FDRingo Starr^FS"));
assertThat(output, containsString("^FO160,200^FB2150,1,0,L,0^AU^FD07 juil. 1940^FS"));
assertThat(output, containsString("^FO160,200^FB1850,1,0,L,0^AT^FD" + patient.getAge() + " an(s)^FS"));
assertThat(output, containsString("^FO160,200^FB1650,1,0,L,0^AU^FDMasculin A 000005^FS"));
assertThat(output, containsString("^FO220,200^FB2150,1,0,L,0^AS^FDAvant Eglise Chretienne des perlerlerin de la siant tete de moliere^FS"));
assertThat(output, containsString("^FO270,200^FB2150,1,0,L,0^AS^FDSaut D'Eau, 1ere Riviere Canot, Saut d'Eau, Centre^FS"));
assertThat(output, containsString("^FO100,2400^AT^BY4^BC,150,N^FDZL1234^XZ"));
}
use of org.openmrs.PatientIdentifier in project openmrs-module-mirebalais by PIH.
the class WristbandTemplateTest method testEstimatedBirthDate.
@Test
public void testEstimatedBirthDate() {
visitLocation.setName("Hôpital Universitaire de Mirebalais");
Patient patient = new Patient();
patient.setGender("M");
patient.setBirthdate(new DateTime(1940, 7, 7, 5, 5, 5).toDate());
patient.setBirthdateEstimated(true);
PatientIdentifier primaryIdentifier = new PatientIdentifier();
primaryIdentifier.setIdentifier("ZL1234");
primaryIdentifier.setIdentifierType(primaryIdentifierType);
primaryIdentifier.setVoided(false);
patient.addIdentifier(primaryIdentifier);
PatientIdentifier paperRecordIdentifier = new PatientIdentifier();
paperRecordIdentifier.setIdentifier("A00005");
paperRecordIdentifier.setIdentifierType(paperRecordIdentifierType);
paperRecordIdentifier.setVoided(false);
patient.addIdentifier(paperRecordIdentifier);
PersonName name = new PersonName();
name.setGivenName("Ringo");
name.setFamilyName("Starr");
patient.addName(name);
String output = wristbandTemplate.generateWristband(patient, new Location());
assertThat(output, containsString("^FO160,200^FB2150,1,0,L,0^AU^FD1940^FS"));
}
use of org.openmrs.PatientIdentifier in project openmrs-module-pihcore by PIH.
the class WristbandTemplateTest method testWristBandTemplate.
@Test
public void testWristBandTemplate() {
Date today = new Date();
visitLocation.setName("Mirebalais");
Patient patient = new Patient();
patient.setGender("M");
patient.setBirthdate(new DateTime(1940, 7, 7, 5, 5, 5).toDate());
PatientIdentifier primaryIdentifier = new PatientIdentifier();
primaryIdentifier.setIdentifier("ZL1234");
primaryIdentifier.setIdentifierType(primaryIdentifierType);
primaryIdentifier.setVoided(false);
patient.addIdentifier(primaryIdentifier);
PatientIdentifier paperRecordIdentifier = new PatientIdentifier();
paperRecordIdentifier.setIdentifier("A000005");
paperRecordIdentifier.setIdentifierType(paperRecordIdentifierType);
paperRecordIdentifier.setVoided(false);
paperRecordIdentifier.setLocation(visitLocation);
patient.addIdentifier(paperRecordIdentifier);
PersonAddress address = new PersonAddress();
address.setAddress2("Avant Eglise Chretienne des perlerlerin de la siant tete de moliere");
address.setAddress1("Saut D'Eau");
address.setAddress3("1ere Riviere Canot");
address.setCityVillage("Saut d'Eau");
address.setStateProvince("Centre");
patient.addAddress(address);
PersonName name = new PersonName();
name.setGivenName("Ringo");
name.setFamilyName("Starr");
patient.addName(name);
when(messageSourceService.getMessage("coreapps.ageYears", Collections.singletonList(patient.getAge()).toArray(), locale)).thenReturn(patient.getAge() + " an(s)");
String output = wristbandTemplate.generateWristband(patient, visitLocation);
assertThat(output, containsString("^XA^CI28^MTD^FWB"));
assertThat(output, containsString("^FO050,200^FB2150,1,0,L,0^AS^FDMirebalais " + df.format(today) + "^FS"));
assertThat(output, containsString("^FO100,200^FB2150,1,0,L,0^AU^FDRingo Starr^FS"));
assertThat(output, containsString("^FO160,200^FB2150,1,0,L,0^AU^FD07 juil. 1940^FS"));
assertThat(output, containsString("^FO160,200^FB1850,1,0,L,0^AT^FD" + patient.getAge() + " an(s)^FS"));
assertThat(output, containsString("^FO160,200^FB1650,1,0,L,0^AU^FDMasculin A 000005^FS"));
assertThat(output, containsString("^FO220,200^FB2150,1,0,L,0^AS^FDAvant Eglise Chretienne des perlerlerin de la siant tete de moliere^FS"));
assertThat(output, containsString("^FO270,200^FB2150,1,0,L,0^AS^FDSaut D'Eau, 1ere Riviere Canot, Saut d'Eau, Centre^FS"));
assertThat(output, containsString("^FO100,2400^AT^BY4^BC,150,N^FDZL1234^XZ"));
}
use of org.openmrs.PatientIdentifier in project openmrs-module-pihcore by PIH.
the class ZplLabLabelTemplateTest method shouldGenerateLabel.
@Test
public void shouldGenerateLabel() {
Patient patient = new Patient();
PersonName name = new PersonName();
name.setGivenName("Mark");
name.setFamilyName("Goodrich");
patient.addName(name);
PatientIdentifier patientIdentifier = new PatientIdentifier();
patientIdentifier.setIdentifier("YXB123");
patientIdentifier.setIdentifierType(primaryIdentifierType);
patient.addIdentifier(patientIdentifier);
String data = template.generateLabel(patient);
String expectedDate = new SimpleDateFormat("dd MMM yyyy hh:mm aaa").format(new Date());
assertThat(data, is("^XA^CI28^PW650^MTT^FO30,20^ARN^FDMark Goodrich ^FS^FO30,50^ATN^BY2,2,50^BCN^FDYXB123^FS^FO300,110^ARN^FD" + expectedDate + "^FS^XZ"));
}
use of org.openmrs.PatientIdentifier in project openmrs-module-pihcore by PIH.
the class DrugOrdersPageController method get.
public void get(PageModel model, UiUtils ui, @InjectBeans PatientDomainWrapper patientDomainWrapper, @RequestParam(required = false, value = "patient") Patient patient, @RequestParam(required = false, value = "hivemrId") String hivemrId, @SpringBean("conceptService") ConceptService conceptService, @SpringBean("patientService") PatientService patientService, @SpringBean("orderService") OrderService orderService, @SpringBean("obsService") ObsService obsService) throws IOException {
if (patient == null) {
PatientIdentifierType hivemrV1 = patientService.getPatientIdentifierTypeByUuid(ZlConfigConstants.PATIENTIDENTIFIERTYPE_HIVEMRV1_UUID);
List<PatientIdentifier> idList = patientService.getPatientIdentifiers(hivemrId, Arrays.asList(hivemrV1), null, null, null);
if (idList.isEmpty()) {
throw new IllegalArgumentException("No patients found with identifier: " + hivemrId);
}
if (idList.size() > 1) {
throw new IllegalArgumentException(idList.size() + " patients found with identifier: " + hivemrId);
}
patient = idList.get(0).getPatient();
}
// Get all of the drug orders for the patient
List<DrugOrder> drugOrders = new ArrayList<>();
for (Order order : orderService.getAllOrdersByPatient(patient)) {
order = HibernateUtil.getRealObjectFromProxy(order);
if (order instanceof DrugOrder && BooleanUtils.isNotTrue(order.getVoided())) {
DrugOrder drugOrder = (DrugOrder) order;
drugOrders.add(drugOrder);
}
}
// Sort these drug orders in chronological order
Collections.sort(drugOrders, (d1, d2) -> {
// Get all of the previous orders for d1. If any are d2, then d1 is later
for (Order d1Prev = d1.getPreviousOrder(); d1Prev != null; d1Prev = d1Prev.getPreviousOrder()) {
if (d1Prev.equals(d2)) {
return 1;
}
}
// Get all of the previous orders for d2. If any are d1, then d2 is later
for (Order d2Prev = d2.getPreviousOrder(); d2Prev != null; d2Prev = d2Prev.getPreviousOrder()) {
if (d2Prev.equals(d1)) {
return -1;
}
}
// If neither is a revision of the other, then compare based on effective start date
int dateCompare = d1.getEffectiveStartDate().compareTo(d2.getEffectiveStartDate());
if (dateCompare != 0) {
return dateCompare;
}
// If they are still the same, then order based on end date
int ret = OpenmrsUtil.compareWithNullAsLatest(d1.getEffectiveStopDate(), d2.getEffectiveStopDate());
if (ret == 0) {
// Finally, order based on orderId
ret = d1.getOrderId().compareTo(d2.getOrderId());
}
return ret;
});
/*
TODO: For now we will organize these by order reason, as this is the way they are being migrated in
from the HIV EMR. Once we have established concept sets for organizing orderables by areas we can adjust
to organize in that way. We'll keep our model generic (based on string category names) to allow for this
We also remove the discontinue orders and associate them back with the orders they discontinue in a map so that
we can organize them together in a single row.
*/
List<Concept> categories = new ArrayList<>();
// HIV
categories.add(conceptService.getConceptByUuid("138405AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"));
// TB
categories.add(conceptService.getConceptByUuid("3ccca7cc-26fe-102b-80cb-0017a47871b2"));
// PTME
categories.add(conceptService.getConceptByUuid("160538AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"));
// Prophylaxis
categories.add(conceptService.getConceptByUuid("1691AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"));
List<DrugOrder> activeOrders = new ArrayList<>();
List<DrugOrder> completedOrders = new ArrayList<>();
Map<String, List<DrugOrder>> activeOrdersByCategory = new LinkedHashMap<>();
Map<String, List<DrugOrder>> completedOrdersByCategory = new LinkedHashMap<>();
Map<DrugOrder, DrugOrder> ordersToDiscontinueOrders = new HashMap<>();
for (Concept category : categories) {
activeOrdersByCategory.put(category.getDisplayString(), new ArrayList<>());
completedOrdersByCategory.put(category.getDisplayString(), new ArrayList<>());
}
activeOrdersByCategory.put("", new ArrayList<>());
completedOrdersByCategory.put("", new ArrayList<>());
for (DrugOrder d : drugOrders) {
if (d.getAction() == Order.Action.DISCONTINUE) {
ordersToDiscontinueOrders.put((DrugOrder) d.getPreviousOrder(), d);
} else {
String category = "";
if (d.getOrderReason() != null && categories.contains(d.getOrderReason())) {
category = d.getOrderReason().getDisplayString();
}
if (d.isActive()) {
activeOrders.add(d);
activeOrdersByCategory.get(category).add(d);
} else {
completedOrders.add(d);
completedOrdersByCategory.get(category).add(d);
}
}
}
// In the legacy HIV EMR, we supported entering notes/comments about a patient's medications. Include those here.
Concept medicationComments = conceptService.getConceptByMapping("10637", "PIH");
List<Obs> medicationCommentObs = obsService.getObservationsByPersonAndConcept(patient, medicationComments);
medicationCommentObs.sort((obs, t1) -> t1.getObsDatetime().compareTo(obs.getObsDatetime()));
patientDomainWrapper.setPatient(patient);
model.addAttribute("patient", patientDomainWrapper);
model.addAttribute("drugOrders", drugOrders);
model.addAttribute("categories", categories);
model.addAttribute("activeOrders", activeOrders);
model.addAttribute("completedOrders", completedOrders);
model.addAttribute("activeOrdersByCategory", activeOrdersByCategory);
model.addAttribute("completedOrdersByCategory", completedOrdersByCategory);
model.addAttribute("ordersToDiscontinueOrders", ordersToDiscontinueOrders);
model.addAttribute("medicationCommentObs", medicationCommentObs);
}
Aggregations