Search in sources :

Example 66 with PatientIdentifierType

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();
}
Also used : PatientIdentifierType(org.openmrs.PatientIdentifierType) PatientIdentifier(org.openmrs.PatientIdentifier)

Example 67 with PatientIdentifierType

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");
}
Also used : RemotePatient(org.openmrs.module.importpatientfromws.RemotePatient) HttpSession(javax.servlet.http.HttpSession) RemotePatient(org.openmrs.module.importpatientfromws.RemotePatient) Patient(org.openmrs.Patient) PatientIdentifierType(org.openmrs.PatientIdentifierType) PatientIdentifier(org.openmrs.PatientIdentifier)

Example 68 with PatientIdentifierType

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;
}
Also used : PersonName(org.openmrs.PersonName) SimpleObject(org.openmrs.ui.framework.SimpleObject) PatientIdentifierType(org.openmrs.PatientIdentifierType) PatientIdentifier(org.openmrs.PatientIdentifier)

Example 69 with PatientIdentifierType

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());
}
Also used : Extension(org.openmrs.module.appframework.domain.Extension) PatientContextModel(org.openmrs.module.coreapps.contextmodel.PatientContextModel) AppContextModel(org.openmrs.module.appframework.context.AppContextModel) ArrayList(java.util.ArrayList) Patient(org.openmrs.Patient) AutoGenerationOption(org.openmrs.module.idgen.AutoGenerationOption) PatientIdentifierType(org.openmrs.PatientIdentifierType)

Example 70 with PatientIdentifierType

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));
}
Also used : ArrayList(java.util.ArrayList) PatientIdentifierType(org.openmrs.PatientIdentifierType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

PatientIdentifierType (org.openmrs.PatientIdentifierType)131 Test (org.junit.Test)99 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)88 PatientIdentifier (org.openmrs.PatientIdentifier)56 PatientServiceImplTest (org.openmrs.api.impl.PatientServiceImplTest)53 Patient (org.openmrs.Patient)37 Location (org.openmrs.Location)29 ArrayList (java.util.ArrayList)20 BindException (org.springframework.validation.BindException)17 Errors (org.springframework.validation.Errors)14 Date (java.util.Date)13 PersonName (org.openmrs.PersonName)13 User (org.openmrs.User)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 Concept (org.openmrs.Concept)6 Person (org.openmrs.Person)5 HashMap (java.util.HashMap)4 PersonAddress (org.openmrs.PersonAddress)4 PatientServiceTest (org.openmrs.api.PatientServiceTest)4 HL7Exception (ca.uhn.hl7v2.HL7Exception)3