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;
}
Aggregations