Search in sources :

Example 1 with UserDto

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();
    }
}
Also used : TaskFailBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.TaskFailBundleFactory) Task(org.hl7.fhir.r4.model.Task) CpClientException(org.hl7.gravity.refimpl.sdohexchange.service.CpService.CpClientException) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) Bundle(org.hl7.fhir.r4.model.Bundle) TaskUpdateBundleExtractor(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.TaskUpdateBundleExtractor) TaskUpdateInfoHolder(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.TaskUpdateBundleExtractor.TaskUpdateInfoHolder) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) TaskUpdateBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.TaskUpdateBundleFactory)

Example 2 with UserDto

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());
}
Also used : TaskInfoHolder(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.TaskInfoBundleExtractor.TaskInfoHolder) Task(org.hl7.fhir.r4.model.Task) OurTaskUpdateBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.OurTaskUpdateBundleFactory) Bundle(org.hl7.fhir.r4.model.Bundle) TaskInfoBundleExtractor(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.TaskInfoBundleExtractor) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) IdType(org.hl7.fhir.r4.model.IdType)

Example 3 with UserDto

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();
}
Also used : UserInfoToDtoConverter(org.hl7.gravity.refimpl.sdohexchange.dto.converter.UserInfoToDtoConverter) UserDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.UserDto) PutMapping(org.springframework.web.bind.annotation.PutMapping) ApiOperation(io.swagger.annotations.ApiOperation)

Example 4 with UserDto

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;
}
Also used : UserDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.UserDto)

Example 5 with 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."));
}
Also used : GoalPrepareBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.GoalPrepareBundleFactory) Goal(org.hl7.fhir.r4.model.Goal) GoalBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.GoalBundleFactory) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) Bundle(org.hl7.fhir.r4.model.Bundle) HealthConcernCreateException(org.hl7.gravity.refimpl.sdohexchange.exception.HealthConcernCreateException) GoalBundleToDtoConverter(org.hl7.gravity.refimpl.sdohexchange.dto.converter.GoalBundleToDtoConverter) GoalPrepareBundleExtractor(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.GoalPrepareBundleExtractor) IdType(org.hl7.fhir.r4.model.IdType)

Aggregations

Bundle (org.hl7.fhir.r4.model.Bundle)12 IdType (org.hl7.fhir.r4.model.IdType)7 IBaseBundle (org.hl7.fhir.instance.model.api.IBaseBundle)5 Task (org.hl7.fhir.r4.model.Task)5 UserDto (org.hl7.gravity.refimpl.sdohexchange.dto.response.UserDto)5 ApiOperation (io.swagger.annotations.ApiOperation)3 UserInfoToDtoConverter (org.hl7.gravity.refimpl.sdohexchange.dto.converter.UserInfoToDtoConverter)3 PutMapping (org.springframework.web.bind.annotation.PutMapping)3 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)2 Condition (org.hl7.fhir.r4.model.Condition)2 Practitioner (org.hl7.fhir.r4.model.Practitioner)2 PractitionerRole (org.hl7.fhir.r4.model.PractitionerRole)2 Reference (org.hl7.fhir.r4.model.Reference)2 ServiceRequest (org.hl7.fhir.r4.model.ServiceRequest)2 HealthConcernCreateException (org.hl7.gravity.refimpl.sdohexchange.exception.HealthConcernCreateException)2 CurrentContextPrepareBundleExtractor (org.hl7.gravity.refimpl.sdohexchange.fhir.extract.CurrentContextPrepareBundleExtractor)2 TaskInfoBundleExtractor (org.hl7.gravity.refimpl.sdohexchange.fhir.extract.TaskInfoBundleExtractor)2 TaskInfoHolder (org.hl7.gravity.refimpl.sdohexchange.fhir.extract.TaskInfoBundleExtractor.TaskInfoHolder)2 CurrentContextPrepareBundleFactory (org.hl7.gravity.refimpl.sdohexchange.fhir.factory.CurrentContextPrepareBundleFactory)2 TaskFailBundleFactory (org.hl7.gravity.refimpl.sdohexchange.fhir.factory.TaskFailBundleFactory)2