Search in sources :

Example 41 with MEDICATIONSTATEMENT

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");
}
Also used : RCMRMT030101UK04CompoundStatement(org.hl7.v3.RCMRMT030101UK04CompoundStatement) Reference(org.hl7.fhir.dstu3.model.Reference) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 42 with MEDICATIONSTATEMENT

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;
}
Also used : Parameters(org.hl7.fhir.r4.model.Parameters) Organization(org.hl7.fhir.r4.model.Organization) Device(org.hl7.fhir.r4.model.Device) CoverageEligibilityResponse(org.hl7.fhir.r4.model.CoverageEligibilityResponse) Patient(org.hl7.fhir.r4.model.Patient) Coverage(org.hl7.fhir.r4.model.Coverage) ResourceType(org.hl7.fhir.r4.model.ResourceType) CoverageEligibilityRequest(org.hl7.fhir.r4.model.CoverageEligibilityRequest) Practitioner(org.hl7.fhir.r4.model.Practitioner) Endpoint(org.hl7.fhir.r4.model.Endpoint) Procedure(org.hl7.fhir.r4.model.Procedure) Location(org.hl7.fhir.r4.model.Location) Operation(ca.uhn.fhir.rest.annotation.Operation)

Example 43 with MEDICATIONSTATEMENT

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;
}
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) OrderSelectRequest(org.hl7.davinci.r4.crdhook.orderselect.OrderSelectRequest) OrderSelectContext(org.hl7.davinci.r4.crdhook.orderselect.OrderSelectContext) CrdPrefetch(org.hl7.davinci.r4.crdhook.CrdPrefetch)

Aggregations

ArrayList (java.util.ArrayList)11 MedicationStatement (org.hl7.fhir.r4.model.MedicationStatement)9 Test (org.junit.jupiter.api.Test)9 Coding (org.hl7.fhir.r4.model.Coding)8 Reference (org.hl7.fhir.dstu3.model.Reference)6 IdType (org.hl7.fhir.dstu3.model.IdType)5 Date (java.util.Date)4 RCMRMT030101UK04Component2 (org.hl7.v3.RCMRMT030101UK04Component2)4 RCMRMT030101UK04EhrExtract (org.hl7.v3.RCMRMT030101UK04EhrExtract)4 DateTimeType (org.hl7.fhir.dstu3.model.DateTimeType)3 Extension (org.hl7.fhir.dstu3.model.Extension)3 Bundle (org.hl7.fhir.r4.model.Bundle)3 UnprocessableEntityException (ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException)2 FileOutputStream (java.io.FileOutputStream)2 List (java.util.List)2 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)2 MedicationRequest (org.hl7.fhir.dstu3.model.MedicationRequest)2 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)2 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)2 Condition (org.hl7.fhir.r4.model.Condition)2