use of org.hl7.fhir.r4.model.Device in project udmi by faucetsdn.
the class ProxyTarget method parseUdmiMetadta.
private Metadata parseUdmiMetadta(String deviceId) {
try {
Device device = cloudIotManager.fetchDevice(deviceId);
Map<String, String> metadata = device.getMetadata();
if (metadata == null) {
return new Metadata();
}
String udmi_metadata = metadata.get(UDMI_METADATA);
if (udmi_metadata == null) {
return new Metadata();
}
return OBJECT_MAPPER.readValue(udmi_metadata, Metadata.class);
} catch (Exception e) {
throw new RuntimeException("While loading device udmi metadata for " + deviceId, e);
}
}
use of org.hl7.fhir.r4.model.Device in project udmi by faucetsdn.
the class CloudIotManager method fetchDeviceList.
public Set<String> fetchDeviceList() {
Preconditions.checkNotNull(cloudIotService, "CloudIoT service not initialized");
Set<Device> allDevices = new HashSet<>();
String nextPageToken = null;
try {
do {
ListDevicesResponse response = cloudIotRegistries.devices().list(getRegistryPath()).setPageToken(nextPageToken).setPageSize(LIST_PAGE_SIZE).execute();
List<Device> devices = response.getDevices();
allDevices.addAll(devices == null ? ImmutableList.of() : devices);
System.err.printf("Retrieved %d devices from registry...%n", allDevices.size());
nextPageToken = response.getNextPageToken();
} while (nextPageToken != null);
return allDevices.stream().map(Device::getId).collect(Collectors.toSet());
} catch (Exception e) {
throw new RuntimeException("While listing devices for registry " + registryId, e);
}
}
use of org.hl7.fhir.r4.model.Device in project summary-care-record-api by NHSDigital.
the class AgentDeviceMapper method map.
@Override
public List<? extends Resource> map(Node agentDevice) {
List<Resource> resources = new ArrayList<>();
var role = new PractitionerRole();
role.setId(randomUUID());
var device = mapDevice(agentDevice);
var org = mapOrganization(agentDevice);
device.setOwner(new Reference(org));
role.setOrganization(new Reference(org));
resources.add(device);
resources.add(org);
resources.add(role);
return resources;
}
use of org.hl7.fhir.r4.model.Device in project summary-care-record-api by NHSDigital.
the class AgentDeviceMapper method mapDevice.
private Device mapDevice(Node agentDevice) {
Device device;
Optional<Node> deviceSds = xmlUtils.detachOptionalNodeByXPath(agentDevice, AGENT_DEVICE_SDS_XPATH);
Optional<Node> deviceHl7 = xmlUtils.detachOptionalNodeByXPath(agentDevice, AGENT_DEVICE_XPATH);
if (deviceSds.isPresent()) {
device = deviceSdsMapper.mapDeviceSds(deviceSds.get());
} else if (deviceHl7.isPresent()) {
device = deviceMapper.mapDevice(deviceHl7.get());
} else {
device = new Device();
device.setId(randomUUID());
}
xmlUtils.getOptionalValueByXPath(agentDevice, ID_ROOT_XPATH).ifPresent(id -> device.addIdentifier().setValue(id));
return device;
}
use of org.hl7.fhir.r4.model.Device in project summary-care-record-api by NHSDigital.
the class DeviceMapper method mapDevice.
public Device mapDevice(Node deviceHl7) {
Device deviceFhir = new Device();
deviceFhir.setId(randomUUID());
xmlUtils.getOptionalValueByXPath(deviceHl7, ID_EXTENSION_XPATH).ifPresent(id -> deviceFhir.addIdentifier().setValue(id));
xmlUtils.detachOptionalNodeByXPath(deviceHl7, CODE_ELEMENT_XPATH).ifPresent(code -> deviceFhir.setType(new CodeableConcept(new Coding().setCode(xmlUtils.getValueByXPath(code, CODE_ATTRIBUTE_XPATH)).setDisplay(xmlUtils.getValueByXPath(code, CODE_DISPLAY_XPATH)))));
addName(deviceHl7, deviceFhir, NAME_XPATH, OTHER);
addName(deviceHl7, deviceFhir, MANUFACTURER_MODE_NAME_XPATH, MANUFACTURERNAME);
xmlUtils.detachOptionalNodeByXPath(deviceHl7, DESCRIPTION_XPATH).ifPresent(descNode -> deviceFhir.addNote(new Annotation().setText(descNode.getTextContent())));
xmlUtils.detachOptionalNodeByXPath(deviceHl7, SOFTWARE_NAME_XPATH).ifPresent(software -> deviceFhir.addVersion(new DeviceVersionComponent().setValue(software.getTextContent())));
return deviceFhir;
}
Aggregations