use of org.hl7.gravity.refimpl.sdohexchange.dto.response.UserDto in project Gravity-SDOH-Exchange-RI by FHIR.
the class TaskService method update.
public void update(String id, UpdateTaskRequestDto update, UserDto user) {
Bundle taskBundle = getTask(id, Task.INCLUDE_FOCUS, Task.INCLUDE_OWNER, Organization.INCLUDE_ENDPOINT.setRecurse(true));
TaskUpdateInfoHolder updateInfo = new TaskUpdateBundleExtractor(id).extract(taskBundle);
Task task = updateInfo.getTask();
ServiceRequest serviceRequest = updateInfo.getServiceRequest();
TaskUpdateBundleFactory updateBundleFactory = new TaskUpdateBundleFactory();
updateBundleFactory.setTask(task);
updateBundleFactory.setServiceRequest(serviceRequest);
updateBundleFactory.setStatus(update.getFhirStatus());
updateBundleFactory.setStatusReason(update.getStatusReason());
updateBundleFactory.setComment(update.getComment());
updateBundleFactory.setUser(user);
ehrClient.transaction().withBundle(updateBundleFactory.createUpdateBundle()).execute();
try {
cpService.sync(task, serviceRequest, updateInfo.getEndpoint());
} catch (CpClientException exc) {
ehrClient.transaction().withBundle(new TaskFailBundleFactory(task, serviceRequest, exc.getMessage()).createFailBundle()).execute();
}
}
use of org.hl7.gravity.refimpl.sdohexchange.dto.response.UserDto in project Gravity-SDOH-Exchange-RI by FHIR.
the class OurTaskService method update.
public void update(String id, UpdateOurTaskRequestDto update, UserDto user) {
Bundle taskBundle = taskRepository.find(id, Lists.newArrayList(Task.INCLUDE_FOCUS));
TaskInfoHolder taskInfo = new TaskInfoBundleExtractor().extract(taskBundle).stream().findFirst().orElseThrow(() -> new ResourceNotFoundException(new IdType(Task.class.getSimpleName(), id)));
OurTaskUpdateBundleFactory bundleFactory = new OurTaskUpdateBundleFactory();
bundleFactory.setTask(taskInfo.getTask());
bundleFactory.setServiceRequest(taskInfo.getServiceRequest());
bundleFactory.setStatus(update.getTaskStatus());
bundleFactory.setStatusReason(update.getStatusReason());
bundleFactory.setComment(update.getComment());
bundleFactory.setUser(user);
taskRepository.transaction(bundleFactory.createUpdateBundle());
}
use of org.hl7.gravity.refimpl.sdohexchange.dto.response.UserDto in project Gravity-SDOH-Exchange-RI by FHIR.
the class PatientTaskController method update.
@PutMapping("{id}")
@ApiOperation(value = "Update Task resource.")
public ResponseEntity<Void> update(@PathVariable @NotBlank(message = "Task id can't be empty.") String id, @Valid @RequestBody UpdateTaskRequestDto update, @ApiIgnore @AuthenticationPrincipal OidcUser user) {
UserDto userDto = new UserInfoToDtoConverter().convert(user.getClaims());
patientTaskService.update(id, update, userDto);
return ResponseEntity.noContent().build();
}
use of org.hl7.gravity.refimpl.sdohexchange.dto.response.UserDto in project Gravity-SDOH-Exchange-RI by FHIR.
the class UserInfoToDtoConverter method convert.
@Override
public UserDto convert(Map<String, Object> claims) {
UserDto userDto = new UserDto();
String fhirUser = getClaimValue(claims, "fhirUser");
if (fhirUser != null) {
userDto.setId(StringUtils.substringAfter(fhirUser, "/"));
userDto.setUserType(StringUtils.substringBefore(fhirUser, "/"));
}
userDto.setName(getClaimValue(claims, "displayName"));
userDto.setEmail(getClaimValue(claims, "email"));
return userDto;
}
use of org.hl7.gravity.refimpl.sdohexchange.dto.response.UserDto in project Gravity-SDOH-Exchange-RI by FHIR.
the class GoalService method create.
public GoalDto create(NewGoalDto newGoalDto, UserDto user) {
Assert.notNull(SmartOnFhirContext.get().getPatient(), "Patient id cannot be null.");
GoalPrepareBundleFactory goalPrepareBundleFactory = new GoalPrepareBundleFactory(SmartOnFhirContext.get().getPatient(), user.getId(), newGoalDto.getProblemIds());
Bundle goalRelatedResources = ehrClient.transaction().withBundle(goalPrepareBundleFactory.createPrepareBundle()).execute();
GoalPrepareBundleExtractor.GoalPrepareInfoHolder goalPrepareInfoHolder = new GoalPrepareBundleExtractor().extract(goalRelatedResources);
GoalBundleFactory bundleFactory = new GoalBundleFactory();
bundleFactory.setName(newGoalDto.getName());
String category = newGoalDto.getCategory();
bundleFactory.setCategory(sdohMappings.findCategoryCoding(category));
bundleFactory.setSnomedCode(sdohMappings.findCoding(category, Goal.class, System.SNOMED, newGoalDto.getSnomedCode()));
bundleFactory.setAchievementStatus(newGoalDto.getAchievementStatus());
bundleFactory.setPatient(goalPrepareInfoHolder.getPatient());
bundleFactory.setPractitioner(goalPrepareInfoHolder.getPractitioner());
bundleFactory.setUser(user);
bundleFactory.setComment(newGoalDto.getComment());
bundleFactory.setProblems(goalPrepareInfoHolder.getProblems(newGoalDto.getProblemIds()));
bundleFactory.setStartDate(newGoalDto.getStart());
Bundle goalCreateBundle = ehrClient.transaction().withBundle(bundleFactory.createPrepareBundle()).execute();
IdType goalId = FhirUtil.getFromResponseBundle(goalCreateBundle, Goal.class);
Bundle responseBundle = searchGoalQuery(Goal.GoalLifecycleStatus.ACTIVE).where(Condition.RES_ID.exactly().code(goalId.getIdPart())).returnBundle(Bundle.class).execute();
Bundle merged = addConditionsToGoalBundle(responseBundle);
return new GoalBundleToDtoConverter().convert(merged).stream().findFirst().orElseThrow(() -> new HealthConcernCreateException("goal is not found in the response bundle."));
}
Aggregations