use of org.hl7.gravity.refimpl.sdohexchange.dto.response.UserDto in project Gravity-SDOH-Exchange-RI by FHIR.
the class PatientTaskService method newTask.
public String newTask(NewPatientTaskRequestDto taskRequest, UserDto user) {
Assert.notNull(SmartOnFhirContext.get().getPatient(), "Patient id cannot be null.");
PatientTaskBundleFactory taskBundleFactory;
if (taskRequest instanceof NewMakeContactTaskRequestDto) {
taskBundleFactory = createMakeContactTaskBundleFactory(user, (NewMakeContactTaskRequestDto) taskRequest);
} else if (taskRequest instanceof NewSocialRiskTaskRequestDto) {
taskBundleFactory = createSocialRiskTaskBundleFactory(user, (NewSocialRiskTaskRequestDto) taskRequest);
} else if (taskRequest instanceof NewFeedbackTaskRequestDto) {
taskBundleFactory = createFeedbackTaskBundleFactory(user, (NewFeedbackTaskRequestDto) taskRequest);
} else {
throw new IllegalArgumentException(taskRequest.getClass().getSimpleName() + " instances not supported yet.");
}
Bundle taskCreateBundle = ehrClient.transaction().withBundle(taskBundleFactory.createBundle()).execute();
return FhirUtil.getFromResponseBundle(taskCreateBundle, Task.class).getIdPart();
}
use of org.hl7.gravity.refimpl.sdohexchange.dto.response.UserDto in project Gravity-SDOH-Exchange-RI by FHIR.
the class PatientTaskService method createSocialRiskTaskBundleFactory.
private PatientSocialRiskTaskBundleFactory createSocialRiskTaskBundleFactory(UserDto user, NewSocialRiskTaskRequestDto socialRiskTaskRequest) {
PatientSocialRiskTaskPrepareBundleFactory taskPrepareBundleFactory = new PatientSocialRiskTaskPrepareBundleFactory(SmartOnFhirContext.get().getPatient(), user.getId(), socialRiskTaskRequest.getQuestionnaireId());
Bundle taskRelatedResources = ehrClient.transaction().withBundle(taskPrepareBundleFactory.createPrepareBundle()).execute();
PatientSocialRiskTaskPrepareBundleExtractor.PatientSocialRiskTaskPrepareInfoHolder taskPrepareInfoHolder = new PatientSocialRiskTaskPrepareBundleExtractor().extract(taskRelatedResources);
PatientSocialRiskTaskBundleFactory taskBundleFactory = new PatientSocialRiskTaskBundleFactory();
taskBundleFactory.setName(socialRiskTaskRequest.getName());
taskBundleFactory.setPatient(taskPrepareInfoHolder.getPatient());
taskBundleFactory.setPriority(socialRiskTaskRequest.getPriority());
taskBundleFactory.setOccurrence(socialRiskTaskRequest.getOccurrence());
taskBundleFactory.setRequester(taskPrepareInfoHolder.getPerformer());
taskBundleFactory.setComment(socialRiskTaskRequest.getComment());
taskBundleFactory.setUser(user);
taskBundleFactory.setQuestionniare(taskPrepareInfoHolder.getQuestionnaire());
return taskBundleFactory;
}
use of org.hl7.gravity.refimpl.sdohexchange.dto.response.UserDto in project Gravity-SDOH-Exchange-RI by FHIR.
the class PatientTaskService method update.
public void update(String id, UpdateTaskRequestDto update, UserDto user) {
Task task = ehrClient.read().resource(Task.class).withId(id).execute();
if (task == null) {
throw new ResourceNotFoundException(new IdType(Task.class.getSimpleName(), id));
}
PatientTaskUpdateBundleFactory updateBundleFactory = new PatientTaskUpdateBundleFactory();
updateBundleFactory.setTask(task);
updateBundleFactory.setStatus(update.getFhirStatus());
updateBundleFactory.setStatusReason(update.getStatusReason());
updateBundleFactory.setComment(update.getComment());
updateBundleFactory.setUser(user);
ehrClient.transaction().withBundle(updateBundleFactory.createUpdateBundle()).execute();
}
use of org.hl7.gravity.refimpl.sdohexchange.dto.response.UserDto in project Gravity-SDOH-Exchange-RI by FHIR.
the class ConsentService method retrieveOrganization.
private Reference retrieveOrganization(UserDto userDto) {
Bundle bundle = new ConsentPrepareBundleFactory(userDto.getId()).createPrepareBundle();
Bundle consentResponseBundle = ehrClient.transaction().withBundle(bundle).execute();
Bundle consentBundle = FhirUtil.getFirstFromBundle(consentResponseBundle, Bundle.class);
PractitionerRole practitionerRole = FhirUtil.getFirstFromBundle(consentBundle, PractitionerRole.class);
Reference organization = practitionerRole.getOrganization();
if (organization == null) {
throw new ConsentCreateException("No Organization found for Consent creation.");
}
return organization;
}
use of org.hl7.gravity.refimpl.sdohexchange.dto.response.UserDto in project Gravity-SDOH-Exchange-RI by FHIR.
the class PractitionerToDtoConverter method convert.
@Override
public UserDto convert(Practitioner practitioner) {
UserDto userDto = new UserDto(practitioner.getIdElement().getIdPart(), Practitioner.class.getSimpleName());
userDto.setName(practitioner.getNameFirstRep().getNameAsSingleString());
return userDto;
}
Aggregations