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.
What you have
Address lines as the records hold them, one per row, and the country file:
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:
$ 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.
$ gridpin batch usa.bin patients.csv out.csv --with fhir
3. Read the result:
$ cat out.csv
What you get
id | gp_fhir_mode | gp_lat | gp_lon |
|---|---|---|---|
| pt-1 | structured | 38.8976751 | -77.036547 |
| pt-2 | structured | 41.878658 | -87.6358684 |
| pt-3 | as_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.
More
- Structured postal addresses for ISO 20022 payments
- Print addresses the way the post lays them out
- Check the addresses in e-invoicing documents
- Geocode patient addresses on your own machine
- Clinical trials: patients to sites, privately
- Your own place names: HQ, depot 3, store 117
- All guides and countries
- Documentation