@@ -29,11 +29,13 @@ import org.hl7.fhir.r4.model.IdType
29
29
import org.hl7.fhir.r4.model.Parameters
30
30
import org.hl7.fhir.r4.model.PlanDefinition
31
31
import org.hl7.fhir.r4.model.Resource
32
+ import org.hl7.fhir.r4.model.ResourceType
32
33
import org.hl7.fhir.r4.model.StructureMap
33
34
import org.hl7.fhir.r4.model.Task
34
35
import org.hl7.fhir.r4.utils.FHIRPathEngine
35
36
import org.hl7.fhir.r4.utils.StructureMapUtilities
36
37
import org.smartregister.fhircore.engine.data.local.DefaultRepository
38
+ import org.smartregister.fhircore.engine.util.extension.asReference
37
39
import org.smartregister.fhircore.engine.util.extension.encodeResourceToString
38
40
import org.smartregister.fhircore.engine.util.extension.getCarePlanId
39
41
import org.smartregister.fhircore.engine.util.extension.taskStatusToCarePlanActivityStatus
@@ -133,12 +135,17 @@ constructor(val fhirEngine: FhirEngine, val transformSupportServices: TransformS
133
135
}
134
136
}
135
137
136
- suspend fun completeTask (id : String , encounterStatus : EncounterStatus ? ) {
138
+ suspend fun completeTask (
139
+ id : String ,
140
+ encounterStatus : EncounterStatus ? ,
141
+ encounterReference : String ,
142
+ ) {
137
143
val resourcesToUpdate = mutableListOf<Resource >()
138
144
val task =
139
145
fhirEngine.get<Task >(id).apply {
140
146
this .status = encounterStatusToTaskStatus(encounterStatus)
141
147
this .lastModified = Date ()
148
+ this .encounter = encounterReference.asReference(ResourceType .Encounter )
142
149
}
143
150
resourcesToUpdate.add(task)
144
151
val carePlanId = task.getCarePlanId()
0 commit comments