SQL on FHIR
2.1.0-pre - release International flag

SQL on FHIR - Local Development build (v2.1.0-pre) built by the FHIR (HL7® FHIR® Standard) Build Tools. See the Directory of published versions

: SQL on FHIR Example - JSON Representation

Active as of 2025-07-31

Raw json | Download

{
  "resourceType" : "Library",
  "id" : "SqlOnFhirExample",
  "meta" : {
    "profile" : [
      🔗 "https://sql-on-fhir.org/ig/StructureDefinition/SQLQuery"
    ]
  },
  "text" : {
    "status" : "generated",
    "div" : "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p class=\"res-header-id\"><b>Generated Narrative: Library SqlOnFhirExample</b></p><a name=\"SqlOnFhirExample\"> </a><a name=\"hcSqlOnFhirExample\"> </a><div style=\"display: inline-block; background-color: #d9e0e7; padding: 6px; margin: 4px; border: 1px solid #8da1b4; border-radius: 5px; line-height: 60%\"><p style=\"margin-bottom: 0px\"/><p style=\"margin-bottom: 0px\">Profile: <a href=\"StructureDefinition-SQLQuery.html\">SQL Query Library</a></p></div><h2>Participants</h2><table class=\"grid\"><tr><td>Author</td><td>Clinical Informatics Team</td></tr></table><h2>Related Artifacts</h2><table class=\"grid\"><tr><td>Depends On</td><td><code>https://sql-on-fhir.org/ig/StructureDefinition/ViewDefinition/PatientDemographics</code></td></tr><tr><td>Depends On</td><td><code>https://sql-on-fhir.org/ig/StructureDefinition/ViewDefinition/PatientAddresses</code></td></tr></table><h2>Parameters</h2><table class=\"grid\"><tr><td>city</td><td>in</td><td/><td/><td>string</td></tr></table><h2>Contents</h2><p>sql_on_fhir_example.sql: (<code>application/sql</code>)</p><pre><code>/*\n@title: Trivial SQL on FHIR Example\n@description: Demonstrating converting SQL to FHIR Library with basic annotations \n@version: 4.2.0\n@status: active\n@author: Clinical Informatics Team\n@publisher: Regional Medical Center\n*/\n\n-- @relatedDependency: https://sql-on-fhir.org/ig/StructureDefinition/ViewDefinition/PatientDemographics\n-- @relatedDependency: https://sql-on-fhir.org/ig/StructureDefinition/ViewDefinition/PatientAddresses\n-- @param: city string\nWITH RankedAddresses AS (\n    SELECT \n        pd.*,\n        pa.*,\n        ROW_NUMBER() OVER (PARTITION BY pd.patient_id ORDER BY pa.address_id) AS address_rank\n    FROM \n        patient_demographics pd\n    JOIN \n        patient_addresses pa ON pd.patient_id = pa.patient_id\n    WHERE \n        pd.age &gt; 18\n        AND pa.city = :city\n)\n</code></pre></div>"
  },
  "url" : "https://sql-on-fhir.org/ig/Library/SqlOnFhirExample",
  "version" : "2.1.0-pre",
  "name" : "SqlOnFhirExample",
  "title" : "SQL on FHIR Example",
  "status" : "active",
  "type" : {
    "coding" : [
      {
        "system" : "https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes",
        "code" : "sql-query"
      }
    ]
  },
  "date" : "2025-07-31T21:26:38+00:00",
  "publisher" : "SQL on FHIR Working Group",
  "contact" : [
    {
      "name" : "SQL on FHIR Working Group",
      "telecom" : [
        {
          "system" : "url",
          "value" : "https://sql-on-fhir.org"
        }
      ]
    }
  ],
  "description" : "Demonstrating a SQL Query Library with basic annotations that can\nassist in generating properties and metadata.\n\n```sql\n/*\n@title: SQL on FHIR Example\n@description: Demonstrating converting SQL to FHIR Library with basic annotations \n@version: 4.2.0\n@status: active\n@author: Clinical Informatics Team\n@publisher: Regional Medical Center\n*/\n\n-- @relatedDependency: https://sql-on-fhir.org/ig/StructureDefinition/ViewDefinition/PatientDemographics\n-- @relatedDependency: https://sql-on-fhir.org/ig/StructureDefinition/ViewDefinition/PatientAddresses\n-- @param: city string\nWITH RankedAddresses AS (\n    SELECT \n        pd.*,\n        pa.*,\n        ROW_NUMBER() OVER (PARTITION BY pd.patient_id ORDER BY pa.address_id) AS address_rank\n    FROM \n        patient_demographics pd\n    JOIN \n        patient_addresses pa ON pd.patient_id = pa.patient_id\n    WHERE \n        pd.age > 18\n        AND pa.city = :city\n)\n```",
  "jurisdiction" : [
    {
      "coding" : [
        {
          "system" : "http://unstats.un.org/unsd/methods/m49/m49.htm",
          "code" : "001",
          "display" : "World"
        }
      ]
    }
  ],
  "author" : [
    {
      "name" : "Clinical Informatics Team"
    }
  ],
  "relatedArtifact" : [
    {
      "type" : "depends-on",
      "resource" : "https://sql-on-fhir.org/ig/StructureDefinition/ViewDefinition/PatientDemographics"
    },
    {
      "type" : "depends-on",
      "resource" : "https://sql-on-fhir.org/ig/StructureDefinition/ViewDefinition/PatientAddresses"
    }
  ],
  "parameter" : [
    {
      "name" : "city",
      "use" : "in",
      "type" : "string"
    }
  ],
  "content" : [
    {
      "contentType" : "application/sql",
      "data" : "LyoKQHRpdGxlOiBUcml2aWFsIFNRTCBvbiBGSElSIEV4YW1wbGUKQGRlc2NyaXB0aW9uOiBEZW1vbnN0cmF0aW5nIGNvbnZlcnRpbmcgU1FMIHRvIEZISVIgTGlicmFyeSB3aXRoIGJhc2ljIGFubm90YXRpb25zIApAdmVyc2lvbjogNC4yLjAKQHN0YXR1czogYWN0aXZlCkBhdXRob3I6IENsaW5pY2FsIEluZm9ybWF0aWNzIFRlYW0KQHB1Ymxpc2hlcjogUmVnaW9uYWwgTWVkaWNhbCBDZW50ZXIKKi8KCi0tIEByZWxhdGVkRGVwZW5kZW5jeTogaHR0cHM6Ly9zcWwtb24tZmhpci5vcmcvaWcvU3RydWN0dXJlRGVmaW5pdGlvbi9WaWV3RGVmaW5pdGlvbi9QYXRpZW50RGVtb2dyYXBoaWNzCi0tIEByZWxhdGVkRGVwZW5kZW5jeTogaHR0cHM6Ly9zcWwtb24tZmhpci5vcmcvaWcvU3RydWN0dXJlRGVmaW5pdGlvbi9WaWV3RGVmaW5pdGlvbi9QYXRpZW50QWRkcmVzc2VzCi0tIEBwYXJhbTogY2l0eSBzdHJpbmcKV0lUSCBSYW5rZWRBZGRyZXNzZXMgQVMgKAogICAgU0VMRUNUIAogICAgICAgIHBkLiosCiAgICAgICAgcGEuKiwKICAgICAgICBST1dfTlVNQkVSKCkgT1ZFUiAoUEFSVElUSU9OIEJZIHBkLnBhdGllbnRfaWQgT1JERVIgQlkgcGEuYWRkcmVzc19pZCkgQVMgYWRkcmVzc19yYW5rCiAgICBGUk9NIAogICAgICAgIHBhdGllbnRfZGVtb2dyYXBoaWNzIHBkCiAgICBKT0lOIAogICAgICAgIHBhdGllbnRfYWRkcmVzc2VzIHBhIE9OIHBkLnBhdGllbnRfaWQgPSBwYS5wYXRpZW50X2lkCiAgICBXSEVSRSAKICAgICAgICBwZC5hZ2UgPiAxOAogICAgICAgIEFORCBwYS5jaXR5ID0gOmNpdHkKKQo=",
      "title" : "sql_on_fhir_example.sql",
      "creation" : "2025-07-22T08:20:49.312999Z"
    }
  ]
}