Search in sources :

Example 11 with Device

use of org.hl7.fhir.dstu3.model.Device in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeSequence.

protected void composeSequence(Complex parent, String parentType, String name, Sequence element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "Sequence", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "Sequence", "identifier", element.getIdentifier().get(i), i);
    if (element.hasTypeElement())
        composeEnum(t, "Sequence", "type", element.getTypeElement(), -1);
    if (element.hasCoordinateSystemElement())
        composeInteger(t, "Sequence", "coordinateSystem", element.getCoordinateSystemElement(), -1);
    if (element.hasPatient())
        composeReference(t, "Sequence", "patient", element.getPatient(), -1);
    if (element.hasSpecimen())
        composeReference(t, "Sequence", "specimen", element.getSpecimen(), -1);
    if (element.hasDevice())
        composeReference(t, "Sequence", "device", element.getDevice(), -1);
    if (element.hasPerformer())
        composeReference(t, "Sequence", "performer", element.getPerformer(), -1);
    if (element.hasQuantity())
        composeQuantity(t, "Sequence", "quantity", element.getQuantity(), -1);
    if (element.hasReferenceSeq())
        composeSequenceSequenceReferenceSeqComponent(t, "Sequence", "referenceSeq", element.getReferenceSeq(), -1);
    for (int i = 0; i < element.getVariant().size(); i++) composeSequenceSequenceVariantComponent(t, "Sequence", "variant", element.getVariant().get(i), i);
    if (element.hasObservedSeqElement())
        composeString(t, "Sequence", "observedSeq", element.getObservedSeqElement(), -1);
    for (int i = 0; i < element.getQuality().size(); i++) composeSequenceSequenceQualityComponent(t, "Sequence", "quality", element.getQuality().get(i), i);
    if (element.hasReadCoverageElement())
        composeInteger(t, "Sequence", "readCoverage", element.getReadCoverageElement(), -1);
    for (int i = 0; i < element.getRepository().size(); i++) composeSequenceSequenceRepositoryComponent(t, "Sequence", "repository", element.getRepository().get(i), i);
    for (int i = 0; i < element.getPointer().size(); i++) composeReference(t, "Sequence", "pointer", element.getPointer().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Example 12 with Device

use of org.hl7.fhir.dstu3.model.Device in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeObservation.

protected void composeObservation(Complex parent, String parentType, String name, Observation element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "Observation", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "Observation", "identifier", element.getIdentifier().get(i), i);
    if (element.hasStatusElement())
        composeEnum(t, "Observation", "status", element.getStatusElement(), -1);
    if (element.hasCategory())
        composeCodeableConcept(t, "Observation", "category", element.getCategory(), -1);
    if (element.hasCode())
        composeCodeableConcept(t, "Observation", "code", element.getCode(), -1);
    if (element.hasSubject())
        composeReference(t, "Observation", "subject", element.getSubject(), -1);
    if (element.hasEncounter())
        composeReference(t, "Observation", "encounter", element.getEncounter(), -1);
    if (element.hasEffective())
        composeType(t, "Observation", "effective", element.getEffective(), -1);
    if (element.hasIssuedElement())
        composeInstant(t, "Observation", "issued", element.getIssuedElement(), -1);
    for (int i = 0; i < element.getPerformer().size(); i++) composeReference(t, "Observation", "performer", element.getPerformer().get(i), i);
    if (element.hasValue())
        composeType(t, "Observation", "value", element.getValue(), -1);
    if (element.hasDataAbsentReason())
        composeCodeableConcept(t, "Observation", "dataAbsentReason", element.getDataAbsentReason(), -1);
    if (element.hasInterpretation())
        composeCodeableConcept(t, "Observation", "interpretation", element.getInterpretation(), -1);
    if (element.hasCommentElement())
        composeString(t, "Observation", "comment", element.getCommentElement(), -1);
    if (element.hasBodySite())
        composeCodeableConcept(t, "Observation", "bodySite", element.getBodySite(), -1);
    if (element.hasMethod())
        composeCodeableConcept(t, "Observation", "method", element.getMethod(), -1);
    if (element.hasSpecimen())
        composeReference(t, "Observation", "specimen", element.getSpecimen(), -1);
    if (element.hasDevice())
        composeReference(t, "Observation", "device", element.getDevice(), -1);
    for (int i = 0; i < element.getReferenceRange().size(); i++) composeObservationObservationReferenceRangeComponent(t, "Observation", "referenceRange", element.getReferenceRange().get(i), i);
    for (int i = 0; i < element.getRelated().size(); i++) composeObservationObservationRelatedComponent(t, "Observation", "related", element.getRelated().get(i), i);
    for (int i = 0; i < element.getComponent().size(); i++) composeObservationObservationComponentComponent(t, "Observation", "component", element.getComponent().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 13 with Device

use of org.hl7.fhir.dstu3.model.Device in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeDeviceUseStatement.

protected void composeDeviceUseStatement(Complex parent, String parentType, String name, DeviceUseStatement element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "DeviceUseStatement", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "DeviceUseStatement", "identifier", element.getIdentifier().get(i), i);
    if (element.hasStatusElement())
        composeEnum(t, "DeviceUseStatement", "status", element.getStatusElement(), -1);
    if (element.hasSubject())
        composeReference(t, "DeviceUseStatement", "subject", element.getSubject(), -1);
    if (element.hasWhenUsed())
        composePeriod(t, "DeviceUseStatement", "whenUsed", element.getWhenUsed(), -1);
    if (element.hasTiming())
        composeType(t, "DeviceUseStatement", "timing", element.getTiming(), -1);
    if (element.hasRecordedOnElement())
        composeDateTime(t, "DeviceUseStatement", "recordedOn", element.getRecordedOnElement(), -1);
    if (element.hasSource())
        composeReference(t, "DeviceUseStatement", "source", element.getSource(), -1);
    if (element.hasDevice())
        composeReference(t, "DeviceUseStatement", "device", element.getDevice(), -1);
    for (int i = 0; i < element.getIndication().size(); i++) composeCodeableConcept(t, "DeviceUseStatement", "indication", element.getIndication().get(i), i);
    if (element.hasBodySite())
        composeCodeableConcept(t, "DeviceUseStatement", "bodySite", element.getBodySite(), -1);
    for (int i = 0; i < element.getNote().size(); i++) composeAnnotation(t, "DeviceUseStatement", "note", element.getNote().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Example 14 with Device

use of org.hl7.fhir.dstu3.model.Device in project org.hl7.fhir.core by hapifhir.

the class Device30_40Test method test1.

@Test
@DisplayName("Test r4 -> dstu3 device conversion.")
public void test1() throws IOException {
    InputStream r4_input = this.getClass().getResourceAsStream("/0_device_40.json");
    InputStream dstu3_expected_output = this.getClass().getResourceAsStream("/0_device_30.json");
    org.hl7.fhir.r4.model.Device r4_actual = (org.hl7.fhir.r4.model.Device) new org.hl7.fhir.r4.formats.JsonParser().parse(r4_input);
    org.hl7.fhir.dstu3.model.Resource dstu3_conv = VersionConvertorFactory_30_40.convertResource(r4_actual, new BaseAdvisor_30_40(false));
    org.hl7.fhir.dstu3.formats.JsonParser dstu3_parser = new org.hl7.fhir.dstu3.formats.JsonParser();
    org.hl7.fhir.dstu3.model.Resource dstu3_expected = dstu3_parser.parse(dstu3_expected_output);
    Assertions.assertTrue(dstu3_expected.equalsDeep(dstu3_conv), "Failed comparing\n" + dstu3_parser.composeString(dstu3_expected) + "\nand\n" + dstu3_parser.composeString(dstu3_conv));
}
Also used : InputStream(java.io.InputStream) BaseAdvisor_30_40(org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 15 with Device

use of org.hl7.fhir.dstu3.model.Device in project org.hl7.fhir.core by hapifhir.

the class Device30_40Test method test2.

@Test
@DisplayName("Test r4 -> dstu3 device conversion, part 2.")
public void test2() throws IOException {
    InputStream r4_input = this.getClass().getResourceAsStream("/1_device_40.json");
    InputStream dstu3_expected_output = this.getClass().getResourceAsStream("/1_device_30.json");
    org.hl7.fhir.r4.model.Device r4_actual = (org.hl7.fhir.r4.model.Device) new org.hl7.fhir.r4.formats.JsonParser().parse(r4_input);
    org.hl7.fhir.dstu3.model.Resource dstu3_conv = VersionConvertorFactory_30_40.convertResource(r4_actual, new BaseAdvisor_30_40(false));
    org.hl7.fhir.dstu3.formats.JsonParser dstu3_parser = new org.hl7.fhir.dstu3.formats.JsonParser();
    org.hl7.fhir.dstu3.model.Resource dstu3_expected = dstu3_parser.parse(dstu3_expected_output);
    Assertions.assertTrue(dstu3_expected.equalsDeep(dstu3_conv), "Failed comparing\n" + dstu3_parser.composeString(dstu3_expected) + "\nand\n" + dstu3_parser.composeString(dstu3_expected));
}
Also used : InputStream(java.io.InputStream) BaseAdvisor_30_40(org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_30_40) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

Device (com.google.api.services.cloudiot.v1.model.Device)21 HttpRequestInitializer (com.google.api.client.http.HttpRequestInitializer)13 JsonFactory (com.google.api.client.json.JsonFactory)13 CloudIot (com.google.api.services.cloudiot.v1.CloudIot)13 HttpCredentialsAdapter (com.google.auth.http.HttpCredentialsAdapter)13 GoogleCredentials (com.google.auth.oauth2.GoogleCredentials)13 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)13 Test (org.junit.jupiter.api.Test)9 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)7 Device (org.hl7.fhir.r4.model.Device)7 Practitioner (org.hl7.fhir.r4.model.Practitioner)7 Reference (org.hl7.fhir.r4.model.Reference)7 ArrayList (java.util.ArrayList)6 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)6 Turtle (org.hl7.fhir.dstu3.utils.formats.Turtle)6 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)6 DeviceCredential (com.google.api.services.cloudiot.v1.model.DeviceCredential)5 PublicKeyCredential (com.google.api.services.cloudiot.v1.model.PublicKeyCredential)5 Coding (org.hl7.fhir.r4.model.Coding)5 Identifier (org.hl7.fhir.r4.model.Identifier)5