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();
}
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();
}
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();
}
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."));
}
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;
}
Aggregations