Search in sources :

Example 21 with ProcedureRequest

use of org.hl7.fhir.dstu3.model.ProcedureRequest in project nia-patient-switching-standard-adaptor by NHSDigital.

the class ProcedureRequestMapperTest method mapProcedureRequestWithNoReferencedEncounter.

@Test
public void mapProcedureRequestWithNoReferencedEncounter() {
    var ehrExtract = unmarshallCodeElement("no_referenced_encounter_example.xml");
    var planStatement = getPlanStatement(ehrExtract);
    ProcedureRequest procedureRequest = procedureRequestMapper.mapToProcedureRequest(ehrExtract, getEhrComposition(ehrExtract), planStatement, SUBJECT, ENCOUNTERS, PRACTISE_CODE);
    assertThat(procedureRequest.getContext().getResource()).isNull();
}
Also used : ProcedureRequest(org.hl7.fhir.dstu3.model.ProcedureRequest) Test(org.junit.jupiter.api.Test)

Example 22 with ProcedureRequest

use of org.hl7.fhir.dstu3.model.ProcedureRequest in project nia-patient-switching-standard-adaptor by NHSDigital.

the class ProcedureRequestMapperTest method mapProcedureRequestWithPrfParticipant.

@Test
public void mapProcedureRequestWithPrfParticipant() {
    var ehrExtract = unmarshallCodeElement("prf_participant_example.xml");
    var planStatement = getPlanStatement(ehrExtract);
    setUpCodeableConceptMock();
    ProcedureRequest procedureRequest = procedureRequestMapper.mapToProcedureRequest(ehrExtract, getEhrComposition(ehrExtract), planStatement, SUBJECT, ENCOUNTERS, PRACTISE_CODE);
    assertFixedValues(planStatement, procedureRequest);
    assertThat(procedureRequest.getReasonCodeFirstRep().getCodingFirstRep().getDisplay()).isEqualTo(planStatement.getCode().getDisplayName());
    assertThat(procedureRequest.getRequester().getAgent().getReference()).isEqualTo("Practitioner/9C1610C2-5E48-4ED5-882B-5A4A172AFA35");
    assertThat(procedureRequest.getContext().getResource().getIdElement().getValue()).isEqualTo(ENCOUNTER_ID);
}
Also used : ProcedureRequest(org.hl7.fhir.dstu3.model.ProcedureRequest) Test(org.junit.jupiter.api.Test)

Example 23 with ProcedureRequest

use of org.hl7.fhir.dstu3.model.ProcedureRequest in project cqf-ruler by DBCG.

the class ActivityDefinitionApplyProvider method resolveProcedureRequest.

private ProcedureRequest resolveProcedureRequest(ActivityDefinition activityDefinition, String patientId, String practitionerId, String organizationId) throws ActivityDefinitionApplyException {
    // status, intent, code, and subject are required
    ProcedureRequest procedureRequest = new ProcedureRequest();
    procedureRequest.setStatus(ProcedureRequest.ProcedureRequestStatus.DRAFT);
    procedureRequest.setIntent(ProcedureRequest.ProcedureRequestIntent.PROPOSAL);
    String patientReferenceString = patientId;
    URI patientIdAsUri = URI.create(patientReferenceString);
    if (!patientIdAsUri.isAbsolute() && patientIdAsUri.getFragment() == null && !patientReferenceString.startsWith("Patient/")) {
        patientReferenceString = "Patient/" + patientId;
    }
    procedureRequest.setSubject(new Reference(patientReferenceString));
    if (practitionerId != null) {
        procedureRequest.setRequester(new ProcedureRequest.ProcedureRequestRequesterComponent().setAgent(new Reference(practitionerId)));
    } else if (organizationId != null) {
        procedureRequest.setRequester(new ProcedureRequest.ProcedureRequestRequesterComponent().setAgent(new Reference(organizationId)));
    }
    if (activityDefinition.hasExtension()) {
        procedureRequest.setExtension(activityDefinition.getExtension());
    }
    if (activityDefinition.hasCode()) {
        procedureRequest.setCode(activityDefinition.getCode());
    } else // code can be set as a dynamicValue
    if (!activityDefinition.hasCode() && !activityDefinition.hasDynamicValue()) {
        throw new ActivityDefinitionApplyException("Missing required code property");
    }
    if (activityDefinition.hasBodySite()) {
        procedureRequest.setBodySite(activityDefinition.getBodySite());
    }
    if (activityDefinition.hasProduct()) {
        throw new ActivityDefinitionApplyException("Product does not map to " + activityDefinition.getKind());
    }
    if (activityDefinition.hasDosage()) {
        throw new ActivityDefinitionApplyException("Dosage does not map to " + activityDefinition.getKind());
    }
    return procedureRequest;
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) ProcedureRequest(org.hl7.fhir.dstu3.model.ProcedureRequest) URI(java.net.URI)

Example 24 with ProcedureRequest

use of org.hl7.fhir.dstu3.model.ProcedureRequest in project cqf-ruler by DBCG.

the class ActivityDefinitionApplyProvider method resolveActivityDefinition.

// For library use
public Resource resolveActivityDefinition(ActivityDefinition activityDefinition, String patientId, String practitionerId, String organizationId, RequestDetails theRequest) throws FHIRException {
    Resource result = newResource(activityDefinition.getKind().toCode());
    switch(result.fhirType()) {
        case "ProcedureRequest":
            result = resolveProcedureRequest(activityDefinition, patientId, practitionerId, organizationId);
            break;
        case "MedicationRequest":
            result = resolveMedicationRequest(activityDefinition, patientId);
            break;
        case "SupplyRequest":
            result = resolveSupplyRequest(activityDefinition, practitionerId, organizationId);
            break;
        case "Procedure":
            result = resolveProcedure(activityDefinition, patientId);
            break;
        case "DiagnosticReport":
            result = resolveDiagnosticReport(activityDefinition, patientId);
            break;
        case "Communication":
            result = resolveCommunication(activityDefinition, patientId);
            break;
        case "CommunicationRequest":
            result = resolveCommunicationRequest(activityDefinition, patientId);
            break;
    }
    for (ActivityDefinition.ActivityDefinitionDynamicValueComponent dynamicValue : activityDefinition.getDynamicValue()) {
        if (dynamicValue.getExpression() != null) {
            Boolean aliasedExpression = null;
            if (dynamicValue.hasLanguage()) {
                String language = dynamicValue.getLanguage();
                if (language.equals("text/cql.identifier") || language.equals("text/cql-identifier") || language.equals("text/cql.name") || language.equals("text/cql-name")) {
                    aliasedExpression = true;
                } else {
                    aliasedExpression = false;
                }
            } else {
                aliasedExpression = false;
            }
            /*
				 * TODO: Passing the activityDefinition as context here because that's what will
				 * have the libraries, but perhaps the "context" here should be the result
				 * resource?
				 */
            Object value = expressionEvaluation.evaluateInContext(activityDefinition, dynamicValue.getExpression(), aliasedExpression, patientId, theRequest);
            // TODO need to verify type... yay
            if (value instanceof Boolean) {
                value = new BooleanType((Boolean) value);
            }
            this.modelResolver.setValue(result, dynamicValue.getPath(), value);
        }
    }
    return result;
}
Also used : Resource(org.hl7.fhir.dstu3.model.Resource) BooleanType(org.hl7.fhir.dstu3.model.BooleanType) ActivityDefinition(org.hl7.fhir.dstu3.model.ActivityDefinition)

Example 25 with ProcedureRequest

use of org.hl7.fhir.dstu3.model.ProcedureRequest in project BridgeServer2 by Sage-Bionetworks.

the class CRCControllerTest method procedureMissingIdentifiers.

@Test(expectedExceptions = BadRequestException.class, expectedExceptionsMessageRegExp = "Could not find Bridge user ID.")
public void procedureMissingIdentifiers() throws Exception {
    when(mockRequest.getHeader(AUTHORIZATION)).thenReturn(AUTHORIZATION_HEADER_VALUE);
    when(mockAccountService.authenticate(any(), any())).thenReturn(account);
    when(mockAccountService.getAccount(ACCOUNT_ID)).thenReturn(Optional.of(account));
    ProcedureRequest procedure = new ProcedureRequest();
    String json = FHIR_CONTEXT.newJsonParser().encodeResourceToString(procedure);
    mockRequestBody(mockRequest, json);
    controller.postProcedureRequest();
}
Also used : ProcedureRequest(org.hl7.fhir.dstu3.model.ProcedureRequest) Test(org.testng.annotations.Test)

Aggregations

ProcedureRequest (org.hl7.fhir.dstu3.model.ProcedureRequest)23 Test (org.junit.jupiter.api.Test)12 Test (org.junit.Test)10 ServiceRequest (org.hl7.fhir.r4.model.ServiceRequest)6 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)6 IdType (org.hl7.fhir.dstu3.model.IdType)5 Reference (org.hl7.fhir.dstu3.model.Reference)5 Bundle (org.hl7.fhir.dstu3.model.Bundle)4 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)3 Identifier (org.hl7.fhir.dstu3.model.Identifier)2 Resource (org.hl7.fhir.dstu3.model.Resource)2 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)2 Test (org.testng.annotations.Test)2 SystemRequestDetails (ca.uhn.fhir.jpa.partition.SystemRequestDetails)1 IParser (ca.uhn.fhir.parser.IParser)1 Create (ca.uhn.fhir.rest.annotation.Create)1 InternalErrorException (ca.uhn.fhir.rest.server.exceptions.InternalErrorException)1 IProcedureRequest (ch.elexis.core.findings.IProcedureRequest)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 URI (java.net.URI)1