Search in sources :

Example 11 with PROCEDURE

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.PROCEDURE in project BridgeServer2 by Sage-Bionetworks.

the class CRCController method postProcedureRequest.

@PutMapping("/v1/cuimc/procedurerequests")
public ResponseEntity<StatusMessage> postProcedureRequest() {
    App app = httpBasicAuthentication();
    IParser parser = FHIR_CONTEXT.newJsonParser();
    JsonNode data = parseJson(JsonNode.class);
    ProcedureRequest procedure = parser.parseResource(ProcedureRequest.class, data.toString());
    String userId = findUserId(procedure.getSubject());
    int status = writeReportAndUpdateState(app, userId, data, PROCEDURE_REPORT, AccountStates.TESTS_COLLECTED, true);
    if (status == 200) {
        return ResponseEntity.ok(new StatusMessage("ProcedureRequest updated."));
    }
    return ResponseEntity.created(URI.create("/v1/cuimc/procedurerequests/" + userId)).body(new StatusMessage("ProcedureRequest created."));
}
Also used : App(org.sagebionetworks.bridge.models.apps.App) ProcedureRequest(org.hl7.fhir.dstu3.model.ProcedureRequest) JsonNode(com.fasterxml.jackson.databind.JsonNode) ContactPoint(org.hl7.fhir.dstu3.model.ContactPoint) IParser(ca.uhn.fhir.parser.IParser) StatusMessage(org.sagebionetworks.bridge.models.StatusMessage) PutMapping(org.springframework.web.bind.annotation.PutMapping)

Example 12 with PROCEDURE

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.PROCEDURE in project cqf-ruler by DBCG.

the class ActivityDefinitionApplyProvider method resolveProcedure.

private Procedure resolveProcedure(ActivityDefinition activityDefinition, String patientId) {
    Procedure procedure = new Procedure();
    // TODO - set the appropriate status
    procedure.setStatus(Procedure.ProcedureStatus.UNKNOWN);
    procedure.setSubject(new Reference(patientId));
    if (activityDefinition.hasCode()) {
        procedure.setCode(activityDefinition.getCode());
    }
    if (activityDefinition.hasBodySite()) {
        procedure.setBodySite(activityDefinition.getBodySite());
    }
    return procedure;
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) Procedure(org.hl7.fhir.dstu3.model.Procedure)

Example 13 with PROCEDURE

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.PROCEDURE 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 "ServiceRequest":
            result = resolveServiceRequest(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;
        case "Task":
            result = resolveTask(activityDefinition, patientId);
            break;
    }
    for (ActivityDefinition.ActivityDefinitionDynamicValueComponent dynamicValue : activityDefinition.getDynamicValue()) {
        // ActivityDefinition apply operation does not fail.
        try {
            if (dynamicValue.getExpression() != null) {
                // Special case for setting a Patient reference
                if ("Patient".equals(dynamicValue.getExpression().getExpression())) {
                    this.modelResolver.setValue(result, dynamicValue.getPath(), new Reference(patientId));
                } else {
                    /*
						 * 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().getExpression(), patientId, theRequest);
                    if (value != null) {
                        logger.debug("dynamicValue value: {}", value);
                        if (value instanceof Boolean) {
                            value = new BooleanType((Boolean) value);
                        } else if (value instanceof DateTime) {
                            value = Date.from(((DateTime) value).getDateTime().toInstant());
                        } else if (value instanceof String) {
                            value = new StringType((String) value);
                        }
                        this.modelResolver.setValue(result, dynamicValue.getPath(), value);
                    } else {
                        logger.warn("WARNING: ActivityDefinition has null value for path: {}", dynamicValue.getPath());
                    }
                }
            }
        } catch (Exception e) {
            logger.error("ERROR: ActivityDefinition dynamicValue {} could not be applied and threw exception {}", dynamicValue.getPath(), e.toString());
            logger.error(e.toString());
        }
    }
    return result;
}
Also used : StringType(org.hl7.fhir.r4.model.StringType) Reference(org.hl7.fhir.r4.model.Reference) Resource(org.hl7.fhir.r4.model.Resource) BooleanType(org.hl7.fhir.r4.model.BooleanType) DateTime(org.opencds.cqf.cql.engine.runtime.DateTime) InternalErrorException(ca.uhn.fhir.rest.server.exceptions.InternalErrorException) FHIRException(org.hl7.fhir.exceptions.FHIRException) ActivityDefinition(org.hl7.fhir.r4.model.ActivityDefinition)

Example 14 with PROCEDURE

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.PROCEDURE in project BridgeServer2 by Sage-Bionetworks.

the class CRCControllerTest method makeProcedureRequest.

private String makeProcedureRequest() {
    ProcedureRequest procedure = new ProcedureRequest();
    Identifier id = new Identifier();
    id.setSystem(USER_ID_VALUE_NS);
    id.setValue(TEST_USER_ID);
    Reference ref = new Reference();
    ref.setIdentifier(id);
    procedure.setSubject(ref);
    return FHIR_CONTEXT.newJsonParser().encodeResourceToString(procedure);
}
Also used : Identifier(org.hl7.fhir.dstu3.model.Identifier) Reference(org.hl7.fhir.dstu3.model.Reference) ProcedureRequest(org.hl7.fhir.dstu3.model.ProcedureRequest)

Example 15 with PROCEDURE

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.PROCEDURE in project BridgeServer2 by Sage-Bionetworks.

the class CRCControllerTest method procedureWrongIdentifier.

@Test(expectedExceptions = BadRequestException.class, expectedExceptionsMessageRegExp = "Could not find Bridge user ID.")
public void procedureWrongIdentifier() 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));
    Identifier identifier = new Identifier();
    identifier.setSystem("wrong-system");
    identifier.setValue(TEST_USER_ID);
    ProcedureRequest procedure = new ProcedureRequest();
    procedure.addIdentifier(identifier);
    String json = FHIR_CONTEXT.newJsonParser().encodeResourceToString(procedure);
    mockRequestBody(mockRequest, json);
    controller.postProcedureRequest();
}
Also used : Identifier(org.hl7.fhir.dstu3.model.Identifier) ProcedureRequest(org.hl7.fhir.dstu3.model.ProcedureRequest) Test(org.testng.annotations.Test)

Aggregations

Procedure (org.hl7.fhir.r4.model.Procedure)22 Test (org.junit.jupiter.api.Test)19 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)14 Coding (org.hl7.fhir.r4.model.Coding)14 ArrayList (java.util.ArrayList)12 Bundle (org.hl7.fhir.r4.model.Bundle)11 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)11 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)9 Reference (org.hl7.fhir.r4.model.Reference)9 ExplanationOfBenefit (org.hl7.fhir.dstu3.model.ExplanationOfBenefit)8 Turtle (org.hl7.fhir.dstu3.utils.formats.Turtle)8 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)8 CCWProcedure (gov.cms.bfd.server.war.commons.CCWProcedure)7 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)7 Coding (org.hl7.fhir.dstu3.model.Coding)7 Date (java.util.Date)6 List (java.util.List)6 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)6 Diagnosis (gov.cms.bfd.server.war.commons.Diagnosis)5 Collectors (java.util.stream.Collectors)5