-
Notifications
You must be signed in to change notification settings - Fork 307
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
Add testcase that references an Observation, add test that uses ELM . #1280
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fantastic progress! thanks so much @ktarasenko
@f-odhiambo can you please also leave a review?
// FIXME | ||
// filter(Patient.ACTIVE, { value = of(true) }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you need to uncommen this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cleaned up filtering for now
// FIXME | ||
// filter(Patient.ACTIVE, { value = of(true) }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
import org.opencds.cqf.cql.evaluator.measure.r4.R4MeasureProcessor | ||
|
||
class FhirOperator(fhirContext: FhirContext, fhirEngine: FhirEngine) { | ||
class FhirOperator(fhirContext: FhirContext, fhirEngine: FhirEngine, debugLogsOn: Boolean = false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you looked into using Timber? wouldn't really want this to be in the public api i think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logging of cql evaluator is a bit tricky. It's also doesn't really log anything, but rather dumps some debug information in memory. I will revert this part to avoid the confusion.
val measureReportJSON = | ||
FhirContext.forR4().newJsonParser().encodeResourceToString(measureReport) | ||
|
||
assertThat(measureReportJSON).isNotNull() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is just testing the serialization? i feel we don't need this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, there should be a special test case for it. Removing
FhirContext.forR4().newJsonParser().encodeResourceToString(measureReport) | ||
|
||
assertThat(measureReportJSON).isNotNull() | ||
assertThat(measureReport).isNotNull() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is subsumed by later lines. so i'd vote removing this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
assertThat(measureReportJSON).isNotNull() | ||
assertThat(measureReport).isNotNull() | ||
assertThat( | ||
measureReport.evaluatedResource.any { it.reference == "Observation/anc-b6-de17-example" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use of any
seems very lenient in test cases. can we harden it?
same with below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
c4ce80f
to
1506f92
Compare
// FIXME | ||
// filter(Patient.ACTIVE, { value = of(true) }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cleaned up filtering for now
// FIXME | ||
// filter(Patient.ACTIVE, { value = of(true) }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
@@ -21,57 +21,56 @@ import com.google.android.fhir.DatabaseErrorStrategy.UNSPECIFIED | |||
import com.google.android.fhir.sync.Authenticator | |||
import com.google.android.fhir.sync.DataSource | |||
|
|||
/** The builder for [FhirEngine] instance */ | |||
/** The builder for [FhirEngine] instance. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having FhirEngineProvider as a singleton creates some problems in tests. @epicadk , @jingtang10 do you think it makes sense to convert it to a normal class and move the burden of keeping a single instance of it to clients?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Workflow library E2E tests require a real instance of the FhirEngine
. Currently the only way to create the FhirEngine
is through FhirEngineProvider
, which maintains a single instance of the FhirServices
.
To improve testability, we either need a way to clean up the FhirEngine
instance or to have a fresh instance of it for every test (add a way to reset the FhirServices
singleton, like i did in this PR).
I'd prefer the second option.
As a next step, given that singletons in android are generally frowned upon, I would suggest to get rid of memoisation part of the FhirEngineProvider
and let it create a fresh instance of the FhirEngine
every time. This way clients can chose their way of maintaining the single instance of the FhirEngine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jingtang10 actually, the second Robolectric test doesn't work if the DB instance wasn't closed after every test case (in the @after method), so to be able to have all testcases in a single test file, this change is needed to be in this PR.
…irEngineProvider singleton
e29b4c0
to
ac1218d
Compare
…ithObservation # Conflicts: # engine/src/main/java/com/google/android/fhir/FhirEngineProvider.kt # engine/src/main/java/com/google/android/fhir/db/Database.kt # workflow/src/test/java/com/google/android/fhir/workflow/FhirOperatorTest.kt
de98911
to
747a3d1
Compare
1cff4a0
to
46b6193
Compare
@jingtang10 @vitorpamplona @f-odhiambo Updated the CL, PTAL |
46b6193
to
ab47c2e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I run the test based on the newly added resources and the $evaluate_measure works for Individual measure reporting. There is a bug in Population measure reporting after adding multiple patients but I think it is more of a CQL than an API error. Can be sorted in a separate PR. I think we can merge this in now
I think this ticket can be merged in as the remaining issue is CQL related - Evaluation fails if we have more than 1 patient being evaluated for ANC Indicator 1 measure reporting. This occurs when you are trying to do a measure reporting evaluation for a population for more than 1 patient
Good job @ktarasenko on the effort put on this |
@f-odhiambo is there an ETA by when this PR can be merged? |
I need access to push an update to Kostia's PR to be reviewed and merged. |
add assertions to the cql test disable populations test
…ithObservation # Conflicts: # workflow/src/main/java/com/google/android/fhir/workflow/FhirEngineRetrieveProvider.kt # workflow/src/main/java/com/google/android/fhir/workflow/FhirOperator.kt
approved by f-odhiambo, changes are addessed
4a706cc
to
03d3d27
Compare
Codecov Report
@@ Coverage Diff @@
## master #1280 +/- ##
=========================================
Coverage 85.72% 85.72%
Complexity 716 716
=========================================
Files 149 149
Lines 10760 10760
Branches 858 858
=========================================
Hits 9224 9224
Misses 1095 1095
Partials 441 441 Continue to review full report at Codecov.
|
Fixes #1107
Description
Add more complex test case for evaluateMeasure that refrerences an observation and an episode of care without the context value
Alternative(s) considered
Have you considered any alternatives? And if so, why have you chosen the approach in this PR?
Type
Bug fix| Testing
Screenshots (if applicable)
Checklist
./gradlew spotlessApply
and./gradlew spotlessCheck
to check my code follows the style guide of this project../gradlew check
and./gradlew connectedCheck
to test my changes locally.