{
  "resourceType" : "Library",
  "id" : "ActivePatientAddressesQuery",
  "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 ActivePatientAddressesQuery</b></p><a name=\"ActivePatientAddressesQuery\"> </a><a name=\"hcActivePatientAddressesQuery\"> </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>Related Artifacts</h2><table class=\"grid\"><tr><td>Depends On</td><td>active_patients</td><td>Active Patients view</td><td><a href=\"Library-ActivePatientsView.html\">Active Patients</a></td></tr><tr><td>Depends On</td><td>patient_address_view</td><td>Patient address view</td><td><code>https://example.org/ViewDefinition/patient_address_view</code></td></tr></table><h2>Contents</h2><p><code>application/sql</code></p><pre><code>SELECT\n  active_patients.patient_id,\n  active_patients.patient_name,\n  patient_address_view.city,\n  patient_address_view.state\nFROM active_patients\nJOIN patient_address_view\n  ON active_patients.patient_id = patient_address_view.patient_id</code></pre></div>"
  },
  "url" : "https://sql-on-fhir.org/ig/Library/ActivePatientAddressesQuery",
  "version" : "2.1.0-pre",
  "name" : "ActivePatientAddressesQuery",
  "title" : "Active Patient Addresses",
  "status" : "active",
  "type" : {
    "coding" : [{
      "system" : "https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes",
      "code" : "sql-query"
    }]
  },
  "date" : "2026-06-13T00:26:08+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" : "Joins the [Active Patients](Library-ActivePatientsView.html) view to patient\naddresses. The `active_patients` label resolves to the referenced SQLView, which\nthe executing engine may materialise or inline.\n\n```sql\nSELECT\n  active_patients.patient_id,\n  active_patients.patient_name,\n  patient_address_view.city,\n  patient_address_view.state\nFROM active_patients\nJOIN patient_address_view\n  ON active_patients.patient_id = patient_address_view.patient_id\n```",
  "jurisdiction" : [{
    "coding" : [{
      "system" : "http://unstats.un.org/unsd/methods/m49/m49.htm",
      "code" : "001",
      "display" : "World"
    }]
  }],
  "relatedArtifact" : [{
    "type" : "depends-on",
    "label" : "active_patients",
    "display" : "Active Patients view",
    "resource" : "https://sql-on-fhir.org/ig/Library/ActivePatientsView"
  },
  {
    "type" : "depends-on",
    "label" : "patient_address_view",
    "display" : "Patient address view",
    "resource" : "https://example.org/ViewDefinition/patient_address_view"
  }],
  "content" : [{
    "extension" : [{
      "url" : "https://sql-on-fhir.org/ig/StructureDefinition/sql-text",
      "valueString" : "SELECT\n  active_patients.patient_id,\n  active_patients.patient_name,\n  patient_address_view.city,\n  patient_address_view.state\nFROM active_patients\nJOIN patient_address_view\n  ON active_patients.patient_id = patient_address_view.patient_id"
    }],
    "contentType" : "application/sql",
    "data" : "U0VMRUNUCiAgYWN0aXZlX3BhdGllbnRzLnBhdGllbnRfaWQsCiAgYWN0aXZlX3BhdGllbnRzLnBhdGllbnRfbmFtZSwKICBwYXRpZW50X2FkZHJlc3Nfdmlldy5jaXR5LAogIHBhdGllbnRfYWRkcmVzc192aWV3LnN0YXRlCkZST00gYWN0aXZlX3BhdGllbnRzCkpPSU4gcGF0aWVudF9hZGRyZXNzX3ZpZXcKICBPTiBhY3RpdmVfcGF0aWVudHMucGF0aWVudF9pZCA9IHBhdGllbnRfYWRkcmVzc192aWV3LnBhdGllbnRfaWQ="
  }]
}