diff --git a/api/src/main/distro/metadata/concepts.xml b/api/src/main/distro/metadata/concepts.xml index 67f1600997..be00e27209 100755 --- a/api/src/main/distro/metadata/concepts.xml +++ b/api/src/main/distro/metadata/concepts.xml @@ -279,4 +279,22 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/hiv/art/BMICalculation.java b/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/hiv/art/BMICalculation.java new file mode 100644 index 0000000000..6ab50cf1f1 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/hiv/art/BMICalculation.java @@ -0,0 +1,69 @@ +/** + * 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.hiv.art; +import org.openmrs.Obs; + import org.openmrs.Patient; + import org.openmrs.Program; + import org.openmrs.api.PatientService; + import org.openmrs.api.PersonService; + import org.openmrs.api.context.Context; + import org.openmrs.calculation.patient.PatientCalculationContext; + import org.openmrs.calculation.result.CalculationResultMap; + import org.openmrs.calculation.result.SimpleResult; + import org.openmrs.module.kenyacore.calculation.AbstractPatientCalculation; + import org.openmrs.module.kenyacore.calculation.Calculations; + import org.openmrs.module.kenyacore.calculation.Filters; + import org.openmrs.module.kenyaemr.Dictionary; + import org.openmrs.module.kenyaemr.calculation.EmrCalculationUtils; + import org.openmrs.module.kenyaemr.metadata.MchMetadata; + import org.openmrs.module.metadatadeploy.MetadataUtils; + + import java.util.Collection; + import java.util.Map; + import java.util.Set; + +/** +* Calculate the bmi at last visit +*/ + public class BMICalculation extends AbstractPatientCalculation { + + @Override + public CalculationResultMap evaluate(Collection cohort, Map parameterValues, PatientCalculationContext context) { + + CalculationResultMap weightMap = Calculations.lastObs(Dictionary.getConcept(Dictionary.WEIGHT_KG), cohort, context); + CalculationResultMap heightMap = Calculations.lastObs(Dictionary.getConcept(Dictionary.HEIGHT_CM), cohort, context); + + + PersonService service = Context.getPersonService(); + + + CalculationResultMap ret = new CalculationResultMap(); + for (Integer ptId : cohort) { + + Double visitWeight = null; + Double visitHeight = null; + String bmiStr = null; + + Obs lastWeightObs = EmrCalculationUtils.obsResultForPatient(weightMap, ptId); + Obs lastHeightObs = EmrCalculationUtils.obsResultForPatient(heightMap, ptId); + //find pregnancy obs + + if (lastHeightObs !=null && lastWeightObs != null ){ + visitHeight = lastHeightObs.getValueNumeric(); + visitWeight = lastWeightObs.getValueNumeric(); + Double bmi = visitWeight / ((visitHeight/100) * (visitHeight/100)); + bmiStr = String.format("%.2f", bmi); + ret.put(ptId, new SimpleResult(bmiStr, this, context)); + } + } + return ret; + } + } + diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/hiv/art/BloodPressureCalculation.java b/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/hiv/art/BloodPressureCalculation.java new file mode 100644 index 0000000000..4ea252bbdc --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/hiv/art/BloodPressureCalculation.java @@ -0,0 +1,64 @@ +/** + * 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.hiv.art; + +import org.openmrs.Concept; +import org.openmrs.Obs; +import org.openmrs.calculation.patient.PatientCalculationContext; +import org.openmrs.calculation.result.CalculationResultMap; +import org.openmrs.calculation.result.ListResult; +import org.openmrs.calculation.result.SimpleResult; +import org.openmrs.module.kenyacore.calculation.AbstractPatientCalculation; +import org.openmrs.module.kenyacore.calculation.CalculationUtils; +import org.openmrs.module.kenyacore.calculation.Calculations; +import org.openmrs.module.kenyaemr.Dictionary; +import org.openmrs.module.kenyaemr.calculation.EmrCalculationUtils; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Map; + + +public class BloodPressureCalculation extends AbstractPatientCalculation { + + /** + * @see org.openmrs.calculation.patient.PatientCalculation#evaluate(Collection, Map, PatientCalculationContext) + */ + @Override + public CalculationResultMap evaluate(Collection cohort, Map parameterValues, PatientCalculationContext context) { + + Concept currentBloodPressure = Dictionary.getConcept(Dictionary.BLOOD_PRESSURE); + CalculationResultMap artStartDates = calculate(new InitialArtStartDateCalculation(), cohort, context); + CalculationResultMap bloodPressureObss = Calculations.allObs(currentBloodPressure, cohort, context); + + CalculationResultMap ret = new CalculationResultMap(); + for (Integer ptId : cohort) { + SimpleResult result = null; + Date artStartDate = EmrCalculationUtils.datetimeResultForPatient(artStartDates, ptId); + ListResult bloodPressureObsResult = (ListResult) bloodPressureObss.get(ptId); + + if (artStartDate != null && bloodPressureObsResult != null && !bloodPressureObsResult.isEmpty()) { + List bloodPressure = CalculationUtils.extractResultValues(bloodPressureObsResult); + Obs lastBeforeArtStart = EmrCalculationUtils.findLastOnOrBefore(bloodPressure, artStartDate); + + if (lastBeforeArtStart != null) { + Double bloodPressureValue = lastBeforeArtStart.getValueNumeric(); + if (bloodPressureValue != null) { + result = new SimpleResult(bloodPressureValue, this); + } + } + } + + ret.put(ptId, result); + } + return ret; + } +} \ No newline at end of file diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/hiv/art/HeightAtArtInitiationCalculation.java b/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/hiv/art/HeightAtArtInitiationCalculation.java new file mode 100644 index 0000000000..8b0400cb2f --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/hiv/art/HeightAtArtInitiationCalculation.java @@ -0,0 +1,64 @@ +/** + * 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.hiv.art; + +import org.openmrs.Concept; +import org.openmrs.Obs; +import org.openmrs.calculation.patient.PatientCalculationContext; +import org.openmrs.calculation.result.CalculationResultMap; +import org.openmrs.calculation.result.ListResult; +import org.openmrs.calculation.result.SimpleResult; +import org.openmrs.module.kenyacore.calculation.AbstractPatientCalculation; +import org.openmrs.module.kenyacore.calculation.CalculationUtils; +import org.openmrs.module.kenyacore.calculation.Calculations; +import org.openmrs.module.kenyaemr.Dictionary; +import org.openmrs.module.kenyaemr.calculation.EmrCalculationUtils; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Map; + + +public class HeightAtArtInitiationCalculation extends AbstractPatientCalculation { + + /** + * @see org.openmrs.calculation.patient.PatientCalculation#evaluate(Collection, Map, PatientCalculationContext) + */ + @Override + public CalculationResultMap evaluate(Collection cohort, Map parameterValues, PatientCalculationContext context) { + + Concept currentHeight = Dictionary.getConcept(Dictionary.HEIGHT_CM); + CalculationResultMap artStartDates = calculate(new InitialArtStartDateCalculation(), cohort, context); + CalculationResultMap heightObss = Calculations.allObs(currentHeight, cohort, context); + + CalculationResultMap ret = new CalculationResultMap(); + for (Integer ptId : cohort) { + SimpleResult result = null; + Date artStartDate = EmrCalculationUtils.datetimeResultForPatient(artStartDates, ptId); + ListResult heightObsResult = (ListResult) heightObss.get(ptId); + + if (artStartDate != null && heightObsResult != null && !heightObsResult.isEmpty()) { + List height = CalculationUtils.extractResultValues(heightObsResult); + Obs lastBeforeArtStart = EmrCalculationUtils.findLastOnOrBefore(height, artStartDate); + + if (lastBeforeArtStart != null) { + Double heightValue = lastBeforeArtStart.getValueNumeric(); + if (heightValue != null) { + result = new SimpleResult(heightValue, this); + } + } + } + + ret.put(ptId, result); + } + return ret; + } +} \ No newline at end of file diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/hiv/art/LMPCalculation.java b/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/hiv/art/LMPCalculation.java new file mode 100644 index 0000000000..cd8a98aff6 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/hiv/art/LMPCalculation.java @@ -0,0 +1,64 @@ +/** + * 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.hiv.art; + +import org.openmrs.Concept; +import org.openmrs.Obs; +import org.openmrs.calculation.patient.PatientCalculationContext; +import org.openmrs.calculation.result.CalculationResultMap; +import org.openmrs.calculation.result.ListResult; +import org.openmrs.calculation.result.SimpleResult; +import org.openmrs.module.kenyacore.calculation.AbstractPatientCalculation; +import org.openmrs.module.kenyacore.calculation.CalculationUtils; +import org.openmrs.module.kenyacore.calculation.Calculations; +import org.openmrs.module.kenyaemr.Dictionary; +import org.openmrs.module.kenyaemr.calculation.EmrCalculationUtils; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Map; + + +public class LMPCalculation extends AbstractPatientCalculation { + + /** + * @see org.openmrs.calculation.patient.PatientCalculation#evaluate(Collection, Map, PatientCalculationContext) + */ + @Override + public CalculationResultMap evaluate(Collection cohort, Map parameterValues, PatientCalculationContext context) { + + Concept currentLMP = Dictionary.getConcept(Dictionary.LMP); + CalculationResultMap artStartDates = calculate(new InitialArtStartDateCalculation(), cohort, context); + CalculationResultMap lmpObss = Calculations.allObs(currentLMP, cohort, context); + + CalculationResultMap ret = new CalculationResultMap(); + for (Integer ptId : cohort) { + SimpleResult result = null; + Date artStartDate = EmrCalculationUtils.datetimeResultForPatient(artStartDates, ptId); + ListResult lmpObsResult = (ListResult) lmpObss.get(ptId); + + if (artStartDate != null && lmpObsResult != null && !lmpObsResult.isEmpty()) { + List lmp = CalculationUtils.extractResultValues(lmpObsResult); + Obs lastBeforeArtStart = EmrCalculationUtils.findLastOnOrBefore(lmp, artStartDate); + + if (lastBeforeArtStart != null) { + Double lmpValue = lastBeforeArtStart.getValueNumeric(); + if (lmpValue != null) { + result = new SimpleResult(lmpValue, this); + } + } + } + + ret.put(ptId, result); + } + return ret; + } +} \ No newline at end of file diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/hiv/art/OxygenSaturationCalculation.java b/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/hiv/art/OxygenSaturationCalculation.java new file mode 100644 index 0000000000..40b7b35992 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/hiv/art/OxygenSaturationCalculation.java @@ -0,0 +1,64 @@ +/** + * 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.hiv.art; + +import org.openmrs.Concept; +import org.openmrs.Obs; +import org.openmrs.calculation.patient.PatientCalculationContext; +import org.openmrs.calculation.result.CalculationResultMap; +import org.openmrs.calculation.result.ListResult; +import org.openmrs.calculation.result.SimpleResult; +import org.openmrs.module.kenyacore.calculation.AbstractPatientCalculation; +import org.openmrs.module.kenyacore.calculation.CalculationUtils; +import org.openmrs.module.kenyacore.calculation.Calculations; +import org.openmrs.module.kenyaemr.Dictionary; +import org.openmrs.module.kenyaemr.calculation.EmrCalculationUtils; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Map; + + +public class OxygenSaturationCalculation extends AbstractPatientCalculation { + + /** + * @see org.openmrs.calculation.patient.PatientCalculation#evaluate(Collection, Map, PatientCalculationContext) + */ + @Override + public CalculationResultMap evaluate(Collection cohort, Map parameterValues, PatientCalculationContext context) { + + Concept currentOxygenSaturation = Dictionary.getConcept(Dictionary.OXYGEN_SATURATION); + CalculationResultMap artStartDates = calculate(new InitialArtStartDateCalculation(), cohort, context); + CalculationResultMap oxygenSaturationObss = Calculations.allObs(currentOxygenSaturation, cohort, context); + + CalculationResultMap ret = new CalculationResultMap(); + for (Integer ptId : cohort) { + SimpleResult result = null; + Date artStartDate = EmrCalculationUtils.datetimeResultForPatient(artStartDates, ptId); + ListResult oxygenSaturationObsResult = (ListResult) oxygenSaturationObss.get(ptId); + + if (artStartDate != null && oxygenSaturationObsResult != null && !oxygenSaturationObsResult.isEmpty()) { + List oxygenSaturation = CalculationUtils.extractResultValues(oxygenSaturationObsResult); + Obs lastBeforeArtStart = EmrCalculationUtils.findLastOnOrBefore(oxygenSaturation, artStartDate); + + if (lastBeforeArtStart != null) { + Double oxygenSaturationValue = lastBeforeArtStart.getValueNumeric(); + if (oxygenSaturationValue != null) { + result = new SimpleResult(oxygenSaturationValue, this); + } + } + } + + ret.put(ptId, result); + } + return ret; + } +} \ No newline at end of file diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/hiv/art/PulseRateCalculation.java b/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/hiv/art/PulseRateCalculation.java new file mode 100644 index 0000000000..018d59cb90 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/hiv/art/PulseRateCalculation.java @@ -0,0 +1,64 @@ +/** + * 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.hiv.art; + +import org.openmrs.Concept; +import org.openmrs.Obs; +import org.openmrs.calculation.patient.PatientCalculationContext; +import org.openmrs.calculation.result.CalculationResultMap; +import org.openmrs.calculation.result.ListResult; +import org.openmrs.calculation.result.SimpleResult; +import org.openmrs.module.kenyacore.calculation.AbstractPatientCalculation; +import org.openmrs.module.kenyacore.calculation.CalculationUtils; +import org.openmrs.module.kenyacore.calculation.Calculations; +import org.openmrs.module.kenyaemr.Dictionary; +import org.openmrs.module.kenyaemr.calculation.EmrCalculationUtils; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Map; + + +public class PulseRateCalculation extends AbstractPatientCalculation { + + /** + * @see org.openmrs.calculation.patient.PatientCalculation#evaluate(Collection, Map, PatientCalculationContext) + */ + @Override + public CalculationResultMap evaluate(Collection cohort, Map parameterValues, PatientCalculationContext context) { + + Concept currentPulseRate = Dictionary.getConcept(Dictionary.PULSE_RATE); + CalculationResultMap artStartDates = calculate(new InitialArtStartDateCalculation(), cohort, context); + CalculationResultMap pulseRateObss = Calculations.allObs(currentPulseRate, cohort, context); + + CalculationResultMap ret = new CalculationResultMap(); + for (Integer ptId : cohort) { + SimpleResult result = null; + Date artStartDate = EmrCalculationUtils.datetimeResultForPatient(artStartDates, ptId); + ListResult pulseRateObsResult = (ListResult) pulseRateObss.get(ptId); + + if (artStartDate != null && pulseRateObsResult != null && !pulseRateObsResult.isEmpty()) { + List pulseRate = CalculationUtils.extractResultValues(pulseRateObsResult); + Obs lastBeforeArtStart = EmrCalculationUtils.findLastOnOrBefore(pulseRate, artStartDate); + + if (lastBeforeArtStart != null) { + Double bmiValue = lastBeforeArtStart.getValueNumeric(); + if (bmiValue != null) { + result = new SimpleResult(bmiValue, this); + } + } + } + + ret.put(ptId, result); + } + return ret; + } +} \ No newline at end of file diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/hiv/art/RespitatoryRateCalculation.java b/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/hiv/art/RespitatoryRateCalculation.java new file mode 100644 index 0000000000..eb0e7a0fe7 --- /dev/null +++ b/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/hiv/art/RespitatoryRateCalculation.java @@ -0,0 +1,64 @@ +/** + * 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.hiv.art; + +import org.openmrs.Concept; +import org.openmrs.Obs; +import org.openmrs.calculation.patient.PatientCalculationContext; +import org.openmrs.calculation.result.CalculationResultMap; +import org.openmrs.calculation.result.ListResult; +import org.openmrs.calculation.result.SimpleResult; +import org.openmrs.module.kenyacore.calculation.AbstractPatientCalculation; +import org.openmrs.module.kenyacore.calculation.CalculationUtils; +import org.openmrs.module.kenyacore.calculation.Calculations; +import org.openmrs.module.kenyaemr.Dictionary; +import org.openmrs.module.kenyaemr.calculation.EmrCalculationUtils; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.Map; + + +public class RespitatoryRateCalculation extends AbstractPatientCalculation { + + /** + * @see org.openmrs.calculation.patient.PatientCalculation#evaluate(Collection, Map, PatientCalculationContext) + */ + @Override + public CalculationResultMap evaluate(Collection cohort, Map parameterValues, PatientCalculationContext context) { + + Concept currentRespiratoryRate = Dictionary.getConcept(Dictionary.RESPIRATORY_RATE); + CalculationResultMap artStartDates = calculate(new InitialArtStartDateCalculation(), cohort, context); + CalculationResultMap respiratoryRateObss = Calculations.allObs(currentRespiratoryRate, cohort, context); + + CalculationResultMap ret = new CalculationResultMap(); + for (Integer ptId : cohort) { + SimpleResult result = null; + Date artStartDate = EmrCalculationUtils.datetimeResultForPatient(artStartDates, ptId); + ListResult respiratoryRateObsResult = (ListResult) respiratoryRateObss.get(ptId); + + if (artStartDate != null && respiratoryRateObsResult != null && !respiratoryRateObsResult.isEmpty()) { + List pulseRate = CalculationUtils.extractResultValues(respiratoryRateObsResult); + Obs lastBeforeArtStart = EmrCalculationUtils.findLastOnOrBefore(pulseRate, artStartDate); + + if (lastBeforeArtStart != null) { + Double respiratoryRateValue = lastBeforeArtStart.getValueNumeric(); + if (respiratoryRateValue != null) { + result = new SimpleResult(respiratoryRateValue, this); + } + } + } + + ret.put(ptId, result); + } + return ret; + } +} \ No newline at end of file diff --git a/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/models/PatientSummary.java b/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/models/PatientSummary.java index 08a691c513..aeca52c21b 100755 --- a/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/models/PatientSummary.java +++ b/api/src/main/java/org/openmrs/module/kenyaemr/calculation/library/models/PatientSummary.java @@ -1,590 +1,751 @@ -/** - * 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.models; - -import org.openmrs.PersonName; - -import java.util.List; -import java.util.Set; - -/** - * Created by codehub on 11/2/15. - * a model class that hold the basics of a patient - */ -public class PatientSummary { - - private Set names; - private String upn; - private String birthDate; - private Integer age; - private String maritalStatus; - private String hivConfrimedDate; - private String firstCd4; - private String firstCd4Date; - private String dateEnrolledIntoCare; - private String whoStagingAtEnrollment; - private String patientEntryPoint; - private String dateEntryPoint; - private String transferInFacility; - private String transferInDate; - private String nameOfTreatmentSupporter; - private String relationshipToTreatmentSupporter; - private String contactOfTreatmentSupporter; - private String drigAllergies; - private String previousArt; - private String dateStartedArt; - private String artPurpose; - private String clinicalStageAtArtStart; - private String currentCd4; - private String purposeDrugs; - private String purposeDate; - private String weightAtArtStart; - private String currentRegimen; - private List ois; - private String dateOfReport; - private String clinicName; - private String mflCode; - private String gender; - private String firstRegimen; - private String cd4AtArtStart; - private String currentArtRegimen; - private String currentWhoStaging; - private String onCtx; - private String dapsone; - private String onIpt; - private String clinicsEnrolled; - private String mostRecentCd4; - private String mostRecentCd4Date; - private String mostRecentVl; - private String mostRecentVlDate; - private String artInterruptions; - private String artInterruptionReason; - private String artInterruptionDate; - private String substitutionWithFirstLine; - private String substitutionWithFirstLineReason; - private String substitutionWithFirstLineDate; - private String switchToSecondLineRegimen; - private String switchToSecondLineRegimenReason; - private String switchToSecondLineRegimenDate; - private String transferOutDate; - private String deathDate; - private String nextAppointmentDate; - - public PatientSummary() { - } - - public PatientSummary(Set names, String upn, String birthDate, Integer age, String maritalStatus, String hivConfrimedDate, String firstCd4, String firstCd4Date, String dateEnrolledIntoCare, String whoStagingAtEnrollment, String patientEntryPoint, String dateEntryPoint, String transferInStatus, String transferInDate, String nameOfTreatmentSupporter, String relationshipToTreatmentSupporter, String contactOfTreatmentSupporter, String drigAllergies, String previousArt, String dateStartedArt, String artPurpose, String clinicalStageAtArtStart, String currentCd4, String purposeDrugs, String purposeDate, String weightAtArtStart, String currentRegimen, List ois, String dateOfReport, String clinicName, String mflCode, String gender, String firstRegimen, String cd4AtArtStart, String currentArtRegimen, String currentWhoStaging, String onCtx, String dapsone, String onIpt, String clinicsEnrolled, String mostRecentCd4, String mostRecentCd4Date, String mostRecentVl, String mostRecentVlDate, String artInterruptions, String artInterruptionReason, String artInterruptionDate, String substitutionWithFirstLine, String substitutionWithFirstLineReason, String substitutionWithFirstLineDate, String switchToSecondLineRegimen, String switchToSecondLineRegimenReason, String switchToSecondLineRegimenDate, String transferOutDate, String deathDate, String nextAppointmentDate) { - this.names = names; - this.upn = upn; - this.birthDate = birthDate; - this.age = age; - this.maritalStatus = maritalStatus; - this.hivConfrimedDate = hivConfrimedDate; - this.firstCd4 = firstCd4; - this.firstCd4Date = firstCd4Date; - this.dateEnrolledIntoCare = dateEnrolledIntoCare; - this.whoStagingAtEnrollment = whoStagingAtEnrollment; - this.patientEntryPoint = patientEntryPoint; - this.dateEntryPoint = dateEntryPoint; - this.transferInFacility = transferInStatus; - this.transferInDate = transferInDate; - this.nameOfTreatmentSupporter = nameOfTreatmentSupporter; - this.relationshipToTreatmentSupporter = relationshipToTreatmentSupporter; - this.contactOfTreatmentSupporter = contactOfTreatmentSupporter; - this.drigAllergies = drigAllergies; - this.previousArt = previousArt; - this.dateStartedArt = dateStartedArt; - this.artPurpose = artPurpose; - this.clinicalStageAtArtStart = clinicalStageAtArtStart; - this.currentCd4 = currentCd4; - this.purposeDrugs = purposeDrugs; - this.purposeDate = purposeDate; - this.weightAtArtStart = weightAtArtStart; - this.currentRegimen = currentRegimen; - this.ois = ois; - this.dateOfReport = dateOfReport; - this.clinicName = clinicName; - this.mflCode = mflCode; - this.gender = gender; - this.firstRegimen = firstRegimen; - this.cd4AtArtStart = cd4AtArtStart; - this.currentArtRegimen = currentArtRegimen; - this.currentWhoStaging = currentWhoStaging; - this.onCtx = onCtx; - this.dapsone = dapsone; - this.onIpt = onIpt; - this.clinicsEnrolled = clinicsEnrolled; - this.mostRecentCd4 = mostRecentCd4; - this.mostRecentCd4Date = mostRecentCd4Date; - this.mostRecentVl = mostRecentVl; - this.mostRecentVlDate = mostRecentVlDate; - this.artInterruptions = artInterruptions; - this.artInterruptionReason = artInterruptionReason; - this.artInterruptionDate = artInterruptionDate; - this.substitutionWithFirstLine = substitutionWithFirstLine; - this.substitutionWithFirstLineReason = substitutionWithFirstLineReason; - this.substitutionWithFirstLineDate = substitutionWithFirstLineDate; - this.switchToSecondLineRegimen = switchToSecondLineRegimen; - this.switchToSecondLineRegimenReason = switchToSecondLineRegimenReason; - this.switchToSecondLineRegimenDate = switchToSecondLineRegimenDate; - this.transferOutDate = transferOutDate; - this.deathDate = deathDate; - this.nextAppointmentDate = nextAppointmentDate; - } - - public String getFirstCd4() { - return firstCd4; - } - - public void setFirstCd4(String firstCd4) { - this.firstCd4 = firstCd4; - } - - public Set getNames() { - return names; - } - - public void setNames(Set names) { - this.names = names; - } - - public String getUpn() { - return upn; - } - - public void setUpn(String upn) { - this.upn = upn; - } - - public String getBirthDate() { - return birthDate; - } - - public void setBirthDate(String birthDate) { - this.birthDate = birthDate; - } - - public Integer getAge() { - return age; - } - - public void setAge(Integer age) { - this.age = age; - } - - public String getMaritalStatus() { - return maritalStatus; - } - - public void setMaritalStatus(String maritalStatus) { - this.maritalStatus = maritalStatus; - } - - public String getHivConfrimedDate() { - return hivConfrimedDate; - } - - public void setHivConfrimedDate(String hivConfrimedDate) { - this.hivConfrimedDate = hivConfrimedDate; - } - - public String getFirstCd4Date() { - return firstCd4Date; - } - - public void setFirstCd4Date(String firstCd4Date) { - this.firstCd4Date = firstCd4Date; - } - - public String getDateEnrolledIntoCare() { - return dateEnrolledIntoCare; - } - - public void setDateEnrolledIntoCare(String dateEnrolledIntoCare) { - this.dateEnrolledIntoCare = dateEnrolledIntoCare; - } - - public String getWhoStagingAtEnrollment() { - return whoStagingAtEnrollment; - } - - public void setWhoStagingAtEnrollment(String whoStagingAtEnrollment) { - this.whoStagingAtEnrollment = whoStagingAtEnrollment; - } - - public String getPatientEntryPoint() { - return patientEntryPoint; - } - - public void setPatientEntryPoint(String patientEntryPoint) { - this.patientEntryPoint = patientEntryPoint; - } - - public String getDateEntryPoint() { - return dateEntryPoint; - } - - public void setDateEntryPoint(String dateEntryPoint) { - this.dateEntryPoint = dateEntryPoint; - } - - public String getTransferInFacility() { - return transferInFacility; - } - - public void setTransferInFacility(String transferInFacility) { - this.transferInFacility = transferInFacility; - } - - public String getTransferInDate() { - return transferInDate; - } - - public void setTransferInDate(String transferInDate) { - this.transferInDate = transferInDate; - } - - public String getNameOfTreatmentSupporter() { - return nameOfTreatmentSupporter; - } - - public void setNameOfTreatmentSupporter(String nameOfTreatmentSupporter) { - this.nameOfTreatmentSupporter = nameOfTreatmentSupporter; - } - - public String getRelationshipToTreatmentSupporter() { - return relationshipToTreatmentSupporter; - } - - public void setRelationshipToTreatmentSupporter(String relationshipToTreatmentSupporter) { - this.relationshipToTreatmentSupporter = relationshipToTreatmentSupporter; - } - - public String getContactOfTreatmentSupporter() { - return contactOfTreatmentSupporter; - } - - public void setContactOfTreatmentSupporter(String contactOfTreatmentSupporter) { - this.contactOfTreatmentSupporter = contactOfTreatmentSupporter; - } - - public String getDrigAllergies() { - return drigAllergies; - } - - public void setDrigAllergies(String drigAllergies) { - this.drigAllergies = drigAllergies; - } - - public String getPreviousArt() { - return previousArt; - } - - public void setPreviousArt(String previousArt) { - this.previousArt = previousArt; - } - - public String getDateStartedArt() { - return dateStartedArt; - } + /** + * 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.models; + + import org.openmrs.PersonName; + + import java.util.List; + import java.util.Set; + + /** + * Created by codehub on 11/2/15. + * a model class that hold the basics of a patient + */ + public class PatientSummary { + + private Set names; + private String upn; + private String birthDate; + private Integer age; + private String maritalStatus; + private String hivConfrimedDate; + private String firstCd4; + private String firstCd4Date; + private String dateEnrolledIntoCare; + private String dateEnrolledInTb; + private String dateCompletedInTb; + private String whoStagingAtEnrollment; + private String patientEntryPoint; + private String dateEntryPoint; + private String transferInFacility; + private String transferInDate; + private String nameOfTreatmentSupporter; + private String tbScreeningOutcome; + private String stiScreeningOutcome; + private String caxcScreeningOutcome; + private String pulseRate; + private String respiratoryRate; + private String bloodPressure; + private String oxygenSaturation; + private String lmp; + private String bmi; + private String kDoDNumber; + private String kDoDUnit; + private String kDoDCadre; + private String kDoDRank; + private String relationshipToTreatmentSupporter; + private String contactOfTreatmentSupporter; + private String drigAllergies; + private String previousArt; + private String dateStartedArt; + private String artPurpose; + private String clinicalStageAtArtStart; + private String currentCd4; + private String purposeDrugs; + private String purposeDate; + private String weightAtArtStart; + private String heightAtArtStart; + private String familyProtection; + private String currentRegimen; + private List ois; + private String dateOfReport; + private String clinicName; + private String mflCode; + private String gender; + private String firstRegimen; + private String cd4AtArtStart; + private String currentArtRegimen; + private String currentWhoStaging; + private String onCtx; + private String dapsone; + private String onIpt; + private String clinicsEnrolled; + private String mostRecentCd4; + private String mostRecentCd4Date; + private String mostRecentVl; + private String mostRecentVlDate; + private String artInterruptions; + private String artInterruptionReason; + private String artInterruptionDate; + private String substitutionWithFirstLine; + private String substitutionWithFirstLineReason; + private String substitutionWithFirstLineDate; + private String switchToSecondLineRegimen; + private String switchToSecondLineRegimenReason; + private String switchToSecondLineRegimenDate; + private String transferOutDate; + private String deathDate; + private String nextAppointmentDate; + + public PatientSummary() { + } + + public PatientSummary(Set names, String upn, String birthDate, Integer age, String maritalStatus, String hivConfrimedDate, String firstCd4, String firstCd4Date,String dateEnrolledInTb,String dateCompletedInTb, String dateEnrolledIntoCare, String whoStagingAtEnrollment, String patientEntryPoint, String dateEntryPoint, String transferInStatus,String tbScreeningOutcome, String stiScreeningOutcome, String kDoDCadre,String kDoDUnit ,String kDoDNumber,String kDoDRank, String caxcScreeningOutcome ,String transferInDate,String pulseRate,String bmi,String lmp, String nameOfTreatmentSupporter, String relationshipToTreatmentSupporter, String contactOfTreatmentSupporter, String drigAllergies, String previousArt, String dateStartedArt, String artPurpose, String clinicalStageAtArtStart, String currentCd4, String purposeDrugs, String purposeDate, String weightAtArtStart,String familyProtection, String heightAtArtStart, String currentRegimen, List ois, String dateOfReport, String clinicName, String mflCode, String gender, String firstRegimen, String cd4AtArtStart, String currentArtRegimen, String currentWhoStaging, String onCtx, String dapsone, String onIpt, String clinicsEnrolled, String mostRecentCd4, String mostRecentCd4Date, String mostRecentVl, String mostRecentVlDate, String artInterruptions, String artInterruptionReason, String artInterruptionDate, String substitutionWithFirstLine, String substitutionWithFirstLineReason, String substitutionWithFirstLineDate, String switchToSecondLineRegimen, String switchToSecondLineRegimenReason, String switchToSecondLineRegimenDate, String transferOutDate, String deathDate, String nextAppointmentDate, String bloodPressure,String respiratoryRate,String oxygenSaturation) { + this.names = names; + this.upn = upn; + this.birthDate = birthDate; + this.age = age; + this.maritalStatus = maritalStatus; + this.hivConfrimedDate = hivConfrimedDate; + this.firstCd4 = firstCd4; + this.kDoDCadre = kDoDCadre; + this.kDoDUnit = kDoDUnit; + this.kDoDNumber = kDoDNumber; + this.kDoDRank = kDoDRank; + this.firstCd4Date = firstCd4Date; + this.dateEnrolledIntoCare = dateEnrolledIntoCare; + this.dateEnrolledInTb = dateEnrolledInTb; + this.dateCompletedInTb = dateCompletedInTb; + this.whoStagingAtEnrollment = whoStagingAtEnrollment; + this.patientEntryPoint = patientEntryPoint; + this.dateEntryPoint = dateEntryPoint; + this.transferInFacility = transferInStatus; + this.transferInDate = transferInDate; + this.nameOfTreatmentSupporter = nameOfTreatmentSupporter; + this.bloodPressure = bloodPressure; + this.respiratoryRate = respiratoryRate; + this.oxygenSaturation = oxygenSaturation; + this.pulseRate = pulseRate; + this.tbScreeningOutcome = tbScreeningOutcome; + this.stiScreeningOutcome = stiScreeningOutcome; + this.caxcScreeningOutcome = caxcScreeningOutcome; + this.lmp = lmp; + this.bmi = bmi; + this.relationshipToTreatmentSupporter = relationshipToTreatmentSupporter; + this.contactOfTreatmentSupporter = contactOfTreatmentSupporter; + this.drigAllergies = drigAllergies; + this.previousArt = previousArt; + this.dateStartedArt = dateStartedArt; + this.artPurpose = artPurpose; + this.clinicalStageAtArtStart = clinicalStageAtArtStart; + this.currentCd4 = currentCd4; + this.purposeDrugs = purposeDrugs; + this.purposeDate = purposeDate; + this.weightAtArtStart = weightAtArtStart; + this.heightAtArtStart = heightAtArtStart; + this.familyProtection = familyProtection; + this.currentRegimen = currentRegimen; + this.ois = ois; + this.dateOfReport = dateOfReport; + this.clinicName = clinicName; + this.mflCode = mflCode; + this.gender = gender; + this.firstRegimen = firstRegimen; + this.cd4AtArtStart = cd4AtArtStart; + this.currentArtRegimen = currentArtRegimen; + this.currentWhoStaging = currentWhoStaging; + this.onCtx = onCtx; + this.dapsone = dapsone; + this.onIpt = onIpt; + this.clinicsEnrolled = clinicsEnrolled; + this.mostRecentCd4 = mostRecentCd4; + this.mostRecentCd4Date = mostRecentCd4Date; + + this.mostRecentVl = mostRecentVl; + this.mostRecentVlDate = mostRecentVlDate; + this.artInterruptions = artInterruptions; + this.artInterruptionReason = artInterruptionReason; + this.artInterruptionDate = artInterruptionDate; + this.substitutionWithFirstLine = substitutionWithFirstLine; + this.substitutionWithFirstLineReason = substitutionWithFirstLineReason; + this.substitutionWithFirstLineDate = substitutionWithFirstLineDate; + this.switchToSecondLineRegimen = switchToSecondLineRegimen; + this.switchToSecondLineRegimenReason = switchToSecondLineRegimenReason; + this.switchToSecondLineRegimenDate = switchToSecondLineRegimenDate; + this.transferOutDate = transferOutDate; + this.deathDate = deathDate; + this.nextAppointmentDate = nextAppointmentDate; + } + + public String getFirstCd4() { + return firstCd4; + } + + public void setFirstCd4(String firstCd4) { + this.firstCd4 = firstCd4; + } + + public Set getNames() { + return names; + } + + public void setNames(Set names) { + this.names = names; + } + + public String getUpn() { + return upn; + } + + public void setUpn(String upn) { + this.upn = upn; + } + + public String getBirthDate() { + return birthDate; + } + + public void setBirthDate(String birthDate) { + this.birthDate = birthDate; + } + + public Integer getAge() { + return age; + } + + public void setAge(Integer age) { + this.age = age; + } + + public String getMaritalStatus() { + return maritalStatus; + } + + public void setMaritalStatus(String maritalStatus) { + this.maritalStatus = maritalStatus; + } + + public String getHivConfrimedDate() { + return hivConfrimedDate; + } + + public void setHivConfrimedDate(String hivConfrimedDate) { + this.hivConfrimedDate = hivConfrimedDate; + } + + public String getFirstCd4Date() { + return firstCd4Date; + } + + public void setFirstCd4Date(String firstCd4Date) { + this.firstCd4Date = firstCd4Date; + } + + public String getDateEnrolledIntoCare() { + return dateEnrolledIntoCare; + } + + public void setDateEnrolledIntoCare(String dateEnrolledIntoCare) { + this.dateEnrolledIntoCare = dateEnrolledIntoCare; + } + + public String getDateEnrolledInTb() { + return dateEnrolledInTb; + } + + public void setDateEnrolledInTb(String dateEnrolledInTb) { + this.dateEnrolledInTb = dateEnrolledInTb; + } + public String getDateCompletedInTb() { + return dateCompletedInTb; + } + + public void setDateCompletedInTb(String dateCompletedInTb) { + this.dateCompletedInTb = dateCompletedInTb; + } + + public String getWhoStagingAtEnrollment() { + return whoStagingAtEnrollment; + } + + public void setWhoStagingAtEnrollment(String whoStagingAtEnrollment) { + this.whoStagingAtEnrollment = whoStagingAtEnrollment; + } + + public String getPatientEntryPoint() { + return patientEntryPoint; + } + + public void setPatientEntryPoint(String patientEntryPoint) { + this.patientEntryPoint = patientEntryPoint; + } + + public String getDateEntryPoint() { + return dateEntryPoint; + } + + public void setDateEntryPoint(String dateEntryPoint) { + this.dateEntryPoint = dateEntryPoint; + } + + public String getTransferInFacility() { + return transferInFacility; + } + + public void setTransferInFacility(String transferInFacility) { + this.transferInFacility = transferInFacility; + } + + public String getTransferInDate() { + return transferInDate; + } + + public void setTransferInDate(String transferInDate) { + this.transferInDate = transferInDate; + } + + public String getNameOfTreatmentSupporter() { + return nameOfTreatmentSupporter; + } + + public void setNameOfTreatmentSupporter(String nameOfTreatmentSupporter) { + this.nameOfTreatmentSupporter = nameOfTreatmentSupporter; + } + + public String getNameTbScreeningOutcome() { + return tbScreeningOutcome; + } + + public void setTbScreeningOutcome(String tbScreeningOutcome) { + this.tbScreeningOutcome = tbScreeningOutcome; + } + public String getStiScreeningOutcome() { + return stiScreeningOutcome; + } + + public void setStiScreeningOutcome(String stiScreeningOutcome) { + this.stiScreeningOutcome = stiScreeningOutcome; + } + public String getCaxcScreeningOutcome() { + return caxcScreeningOutcome; + } + + public void setCaxcScreeningOutcome(String caxcScreeningOutcome) { + this.caxcScreeningOutcome = caxcScreeningOutcome; + } + public String getPulseRate() { + return pulseRate; + } + + public void setPulseRate(String pulseRate) { + this.pulseRate = pulseRate; + } + + public String getLmp() { + return lmp; + } + + public void setLmp(String lmp) { + this.lmp = lmp; + } + + public String getBmi() { + return bmi; + } + public void setBmi(String bmi) { + this.bmi = bmi; + } + + + public String getKdodCadre() { + return kDoDCadre; + } + public void setKdodCadre(String kDoDCadre) { + this.kDoDCadre = kDoDCadre; + } + + public String getKdodUnit() { + return kDoDUnit; + } + public void setKdodUnit(String kDoDUnit) { + this.kDoDUnit = kDoDUnit; + } + + public String getKdodNumber() { + return kDoDNumber; + } + public void setKdodNumber(String kDoDNumber) { + this.kDoDNumber = kDoDNumber; + } + + public String getKdodRank() { + return kDoDRank; + } + public void setKdodRank(String kDoDRank) { + this.kDoDRank = kDoDRank; + } + + public String getBloodPressure() { + return bloodPressure; + } + + public void setBloodPressure(String bloodPressure) { + this.bloodPressure = bloodPressure; + } + public String getRespiratoryRate() { + return respiratoryRate; + } + + public void setRespiratoryRate(String respiratoryRate) { + this.respiratoryRate = respiratoryRate; + } + public String getOxygenSaturation() { + return oxygenSaturation; + } + + public void setOxygenSaturation(String oxygenSaturation) { + this.oxygenSaturation = oxygenSaturation; + } + + public String getRelationshipToTreatmentSupporter() { + return relationshipToTreatmentSupporter; + } + + public void setRelationshipToTreatmentSupporter(String relationshipToTreatmentSupporter) { + this.relationshipToTreatmentSupporter = relationshipToTreatmentSupporter; + } + + public String getContactOfTreatmentSupporter() { + return contactOfTreatmentSupporter; + } + + public void setContactOfTreatmentSupporter(String contactOfTreatmentSupporter) { + this.contactOfTreatmentSupporter = contactOfTreatmentSupporter; + } + + public String getDrigAllergies() { + return drigAllergies; + } + + public void setDrigAllergies(String drigAllergies) { + this.drigAllergies = drigAllergies; + } + + public String getPreviousArt() { + return previousArt; + } + + public void setPreviousArt(String previousArt) { + this.previousArt = previousArt; + } + + public String getDateStartedArt() { + return dateStartedArt; + } + + public void setDateStartedArt(String dateStartedArt) { + this.dateStartedArt = dateStartedArt; + } + + public String getArtPurpose() { + return artPurpose; + } + + public void setArtPurpose(String artPurpose) { + this.artPurpose = artPurpose; + } + + public String getClinicalStageAtArtStart() { + return clinicalStageAtArtStart; + } + + public void setClinicalStageAtArtStart(String clinicalStageAtArtStart) { + this.clinicalStageAtArtStart = clinicalStageAtArtStart; + } + + public String getCurrentCd4() { + return currentCd4; + } + + public void setCurrentCd4(String currentCd4) { + this.currentCd4 = currentCd4; + } + + public String getPurposeDrugs() { + return purposeDrugs; + } + + public void setPurposeDrugs(String purposeDrugs) { + this.purposeDrugs = purposeDrugs; + } + + public String getPurposeDate() { + return purposeDate; + } + + public void setPurposeDate(String purposeDate) { + this.purposeDate = purposeDate; + } + + public String getWeightAtArtStart() { + return weightAtArtStart; + } + + public void setWeightAtArtStart(String weightAtArtStart) { + this.weightAtArtStart = weightAtArtStart; + } - public void setDateStartedArt(String dateStartedArt) { - this.dateStartedArt = dateStartedArt; - } + public String getFamilyProtection() { + return familyProtection; + } - public String getArtPurpose() { - return artPurpose; - } + public void setFamilyProtection(String familyProtection) { + this.familyProtection = familyProtection; + } - public void setArtPurpose(String artPurpose) { - this.artPurpose = artPurpose; - } + public String getHeightAtArtStart() { + return heightAtArtStart; + } - public String getClinicalStageAtArtStart() { - return clinicalStageAtArtStart; - } + public void setHeightAtArtStart(String heightAtArtStart) { + this.heightAtArtStart = heightAtArtStart; + } - public void setClinicalStageAtArtStart(String clinicalStageAtArtStart) { - this.clinicalStageAtArtStart = clinicalStageAtArtStart; - } + public String getCurrentRegimen() { + return currentRegimen; + } - public String getCurrentCd4() { - return currentCd4; - } + public void setCurrentRegimen(String currentRegimen) { + this.currentRegimen = currentRegimen; + } - public void setCurrentCd4(String currentCd4) { - this.currentCd4 = currentCd4; - } + public List getOis() { + return ois; + } - public String getPurposeDrugs() { - return purposeDrugs; - } + public void setOis(List ois) { + this.ois = ois; + } - public void setPurposeDrugs(String purposeDrugs) { - this.purposeDrugs = purposeDrugs; - } + public String getDateOfReport() { + return dateOfReport; + } - public String getPurposeDate() { - return purposeDate; - } + public void setDateOfReport(String dateOfReport) { + this.dateOfReport = dateOfReport; + } - public void setPurposeDate(String purposeDate) { - this.purposeDate = purposeDate; - } + public String getClinicName() { + return clinicName; + } - public String getWeightAtArtStart() { - return weightAtArtStart; - } + public void setClinicName(String clinicName) { + this.clinicName = clinicName; + } - public void setWeightAtArtStart(String weightAtArtStart) { - this.weightAtArtStart = weightAtArtStart; - } + public String getMflCode() { + return mflCode; + } - public String getCurrentRegimen() { - return currentRegimen; - } + public void setMflCode(String mflCode) { + this.mflCode = mflCode; + } - public void setCurrentRegimen(String currentRegimen) { - this.currentRegimen = currentRegimen; - } + public String getGender() { + return gender; + } - public List getOis() { - return ois; - } + public void setGender(String gender) { + this.gender = gender; + } - public void setOis(List ois) { - this.ois = ois; - } + public String getFirstRegimen() { + return firstRegimen; + } - public String getDateOfReport() { - return dateOfReport; - } + public void setFirstRegimen(String firstRegimen) { + this.firstRegimen = firstRegimen; + } - public void setDateOfReport(String dateOfReport) { - this.dateOfReport = dateOfReport; - } + public String getCd4AtArtStart() { + return cd4AtArtStart; + } - public String getClinicName() { - return clinicName; - } + public void setCd4AtArtStart(String cd4AtArtStart) { + this.cd4AtArtStart = cd4AtArtStart; + } - public void setClinicName(String clinicName) { - this.clinicName = clinicName; - } + public String getCurrentArtRegimen() { + return currentArtRegimen; + } - public String getMflCode() { - return mflCode; - } + public void setCurrentArtRegimen(String currentArtRegimen) { + this.currentArtRegimen = currentArtRegimen; + } - public void setMflCode(String mflCode) { - this.mflCode = mflCode; - } + public String getCurrentWhoStaging() { + return currentWhoStaging; + } - public String getGender() { - return gender; - } + public void setCurrentWhoStaging(String currentWhoStaging) { + this.currentWhoStaging = currentWhoStaging; + } - public void setGender(String gender) { - this.gender = gender; - } + public String getOnCtx() { + return onCtx; + } - public String getFirstRegimen() { - return firstRegimen; - } + public void setOnCtx(String onCtx) { + this.onCtx = onCtx; + } - public void setFirstRegimen(String firstRegimen) { - this.firstRegimen = firstRegimen; - } + public String getDapsone() { + return dapsone; + } - public String getCd4AtArtStart() { - return cd4AtArtStart; - } + public void setDapsone(String dapsone) { + this.dapsone = dapsone; + } - public void setCd4AtArtStart(String cd4AtArtStart) { - this.cd4AtArtStart = cd4AtArtStart; - } + public String getOnIpt() { + return onIpt; + } - public String getCurrentArtRegimen() { - return currentArtRegimen; - } + public void setOnIpt(String onIpt) { + this.onIpt = onIpt; + } - public void setCurrentArtRegimen(String currentArtRegimen) { - this.currentArtRegimen = currentArtRegimen; - } + public String getClinicsEnrolled() { + return clinicsEnrolled; + } - public String getCurrentWhoStaging() { - return currentWhoStaging; - } + public void setClinicsEnrolled(String clinicsEnrolled) { + this.clinicsEnrolled = clinicsEnrolled; + } - public void setCurrentWhoStaging(String currentWhoStaging) { - this.currentWhoStaging = currentWhoStaging; - } + public String getMostRecentCd4() { + return mostRecentCd4; + } - public String getOnCtx() { - return onCtx; - } + public void setMostRecentCd4(String mostRecentCd4) { + this.mostRecentCd4 = mostRecentCd4; + } - public void setOnCtx(String onCtx) { - this.onCtx = onCtx; - } + public String getMostRecentCd4Date() { + return mostRecentCd4Date; + } - public String getDapsone() { - return dapsone; - } + public void setMostRecentCd4Date(String mostRecentCd4Date) { + this.mostRecentCd4Date = mostRecentCd4Date; + } - public void setDapsone(String dapsone) { - this.dapsone = dapsone; - } + public String getMostRecentVl() { + return mostRecentVl; + } - public String getOnIpt() { - return onIpt; - } + public void setMostRecentVl(String mostRecentVl) { + this.mostRecentVl = mostRecentVl; + } - public void setOnIpt(String onIpt) { - this.onIpt = onIpt; - } + public String getMostRecentVlDate() { + return mostRecentVlDate; + } - public String getClinicsEnrolled() { - return clinicsEnrolled; - } + public void setMostRecentVlDate(String mostRecentVlDate) { + this.mostRecentVlDate = mostRecentVlDate; + } - public void setClinicsEnrolled(String clinicsEnrolled) { - this.clinicsEnrolled = clinicsEnrolled; - } + public String getArtInterruptions() { + return artInterruptions; + } - public String getMostRecentCd4() { - return mostRecentCd4; - } - - public void setMostRecentCd4(String mostRecentCd4) { - this.mostRecentCd4 = mostRecentCd4; - } - - public String getMostRecentCd4Date() { - return mostRecentCd4Date; - } - - public void setMostRecentCd4Date(String mostRecentCd4Date) { - this.mostRecentCd4Date = mostRecentCd4Date; - } - - public String getMostRecentVl() { - return mostRecentVl; - } - - public void setMostRecentVl(String mostRecentVl) { - this.mostRecentVl = mostRecentVl; - } - - public String getMostRecentVlDate() { - return mostRecentVlDate; - } - - public void setMostRecentVlDate(String mostRecentVlDate) { - this.mostRecentVlDate = mostRecentVlDate; - } + public void setArtInterruptions(String artInterruptions) { + this.artInterruptions = artInterruptions; + } - public String getArtInterruptions() { - return artInterruptions; - } + public String getArtInterruptionReason() { + return artInterruptionReason; + } - public void setArtInterruptions(String artInterruptions) { - this.artInterruptions = artInterruptions; - } + public void setArtInterruptionReason(String artInterruptionReason) { + this.artInterruptionReason = artInterruptionReason; + } - public String getArtInterruptionReason() { - return artInterruptionReason; - } - - public void setArtInterruptionReason(String artInterruptionReason) { - this.artInterruptionReason = artInterruptionReason; - } + public String getArtInterruptionDate() { + return artInterruptionDate; + } - public String getArtInterruptionDate() { - return artInterruptionDate; - } + public void setArtInterruptionDate(String artInterruptionDate) { + this.artInterruptionDate = artInterruptionDate; + } - public void setArtInterruptionDate(String artInterruptionDate) { - this.artInterruptionDate = artInterruptionDate; - } + public String getSubstitutionWithFirstLine() { + return substitutionWithFirstLine; + } - public String getSubstitutionWithFirstLine() { - return substitutionWithFirstLine; - } + public void setSubstitutionWithFirstLine(String substitutionWithFirstLine) { + this.substitutionWithFirstLine = substitutionWithFirstLine; + } - public void setSubstitutionWithFirstLine(String substitutionWithFirstLine) { - this.substitutionWithFirstLine = substitutionWithFirstLine; - } + public String getSubstitutionWithFirstLineReason() { + return substitutionWithFirstLineReason; + } - public String getSubstitutionWithFirstLineReason() { - return substitutionWithFirstLineReason; - } + public void setSubstitutionWithFirstLineReason(String substitutionWithFirstLineReason) { + this.substitutionWithFirstLineReason = substitutionWithFirstLineReason; + } - public void setSubstitutionWithFirstLineReason(String substitutionWithFirstLineReason) { - this.substitutionWithFirstLineReason = substitutionWithFirstLineReason; - } + public String getSubstitutionWithFirstLineDate() { + return substitutionWithFirstLineDate; + } - public String getSubstitutionWithFirstLineDate() { - return substitutionWithFirstLineDate; - } + public void setSubstitutionWithFirstLineDate(String substitutionWithFirstLineDate) { + this.substitutionWithFirstLineDate = substitutionWithFirstLineDate; + } - public void setSubstitutionWithFirstLineDate(String substitutionWithFirstLineDate) { - this.substitutionWithFirstLineDate = substitutionWithFirstLineDate; - } + public String getSwitchToSecondLineRegimen() { + return switchToSecondLineRegimen; + } - public String getSwitchToSecondLineRegimen() { - return switchToSecondLineRegimen; - } + public void setSwitchToSecondLineRegimen(String switchToSecondLineRegimen) { + this.switchToSecondLineRegimen = switchToSecondLineRegimen; + } - public void setSwitchToSecondLineRegimen(String switchToSecondLineRegimen) { - this.switchToSecondLineRegimen = switchToSecondLineRegimen; - } + public String getSwitchToSecondLineRegimenReason() { + return switchToSecondLineRegimenReason; + } - public String getSwitchToSecondLineRegimenReason() { - return switchToSecondLineRegimenReason; - } + public void setSwitchToSecondLineRegimenReason(String switchToSecondLineRegimenReason) { + this.switchToSecondLineRegimenReason = switchToSecondLineRegimenReason; + } - public void setSwitchToSecondLineRegimenReason(String switchToSecondLineRegimenReason) { - this.switchToSecondLineRegimenReason = switchToSecondLineRegimenReason; - } + public String getSwitchToSecondLineRegimenDate() { + return switchToSecondLineRegimenDate; + } - public String getSwitchToSecondLineRegimenDate() { - return switchToSecondLineRegimenDate; - } + public void setSwitchToSecondLineRegimenDate(String switchToSecondLineRegimenDate) { + this.switchToSecondLineRegimenDate = switchToSecondLineRegimenDate; + } - public void setSwitchToSecondLineRegimenDate(String switchToSecondLineRegimenDate) { - this.switchToSecondLineRegimenDate = switchToSecondLineRegimenDate; - } + public String getTransferOutDate() { + return transferOutDate; + } - public String getTransferOutDate() { - return transferOutDate; - } + public void setTransferOutDate(String transferOutDate) { + this.transferOutDate = transferOutDate; + } - public void setTransferOutDate(String transferOutDate) { - this.transferOutDate = transferOutDate; - } + public String getDeathDate() { + return deathDate; + } - public String getDeathDate() { - return deathDate; - } + public void setDeathDate(String deathDate) { + this.deathDate = deathDate; + } - public void setDeathDate(String deathDate) { - this.deathDate = deathDate; - } + public String getNextAppointmentDate() { + return nextAppointmentDate; + } - public String getNextAppointmentDate() { - return nextAppointmentDate; - } + public void setNextAppointmentDate(String nextAppointmentDate) { + this.nextAppointmentDate = nextAppointmentDate; + } - public void setNextAppointmentDate(String nextAppointmentDate) { - this.nextAppointmentDate = nextAppointmentDate; } - -} diff --git a/omod/src/main/java/org/openmrs/module/kenyaemr/fragment/controller/SummariesFragmentController.java b/omod/src/main/java/org/openmrs/module/kenyaemr/fragment/controller/SummariesFragmentController.java index c84f4e0577..050fc790bc 100755 --- a/omod/src/main/java/org/openmrs/module/kenyaemr/fragment/controller/SummariesFragmentController.java +++ b/omod/src/main/java/org/openmrs/module/kenyaemr/fragment/controller/SummariesFragmentController.java @@ -1,901 +1,1079 @@ -/** - * 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.fragment.controller; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.joda.time.DateTime; -import org.joda.time.Years; -import org.openmrs.Concept; -import org.openmrs.ConceptName; -import org.openmrs.DrugOrder; -import org.openmrs.Obs; -import org.openmrs.Patient; -import org.openmrs.PatientIdentifier; -import org.openmrs.PatientIdentifierType; -import org.openmrs.PatientProgram; -import org.openmrs.PersonName; -import org.openmrs.Program; -import org.openmrs.api.PatientService; -import org.openmrs.api.context.Context; -import org.openmrs.calculation.patient.PatientCalculationContext; -import org.openmrs.calculation.patient.PatientCalculationService; -import org.openmrs.calculation.result.CalculationResult; -import org.openmrs.calculation.result.CalculationResultMap; -import org.openmrs.calculation.result.ListResult; -import org.openmrs.module.kenyacore.CoreConstants; -import org.openmrs.module.kenyacore.calculation.CalculationUtils; -import org.openmrs.module.kenyacore.calculation.Calculations; -import org.openmrs.module.kenyaemr.Dictionary; -import org.openmrs.module.kenyaemr.api.KenyaEmrService; -import org.openmrs.module.kenyaemr.calculation.EmrCalculationUtils; -import org.openmrs.module.kenyaemr.calculation.library.hiv.LastReturnVisitDateCalculation; -import org.openmrs.module.kenyaemr.calculation.library.hiv.LastWhoStageCalculation; -import org.openmrs.module.kenyaemr.calculation.library.hiv.art.CD4AtARTInitiationCalculation; -import org.openmrs.module.kenyaemr.calculation.library.hiv.art.CurrentArtRegimenCalculation; -import org.openmrs.module.kenyaemr.calculation.library.hiv.art.InitialArtRegimenCalculation; -import org.openmrs.module.kenyaemr.calculation.library.hiv.art.InitialArtStartDateCalculation; -import org.openmrs.module.kenyaemr.calculation.library.hiv.art.LastCd4CountDateCalculation; -import org.openmrs.module.kenyaemr.calculation.library.hiv.art.TransferInDateCalculation; -import org.openmrs.module.kenyaemr.calculation.library.hiv.art.TransferOutDateCalculation; -import org.openmrs.module.kenyaemr.calculation.library.hiv.art.ViralLoadAndLdlCalculation; -import org.openmrs.module.kenyaemr.calculation.library.hiv.art.WeightAtArtInitiationCalculation; -import org.openmrs.module.kenyaemr.calculation.library.hiv.art.WhoStageAtArtStartCalculation; -import org.openmrs.module.kenyaemr.calculation.library.models.PatientSummary; -import org.openmrs.module.kenyaemr.calculation.library.rdqa.DateOfDeathCalculation; -import org.openmrs.module.kenyaemr.calculation.library.rdqa.PatientProgramEnrollmentCalculation; -import org.openmrs.module.kenyaemr.metadata.HivMetadata; -import org.openmrs.module.kenyaemr.regimen.RegimenOrder; -import org.openmrs.module.metadatadeploy.MetadataUtils; -import org.openmrs.ui.framework.annotation.FragmentParam; -import org.openmrs.ui.framework.fragment.FragmentModel; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * Created by codehub on 10/30/15. - * A fragment controller for a patient summary details - */ -public class SummariesFragmentController { - protected static final Log log = LogFactory.getLog(SummariesFragmentController.class); - - public void controller(@FragmentParam("patient") Patient patient, - FragmentModel model){ - PatientSummary patientSummary = new PatientSummary(); - PatientService patientService = Context.getPatientService(); - KenyaEmrService kenyaEmrService = Context.getService(KenyaEmrService.class); - Program hivProgram = MetadataUtils.existing(Program.class, HivMetadata._Program.HIV); - Date artStartDate = null; - - patientSummary.setDateOfReport(formatDate(new Date())); - patientSummary.setClinicName(kenyaEmrService.getDefaultLocation().getName()); - patientSummary.setMflCode(kenyaEmrService.getDefaultLocationMflCode()); - //find the names - patientSummary.setNames(patient.getNames()); - //age - patientSummary.setAge(age(new Date(), patient.getBirthdate())); - //birthdate - patientSummary.setBirthDate(formatDate(patient.getBirthdate())); - //gender - patientSummary.setGender(patient.getGender()); - - PatientIdentifierType type = MetadataUtils.existing(PatientIdentifierType.class, HivMetadata._PatientIdentifierType.UNIQUE_PATIENT_NUMBER); - List upn = patientService.getPatientIdentifiers(null, Arrays.asList(type), null, Arrays.asList(patient), false); - if(upn.size() > 0){ - patientSummary.setUpn(upn.get(0).getIdentifier()); - } + /** + * 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.fragment.controller; + + import org.apache.commons.logging.Log; + import org.apache.commons.logging.LogFactory; + import org.joda.time.DateTime; + import org.joda.time.Years; + import org.openmrs.Concept; + import org.openmrs.Obs; + import org.openmrs.Patient; + import org.openmrs.PatientIdentifier; + import org.openmrs.PatientIdentifierType; + import org.openmrs.PatientProgram; + import org.openmrs.PersonName; + import org.openmrs.Program; + import org.openmrs.api.AdministrationService; + import org.openmrs.api.PatientService; + import org.openmrs.api.context.Context; + import org.openmrs.calculation.patient.PatientCalculationContext; + import org.openmrs.calculation.patient.PatientCalculationService; + import org.openmrs.calculation.result.CalculationResult; + import org.openmrs.calculation.result.CalculationResultMap; + import org.openmrs.calculation.result.ListResult; + import org.openmrs.module.kenyacore.calculation.CalculationUtils; + import org.openmrs.module.kenyacore.calculation.Calculations; + import org.openmrs.module.kenyaemr.Dictionary; + import org.openmrs.module.kenyaemr.api.KenyaEmrService; + import org.openmrs.module.kenyaemr.calculation.EmrCalculationUtils; + import org.openmrs.module.kenyaemr.calculation.library.hiv.LastReturnVisitDateCalculation; + import org.openmrs.module.kenyaemr.calculation.library.hiv.LastWhoStageCalculation; + import org.openmrs.module.kenyaemr.calculation.library.hiv.art.*; + import org.openmrs.module.kenyaemr.calculation.library.models.PatientSummary; + import org.openmrs.module.kenyaemr.calculation.library.rdqa.DateOfDeathCalculation; + import org.openmrs.module.kenyaemr.calculation.library.rdqa.PatientProgramEnrollmentCalculation; + import org.openmrs.module.kenyaemr.metadata.HivMetadata; + import org.openmrs.module.kenyaemr.metadata.TbMetadata; + import org.openmrs.module.kenyaemr.wrapper.PatientWrapper; + import org.openmrs.module.metadatadeploy.MetadataUtils; + import org.openmrs.ui.framework.annotation.FragmentParam; + import org.openmrs.ui.framework.fragment.FragmentModel; + + import java.text.DateFormat; + import java.text.SimpleDateFormat; + import java.util.ArrayList; + import java.util.Arrays; + import java.util.Calendar; + import java.util.Collections; + import java.util.Date; + import java.util.HashMap; + import java.util.HashSet; + import java.util.List; + import java.util.Map; + import java.util.Set; + + /** + * Created by codehub on 10/30/15. + * A fragment controller for a patient summary details + */ + public class SummariesFragmentController { + protected static final Log log = LogFactory.getLog(SummariesFragmentController.class); + private AdministrationService administrationService = Context.getAdministrationService(); + final String isKDoD = (administrationService.getGlobalProperty("kenyaemr.isKDoD")); + public void controller(@FragmentParam("patient") Patient patient, + FragmentModel model){ + PatientWrapper wrapper = new PatientWrapper(patient); + + PatientSummary patientSummary = new PatientSummary(); + PatientService patientService = Context.getPatientService(); + KenyaEmrService kenyaEmrService = Context.getService(KenyaEmrService.class); + Program hivProgram = MetadataUtils.existing(Program.class, HivMetadata._Program.HIV); + + + Date artStartDate = null; + + String kDoDServiceNumber; + String kDoDCadre; + String kDoDRank; + String kDoDUnit; + String uniquePatientNumber; + patientSummary.setDateOfReport(formatDate(new Date())); + patientSummary.setClinicName(kenyaEmrService.getDefaultLocation().getName()); + patientSummary.setMflCode(kenyaEmrService.getDefaultLocationMflCode()); + //find the names + patientSummary.setNames(patient.getNames()); + //age + patientSummary.setAge(age(new Date(), patient.getBirthdate())); + //birthdate + patientSummary.setBirthDate(formatDate(patient.getBirthdate())); + //gender + patientSummary.setGender(patient.getGender()); + + PatientIdentifierType type = MetadataUtils.existing(PatientIdentifierType.class, HivMetadata._PatientIdentifierType.UNIQUE_PATIENT_NUMBER); + List upn = patientService.getPatientIdentifiers(null, Arrays.asList(type), null, Arrays.asList(patient), false); + if(upn.size() > 0){ + patientSummary.setUpn(upn.get(0).getIdentifier()); + } - PatientCalculationContext context = Context.getService(PatientCalculationService.class).createCalculationContext(); - context.setNow(new Date()); + PatientCalculationContext context = Context.getService(PatientCalculationService.class).createCalculationContext(); + context.setNow(new Date()); - //get civil status - CalculationResultMap civilStatus = Calculations.lastObs(Dictionary.getConcept(Dictionary.CIVIL_STATUS), Arrays.asList(patient.getId()), context); - Concept status = EmrCalculationUtils.codedObsResultForPatient(civilStatus, patient.getPatientId()); - if(status != null){ - patientSummary.setMaritalStatus(status.getName().getName()); - } - else { - patientSummary.setMaritalStatus(""); - } + //get civil status + CalculationResultMap civilStatus = Calculations.lastObs(Dictionary.getConcept(Dictionary.CIVIL_STATUS), Arrays.asList(patient.getId()), context); + Concept status = EmrCalculationUtils.codedObsResultForPatient(civilStatus, patient.getPatientId()); + if(status != null){ + patientSummary.setMaritalStatus(status.getName().getName()); + } + else { + patientSummary.setMaritalStatus(""); + } - //date confirmed hiv positive - CalculationResultMap hivConfirmation = Calculations.lastObs(Dictionary.getConcept(Dictionary.DATE_OF_HIV_DIAGNOSIS), Arrays.asList(patient.getId()), context); - Date dateConfirmed = EmrCalculationUtils.datetimeObsResultForPatient(hivConfirmation, patient.getPatientId()); - if(dateConfirmed != null){ - patientSummary.setHivConfrimedDate(formatDate(dateConfirmed)); - } - else { - patientSummary.setHivConfrimedDate(""); - } + //date completed tb - //first cd4 count - CalculationResultMap firstCd4CountMap = Calculations.firstObs(Dictionary.getConcept(Dictionary.CD4_COUNT), Arrays.asList(patient.getId()), context); - Obs cd4Value = EmrCalculationUtils.obsResultForPatient(firstCd4CountMap, patient.getPatientId()); - if(cd4Value != null){ - patientSummary.setFirstCd4(cd4Value.getValueNumeric().toString()); - patientSummary.setFirstCd4Date(formatDate(cd4Value.getObsDatetime())); + //date confirmed hiv positive + CalculationResultMap hivConfirmation = Calculations.lastObs(Dictionary.getConcept(Dictionary.DATE_OF_HIV_DIAGNOSIS), Arrays.asList(patient.getId()), context); + Date dateConfirmed = EmrCalculationUtils.datetimeObsResultForPatient(hivConfirmation, patient.getPatientId()); + if(dateConfirmed != null){ + patientSummary.setHivConfrimedDate(formatDate(dateConfirmed)); + } + else { + patientSummary.setHivConfrimedDate(""); + } - } - else { - patientSummary.setFirstCd4(""); - patientSummary.setFirstCd4Date(""); - } - //date enrolled into care - CalculationResultMap enrolled = Calculations.firstEnrollments(hivProgram, Arrays.asList(patient.getPatientId()), context); - PatientProgram program = EmrCalculationUtils.resultForPatient(enrolled, patient.getPatientId()); - if(program != null) { - patientSummary.setDateEnrolledIntoCare(formatDate(program.getDateEnrolled())); - } - else { - patientSummary.setDateEnrolledIntoCare(""); - } + //first cd4 count + CalculationResultMap firstCd4CountMap = Calculations.firstObs(Dictionary.getConcept(Dictionary.CD4_COUNT), Arrays.asList(patient.getId()), context); + Obs cd4Value = EmrCalculationUtils.obsResultForPatient(firstCd4CountMap, patient.getPatientId()); + if(cd4Value != null){ + patientSummary.setFirstCd4(cd4Value.getValueNumeric().toString()); + patientSummary.setFirstCd4Date(formatDate(cd4Value.getObsDatetime())); - //who staging - CalculationResultMap whoStage = Calculations.firstObs(Dictionary.getConcept(Dictionary.CURRENT_WHO_STAGE), Arrays.asList(patient.getPatientId()), context); - Obs firstWhoStageObs = EmrCalculationUtils.obsResultForPatient(whoStage, patient.getPatientId()); - if(firstWhoStageObs != null){ - patientSummary.setWhoStagingAtEnrollment(whoStaging(firstWhoStageObs.getValueCoded())); - } - else { - patientSummary.setWhoStagingAtEnrollment(""); - } + } + else { + patientSummary.setFirstCd4(""); + patientSummary.setFirstCd4Date(""); + } + //date enrolled into care + CalculationResultMap enrolled = Calculations.firstEnrollments(hivProgram, Arrays.asList(patient.getPatientId()), context); + PatientProgram program = EmrCalculationUtils.resultForPatient(enrolled, patient.getPatientId()); + if(program != null) { + patientSummary.setDateEnrolledIntoCare(formatDate(program.getDateEnrolled())); + } + else { + patientSummary.setDateEnrolledIntoCare(""); + } - //patient entry point - CalculationResultMap entryPointMap = Calculations.lastObs(Dictionary.getConcept(Dictionary.METHOD_OF_ENROLLMENT), Arrays.asList(patient.getPatientId()), context); - Obs entryPointObs = EmrCalculationUtils.obsResultForPatient(entryPointMap, patient.getPatientId()); - if(entryPointObs != null) { - patientSummary.setPatientEntryPoint(entryPointAbbriviations(entryPointObs.getValueCoded())); - patientSummary.setDateEntryPoint(formatDate(entryPointObs.getObsDatetime())); - } - else { - patientSummary.setPatientEntryPoint(""); - patientSummary.setDateEntryPoint(""); - } + //patient entry point + CalculationResultMap ftPlanning = Calculations.lastObs(Dictionary.getConcept(Dictionary.METHOD_OF_FAMILY_PLANNING), Arrays.asList(patient.getPatientId()), context); + Obs ftPlanningObs = EmrCalculationUtils.obsResultForPatient(ftPlanning, patient.getPatientId()); + if(ftPlanningObs != null) { + patientSummary.setFamilyProtection(entryPointAbbriviations(ftPlanningObs.getValueCoded())); + } + else { + patientSummary.setFamilyProtection(""); + } - Set names = patient.getNames(); - StringBuilder stringBuilder = new StringBuilder(); - for(PersonName name: names){ - stringBuilder.append(name); - } - //transfer in date - CalculationResult transferInResults = EmrCalculationUtils.evaluateForPatient(TransferInDateCalculation.class, null, patient); - String tiDate; - if(transferInResults.isEmpty()){ - tiDate = "N/A"; - } - else { - tiDate = formatDate((Date) transferInResults.getValue()); - } - //facility transferred form - CalculationResultMap transferInFacilty = Calculations.lastObs(Dictionary.getConcept("160535AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), Arrays.asList(patient.getPatientId()), context); - Obs faciltyObs = EmrCalculationUtils.obsResultForPatient(transferInFacilty, patient.getPatientId()); - if(faciltyObs != null){ - patientSummary.setTransferInFacility(faciltyObs.getValueText()); - } - else { - patientSummary.setTransferInFacility("N/A"); - } - //treatment suppoter details - CalculationResultMap treatmentSupporterName = Calculations.lastObs(Dictionary.getConcept("160638AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), Arrays.asList(patient.getPatientId()), context); - CalculationResultMap treatmentSupporterRelation = Calculations.lastObs(Dictionary.getConcept("160640AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), Arrays.asList(patient.getPatientId()), context); - CalculationResultMap treatmentSupporterContacts = Calculations.lastObs(Dictionary.getConcept("160642AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), Arrays.asList(patient.getPatientId()), context); - - Obs treatmentSupporterNameObs = EmrCalculationUtils.obsResultForPatient(treatmentSupporterName, patient.getPatientId()); - Obs treatmentSupporterRelationObs = EmrCalculationUtils.obsResultForPatient(treatmentSupporterRelation, patient.getPatientId()); - Obs treatmentSupporterContactsObs = EmrCalculationUtils.obsResultForPatient(treatmentSupporterContacts, patient.getPatientId()); - if(treatmentSupporterNameObs != null){ - patientSummary.setNameOfTreatmentSupporter(treatmentSupporterNameObs.getValueText()); - } - else { - patientSummary.setNameOfTreatmentSupporter(""); - } + //who staging + CalculationResultMap whoStage = Calculations.firstObs(Dictionary.getConcept(Dictionary.CURRENT_WHO_STAGE), Arrays.asList(patient.getPatientId()), context); + Obs firstWhoStageObs = EmrCalculationUtils.obsResultForPatient(whoStage, patient.getPatientId()); + if(firstWhoStageObs != null){ + patientSummary.setWhoStagingAtEnrollment(whoStaging(firstWhoStageObs.getValueCoded())); + } + else { + patientSummary.setWhoStagingAtEnrollment(""); + } + //CaCX + CalculationResultMap cacxMap = Calculations.lastObs(Dictionary.getConcept(Dictionary.CACX_SCREENING), Arrays.asList(patient.getPatientId()), context); + Obs cacxObs = EmrCalculationUtils.obsResultForPatient(cacxMap, patient.getPatientId()); + if(cacxObs != null) { + patientSummary.setCaxcScreeningOutcome(entryPointAbbriviations(cacxObs.getValueCoded())); + } + else { + patientSummary.setCaxcScreeningOutcome(""); + } - if(treatmentSupporterRelationObs != null){ - patientSummary.setRelationshipToTreatmentSupporter(treatmentSupporterRelationObs.getValueCoded().getName().getName()); - } - else { - patientSummary.setRelationshipToTreatmentSupporter(""); - } + //STI SCREENING + CalculationResultMap stiScreen = Calculations.lastObs(Dictionary.getConcept(Dictionary.STI_SCREENING), Arrays.asList(patient.getPatientId()), context); + Obs stiObs = EmrCalculationUtils.obsResultForPatient(stiScreen, patient.getPatientId()); + if(stiObs != null) { + patientSummary.setStiScreeningOutcome(entryPointAbbriviations(stiObs.getValueCoded())); + } + else { + patientSummary.setStiScreeningOutcome(""); + } + ///TB Screening + CalculationResultMap tbMap = Calculations.lastObs(Dictionary.getConcept(Dictionary.TB_SCREENING), Arrays.asList(patient.getPatientId()), context); + Obs tbObs = EmrCalculationUtils.obsResultForPatient(tbMap, patient.getPatientId()); + if(tbObs != null) { + patientSummary.setTbScreeningOutcome(entryPointAbbriviations(tbObs.getValueCoded())); + } + else { + patientSummary.setTbScreeningOutcome(""); + } + //patient entry point + CalculationResultMap entryPointMap = Calculations.lastObs(Dictionary.getConcept(Dictionary.METHOD_OF_ENROLLMENT), Arrays.asList(patient.getPatientId()), context); + Obs entryPointObs = EmrCalculationUtils.obsResultForPatient(entryPointMap, patient.getPatientId()); + if(entryPointObs != null) { + patientSummary.setPatientEntryPoint(entryPointAbbriviations(entryPointObs.getValueCoded())); + patientSummary.setDateEntryPoint(formatDate(entryPointObs.getObsDatetime())); + } + else { + patientSummary.setPatientEntryPoint(""); + patientSummary.setDateEntryPoint(""); + } + ///TB Start date + CalculationResultMap tbConfirmation = Calculations.lastObs(Dictionary.getConcept(Dictionary.TB_START_DATE), Arrays.asList(patient.getPatientId()), context); + Obs tbDateConfirmed = EmrCalculationUtils.obsResultForPatient(tbConfirmation, patient.getPatientId()); + if(tbDateConfirmed != null) { + patientSummary.setDateEnrolledInTb(formatDate(tbDateConfirmed.getObsDatetime())); + } + else { + patientSummary.setDateEnrolledInTb(""); + } + //TB Complete date + CalculationResultMap tbCompletion = Calculations.lastObs(Dictionary.getConcept(Dictionary.TB_END_DATE), Arrays.asList(patient.getPatientId()), context); + Obs dateCompletedTB = EmrCalculationUtils.obsResultForPatient(tbCompletion, patient.getPatientId()); + if(dateCompletedTB != null) { + patientSummary.setDateCompletedInTb(formatDate(dateCompletedTB.getObsDatetime())); + } + else { + patientSummary.setDateCompletedInTb(""); + } - if(treatmentSupporterContactsObs != null){ - patientSummary.setContactOfTreatmentSupporter(treatmentSupporterContactsObs.getValueText()); - } - else { - patientSummary.setContactOfTreatmentSupporter(""); - } + Set names = patient.getNames(); + StringBuilder stringBuilder = new StringBuilder(); + for(PersonName name: names){ + stringBuilder.append(name); + } - //allergies - CalculationResultMap alergies = Calculations.allObs(Dictionary.getConcept("160643AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), Arrays.asList(patient.getPatientId()), context); - ListResult allergyResults = (ListResult) alergies.get(patient.getPatientId()); - List listOfAllergies = CalculationUtils.extractResultValues(allergyResults); - String allergies = ""; - if(listOfAllergies.size() == 0){ - allergies = "None"; - } - else if(listOfAllergies.size() == 1){ - allergies = listOfAllergies.get(0).getValueCoded().getName().getName(); - } - else{ - for (Obs obs : listOfAllergies) { - if (obs != null) { - allergies += obs.getValueCoded().getName().getName()+" "; + //transfer in date + CalculationResult transferInResults = EmrCalculationUtils.evaluateForPatient(TransferInDateCalculation.class, null, patient); + String tiDate; + if(transferInResults.isEmpty()){ + tiDate = "N/A"; + } + else { + tiDate = formatDate((Date) transferInResults.getValue()); + } + //facility transferred form + CalculationResultMap transferInFacilty = Calculations.lastObs(Dictionary.getConcept("160535AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), Arrays.asList(patient.getPatientId()), context); + Obs faciltyObs = EmrCalculationUtils.obsResultForPatient(transferInFacilty, patient.getPatientId()); + if(faciltyObs != null){ + patientSummary.setTransferInFacility(faciltyObs.getValueText()); + } + else { + patientSummary.setTransferInFacility("N/A"); + } + //treatment suppoter details + CalculationResultMap treatmentSupporterName = Calculations.lastObs(Dictionary.getConcept("160638AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), Arrays.asList(patient.getPatientId()), context); + CalculationResultMap treatmentSupporterRelation = Calculations.lastObs(Dictionary.getConcept("160640AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), Arrays.asList(patient.getPatientId()), context); + CalculationResultMap treatmentSupporterContacts = Calculations.lastObs(Dictionary.getConcept("160642AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), Arrays.asList(patient.getPatientId()), context); + + Obs treatmentSupporterNameObs = EmrCalculationUtils.obsResultForPatient(treatmentSupporterName, patient.getPatientId()); + Obs treatmentSupporterRelationObs = EmrCalculationUtils.obsResultForPatient(treatmentSupporterRelation, patient.getPatientId()); + Obs treatmentSupporterContactsObs = EmrCalculationUtils.obsResultForPatient(treatmentSupporterContacts, patient.getPatientId()); + if(treatmentSupporterNameObs != null){ + patientSummary.setNameOfTreatmentSupporter(treatmentSupporterNameObs.getValueText()); + } + else { + patientSummary.setNameOfTreatmentSupporter(""); + } + + if(treatmentSupporterRelationObs != null){ + patientSummary.setRelationshipToTreatmentSupporter(treatmentSupporterRelationObs.getValueCoded().getName().getName()); + } + else { + patientSummary.setRelationshipToTreatmentSupporter(""); + } + + if(treatmentSupporterContactsObs != null){ + patientSummary.setContactOfTreatmentSupporter(treatmentSupporterContactsObs.getValueText()); + } + else { + patientSummary.setContactOfTreatmentSupporter(""); + } + // tbScreening + CalculationResultMap chronicIllness = Calculations.allObs(Dictionary.getConcept("145439AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), Arrays.asList(patient.getPatientId()), context); + ListResult chronicIllnessResults = (ListResult) chronicIllness.get(patient.getPatientId()); + List listOfChronicIllness = CalculationUtils.extractResultValues(chronicIllnessResults); + String chronicDisease = ""; + if(listOfChronicIllness.size() == 0){ + chronicDisease = "None"; + } + else if(listOfChronicIllness.size() == 1){ + chronicDisease = listOfChronicIllness.get(0).getValueCoded().getName().getName(); + } + else{ + for (Obs obs : listOfChronicIllness) { + if (obs != null) { + chronicDisease += obs.getValueCoded().getName().getName()+" "; + } + } + } + //stiScreening + CalculationResultMap alergies = Calculations.allObs(Dictionary.getConcept("160643AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), Arrays.asList(patient.getPatientId()), context); + ListResult allergyResults = (ListResult) alergies.get(patient.getPatientId()); + List listOfAllergies = CalculationUtils.extractResultValues(allergyResults); + String allergies = ""; + if(listOfAllergies.size() == 0){ + allergies = "None"; + } + else if(listOfAllergies.size() == 1){ + allergies = listOfAllergies.get(0).getValueCoded().getName().getName(); + } + else{ + for (Obs obs : listOfAllergies) { + if (obs != null) { + allergies += obs.getValueCoded().getName().getName()+" "; + } } } - } - //previous art details - CalculationResultMap previousArt = Calculations.lastObs(Dictionary.getConcept("160533AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), Arrays.asList(patient.getPatientId()), context); - Obs previousArtObs = EmrCalculationUtils.obsResultForPatient(previousArt,patient.getPatientId()); - - if (previousArtObs != null && previousArtObs.getValueCoded() != null && previousArtObs.getValueCoded().getConceptId() == 1 && previousArtObs.getVoided().equals(false)) { - patientSummary.setPreviousArt("Yes"); - } else if (previousArtObs != null && previousArtObs.getValueCoded() != null && previousArtObs.getValueCoded().getConceptId() == 2 && previousArtObs.getVoided().equals(false)) { - patientSummary.setPreviousArt("No"); - } else { - patientSummary.setPreviousArt("None"); - } - //set the purpose for previous art - CalculationResultMap previousArtPurposePmtct = Calculations.lastObs(Dictionary.getConcept("1148AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), Arrays.asList(patient.getPatientId()), context); - CalculationResultMap previousArtPurposePep = Calculations.lastObs(Dictionary.getConcept("1691AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), Arrays.asList(patient.getPatientId()), context); - CalculationResultMap previousArtPurposeHaart = Calculations.lastObs(Dictionary.getConcept("1181AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), Arrays.asList(patient.getPatientId()), context); - Obs previousArtPurposePmtctObs = EmrCalculationUtils.obsResultForPatient(previousArtPurposePmtct, patient.getPatientId()); - Obs previousArtPurposePepObs = EmrCalculationUtils.obsResultForPatient(previousArtPurposePep, patient.getPatientId()); - Obs previousArtPurposeHaartObs = EmrCalculationUtils.obsResultForPatient(previousArtPurposeHaart, patient.getPatientId()); - String purposeString = ""; - if(patientSummary.getPreviousArt().equals("None") || patientSummary.getPreviousArt().equals("No")){ - purposeString ="None"; - } - if(previousArtPurposePmtctObs != null && previousArtPurposePmtctObs.getValueCoded() != null) { - purposeString +=previousArtReason(previousArtPurposePmtctObs.getConcept()); - } - if(previousArtPurposePepObs != null && previousArtPurposePepObs.getValueCoded() != null){ - purposeString += " "+previousArtReason(previousArtPurposePepObs.getConcept()); - } - if(previousArtPurposeHaartObs != null && previousArtPurposeHaartObs.getValueCoded() != null){ - purposeString +=" "+ previousArtReason(previousArtPurposeHaartObs.getConcept()); - } + //previous art details + CalculationResultMap previousArt = Calculations.lastObs(Dictionary.getConcept("160533AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), Arrays.asList(patient.getPatientId()), context); + Obs previousArtObs = EmrCalculationUtils.obsResultForPatient(previousArt,patient.getPatientId()); - patientSummary.setArtPurpose(purposeString); + if (previousArtObs != null && previousArtObs.getValueCoded() != null && previousArtObs.getValueCoded().getConceptId() == 1 && previousArtObs.getVoided().equals(false)) { + patientSummary.setPreviousArt("Yes"); + } else if (previousArtObs != null && previousArtObs.getValueCoded() != null && previousArtObs.getValueCoded().getConceptId() == 2 && previousArtObs.getVoided().equals(false)) { + patientSummary.setPreviousArt("No"); + } else { + patientSummary.setPreviousArt("None"); + } + //set the purpose for previous art + CalculationResultMap previousArtPurposePmtct = Calculations.lastObs(Dictionary.getConcept("1148AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), Arrays.asList(patient.getPatientId()), context); + CalculationResultMap previousArtPurposePep = Calculations.lastObs(Dictionary.getConcept("1691AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), Arrays.asList(patient.getPatientId()), context); + CalculationResultMap previousArtPurposeHaart = Calculations.lastObs(Dictionary.getConcept("1181AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), Arrays.asList(patient.getPatientId()), context); + Obs previousArtPurposePmtctObs = EmrCalculationUtils.obsResultForPatient(previousArtPurposePmtct, patient.getPatientId()); + Obs previousArtPurposePepObs = EmrCalculationUtils.obsResultForPatient(previousArtPurposePep, patient.getPatientId()); + Obs previousArtPurposeHaartObs = EmrCalculationUtils.obsResultForPatient(previousArtPurposeHaart, patient.getPatientId()); + String purposeString = ""; + if(patientSummary.getPreviousArt().equals("None") || patientSummary.getPreviousArt().equals("No")){ + purposeString ="None"; + } + if(previousArtPurposePmtctObs != null && previousArtPurposePmtctObs.getValueCoded() != null) { + purposeString +=previousArtReason(previousArtPurposePmtctObs.getConcept()); + } + if(previousArtPurposePepObs != null && previousArtPurposePepObs.getValueCoded() != null){ + purposeString += " "+previousArtReason(previousArtPurposePepObs.getConcept()); + } + if(previousArtPurposeHaartObs != null && previousArtPurposeHaartObs.getValueCoded() != null){ + purposeString +=" "+ previousArtReason(previousArtPurposeHaartObs.getConcept()); + } - //art start date - CalculationResult artStartDateResults = EmrCalculationUtils.evaluateForPatient(InitialArtStartDateCalculation.class, null, patient); - if(artStartDateResults != null) { - artStartDate = (Date) artStartDateResults.getValue(); - patientSummary.setDateStartedArt(formatDate((Date) artStartDateResults.getValue())); - } - else { - patientSummary.setDateStartedArt(""); - } + patientSummary.setArtPurpose(purposeString); - //Clinical stage at art start - CalculationResult whoStageAtArtStartResults = EmrCalculationUtils.evaluateForPatient(WhoStageAtArtStartCalculation.class, null,patient); - if(whoStageAtArtStartResults != null){ - patientSummary.setClinicalStageAtArtStart(intergerToRoman(whoStageAtArtStartResults.getValue().toString())); - } - else { - patientSummary.setClinicalStageAtArtStart(""); - } + //art start date + CalculationResult artStartDateResults = EmrCalculationUtils.evaluateForPatient(InitialArtStartDateCalculation.class, null, patient); + if(artStartDateResults != null) { + artStartDate = (Date) artStartDateResults.getValue(); + patientSummary.setDateStartedArt(formatDate((Date) artStartDateResults.getValue())); + } + else { + patientSummary.setDateStartedArt(""); + } - //cd4 at art initiation - CalculationResult cd4AtArtStartResults = EmrCalculationUtils.evaluateForPatient(CD4AtARTInitiationCalculation.class, null,patient); - if(cd4AtArtStartResults != null){ - patientSummary.setCd4AtArtStart(cd4AtArtStartResults.getValue().toString()); - } - else { - patientSummary.setCd4AtArtStart(""); - } + //Clinical stage at art start + CalculationResult whoStageAtArtStartResults = EmrCalculationUtils.evaluateForPatient(WhoStageAtArtStartCalculation.class, null,patient); + if(whoStageAtArtStartResults != null){ + patientSummary.setClinicalStageAtArtStart(intergerToRoman(whoStageAtArtStartResults.getValue().toString())); + } + else { + patientSummary.setClinicalStageAtArtStart(""); + } - //weight at art initiation - CalculationResult weightAtArtStartResults = EmrCalculationUtils.evaluateForPatient(WeightAtArtInitiationCalculation.class, null,patient); - if(weightAtArtStartResults != null){ - patientSummary.setWeightAtArtStart(weightAtArtStartResults.getValue().toString()); - } - else { - patientSummary.setWeightAtArtStart(""); - } + //cd4 at art initiation + CalculationResult cd4AtArtStartResults = EmrCalculationUtils.evaluateForPatient(CD4AtARTInitiationCalculation.class, null,patient); + if(cd4AtArtStartResults != null){ + patientSummary.setCd4AtArtStart(cd4AtArtStartResults.getValue().toString()); + } + else { + patientSummary.setCd4AtArtStart(""); + } - //first regimen for the patient - CalculationResult firstRegimenResults = EmrCalculationUtils.evaluateForPatient(InitialArtRegimenCalculation.class, null, patient); - String firstRegimen; - if(firstRegimenResults == null || firstRegimenResults.isEmpty()){ - firstRegimen = ""; - } - else { - firstRegimen = firstRegimenResults.getValue().toString(); - } - //previous drugs/regimens and dates - String regimens = ""; - String regimenDates = ""; - CalculationResultMap pmtctRegimenHivEnroll = Calculations.lastObs(Dictionary.getConcept("966AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), Arrays.asList(patient.getPatientId()), context); - CalculationResultMap pepAndHaartRegimenHivEnroll = Calculations.allObs(Dictionary.getConcept("1088AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), Arrays.asList(patient.getPatientId()), context); - - Obs obsPmtctHivEnroll = EmrCalculationUtils.obsResultForPatient(pmtctRegimenHivEnroll, patient.getPatientId()); - - ListResult listResults = (ListResult) pepAndHaartRegimenHivEnroll.get(patient.getPatientId()); - List pepAndHaartRegimenObsList = CalculationUtils.extractResultValues(listResults); - if(patientSummary.getPreviousArt().equals("None") || patientSummary.getPreviousArt().equals("No")){ - regimens = "None"; - regimenDates += "None"; - } - if(obsPmtctHivEnroll != null){ + //pulse rate + CalculationResult pulseRate = EmrCalculationUtils.evaluateForPatient(PulseRateCalculation.class, null,patient); + if(pulseRate != null){ + patientSummary.setPulseRate(pulseRate.getValue().toString()); + } + else { + patientSummary.setPulseRate(""); + } - regimens = getCorrectDrugCode(obsPmtctHivEnroll.getValueCoded()); - regimenDates = formatDate(obsPmtctHivEnroll.getObsDatetime()); - } + //Blood Pressure + CalculationResult bloodPressure = EmrCalculationUtils.evaluateForPatient(BloodPressureCalculation.class, null,patient); + if(bloodPressure != null){ + patientSummary.setBloodPressure(bloodPressure.getValue().toString()); + } + else { + patientSummary.setBloodPressure(""); + } - if(pepAndHaartRegimenObsList != null && !pepAndHaartRegimenObsList.isEmpty() && pepAndHaartRegimenObsList.size() == 1){ - regimens =getCorrectDrugCode(pepAndHaartRegimenObsList.get(0).getValueCoded()); - regimenDates =formatDate(pepAndHaartRegimenObsList.get(0).getObsDatetime()); + //respitatory Rate/ + CalculationResult respiratoryRate = EmrCalculationUtils.evaluateForPatient(RespitatoryRateCalculation.class, null,patient); + if(respiratoryRate != null){ + patientSummary.setRespiratoryRate(respiratoryRate.getValue().toString()); + } + else { + patientSummary.setRespiratoryRate(""); + } - } - else if(pepAndHaartRegimenObsList != null && !pepAndHaartRegimenObsList.isEmpty() && pepAndHaartRegimenObsList.size() > 1){ - for(Obs obs:pepAndHaartRegimenObsList) { - regimens +=getCorrectDrugCode(obs.getValueCoded())+","; - regimenDates =formatDate(obs.getObsDatetime()); + //LMP + CalculationResult lmp = EmrCalculationUtils.evaluateForPatient(LMPCalculation.class, null,patient); + if(lmp != null){ + patientSummary.setLmp(lmp.getValue().toString()); + } + else { + patientSummary.setLmp(""); } - } - patientSummary.setPurposeDrugs(regimens); - patientSummary.setPurposeDate(regimenDates); - - //past or current oisg - CalculationResultMap problemsAdded = Calculations.allObs(Dictionary.getConcept(Dictionary.PROBLEM_ADDED), Arrays.asList(patient.getPatientId()), context); - ListResult problemsAddedList = (ListResult) problemsAdded.get(patient.getPatientId()); - List problemsAddedListObs = CalculationUtils.extractResultValues(problemsAddedList); - Set ios = new HashSet(); - String iosResults = ""; - List iosIntoList = new ArrayList(); - for (Obs obs : problemsAddedListObs) { - ios.add(obs.getValueCoded().getConceptId()); - } - iosIntoList.addAll(ios); - if (iosIntoList.size() == 1) { - iosResults = ios(iosIntoList.get(0)); - } else { - for (Integer values : iosIntoList) { - if (values != 1107) { - iosResults += ios(values) + " "; - } - } + //Oxygen Saturation/ + CalculationResult oxygenSaturation = EmrCalculationUtils.evaluateForPatient(OxygenSaturationCalculation.class, null,patient); + if(oxygenSaturation != null){ + patientSummary.setOxygenSaturation(oxygenSaturation.getValue().toString()); + } + else { + patientSummary.setOxygenSaturation(""); } - //current art regimen - CalculationResult currentRegimenResults = EmrCalculationUtils.evaluateForPatient(CurrentArtRegimenCalculation.class, null, patient); - if(currentRegimenResults != null) { - String roCurrent = currentRegimenResults.toString(); - if (roCurrent != null) { - patientSummary.setCurrentArtRegimen(roCurrent); + + //height at art initiation + CalculationResult bmiResults = EmrCalculationUtils.evaluateForPatient(BMICalculation.class, null,patient); + if(bmiResults != null){ + patientSummary.setBmi(bmiResults.getValue().toString()); + } + else { + patientSummary.setBmi(""); } - } - else { - patientSummary.setCurrentArtRegimen(""); - } - //current who staging - CalculationResult currentWhoStaging = EmrCalculationUtils.evaluateForPatient(LastWhoStageCalculation.class, null, patient); - if(currentWhoStaging != null){ - patientSummary.setCurrentWhoStaging(whoStaging(((Obs) currentWhoStaging.getValue()).getValueCoded())); - } - else { - patientSummary.setCurrentWhoStaging(""); - } - //find whether this patient has been in CTX - CalculationResultMap medOrdersMapCtx = Calculations.allObs(Dictionary.getConcept(Dictionary.MEDICATION_ORDERS), Arrays.asList(patient.getPatientId()), context); - CalculationResultMap medicationDispensedCtx = Calculations.lastObs(Dictionary.getConcept(Dictionary.COTRIMOXAZOLE_DISPENSED), Arrays.asList(patient.getPatientId()), context); - - ListResult medOrdersMapListResults = (ListResult) medOrdersMapCtx.get(patient.getPatientId()); - List listOfObsCtx = CalculationUtils.extractResultValues(medOrdersMapListResults); - - Obs medicationDispensedCtxObs = EmrCalculationUtils.obsResultForPatient(medicationDispensedCtx, patient.getPatientId()); - String ctxValue = ""; - if(listOfObsCtx.size() > 0){ - Collections.reverse(listOfObsCtx); - for(Obs obs:listOfObsCtx){ - if(obs.getValueCoded().equals(Dictionary.getConcept(Dictionary.SULFAMETHOXAZOLE_TRIMETHOPRIM))){ - ctxValue = "Yes"; - break; - } + //height at art initiation + CalculationResult heightAtArtStartResults = EmrCalculationUtils.evaluateForPatient(HeightAtArtInitiationCalculation.class, null,patient); + if(heightAtArtStartResults != null){ + patientSummary.setHeightAtArtStart(heightAtArtStartResults.getValue().toString()); } - } - else if(medicationDispensedCtxObs != null && medicationDispensedCtxObs.getValueCoded().equals(Dictionary.getConcept(Dictionary.YES))){ - ctxValue = "Yes"; - } - else if(medicationDispensedCtxObs != null && medicationDispensedCtxObs.getValueCoded().equals(Dictionary.getConcept(Dictionary.NO))){ - ctxValue = "No"; - } - else if(medicationDispensedCtxObs != null && medicationDispensedCtxObs.getValueCoded().equals(Dictionary.getConcept(Dictionary.NOT_APPLICABLE))){ - ctxValue = "N/A"; - } - else { - ctxValue = "No"; - } - //Find if a patient is on dapsone - CalculationResultMap medOrdersMapDapsone = Calculations.lastObs(Dictionary.getConcept(Dictionary.MEDICATION_ORDERS), Arrays.asList(patient.getPatientId()), context); - Obs medOrdersMapObsDapsone = EmrCalculationUtils.obsResultForPatient(medOrdersMapDapsone, patient.getPatientId()); - if(medOrdersMapObsDapsone != null && medOrdersMapObsDapsone.getValueCoded().equals(Dictionary.getConcept(Dictionary.DAPSONE))){ - patientSummary.setDapsone("Yes"); - } - else if(medOrdersMapObsDapsone != null && medOrdersMapObsDapsone.getValueCoded().equals(Dictionary.getConcept(Dictionary.SULFAMETHOXAZOLE_TRIMETHOPRIM)) || medicationDispensedCtxObs != null && medicationDispensedCtxObs.getValueCoded().equals(Dictionary.getConcept(Dictionary.YES))){ - patientSummary.setDapsone("No"); - } - else { - patientSummary.setDapsone("No"); - } - //on IPT - CalculationResultMap medOrdersMapInh = Calculations.lastObs(Dictionary.getConcept(Dictionary.MEDICATION_ORDERS), Arrays.asList(patient.getPatientId()), context); - Obs medOrdersMapObsInh = EmrCalculationUtils.obsResultForPatient(medOrdersMapInh, patient.getPatientId()); - CalculationResultMap medicationDispensedIpt = Calculations.lastObs(Dictionary.getConcept(Dictionary.ISONIAZID_DISPENSED), Arrays.asList(patient.getPatientId()), context); - Obs medicationDispensedIptObs = EmrCalculationUtils.obsResultForPatient(medicationDispensedIpt, patient.getPatientId()); - if(medOrdersMapObsInh != null && medOrdersMapObsInh.getValueCoded().equals(Dictionary.getConcept(Dictionary.ISONIAZID))){ - patientSummary.setOnIpt("Yes"); - } - else if(medicationDispensedIptObs != null && medicationDispensedIptObs.getValueCoded().equals(Dictionary.getConcept(Dictionary.YES))){ - patientSummary.setOnIpt("Yes"); - } - else if(medicationDispensedIptObs != null && medicationDispensedIptObs.getValueCoded().equals(Dictionary.getConcept(Dictionary.NO))){ - patientSummary.setOnIpt("No"); - } - else if(medicationDispensedIptObs != null && medicationDispensedIptObs.getValueCoded().equals(Dictionary.getConcept(Dictionary.NOT_APPLICABLE))){ - patientSummary.setOnIpt("N/A"); - } - else { - patientSummary.setOnIpt("No"); - } + else { + patientSummary.setHeightAtArtStart(""); + } + //weight at art initiation + CalculationResult weightAtArtStartResults = EmrCalculationUtils.evaluateForPatient(WeightAtArtInitiationCalculation.class, null,patient); + if(weightAtArtStartResults != null){ + patientSummary.setWeightAtArtStart(weightAtArtStartResults.getValue().toString()); + } + else { + patientSummary.setWeightAtArtStart(""); + } + - //find clinics enrolled - CalculationResult clinicsEnrolledResult = EmrCalculationUtils.evaluateForPatient(PatientProgramEnrollmentCalculation.class, null, patient); - Set patientProgramList= new HashSet(); - List setToList = new ArrayList(); - if(clinicsEnrolledResult != null){ - List patientPrograms = (List) clinicsEnrolledResult.getValue(); - for(PatientProgram p: patientPrograms) { - patientProgramList.add(programs(p.getProgram().getConcept().getConceptId())); + + //first regimen for the patient + CalculationResult firstRegimenResults = EmrCalculationUtils.evaluateForPatient(InitialArtRegimenCalculation.class, null, patient); + String firstRegimen; + if(firstRegimenResults == null || firstRegimenResults.isEmpty()){ + firstRegimen = ""; } - } - setToList.addAll(patientProgramList); - String clinicValues = ""; - if(setToList.size() == 1){ - clinicValues = setToList.get(0); - } - else { - for(String val:setToList) { - clinicValues += val+","; + else { + firstRegimen = firstRegimenResults.getValue().toString(); } - } - //most recent cd4 - CalculationResult cd4Results = EmrCalculationUtils.evaluateForPatient(LastCd4CountDateCalculation.class, null, patient); - if(cd4Results != null && cd4Results.getValue() != null){ - patientSummary.setMostRecentCd4(((Obs) cd4Results.getValue()).getValueNumeric().toString()); - patientSummary.setMostRecentCd4Date(formatDate(((Obs) cd4Results.getValue()).getObsDatetime())); - } - else{ - patientSummary.setMostRecentCd4(""); - patientSummary.setMostRecentCd4Date(""); - } + //previous drugs/regimens and dates + String regimens = ""; + String regimenDates = ""; + CalculationResultMap pmtctRegimenHivEnroll = Calculations.lastObs(Dictionary.getConcept("966AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), Arrays.asList(patient.getPatientId()), context); + CalculationResultMap pepAndHaartRegimenHivEnroll = Calculations.allObs(Dictionary.getConcept("1088AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), Arrays.asList(patient.getPatientId()), context); + + Obs obsPmtctHivEnroll = EmrCalculationUtils.obsResultForPatient(pmtctRegimenHivEnroll, patient.getPatientId()); + + ListResult listResults = (ListResult) pepAndHaartRegimenHivEnroll.get(patient.getPatientId()); + List pepAndHaartRegimenObsList = CalculationUtils.extractResultValues(listResults); + if(patientSummary.getPreviousArt().equals("None") || patientSummary.getPreviousArt().equals("No")){ + regimens = "None"; + regimenDates += "None"; + } + if(obsPmtctHivEnroll != null){ + regimens = getCorrectDrugCode(obsPmtctHivEnroll.getValueCoded()); + regimenDates = formatDate(obsPmtctHivEnroll.getObsDatetime()); + } - //most recent viral load - CalculationResult vlResults = EmrCalculationUtils.evaluateForPatient(ViralLoadAndLdlCalculation.class, null, patient); + if(pepAndHaartRegimenObsList != null && !pepAndHaartRegimenObsList.isEmpty() && pepAndHaartRegimenObsList.size() == 1){ + regimens =getCorrectDrugCode(pepAndHaartRegimenObsList.get(0).getValueCoded()); + regimenDates =formatDate(pepAndHaartRegimenObsList.get(0).getObsDatetime()); - String viralLoadValue = "None"; - String viralLoadDate = "None"; - if(!vlResults.isEmpty()) { - String values = vlResults.getValue().toString(); - //split by brace - String value = values.replaceAll("\\{", "").replaceAll("\\}",""); - if(!value.isEmpty()) { - String[] splitByEqualSign = value.split("="); - viralLoadValue = splitByEqualSign[0]; + } + else if(pepAndHaartRegimenObsList != null && !pepAndHaartRegimenObsList.isEmpty() && pepAndHaartRegimenObsList.size() > 1){ + for(Obs obs:pepAndHaartRegimenObsList) { + regimens +=getCorrectDrugCode(obs.getValueCoded())+","; + regimenDates =formatDate(obs.getObsDatetime()); + } + } + patientSummary.setPurposeDrugs(regimens); + patientSummary.setPurposeDate(regimenDates); + + //past or current oisg + CalculationResultMap problemsAdded = Calculations.allObs(Dictionary.getConcept(Dictionary.PROBLEM_ADDED), Arrays.asList(patient.getPatientId()), context); + ListResult problemsAddedList = (ListResult) problemsAdded.get(patient.getPatientId()); + List problemsAddedListObs = CalculationUtils.extractResultValues(problemsAddedList); + + Set ios = new HashSet(); + String iosResults = ""; + List iosIntoList = new ArrayList(); + for (Obs obs : problemsAddedListObs) { + ios.add(obs.getValueCoded().getConceptId()); + } + iosIntoList.addAll(ios); + if (iosIntoList.size() == 1) { + iosResults = ios(iosIntoList.get(0)); + } else { + for (Integer values : iosIntoList) { + if (values != 1107) { + iosResults += ios(values) + " "; + } + } + } - //for a date from a string - String dateSplitedBySpace = splitByEqualSign[1].split(" ")[0].trim(); - String yearPart = dateSplitedBySpace.split("-")[0].trim(); - String monthPart = dateSplitedBySpace.split("-")[1].trim(); - String dayPart = dateSplitedBySpace.split("-")[2].trim(); + //current art regimen + CalculationResult currentRegimenResults = EmrCalculationUtils.evaluateForPatient(CurrentArtRegimenCalculation.class, null, patient); + if(currentRegimenResults != null) { + String roCurrent = currentRegimenResults.toString(); + if (roCurrent != null) { + patientSummary.setCurrentArtRegimen(roCurrent); + } + } + else { + patientSummary.setCurrentArtRegimen(""); + } - Calendar calendar = Calendar.getInstance(); - calendar.set(Calendar.YEAR, Integer.parseInt(yearPart)); - calendar.set(Calendar.MONTH, Integer.parseInt(monthPart) - 1); - calendar.set(Calendar.DATE, Integer.parseInt(dayPart)); + //current who staging + CalculationResult currentWhoStaging = EmrCalculationUtils.evaluateForPatient(LastWhoStageCalculation.class, null, patient); + if(currentWhoStaging != null){ + patientSummary.setCurrentWhoStaging(whoStaging(((Obs) currentWhoStaging.getValue()).getValueCoded())); + } + else { + patientSummary.setCurrentWhoStaging(""); + } + //find whether this patient has been in CTX + CalculationResultMap medOrdersMapCtx = Calculations.allObs(Dictionary.getConcept(Dictionary.MEDICATION_ORDERS), Arrays.asList(patient.getPatientId()), context); + CalculationResultMap medicationDispensedCtx = Calculations.lastObs(Dictionary.getConcept(Dictionary.COTRIMOXAZOLE_DISPENSED), Arrays.asList(patient.getPatientId()), context); + + ListResult medOrdersMapListResults = (ListResult) medOrdersMapCtx.get(patient.getPatientId()); + List listOfObsCtx = CalculationUtils.extractResultValues(medOrdersMapListResults); + + Obs medicationDispensedCtxObs = EmrCalculationUtils.obsResultForPatient(medicationDispensedCtx, patient.getPatientId()); + String ctxValue = ""; + if(listOfObsCtx.size() > 0){ + Collections.reverse(listOfObsCtx); + for(Obs obs:listOfObsCtx){ + if(obs.getValueCoded().equals(Dictionary.getConcept(Dictionary.SULFAMETHOXAZOLE_TRIMETHOPRIM))){ + ctxValue = "Yes"; + break; + } + } + } + else if(medicationDispensedCtxObs != null && medicationDispensedCtxObs.getValueCoded().equals(Dictionary.getConcept(Dictionary.YES))){ + ctxValue = "Yes"; + } + else if(medicationDispensedCtxObs != null && medicationDispensedCtxObs.getValueCoded().equals(Dictionary.getConcept(Dictionary.NO))){ + ctxValue = "No"; + } + else if(medicationDispensedCtxObs != null && medicationDispensedCtxObs.getValueCoded().equals(Dictionary.getConcept(Dictionary.NOT_APPLICABLE))){ + ctxValue = "N/A"; + } + else { + ctxValue = "No"; + } + //Find if a patient is on dapsone + CalculationResultMap medOrdersMapDapsone = Calculations.lastObs(Dictionary.getConcept(Dictionary.MEDICATION_ORDERS), Arrays.asList(patient.getPatientId()), context); + Obs medOrdersMapObsDapsone = EmrCalculationUtils.obsResultForPatient(medOrdersMapDapsone, patient.getPatientId()); + if(medOrdersMapObsDapsone != null && medOrdersMapObsDapsone.getValueCoded().equals(Dictionary.getConcept(Dictionary.DAPSONE))){ + patientSummary.setDapsone("Yes"); + } + else if(medOrdersMapObsDapsone != null && medOrdersMapObsDapsone.getValueCoded().equals(Dictionary.getConcept(Dictionary.SULFAMETHOXAZOLE_TRIMETHOPRIM)) || medicationDispensedCtxObs != null && medicationDispensedCtxObs.getValueCoded().equals(Dictionary.getConcept(Dictionary.YES))){ + patientSummary.setDapsone("No"); + } + else { + patientSummary.setDapsone("No"); + } + //on IPT + CalculationResultMap medOrdersMapInh = Calculations.lastObs(Dictionary.getConcept(Dictionary.MEDICATION_ORDERS), Arrays.asList(patient.getPatientId()), context); + Obs medOrdersMapObsInh = EmrCalculationUtils.obsResultForPatient(medOrdersMapInh, patient.getPatientId()); + CalculationResultMap medicationDispensedIpt = Calculations.lastObs(Dictionary.getConcept(Dictionary.ISONIAZID_DISPENSED), Arrays.asList(patient.getPatientId()), context); + Obs medicationDispensedIptObs = EmrCalculationUtils.obsResultForPatient(medicationDispensedIpt, patient.getPatientId()); + if(medOrdersMapObsInh != null && medOrdersMapObsInh.getValueCoded().equals(Dictionary.getConcept(Dictionary.ISONIAZID))){ + patientSummary.setOnIpt("Yes"); + } + else if(medicationDispensedIptObs != null && medicationDispensedIptObs.getValueCoded().equals(Dictionary.getConcept(Dictionary.YES))){ + patientSummary.setOnIpt("Yes"); + } + else if(medicationDispensedIptObs != null && medicationDispensedIptObs.getValueCoded().equals(Dictionary.getConcept(Dictionary.NO))){ + patientSummary.setOnIpt("No"); + } + else if(medicationDispensedIptObs != null && medicationDispensedIptObs.getValueCoded().equals(Dictionary.getConcept(Dictionary.NOT_APPLICABLE))){ + patientSummary.setOnIpt("N/A"); + } + else { + patientSummary.setOnIpt("No"); + } - viralLoadDate = formatDate(calendar.getTime()); + //find clinics enrolled + CalculationResult clinicsEnrolledResult = EmrCalculationUtils.evaluateForPatient(PatientProgramEnrollmentCalculation.class, null, patient); + Set patientProgramList= new HashSet(); + List setToList = new ArrayList(); + if(clinicsEnrolledResult != null){ + List patientPrograms = (List) clinicsEnrolledResult.getValue(); + for(PatientProgram p: patientPrograms) { + + patientProgramList.add(programs(p.getProgram().getConcept().getConceptId())); + } + } + setToList.addAll(patientProgramList); + String clinicValues = ""; + if(setToList.size() == 1){ + clinicValues = setToList.get(0); + } + else { + for(String val:setToList) { + clinicValues += val+","; + } + } + //most recent cd4 + CalculationResult cd4Results = EmrCalculationUtils.evaluateForPatient(LastCd4CountDateCalculation.class, null, patient); + if(cd4Results != null && cd4Results.getValue() != null){ + patientSummary.setMostRecentCd4(((Obs) cd4Results.getValue()).getValueNumeric().toString()); + patientSummary.setMostRecentCd4Date(formatDate(((Obs) cd4Results.getValue()).getObsDatetime())); + } + else{ + patientSummary.setMostRecentCd4(""); + patientSummary.setMostRecentCd4Date(""); } - } - // find deceased date - CalculationResult deadResults = EmrCalculationUtils.evaluateForPatient(DateOfDeathCalculation.class, null, patient); - String dead; - if(deadResults.isEmpty()){ - dead = "N/A"; - } - else { - dead = formatDate((Date) deadResults.getValue()); - } + //most recent viral load + CalculationResult vlResults = EmrCalculationUtils.evaluateForPatient(ViralLoadAndLdlCalculation.class, null, patient); - // next appointment date - CalculationResult returnVisitResults = EmrCalculationUtils.evaluateForPatient(LastReturnVisitDateCalculation.class, null, patient); - if(returnVisitResults != null){ - patientSummary.setNextAppointmentDate(formatDate((Date) returnVisitResults.getValue())); - } - else { - patientSummary.setNextAppointmentDate(""); - } - // transfer out date - CalculationResult totResults = EmrCalculationUtils.evaluateForPatient(TransferOutDateCalculation.class, null, patient); - String toDate; - if(totResults.isEmpty()){ - toDate = "N/A"; - } - else { - toDate = formatDate((Date) totResults.getValue()); - } - //transfer out to facility - String toFacility; - CalculationResultMap transferOutFacilty = Calculations.lastObs(Dictionary.getConcept("159495AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), Arrays.asList(patient.getPatientId()), context); - Obs transferOutFacilityObs = EmrCalculationUtils.obsResultForPatient(transferOutFacilty, patient.getPatientId()); - if(transferOutFacilityObs != null){ - toFacility = transferOutFacilityObs.getValueText(); - } - else { - toFacility = "N/A"; - } + String viralLoadValue = "None"; + String viralLoadDate = "None"; + if(!vlResults.isEmpty()) { + String values = vlResults.getValue().toString(); + //split by brace + String value = values.replaceAll("\\{", "").replaceAll("\\}",""); + if(!value.isEmpty()) { + String[] splitByEqualSign = value.split("="); + viralLoadValue = splitByEqualSign[0]; - model.addAttribute("patient", patientSummary); - model.addAttribute("names", stringBuilder); - model.addAttribute("currentRegimen", patientSummary.getCurrentArtRegimen()); - model.addAttribute("onCtx", ctxValue); - model.addAttribute("onDapsone", patientSummary.getDapsone()); - model.addAttribute("onIpt", patientSummary.getOnIpt()); - model.addAttribute("programs", patientSummary.getClinicsEnrolled()); - model.addAttribute("recentCd4Count", patientSummary.getMostRecentCd4()); - model.addAttribute("recentCd4CountDate", patientSummary.getMostRecentCd4Date()); - model.addAttribute("recentVl", viralLoadValue); - model.addAttribute("recentVlDate", viralLoadDate); - model.addAttribute("deadDeath", dead); - model.addAttribute("returnVisitDate", patientSummary.getNextAppointmentDate()); - model.addAttribute("toDate", toDate); - model.addAttribute("toFacility", toFacility); - model.addAttribute("tiDate", tiDate); - model.addAttribute("allergies", allergies); - model.addAttribute("iosResults", iosResults); - model.addAttribute("clinicValues", clinicValues); - model.addAttribute("firstRegimen", firstRegimen); - } + //for a date from a string + String dateSplitedBySpace = splitByEqualSign[1].split(" ")[0].trim(); + String yearPart = dateSplitedBySpace.split("-")[0].trim(); + String monthPart = dateSplitedBySpace.split("-")[1].trim(); + String dayPart = dateSplitedBySpace.split("-")[2].trim(); - private String formatDate(Date date) { - DateFormat dateFormatter = new SimpleDateFormat("dd/MM/yyyy"); - return date == null?"":dateFormatter.format(date); - } + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.YEAR, Integer.parseInt(yearPart)); + calendar.set(Calendar.MONTH, Integer.parseInt(monthPart) - 1); + calendar.set(Calendar.DATE, Integer.parseInt(dayPart)); - private int age(Date d1, Date d2){ - DateTime birthDate = new DateTime(d1.getTime()); - DateTime today = new DateTime(d2.getTime()); + viralLoadDate = formatDate(calendar.getTime()); + } + } + if(isKDoD.equals("true")){ + kDoDServiceNumber = wrapper.getKDoDServiceNumber(); + kDoDCadre = wrapper.getCadre(); + kDoDRank = wrapper.getRank(); + kDoDUnit = wrapper.getKDoDUnit(); + } + else{ + uniquePatientNumber = wrapper.getUniquePatientNumber(); + } + // find deceased date + CalculationResult deadResults = EmrCalculationUtils.evaluateForPatient(DateOfDeathCalculation.class, null, patient); + String dead; + if(deadResults.isEmpty()){ + dead = "N/A"; + } + else { + dead = formatDate((Date) deadResults.getValue()); + } - return Math.abs(Years.yearsBetween(today, birthDate).getYears()); - } + // next appointment date + CalculationResult returnVisitResults = EmrCalculationUtils.evaluateForPatient(LastReturnVisitDateCalculation.class, null, patient); + if(returnVisitResults != null){ + patientSummary.setNextAppointmentDate(formatDate((Date) returnVisitResults.getValue())); + } + else { + patientSummary.setNextAppointmentDate(""); + } + // transfer out date + CalculationResult totResults = EmrCalculationUtils.evaluateForPatient(TransferOutDateCalculation.class, null, patient); + String toDate; + if(totResults.isEmpty()){ + toDate = "N/A"; + } + else { + toDate = formatDate((Date) totResults.getValue()); + } + //transfer out to facility + String toFacility; + CalculationResultMap transferOutFacilty = Calculations.lastObs(Dictionary.getConcept("159495AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"), Arrays.asList(patient.getPatientId()), context); + Obs transferOutFacilityObs = EmrCalculationUtils.obsResultForPatient(transferOutFacilty, patient.getPatientId()); + if(transferOutFacilityObs != null){ + toFacility = transferOutFacilityObs.getValueText(); + } + else { + toFacility = "N/A"; + } + /*Create list of cadre answer concepts */ + List cadreOptions = Arrays.asList( + new String("Troop"), + new String("Civilian") + ); + model.addAttribute("cadreOptions", cadreOptions); + /*Create list of rank answer Options */ + List rankOptions = Arrays.asList( + new String("General(Gen)"), + new String("Lieutenant General (Lt Gen)"), + new String("Major General (Maj Gen)"), + new String("Brigadier (Brig)"), + new String("Colonel (Col)"), + new String("Lieutenant Colonel (Lt Col)"), + new String("Major (Maj)"), + new String("Captain (Capt)"), + new String("Lieutenant (Lt)"), + new String("2nd Lieutenant (2lt)"), + new String("Warrant officer 1 (WO1)"), + new String("Warrant officer 2 (WO2)"), + new String("Senior Sergeant (Ssgt)"), + new String("Sergeant (Sgt)"), + new String("Corporal (Cpl)"), + new String("Private (Spte)") + ); + model.addAttribute("rankOptions", rankOptions); + model.addAttribute("isKDoD", isKDoD); + model.addAttribute("patient", patientSummary); + model.addAttribute("names", stringBuilder); + model.addAttribute("currentRegimen", patientSummary.getCurrentArtRegimen()); + model.addAttribute("familyProtection", patientSummary.getFamilyProtection()); + model.addAttribute("onCtx", ctxValue); + model.addAttribute("onDapsone", patientSummary.getDapsone()); + model.addAttribute("onIpt", patientSummary.getOnIpt()); + model.addAttribute("programs", patientSummary.getClinicsEnrolled()); + model.addAttribute("recentCd4Count", patientSummary.getMostRecentCd4()); + model.addAttribute("recentCd4CountDate", patientSummary.getMostRecentCd4Date()); + model.addAttribute("recentVl", viralLoadValue); + model.addAttribute("recentVlDate", viralLoadDate); + model.addAttribute("deadDeath", dead); + model.addAttribute("returnVisitDate", patientSummary.getNextAppointmentDate()); + model.addAttribute("toDate", toDate); + model.addAttribute("toFacility", toFacility); + model.addAttribute("tiDate", tiDate); + model.addAttribute("allergies", allergies); + model.addAttribute("iosResults", iosResults); + model.addAttribute("clinicValues", clinicValues); + model.addAttribute("firstRegimen", firstRegimen); + model.addAttribute("chronicDisease", chronicDisease); + + + } + + private String formatDate(Date date) { + DateFormat dateFormatter = new SimpleDateFormat("dd/MM/yyyy"); + return date == null?"":dateFormatter.format(date); + } + + private int age(Date d1, Date d2){ + DateTime birthDate = new DateTime(d1.getTime()); + DateTime today = new DateTime(d2.getTime()); + + return Math.abs(Years.yearsBetween(today, birthDate).getYears()); + } + + String entryPointAbbriviations(Concept concept) { + String value = "Other"; + if(concept.equals(Dictionary.getConcept(Dictionary.VCT_PROGRAM))) { + value = "VCT"; + } + else if(concept.equals(Dictionary.getConcept(Dictionary.PMTCT_PROGRAM))){ + value = "PMTCT"; + } + else if(concept.equals(Dictionary.getConcept(Dictionary.PEDIATRIC_INPATIENT_SERVICE))){ + value = "IPD-P"; + } + else if(concept.equals(Dictionary.getConcept(Dictionary.ADULT_INPATIENT_SERVICE))){ + value = "IPD-A"; + } - String entryPointAbbriviations(Concept concept) { - String value = "Other"; - if(concept.equals(Dictionary.getConcept(Dictionary.VCT_PROGRAM))) { - value = "VCT"; - } - else if(concept.equals(Dictionary.getConcept(Dictionary.PMTCT_PROGRAM))){ - value = "PMTCT"; - } - else if(concept.equals(Dictionary.getConcept(Dictionary.PEDIATRIC_INPATIENT_SERVICE))){ - value = "IPD-P"; - } - else if(concept.equals(Dictionary.getConcept(Dictionary.ADULT_INPATIENT_SERVICE))){ - value = "IPD-A"; - } + else if(concept.equals(Dictionary.getConcept("160542AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ + value = "OPD"; + } - else if(concept.equals(Dictionary.getConcept("160542AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ - value = "OPD"; - } + else if(concept.equals(Dictionary.getConcept(Dictionary.TUBERCULOSIS_TREATMENT_PROGRAM))){ + value = "TB"; + } + else if(concept.equals(Dictionary.getConcept("160543AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ + value = "CBO"; + } + else if(concept.equals(Dictionary.getConcept("160543AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ + value = "CBO"; + } - else if(concept.equals(Dictionary.getConcept(Dictionary.TUBERCULOSIS_TREATMENT_PROGRAM))){ - value = "TB"; - } - else if(concept.equals(Dictionary.getConcept("160543AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ - value = "CBO"; - } - else if(concept.equals(Dictionary.getConcept("160543AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ - value = "CBO"; - } + else if(concept.equals(Dictionary.getConcept(Dictionary.UNDER_FIVE_CLINIC))){ + value = "UNDER FIVE"; + } - else if(concept.equals(Dictionary.getConcept(Dictionary.UNDER_FIVE_CLINIC))){ - value = "UNDER FIVE"; - } + else if(concept.equals(Dictionary.getConcept("160546AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ + value = "STI"; + } - else if(concept.equals(Dictionary.getConcept("160546AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ - value = "STI"; - } + else if(concept.equals(Dictionary.getConcept("160548AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ + value = "IDU"; + } - else if(concept.equals(Dictionary.getConcept("160548AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ - value = "IDU"; - } + else if(concept.equals(Dictionary.getConcept("160548AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ + value = "IDU"; + } - else if(concept.equals(Dictionary.getConcept("160548AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ - value = "IDU"; - } + else if(concept.equals(Dictionary.getConcept(Dictionary.MATERNAL_AND_CHILD_HEALTH_PROGRAM))){ + value = "MCH"; + } - else if(concept.equals(Dictionary.getConcept(Dictionary.MATERNAL_AND_CHILD_HEALTH_PROGRAM))){ - value = "MCH"; - } + else if(concept.equals(Dictionary.getConcept("162223AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ + value = "VMMC"; + } - else if(concept.equals(Dictionary.getConcept("162223AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ - value = "VMMC"; - } + else if(concept.equals(Dictionary.getConcept(Dictionary.TRANSFER_IN))){ + value = "TI"; + } - else if(concept.equals(Dictionary.getConcept(Dictionary.TRANSFER_IN))){ - value = "TI"; + return value; } - return value; - } + String whoStaging(Concept concept){ + String stage = ""; + if(concept.equals(Dictionary.getConcept(Dictionary.WHO_STAGE_1_ADULT)) || concept.equals(Dictionary.getConcept(Dictionary.WHO_STAGE_1_PEDS))){ - String whoStaging(Concept concept){ - String stage = ""; - if(concept.equals(Dictionary.getConcept(Dictionary.WHO_STAGE_1_ADULT)) || concept.equals(Dictionary.getConcept(Dictionary.WHO_STAGE_1_PEDS))){ + stage = "I"; + } + else if(concept.equals(Dictionary.getConcept(Dictionary.WHO_STAGE_2_ADULT)) || concept.equals(Dictionary.getConcept(Dictionary.WHO_STAGE_2_PEDS))){ - stage = "I"; - } - else if(concept.equals(Dictionary.getConcept(Dictionary.WHO_STAGE_2_ADULT)) || concept.equals(Dictionary.getConcept(Dictionary.WHO_STAGE_2_PEDS))){ + stage = "II"; + } + else if(concept.equals(Dictionary.getConcept(Dictionary.WHO_STAGE_3_ADULT)) || concept.equals(Dictionary.getConcept(Dictionary.WHO_STAGE_3_PEDS))){ - stage = "II"; - } - else if(concept.equals(Dictionary.getConcept(Dictionary.WHO_STAGE_3_ADULT)) || concept.equals(Dictionary.getConcept(Dictionary.WHO_STAGE_3_PEDS))){ + stage = "III"; + } + else if(concept.equals(Dictionary.getConcept(Dictionary.WHO_STAGE_4_ADULT)) || concept.equals(Dictionary.getConcept(Dictionary.WHO_STAGE_4_PEDS))){ - stage = "III"; + stage = "IV"; + } + return stage; } - else if(concept.equals(Dictionary.getConcept(Dictionary.WHO_STAGE_4_ADULT)) || concept.equals(Dictionary.getConcept(Dictionary.WHO_STAGE_4_PEDS))){ - stage = "IV"; - } - return stage; - } + String previousArtReason(Concept concept){ + String value = ""; + if(concept.equals(Dictionary.getConcept("1148AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ + value ="PMTCT"; + } + else if(concept.equals(Dictionary.getConcept("1691AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ + value = "PEP"; + } - String previousArtReason(Concept concept){ - String value = ""; - if(concept.equals(Dictionary.getConcept("1148AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ - value ="PMTCT"; - } - else if(concept.equals(Dictionary.getConcept("1691AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ - value = "PEP"; + else if(concept.equals(Dictionary.getConcept("1181AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ + value = "HAART"; + } + return value; } + String ios(Integer concept) { + String value ; + if(concept.equals(123358)){ + value = "Zoster"; + } + else if(concept.equals(5334)){ + value = "Thrush - oral"; + } + else if(concept.equals(298)){ + value = "Thrush - vaginal"; + } + else if(concept.equals(143264)){ + value = "Cough"; + } + else if(concept.equals(122496)){ + value = "Difficult breathing"; + } + else if(concept.equals(140238)){ + value = "Fever"; + } + else if(concept.equals(487)){ + value = "Dementia/Enceph"; + } + else if(concept.equals(150796)){ + value = "Weight loss"; + } + else if(concept.equals(114100)){ + value = "Pneumonia"; + } + else if(concept.equals(123529)){ + value = "Urethral discharge"; + } + else if(concept.equals(902)){ + value = "Pelvic inflammatory disease"; + } + else if(concept.equals(111721)){ + value = "Ulcers - mouth"; + } + else if(concept.equals(120939)){ + value = "Ulcers - other"; + } + else if(concept.equals(145762)){ + value = "Genital ulcer disease"; + } + else if(concept.equals(140707)){ + value = "Poor weight gain"; + } + else if(concept.equals(112141)){ + value = "Tuberculosis"; + } + else if(concept.equals(160028)){ + value = "Immune reconstitution inflammatory syndrome"; + } + else if(concept.equals(162330)){ + value = "Severe uncomplicated malnutrition"; + } + else if(concept.equals(162331)){ + value = "Severe complicated malnutrition"; + } - else if(concept.equals(Dictionary.getConcept("1181AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ - value = "HAART"; - } - return value; - } - String ios(Integer concept) { - String value ; - if(concept.equals(123358)){ - value = "Zoster"; - } - else if(concept.equals(5334)){ - value = "Thrush - oral"; - } - else if(concept.equals(298)){ - value = "Thrush - vaginal"; - } - else if(concept.equals(143264)){ - value = "Cough"; - } - else if(concept.equals(122496)){ - value = "Difficult breathing"; - } - else if(concept.equals(140238)){ - value = "Fever"; - } - else if(concept.equals(487)){ - value = "Dementia/Enceph"; - } - else if(concept.equals(150796)){ - value = "Weight loss"; - } - else if(concept.equals(114100)){ - value = "Pneumonia"; - } - else if(concept.equals(123529)){ - value = "Urethral discharge"; - } - else if(concept.equals(902)){ - value = "Pelvic inflammatory disease"; - } - else if(concept.equals(111721)){ - value = "Ulcers - mouth"; - } - else if(concept.equals(120939)){ - value = "Ulcers - other"; - } - else if(concept.equals(145762)){ - value = "Genital ulcer disease"; - } - else if(concept.equals(140707)){ - value = "Poor weight gain"; - } - else if(concept.equals(112141)){ - value = "Tuberculosis"; - } - else if(concept.equals(160028)){ - value = "Immune reconstitution inflammatory syndrome"; - } - else if(concept.equals(162330)){ - value = "Severe uncomplicated malnutrition"; - } - else if(concept.equals(162331)){ - value = "Severe complicated malnutrition"; - } + else if(concept.equals(1107)){ + value = "None"; + } - else if(concept.equals(1107)){ - value = "None"; + else { + value = Context.getConceptService().getConcept(concept).getName().getName(); + } + return value; } - else { - value = Context.getConceptService().getConcept(concept).getName().getName(); - } - return value; - } + Map> standardRegimens(){ - Map> standardRegimens(){ - - Map> listMap = new HashMap>(); - listMap.put("AZT+3TC+NVP", Arrays.asList("ZIDOVUDINE","LAMIVUDINE", "NEVIRAPINE" )); - listMap.put("AZT+3TC+EFV", Arrays.asList("ZIDOVUDINE","LAMIVUDINE", "EFAVIRENZ" )); - listMap.put("AZT+3TC+ABC", Arrays.asList("ZIDOVUDINE","LAMIVUDINE", "ABACAVIR" )); - - listMap.put("TDF+3TC+NVP", Arrays.asList("TENOFOVIR","LAMIVUDINE", "NEVIRAPINE" )); - listMap.put("TDF+3TC+EFV", Arrays.asList("TENOFOVIR","LAMIVUDINE", "EFAVIRENZ" )); - listMap.put("TDF+3TC+ABC", Arrays.asList("TENOFOVIR","LAMIVUDINE", "ABACAVIR" )); - listMap.put("TDF+3TC+AZT", Arrays.asList("TENOFOVIR","LAMIVUDINE", "ZIDOVUDINE" )); - - listMap.put("d4T+3TC+NVP", Arrays.asList("STAVUDINE","LAMIVUDINE", "NEVIRAPINE" )); - listMap.put("d4T+3TC+EFV", Arrays.asList("STAVUDINE","LAMIVUDINE", "EFAVIRENZ" )); - listMap.put("d4T+3TC+ABC", Arrays.asList("STAVUDINE","LAMIVUDINE", "ABACAVIR" )); - - listMap.put("AZT+3TC+LPV/r", Arrays.asList("ZIDOVUDINE","LAMIVUDINE", "LOPINAVIR", "RITONAVIR" )); - listMap.put("AZT+3TC+ATV/r", Arrays.asList("ZIDOVUDINE","LAMIVUDINE", "ATAZANAVIR", "RITONAVIR" )); - listMap.put("TDF+3TC+LPV/r", Arrays.asList("TENOFOVIR","LAMIVUDINE", "LOPINAVIR", "RITONAVIR" )); - listMap.put("TDF+ABC+LPV/r", Arrays.asList("TENOFOVIR","ABACAVIR", "LOPINAVIR", "RITONAVIR" )); - listMap.put("TDF+3TC+ATV/r", Arrays.asList("TENOFOVIR","LAMIVUDINE", "ATAZANAVIR", "RITONAVIR" )); - listMap.put("ABC+ddI+LPV/r", Arrays.asList("ABACAVIR","DIDANOSINE", "LOPINAVIR", "RITONAVIR" )); - listMap.put("d4T+3TC+LPV/r", Arrays.asList("STAVUDINE","LAMIVUDINE", "LOPINAVIR", "RITONAVIR" )); - listMap.put("d4T+ABC+LPV/r", Arrays.asList("STAVUDINE","ABACAVIR", "LOPINAVIR", "RITONAVIR" )); - listMap.put("AZT+ddI+LPV/r", Arrays.asList("ZIDOVUDINE","DIDANOSINE", "LOPINAVIR", "RITONAVIR" )); - listMap.put("TDF+AZT+LPV/r", Arrays.asList("TENOFOVIR","ZIDOVUDINE", "LOPINAVIR", "RITONAVIR" )); - listMap.put("AZT+ABC+LPV/r", Arrays.asList("ZIDOVUDINE","ABACAVIR", "LOPINAVIR", "RITONAVIR" )); - - listMap.put("ABC+3TC+NVP", Arrays.asList("ABACAVIR","LAMIVUDINE", "NEVIRAPINE" )); - listMap.put("ABC+3TC+EFV", Arrays.asList("ABACAVIR","LAMIVUDINE", "EFAVIRENZ" )); - listMap.put("ABC+3TC+AZT", Arrays.asList("ABACAVIR","LAMIVUDINE", "ZIDOVUDINE" )); - - listMap.put("ABC+3TC+LPV/r", Arrays.asList("ABACAVIR","LAMIVUDINE", "LOPINAVIR", "RITONAVIR" )); - listMap.put("ABC+ddI+LPV/r", Arrays.asList("ABACAVIR","DIDANOSINE", "LOPINAVIR", "RITONAVIR" )); - listMap.put("AZT+3TC+DRV/r", Arrays.asList("ZIDOVUDINE","LAMIVUDINE", "DARUNAVIR", "RITONAVIR" )); - listMap.put("ABC+3TC+DRV/r", Arrays.asList("ABACAVIR","LAMIVUDINE", "DARUNAVIR", "RITONAVIR" )); - - return listMap; + Map> listMap = new HashMap>(); + listMap.put("AZT+3TC+NVP", Arrays.asList("ZIDOVUDINE","LAMIVUDINE", "NEVIRAPINE" )); + listMap.put("AZT+3TC+EFV", Arrays.asList("ZIDOVUDINE","LAMIVUDINE", "EFAVIRENZ" )); + listMap.put("AZT+3TC+ABC", Arrays.asList("ZIDOVUDINE","LAMIVUDINE", "ABACAVIR" )); - } - String getRegimenName(Map> standardRegimens, List drugs){ - if (standardRegimens.size() ==0 ) - return null; + listMap.put("TDF+3TC+NVP", Arrays.asList("TENOFOVIR","LAMIVUDINE", "NEVIRAPINE" )); + listMap.put("TDF+3TC+EFV", Arrays.asList("TENOFOVIR","LAMIVUDINE", "EFAVIRENZ" )); + listMap.put("TDF+3TC+ABC", Arrays.asList("TENOFOVIR","LAMIVUDINE", "ABACAVIR" )); + listMap.put("TDF+3TC+AZT", Arrays.asList("TENOFOVIR","LAMIVUDINE", "ZIDOVUDINE" )); - if (drugs.size() == 0) - return null; - String regimen = null; + listMap.put("d4T+3TC+NVP", Arrays.asList("STAVUDINE","LAMIVUDINE", "NEVIRAPINE" )); + listMap.put("d4T+3TC+EFV", Arrays.asList("STAVUDINE","LAMIVUDINE", "EFAVIRENZ" )); + listMap.put("d4T+3TC+ABC", Arrays.asList("STAVUDINE","LAMIVUDINE", "ABACAVIR" )); - for (String key : standardRegimens.keySet()){ - List value = standardRegimens.get(key); - if (value.containsAll(drugs)) { - regimen = key; - break; - } + listMap.put("AZT+3TC+LPV/r", Arrays.asList("ZIDOVUDINE","LAMIVUDINE", "LOPINAVIR", "RITONAVIR" )); + listMap.put("AZT+3TC+ATV/r", Arrays.asList("ZIDOVUDINE","LAMIVUDINE", "ATAZANAVIR", "RITONAVIR" )); + listMap.put("TDF+3TC+LPV/r", Arrays.asList("TENOFOVIR","LAMIVUDINE", "LOPINAVIR", "RITONAVIR" )); + listMap.put("TDF+ABC+LPV/r", Arrays.asList("TENOFOVIR","ABACAVIR", "LOPINAVIR", "RITONAVIR" )); + listMap.put("TDF+3TC+ATV/r", Arrays.asList("TENOFOVIR","LAMIVUDINE", "ATAZANAVIR", "RITONAVIR" )); + listMap.put("ABC+ddI+LPV/r", Arrays.asList("ABACAVIR","DIDANOSINE", "LOPINAVIR", "RITONAVIR" )); + listMap.put("d4T+3TC+LPV/r", Arrays.asList("STAVUDINE","LAMIVUDINE", "LOPINAVIR", "RITONAVIR" )); + listMap.put("d4T+ABC+LPV/r", Arrays.asList("STAVUDINE","ABACAVIR", "LOPINAVIR", "RITONAVIR" )); + listMap.put("AZT+ddI+LPV/r", Arrays.asList("ZIDOVUDINE","DIDANOSINE", "LOPINAVIR", "RITONAVIR" )); + listMap.put("TDF+AZT+LPV/r", Arrays.asList("TENOFOVIR","ZIDOVUDINE", "LOPINAVIR", "RITONAVIR" )); + listMap.put("AZT+ABC+LPV/r", Arrays.asList("ZIDOVUDINE","ABACAVIR", "LOPINAVIR", "RITONAVIR" )); - } - return regimen; - } - String programs(int value){ - String prog=""; - if(value == 160541){ - prog ="TB"; - } + listMap.put("ABC+3TC+NVP", Arrays.asList("ABACAVIR","LAMIVUDINE", "NEVIRAPINE" )); + listMap.put("ABC+3TC+EFV", Arrays.asList("ABACAVIR","LAMIVUDINE", "EFAVIRENZ" )); + listMap.put("ABC+3TC+AZT", Arrays.asList("ABACAVIR","LAMIVUDINE", "ZIDOVUDINE" )); - if(value == 160631){ - prog ="HIV"; - } + listMap.put("ABC+3TC+LPV/r", Arrays.asList("ABACAVIR","LAMIVUDINE", "LOPINAVIR", "RITONAVIR" )); + listMap.put("ABC+ddI+LPV/r", Arrays.asList("ABACAVIR","DIDANOSINE", "LOPINAVIR", "RITONAVIR" )); + listMap.put("AZT+3TC+DRV/r", Arrays.asList("ZIDOVUDINE","LAMIVUDINE", "DARUNAVIR", "RITONAVIR" )); + listMap.put("ABC+3TC+DRV/r", Arrays.asList("ABACAVIR","LAMIVUDINE", "DARUNAVIR", "RITONAVIR" )); + + return listMap; - if(value == 159937){ - prog ="MCH"; } + String getRegimenName(Map> standardRegimens, List drugs){ + if (standardRegimens.size() ==0 ) + return null; - return prog; - } + if (drugs.size() == 0) + return null; + String regimen = null; - String getCorrectDrugCode(Concept concept){ - String defaultString = ""; - if(concept.equals(Dictionary.getConcept("794AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ - defaultString = "LPV/r"; - } - else if(concept.equals(Dictionary.getConcept("84309AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ - defaultString = "d4T"; - } - else if(concept.equals(Dictionary.getConcept("74807AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ - defaultString = "DDI"; - } - else if(concept.equals(Dictionary.getConcept("70056AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ - defaultString = "ABC"; - } - else if(concept.equals(Dictionary.getConcept("80487AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ - defaultString = "NFV"; - } - else if(concept.equals(Dictionary.getConcept("80586AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ - defaultString = "NVP"; - } - else if(concept.equals(Dictionary.getConcept("75523AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ - defaultString = "EFV"; - } - else if(concept.equals(Dictionary.getConcept("78643AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ - defaultString = "3TC"; - } - else if(concept.equals(Dictionary.getConcept("84795AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ - defaultString = "TDF"; - } - else if(concept.equals(Dictionary.getConcept("86663AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ - defaultString = "AZT"; - } - else if(concept.equals(Dictionary.getConcept("83412AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ - defaultString = "RTV"; - } - else if(concept.equals(Dictionary.getConcept("71647AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ - defaultString = "ATV"; - } - else { - defaultString = concept.getName().getName(); - } + for (String key : standardRegimens.keySet()){ + List value = standardRegimens.get(key); + if (value.containsAll(drugs)) { + regimen = key; + break; + } - return defaultString; - } - String intergerToRoman(String integer){ - String value = ""; - if(integer.equals("1")){ - value = "I"; + } + return regimen; } - else if(integer.equals("2")){ - value = "II"; + String programs(int value){ + String prog=""; + if(value == 160541){ + prog ="TB"; + } + + if(value == 160631){ + prog ="HIV"; + } + + if(value == 159937){ + prog ="MCH"; + } + + return prog; } - else if(integer.equals("3")){ - value = "III"; + + String getCorrectDrugCode(Concept concept){ + String defaultString = ""; + if(concept.equals(Dictionary.getConcept("794AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ + defaultString = "LPV/r"; + } + else if(concept.equals(Dictionary.getConcept("84309AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ + defaultString = "d4T"; + } + else if(concept.equals(Dictionary.getConcept("74807AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ + defaultString = "DDI"; + } + else if(concept.equals(Dictionary.getConcept("70056AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ + defaultString = "ABC"; + } + else if(concept.equals(Dictionary.getConcept("80487AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ + defaultString = "NFV"; + } + else if(concept.equals(Dictionary.getConcept("80586AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ + defaultString = "NVP"; + } + else if(concept.equals(Dictionary.getConcept("75523AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ + defaultString = "EFV"; + } + else if(concept.equals(Dictionary.getConcept("78643AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ + defaultString = "3TC"; + } + else if(concept.equals(Dictionary.getConcept("84795AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ + defaultString = "TDF"; + } + else if(concept.equals(Dictionary.getConcept("86663AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ + defaultString = "AZT"; + } + else if(concept.equals(Dictionary.getConcept("83412AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ + defaultString = "RTV"; + } + else if(concept.equals(Dictionary.getConcept("71647AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"))){ + defaultString = "ATV"; + } + else { + defaultString = concept.getName().getName(); + } + + return defaultString; } - else if(integer.equals("4")){ - value = "IV"; + String intergerToRoman(String integer){ + String value = ""; + if(integer.equals("1")){ + value = "I"; + } + else if(integer.equals("2")){ + value = "II"; + } + else if(integer.equals("3")){ + value = "III"; + } + else if(integer.equals("4")){ + value = "IV"; + } + return value; } - return value; - } -} + } diff --git a/omod/src/main/webapp/fragments/summaries.gsp b/omod/src/main/webapp/fragments/summaries.gsp index 9a1351e11c..35931dddc2 100755 --- a/omod/src/main/webapp/fragments/summaries.gsp +++ b/omod/src/main/webapp/fragments/summaries.gsp @@ -1,232 +1,343 @@ + <% + def kDoDNumber = patient.kDoDCadre + def kDoDCadre = patient.kDoDCadre + def kDoDRank = patient.kDoDRank + def kDoDUnit = patient.kDoDUnit + %> + -
-
Patient Summary
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Date of report: ${patient.dateOfReport}Clinic name: ${patient.clinicName}MFL code: ${patient.mflCode}
UPN: ${ patient.upn }Name: ${names}
DOB: ${ patient.birthDate } - Age: ${ patient.age } -       Gender: ${ patient.gender} -       Marital status: ${ patient.maritalStatus } -
  
Date Confirmed HIV Positive: ${ patient.hivConfrimedDate }First CD4: ${ patient.firstCd4 }Date first CD4: ${ patient.firstCd4Date }
Date enrolled into care: ${ patient.dateEnrolledIntoCare}WHO stage at enrollment: ${patient.whoStagingAtEnrollment}Transfer in date: ${tiDate}
Entry point: ${patient.patientEntryPoint}Date of entry point: ${patient.dateEntryPoint}Facility transferred from: ${patient.transferInFacility}
 
Treatment supporter details:
Name: ${patient.nameOfTreatmentSupporter}Relationship: ${patient.relationshipToTreatmentSupporter}Contact details: ${patient.contactOfTreatmentSupporter}
 
Drug allergies: ${allergies}
 
Previous ART: ${patient.previousArt}Date started ART: ${patient.dateStartedArt}
Purpose: ${patient.artPurpose}Clinical stage at ART: ${patient.clinicalStageAtArtStart}CD4 at ART: ${patient.cd4AtArtStart}
Drugs/Regimen: ${patient.purposeDrugs}Weight at ART: ${patient.weightAtArtStart}
Date: ${patient.purposeDate}First regimen: ${firstRegimen}
Past or current OI: ${iosResults}
 
Current ART regimen: ${currentRegimen} - - - - - - -
ART interruptions: - - - - - - - -
Reason:
Date:
-
-
Current WHO stage: ${patient.currentWhoStaging} - - - - - -
Substitution within 1st line regimen: - - - - - - - -
Reason:
Date:
-
- -
CTX: ${onCtx} - - - - - -
Switch to 2nd line regimen: - - - - - - - -
Reason:
Date:
-
-
Dapsone: ${onDapsone}TPT: ${onIpt} 
Clinics enrolled: ${clinicValues} - Transfer out date: ${toDate}
- Transfer out facility: ${toFacility} -
- - - - - -
Most recent CD4: ${recentCd4Count}Date: ${recentCd4CountDate}
- - -
- Death date: ${deadDeath} -
- - - - - -
Most recent VL: ${recentVl} Date: ${recentVlDate}
-
- Next appointment: ${returnVisitDate} -
+ + table.moh257 { + border-collapse: collapse; + background-color: #D9F4D3; + width: 75%; + } + table.moh257 > tbody > tr > td, table.moh257 > tbody > tr > th { + border: 1px solid black; + vertical-align: baseline; + padding: 2px; + text-align: left; + background-color: #D9F4D3; + } + + + +
+
Patient Summary
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Date of report: ${patient.dateOfReport}Clinic name: ${patient.clinicName}MFL code: ${patient.mflCode}
UPN: ${ patient.upn }Name: ${names}
DOB: ${ patient.birthDate } + Age: ${ patient.age } +       Gender: ${ patient.gender} +       Marital status: ${ patient.maritalStatus } +
  
Date Confirmed HIV Positive: ${ patient.hivConfrimedDate }First CD4: ${ patient.firstCd4 }Date first CD4: ${ patient.firstCd4Date }
Date enrolled into care: ${ patient.dateEnrolledIntoCare}WHO stage at enrollment: ${patient.whoStagingAtEnrollment}Transfer in date: ${tiDate}
Entry point: ${patient.patientEntryPoint}Date of entry point: ${patient.dateEntryPoint}Facility transferred from: ${patient.transferInFacility}
 
Treatment supporter details:
Name: ${patient.nameOfTreatmentSupporter}Relationship: ${patient.relationshipToTreatmentSupporter}Contact details: ${patient.contactOfTreatmentSupporter}
 
Drug allergies: ${allergies}
 
Chronic Illness: ${chronicDisease}
Respiratory Rate: ${patient.respiratoryRate}Blood Pressure: ${patient.bloodPressure}
Oxygen Saturation: ${patient.oxygenSaturation}Pulse Rate: ${patient.pulseRate}
 
Previous ART: ${patient.previousArt}Date started ART: ${patient.dateStartedArt}
Purpose: ${patient.artPurpose}Clinical stage at ART: ${patient.clinicalStageAtArtStart}CD4 at ART: ${patient.cd4AtArtStart}
Drugs/Regimen: ${patient.purposeDrugs}
Family Protection: ${patient.familyProtection}
Weight: ${patient.weightAtArtStart}Height: ${patient.heightAtArtStart}BMI: ${patient.bmi}
kDoD Cadre: ${patient.kDoDCadre}kDoD Unit: ${patient.kDoDUnit}kDoD Rank: ${patient.kDoDRank}
kDoD Number: ${patient.kDoDNumber}
LMP: ${patient.lmp}
TPT Start Date: ${patient.dateEnrolledInTb}TPT Completion Date: ${patient.dateCompletedInTb}
TB Screening: ${patient.tbScreeningOutcome}
STI Screening: ${patient.stiScreeningOutcome}
CACX Screening: ${patient.caxcScreeningOutcome}
Date: ${patient.purposeDate}First regimen: ${firstRegimen}
Past or current OI: ${iosResults}
 
Current ART regimen: ${currentRegimen} + + + + + + +
ART interruptions: + + + + + + + +
Reason:
Date:
+
+
Current WHO stage: ${patient.currentWhoStaging} + + + + + +
Substitution within 1st line regimen: + + + + + + + +
Reason:
Date:
+
+ +
CTX: ${onCtx} + + + + + +
Switch to 2nd line regimen: + + + + + + + +
Reason:
Date:
+
+
Dapsone: ${onDapsone}TPT: ${onIpt} 
Clinics enrolled: ${clinicValues} + Transfer out date: ${toDate}
+ Transfer out facility: ${toFacility} +
+ + + + + +
Most recent CD4: ${recentCd4Count}Date: ${recentCd4CountDate}
+ + +
+ Death date: ${deadDeath} +
+ + + + + +
Most recent VL: ${recentVl} Date: ${recentVlDate}
+
+ Next appointment: ${returnVisitDate} +
+
+ +
+
+
+ +