Search in sources :

Example 81 with FINAL

use of org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL in project pathling by aehrc.

the class BatchProvider method batch.

@Transaction
@OperationAccess("batch")
public Bundle batch(@Nullable @TransactionParam final Bundle bundle) {
    checkUserInput(bundle != null, "Bundle must be provided");
    final Map<ResourceType, List<IBaseResource>> resourcesForUpdate = new EnumMap<>(ResourceType.class);
    final Bundle response = new Bundle();
    response.setType(BATCHRESPONSE);
    // the responses should these operations be successful.
    for (final Bundle.BundleEntryComponent entry : bundle.getEntry()) {
        processEntry(resourcesForUpdate, response, entry);
    }
    if (!resourcesForUpdate.isEmpty()) {
        // Merge in any updated resources into their respective tables.
        update(resourcesForUpdate);
    }
    return response;
}
Also used : Bundle(org.hl7.fhir.r4.model.Bundle) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) ResourceType(org.hl7.fhir.r4.model.Enumerations.ResourceType) ArrayList(java.util.ArrayList) List(java.util.List) EnumMap(java.util.EnumMap) OperationAccess(au.csiro.pathling.security.OperationAccess) Transaction(ca.uhn.fhir.rest.annotation.Transaction)

Example 82 with FINAL

use of org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL in project pathling by aehrc.

the class BatchProvider method addResponse.

private void addResponse(@Nonnull final Bundle response, @Nonnull final IBaseResource preparedResource) {
    final BundleEntryComponent responseEntry = response.addEntry();
    final BundleEntryResponseComponent responseElement = new BundleEntryResponseComponent();
    responseElement.setStatus("200");
    responseEntry.setResponse(responseElement);
    responseEntry.setResource((Resource) preparedResource);
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) BundleEntryResponseComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryResponseComponent)

Example 83 with FINAL

use of org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL in project pathling by aehrc.

the class TestData method newQuestionnaire.

/**
 * Returns a FHIR Questionnaire resource for testing purposes.
 */
public static Questionnaire newQuestionnaire() {
    final Questionnaire questionnaire = new Questionnaire();
    questionnaire.setId("Questionnaire/1");
    final QuestionnaireItemComponent item = questionnaire.addItem();
    item.addEnableWhen().setAnswer(new DecimalType(TEST_VERY_SMALL_DECIMAL_SCALE_6));
    item.addInitial().setValue(new DecimalType(TEST_VERY_BIG_DECIMAL));
    // This nested item will be discarded on import, as we currently skip recursive elements.
    final QuestionnaireItemComponent nestedItem = item.addItem();
    nestedItem.addInitial().setValue(new DecimalType(TEST_SMALL_DECIMAL));
    return questionnaire;
}
Also used : QuestionnaireItemComponent(org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent)

Example 84 with FINAL

use of org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL in project pathling by aehrc.

the class TestData method newCondition.

/**
 * Returns a FHIR Condition for testing purposes.
 */
public static Condition newCondition() {
    final Condition condition = new Condition();
    // Condition based on example from FHIR:
    // https://www.hl7.org/fhir/condition-example.json.html
    condition.setId("example");
    condition.setLanguage("en_US");
    // Narrative text
    final Narrative narrative = new Narrative();
    narrative.setStatusAsString("generated");
    narrative.setDivAsString("This data was generated for test purposes.");
    final XhtmlNode node = new XhtmlNode();
    node.setNodeType(NodeType.Text);
    node.setValue("Severe burn of left ear (Date: 24-May 2012)");
    condition.setText(narrative);
    condition.setSubject(new Reference("Patient/example").setDisplay("Here is a display for you."));
    final CodeableConcept verificationStatus = new CodeableConcept();
    verificationStatus.addCoding(new Coding(ConditionVerStatus.CONFIRMED.getSystem(), ConditionVerStatus.CONFIRMED.toCode(), ConditionVerStatus.CONFIRMED.getDisplay()));
    condition.setVerificationStatus(verificationStatus);
    // Condition code
    final CodeableConcept code = new CodeableConcept();
    code.addCoding().setSystem("http://snomed.info/sct").setCode("39065001").setDisplay("Severe");
    condition.setSeverity(code);
    // Severity code
    final CodeableConcept severity = new CodeableConcept();
    severity.addCoding().setSystem("http://snomed.info/sct").setCode("24484000").setDisplay("Burn of ear").setUserSelected(true);
    condition.setSeverity(severity);
    // Onset date time
    final DateTimeType onset = new DateTimeType();
    onset.setValueAsString("2012-05-24");
    condition.setOnset(onset);
    return condition;
}
Also used : XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 85 with FINAL

use of org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL in project pathling by aehrc.

the class TestData method newConditionWithExtensions.

public static Condition newConditionWithExtensions() {
    // Condition
    // - extension:
    // - url: uuid:ext1
    // - value: ext1
    // - extension:
    // - url: uuid:ext2
    // - value: 2
    // - extension:
    // - url: uuid:ext4
    // - extension
    // - url: uuid:nested
    // - value: nested
    // - identifier
    // - id: uuid:identifier1
    // - extension:
    // - url: uuid:ext10
    // - value: ext10
    // - extension:
    // - url: uuid:ext11
    // - value: 11
    // - stage
    // - type
    // - extension
    // - url: uuid:ext12
    // - value: ext12
    final Condition conditionWithExtension = new Condition();
    conditionWithExtension.setId("someId");
    final Extension nestedExtension = new Extension("uuid:ext4");
    nestedExtension.addExtension(new Extension("uuid:nested", new StringType("nested")));
    conditionWithExtension.setExtension(Arrays.asList(new Extension("uuid:ext1", new StringType("ext1")), new Extension("uuid:ext2", new IntegerType(2)), nestedExtension));
    conditionWithExtension.setMeta(new Meta().setVersionId("MetVersion"));
    conditionWithExtension.setOnset(new Range());
    conditionWithExtension.setSeverity(new CodeableConcept().addCoding(new Coding("sys", "code", "name")));
    final Identifier identifier = conditionWithExtension.getIdentifierFirstRep();
    identifier.setId("uuid:identifier1");
    identifier.setExtension(Arrays.asList(new Extension("uuid:ext10", new StringType("ext10")), new Extension("uuid:ext11", new IntegerType(11))));
    final ConditionStageComponent stage = conditionWithExtension.getStageFirstRep();
    stage.getType().setExtension(Collections.singletonList(new Extension("uuid:ext12", new StringType("ext12"))));
    return conditionWithExtension;
}
Also used : ConditionStageComponent(org.hl7.fhir.r4.model.Condition.ConditionStageComponent)

Aggregations

Test (org.junit.jupiter.api.Test)229 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)85 HashMap (java.util.HashMap)83 CamelSpringBootTest (org.apache.camel.test.spring.junit5.CamelSpringBootTest)59 List (java.util.List)53 Bundle (org.hl7.fhir.dstu3.model.Bundle)50 Nonnull (javax.annotation.Nonnull)48 Patient (org.hl7.fhir.dstu3.model.Patient)46 Organization (org.hl7.fhir.dstu3.model.Organization)45 ArrayList (java.util.ArrayList)44 Bundle (org.hl7.fhir.r4.model.Bundle)41 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)39 UUID (java.util.UUID)38 Collectors (java.util.stream.Collectors)38 Coding (org.hl7.fhir.r4.model.Coding)34 FhirContext (ca.uhn.fhir.context.FhirContext)33 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)32 IParser (ca.uhn.fhir.parser.IParser)31 IOException (java.io.IOException)29 IdType (org.hl7.fhir.dstu3.model.IdType)28