Search in sources :

Example 66 with Address

use of com.adobe.target.delivery.v1.model.Address in project data-transfer-project by google.

the class GoogleContactsImportConversionTest method testConversionToGoogleAddresses.

@Test
public void testConversionToGoogleAddresses() {
    // Set up vCard with a primary address and a secondary address
    String primaryStreet = "221B Baker St";
    String primaryLocality = "London";
    ezvcard.property.Address primaryAddress = new ezvcard.property.Address();
    primaryAddress.setStreetAddress(primaryStreet);
    primaryAddress.setLocality(primaryLocality);
    primaryAddress.setPref(VCARD_PRIMARY_PREF);
    String altStreet = "42 Wallaby Way";
    String altLocality = "Sydney";
    ezvcard.property.Address altAddress = new ezvcard.property.Address();
    altAddress.setStreetAddress(altStreet);
    altAddress.setLocality(altLocality);
    altAddress.setPref(VCARD_PRIMARY_PREF + 1);
    // Add addresses to vCard.  Order shouldn't matter.
    VCard vCard = defaultVCard;
    vCard.addAddress(primaryAddress);
    vCard.addAddress(altAddress);
    // Run test
    Person person = GoogleContactsImporter.convert(vCard);
    // Check results
    // Check correct number of addresses
    assertThat(person.getAddresses().size()).isEqualTo(2);
    // Check primary address
    List<Address> actualPrimaryAddresses = person.getAddresses().stream().filter(a -> a.getMetadata().getPrimary()).collect(Collectors.toList());
    List<String> actualPrimaryAddressStreets = getValuesFromFields(actualPrimaryAddresses, Address::getStreetAddress);
    assertThat(actualPrimaryAddressStreets).containsExactly(primaryStreet);
    // Check secondary address
    List<Address> actualSecondaryAddresses = person.getAddresses().stream().filter(a -> !a.getMetadata().getPrimary()).collect(Collectors.toList());
    List<String> actualSecondaryAddressStreets = getValuesFromFields(actualSecondaryAddresses, Address::getStreetAddress);
    assertThat(actualSecondaryAddressStreets).containsExactly(altStreet);
}
Also used : VCard(ezvcard.VCard) EmailAddress(com.google.api.services.people.v1.model.EmailAddress) Telephone(ezvcard.property.Telephone) Test(org.junit.Test) PhoneNumber(com.google.api.services.people.v1.model.PhoneNumber) Truth.assertThat(com.google.common.truth.Truth.assertThat) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) StructuredName(ezvcard.property.StructuredName) SOURCE_PARAM_NAME_TYPE(org.dataportabilityproject.datatransfer.google.common.GoogleStaticObjects.SOURCE_PARAM_NAME_TYPE) Pair(com.google.gdata.util.common.base.Pair) Person(com.google.api.services.people.v1.model.Person) List(java.util.List) CONTACT_SOURCE_TYPE(org.dataportabilityproject.datatransfer.google.common.GoogleStaticObjects.CONTACT_SOURCE_TYPE) Nullable(com.google.gdata.util.common.base.Nullable) Address(com.google.api.services.people.v1.model.Address) Email(ezvcard.property.Email) VCARD_PRIMARY_PREF(org.dataportabilityproject.datatransfer.google.common.GoogleStaticObjects.VCARD_PRIMARY_PREF) Name(com.google.api.services.people.v1.model.Name) Collections(java.util.Collections) Before(org.junit.Before) EmailAddress(com.google.api.services.people.v1.model.EmailAddress) Address(com.google.api.services.people.v1.model.Address) VCard(ezvcard.VCard) Person(com.google.api.services.people.v1.model.Person) Test(org.junit.Test)

Example 67 with Address

use of com.adobe.target.delivery.v1.model.Address in project wildfly-camel by wildfly-extras.

the class FhirJsonIntegrationTest method createPatient.

private Patient createPatient() {
    Patient patient = new Patient();
    patient.addName(new HumanName().addGiven("Sherlock").setFamily("Holmes")).addAddress(new Address().addLine("221b Baker St, Marylebone, London NW1 6XE, UK"));
    return patient;
}
Also used : HumanName(org.hl7.fhir.dstu3.model.HumanName) Address(org.hl7.fhir.dstu3.model.Address) Patient(org.hl7.fhir.dstu3.model.Patient)

Example 68 with Address

use of com.adobe.target.delivery.v1.model.Address in project data-transfer-project by google.

the class GoogleContactsImportConversionTest method testConversionToGoogleAddresses.

@Test
public void testConversionToGoogleAddresses() {
    // Set up vCard with a primary address and a secondary address
    String primaryStreet = "221B Baker St";
    String primaryLocality = "London";
    ezvcard.property.Address primaryAddress = new ezvcard.property.Address();
    primaryAddress.setStreetAddress(primaryStreet);
    primaryAddress.setLocality(primaryLocality);
    primaryAddress.setPref(VCARD_PRIMARY_PREF);
    String altStreet = "42 Wallaby Way";
    String altLocality = "Sydney";
    ezvcard.property.Address altAddress = new ezvcard.property.Address();
    altAddress.setStreetAddress(altStreet);
    altAddress.setLocality(altLocality);
    altAddress.setPref(VCARD_PRIMARY_PREF + 1);
    // Add addresses to vCard.  Order shouldn't matter.
    VCard vCard = defaultVCard;
    vCard.addAddress(primaryAddress);
    vCard.addAddress(altAddress);
    // Run test
    Person person = GoogleContactsImporter.convert(vCard);
    // Check results
    // Check correct number of addresses
    assertThat(person.getAddresses().size()).isEqualTo(2);
    // Check primary address
    List<Address> actualPrimaryAddresses = person.getAddresses().stream().filter(a -> a.getMetadata().getPrimary()).collect(Collectors.toList());
    List<String> actualPrimaryAddressStreets = getValuesFromFields(actualPrimaryAddresses, Address::getStreetAddress);
    assertThat(actualPrimaryAddressStreets).containsExactly(primaryStreet);
    // Check secondary address
    List<Address> actualSecondaryAddresses = person.getAddresses().stream().filter(a -> !a.getMetadata().getPrimary()).collect(Collectors.toList());
    List<String> actualSecondaryAddressStreets = getValuesFromFields(actualSecondaryAddresses, Address::getStreetAddress);
    assertThat(actualSecondaryAddressStreets).containsExactly(altStreet);
}
Also used : VCard(ezvcard.VCard) SOURCE_PARAM_NAME_TYPE(org.datatransferproject.datatransfer.google.common.GoogleStaticObjects.SOURCE_PARAM_NAME_TYPE) VCARD_PRIMARY_PREF(org.datatransferproject.datatransfer.google.common.GoogleStaticObjects.VCARD_PRIMARY_PREF) EmailAddress(com.google.api.services.people.v1.model.EmailAddress) Telephone(ezvcard.property.Telephone) Test(org.junit.Test) PhoneNumber(com.google.api.services.people.v1.model.PhoneNumber) Truth.assertThat(com.google.common.truth.Truth.assertThat) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) StructuredName(ezvcard.property.StructuredName) CONTACT_SOURCE_TYPE(org.datatransferproject.datatransfer.google.common.GoogleStaticObjects.CONTACT_SOURCE_TYPE) Pair(com.google.gdata.util.common.base.Pair) Person(com.google.api.services.people.v1.model.Person) List(java.util.List) Nullable(com.google.gdata.util.common.base.Nullable) Address(com.google.api.services.people.v1.model.Address) Email(ezvcard.property.Email) Name(com.google.api.services.people.v1.model.Name) Collections(java.util.Collections) Before(org.junit.Before) EmailAddress(com.google.api.services.people.v1.model.EmailAddress) Address(com.google.api.services.people.v1.model.Address) VCard(ezvcard.VCard) Person(com.google.api.services.people.v1.model.Person) Test(org.junit.Test)

Example 69 with Address

use of com.adobe.target.delivery.v1.model.Address in project synthea by synthetichealth.

the class FhirR4 method provider.

/**
 * Map the Provider into a FHIR Organization resource, and add it to the given Bundle.
 *
 * @param rand     Source of randomness to use when generating ids etc
 * @param bundle   The Bundle to add to
 * @param provider The Provider
 * @return The added Entry
 */
protected static BundleEntryComponent provider(RandomNumberGenerator rand, Bundle bundle, Provider provider) {
    Organization organizationResource = new Organization();
    if (USE_US_CORE_IG) {
        Meta meta = new Meta();
        meta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-organization");
        organizationResource.setMeta(meta);
    } else if (USE_SHR_EXTENSIONS) {
        organizationResource.setMeta(new Meta().addProfile(SHR_EXT + "shr-entity-Organization"));
        organizationResource.addIdentifier().setSystem("urn:ietf:rfc:3986").setValue("urn:uuid" + provider.getResourceID());
        organizationResource.addContact().setName(new HumanName().setText("Synthetic Provider"));
    }
    List<CodeableConcept> organizationType = new ArrayList<CodeableConcept>();
    organizationType.add(mapCodeToCodeableConcept(new Code("http://terminology.hl7.org/CodeSystem/organization-type", "prov", "Healthcare Provider"), "http://terminology.hl7.org/CodeSystem/organization-type"));
    organizationResource.addIdentifier().setSystem(SYNTHEA_IDENTIFIER).setValue((String) provider.getResourceID());
    organizationResource.setActive(true);
    organizationResource.setId(provider.getResourceID());
    organizationResource.setName(provider.name);
    organizationResource.setType(organizationType);
    Address address = new Address().addLine(provider.address).setCity(provider.city).setPostalCode(provider.zip).setState(provider.state);
    if (COUNTRY_CODE != null) {
        address.setCountry(COUNTRY_CODE);
    }
    organizationResource.addAddress(address);
    if (provider.phone != null && !provider.phone.isEmpty()) {
        ContactPoint contactPoint = new ContactPoint().setSystem(ContactPointSystem.PHONE).setValue(provider.phone);
        organizationResource.addTelecom(contactPoint);
    } else if (USE_US_CORE_IG) {
        ContactPoint contactPoint = new ContactPoint().setSystem(ContactPointSystem.PHONE).setValue("(555) 555-5555");
        organizationResource.addTelecom(contactPoint);
    }
    org.hl7.fhir.r4.model.Location location = null;
    if (USE_US_CORE_IG) {
        location = providerLocation(rand, bundle, provider);
    }
    BundleEntryComponent entry = newEntry(bundle, organizationResource, provider.getResourceID());
    // add location to bundle *after* organization to ensure no forward reference
    if (location != null) {
        newEntry(bundle, location, provider.getResourceLocationID());
    }
    return entry;
}
Also used : Meta(org.hl7.fhir.r4.model.Meta) Organization(org.hl7.fhir.r4.model.Organization) Address(org.hl7.fhir.r4.model.Address) ArrayList(java.util.ArrayList) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) HumanName(org.hl7.fhir.r4.model.HumanName) ContactPoint(org.hl7.fhir.r4.model.ContactPoint) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 70 with Address

use of com.adobe.target.delivery.v1.model.Address in project synthea by synthetichealth.

the class FhirStu3 method practitioner.

/**
 * Map the clinician into a FHIR Practitioner resource, and add it to the given Bundle.
 * @param bundle The Bundle to add to
 * @param clinician The clinician
 * @return The added Entry
 */
protected static BundleEntryComponent practitioner(Bundle bundle, Clinician clinician) {
    Practitioner practitionerResource = new Practitioner();
    practitionerResource.addIdentifier().setSystem("http://hl7.org/fhir/sid/us-npi").setValue(clinician.npi);
    practitionerResource.setActive(true);
    practitionerResource.addName().setFamily((String) clinician.attributes.get(Clinician.LAST_NAME)).addGiven((String) clinician.attributes.get(Clinician.FIRST_NAME)).addPrefix((String) clinician.attributes.get(Clinician.NAME_PREFIX));
    Address address = new Address().addLine((String) clinician.attributes.get(Clinician.ADDRESS)).setCity((String) clinician.attributes.get(Clinician.CITY)).setPostalCode((String) clinician.attributes.get(Clinician.ZIP)).setState((String) clinician.attributes.get(Clinician.STATE));
    if (COUNTRY_CODE != null) {
        address.setCountry(COUNTRY_CODE);
    }
    practitionerResource.addAddress(address);
    if (clinician.attributes.get(Person.GENDER).equals("M")) {
        practitionerResource.setGender(AdministrativeGender.MALE);
    } else if (clinician.attributes.get(Person.GENDER).equals("F")) {
        practitionerResource.setGender(AdministrativeGender.FEMALE);
    }
    return newEntry(bundle, practitionerResource, clinician.getResourceID());
}
Also used : Practitioner(org.hl7.fhir.dstu3.model.Practitioner) Address(org.hl7.fhir.dstu3.model.Address)

Aggregations

Address (org.hl7.fhir.r4.model.Address)75 Test (org.junit.Test)35 Address (org.hl7.fhir.dstu3.model.Address)22 PersonAddress (org.openmrs.PersonAddress)21 HumanName (org.hl7.fhir.r4.model.HumanName)20 Patient (org.hl7.fhir.r4.model.Patient)18 ArrayList (java.util.ArrayList)17 Identifier (org.hl7.fhir.r4.model.Identifier)17 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)16 Test (org.junit.jupiter.api.Test)13 Organization (org.hl7.fhir.r4.model.Organization)12 Address (com.amazonaws.services.ec2.model.Address)7 HumanName (org.hl7.fhir.dstu3.model.HumanName)7 PatientCommunicationComponent (org.hl7.fhir.r4.model.Patient.PatientCommunicationComponent)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 DescribeAddressesResult (com.amazonaws.services.ec2.model.DescribeAddressesResult)5 HashSet (java.util.HashSet)5 Coding (org.hl7.fhir.r4.model.Coding)5 StringType (org.hl7.fhir.r4.model.StringType)5 Before (org.junit.Before)5