001package ca.uhn.fhir.rest.server.interceptor.validation.address;
002
003/*-
004 * #%L
005 * HAPI FHIR - Server Framework
006 * %%
007 * Copyright (C) 2014 - 2023 Smile CDR, Inc.
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 *
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023import ca.uhn.fhir.context.FhirContext;
024import org.hl7.fhir.instance.model.api.IBase;
025
026/**
027 * Contract for validating addresses.
028 */
029public interface IAddressValidator {
030
031        /**
032         * URL for validation results that should be placed on addresses. Extension with boolean value "true" indicates there there is an address validation error.
033         */
034        public static final String ADDRESS_VALIDATION_EXTENSION_URL = "http://hapifhir.org/StructureDefinition/ext-validation-address-has-error";
035
036        /**
037         * URL for an optional address quality extensions that may be added to addresses.
038         */
039        public static final String ADDRESS_QUALITY_EXTENSION_URL = "http://hapifhir.org/StructureDefinition/ext-validation-address-quality";
040
041        /**
042         * URL for an optional geocoding accuracy extensions that may be added to addresses.
043         */
044        public static final String ADDRESS_GEO_ACCURACY_EXTENSION_URL = "http://hapifhir.org/StructureDefinition/ext-validation-address-geo-accuracy";
045
046        /**
047         * URL for an optional address verification extensions that may be added to addresses.
048         */
049        public static final String ADDRESS_VERIFICATION_CODE_EXTENSION_URL = "http://hapifhir.org/StructureDefinition/ext-validation-address-verification";
050
051        /**
052         * URL for an optional FHIR geolocation extension.
053         */
054        public static final String FHIR_GEOCODE_EXTENSION_URL = "http://hl7.org/fhir/StructureDefinition/geolocation";
055
056        /**
057         * Validates address against a service
058         *
059         * @param theAddress     Address to be validated
060         * @param theFhirContext Current FHIR context
061         * @return Returns true in case address represents a valid
062         * @throws AddressValidationException AddressValidationException is thrown in case validation can not be completed successfully.
063         */
064        AddressValidationResult isValid(IBase theAddress, FhirContext theFhirContext) throws AddressValidationException;
065
066}