Search in sources :

Example 76 with ContactPoint

use of org.hl7.fhir.dstu2.model.ContactPoint in project gpconnect-demonstrator by nhsconnect.

the class PatientResourceProvider method validateTelecomAndAddress.

private void validateTelecomAndAddress(Patient patient) {
    // 0..1 of phone - (not nec. temp),  0..1 of email
    HashSet<ContactPointUse> phoneUse = new HashSet<>();
    int emailCount = 0;
    for (ContactPoint telecom : patient.getTelecom()) {
        if (telecom.hasSystem()) {
            if (telecom.getSystem() != null) {
                switch(telecom.getSystem()) {
                    case PHONE:
                        if (telecom.hasUse()) {
                            switch(telecom.getUse()) {
                                case HOME:
                                case WORK:
                                case MOBILE:
                                case TEMP:
                                    if (!phoneUse.contains(telecom.getUse())) {
                                        phoneUse.add(telecom.getUse());
                                    } else {
                                        throwInvalidRequest400_BadRequestException("Only one Telecom of type phone with use type " + telecom.getUse().toString().toLowerCase() + " is allowed in a register patient request.");
                                    }
                                    break;
                                default:
                                    throwInvalidRequest400_BadRequestException("Invalid Telecom of type phone use type " + telecom.getUse().toString().toLowerCase() + " in a register patient request.");
                            }
                        } else {
                            throwInvalidRequest400_BadRequestException("Invalid Telecom - no Use type provided in a register patient request.");
                        }
                        break;
                    case EMAIL:
                        if (++emailCount > 1) {
                            throwInvalidRequest400_BadRequestException("Only one Telecom of type " + "email" + " is allowed in a register patient request.");
                        }
                        break;
                    default:
                        throwInvalidRequest400_BadRequestException("Telecom system is missing in a register patient request.");
                }
            }
        } else {
            throwInvalidRequest400_BadRequestException("Telecom system is missing in a register patient request.");
        }
    }
    // iterate telcom
    // count by useType - Only the first address is persisted at present
    HashSet<AddressUse> useTypeCount = new HashSet<>();
    for (Address address : patient.getAddress()) {
        AddressUse useType = address.getUse();
        // #189 address use types work and old are not allowed
        if (useType == WORK || useType == OLD) {
            throwUnprocessableEntity422_InvalidResourceException("Address use type " + useType + " cannot be sent in a register patient request.");
        }
        if (!useTypeCount.contains(useType)) {
            useTypeCount.add(useType);
        } else {
            // #174 Only a single address of each usetype may be sent
            throwUnprocessableEntity422_InvalidResourceException("Only a single address of each use type can be sent in a register patient request.");
        }
    }
// for address
}
Also used : ContactPointUse(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse) AddressUse(org.hl7.fhir.dstu3.model.Address.AddressUse)

Example 77 with ContactPoint

use of org.hl7.fhir.dstu2.model.ContactPoint in project gpconnect-demonstrator by nhsconnect.

the class OrganizationResourceProvider method getValidTelecom.

private ContactPoint getValidTelecom() {
    ContactPoint orgTelCom = new ContactPoint();
    // doesn't atppear to do anything
    orgTelCom.addExtension().setUrl("testUrl");
    orgTelCom.setSystem(ContactPointSystem.PHONE);
    orgTelCom.setUse(ContactPointUse.WORK);
    // #152
    orgTelCom.setValue("12345678");
    return orgTelCom;
}
Also used : ContactPoint(org.hl7.fhir.dstu3.model.ContactPoint)

Example 78 with ContactPoint

use of org.hl7.fhir.dstu2.model.ContactPoint in project gpconnect-demonstrator by nhsconnect.

the class StaticElementsHelper method getValidTelecom.

public ContactPoint getValidTelecom() {
    ContactPoint orgTelCom = new ContactPoint();
    Extension extension = new Extension("testurl");
    orgTelCom.addExtension(extension);
    orgTelCom.setSystem(ContactPointSystem.PHONE);
    orgTelCom.setUse(ContactPointUse.WORK);
    orgTelCom.setValue("telecomVal");
    return orgTelCom;
}
Also used : Extension(org.hl7.fhir.dstu3.model.Extension) ContactPoint(org.hl7.fhir.dstu3.model.ContactPoint)

Example 79 with ContactPoint

use of org.hl7.fhir.dstu2.model.ContactPoint 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 80 with ContactPoint

use of org.hl7.fhir.dstu2.model.ContactPoint in project synthea by synthetichealth.

the class FhirStu3 method provider.

/**
 * Map the Provider into a FHIR Organization resource, and add it to the given Bundle.
 * @param bundle The Bundle to add to
 * @param provider The Provider
 * @return The added Entry
 */
protected static BundleEntryComponent provider(Bundle bundle, Provider provider) {
    org.hl7.fhir.dstu3.model.Organization organizationResource = new org.hl7.fhir.dstu3.model.Organization();
    List<CodeableConcept> organizationType = new ArrayList<CodeableConcept>();
    organizationType.add(mapCodeToCodeableConcept(new Code("http://hl7.org/fhir/organization-type", "prov", "Healthcare Provider"), "http://hl7.org/fhir/organization-type"));
    organizationResource.addIdentifier().setSystem("https://github.com/synthetichealth/synthea").setValue((String) provider.getResourceID());
    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);
    Point2D.Double coord = provider.getLonLat();
    if (coord != null) {
        Extension geolocation = address.addExtension();
        geolocation.setUrl("http://hl7.org/fhir/StructureDefinition/geolocation");
        geolocation.addExtension("latitude", new DecimalType(coord.getY()));
        geolocation.addExtension("longitude", new DecimalType(coord.getX()));
    }
    if (provider.phone != null && !provider.phone.isEmpty()) {
        ContactPoint contactPoint = new ContactPoint().setSystem(ContactPointSystem.PHONE).setValue(provider.phone);
        organizationResource.addTelecom(contactPoint);
    }
    if (USE_SHR_EXTENSIONS) {
        organizationResource.setMeta(new Meta().addProfile(SHR_EXT + "shr-entity-Organization"));
        // required fields for this profile are identifier, type, address, and contact
        organizationResource.addIdentifier().setSystem("urn:ietf:rfc:3986").setValue("urn:uuid:" + provider.getResourceID());
        organizationResource.addContact().setName(new HumanName().setText("Synthetic Provider"));
    }
    return newEntry(bundle, organizationResource, provider.getResourceID());
}
Also used : Meta(org.hl7.fhir.dstu3.model.Meta) Organization(org.hl7.fhir.dstu3.model.Organization) Address(org.hl7.fhir.dstu3.model.Address) ArrayList(java.util.ArrayList) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) Extension(org.hl7.fhir.dstu3.model.Extension) Organization(org.hl7.fhir.dstu3.model.Organization) ContactPoint(org.hl7.fhir.dstu3.model.ContactPoint) HumanName(org.hl7.fhir.dstu3.model.HumanName) Point2D(java.awt.geom.Point2D) DecimalType(org.hl7.fhir.dstu3.model.DecimalType) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Aggregations

ContactPoint (org.hl7.fhir.r4.model.ContactPoint)56 Test (org.junit.Test)28 Address (org.hl7.fhir.r4.model.Address)18 Identifier (org.hl7.fhir.r4.model.Identifier)17 HumanName (org.hl7.fhir.r4.model.HumanName)16 PersonAttribute (org.openmrs.PersonAttribute)15 NotImplementedException (org.apache.commons.lang3.NotImplementedException)14 ContactPoint (org.hl7.fhir.dstu3.model.ContactPoint)14 Test (org.junit.jupiter.api.Test)14 ArrayList (java.util.ArrayList)12 Organization (org.hl7.fhir.r4.model.Organization)12 ProviderAttribute (org.openmrs.ProviderAttribute)11 HashSet (java.util.HashSet)10 IdType (org.hl7.fhir.dstu3.model.IdType)9 Patient (org.hl7.fhir.r4.model.Patient)9 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)7 ContactDetail (org.hl7.fhir.r5.model.ContactDetail)6 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)6 HashMap (java.util.HashMap)5 Base64 (org.apache.commons.codec.binary.Base64)5