Search in sources :

Example 6 with UserDto

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();
}
Also used : Task(org.hl7.fhir.r4.model.Task) NewFeedbackTaskRequestDto(org.hl7.gravity.refimpl.sdohexchange.dto.request.patienttask.NewFeedbackTaskRequestDto) Bundle(org.hl7.fhir.r4.model.Bundle) NewSocialRiskTaskRequestDto(org.hl7.gravity.refimpl.sdohexchange.dto.request.patienttask.NewSocialRiskTaskRequestDto) NewMakeContactTaskRequestDto(org.hl7.gravity.refimpl.sdohexchange.dto.request.patienttask.NewMakeContactTaskRequestDto) PatientTaskBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.patienttask.PatientTaskBundleFactory)

Example 7 with UserDto

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;
}
Also used : PatientSocialRiskTaskPrepareBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.patienttask.PatientSocialRiskTaskPrepareBundleFactory) PatientSocialRiskTaskBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.patienttask.PatientSocialRiskTaskBundleFactory) Bundle(org.hl7.fhir.r4.model.Bundle) PatientSocialRiskTaskPrepareBundleExtractor(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.patienttask.PatientSocialRiskTaskPrepareBundleExtractor)

Example 8 with UserDto

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

Example 9 with UserDto

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;
}
Also used : ConsentCreateException(org.hl7.gravity.refimpl.sdohexchange.exception.ConsentCreateException) Bundle(org.hl7.fhir.r4.model.Bundle) Reference(org.hl7.fhir.r4.model.Reference) ConsentPrepareBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.ConsentPrepareBundleFactory) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole)

Example 10 with UserDto

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

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