When I call EvaluationService.evaluate(queryBuilder, context), InteliJ gives me an error that cannot access org.openmrs.calculation.patient.PatientCalculationContext.
I also noticed that even lines like
sqlQueryBuilder sqlQueryBuilder = new SqlQueryBuilder();
String sqlQuery = "select o.person_id from obs o inner join patient p on o.person_id = p.patient_id "
+ "where o.voided = false and p.voided = false and concept_id = :questionConceptId and "
+ "o.obs_datetime >= :onOrAfter and o.obs_datetime <= :onOrBefore and o.value_coded IN (:valueList)";
sqlQueryBuilder.append(sqlQuery);
sqlQueryBuilder.setParameters(context.getParameterValues());
that don’t show this error in InteliJ fails during build with the same error message.
any where in the code will show an error messages. Though this doesn’t prevent the code from building. But having
SqlQueryBuilder sqlQueryBuilder = new SqlQueryBuilder();
String sqlQuery = "select o.person_id from obs o inner join patient p on o.person_id = p.patient_id "
+ "where o.voided = false and p.voided = false and concept_id = :questionConceptId and "
+ "o.obs_datetime >= :onOrAfter and o.obs_datetime <= :onOrBefore and o.value_coded IN (:valueList)";
sqlQueryBuilder.append(sqlQuery);
sqlQueryBuilder.setParameters(context.getParameterValues());
Will cause the build to fail with a compile error on the last line. Though this isn’t reported by InteliJ but the error message is the same as that reported by InteliJ when you call
When trying to reproduce this, I noticed those exact same lines of codes don’t throw any error or cause the build to fail when placed inside a unit test.
@ivange94, the issue appears to be that you are including the dependency of calculation-api with a “test” scope. I think you’ll find that if you change that to “provided”, then things will start to work as expected. Provided scope is appropriate because the calculation module is a runtime dependency that is required to be available (based on the fact that it is required by the reporting module).