SQL on FHIR
            
            2.0.0 - release
  
            
          
This page is part of the SQL on FHIR (v2.0.0: Release) based on FHIR (HL7® FHIR® Standard) v5.0.0. This is the current published version. For a full list of available versions, see the Directory of published versions
This content is an example of the View Definition Logical Model and is not a FHIR Resource
    
{
  "resourceType": "https://sql-on-fhir.org/ig/StructureDefinition/ViewDefinition",
  "select": [
    {
      "column": [
        {
          "path": "getResourceKey()",
          "name": "patient_id"
        }
      ]
    },
    {
      "column": [
        {
          "path": "line.join('\n')",
          "name": "street",
          "description": "The full street address, including newlines if present."
        },
        {
          "path": "use",
          "name": "use"
        },
        {
          "path": "city",
          "name": "city"
        },
        {
          "path": "postalCode",
          "name": "zip"
        }
      ],
      "forEach": "address"
    }
  ],
  "name": "patient_addresses",
  "status": "draft",
  "resource": "Patient"
}
  
This will result in a "patient_addresses" table that looks like this:
| patient_id | street | use | city | zip | 
|---|---|---|---|---|
| 1 | 123 Main St\nApt 1 | home | San Diego | 92101 | 
| 1 | 456 Maplewood Dve\nApt 2 | work | New York | 10001 | 
| 2 | 789 Brookside Ave\nApt 3 | home | Los Angeles | 90001 | 
| 3 | 987 Pinehurst Rd\nApt 4 | home | Chicago | 60601 | 
| 3 | 654 Evergreen Tce\nApt 5 | work | Houston | 77001 |