Search in sources :

Example 66 with Device

use of org.hl7.fhir.dstu3.model.Device in project udmi by faucetsdn.

the class ProxyTarget method newMqttPublisher.

private MessagePublisher newMqttPublisher(String deviceId) {
    initializedTimes.put(deviceId, LocalDateTime.now());
    Device device = cloudIotManager.fetchDevice(deviceId);
    Map<String, String> metadata = device.getMetadata();
    if (metadata == null || !metadata.containsKey("key_algorithm")) {
        info("Missing metadata.key_algorithm for " + deviceId);
        return null;
    }
    info("Publishers create " + deviceId);
    String keyAlgorithm = metadata.get("key_algorithm");
    String key_bytes = metadata.get("key_bytes");
    byte[] keyBytes = Base64.getDecoder().decode(key_bytes);
    return new MqttPublisher(proxyConfig.dstProjectId, proxyConfig.dstCloudRegion, proxyConfig.dstRegistryId, deviceId, keyBytes, keyAlgorithm, this::messageHandler, this::errorHandler);
}
Also used : Device(com.google.api.services.cloudiot.v1.model.Device)

Example 67 with Device

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

the class RdfParser method composeDeviceUseRequest.

protected void composeDeviceUseRequest(Complex parent, String parentType, String name, DeviceUseRequest element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "DeviceUseRequest", name, element, index);
    if (element.hasBodySite())
        composeType(t, "DeviceUseRequest", "bodySite", element.getBodySite(), -1);
    if (element.hasStatusElement())
        composeEnum(t, "DeviceUseRequest", "status", element.getStatusElement(), -1);
    if (element.hasDevice())
        composeReference(t, "DeviceUseRequest", "device", element.getDevice(), -1);
    if (element.hasEncounter())
        composeReference(t, "DeviceUseRequest", "encounter", element.getEncounter(), -1);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "DeviceUseRequest", "identifier", element.getIdentifier().get(i), i);
    for (int i = 0; i < element.getIndication().size(); i++) composeCodeableConcept(t, "DeviceUseRequest", "indication", element.getIndication().get(i), i);
    for (int i = 0; i < element.getNotes().size(); i++) composeString(t, "DeviceUseRequest", "notes", element.getNotes().get(i), i);
    for (int i = 0; i < element.getPrnReason().size(); i++) composeCodeableConcept(t, "DeviceUseRequest", "prnReason", element.getPrnReason().get(i), i);
    if (element.hasOrderedOnElement())
        composeDateTime(t, "DeviceUseRequest", "orderedOn", element.getOrderedOnElement(), -1);
    if (element.hasRecordedOnElement())
        composeDateTime(t, "DeviceUseRequest", "recordedOn", element.getRecordedOnElement(), -1);
    if (element.hasSubject())
        composeReference(t, "DeviceUseRequest", "subject", element.getSubject(), -1);
    if (element.hasTiming())
        composeType(t, "DeviceUseRequest", "timing", element.getTiming(), -1);
    if (element.hasPriorityElement())
        composeEnum(t, "DeviceUseRequest", "priority", element.getPriorityElement(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 68 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);
    if (element.hasTypeElement())
        composeEnum(t, "Sequence", "type", element.getTypeElement(), -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.hasQuantity())
        composeQuantity(t, "Sequence", "quantity", element.getQuantity(), -1);
    if (element.hasSpecies())
        composeCodeableConcept(t, "Sequence", "species", element.getSpecies(), -1);
    for (int i = 0; i < element.getReferenceSeq().size(); i++) composeSequenceSequenceReferenceSeqComponent(t, "Sequence", "referenceSeq", element.getReferenceSeq().get(i), i);
    if (element.hasVariation())
        composeSequenceSequenceVariationComponent(t, "Sequence", "variation", element.getVariation(), -1);
    for (int i = 0; i < element.getQuality().size(); i++) composeSequenceSequenceQualityComponent(t, "Sequence", "quality", element.getQuality().get(i), i);
    if (element.hasAllelicState())
        composeCodeableConcept(t, "Sequence", "allelicState", element.getAllelicState(), -1);
    if (element.hasAllelicFrequencyElement())
        composeDecimal(t, "Sequence", "allelicFrequency", element.getAllelicFrequencyElement(), -1);
    if (element.hasCopyNumberEvent())
        composeCodeableConcept(t, "Sequence", "copyNumberEvent", element.getCopyNumberEvent(), -1);
    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);
    if (element.hasObservedSeqElement())
        composeString(t, "Sequence", "observedSeq", element.getObservedSeqElement(), -1);
    if (element.hasObservation())
        composeReference(t, "Sequence", "observation", element.getObservation(), -1);
    if (element.hasStructureVariation())
        composeSequenceSequenceStructureVariationComponent(t, "Sequence", "structureVariation", element.getStructureVariation(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 69 with Device

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

the class RdfParser method composeMedicationAdministration.

protected void composeMedicationAdministration(Complex parent, String parentType, String name, MedicationAdministration element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "MedicationAdministration", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "MedicationAdministration", "identifier", element.getIdentifier().get(i), i);
    for (int i = 0; i < element.getDefinition().size(); i++) composeReference(t, "MedicationAdministration", "definition", element.getDefinition().get(i), i);
    for (int i = 0; i < element.getPartOf().size(); i++) composeReference(t, "MedicationAdministration", "partOf", element.getPartOf().get(i), i);
    if (element.hasStatusElement())
        composeEnum(t, "MedicationAdministration", "status", element.getStatusElement(), -1);
    if (element.hasCategory())
        composeCodeableConcept(t, "MedicationAdministration", "category", element.getCategory(), -1);
    if (element.hasMedication())
        composeType(t, "MedicationAdministration", "medication", element.getMedication(), -1);
    if (element.hasSubject())
        composeReference(t, "MedicationAdministration", "subject", element.getSubject(), -1);
    if (element.hasContext())
        composeReference(t, "MedicationAdministration", "context", element.getContext(), -1);
    for (int i = 0; i < element.getSupportingInformation().size(); i++) composeReference(t, "MedicationAdministration", "supportingInformation", element.getSupportingInformation().get(i), i);
    if (element.hasEffective())
        composeType(t, "MedicationAdministration", "effective", element.getEffective(), -1);
    for (int i = 0; i < element.getPerformer().size(); i++) composeMedicationAdministrationMedicationAdministrationPerformerComponent(t, "MedicationAdministration", "performer", element.getPerformer().get(i), i);
    if (element.hasNotGivenElement())
        composeBoolean(t, "MedicationAdministration", "notGiven", element.getNotGivenElement(), -1);
    for (int i = 0; i < element.getReasonNotGiven().size(); i++) composeCodeableConcept(t, "MedicationAdministration", "reasonNotGiven", element.getReasonNotGiven().get(i), i);
    for (int i = 0; i < element.getReasonCode().size(); i++) composeCodeableConcept(t, "MedicationAdministration", "reasonCode", element.getReasonCode().get(i), i);
    for (int i = 0; i < element.getReasonReference().size(); i++) composeReference(t, "MedicationAdministration", "reasonReference", element.getReasonReference().get(i), i);
    if (element.hasPrescription())
        composeReference(t, "MedicationAdministration", "prescription", element.getPrescription(), -1);
    for (int i = 0; i < element.getDevice().size(); i++) composeReference(t, "MedicationAdministration", "device", element.getDevice().get(i), i);
    for (int i = 0; i < element.getNote().size(); i++) composeAnnotation(t, "MedicationAdministration", "note", element.getNote().get(i), i);
    if (element.hasDosage())
        composeMedicationAdministrationMedicationAdministrationDosageComponent(t, "MedicationAdministration", "dosage", element.getDosage(), -1);
    for (int i = 0; i < element.getEventHistory().size(); i++) composeReference(t, "MedicationAdministration", "eventHistory", element.getEventHistory().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Example 70 with Device

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

the class RdfParser method composeDevice.

protected void composeDevice(Complex parent, String parentType, String name, Device element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "Device", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "Device", "identifier", element.getIdentifier().get(i), i);
    if (element.hasUdi())
        composeDeviceDeviceUdiComponent(t, "Device", "udi", element.getUdi(), -1);
    if (element.hasStatusElement())
        composeEnum(t, "Device", "status", element.getStatusElement(), -1);
    if (element.hasType())
        composeCodeableConcept(t, "Device", "type", element.getType(), -1);
    if (element.hasLotNumberElement())
        composeString(t, "Device", "lotNumber", element.getLotNumberElement(), -1);
    if (element.hasManufacturerElement())
        composeString(t, "Device", "manufacturer", element.getManufacturerElement(), -1);
    if (element.hasManufactureDateElement())
        composeDateTime(t, "Device", "manufactureDate", element.getManufactureDateElement(), -1);
    if (element.hasExpirationDateElement())
        composeDateTime(t, "Device", "expirationDate", element.getExpirationDateElement(), -1);
    if (element.hasModelElement())
        composeString(t, "Device", "model", element.getModelElement(), -1);
    if (element.hasVersionElement())
        composeString(t, "Device", "version", element.getVersionElement(), -1);
    if (element.hasPatient())
        composeReference(t, "Device", "patient", element.getPatient(), -1);
    if (element.hasOwner())
        composeReference(t, "Device", "owner", element.getOwner(), -1);
    for (int i = 0; i < element.getContact().size(); i++) composeContactPoint(t, "Device", "contact", element.getContact().get(i), i);
    if (element.hasLocation())
        composeReference(t, "Device", "location", element.getLocation(), -1);
    if (element.hasUrlElement())
        composeUri(t, "Device", "url", element.getUrlElement(), -1);
    for (int i = 0; i < element.getNote().size(); i++) composeAnnotation(t, "Device", "note", element.getNote().get(i), i);
    for (int i = 0; i < element.getSafety().size(); i++) composeCodeableConcept(t, "Device", "safety", element.getSafety().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

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