use of org.openmrs.PatientIdentifierType in project openmrs-module-mirebalais by PIH.
the class ZlEmrIdCardPrinter method getIdentifier.
/**
* @return the patient identifier in the format that it should be displayed on the id cards
*/
protected String getIdentifier(Patient patient) {
PatientIdentifierType idType = emrApiProperties.getPrimaryIdentifierType();
PatientIdentifier pi = patient.getPatientIdentifier(idType);
if (pi == null || pi.isVoided()) {
pi = patient.getPatientIdentifier();
}
return pi == null ? "" : pi.getIdentifier();
}
use of org.openmrs.PatientIdentifierType in project openmrs-module-mirebalais by PIH.
the class LegacyMasterPatientIndexSetup method setupConnectionToMasterPatientIndex.
public static void setupConnectionToMasterPatientIndex(RuntimeProperties customProperties) {
String url = customProperties.getLacollineServerUrl();
String username = customProperties.getLacollineUsername();
String password = customProperties.getLacollinePassword();
if (url == null || username == null || password == null) {
log.warn("Not configuring link to Lacolline server (url, username, and password are required)");
return;
}
Map<String, PatientIdentifierType> identifierTypeMap = new HashMap<String, PatientIdentifierType>();
identifierTypeMap.put("a541af1e-105c-40bf-b345-ba1fd6a59b85", MetadataUtils.existing(PatientIdentifierType.class, PihHaitiPatientIdentifierTypes.ZL_EMR_ID.uuid()));
// TODO create PatientIdentifierType for Lacolline KE dossier number
identifierTypeMap.put("e66645eb-03a8-4991-b4ce-e87318e37566", MetadataUtils.existing(PatientIdentifierType.class, PihHaitiPatientIdentifierTypes.EXTERNAL_DOSSIER_NUMBER.uuid()));
// TODO create PatientIdentifierType for Lacolline dental dossier number
Map<String, Location> locationMap = new HashMap<String, Location>();
locationMap.put("23e7bb0d-51f9-4d5f-b34b-2fbbfeea1960", Context.getLocationService().getLocationByUuid(MirebalaisConstants.LACOLLINE_LOCATION_UUID));
Map<String, PersonAttributeType> attributeTypeMap = new HashMap<String, PersonAttributeType>();
attributeTypeMap.put("340d04c4-0370-102d-b0e3-001ec94a0cc1", MetadataUtils.existing(PersonAttributeType.class, HaitiPersonAttributeTypes.TELEPHONE_NUMBER.uuid()));
RemoteServerConfiguration config = new RemoteServerConfiguration();
config.setUrl(url);
config.setUsername(username);
config.setPassword(password);
config.setIdentifierTypeMap(identifierTypeMap);
config.setLocationMap(locationMap);
config.setAttributeTypeMap(attributeTypeMap);
Context.getService(ImportPatientFromWebService.class).registerRemoteServer("lacolline", config);
}
use of org.openmrs.PatientIdentifierType in project openmrs-module-mirebalais by PIH.
the class PaperRecordServiceIT method shouldCreateTwoDifferentDossierNumbers.
@Test
@DirtiesContext
public void shouldCreateTwoDifferentDossierNumbers() throws Exception {
authenticate();
PatientIdentifierType patientIdentifierType = Context.getPatientService().getPatientIdentifierTypeByUuid("e66645eb-03a8-4991-b4ce-e87318e37566");
when(paperRecordProperties.getPaperRecordIdentifierType()).thenReturn(patientIdentifierType);
Location location = new Location(15);
LocationTag locationTag = new LocationTag(15);
locationTag.setName("tag");
location.addTag(locationTag);
when(paperRecordProperties.getMedicalRecordLocationLocationTag()).thenReturn(locationTag);
PaperRecord paperRecord1 = ((PaperRecordServiceImpl) paperRecordService).createPaperRecord(new Patient(), location);
assertTrue(paperRecord1.getPatientIdentifier().getIdentifier().matches("A\\d{6}"));
PaperRecord paperRecord2 = ((PaperRecordServiceImpl) paperRecordService).createPaperRecord(new Patient(), location);
assertTrue(paperRecord2.getPatientIdentifier().getIdentifier().matches("A\\d{6}"));
assertThat(paperRecord1.getPatientIdentifier().getIdentifier(), not(paperRecord2.getPatientIdentifier().getIdentifier()));
}
use of org.openmrs.PatientIdentifierType 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);
}
use of org.openmrs.PatientIdentifierType in project openmrs-module-pihcore by PIH.
the class VitalsListPageController method get.
public String get(PageModel model, UiUtils ui, @SpringBean("encounterService") EncounterService encounterService, @SpringBean("patientService") PatientService patientService, @SpringBean Config config) throws IOException {
// TODO restrict by location at some point if necessary
ResourceFactory resourceFactory = ResourceFactory.getInstance();
Map<Patient, Encounter> patientsWithCheckInEncounter = new LinkedHashMap<Patient, Encounter>();
// all patients that have a check-in encounter today, but no vitals encounter
List<Encounter> checkInEncounters = encounterService.getEncounters(null, null, new DateMidnight().toDate(), null, null, Collections.singletonList(Metadata.lookupEncounterType(PihEmrConfigConstants.ENCOUNTERTYPE_CHECK_IN_UUID)), null, null, null, false);
List<Encounter> vitalsEncounters = encounterService.getEncounters(null, null, new DateMidnight().toDate(), null, null, Collections.singletonList(Metadata.lookupEncounterType(PihEmrConfigConstants.ENCOUNTERTYPE_VITALS_UUID)), null, null, null, false);
for (Encounter encounter : checkInEncounters) {
// sanity check on visit
if (encounter.getVisit() != null) {
// we check that the patient isn't already in the list instead of just inserting again because we want to keep the earliest date
if (!patientsWithCheckInEncounter.containsKey(encounter.getPatient())) {
patientsWithCheckInEncounter.put(encounter.getPatient(), encounter);
}
}
}
for (Encounter encounter : vitalsEncounters) {
if (patientsWithCheckInEncounter.containsKey(encounter.getPatient())) {
patientsWithCheckInEncounter.remove(encounter.getPatient());
}
}
String formPath = PihCoreUtil.getFormResource("vitals.xml");
SimpleObject vitalsListBreadcrumb = SimpleObject.create("label", ui.message("pihcore.vitalsList.title"), "link", ui.pageLink("pihcore", "vitals/vitalsList"));
PatientIdentifierType dossierNumberType = patientService.getPatientIdentifierTypeByUuid(ZlConfigConstants.PATIENTIDENTIFIERTYPE_DOSSIERNUMBER_UUID);
// used to determine whether or not we display a link to the patient in the results list
model.addAttribute("patientWithCheckInEncounter", patientsWithCheckInEncounter);
model.addAttribute("mothersFirstName", Metadata.getMothersFirstNameAttributeType());
model.addAttribute("dossierIdentifierName", dossierNumberType == null ? null : dossierNumberType.getName());
model.addAttribute("breadcrumbOverride", ui.toJson(Arrays.asList(vitalsListBreadcrumb)));
model.addAttribute("formPath", formPath);
return null;
}
Aggregations