Search in sources :

Example 66 with Location

use of com.google.api.services.actions_fulfillment.v2.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();
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) Immunization(org.hl7.fhir.r4.model.Immunization) Organization(org.hl7.fhir.r4.model.Organization) Bundle(org.hl7.fhir.r4.model.Bundle) Patient(org.hl7.fhir.r4.model.Patient) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) Practitioner(org.hl7.fhir.r4.model.Practitioner) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Observation(org.hl7.fhir.r4.model.Observation) Encounter(org.hl7.fhir.r4.model.Encounter) MedicationStatement(org.hl7.fhir.r4.model.MedicationStatement) Location(org.hl7.fhir.r4.model.Location)

Example 67 with Location

use of com.google.api.services.actions_fulfillment.v2.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);
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Reference(org.hl7.fhir.r4.model.Reference) EncounterLocationComponent(org.hl7.fhir.r4.model.Encounter.EncounterLocationComponent) Resource(org.hl7.fhir.r4.model.Resource) ArrayList(java.util.ArrayList) Encounter(org.hl7.fhir.r4.model.Encounter) Location(org.hl7.fhir.r4.model.Location) Test(org.junit.Test)

Example 68 with Location

use of com.google.api.services.actions_fulfillment.v2.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);
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Reference(org.hl7.fhir.r4.model.Reference) EncounterLocationComponent(org.hl7.fhir.r4.model.Encounter.EncounterLocationComponent) Resource(org.hl7.fhir.r4.model.Resource) ArrayList(java.util.ArrayList) Encounter(org.hl7.fhir.r4.model.Encounter) Location(org.hl7.fhir.r4.model.Location) Test(org.junit.Test)

Example 69 with Location

use of com.google.api.services.actions_fulfillment.v2.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;
}
Also used : PostalAddress(com.google.api.services.actions_fulfillment.v2.model.PostalAddress) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) LatLng(com.google.api.services.actions_fulfillment.v2.model.LatLng) Location(com.google.api.services.actions_fulfillment.v2.model.Location)

Example 70 with Location

use of com.google.api.services.actions_fulfillment.v2.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();
}
Also used : Argument(com.google.api.services.actions_fulfillment.v2.model.Argument) ResourceBundle(java.util.ResourceBundle) JsonObject(com.google.gson.JsonObject) JSONObject(org.json.simple.JSONObject) ResponseBuilder(com.google.actions.api.response.ResponseBuilder) Location(com.google.api.services.actions_fulfillment.v2.model.Location) ForIntent(com.google.actions.api.ForIntent)

Aggregations

Test (org.junit.Test)120 Location (org.hl7.fhir.r4.model.Location)93 Location (org.hl7.fhir.dstu3.model.Location)66 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)59 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)42 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)30 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)27 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)21 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)20 StringOrListParam (ca.uhn.fhir.rest.param.StringOrListParam)20 StringParam (ca.uhn.fhir.rest.param.StringParam)20 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)16 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)16 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)16 MockIBundleProvider (org.openmrs.module.fhir2.providers.r4.MockIBundleProvider)16 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)13 Test (org.junit.jupiter.api.Test)13 ArrayList (java.util.ArrayList)11 HashSet (java.util.HashSet)11 TokenParam (ca.uhn.fhir.rest.param.TokenParam)10