Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TaskRequest Object should only be created if incoming task is persisted #39

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,12 @@ public void execute() {
taskBundle = client.loadPage().next(taskBundle).execute();
taskBundles.add(taskBundle);
}
updateTasksInBundle(taskBundles);

TaskRequest request = new TaskRequest();
request.setRequestDate(newDate);
labOnFhirService.saveOrUpdateTaskRequest(request);
Boolean tasksUpdated = updateTasksInBundle(taskBundles);
if (tasksUpdated) {
TaskRequest request = new TaskRequest();
request.setRequestDate(newDate);
labOnFhirService.saveOrUpdateTaskRequest(request);
}
}
catch (Exception e) {
log.error("ERROR executing FetchTaskUpdates : " + e.toString() + getStackTrace(e));
Expand All @@ -146,7 +147,8 @@ public void shutdown() {
this.stopExecuting();
}

private void updateTasksInBundle(List<Bundle> taskBundles) {
private Boolean updateTasksInBundle(List<Bundle> taskBundles) {
Boolean tasksUpdated = false;
for (Bundle bundle : taskBundles) {
for (Iterator tasks = bundle.getEntry().iterator(); tasks.hasNext();) {
String openmrsTaskUuid = null;
Expand All @@ -170,6 +172,7 @@ private void updateTasksInBundle(List<Bundle> taskBundles) {
}
if (taskOutPutUpdated) {
taskService.update(openmrsTaskUuid, openmrsTask);
tasksUpdated = taskOutPutUpdated;
}
}
}
Expand All @@ -178,6 +181,7 @@ private void updateTasksInBundle(List<Bundle> taskBundles) {
}
}
}
return tasksUpdated;
}

private Boolean updateOutput(List<Task.TaskOutputComponent> output, Task openmrsTask) {
Expand Down
Loading