Skip to content

Commit

Permalink
Resolved merge conflicts (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
moshonk authored Jan 31, 2024
1 parent b3ed330 commit 1a6897b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public Task createOrder(Order order) throws OrderCreationException {
mappedTestsExist = true;
}
}

if (!mappedTestsExist && config.filterOrderByTestUuuids()) {
return null;
}
Expand Down Expand Up @@ -85,26 +85,31 @@ public Task createOrder(Order order) throws OrderCreationException {
// Create References
List<Reference> basedOnRefs = Collections.singletonList(
newReference(order.getUuid(), FhirConstants.SERVICE_REQUEST));

Reference forReference = newReference(order.getPatient().getUuid(), FhirConstants.PATIENT);

Reference ownerRef = newReference(config.getLisUserUuid(), FhirConstants.PRACTITIONER);

Reference encounterRef = newReference(order.getEncounter().getUuid(), FhirConstants.ENCOUNTER);

Optional<EncounterProvider> requesterProvider = order.getEncounter().getActiveEncounterProviders().stream()
.findFirst();

Reference requesterRef = requesterProvider.map(
encounterProvider -> newReference(encounterProvider.getUuid(), FhirConstants.PRACTITIONER)).orElse(null);


Reference locationRef = null;
if (order.getEncounter().getLocation() != null) {
locationRef = newReference(order.getEncounter().getLocation().getUuid(), FhirConstants.LOCATION);
}

// Create Task Resource for given Order
Task newTask = createTask(basedOnRefs, forReference, ownerRef, encounterRef ,taskInputs);
Task newTask = createTask(basedOnRefs, forReference, ownerRef, encounterRef, locationRef ,taskInputs);

if (order.getEncounter().getActiveEncounterProviders().isEmpty()) {
newTask.setRequester(requesterRef);
}

// Save the new Task Resource
try {
newTask = taskService.create(newTask);
Expand All @@ -116,14 +121,15 @@ public Task createOrder(Order order) throws OrderCreationException {
}

private Task createTask(List<Reference> basedOnRefs, Reference forReference, Reference ownerRef,
Reference encounterRef ,List<Task.ParameterComponent> taskInputs) {
Reference encounterRef, Reference locationRef ,List<Task.ParameterComponent> taskInputs) {
Task newTask = new Task();
newTask.setStatus(Task.TaskStatus.REQUESTED);
newTask.setIntent(Task.TaskIntent.ORDER);
newTask.setBasedOn(basedOnRefs);
newTask.setFor(forReference);
newTask.setOwner(ownerRef);
newTask.setEncounter(encounterRef);
newTask.setLocation(locationRef);
if (taskInputs != null) {
newTask.setInput(taskInputs);
}
Expand Down Expand Up @@ -171,9 +177,9 @@ public Task createOrder(Encounter encounter) throws OrderCreationException {
taskInputs.add(input);
}
}

// Create Task Resource for given Order
Task newTask = createTask(basedOnRefs, forReference, ownerRef, encounterRef ,taskInputs);
Task newTask = createTask(basedOnRefs, forReference, ownerRef, encounterRef, locationRef ,taskInputs);
newTask.setLocation(locationRef);

if (!encounter.getActiveEncounterProviders().isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,14 @@ public Bundle createLabBundle(Task task) {
includes.add(new Include("Task:owner"));
includes.add(new Include("Task:encounter"));
includes.add(new Include("Task:based-on"));
includes.add(new Include("Task:location"));

IBundleProvider labBundle = fhirTaskService.searchForTasks(new TaskSearchParams(null, null, null, uuid, null, null, includes));

Bundle transactionBundle = new Bundle();
transactionBundle.setType(Bundle.BundleType.TRANSACTION);
List<IBaseResource> labResources = labBundle.getAllResources();
if (!task.getLocation().isEmpty() && config.getLabUpdateTriggerObject().equals("Encounter")) {
if (!task.getLocation().isEmpty()) {
labResources.add(fhirLocationService.get(FhirUtils.referenceToId(task.getLocation().getReference()).get()));
}
for (IBaseResource r : labResources) {
Expand Down

0 comments on commit 1a6897b

Please sign in to comment.