use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.MEDICATIONSTATEMENT in project nia-patient-switching-standard-adaptor by NHSDigital.
the class ResourceReferenceUtilTest method testMedicationResourcesReferencedAtCompoundStatementLevel.
@Test
public void testMedicationResourcesReferencedAtCompoundStatementLevel() {
final RCMRMT030101UK04CompoundStatement compoundStatement = unmarshallCompoundStatementElement("compound_statement_medication.xml");
List<Reference> references = new ArrayList<>();
resourceReferenceUtil.extractChildReferencesFromCompoundStatement(compoundStatement, references);
assertThat(references.size()).isEqualTo(THREE);
assertThat(references.get(0).getReference()).isEqualTo("MedicationStatement/A0A70B62-2649-4C8F-B3AB-618B8257C942-MS");
assertThat(references.get(1).getReference()).isEqualTo("MedicationRequest/A0A70B62-2649-4C8F-B3AB-618B8257C942");
assertThat(references.get(2).getReference()).isEqualTo("MedicationRequest/9B4B797A-D674-4362-B666-2ADC8551EEDA");
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.MEDICATIONSTATEMENT in project CRD by HL7-DaVinci.
the class CoverageRequirementsDiscoveryOperationHardCodedResponse method coverageRequirementsDiscovery.
/**
* Submits the CRD request.
* @param request the request to be submitted
* @param endpoint the endpoint to submit the request to
* @param requestQualification what kind of request it is
* @return the parameters returned from the server
*/
@Operation(name = "$coverage-requirements-discovery", idempotent = true)
public Parameters coverageRequirementsDiscovery(@OperationParam(name = "request") Parameters.ParametersParameterComponent request, @OperationParam(name = "endpoint") Endpoint endpoint, @OperationParam(name = "requestQualification") CodeableConcept requestQualification) {
logger.debug("coverageRequirementsDiscovery: start");
Parameters retVal = new Parameters();
CoverageEligibilityRequest eligibilityRequest = null;
Patient patient = null;
Coverage coverage = null;
Practitioner provider = null;
Organization insurer = null;
Location facility = null;
// supportingInformation
// serviceInformation
// grab the list of parameters
List<Parameters.ParametersParameterComponent> paramList = request.getPart();
// pull each of the parameters from the list
for (Parameters.ParametersParameterComponent part : paramList) {
System.out.println(part.getName());
switch(part.getName()) {
case "eligibilityrequest":
logger.debug("CRD: got eligibilityrequest");
eligibilityRequest = (CoverageEligibilityRequest) part.getResource();
break;
case "patient":
logger.debug("CRD: got patient");
patient = (Patient) part.getResource();
break;
case "coverage":
logger.debug("CRD: got coverage");
coverage = (Coverage) part.getResource();
break;
case "provider":
logger.debug("CRD: got provider");
provider = (Practitioner) part.getResource();
break;
case "insurer":
logger.debug("CRD: got insurer");
insurer = (Organization) part.getResource();
break;
case "facility":
logger.debug("CRD: got facility");
facility = (Location) part.getResource();
break;
case "patientContext":
ResourceType patientContextType = part.getResource().getResourceType();
switch(patientContextType) {
case Condition:
logger.debug("CRD: got request.patientContext of type Condition");
break;
case Device:
logger.debug("CRD: got request.patientContext of type Device");
break;
case Procedure:
logger.debug("CRD: got request.patientContext of type Procedure");
break;
case MedicationStatement:
logger.debug("CRD: got request.patientContext of type MedicationStatement");
break;
case HealthcareService:
logger.debug("CRD: got request.patientContext of type HealthcareService");
break;
default:
logger.warn("Warning: unexpected request.patientContext type");
break;
}
break;
case "serviceInformationReference":
ResourceType serviceInformationReferenceType = part.getResource().getResourceType();
switch(serviceInformationReferenceType) {
case Procedure:
logger.debug("CRD: got request.serviceInformationReferenceType of type Procedure");
break;
case HealthcareService:
logger.debug("CRD: got request.serviceInformationReferenceType " + "of type HealthcareService");
break;
case ServiceRequest:
logger.debug("CRD: got request.serviceInformationReferenceType " + "of type ServiceRequest");
break;
case MedicationRequest:
logger.debug("CRD: got request.serviceInformationReferenceType " + "of type MedicationRequest");
break;
case Medication:
logger.debug("CRD: got request.serviceInformationReferenceType of type Medication");
break;
case Device:
logger.debug("CRD: got request.serviceInformationReferenceType of type Device");
break;
case DeviceRequest:
logger.debug("CRD: got request.serviceInformationReferenceType " + "of type DeviceRequest");
break;
default:
logger.warn("Warning: unexpected request.serviceInformationReferenceType type");
break;
}
break;
default:
logger.warn("Warning: unexpected parameter part: " + part.getName());
break;
}
}
// Note: if nothing is set in the reference (even if it was created) it will be null
if (nullCheck(eligibilityRequest, "eligibilityrequest") || nullCheck(patient, "patient") || nullCheck(coverage, "coverage") || nullCheck(provider, "provider") || nullCheck(insurer, "insurer")) {
logger.error("ERROR: required information missing!");
return retVal;
}
// print out the patient name
assert patient != null;
if (patient.hasName()) {
logger.debug("CRD: Patient Name: " + patient.getName().get(0).getText());
} else {
logger.debug("CRD: No Patient Name provided");
}
// start building the response
CoverageEligibilityResponse eligibilityResponse = new CoverageEligibilityResponse();
eligibilityResponse.setDisposition("this is a test");
Endpoint finalEndPoint = new Endpoint();
finalEndPoint.setAddress("http://www.mitre.org");
Parameters.ParametersParameterComponent response = retVal.addParameter();
response.setName("response");
response.addPart().setName("eligibilityresponse").setResource(eligibilityResponse);
response.addPart().setName("requestProvider").setResource(provider);
response.addPart().setName("request").setResource(eligibilityRequest);
response.addPart().setName("insurer").setResource(insurer);
response.addPart().setName("coverage").setResource(coverage);
// add a few service resources to the parameters
Procedure procedure = new Procedure();
procedure.setId("procedure-1");
Device device = new Device();
device.setModelNumber("LMNOP678");
response.addPart().setName("service").setResource(procedure);
response.addPart().setName("service").setResource(device);
if (finalEndPoint != null) {
response.addPart().setName("endPoint").setResource(finalEndPoint);
}
logger.debug("coverageRequirementsDiscovery: end");
return retVal;
}
use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.MEDICATIONSTATEMENT in project CRD by HL7-DaVinci.
the class CrdRequestCreator method createOrderSelectRequest.
/**
* Generate a order select request that contains a DeviceRequest.
*
* @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 OrderSelectRequest createOrderSelectRequest(Enumerations.AdministrativeGender patientGender, Date patientBirthdate, String patientAddressState, String providerAddressState, Coding requestCoding, Coding statementCoding) {
OrderSelectRequest request = new OrderSelectRequest();
request.setHook(Hook.ORDER_SELECT);
request.setHookInstance(UUID.randomUUID().toString());
OrderSelectContext context = new OrderSelectContext();
request.setContext(context);
context.setUserId("Practitioner/1234");
Patient patient = createPatient(patientGender, patientBirthdate, patientAddressState);
context.setPatientId(patient.getId());
// create and build MedicationRequest
MedicationRequest mr = new MedicationRequest();
mr.setStatus(MedicationRequest.MedicationRequestStatus.DRAFT);
mr.setId("MedicationRequest/123");
mr.setIntent(MedicationRequest.MedicationRequestIntent.ORDER);
PrefetchCallback callback = (p, c) -> {
mr.setPerformer(new Reference(p));
mr.addInsurance(new Reference(c));
};
mr.setSubject(new Reference(patient));
Practitioner provider = createPractitioner();
Bundle prefetchBundle = createPrefetchBundle(patient, provider, callback, providerAddressState);
mr.setMedication(new CodeableConcept().addCoding(requestCoding));
Bundle orderBundle = new Bundle();
Bundle.BundleEntryComponent bec = new Bundle.BundleEntryComponent();
bec.setResource(mr);
orderBundle.addEntry(bec);
Bundle.BundleEntryComponent pfDrBec = new Bundle.BundleEntryComponent();
pfDrBec.setResource(mr);
prefetchBundle.addEntry(pfDrBec);
context.setDraftOrders(orderBundle);
context.setSelections(new String[] { "123" });
Bundle prefetchMedicationStatementBundle = new Bundle();
bec = new Bundle.BundleEntryComponent();
bec.setResource(patient);
prefetchMedicationStatementBundle.addEntry(bec);
bec = new Bundle.BundleEntryComponent();
MedicationStatement ms = new MedicationStatement();
ms.setId("MedciationStatement/12345");
ms.setMedication(new CodeableConcept().addCoding(statementCoding));
bec.setResource(ms);
prefetchMedicationStatementBundle.addEntry(bec);
// add the prefetch into the request
CrdPrefetch prefetch = new CrdPrefetch();
prefetch.setMedicationRequestBundle(prefetchBundle);
prefetch.setMedicationStatementBundle(prefetchMedicationStatementBundle);
request.setPrefetch(prefetch);
return request;
}
Aggregations