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

Specify data endpoint when invoking $apply on a PlanDefinition #1982

Merged
merged 3 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"resourceType": "CarePlan",
"contained": [
{
"resourceType": "RequestGroup",
"id": "Plan-Definition-Example",
"instantiatesCanonical": [
"http://example.com/PlanDefinition/Plan-Definition-Example"
],
"status": "draft",
"intent": "proposal",
"subject": {
"reference": "Patient/Female-Patient-Example"
},
"action": [
{
"resource": {
"reference": "Task"
}
}
]
},
{
"resourceType": "Task",
"id": "Task",
"extension": [
{
"url": "http://hl7.org/fhir/aphl/StructureDefinition/condition",
"valueExpression": {
"language": "text/cql.identifier",
"expression": "Patient is Female"
}
}
],
"basedOn": [
{
"reference": "#RequestGroup/Plan-Definition-Example",
"type": "RequestGroup"
}
],
"status": "draft",
"description": "Example Task"
}
],
"instantiatesCanonical": [
"http://example.com/PlanDefinition/Plan-Definition-Example"
],
"status": "draft",
"intent": "proposal",
"subject": {
"reference": "Patient/Female-Patient-Example"
},
"activity": [
{
"reference": {
"reference": "#Plan-Definition-Example"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
library example version '1.0.0'
using FHIR version '4.0.1'
include FHIRHelpers version '4.0.1'

context Patient

define "Patient is Female": Patient.gender = 'female'

define "Get Task Description": 'Example Task'
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"resourceType": "Bundle",
"entry": [
{
"resource": {
"resourceType": "Patient",
"id": "Female-Patient-Example",
"active": true,
"name": [
{
"use": "official",
"family": "Kensington",
"given": [
"Amelia"
]
}
],
"gender": "female",
"birthDate": "1986-03-18",
"deceasedBoolean": false
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{
"resource": {
"resourceType": "ActivityDefinition",
"id": "Activity-Example",
"url": "http://example.com/ActivityDefinition/Activity-Example",
"status": "active",
"kind": "Task",
"library": [
"http://example.com/Library/example|1.0.0"
],
"dynamicValue": [
{
"path": "description",
"expression": {
"language": "text/cql.identifier",
"expression": "Get Task Description"
}
}
]
}
},
{
"resource": {
"resourceType": "PlanDefinition",
"id": "Plan-Definition-Example",
"url" : "http://example.com/PlanDefinition/Plan-Definition-Example",
"status": "active",
"type": "workflow-definition",
"library": [
"http://example.com/Library/example|1.0.0"
],
"action": [
{
"title": "Test for Female Patient",
"definitionCanonical": "http://example.com/ActivityDefinition/Activity-Example",
"condition": [
{
"kind": "applicability",
"expression": {
"language": "text/cql.identifier",
"expression": "Patient is Female"
}
}
]
}
]
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,9 @@ internal constructor(
/* useServerData= */ null,
/* bundle= */ null,
/* prefetchData= */ null,
/* dataEndpoint= */ null,
/* dataEndpoint= */ Endpoint()
.setAddress("localhost")
.setConnectionType(Coding().setCode(Constants.HL7_FHIR_FILES)),
/* contentEndpoint*/ null,
/* terminologyEndpoint= */ null
) as IBaseResource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,28 @@ class FhirOperatorTest {
)
}

@Test
fun generateCarePlanWithCqlApplicabilityCondition() = runBlockingOnWorkerThread {
loadFile("/plan-definition/cql-applicability-condition/patient.json", ::importToFhirEngine)
loadFile(
"/plan-definition/cql-applicability-condition/plan_definition.json",
::installToIgManager
)
loadFile("/plan-definition/cql-applicability-condition/example-1.0.0.cql", ::installToIgManager)

val carePlan =
fhirOperator.generateCarePlan(
planDefinitionId = "Plan-Definition-Example",
patientId = "Patient/Female-Patient-Example"
)

assertEquals(
readResourceAsString("/plan-definition/cql-applicability-condition/care_plan.json"),
jsonParser.encodeResourceToString(carePlan),
true
)
}

@Test
fun evaluatePopulationMeasure() = runBlockingOnWorkerThread {
loadFile("/first-contact/01-registration/patient-charity-otala-1.json", ::importToFhirEngine)
Expand Down