Skip to content

Commit

Permalink
Merge pull request #2056 from njorocs/dmi-case-report
Browse files Browse the repository at this point in the history
Dmi case report
  • Loading branch information
patryllus authored Nov 16, 2024
2 parents cbf6c40 + 7eb5fe5 commit 5eb7a94
Show file tree
Hide file tree
Showing 65 changed files with 3,756 additions and 0 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* 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.reporting.cohort.definition.dmi.casereport;

import org.openmrs.Visit;
import org.openmrs.module.reporting.common.Localized;
import org.openmrs.module.reporting.definition.configuration.ConfigurationProperty;
import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy;
import org.openmrs.module.reporting.evaluation.caching.Caching;
import org.openmrs.module.reporting.query.BaseQuery;
import org.openmrs.module.reporting.query.visit.definition.VisitQuery;

import java.util.Date;

/**
* Surveillance cases cohort definition
*/

@Caching(strategy = ConfigurationPropertyCachingStrategy.class)
@Localized("reporting.CaseComplaintsCohortDefinition")
public class CaseComplaintsCohortDefinition extends BaseQuery<Visit> implements VisitQuery {
@ConfigurationProperty
private Date asOfDate;

public CaseComplaintsCohortDefinition() {
}

public Date getAsOfDate() {
return asOfDate;
}

public void setAsOfDate(Date asOfDate) {
this.asOfDate = asOfDate;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* 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.reporting.cohort.definition.dmi.casereport;

import org.openmrs.Visit;
import org.openmrs.module.reporting.common.Localized;
import org.openmrs.module.reporting.definition.configuration.ConfigurationProperty;
import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy;
import org.openmrs.module.reporting.evaluation.caching.Caching;
import org.openmrs.module.reporting.query.BaseQuery;
import org.openmrs.module.reporting.query.visit.definition.VisitQuery;

import java.util.Date;

/**
* Surveillance cases cohort definition
*/

@Caching(strategy = ConfigurationPropertyCachingStrategy.class)
@Localized("reporting.CaseDiagnosisCohortDefinition")
public class CaseDiagnosisCohortDefinition extends BaseQuery<Visit> implements VisitQuery {
@ConfigurationProperty
private Date asOfDate;

public CaseDiagnosisCohortDefinition() {
}

public Date getAsOfDate() {
return asOfDate;
}

public void setAsOfDate(Date asOfDate) {
this.asOfDate = asOfDate;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* 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.reporting.cohort.definition.dmi.casereport;

import org.openmrs.Visit;
import org.openmrs.module.reporting.common.Localized;
import org.openmrs.module.reporting.definition.configuration.ConfigurationProperty;
import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy;
import org.openmrs.module.reporting.evaluation.caching.Caching;
import org.openmrs.module.reporting.query.BaseQuery;
import org.openmrs.module.reporting.query.visit.definition.VisitQuery;

import java.util.Date;

/**
* Surveillance cases cohort definition
*/

@Caching(strategy = ConfigurationPropertyCachingStrategy.class)
@Localized("reporting.CaseLabsCohortDefinition")
public class CaseLabsCohortDefinition extends BaseQuery<Visit> implements VisitQuery {
@ConfigurationProperty
private Date asOfDate;

public CaseLabsCohortDefinition() {
}

public Date getAsOfDate() {
return asOfDate;
}

public void setAsOfDate(Date asOfDate) {
this.asOfDate = asOfDate;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* 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.reporting.cohort.definition.dmi.casereport;

import org.openmrs.Visit;
import org.openmrs.module.reporting.common.Localized;
import org.openmrs.module.reporting.definition.configuration.ConfigurationProperty;
import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy;
import org.openmrs.module.reporting.evaluation.caching.Caching;
import org.openmrs.module.reporting.query.BaseQuery;
import org.openmrs.module.reporting.query.visit.definition.VisitQuery;

import java.util.Date;

/**
* Surveillance cases cohort definition
*/

@Caching(strategy = ConfigurationPropertyCachingStrategy.class)
@Localized("reporting.CaseVitalsCohortDefinition")
public class CaseVitalsCohortDefinition extends BaseQuery<Visit> implements VisitQuery {
@ConfigurationProperty
private Date asOfDate;

public CaseVitalsCohortDefinition() {
}

public Date getAsOfDate() {
return asOfDate;
}

public void setAsOfDate(Date asOfDate) {
this.asOfDate = asOfDate;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* 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.reporting.cohort.definition.dmi.casereport;

import org.openmrs.Visit;
import org.openmrs.module.reporting.common.Localized;
import org.openmrs.module.reporting.definition.configuration.ConfigurationProperty;
import org.openmrs.module.reporting.definition.configuration.ConfigurationPropertyCachingStrategy;
import org.openmrs.module.reporting.evaluation.caching.Caching;
import org.openmrs.module.reporting.query.BaseQuery;
import org.openmrs.module.reporting.query.visit.definition.VisitQuery;

import java.util.Date;

/**
* Surveillance cases cohort definition
*/

@Caching(strategy = ConfigurationPropertyCachingStrategy.class)
@Localized("reporting.IllCasesCohortDefinition")
public class IllCasesCohortDefinition extends BaseQuery<Visit> implements VisitQuery {
@ConfigurationProperty
private Date asOfDate;

public IllCasesCohortDefinition() {
}

public Date getAsOfDate() {
return asOfDate;
}

public void setAsOfDate(Date asOfDate) {
this.asOfDate = asOfDate;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* 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.reporting.cohort.definition.evaluator.dmi.casereport;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openmrs.annotation.Handler;
import org.openmrs.module.kenyaemr.reporting.cohort.definition.dmi.casereport.CaseComplaintsCohortDefinition;
import org.openmrs.module.reporting.common.ObjectUtil;
import org.openmrs.module.reporting.evaluation.EvaluationContext;
import org.openmrs.module.reporting.evaluation.EvaluationException;
import org.openmrs.module.reporting.evaluation.querybuilder.SqlQueryBuilder;
import org.openmrs.module.reporting.evaluation.service.EvaluationService;
import org.openmrs.module.reporting.query.visit.VisitQueryResult;
import org.openmrs.module.reporting.query.visit.definition.VisitQuery;
import org.openmrs.module.reporting.query.visit.evaluator.VisitQueryEvaluator;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.List;

/**
* Evaluator for case complaints Cohort
*/
@Handler(supports = {CaseComplaintsCohortDefinition.class})
public class CaseComplaintsCohortDefinitionEvaluator implements VisitQueryEvaluator {

private final Log log = LogFactory.getLog(this.getClass());

@Autowired
EvaluationService evaluationService;

@Override
public VisitQueryResult evaluate(VisitQuery visitQuery, EvaluationContext context) throws EvaluationException {
context = ObjectUtil.nvl(context, new EvaluationContext());
VisitQueryResult queryResult = new VisitQueryResult(visitQuery, context);

String qry = "select i.visit_id\n" +
"from kenyaemr_etl.etl_allergy_chronic_illness i\n" +
"where i.visit_date between date(:startDate) and date(:endDate)\n" +
" and i.complaint is not null\n" +
"group by visit_id;";

SqlQueryBuilder builder = new SqlQueryBuilder();
builder.append(qry);
Date startDate = (Date) context.getParameterValue("startDate");
Date endDate = (Date) context.getParameterValue("endDate");
builder.addParameter("endDate", endDate);
builder.addParameter("startDate", startDate);

List<Integer> results = evaluationService.evaluateToList(builder, Integer.class, context);
queryResult.getMemberIds().addAll(results);
return queryResult;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* 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.reporting.cohort.definition.evaluator.dmi.casereport;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openmrs.annotation.Handler;
import org.openmrs.module.kenyaemr.reporting.cohort.definition.dmi.casereport.CaseDiagnosisCohortDefinition;
import org.openmrs.module.reporting.common.ObjectUtil;
import org.openmrs.module.reporting.evaluation.EvaluationContext;
import org.openmrs.module.reporting.evaluation.EvaluationException;
import org.openmrs.module.reporting.evaluation.querybuilder.SqlQueryBuilder;
import org.openmrs.module.reporting.evaluation.service.EvaluationService;
import org.openmrs.module.reporting.query.visit.VisitQueryResult;
import org.openmrs.module.reporting.query.visit.definition.VisitQuery;
import org.openmrs.module.reporting.query.visit.evaluator.VisitQueryEvaluator;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.List;

/**
* Evaluator for case complaints Cohort
*/
@Handler(supports = {CaseDiagnosisCohortDefinition.class})
public class CaseDiagnosisCohortDefinitionEvaluator implements VisitQueryEvaluator {

private final Log log = LogFactory.getLog(this.getClass());

@Autowired
EvaluationService evaluationService;

@Override
public VisitQueryResult evaluate(VisitQuery visitQuery, EvaluationContext context) throws EvaluationException {
context = ObjectUtil.nvl(context, new EvaluationContext());
VisitQueryResult queryResult = new VisitQueryResult(visitQuery, context);

String qry = "select e.visit_id\n" +
"from kenyaemr_etl.etl_clinical_encounter e\n" +
" inner join openmrs.encounter_diagnosis d\n" +
" on e.encounter_id = d.encounter_id and d.dx_rank = 2 and d.voided = 0\n" +
"where e.visit_date between date(:startDate) and date(:endDate)\n" +
"GROUP BY e.visit_id;";

SqlQueryBuilder builder = new SqlQueryBuilder();
builder.append(qry);
Date startDate = (Date) context.getParameterValue("startDate");
Date endDate = (Date) context.getParameterValue("endDate");
builder.addParameter("endDate", endDate);
builder.addParameter("startDate", startDate);

List<Integer> results = evaluationService.evaluateToList(builder, Integer.class, context);
queryResult.getMemberIds().addAll(results);
return queryResult;
}
}
Loading

0 comments on commit 5eb7a94

Please sign in to comment.