Skip to content

Commit

Permalink
Merge pull request #1682 from jecihjoy/openmrs-2.6.x-upgrade
Browse files Browse the repository at this point in the history
Openmrs 2.6.x upgrade
  • Loading branch information
makombe authored Oct 3, 2023
2 parents 12a8f68 + 47a7cc5 commit 1d3bee0
Show file tree
Hide file tree
Showing 37 changed files with 2,572 additions and 517 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ private void processEditHivFollowupEncounter(Encounter enc) throws Throwable {
appointmentServiceDefinition.setAppointmentServiceId(appointmentServiceDefinitionService.getAppointmentServiceByUuid(DRUG_REFILL_SERVICE).getId());

Appointment editedFollowUpAppointment = appointmentsService.getAppointmentByUuid(enc.getUuid());

Appointment refillAppointment = new Appointment();
Date refillStartDateTime = DateUtil.convertToDate(dateFormat.format(o.getValueDatetime()).concat("T07:00:00.0Z"), DateUtil.DateFormatType.UTC);
Date refillEndDateTime = DateUtil.convertToDate(dateFormat.format(o.getValueDatetime()).concat("T20:00:00.0Z"), DateUtil.DateFormatType.UTC);
Expand All @@ -234,10 +233,11 @@ private void processEditHivFollowupEncounter(Encounter enc) throws Throwable {
refillAppointment.setProvider(EmrUtils.getProvider(Context.getAuthenticatedUser()));
refillAppointment.setAppointmentKind(AppointmentKind.Scheduled);
Appointment app = appointmentsService.validateAndSave(refillAppointment);

editedFollowUpAppointment.setRelatedAppointment(app);
Appointment app2 = appointmentsService.validateAndSave(editedFollowUpAppointment);


if (editedFollowUpAppointment != null) {
editedFollowUpAppointment.setRelatedAppointment(app);
Appointment app2 = appointmentsService.validateAndSave(editedFollowUpAppointment);
}
}

}
Expand Down Expand Up @@ -277,7 +277,7 @@ private void processCreateHivFollowupEncounter(Encounter enc) throws Throwable {
refillApptDate = o.getValueDatetime();
}

if(appointmentReason != null && appointmentReason == 160523 || appointmentReason != null && appointmentReason == 160521 ) {
if((appointmentReason != null && appointmentReason == 160523) || (appointmentReason != null && appointmentReason == 160521) ) {
AppointmentServiceDefinition appointmentServiceDefinition = new AppointmentServiceDefinition();

// create HIV followup appointment
Expand Down Expand Up @@ -316,8 +316,10 @@ private void processCreateHivFollowupEncounter(Encounter enc) throws Throwable {
refillAppointment.setAppointmentKind(AppointmentKind.Scheduled);
Appointment app = appointmentsService.validateAndSave(refillAppointment);

currentFollowUpAppointment.setRelatedAppointment(app);
Appointment app2 = appointmentsService.validateAndSave(currentFollowUpAppointment);
if (currentFollowUpAppointment != null ) {
currentFollowUpAppointment.setRelatedAppointment(app);
Appointment app2 = appointmentsService.validateAndSave(currentFollowUpAppointment);
}
}

} else if ( appointmentReason != null && appointmentReason == 1283) {
Expand Down Expand Up @@ -369,7 +371,6 @@ private void processProgramEncounter(Encounter enc) throws Throwable {

if(editAppointment != null) {
//edit MCH or PREP or TB or KP appointment

Date nextApptStartDateTime = DateUtil.convertToDate(dateFormat.format(o.getValueDatetime()).concat("T07:00:00.0Z"), DateUtil.DateFormatType.UTC);
Date nextApptEndDateTime = DateUtil.convertToDate(dateFormat.format(o.getValueDatetime()).concat("T20:00:00.0Z"), DateUtil.DateFormatType.UTC);
editAppointment.setStartDateTime(nextApptStartDateTime);
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import org.openmrs.Concept;
import org.openmrs.Obs;
import org.openmrs.Program;
import org.openmrs.api.ConceptService;
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;
Expand Down Expand Up @@ -60,13 +62,15 @@ public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Obj
// Get all patients who are alive and in TB program
Set<Integer> alive = Filters.alive(cohort, context);
Set<Integer> inTbProgram = Filters.inProgram(tbProgram, alive, context);
ConceptService cs = Context.getConceptService();

// Get concepts
Concept tbsuspect = Dictionary.getConcept(Dictionary.DISEASE_SUSPECTED);
Concept pulmonaryTb = Dictionary.getConcept(Dictionary.PULMONARY_TB);
Concept smearPositive = Dictionary.getConcept(Dictionary.POSITIVE);
Concept NEGATIVE = Dictionary.getConcept(Dictionary.NEGATIVE);
Concept SPUTUM_FOR_ACID_FAST_BACILLI = Dictionary.getConcept(Dictionary.SPUTUM_FOR_ACID_FAST_BACILLI);
Concept geneXpertConcept = cs.getConcept(162202);

// check if there is any observation recorded per the tuberculosis disease status
CalculationResultMap lastObsTbDiseaseStatus = Calculations.lastObs(Dictionary.getConcept(Dictionary.TUBERCULOSIS_DISEASE_STATUS), cohort, context);
Expand All @@ -81,6 +85,7 @@ public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Obj

// get the date when Tb treatment was started, the patient should be in tb program to have this date
CalculationResultMap tbStartTreatmentDate = Calculations.lastObs(Dictionary.getConcept(Dictionary.TUBERCULOSIS_DRUG_TREATMENT_START_DATE), cohort, context);
CalculationResultMap lastGeneXpertConcept = Calculations.lastObs(geneXpertConcept, alive, context);

CalculationResultMap ret = new CalculationResultMap();
for (Integer ptId : cohort) {
Expand All @@ -91,10 +96,11 @@ public CalculationResultMap evaluate(Collection<Integer> cohort, Map<String, Obj
Date treatmentStartDate = EmrCalculationUtils.datetimeObsResultForPatient(tbStartTreatmentDate, ptId);
Obs lastObsTbDiseaseResults = EmrCalculationUtils.obsResultForPatient(lastObsTbDiseaseStatus, ptId);
Obs lastSputumResultsObs = EmrCalculationUtils.obsResultForPatient(lastSputumResults, ptId);

Obs lastGeneXpertObs = EmrCalculationUtils.obsResultForPatient(lastGeneXpertConcept, ptId);
//
// check if a patient is alive
if (alive.contains(ptId)) {
if ((lastObsTbDiseaseResults != null) && (lastObsTbDiseaseResults.getValueCoded().equals(tbsuspect)) && lastSputumResultsObs == null && !(inTbProgram.contains(ptId))) {
if ((lastObsTbDiseaseResults != null) && (lastObsTbDiseaseResults.getValueCoded().equals(tbsuspect)) && lastSputumResultsObs == null && !(inTbProgram.contains(ptId)) && lastGeneXpertObs ==null) {
needsSputum = true;
}
else if(inTbProgram.contains(ptId) && diseaseClassification != null && tbResults != null && (diseaseClassification.getValueCoded().equals(pulmonaryTb)) && (tbResults.getValueCoded().equals(smearPositive)) && treatmentStartDate != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
import org.openmrs.module.kenyaemr.reporting.data.converter.definition.art.ETLRefillDateDataDefinition;
import org.openmrs.module.kenyaemr.reporting.data.converter.definition.art.ETLStabilityDataDefinition;
import org.openmrs.module.kenyaemr.reporting.data.converter.definition.art.HeightAtArtDataDefinition;
import org.openmrs.module.kenyaemr.reporting.data.converter.definition.art.MedicalCoverDataDefinition;
import org.openmrs.module.kenyaemr.reporting.data.converter.definition.art.MedicalCoverStatusDataDefinition;
import org.openmrs.module.kenyaemr.reporting.data.converter.definition.art.NCDDateDataDefinition;
import org.openmrs.module.kenyaemr.reporting.data.converter.definition.art.NCDStatusDataDefinition;
import org.openmrs.module.kenyaemr.reporting.data.converter.definition.art.NCDsDataDefinition;
Expand Down Expand Up @@ -187,6 +189,12 @@ protected PatientDataSetDefinition activePatientsDataSetDefinition(String datase
BloodPressureDataDefinition bloodPressureDataDefinition = new BloodPressureDataDefinition();
bloodPressureDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class));
bloodPressureDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class));
MedicalCoverDataDefinition medicalCoverDataDefinition = new MedicalCoverDataDefinition();
medicalCoverDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class));
medicalCoverDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class));
MedicalCoverStatusDataDefinition medicalCoverStatusDataDefinition = new MedicalCoverStatusDataDefinition();
medicalCoverStatusDataDefinition.addParameter(new Parameter("endDate", "End Date", Date.class));
medicalCoverStatusDataDefinition.addParameter(new Parameter("startDate", "Start Date", Date.class));


DataConverter formatter = new ObjectFormatter("{familyName}, {givenName}");
Expand Down Expand Up @@ -238,6 +246,8 @@ protected PatientDataSetDefinition activePatientsDataSetDefinition(String datase
dsd.addColumn("NCDs Onset Date", ncdDateDataDefinition, "endDate=${endDate}");
dsd.addColumn("NCDs status", ncdStatusDataDefinition, "endDate=${endDate}");
dsd.addColumn("AHD Client", new CalculationDataDefinition("AHD Client", new PatientsWithAdvancedHivDiseaseCalculation()), "", new BooleanResultsConverter());
dsd.addColumn("Medical cover", medicalCoverDataDefinition, "endDate=${endDate}");
dsd.addColumn("Medical cover status", medicalCoverStatusDataDefinition, "endDate=${endDate}");


return dsd;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,9 @@
import org.openmrs.module.kenyaemr.reporting.calculation.converter.RDQACalculationResultConverter;
import org.openmrs.module.kenyaemr.reporting.cohort.definition.CCCDefaulterTracingRegisterCohortDefinition;
import org.openmrs.module.kenyaemr.reporting.data.converter.MissedAppointmentReasonsConverter;
import org.openmrs.module.kenyaemr.reporting.data.converter.definition.HIVTestOneDataDefinition;
import org.openmrs.module.kenyaemr.reporting.data.converter.definition.art.ETLLastVisitDateDataDefinition;
import org.openmrs.module.kenyaemr.reporting.data.converter.definition.art.ETLNextAppointmentDateDataDefinition;
import org.openmrs.module.kenyaemr.reporting.data.converter.definition.defaulterTracing.FinalOutcomeDataDefinition;
import org.openmrs.module.kenyaemr.reporting.data.converter.definition.defaulterTracing.ProviderCommentsDataDefinition;
import org.openmrs.module.kenyaemr.reporting.data.converter.definition.defaulterTracing.ReasonForMissedAppointmentDataDefinition;
import org.openmrs.module.kenyaemr.reporting.data.converter.definition.defaulterTracing.ReturnToCareDateDataDefinition;
import org.openmrs.module.kenyaemr.reporting.data.converter.definition.defaulterTracing.HonouredAppointmentDateDataDefinition;
import org.openmrs.module.kenyaemr.reporting.data.converter.definition.defaulterTracing.TracingNumberDataDefinition;
import org.openmrs.module.kenyaemr.reporting.data.converter.definition.defaulterTracing.TracingOutcomeDataDefinition;
import org.openmrs.module.kenyaemr.reporting.data.converter.definition.defaulterTracing.TracingTypeDataDefinition;
import org.openmrs.module.kenyaemr.reporting.data.converter.definition.defaulterTracing.*;
import org.openmrs.module.metadatadeploy.MetadataUtils;
import org.openmrs.module.reporting.common.SortCriteria;
import org.openmrs.module.reporting.data.DataDefinition;
Expand Down Expand Up @@ -105,6 +98,21 @@ protected DataSetDefinition datasetColumns() {
providerDataDefinition.setSingleProvider(true);
PersonAttributeType phoneNumber = MetadataUtils.existing(PersonAttributeType.class, CommonMetadata._PersonAttributeType.TELEPHONE_CONTACT);

String dateParams = "startDate=${startDate},endDate=${endDate}";

DateMissedAppointmentBeforeTracingDataDefinition dateMissedAppointment = new DateMissedAppointmentBeforeTracingDataDefinition();
dateMissedAppointment.addParameter(new Parameter("startDate", "Start Date", Date.class));
dateMissedAppointment.addParameter(new Parameter("endDate", "End Date", Date.class));

HonouredAppointmentDateDataDefinition dateHonouredAppointment = new HonouredAppointmentDateDataDefinition();
dateHonouredAppointment.addParameter(new Parameter("startDate", "Start Date", Date.class));
dateHonouredAppointment.addParameter(new Parameter("endDate", "End Date", Date.class));

LastVisitDateBeforeMissedAppointmentDataDefinition lastVisitBeforeMissedApp = new LastVisitDateBeforeMissedAppointmentDataDefinition();
lastVisitBeforeMissedApp.addParameter(new Parameter("startDate", "Start Date", Date.class));
lastVisitBeforeMissedApp.addParameter(new Parameter("endDate", "End Date", Date.class));


dsd.addColumn("Name", nameDef, "");
dsd.addColumn("id", new PatientIdDataDefinition(), "");
dsd.addColumn("Date of Birth", new BirthdateDataDefinition(), "", new BirthdateConverter(DATE_FORMAT));
Expand All @@ -118,16 +126,15 @@ protected DataSetDefinition datasetColumns() {
dsd.addColumn("Outcome", new TracingOutcomeDataDefinition(),"");
dsd.addColumn("Tracing attempt No", new TracingNumberDataDefinition(),"");
dsd.addColumn("Final Outcome", new FinalOutcomeDataDefinition(),"");
dsd.addColumn("Last Visit Date", new ETLLastVisitDateDataDefinition(),"", new DateConverter(DATE_FORMAT));
dsd.addColumn("Last Appointment Date", new ETLNextAppointmentDateDataDefinition(), "", new DateConverter(DATE_FORMAT));
dsd.addColumn("Last Visit Date", lastVisitBeforeMissedApp,dateParams, new DateConverter(DATE_FORMAT));
dsd.addColumn("Last Appointment Date", dateMissedAppointment, dateParams, new DateConverter(DATE_FORMAT));
dsd.addColumn("Reason for missed appointment", new ReasonForMissedAppointmentDataDefinition(),"", new MissedAppointmentReasonsConverter());
dsd.addColumn("Date promised to come", new ReturnToCareDateDataDefinition(),"", new DateConverter(DATE_FORMAT));
dsd.addColumn("Honoured appointment date", new HonouredAppointmentDateDataDefinition(),"", new DateConverter(DATE_FORMAT));
dsd.addColumn("Honoured appointment date", dateHonouredAppointment,dateParams, new DateConverter(DATE_FORMAT));
dsd.addColumn("Comments", new ProviderCommentsDataDefinition(),"");
dsd.addColumn("Provider", providerDataDefinition,"", new EncounterProviderConverter());



CCCDefaulterTracingRegisterCohortDefinition cd = new CCCDefaulterTracingRegisterCohortDefinition();
cd.addParameter(new Parameter("startDate", "Start Date", Date.class));
cd.addParameter(new Parameter("endDate", "End Date", Date.class));
Expand Down
Loading

0 comments on commit 1d3bee0

Please sign in to comment.