Search in sources :

Example 1 with NewMakeContactTaskRequestDto

use of org.hl7.gravity.refimpl.sdohexchange.dto.request.patienttask.NewMakeContactTaskRequestDto 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 2 with NewMakeContactTaskRequestDto

use of org.hl7.gravity.refimpl.sdohexchange.dto.request.patienttask.NewMakeContactTaskRequestDto in project Gravity-SDOH-Exchange-RI by FHIR.

the class PatientTaskService method createMakeContactTaskBundleFactory.

private PatientMakeContactTaskBundleFactory createMakeContactTaskBundleFactory(UserDto user, NewMakeContactTaskRequestDto makeContactTaskRequest) {
    PatientMakeContactTaskPrepareBundleFactory taskPrepareBundleFactory = new PatientMakeContactTaskPrepareBundleFactory(SmartOnFhirContext.get().getPatient(), user.getId(), makeContactTaskRequest.getHealthcareServiceId(), makeContactTaskRequest.getReferralTaskId());
    Bundle taskRelatedResources = ehrClient.transaction().withBundle(taskPrepareBundleFactory.createPrepareBundle()).execute();
    PatientMakeContactTaskPrepareBundleExtractor.PatientMakeContactTaskPrepareInfoHolder taskPrepareInfoHolder = new PatientMakeContactTaskPrepareBundleExtractor().extract(taskRelatedResources);
    PatientMakeContactTaskBundleFactory taskBundleFactory = new PatientMakeContactTaskBundleFactory();
    taskBundleFactory.setName(makeContactTaskRequest.getName());
    taskBundleFactory.setPatient(taskPrepareInfoHolder.getPatient());
    taskBundleFactory.setPriority(makeContactTaskRequest.getPriority());
    taskBundleFactory.setOccurrence(makeContactTaskRequest.getOccurrence());
    taskBundleFactory.setRequester(taskPrepareInfoHolder.getPerformer());
    // TODO verify whether the passed Task instance is related to the Patient
    taskBundleFactory.setReferralTask(taskPrepareInfoHolder.getReferralTask());
    taskBundleFactory.setComment(makeContactTaskRequest.getComment());
    taskBundleFactory.setUser(user);
    // TODO verify whether the passed HealthcareService instance is related to the task
    taskBundleFactory.setContactInfo(taskPrepareInfoHolder.getHealthcareService());
    return taskBundleFactory;
}
Also used : PatientMakeContactTaskBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.patienttask.PatientMakeContactTaskBundleFactory) Bundle(org.hl7.fhir.r4.model.Bundle) PatientMakeContactTaskPrepareBundleFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.patienttask.PatientMakeContactTaskPrepareBundleFactory) PatientMakeContactTaskPrepareBundleExtractor(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.patienttask.PatientMakeContactTaskPrepareBundleExtractor)

Aggregations

Bundle (org.hl7.fhir.r4.model.Bundle)2 Task (org.hl7.fhir.r4.model.Task)1 NewFeedbackTaskRequestDto (org.hl7.gravity.refimpl.sdohexchange.dto.request.patienttask.NewFeedbackTaskRequestDto)1 NewMakeContactTaskRequestDto (org.hl7.gravity.refimpl.sdohexchange.dto.request.patienttask.NewMakeContactTaskRequestDto)1 NewSocialRiskTaskRequestDto (org.hl7.gravity.refimpl.sdohexchange.dto.request.patienttask.NewSocialRiskTaskRequestDto)1 PatientMakeContactTaskPrepareBundleExtractor (org.hl7.gravity.refimpl.sdohexchange.fhir.extract.patienttask.PatientMakeContactTaskPrepareBundleExtractor)1 PatientMakeContactTaskBundleFactory (org.hl7.gravity.refimpl.sdohexchange.fhir.factory.patienttask.PatientMakeContactTaskBundleFactory)1 PatientMakeContactTaskPrepareBundleFactory (org.hl7.gravity.refimpl.sdohexchange.fhir.factory.patienttask.PatientMakeContactTaskPrepareBundleFactory)1 PatientTaskBundleFactory (org.hl7.gravity.refimpl.sdohexchange.fhir.factory.patienttask.PatientTaskBundleFactory)1