use of com.ibm.watson.compare_comply.v1.model.Location in project eCRNow by drajer-health.
the class FhirEicrGeneratorFromR4 method convertR4FhirBundletoCdaEicr.
public static String convertR4FhirBundletoCdaEicr(R4FhirData data) {
StringBuilder eICR = new StringBuilder();
if (data != null) {
Bundle bundle = data.getData();
if (bundle != null) {
List<BundleEntryComponent> entries = bundle.getEntry();
for (BundleEntryComponent ent : entries) {
// Populate data ..this can be moved to the APIs where the bundle is getting created.
if (ent.getResource() instanceof Patient) {
logger.info(" Bundle contains Patient ");
data.setPatient((Patient) ent.getResource());
} else if (ent.getResource() instanceof Practitioner) {
logger.info(" Bundle contains Practitioner ");
data.setPractitioner((Practitioner) ent.getResource());
} else if (ent.getResource() instanceof Encounter) {
logger.info(" Bundle contains Encounter ");
data.setEncounter((Encounter) ent.getResource());
} else if (ent.getResource() instanceof Location) {
logger.info(" Bundle contains Location ");
data.setLocation((Location) ent.getResource());
} else if (ent.getResource() instanceof Organization) {
logger.info(" Bundle contains Organization ");
data.setOrganization((Organization) ent.getResource());
} else if (ent.getResource() instanceof Condition) {
logger.info(" Bundle contains Condition ");
data.getConditions().add((Condition) ent.getResource());
} else if (ent.getResource() instanceof Observation) {
logger.info(" Bundle constains Observation ");
Observation obs = (Observation) ent.getResource();
} else if (ent.getResource() instanceof DiagnosticReport) {
logger.info(" Bundle contains Diagnostic Report ");
data.getDiagReports().add((DiagnosticReport) ent.getResource());
} else if (ent.getResource() instanceof MedicationStatement) {
logger.info(" Bundle contains MedicationStatement ");
data.getMedications().add((MedicationStatement) ent.getResource());
} else if (ent.getResource() instanceof Immunization) {
logger.info(" Bundle contains Immunization ");
data.getImmunizations().add((Immunization) ent.getResource());
}
}
}
} else {
logger.error(" No Fhir Bundle Available to create CDA Documents ");
}
return eICR.toString();
}
use of com.ibm.watson.compare_comply.v1.model.Location in project eCRNow by drajer-health.
the class CdaFhirUtilitiesTest method testGetOrganization_withNullLocationComp.
@Test
public void testGetOrganization_withNullLocationComp() {
EncounterLocationComponent loc = null;
Reference ref = new Reference();
ref.setReference("ResId");
BundleEntryComponent bundleEntry = new BundleEntryComponent();
Resource location = ResourceFactory.createResource("Location");
location.setId("ResId");
bundleEntry.setResource(location);
List<BundleEntryComponent> entries = new ArrayList<BundleEntryComponent>();
entries.add(bundleEntry);
Encounter en = new Encounter();
List<EncounterLocationComponent> locationList = new ArrayList<Encounter.EncounterLocationComponent>();
locationList.add(loc);
en.setLocation(locationList);
Location testLocation = CdaFhirUtilities.getLocation(entries, en);
assertNull(testLocation);
}
use of com.ibm.watson.compare_comply.v1.model.Location in project eCRNow by drajer-health.
the class CdaFhirUtilitiesTest method testGetOrganization_withLocationEntry.
@Test
public void testGetOrganization_withLocationEntry() {
EncounterLocationComponent loc = new EncounterLocationComponent();
Reference ref = new Reference();
ref.setReference("ResId");
loc.setLocation(ref);
BundleEntryComponent bundleEntry = new BundleEntryComponent();
Resource location = ResourceFactory.createResource("Location");
location.setId("ResId");
bundleEntry.setResource(location);
List<BundleEntryComponent> entries = new ArrayList<BundleEntryComponent>();
entries.add(bundleEntry);
Encounter en = new Encounter();
List<EncounterLocationComponent> locationList = new ArrayList<Encounter.EncounterLocationComponent>();
locationList.add(loc);
en.setLocation(locationList);
Location testLocation = CdaFhirUtilities.getLocation(entries, en);
assertNotNull(testLocation);
}
use of com.ibm.watson.compare_comply.v1.model.Location in project dialogflow-transactions-java by actions-on-google.
the class LocationDeserializer method deserialize.
@Override
public Location deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonObject jsonObject = json.getAsJsonObject();
Location location = new Location();
JsonElement city = jsonObject.get("city");
JsonElement coordinates = jsonObject.get("coordinates");
JsonElement name = jsonObject.get("name");
JsonElement notes = jsonObject.get("notes");
JsonElement phoneNumber = jsonObject.get("phoneNumber");
JsonElement placeId = jsonObject.get("placeId");
JsonElement zipCode = jsonObject.get("zipCode");
JsonElement formattedAddress = jsonObject.get("formattedAddress");
JsonElement postalAddress = jsonObject.get("postalAddress");
if (city != null) {
location.setCity(city.getAsString());
}
if (name != null) {
location.setName(name.getAsString());
}
if (notes != null) {
location.setNotes(notes.getAsString());
}
if (phoneNumber != null) {
location.setPhoneNumber(phoneNumber.getAsString());
}
if (placeId != null) {
location.setPlaceId(placeId.getAsString());
}
if (zipCode != null) {
location.setZipCode(zipCode.getAsString());
}
if (formattedAddress != null) {
location.setFormattedAddress(formattedAddress.getAsString());
}
if (postalAddress != null) {
PostalAddress address = context.deserialize(postalAddress.getAsJsonObject(), PostalAddress.class);
location.setPostalAddress(address);
}
if (coordinates != null) {
LatLng coords = context.deserialize(coordinates.getAsJsonObject(), LatLng.class);
location.setCoordinates(coords);
}
return location;
}
use of com.ibm.watson.compare_comply.v1.model.Location in project dialogflow-transactions-java by actions-on-google.
the class TransactionsApp method deliveryAddressComplete.
// Verifies delivery address and caches it for later use
@ForIntent("Delivery Address Complete")
public ActionResponse deliveryAddressComplete(ActionRequest request) {
ResourceBundle rb = ResourceBundle.getBundle("resources", request.getLocale());
// Check delivery address value
Argument deliveryAddressValue = request.getArgument("DELIVERY_ADDRESS_VALUE");
Location deliveryAddress = null;
if (deliveryAddressValue != null) {
Map<String, Object> map = deliveryAddressValue.getExtension();
if (map != null) {
String userDecision = (String) map.get("userDecision");
Location location = (Location) map.get("location");
deliveryAddress = userDecision != null && userDecision.equals("ACCEPTED") ? location : null;
}
}
ResponseBuilder responseBuilder = getResponseBuilder(request);
if (deliveryAddress != null) {
// Cache delivery address in conversation data for later use
Map<String, Object> conversationData = request.getConversationData();
conversationData.put("location", GSON_BUILDER.create().toJson(deliveryAddress, Location.class));
responseBuilder.add(rb.getString("confirm_transaction")).addSuggestions(new String[] { "confirm transaction" });
} else {
responseBuilder.add(rb.getString("delivery_address_failed"));
}
return responseBuilder.build();
}
Aggregations