Search in sources :

Example 11 with UserDto

use of org.hl7.gravity.refimpl.sdohexchange.dto.response.UserDto in project Gravity-SDOH-Exchange-RI by FHIR.

the class TaskService method getRole.

private PractitionerRole getRole(UserDto user) {
    Bundle prs = cpClient.search().forResource(PractitionerRole.class).where(PractitionerRole.PRACTITIONER.hasId(user.getId())).and(new StringClientParam(Constants.PARAM_PROFILE).matches().value(UsCoreProfiles.PRACTITIONER_ROLE)).and(new StringClientParam(PractitionerRole.SP_ORGANIZATION + "." + Constants.PARAM_PROFILE).matches().value(UsCoreProfiles.ORGANIZATION)).returnBundle(Bundle.class).execute();
    List<PractitionerRole> roles = FhirUtil.getFromBundle(prs, PractitionerRole.class);
    if (roles.isEmpty()) {
        throw new IllegalStateException("No Practitioner role with US Core profile which references to US Core Organization have been found.");
    } else if (roles.size() > 1) {
        throw new IllegalStateException("More than one Practitioner role with US Core profile which references to US Core Organization have been " + "found.");
    }
    return roles.stream().findFirst().get();
}
Also used : StringClientParam(ca.uhn.fhir.rest.gclient.StringClientParam) Bundle(org.hl7.fhir.r4.model.Bundle) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole)

Example 12 with UserDto

use of org.hl7.gravity.refimpl.sdohexchange.dto.response.UserDto in project Gravity-SDOH-Exchange-RI by FHIR.

the class TaskController 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());
    taskService.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 13 with UserDto

use of org.hl7.gravity.refimpl.sdohexchange.dto.response.UserDto in project Gravity-SDOH-Exchange-RI by FHIR.

the class OurTaskController method update.

@PutMapping("/{id}")
@ApiOperation(value = "Update Our Task resource.")
public ResponseEntity<Void> update(@PathVariable @NotBlank(message = "Task id can't be empty.") String id, @RequestBody @Valid UpdateOurTaskRequestDto updateOurTaskRequestDto, @ApiIgnore @AuthenticationPrincipal OidcUser user) {
    UserDto userDto = new UserInfoToDtoConverter().convert(user.getClaims());
    ourTaskService.update(id, updateOurTaskRequestDto, 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 14 with UserDto

use of org.hl7.gravity.refimpl.sdohexchange.dto.response.UserDto in project Gravity-SDOH-Exchange-RI by FHIR.

the class HealthConcernService method create.

public HealthConcernDto create(NewHealthConcernDto newHealthConcernDto, UserDto user) {
    Assert.notNull(SmartOnFhirContext.get().getPatient(), "Patient id cannot be null.");
    CurrentContextPrepareBundleFactory healthConcernPrepareBundleFactory = new CurrentContextPrepareBundleFactory(SmartOnFhirContext.get().getPatient(), user.getId());
    Bundle healthConcernRelatedResources = ehrClient.transaction().withBundle(healthConcernPrepareBundleFactory.createPrepareBundle()).execute();
    CurrentContextPrepareInfoHolder healthConcernPrepareInfoHolder = new CurrentContextPrepareBundleExtractor().extract(healthConcernRelatedResources);
    ConditionBundleFactory bundleFactory = new ConditionBundleFactory();
    bundleFactory.setName(newHealthConcernDto.getName());
    bundleFactory.setBasedOnText(newHealthConcernDto.getBasedOnText());
    String category = newHealthConcernDto.getCategory();
    bundleFactory.setCategory(sdohMappings.findCategoryCoding(category));
    bundleFactory.setConditionType(UsCoreConditionCategory.HEALTHCONCERN);
    bundleFactory.setIcdCode(sdohMappings.findCoding(category, Condition.class, System.ICD_10, newHealthConcernDto.getIcdCode()));
    bundleFactory.setSnomedCode(sdohMappings.findCoding(category, Condition.class, System.SNOMED, newHealthConcernDto.getSnomedCode()));
    bundleFactory.setPatient(healthConcernPrepareInfoHolder.getPatient());
    bundleFactory.setPractitioner(healthConcernPrepareInfoHolder.getPractitioner());
    Bundle healthConcernCreateBundle = ehrClient.transaction().withBundle(bundleFactory.createBundle()).execute();
    IdType healthConcernId = FhirUtil.getFromResponseBundle(healthConcernCreateBundle, Condition.class);
    Bundle responseBundle = searchHealthConcernQuery(ConditionClinicalStatus.ACTIVE).where(Condition.RES_ID.exactly().code(healthConcernId.getIdPart())).returnBundle(Bundle.class).execute();
    return new HealthConcernBundleToDtoConverter().convert(responseBundle).stream().findFirst().orElseThrow(() -> new HealthConcernCreateException("Health Concern is not found in the response bundle."));
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) CurrentContextPrepareBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.CurrentContextPrepareBundleFactory) CurrentContextPrepareBundleExtractor(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.CurrentContextPrepareBundleExtractor) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) Bundle(org.hl7.fhir.r4.model.Bundle) HealthConcernCreateException(org.hl7.gravity.refimpl.sdohexchange.exception.HealthConcernCreateException) HealthConcernBundleToDtoConverter(org.hl7.gravity.refimpl.sdohexchange.dto.converter.HealthConcernBundleToDtoConverter) CurrentContextPrepareInfoHolder(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.CurrentContextPrepareBundleExtractor.CurrentContextPrepareInfoHolder) ConditionBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.ConditionBundleFactory) IdType(org.hl7.fhir.r4.model.IdType)

Example 15 with UserDto

use of org.hl7.gravity.refimpl.sdohexchange.dto.response.UserDto in project Gravity-SDOH-Exchange-RI by FHIR.

the class PatientTaskService method createFeedbackTaskBundleFactory.

private PatientTaskBundleFactory createFeedbackTaskBundleFactory(UserDto user, NewFeedbackTaskRequestDto feedbackTaskRequest) {
    PatientFeedbackTaskPrepareBundleFactory taskPrepareBundleFactory = new PatientFeedbackTaskPrepareBundleFactory(SmartOnFhirContext.get().getPatient(), user.getId(), feedbackTaskRequest.getReferralTaskId());
    Bundle taskRelatedResources = ehrClient.transaction().withBundle(taskPrepareBundleFactory.createPrepareBundle()).execute();
    PatientFeedbackTaskPrepareBundleExtractor.PatientFeedbackTaskPrepareInfoHolder taskPrepareInfoHolder = new PatientFeedbackTaskPrepareBundleExtractor().extract(taskRelatedResources);
    PatientFeedbackTaskBundleFactory taskBundleFactory = new PatientFeedbackTaskBundleFactory();
    taskBundleFactory.setName(feedbackTaskRequest.getName());
    taskBundleFactory.setPatient(taskPrepareInfoHolder.getPatient());
    taskBundleFactory.setPriority(feedbackTaskRequest.getPriority());
    taskBundleFactory.setOccurrence(feedbackTaskRequest.getOccurrence());
    taskBundleFactory.setRequester(taskPrepareInfoHolder.getPerformer());
    // TODO verify whether the passed Task instance is related to the Patient
    taskBundleFactory.setReferralTask(taskPrepareInfoHolder.getReferralTask());
    taskBundleFactory.setComment(feedbackTaskRequest.getComment());
    taskBundleFactory.setUser(user);
    return taskBundleFactory;
}
Also used : PatientFeedbackTaskBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.patienttask.PatientFeedbackTaskBundleFactory) PatientFeedbackTaskPrepareBundleExtractor(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.patienttask.PatientFeedbackTaskPrepareBundleExtractor) Bundle(org.hl7.fhir.r4.model.Bundle) PatientFeedbackTaskPrepareBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.patienttask.PatientFeedbackTaskPrepareBundleFactory)

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