use of org.hl7.fhir.r4b.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
}
use of org.hl7.fhir.r4b.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;
}
use of org.hl7.fhir.r4b.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;
}
use of org.hl7.fhir.r4b.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;
}
use of org.hl7.fhir.r4b.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());
}
Aggregations