Skip to content

Commit

Permalink
Removed unused code - identifierManager
Browse files Browse the repository at this point in the history
  • Loading branch information
patryllus committed Apr 20, 2022
1 parent 4b0b469 commit 90d4fad
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
*
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
* graphic logo is a trademark of OpenMRS Inc.
*/
package org.openmrs.module.kenyaemr.calculation.library;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openmrs.PatientIdentifier;
import org.openmrs.PatientIdentifierType;
import org.openmrs.api.PatientService;
import org.openmrs.api.context.Context;
import org.openmrs.calculation.patient.PatientCalculationContext;
import org.openmrs.calculation.result.CalculationResultMap;
import org.openmrs.module.kenyacore.calculation.AbstractPatientCalculation;
import org.openmrs.module.kenyacore.calculation.BooleanResult;
import org.openmrs.module.kenyacore.identifier.IdentifierManager;
import org.openmrs.module.kenyaemr.metadata.CommonMetadata;
import org.openmrs.module.metadatadeploy.MetadataUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
* Missing all registration identifiers
* Registration identifiers are:
* ************************
* Patient Clinic Number
* National ID Number
* Passport Number
* Huduma Number
* Birth Certificate Number
*/
public class MissingAllRegistrationIdentifiersCalculation extends AbstractPatientCalculation {
protected static final Log log = LogFactory.getLog(MissingAllRegistrationIdentifiersCalculation.class);

@Override
public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Object> params, PatientCalculationContext context) {

CalculationResultMap ret = new CalculationResultMap();
for (Integer ptId : cohort) {
boolean missingAllIdentifiers = true;
PatientService patientService = Context.getPatientService();

PatientIdentifierType nationalID = MetadataUtils.existing(PatientIdentifierType.class, CommonMetadata._PatientIdentifierType.NATIONAL_ID);
PatientIdentifierType patientClinicNo = MetadataUtils.existing(PatientIdentifierType.class, CommonMetadata._PatientIdentifierType.PATIENT_CLINIC_NUMBER);
PatientIdentifierType passPortNo = MetadataUtils.existing(PatientIdentifierType.class, CommonMetadata._PatientIdentifierType.PASSPORT_NUMBER);
PatientIdentifierType hudumaNo = MetadataUtils.existing(PatientIdentifierType.class, CommonMetadata._PatientIdentifierType.HUDUMA_NUMBER);
PatientIdentifierType birthCertNo = MetadataUtils.existing(PatientIdentifierType.class, CommonMetadata._PatientIdentifierType.BIRTH_CERTIFICATE_NUMBER);

List<PatientIdentifier> patientRegIdentifiers = patientService.getPatientIdentifiers(null, Arrays.asList(nationalID,patientClinicNo,passPortNo,hudumaNo,birthCertNo), null, Arrays.asList(patientService.getPatient(ptId)), false);
if(patientRegIdentifiers.size() > 0){
missingAllIdentifiers = false;
}
ret.put(ptId, new BooleanResult(missingAllIdentifiers, this, context));
}

return ret;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.openmrs.module.kenyacore.calculation.CalculationUtils;
import org.openmrs.module.kenyacore.form.FormDescriptor;
import org.openmrs.module.kenyacore.form.FormManager;
import org.openmrs.module.kenyaemr.calculation.library.MissingAllRegistrationIdentifiersCalculation;
import org.openmrs.module.kenyaemr.calculation.library.RecordedDeceasedCalculation;
import org.openmrs.module.kenyaui.KenyaUiUtils;
import org.openmrs.ui.framework.SimpleObject;
Expand Down Expand Up @@ -52,6 +53,7 @@ public void controller(@FragmentParam("patient") Patient patient,

model.addAttribute("patient", patient);
model.addAttribute("recordedAsDeceased", hasBeenRecordedAsDeceased(patient));
model.addAttribute("missingIdentifiers", hasNoRequiredRegistrationIdentifiers(patient));
model.addAttribute("forms", forms);
}

Expand All @@ -64,4 +66,19 @@ protected boolean hasBeenRecordedAsDeceased(Patient patient) {
PatientCalculation calc = CalculationUtils.instantiateCalculation(RecordedDeceasedCalculation.class, null);
return ResultUtil.isTrue(Context.getService(PatientCalculationService.class).evaluate(patient.getId(), calc));
}
/**
* Checks if a patient has been recorded required patient registration identifiers
* Patient Clinic Number
* National ID Number
* Passport Number
* Huduma Number
* Birth Certificate Number
*
* @param patient the patient
* @return true if patient has no recorded registration identifiers
*/
protected boolean hasNoRequiredRegistrationIdentifiers(Patient patient) {
PatientCalculation calc = CalculationUtils.instantiateCalculation(MissingAllRegistrationIdentifiersCalculation.class, null);
return ResultUtil.isTrue(Context.getService(PatientCalculationService.class).evaluate(patient.getId(), calc));
}
}
5 changes: 5 additions & 0 deletions omod/src/main/webapp/fragments/patient/patientSummary.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
Patient has been recorded as deceased in a program form. Please update the registration form.
</div>
<% } %>
<% if (missingIdentifiers) { %>
<div class="ke-warning" style="margin-bottom: 5px">
Patient has missing registration identifiers.
</div>
<% } %>

<button type="button" class="ke-compact" onclick="ui.navigate('${ ui.pageLink("kenyaemr", "registration/editPatient", [ patientId: patient.id, returnUrl: ui.thisUrl() ]) }')">
<img src="${ ui.resourceLink("kenyaui", "images/glyphs/edit.png") }" />
Expand Down

0 comments on commit 90d4fad

Please sign in to comment.