Skip to content

Commit

Permalink
KOP-682: Forgot to replace the instantiatesCanonical logic in one place.
Browse files Browse the repository at this point in the history
  • Loading branch information
JorisHeadease committed Nov 3, 2023
1 parent 5919154 commit 78f3eae
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</parent>
<groupId>nl.koppeltaal</groupId>
<artifactId>spring-boot-starter-smart-service</artifactId>
<version>1.1.58-SNAPSHOT</version>
<version>1.1.59-SNAPSHOT</version>
<name>Koppeltaal-2.0-Spring-SMART-Service</name>
<description>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)</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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);

Expand All @@ -22,4 +22,15 @@ public static Optional<String> 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;
}
}

0 comments on commit 78f3eae

Please sign in to comment.