Patient addresses as FHIR Address resources

A hospital, a lab or a health app keeps addresses in HL7 FHIR and needs them structured and placed on a map. Sending patients' addresses to an online geocoder is exactly what a privacy review stops. Here the country file answers on your machine.

New Mail and payments Command line Health

What you have

Address lines as the records hold them, one per row, and the country file:

patients.csvfile
id,address
pt-1,"1600 Pennsylvania Ave NW, Washington, DC 20500"
pt-2,"233 S Wacker Dr, Chicago, IL 60606"
pt-3,"12 Imaginary Lane, Springfield"

Steps

1. One address, to see the resource:

terminalCLI
$ gridpin format usa.bin "233 S Wacker Dr, Chicago, IL 60606" --out fhir
{"address":{"city":"Chicago","country":"US","extension":[{"extension":[{"url":"latitude","valueDecimal":41.878658},{"url":"longitude","valueDecimal":-87.6358684}],"url":"http://hl7.org/fhir/StructureDefinition/geolocation"}],"line":["233 South WACKER Drive"],"postalCode":"60606","text":"233 South WACKER Drive, Chicago 60606","type":"physical"},"mode":"structured","reasons":[]}

2. A whole table: the resource comes as one JSON column.

terminalCLI
$ gridpin batch usa.bin patients.csv out.csv --with fhir

3. Read the result:

terminalCLI
$ cat out.csv

What you get

idgp_fhir_modegp_latgp_lon
pt-1structured38.8976751-77.036547
pt-2structured41.878658-87.6358684
pt-3as_written

structured means the file confirmed the house in the town the line names: the resource has line, city, postalCode, country and the point as the FHIR geolocation extension. as_written keeps the line as text and adds nothing, so a guess never reaches a health record.

Why it works

The line is geocoded on the country file, and only a house the file knows, in the town the line names, becomes a structured address. FHIR asks that the text hold nothing the parts lack, so the text of a structured address is written from its own parts.

Limits

  • A post office box or a street without a number gets no point.
  • FHIR Bundles are not read: give the address lines.
  • These are the engine's checks, not a conformance statement of the HL7 validator.

The function: FHIR Address. All its keys: command reference. Related: geocode patient addresses on your own machine.