Search in sources :

Example 1 with OrderSignContext

use of org.hl7.davinci.r4.crdhook.ordersign.OrderSignContext in project CRD by HL7-DaVinci.

the class CrdRequestCreator method createOrderSignRequest.

/**
 * Generate a order sign request that contains a ServiceRequest.
 *
 * @param patientGender Desired gender of the patient in the request
 * @param patientBirthdate Desired birth date of the patient in the request
 * @return Fully populated CdsRequest
 */
public static OrderSignRequest createOrderSignRequest(Enumerations.AdministrativeGender patientGender, Date patientBirthdate, String patientAddressState, String providerAddressState) {
    OrderSignRequest request = new OrderSignRequest();
    request.setHook(Hook.ORDER_SIGN);
    request.setHookInstance(UUID.randomUUID().toString());
    OrderSignContext context = new OrderSignContext();
    request.setContext(context);
    context.setUserId("Practitioner/1234");
    Patient patient = createPatient(patientGender, patientBirthdate, patientAddressState);
    context.setPatientId(patient.getId());
    ServiceRequest sr = new ServiceRequest();
    sr.setStatus(ServiceRequest.ServiceRequestStatus.DRAFT);
    sr.setId("DeviceRequest/123");
    sr.setIntent(ServiceRequest.ServiceRequestIntent.ORDER);
    PrefetchCallback callback = (p, c) -> {
        sr.addPerformer(new Reference(p));
        sr.addInsurance(new Reference(c));
    };
    sr.setSubject(new Reference(patient));
    Practitioner provider = createPractitioner();
    Bundle prefetchBundle = createPrefetchBundle(patient, provider, callback, providerAddressState);
    Coding oxygen = new Coding().setCode("A0426").setSystem("https://bluebutton.cms.gov/resources/codesystem/hcpcs").setDisplay("Ambulance service, advanced life support, non-emergency transport, level 1 (als 1)");
    sr.setCode(new CodeableConcept().addCoding(oxygen).setText("Ambulance service Non-Emergency Transport"));
    Bundle orderBundle = new Bundle();
    Bundle.BundleEntryComponent bec = new Bundle.BundleEntryComponent();
    bec.setResource(sr);
    orderBundle.addEntry(bec);
    Bundle.BundleEntryComponent pfDrBec = new Bundle.BundleEntryComponent();
    pfDrBec.setResource(sr);
    prefetchBundle.addEntry(pfDrBec);
    context.setDraftOrders(orderBundle);
    Device device = new Device();
    device.setType(new CodeableConcept().addCoding(oxygen));
    bec = new Bundle.BundleEntryComponent();
    bec.setResource(device);
    prefetchBundle.addEntry(bec);
    CrdPrefetch prefetch = new CrdPrefetch();
    prefetch.setServiceRequestBundle(prefetchBundle);
    request.setPrefetch(prefetch);
    return request;
}
Also used : CrdPrefetch(org.hl7.davinci.r4.crdhook.CrdPrefetch) Logger(org.slf4j.Logger) OrderSignContext(org.hl7.davinci.r4.crdhook.ordersign.OrderSignContext) Date(java.util.Date) org.hl7.fhir.r4.model(org.hl7.fhir.r4.model) LoggerFactory(org.slf4j.LoggerFactory) UUID(java.util.UUID) OrderSignRequest(org.hl7.davinci.r4.crdhook.ordersign.OrderSignRequest) OrderSelectContext(org.hl7.davinci.r4.crdhook.orderselect.OrderSelectContext) AddressUse(org.hl7.fhir.r4.model.Address.AddressUse) ArrayList(java.util.ArrayList) List(java.util.List) OrderSelectRequest(org.hl7.davinci.r4.crdhook.orderselect.OrderSelectRequest) Hook(org.cdshooks.Hook) AddressType(org.hl7.fhir.r4.model.Address.AddressType) OrderSignContext(org.hl7.davinci.r4.crdhook.ordersign.OrderSignContext) CrdPrefetch(org.hl7.davinci.r4.crdhook.CrdPrefetch) OrderSignRequest(org.hl7.davinci.r4.crdhook.ordersign.OrderSignRequest)

Aggregations

ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 UUID (java.util.UUID)1 Hook (org.cdshooks.Hook)1 CrdPrefetch (org.hl7.davinci.r4.crdhook.CrdPrefetch)1 OrderSelectContext (org.hl7.davinci.r4.crdhook.orderselect.OrderSelectContext)1 OrderSelectRequest (org.hl7.davinci.r4.crdhook.orderselect.OrderSelectRequest)1 OrderSignContext (org.hl7.davinci.r4.crdhook.ordersign.OrderSignContext)1 OrderSignRequest (org.hl7.davinci.r4.crdhook.ordersign.OrderSignRequest)1 org.hl7.fhir.r4.model (org.hl7.fhir.r4.model)1 AddressType (org.hl7.fhir.r4.model.Address.AddressType)1 AddressUse (org.hl7.fhir.r4.model.Address.AddressUse)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1