use of org.openmrs.PatientIdentifierType in project openmrs-module-pihcore 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 FindPatientPageController method post.
public String post(@RequestParam(required = false, value = "remoteServer") String remoteServer, @RequestParam("remoteUuid") String remoteUuid, UiUtils ui, HttpServletRequest request) {
if (StringUtils.isNotBlank(remoteUuid)) {
HttpSession session = request.getSession();
RemotePatient remotePatient = getFromCache(remoteUuid, session);
if (remotePatient != null) {
// import the patient
try {
Patient patient = remotePatient.getPatient();
PatientIdentifierType zlIdentifierType = MetadataUtils.existing(PatientIdentifierType.class, PihHaitiPatientIdentifierTypes.ZL_EMR_ID.uuid());
if (zlIdentifierType != null && patient != null) {
PatientIdentifier patientIdentifier = patient.getPatientIdentifier(zlIdentifierType);
if (patientIdentifier != null) {
patientIdentifier.setPreferred(true);
}
}
patient = Context.getPatientService().savePatient(patient);
if (patient != null) {
request.getSession().setAttribute(EmrConstants.SESSION_ATTRIBUTE_INFO_MESSAGE, ui.message("mirebalais.mpi.import.success", ui.format(patient)));
request.getSession().setAttribute(EmrConstants.SESSION_ATTRIBUTE_TOAST_MESSAGE, "true");
removeFromCache(remoteUuid, session);
return "redirect:" + ui.pageLink("coreapps", "patientdashboard/patientDashboard?patientId=" + patient.getId().toString());
}
} catch (Exception e) {
log.error("failed to import patient", e);
request.getSession().setAttribute(EmrConstants.SESSION_ATTRIBUTE_ERROR_MESSAGE, ui.message("mirebalais.mpi.import.error", e.getMessage()));
}
}
}
return "redirect:" + ui.pageLink("mirebalais/mpi", "findPatient");
}
use of org.openmrs.PatientIdentifierType in project openmrs-module-coreapps by openmrs.
the class FindPatientFragmentController method simplify.
SimpleObject simplify(UiUtils ui, EmrApiProperties emrApiProperties, Patient patient) {
PersonName name = patient.getPersonName();
SimpleObject preferredName = SimpleObject.fromObject(name, ui, "givenName", "middleName", "familyName", "familyName2");
preferredName.put("name", ui.format(name));
PatientIdentifierType primaryIdentifierType = emrApiProperties.getPrimaryIdentifierType();
List<PatientIdentifier> primaryIdentifiers = patient.getPatientIdentifiers(primaryIdentifierType);
SimpleObject o = SimpleObject.fromObject(patient, ui, "patientId", "gender", "age", "birthdate", "birthdateEstimated");
o.put("preferredName", preferredName);
o.put("primaryIdentifiers", SimpleObject.fromCollection(primaryIdentifiers, ui, "identifier"));
return o;
}
use of org.openmrs.PatientIdentifierType in project openmrs-module-coreapps by openmrs.
the class PatientHeaderFragmentController method controller.
public void controller(FragmentConfiguration config, @SpringBean("emrApiProperties") EmrApiProperties emrApiProperties, @SpringBean("coreAppsProperties") CoreAppsProperties coreAppsProperties, @SpringBean("baseIdentifierSourceService") IdentifierSourceService identifierSourceService, @FragmentParam(required = false, value = "appContextModel") AppContextModel appContextModel, @SpringBean("appFrameworkService") AppFrameworkService appFrameworkService, @FragmentParam("patient") Object patient, @InjectBeans PatientDomainWrapper wrapper, @SpringBean("adtService") AdtService adtService, UiSessionContext sessionContext, UiUtils uiUtils, FragmentModel model) {
if (patient instanceof Patient) {
wrapper.setPatient((Patient) patient);
} else {
wrapper = (PatientDomainWrapper) patient;
}
config.addAttribute("patient", wrapper);
config.addAttribute("patientNames", getNames(wrapper.getPersonName()));
if (appContextModel == null) {
AppContextModel contextModel = sessionContext.generateAppContextModel();
contextModel.put("patient", new PatientContextModel(wrapper.getPatient()));
model.addAttribute("appContextModel", contextModel);
}
List<Extension> firstLineFragments = appFrameworkService.getExtensionsForCurrentUser("patientHeader.firstLineFragments");
Collections.sort(firstLineFragments);
model.addAttribute("firstLineFragments", firstLineFragments);
List<Extension> secondLineFragments = appFrameworkService.getExtensionsForCurrentUser("patientHeader.secondLineFragments");
Collections.sort(secondLineFragments);
model.addAttribute("secondLineFragments", secondLineFragments);
List<ExtraPatientIdentifierType> extraPatientIdentifierTypes = new ArrayList<ExtraPatientIdentifierType>();
for (PatientIdentifierType type : emrApiProperties.getExtraPatientIdentifierTypes()) {
List<AutoGenerationOption> options = identifierSourceService.getAutoGenerationOptions(type);
// TODO note that this may allow use to edit a identifier that should not be editable, or vice versa, in the rare case where there are multiple autogeneration
// TODO options for a single identifier type (which is possible if you have multiple locations) and the manual entry boolean is different between those two generators
extraPatientIdentifierTypes.add(new ExtraPatientIdentifierType(type, options.size() > 0 ? options.get(0).isManualEntryEnabled() : true));
}
config.addAttribute("extraPatientIdentifierTypes", extraPatientIdentifierTypes);
config.addAttribute("extraPatientIdentifiersMappedByType", wrapper.getExtraIdentifiersMappedByType(sessionContext.getSessionLocation()));
config.addAttribute("dashboardUrl", coreAppsProperties.getDashboardUrl());
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientSearchCriteriaTest method getSearchMode_shouldIdentifySearchByIdentifierTypeList.
/**
* @see PatientSearchCriteria#getSearchMode(String, String, java.util.List, boolean)
*/
@Test
public void getSearchMode_shouldIdentifySearchByIdentifierTypeList() {
List<PatientIdentifierType> patientIdentifierTypeList = new ArrayList<>();
patientIdentifierTypeList.add(new PatientIdentifierType());
// testing variations of empty or blank value for name
//
Assert.assertEquals(PatientSearchMode.PATIENT_SEARCH_BY_IDENTIFIER, patientSearchCriteria.getSearchMode(null, null, patientIdentifierTypeList, false));
Assert.assertEquals(PatientSearchMode.PATIENT_SEARCH_BY_IDENTIFIER, patientSearchCriteria.getSearchMode("", null, patientIdentifierTypeList, false));
Assert.assertEquals(PatientSearchMode.PATIENT_SEARCH_BY_IDENTIFIER, patientSearchCriteria.getSearchMode(" \n\t", null, patientIdentifierTypeList, false));
// testing variations of empty or blank value for identifier
//
Assert.assertEquals(PatientSearchMode.PATIENT_SEARCH_BY_IDENTIFIER, patientSearchCriteria.getSearchMode(null, "", patientIdentifierTypeList, false));
Assert.assertEquals(PatientSearchMode.PATIENT_SEARCH_BY_IDENTIFIER, patientSearchCriteria.getSearchMode(null, " \n\t", patientIdentifierTypeList, false));
// testing variations of empty or blank values for name and identifier
//
Assert.assertEquals(PatientSearchMode.PATIENT_SEARCH_BY_IDENTIFIER, patientSearchCriteria.getSearchMode("", "", patientIdentifierTypeList, false));
Assert.assertEquals(PatientSearchMode.PATIENT_SEARCH_BY_IDENTIFIER, patientSearchCriteria.getSearchMode(" \n\t", "", patientIdentifierTypeList, false));
Assert.assertEquals(PatientSearchMode.PATIENT_SEARCH_BY_IDENTIFIER, patientSearchCriteria.getSearchMode("", "\n\t", patientIdentifierTypeList, false));
Assert.assertEquals(PatientSearchMode.PATIENT_SEARCH_BY_IDENTIFIER, patientSearchCriteria.getSearchMode(" \n\t", " \n\t", patientIdentifierTypeList, false));
}
Aggregations