Added geo accuracy code
This commit is contained in:
parent
4050c42bf4
commit
d45972abed
|
@ -38,6 +38,11 @@ public interface IAddressValidator {
|
||||||
*/
|
*/
|
||||||
public static final String ADDRESS_QUALITY_EXTENSION_URL = "http://hapifhir.org/StructureDefinition/ext-validation-address-quality";
|
public static final String ADDRESS_QUALITY_EXTENSION_URL = "http://hapifhir.org/StructureDefinition/ext-validation-address-quality";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* URL for an optional geocoding accuracy extensions that may be added to addresses.
|
||||||
|
*/
|
||||||
|
public static final String ADDRESS_GEO_ACCURACY_EXTENSION_URL = "http://hapifhir.org/StructureDefinition/ext-validation-address-geo-accuracy";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URL for an optional address verification extensions that may be added to addresses.
|
* URL for an optional address verification extensions that may be added to addresses.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.springframework.http.ResponseEntity;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
@ -63,6 +64,7 @@ public class LoquateAddressValidator extends BaseRestfulValidator {
|
||||||
public static final String PROPERTY_GEOCODE = "service.geocode";
|
public static final String PROPERTY_GEOCODE = "service.geocode";
|
||||||
public static final String LOQUATE_AQI = "AQI";
|
public static final String LOQUATE_AQI = "AQI";
|
||||||
public static final String LOQUATE_AVC = "AVC";
|
public static final String LOQUATE_AVC = "AVC";
|
||||||
|
public static final String LOQUATE_GEO_ACCURACY = "GeoAccuracy";
|
||||||
|
|
||||||
protected static final String[] DUPLICATE_FIELDS_IN_ADDRESS_LINES = {"Locality", "AdministrativeArea", "PostalCode"};
|
protected static final String[] DUPLICATE_FIELDS_IN_ADDRESS_LINES = {"Locality", "AdministrativeArea", "PostalCode"};
|
||||||
protected static final String DEFAULT_DATA_CLEANSE_ENDPOINT = "https://api.addressy.com/Cleansing/International/Batch/v1.00/json4.ws";
|
protected static final String DEFAULT_DATA_CLEANSE_ENDPOINT = "https://api.addressy.com/Cleansing/International/Batch/v1.00/json4.ws";
|
||||||
|
@ -139,8 +141,10 @@ public class LoquateAddressValidator extends BaseRestfulValidator {
|
||||||
helper.setState(getString(match, "AdministrativeArea"));
|
helper.setState(getString(match, "AdministrativeArea"));
|
||||||
helper.setPostalCode(getString(match, "PostalCode"));
|
helper.setPostalCode(getString(match, "PostalCode"));
|
||||||
helper.setCountry(getString(match, "CountryName"));
|
helper.setCountry(getString(match, "CountryName"));
|
||||||
|
|
||||||
addExtension(match, LOQUATE_AQI, ADDRESS_QUALITY_EXTENSION_URL, helper, theFhirContext);
|
addExtension(match, LOQUATE_AQI, ADDRESS_QUALITY_EXTENSION_URL, helper, theFhirContext);
|
||||||
addExtension(match, LOQUATE_AVC, ADDRESS_VERIFICATION_CODE_EXTENSION_URL, helper, theFhirContext);
|
addExtension(match, LOQUATE_AVC, ADDRESS_VERIFICATION_CODE_EXTENSION_URL, helper, theFhirContext);
|
||||||
|
addExtension(match, LOQUATE_GEO_ACCURACY, ADDRESS_GEO_ACCURACY_EXTENSION_URL, helper, theFhirContext);
|
||||||
|
|
||||||
return helper.getAddress();
|
return helper.getAddress();
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,7 @@ class LoquateAddressValidatorTest {
|
||||||
" {\n" +
|
" {\n" +
|
||||||
" \"AQI\": \"A\",\n" +
|
" \"AQI\": \"A\",\n" +
|
||||||
" \"AVC\": \"V44-I44-P6-100\",\n" +
|
" \"AVC\": \"V44-I44-P6-100\",\n" +
|
||||||
|
" \"GeoAccuracy\": \"Z1\",\n" +
|
||||||
" \"Address\": \"My Valid Address\",\n" +
|
" \"Address\": \"My Valid Address\",\n" +
|
||||||
" \"Latitude\": \"-32.94217742803439\",\n" +
|
" \"Latitude\": \"-32.94217742803439\",\n" +
|
||||||
" \"Longitude\": \"-60.640132034941836\"\n" +
|
" \"Longitude\": \"-60.640132034941836\"\n" +
|
||||||
|
@ -240,6 +241,10 @@ class LoquateAddressValidatorTest {
|
||||||
IBaseExtension verificationCode = ExtensionUtil.getExtensionByUrl(address, IAddressValidator.ADDRESS_VERIFICATION_CODE_EXTENSION_URL);
|
IBaseExtension verificationCode = ExtensionUtil.getExtensionByUrl(address, IAddressValidator.ADDRESS_VERIFICATION_CODE_EXTENSION_URL);
|
||||||
assertNotNull(verificationCode);
|
assertNotNull(verificationCode);
|
||||||
assertEquals("V44-I44-P6-100", verificationCode.getValue().toString());
|
assertEquals("V44-I44-P6-100", verificationCode.getValue().toString());
|
||||||
|
|
||||||
|
IBaseExtension geoAccuracy = ExtensionUtil.getExtensionByUrl(address, IAddressValidator.ADDRESS_GEO_ACCURACY_EXTENSION_URL);
|
||||||
|
assertNotNull(geoAccuracy);
|
||||||
|
assertEquals("Z1", geoAccuracy.getValue().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue