Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise the NCD column in Active on ART to pick the most current HIV greencard #2035

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public class NCDDateDataEvaluator implements PersonDataEvaluator {
public EvaluatedPersonData evaluate(PersonDataDefinition definition, EvaluationContext context) throws EvaluationException {
EvaluatedPersonData c = new EvaluatedPersonData(definition, context);

String qry = "select ci.patient_id,\n" +
" group_concat(ci.chronic_illness_onset_date) as ChronicIllness_onset\n" +
"from kenyaemr_etl.etl_allergy_chronic_illness ci\n" +
"where ci.visit_date <= date(:endDate)\n" +
"group by ci.patient_id;";
String qry = "SELECT ci.patient_id,\n" +
" DATE(MAX(ci.chronic_illness_onset_date)) AS ChronicIllness_onset\n" +
"FROM kenyaemr_etl.etl_allergy_chronic_illness ci\n" +
"WHERE ci.visit_date <= DATE(:endDate)\n" +
"GROUP BY ci.patient_id;";

SqlQueryBuilder queryBuilder = new SqlQueryBuilder();
queryBuilder.append(qry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,39 +33,40 @@ public class NCDSDataEvaluator implements PersonDataEvaluator {
public EvaluatedPersonData evaluate(PersonDataDefinition definition, EvaluationContext context) throws EvaluationException {
EvaluatedPersonData c = new EvaluatedPersonData(definition, context);

String qry = "\n" +
"select ci.patient_id,group_concat( case ci.chronic_illness\n" +
" when 149019 then 'Alzheimers Disease and other Dementias'\n" +
" when 148432 then 'Arthritis'\n" +
" when 153754 then 'Asthma'\n" +
" when 159351 then 'Cancer'\n" +
" when 119270 then 'Cardiovascular diseases'\n" +
" when 120637 then 'Chronic Hepatitis'\n" +
" when 145438 then 'Chronic Kidney Disease'\n" +
" when 1295 then 'Chronic Obstructive Pulmonary Disease(COPD)'\n" +
" when 120576 then 'Chronic Renal Failure'\n" +
" when 119692 then 'Cystic Fibrosis'\n" +
" when 120291 then 'Deafness and Hearing impairment'\n" +
" when 119481 then 'Diabetes'\n" +
" when 118631 then 'Endometriosis'\n" +
" when 117855 then 'Epilepsy'\n" +
" when 117789 then 'Glaucoma'\n" +
" when 139071 then 'Heart Disease'\n" +
" when 115728 then 'Hyperlipidaemia'\n" +
" when 117399 then 'Hypertension'\n" +
" when 117321 then 'Hypothyroidism'\n" +
" when 151342 then 'Mental illness'\n" +
" when 133687 then 'Multiple Sclerosis'\n" +
" when 115115 then 'Obesity'\n" +
" when 114662 then 'Osteoporosis'\n" +
" when 117703 then 'Sickle Cell Anaemia'\n" +
" when 118976 then 'Thyroid disease'\n" +
" when 141623 then 'Dyslipidemia'\n" +
" end SEPARATOR\n" +
" ',') as ChronicIllness\n" +
" from kenyaemr_etl.etl_allergy_chronic_illness ci\n" +
" where ci.visit_date <= date(:endDate)\n" +
" group by ci.patient_id;";
String qry = "SELECT ci.patient_id,\n" +
" SUBSTRING_INDEX(\n" +
" MAX(CONCAT(visit_date, ',', \n" +
" COALESCE(CASE ci.chronic_illness\n" +
" WHEN 149019 THEN 'Alzheimers Disease and other Dementias'\n" +
" WHEN 148432 THEN 'Arthritis'\n" +
" WHEN 153754 THEN 'Asthma'\n" +
" WHEN 159351 THEN 'Cancer'\n" +
" WHEN 119270 THEN 'Cardiovascular diseases'\n" +
" WHEN 120637 THEN 'Chronic Hepatitis'\n" +
" WHEN 145438 THEN 'Chronic Kidney Disease'\n" +
" WHEN 1295 THEN 'Chronic Obstructive Pulmonary Disease(COPD)'\n" +
" WHEN 120576 THEN 'Chronic Renal Failure'\n" +
" WHEN 119692 THEN 'Cystic Fibrosis'\n" +
" WHEN 120291 THEN 'Deafness and Hearing impairment'\n" +
" WHEN 119481 THEN 'Diabetes'\n" +
" WHEN 118631 THEN 'Endometriosis'\n" +
" WHEN 117855 THEN 'Epilepsy'\n" +
" WHEN 117789 THEN 'Glaucoma'\n" +
" WHEN 139071 THEN 'Heart Disease'\n" +
" WHEN 115728 THEN 'Hyperlipidaemia'\n" +
" WHEN 117399 THEN 'Hypertension'\n" +
" WHEN 117321 THEN 'Hypothyroidism'\n" +
" WHEN 151342 THEN 'Mental illness'\n" +
" WHEN 133687 THEN 'Multiple Sclerosis'\n" +
" WHEN 115115 THEN 'Obesity'\n" +
" WHEN 114662 THEN 'Osteoporosis'\n" +
" WHEN 117703 THEN 'Sickle Cell Anaemia'\n" +
" WHEN 118976 THEN 'Thyroid disease'\n" +
" WHEN 141623 THEN 'Dyslipidemia'\n" +
" END))), ',', -1) AS ChronicIllness\n" +
"FROM kenyaemr_etl.etl_allergy_chronic_illness ci\n" +
"WHERE ci.visit_date <= DATE(:endDate)\n" +
"GROUP BY ci.patient_id;";

SqlQueryBuilder queryBuilder = new SqlQueryBuilder();
queryBuilder.append(qry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,19 @@ public class NCDStatusDataEvaluator implements PersonDataEvaluator {
public EvaluatedPersonData evaluate(PersonDataDefinition definition, EvaluationContext context) throws EvaluationException {
EvaluatedPersonData c = new EvaluatedPersonData(definition, context);

String qry = "select ci.patient_id,\n" +
" group_concat(case ci.is_chronic_illness_controlled\n" +
" when 1065 then 'Controlled'\n" +
" when 1066 then 'Not controlled' end) as controlled_status\n" +
"from kenyaemr_etl.etl_allergy_chronic_illness ci\n" +
"where ci.visit_date <= date(:endDate)\n" +
"group by ci.patient_id;";
String qry = "SELECT ci.patient_id,\n" +
" (CASE ci.is_chronic_illness_controlled\n" +
" WHEN 1065 THEN 'Controlled'\n" +
" WHEN 1066 THEN 'Not controlled'\n" +
" END) AS controlled_status\n" +
"FROM kenyaemr_etl.etl_allergy_chronic_illness ci\n" +
"JOIN (\n" +
" SELECT patient_id, MAX(visit_date) AS latest_visit_date\n" +
" FROM kenyaemr_etl.etl_allergy_chronic_illness\n" +
" WHERE visit_date <= DATE(:endDate)\n" +
" GROUP BY patient_id\n" +
") latest ON ci.patient_id = latest.patient_id AND ci.visit_date = latest.latest_visit_date\n" +
"GROUP BY ci.patient_id;";

SqlQueryBuilder queryBuilder = new SqlQueryBuilder();
queryBuilder.append(qry);
Expand Down