use of org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED in project fhir-bridge by ehrbase.
the class ProvideResourceAuditHandler method process.
@Override
public void process(Exchange exchange) throws Exception {
RequestDetails requestDetails = getRequestDetails(exchange);
AuditEvent auditEvent = new AuditEvent(new Coding("http://terminology.hl7.org/CodeSystem/audit-event-type", "rest", "RESTful Operation"), new InstantType(new Date()), getSource());
getSubtype(requestDetails).ifPresent(auditEvent::addSubtype);
getAction(requestDetails).ifPresent(auditEvent::setAction);
Throwable ex = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Throwable.class);
if (ex == null) {
auditEvent.setOutcome(AuditEvent.AuditEventOutcome._0);
auditEvent.setOutcomeDesc("Operation completed successfully");
} else {
auditEvent.setOutcome(AuditEvent.AuditEventOutcome._8);
auditEvent.setOutcomeDesc("Operation failed: " + ex.getMessage());
}
auditEvent.addAgent(getAgent(exchange));
getEntity(exchange, requestDetails).ifPresent(auditEvent::addEntity);
MethodOutcome outcome = auditEventDao.create(auditEvent, requestDetails);
LOG.debug("Created AuditEvent: id={}", outcome.getId());
}
use of org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED in project odm2fhir by num-codex.
the class ImmunizationStatus method createImmunization.
@SuppressWarnings("fallthrough")
private Immunization createImmunization(ItemData immunizationCoding, ItemData dateCoding, ItemData textValue) {
var immunization = (Immunization) new Immunization().addIdentifier(createIdentifier(IMMUNIZATION, immunizationCoding)).setOccurrence(createDateTimeType(dateCoding)).setMeta(createMeta(NUMStructureDefinition.IMMUNIZATION));
var vaccineCodeableCoding = new CodeableConcept();
var diseaseCodeableCoding = new CodeableConcept();
for (var coding : createCodings(immunizationCoding)) {
switch(coding.getCode()) {
case // YES
"410605003":
immunization.setStatus(COMPLETED);
break;
case // NO
"410594000":
immunization.setStatus(NOTDONE);
break;
case // Answer = Sonstige/Other
"385432009":
diseaseCodeableCoding.addCoding(coding.setDisplay("Not applicable (qualifier value)"));
if (!textValue.isEmpty()) {
diseaseCodeableCoding.setText(textValue.getValue());
}
break;
case // UNKNOWN
"261665006":
// do not create FHIR-resources
return new Immunization();
// Influenza
case "836377006":
// Pneumokokken
case "836398006":
// BCG
case "836402002":
case // Covid19
"1119349007":
vaccineCodeableCoding.addCoding(coding);
break;
// cases for targetDisease
case // Andere
"64572001":
if (!textValue.isEmpty()) {
diseaseCodeableCoding.setText(textValue.getValue());
}
// Influenza
case "6142004":
// Pneumokokken
case "16814004":
// BCG
case "56717001":
case // Covid19
"840539006":
diseaseCodeableCoding.addCoding(coding);
break;
}
}
if (vaccineCodeableCoding.isEmpty()) {
// add No-Known-Immunuzations if no vaccineCode given
vaccineCodeableCoding.addCoding(createCoding(NO_IMMUNIZATION_INFO_UV_IPS, "no-known-immunizations", "vaccineCode unknown"));
}
if (diseaseCodeableCoding.isEmpty()) {
// add targetDisease unknown if none present
diseaseCodeableCoding.addCoding(createCoding(SNOMED_CT, "64572001", "Disease (disorder)"));
}
immunization.setVaccineCode(vaccineCodeableCoding).addProtocolApplied(new ImmunizationProtocolAppliedComponent().setDoseNumber((StringType) new StringType().addExtension(DATA_ABSENT_FOR_UNKNOWN_REASON)).addTargetDisease(diseaseCodeableCoding));
return immunization;
}
use of org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED in project pathling by aehrc.
the class DockerImageTest method importDataAndQuery.
@Test
void importDataAndQuery() throws JSONException {
try {
// Get the token endpoint from the CapabilityStatement.
final CapabilityStatement capabilities = getCapabilityStatement();
final String tokenUrl = capabilities.getRest().stream().findFirst().map(rest -> ((UriType) rest.getSecurity().getExtensionByUrl("http://fhir-registry.smarthealthit.org/StructureDefinition/oauth-uris").getExtensionByUrl("token").getValue()).asStringValue()).orElseThrow();
// Get an access token from the token endpoint.
final HttpPost clientCredentialsGrant = new HttpPost(tokenUrl);
final List<? extends NameValuePair> nameValuePairs = Arrays.asList(new BasicNameValuePair("grant_type", "client_credentials"), new BasicNameValuePair("client_id", CLIENT_ID), new BasicNameValuePair("client_secret", CLIENT_SECRET), new BasicNameValuePair("scope", REQUESTED_SCOPE));
clientCredentialsGrant.setEntity(new UrlEncodedFormEntity(nameValuePairs));
log.info("Requesting client credentials grant");
final String accessToken;
try (final CloseableHttpResponse response = (CloseableHttpResponse) httpClient.execute(clientCredentialsGrant)) {
assertThat(response.getStatusLine().getStatusCode()).withFailMessage("Client credentials grant did not succeed").isEqualTo(200);
final InputStream clientCredentialsStream = response.getEntity().getContent();
final Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();
final ClientCredentialsResponse ccResponse = gson.fromJson(new InputStreamReader(clientCredentialsStream), ClientCredentialsResponse.class);
accessToken = ccResponse.getAccessToken();
}
// Create a request to the $import operation, referencing the NDJSON files we have loaded into
// the staging area.
final InputStream requestStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("import/SystemTest/request.Parameters.json");
assertThat(requestStream).isNotNull();
final HttpPost importRequest = new HttpPost("http://localhost:8091/fhir/$import");
importRequest.setEntity(new InputStreamEntity(requestStream));
importRequest.addHeader("Content-Type", "application/json");
importRequest.addHeader("Accept", "application/fhir+json");
importRequest.addHeader("Authorization", "Bearer " + accessToken);
log.info("Sending import request");
final OperationOutcome importOutcome;
try (final CloseableHttpResponse response = (CloseableHttpResponse) httpClient.execute(importRequest)) {
final InputStream importResponseStream = response.getEntity().getContent();
importOutcome = (OperationOutcome) jsonParser.parseResource(importResponseStream);
assertThat(response.getStatusLine().getStatusCode()).withFailMessage(importOutcome.getIssueFirstRep().getDiagnostics()).isEqualTo(200);
}
assertThat(importOutcome.getIssueFirstRep().getDiagnostics()).isEqualTo("Data import completed successfully");
log.info("Import completed successfully");
final Parameters inParams = new Parameters();
// Set subject resource parameter.
final ParametersParameterComponent subjectResourceParam = new ParametersParameterComponent();
subjectResourceParam.setName("subjectResource");
subjectResourceParam.setValue(new CodeType("Patient"));
// Add aggregation, number of patients.
final ParametersParameterComponent aggregationParam = new ParametersParameterComponent();
aggregationParam.setName("aggregation");
aggregationParam.setValue(new StringType("count()"));
// Add grouping, has the patient been diagnosed with a chronic disease?
final ParametersParameterComponent groupingParam = new ParametersParameterComponent();
groupingParam.setName("grouping");
groupingParam.setValue(new StringType("reverseResolve(Condition.subject)" + ".code" + ".memberOf('http://snomed.info/sct?fhir_vs=ecl/" + "^ 32570581000036105 : " + "<< 263502005 = << 90734009')"));
// Add filter, females only.
final ParametersParameterComponent filterParam = new ParametersParameterComponent();
filterParam.setName("filter");
filterParam.setValue(new StringType("gender = 'female'"));
inParams.getParameter().add(subjectResourceParam);
inParams.getParameter().add(aggregationParam);
inParams.getParameter().add(groupingParam);
inParams.getParameter().add(filterParam);
// Send a request to the `$aggregate` operation on the FHIR server.
final String requestString = jsonParser.encodeResourceToString(inParams);
final HttpPost queryRequest = new HttpPost("http://localhost:8091/fhir/Patient/$aggregate");
queryRequest.setEntity(new StringEntity(requestString));
queryRequest.addHeader("Content-Type", "application/fhir+json");
queryRequest.addHeader("Accept", "application/fhir+json");
queryRequest.addHeader("Authorization", "Bearer " + accessToken);
log.info("Sending query request");
try (final CloseableHttpResponse response = (CloseableHttpResponse) httpClient.execute(queryRequest)) {
final int statusCode = response.getStatusLine().getStatusCode();
final InputStream queryResponseStream = response.getEntity().getContent();
if (statusCode == 200) {
final StringWriter writer = new StringWriter();
IOUtils.copy(queryResponseStream, writer, StandardCharsets.UTF_8);
assertJson("responses/DockerImageTest/importDataAndQuery.Parameters.json", writer.toString());
} else {
captureLogs();
final OperationOutcome opOutcome = (OperationOutcome) jsonParser.parseResource(queryResponseStream);
assertEquals(200, statusCode, opOutcome.getIssueFirstRep().getDiagnostics());
}
}
} catch (final Exception e) {
captureLogs();
} finally {
stopContainer(dockerClient, fhirServerContainerId);
fhirServerContainerId = null;
getRuntime().removeShutdownHook(shutdownHook);
}
}
use of org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED in project org.hl7.fhir.core by hapifhir.
the class MedicationDispense10_50 method convertMedicationDispenseStatus.
public static org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes> convertMedicationDispenseStatus(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.MedicationDispense.MedicationDispenseStatus> src) throws FHIRException {
if (src == null)
return null;
org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new MedicationDispenseStatusCodesEnumFactory());
ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt);
switch(src.getValue()) {
case COMPLETED:
tgt.setValue(org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes.COMPLETED);
break;
case ENTEREDINERROR:
tgt.setValue(org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes.ENTEREDINERROR);
break;
case INPROGRESS:
tgt.setValue(org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes.INPROGRESS);
break;
case NULL:
tgt.setValue(org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes.NULL);
break;
case ONHOLD:
tgt.setValue(org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes.ONHOLD);
break;
case STOPPED:
tgt.setValue(org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes.STOPPED);
break;
}
return tgt;
}
use of org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED in project org.hl7.fhir.core by hapifhir.
the class MedicationDispense40_50 method convertMedicationStatus.
private static org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes> convertMedicationStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.MedicationDispense.MedicationDispenseStatus> src) {
if (src == null)
return null;
org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new MedicationDispenseStatusCodesEnumFactory());
ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
switch(src.getValue()) {
case CANCELLED:
tgt.setValue(org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes.CANCELLED);
break;
case COMPLETED:
tgt.setValue(org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes.COMPLETED);
break;
case DECLINED:
tgt.setValue(org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes.DECLINED);
break;
case ENTEREDINERROR:
tgt.setValue(org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes.ENTEREDINERROR);
break;
case INPROGRESS:
tgt.setValue(org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes.INPROGRESS);
break;
case NULL:
tgt.setValue(org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes.NULL);
break;
case ONHOLD:
tgt.setValue(org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes.ONHOLD);
break;
case PREPARATION:
tgt.setValue(org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes.PREPARATION);
break;
case STOPPED:
tgt.setValue(org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes.STOPPED);
break;
case UNKNOWN:
tgt.setValue(org.hl7.fhir.r5.model.MedicationDispense.MedicationDispenseStatusCodes.UNKNOWN);
break;
}
return tgt;
}
Aggregations