diff --git a/pom.xml b/pom.xml index 7e9c899..238706e 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ nl.koppeltaal spring-boot-starter-smart-service - 1.1.58-SNAPSHOT + 1.1.59-SNAPSHOT Koppeltaal-2.0-Spring-SMART-Service spring-boot-starter-smart-service project to connect to a FHIR Store that works according to the SMART Backend Service flow (https://hl7.org/fhir/uv/bulkdata/authorization/index.html) diff --git a/src/main/java/nl/koppeltaal/spring/boot/starter/smartservice/dto/TaskDtoConverter.java b/src/main/java/nl/koppeltaal/spring/boot/starter/smartservice/dto/TaskDtoConverter.java index e1329de..13cfdb9 100644 --- a/src/main/java/nl/koppeltaal/spring/boot/starter/smartservice/dto/TaskDtoConverter.java +++ b/src/main/java/nl/koppeltaal/spring/boot/starter/smartservice/dto/TaskDtoConverter.java @@ -32,7 +32,7 @@ public void applyDto(Task task, TaskDto taskDto) { Collections.singletonList(createIdentifier(taskDto.getIdentifierSystem(), taskDto.getIdentifierValue()))); task.setRequester(new Reference(taskDto.getPractitioner())); task.setOwner(new Reference(taskDto.getPatient())); - addInstantiatesExtension(task, taskDto.getActivityDefinition()); + task.addExtension(ExtensionUtils.getInstantiatesExtension(taskDto.getActivityDefinition())); task.setStatus(Task.TaskStatus.fromCode(taskDto.getStatus())); // remove all "old" observer values @@ -59,18 +59,6 @@ public static void addObserverExtension(Task task, String observerReference) { task.addExtension(observerExtension); } - public static void addInstantiatesExtension(Task task, String activityDefinitionReference) { - final Reference instantiatesReference = new Reference(); - instantiatesReference.setReference(activityDefinitionReference); - instantiatesReference.setType(ResourceType.ActivityDefinition.name()); - - final Extension instantiatesExtension = new Extension(); - instantiatesExtension.setValue(instantiatesReference); - instantiatesExtension.setUrl(KT2_EXTENSION__TASK__INSTANTIATES); - - task.addExtension(instantiatesExtension); - } - public void applyResource(TaskDto taskDto, Task task) { taskDto.setReference(getRelativeReference(task.getIdElement())); diff --git a/src/main/java/nl/koppeltaal/spring/boot/starter/smartservice/service/fhir/TaskFhirClientService.java b/src/main/java/nl/koppeltaal/spring/boot/starter/smartservice/service/fhir/TaskFhirClientService.java index 45ee491..8784760 100644 --- a/src/main/java/nl/koppeltaal/spring/boot/starter/smartservice/service/fhir/TaskFhirClientService.java +++ b/src/main/java/nl/koppeltaal/spring/boot/starter/smartservice/service/fhir/TaskFhirClientService.java @@ -71,7 +71,7 @@ public Task getOrCreateTask(Patient patient, Practitioner practitioner, Activity task.setStatus(Task.TaskStatus.READY); task.setIntent(Task.TaskIntent.ORDER); task.getExecutionPeriod().setStart(new Date()); - task.setInstantiatesCanonical(activityDefinition.getUrl()); + task.addExtension(ExtensionUtils.getInstantiatesExtension(ResourceUtils.getReference(activityDefinition))); task = storeResource(task); } else { task = tasks.get(0); diff --git a/src/main/java/nl/koppeltaal/spring/boot/starter/smartservice/utils/ExtensionUtils.java b/src/main/java/nl/koppeltaal/spring/boot/starter/smartservice/utils/ExtensionUtils.java index b02f4b3..1d3f963 100644 --- a/src/main/java/nl/koppeltaal/spring/boot/starter/smartservice/utils/ExtensionUtils.java +++ b/src/main/java/nl/koppeltaal/spring/boot/starter/smartservice/utils/ExtensionUtils.java @@ -1,13 +1,13 @@ package nl.koppeltaal.spring.boot.starter.smartservice.utils; -import org.hl7.fhir.r4.model.DomainResource; -import org.hl7.fhir.r4.model.Extension; -import org.hl7.fhir.r4.model.Reference; +import org.hl7.fhir.r4.model.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Optional; +import static nl.koppeltaal.spring.boot.starter.smartservice.constants.FhirConstant.KT2_EXTENSION__TASK__INSTANTIATES; + public class ExtensionUtils { private static final Logger LOG = LoggerFactory.getLogger(ExtensionUtils.class); @@ -22,4 +22,15 @@ public static Optional getReferenceValue(DomainResource resource, String return Optional.empty(); } + public static Extension getInstantiatesExtension(String activityDefinitionReference) { + final Reference instantiatesReference = new Reference(); + instantiatesReference.setReference(activityDefinitionReference); + instantiatesReference.setType(ResourceType.ActivityDefinition.name()); + + final Extension instantiatesExtension = new Extension(); + instantiatesExtension.setValue(instantiatesReference); + instantiatesExtension.setUrl(KT2_EXTENSION__TASK__INSTANTIATES); + + return instantiatesExtension; + } }