-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1045 from gabriel090/KHP3-285
KHP3-285: KNH/KDO patient summary
- Loading branch information
Showing
11 changed files
with
2,482 additions
and
1,561 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...src/main/java/org/openmrs/module/kenyaemr/calculation/library/hiv/art/BMICalculation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Integer> cohort, Map<String, Object> 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; | ||
} | ||
} | ||
|
64 changes: 64 additions & 0 deletions
64
...ava/org/openmrs/module/kenyaemr/calculation/library/hiv/art/BloodPressureCalculation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Integer> cohort, Map<String, Object> 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<Obs> 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; | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...openmrs/module/kenyaemr/calculation/library/hiv/art/HeightAtArtInitiationCalculation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Integer> cohort, Map<String, Object> 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<Obs> 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; | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...src/main/java/org/openmrs/module/kenyaemr/calculation/library/hiv/art/LMPCalculation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Integer> cohort, Map<String, Object> 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<Obs> 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; | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
.../org/openmrs/module/kenyaemr/calculation/library/hiv/art/OxygenSaturationCalculation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Integer> cohort, Map<String, Object> 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<Obs> 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; | ||
} | ||
} |
Oops, something went wrong.