Skip to content

Commit

Permalink
Specify data endpoint when invoking $apply on a PlanDefinition (#1982)
Browse files Browse the repository at this point in the history
* Specify data endpoint when invoking  on a PlanDefinition

* Updated test case so that the url does not contain 'localhost'
  • Loading branch information
divyaramnath-13 committed Apr 25, 2023
1 parent c07e7b8 commit 244fedc
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 1 deletion.
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

0 comments on commit 244fedc

Please sign in to comment.