use of org.hl7.fhir.r4.model.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."));
}
use of org.hl7.fhir.r4.model.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;
}
use of org.hl7.fhir.r4.model.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;
}
use of org.hl7.fhir.r4.model.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);
}
use of org.hl7.fhir.r4.model.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();
}
Aggregations