[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-nvidia-fhir-basics":3,"mdc--7xmjjm-key":34,"related-repo-nvidia-fhir-basics":3043,"related-org-nvidia-fhir-basics":3138},{"slug":4,"name":4,"fn":5,"description":6,"org":7,"tags":11,"stars":23,"repoUrl":24,"updatedAt":25,"license":26,"forks":27,"topics":28,"repo":29,"sourceUrl":32,"mdContent":33},"fhir-basics","query and parse FHIR R4 API resources","Teaches agents how FHIR R4 APIs work, what resources are available, how to query them with search parameters, and how to correctly parse all response formats including component Observations.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},"nvidia","NVIDIA","https:\u002F\u002Fpexgzepcugksgbtrxkhf.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Forg-logos\u002Fnvidia.png",[12,16,17,20],{"name":13,"slug":14,"type":15},"Healthcare","healthcare","tag",{"name":9,"slug":8,"type":15},{"name":18,"slug":19,"type":15},"FHIR","fhir",{"name":21,"slug":22,"type":15},"API Development","api-development",1144,"https:\u002F\u002Fgithub.com\u002FNVIDIA\u002Fdgx-spark-playbooks","2026-07-14T05:35:57.797226",null,249,[],{"repoUrl":24,"stars":23,"forks":27,"topics":30,"description":31},[],"Collection of step-by-step playbooks for setting up AI\u002FML workloads on NVIDIA DGX Spark devices with Blackwell architecture.","https:\u002F\u002Fgithub.com\u002FNVIDIA\u002Fdgx-spark-playbooks\u002Ftree\u002FHEAD\u002Fnvidia\u002Fstation-healthcare-agent\u002Fassets\u002Fskills\u002Ffhir-basics","---\nname: fhir-basics\ndescription: Teaches agents how FHIR R4 APIs work, what resources are available, how to query them with search parameters, and how to correctly parse all response formats including component Observations.\nmetadata:\n  openclaw:\n    requires:\n      bins: [\"python3\"]\n---\n\n# FHIR Data Retrieval\n\n**Important**: In this sandbox, run Python scripts with `python` (not `python3`). Use `subprocess.run([\"curl\", \"-sf\", url], capture_output=True, text=True)` for all FHIR HTTP calls — the `requests` library does NOT work through the sandbox proxy. Always parse the output with `json.loads()`.\n\nFHIR (Fast Healthcare Interoperability Resources) R4 is the standard API format mandated by the 21st Century Cures Act for US healthcare interoperability. ~70% of US hospitals expose FHIR R4 endpoints (ONC 2024). All queries use REST GET requests returning JSON Bundles.\n\n## Default FHIR Endpoint\n\nUnless the user specifies a different FHIR server, always use: `https:\u002F\u002Fr4.smarthealthit.org`\n\nThis is the SMART on FHIR public test server with synthetic (Synthea) patient data. No authentication required.\n\n**Query format for this server**: Use bare codes without system URIs. Example: `code=44054006` NOT `code=http:\u002F\u002Fsnomed.info\u002Fsct|44054006`. The test server does not support system-qualified code searches and will return empty results.\n\n## Authentication\n\n- **Public test servers** (e.g., `https:\u002F\u002Fr4.smarthealthit.org`): No authentication required. Synthetic data, real FHIR format.\n- **Production hospital endpoints**: Use SMART on FHIR OAuth2 flows. Requires a `client_id`, redirect URI, and scope negotiation. Access tokens are passed as `Authorization: Bearer {token}` headers.\n\n## Resource Endpoints and Search Parameters\n\n### Patient\n\n```\nGET \u002FPatient                              -- all patients (paginated)\nGET \u002FPatient?name=Smith                   -- search by family or given name\nGET \u002FPatient?name=John&name=Smith         -- search by given AND family name\nGET \u002FPatient?birthdate=1970-01-01         -- exact birthdate\nGET \u002FPatient?birthdate=ge1960-01-01&birthdate=le1970-12-31  -- date range\nGET \u002FPatient?gender=male                  -- filter by gender\nGET \u002FPatient\u002F{id}                         -- get a specific patient by ID\nGET \u002FPatient?_count=50                    -- control page size\n```\n\n### Condition (Diagnoses)\n\n```\nGET \u002FCondition?patient={id}                           -- all conditions for a patient\nGET \u002FCondition?patient={id}&clinical-status=active     -- only active conditions\nGET \u002FCondition?code={snomed_code}                      -- all patients with a condition (cohort query)\nGET \u002FCondition?code=44054006&_count=200                -- paginated cohort (bare code for test server)\n```\n\nFor the default test server (`r4.smarthealthit.org`), always use bare codes (e.g., `code=44054006`). Production servers may require the full system URI (`code=http:\u002F\u002Fsnomed.info\u002Fsct|44054006`).\n\n### Observation (Labs and Vitals)\n\n```\nGET \u002FObservation?patient={id}                            -- all observations\nGET \u002FObservation?patient={id}&code={loinc}               -- specific lab by LOINC\nGET \u002FObservation?patient={id}&code={loinc}&_sort=-date&_count=1  -- most recent only\nGET \u002FObservation?patient={id}&category=vital-signs       -- vitals only\nGET \u002FObservation?patient={id}&category=laboratory        -- labs only\nGET \u002FObservation?patient={id}&date=ge2023-01-01          -- after a date\n```\n\n### MedicationRequest (Prescriptions)\n\n```\nGET \u002FMedicationRequest?patient={id}                  -- all prescriptions\nGET \u002FMedicationRequest?patient={id}&status=active    -- current prescriptions only\nGET \u002FMedicationRequest?patient={id}&_count=100       -- increase page size\n```\n\n### Encounter (Visits)\n\n```\nGET \u002FEncounter?patient={id}                          -- all encounters\nGET \u002FEncounter?patient={id}&_sort=-date&_count=5     -- 5 most recent visits\nGET \u002FEncounter?patient={id}&type=office              -- office visits only\n```\n\n### DiagnosticReport (Lab Reports, Imaging)\n\n```\nGET \u002FDiagnosticReport?patient={id}                   -- all reports\nGET \u002FDiagnosticReport?patient={id}&category=LAB      -- lab reports\nGET \u002FDiagnosticReport?patient={id}&category=imaging  -- imaging reports\n```\n\n## Key LOINC Codes\n\n| LOINC | Lab\u002FVital | Notes |\n|-------|-----------|-------|\n| 4548-4 | Hemoglobin A1c (HbA1c) | Primary diabetes monitoring |\n| 2345-7 | Glucose | Fasting or random |\n| 2160-0 | Creatinine | Kidney function |\n| 33914-3 | eGFR (CKD-EPI) | Kidney function staging |\n| 2093-3 | Total Cholesterol | Lipid panel |\n| 2571-8 | Triglycerides | Lipid panel |\n| 2085-9 | HDL Cholesterol | Lipid panel |\n| 18262-6 | LDL Cholesterol | Lipid panel |\n| 85354-9 | Blood Pressure panel | Component observation (see below) |\n| 8480-6 | Systolic Blood Pressure | Component of BP panel, or standalone |\n| 8462-4 | Diastolic Blood Pressure | Component of BP panel, or standalone |\n| 42637-9 | BNP (B-type Natriuretic Peptide) | Heart failure marker |\n| 33762-6 | NT-proBNP | Heart failure marker (alternative to BNP) |\n| 6690-2 | WBC Count | Infection\u002Finflammation |\n| 718-7 | Hemoglobin | Anemia screening |\n| 2823-3 | Potassium | Electrolyte; critical for ACEi\u002FARB\u002FMRA monitoring |\n| 2951-2 | Sodium | Electrolyte |\n| 1742-6 | ALT | Liver function |\n| 14959-1 | Microalbumin\u002FCreatinine Ratio (urine) | Diabetic nephropathy screening |\n\n## Parsing FHIR JSON Responses\n\n### Bundle Structure\n\nEvery search returns a Bundle:\n```json\n{\n  \"resourceType\": \"Bundle\",\n  \"type\": \"searchset\",\n  \"total\": 42,\n  \"entry\": [ { \"resource\": { ... } }, ... ],\n  \"link\": [\n    { \"relation\": \"self\", \"url\": \"...\" },\n    { \"relation\": \"next\", \"url\": \"...\" }\n  ]\n}\n```\n\nAlways check `bundle.get('entry', [])` before iterating -- an empty result returns a Bundle with no `entry` key.\n\n### Patient Resource\n\n```python\npatient = entry['resource']\npatient_id = patient['id']\ngiven = patient['name'][0].get('given', [''])[0]\nfamily = patient['name'][0].get('family', '')\nfull_name = f\"{given} {family}\"\nbirth_date = patient.get('birthDate', 'Unknown')\ngender = patient.get('gender', 'Unknown')\n\n# Address (optional)\naddress = patient.get('address', [{}])[0]\ncity = address.get('city', '')\nstate = address.get('state', '')\n```\n\n### Condition Resource\n\n```python\ncondition = entry['resource']\n\n# Code -- check ALL coding entries, not just [0]\ncodings = condition.get('code', {}).get('coding', [])\nfor coding in codings:\n    system = coding.get('system', '')\n    code = coding.get('code', '')\n    display = coding.get('display', '')\n    if 'snomed' in system:\n        snomed_code = code\n    elif 'icd' in system.lower():\n        icd_code = code\n\n# Clinical status\nstatus_codings = condition.get('clinicalStatus', {}).get('coding', [])\nclinical_status = status_codings[0]['code'] if status_codings else 'unknown'\n# Values: \"active\", \"recurrence\", \"relapse\", \"inactive\", \"remission\", \"resolved\"\n\n# Onset\nonset = condition.get('onsetDateTime', condition.get('onsetPeriod', {}).get('start', 'Unknown'))\n\n# Verification status (confirmed, unconfirmed, provisional, differential, refuted)\nverification = condition.get('verificationStatus', {}).get('coding', [{}])[0].get('code', 'unknown')\n```\n\n### Observation Resource -- Simple (single value)\n\nMost labs return a single value in `valueQuantity`:\n```python\nobs = entry['resource']\nlab_name = obs['code']['coding'][0]['display']\nloinc_code = obs['code']['coding'][0]['code']\ndate = obs.get('effectiveDateTime', 'Unknown')\n\n# Value -- multiple possible formats\nif 'valueQuantity' in obs:\n    value = obs['valueQuantity']['value']\n    unit = obs['valueQuantity'].get('unit', '')\nelif 'valueString' in obs:\n    value = obs['valueString']    # qualitative result like \"negative\"\n    unit = ''\nelif 'valueCodeableConcept' in obs:\n    value = obs['valueCodeableConcept'].get('text', 'See coding')\n    unit = ''\nelse:\n    value = None  # check component (see below)\n\n# Reference range (from the lab, more accurate than general tables)\nref_ranges = obs.get('referenceRange', [])\nif ref_ranges:\n    low = ref_ranges[0].get('low', {}).get('value')\n    high = ref_ranges[0].get('high', {}).get('value')\n```\n\n### Observation Resource -- Component (Blood Pressure)\n\nBlood pressure in FHIR is typically a **component Observation** with LOINC `85354-9` (BP panel). Systolic and diastolic are nested inside `component[]`, NOT in `valueQuantity`:\n\n```python\nobs = entry['resource']\npanel_code = obs['code']['coding'][0]['code']\n\nif panel_code == '85354-9' or 'component' in obs:\n    systolic = None\n    diastolic = None\n    for comp in obs.get('component', []):\n        comp_code = comp['code']['coding'][0]['code']\n        if comp_code == '8480-6':  # systolic\n            systolic = comp['valueQuantity']['value']\n        elif comp_code == '8462-4':  # diastolic\n            diastolic = comp['valueQuantity']['value']\n```\n\n**Critical**: When querying for systolic BP (LOINC 8480-6), some FHIR servers return the panel Observation (85354-9) where systolic is inside `component`. Others return a standalone Observation with `valueQuantity`. Your code must handle both:\n\n```python\ndef get_bp(patient_id, base_url):\n    \"\"\"Get most recent blood pressure, handling both panel and standalone formats.\"\"\"\n    # Try panel first\n    r = fhir_get(\"Observation\",\n                     params={\"patient\": patient_id, \"code\": \"85354-9\",\n                             \"_sort\": \"-date\", \"_count\": \"1\"}).json()\n    if r.get('entry'):\n        obs = r['entry'][0]['resource']\n        systolic = diastolic = None\n        for comp in obs.get('component', []):\n            c = comp['code']['coding'][0]['code']\n            if c == '8480-6':\n                systolic = comp['valueQuantity']['value']\n            elif c == '8462-4':\n                diastolic = comp['valueQuantity']['value']\n        if systolic is not None:\n            return systolic, diastolic, obs.get('effectiveDateTime', 'Unknown')\n\n    # Fallback: standalone systolic\n    r = fhir_get(\"Observation\",\n                     params={\"patient\": patient_id, \"code\": \"8480-6\",\n                             \"_sort\": \"-date\", \"_count\": \"1\"}).json()\n    if r.get('entry'):\n        obs = r['entry'][0]['resource']\n        systolic = obs.get('valueQuantity', {}).get('value')\n        return systolic, None, obs.get('effectiveDateTime', 'Unknown')\n\n    return None, None, None\n```\n\n### MedicationRequest Resource\n\n```python\nmed = entry['resource']\n\n# Medication name -- check multiple locations\nmed_name = (\n    med.get('medicationCodeableConcept', {}).get('text')\n    or med.get('medicationCodeableConcept', {}).get('coding', [{}])[0].get('display')\n    or 'Unknown medication'\n)\n\n# Status\nstatus = med.get('status', 'unknown')  # active, on-hold, cancelled, completed, stopped\n\n# Dosage\ndosage_instructions = med.get('dosageInstruction', [{}])\ndosage_text = dosage_instructions[0].get('text', 'No dosage recorded') if dosage_instructions else 'No dosage recorded'\n\n# Authored date\nauthored = med.get('authoredOn', 'Unknown')\n```\n\n## Pagination\n\nFHIR responses default to 20 results per page (server-dependent). Always handle pagination for cohort queries:\n\n```python\ndef get_all_pages(url, params=None):\n    \"\"\"Fetch all pages of a FHIR Bundle search.\"\"\"\n    all_entries = []\n    if params:\n        r = fhir_get(url, params)\n    else:\n        r = fhir_get(url)\n    all_entries.extend(r.get('entry', []))\n\n    # Follow 'next' links\n    while True:\n        next_url = None\n        for link in r.get('link', []):\n            if link.get('relation') == 'next':\n                next_url = link['url']\n                break\n        if not next_url:\n            break\n        r = fhir_get(next_url)\n        all_entries.extend(r.get('entry', []))\n\n    return all_entries\n```\n\nFor large cohorts, set `_count=200` to reduce the number of pages. The SMART test server caps at ~1000 results regardless.\n\n## Batched and Multi-Patient Queries (CRITICAL for Performance)\n\n**Never loop over patients making individual FHIR calls.** Each HTTP call through the sandbox proxy adds 1-3 seconds of latency. For 24 patients x 4 LOINC codes, that is 96 sequential calls = 5+ minutes. Instead, fetch all observations for a LOINC code in one request and filter client-side in Python.\n\n### Pattern 1: Fetch all Observations for a LOINC code (preferred)\n\nQuery Observation by code alone (no patient filter) to get results for ALL patients in one call:\n\n```\nGET \u002FObservation?code={loinc}&_count=500&_sort=-date\n```\n\nThen filter in Python by patient reference:\n\n```python\ndef get_all_obs_for_code(loinc_code, count=500):\n    \"\"\"Fetch ALL observations for a LOINC code across all patients in one call.\"\"\"\n    entries = get_all_pages(\"Observation\", {\"code\": loinc_code, \"_count\": str(count), \"_sort\": \"-date\"})\n    # Build dict: patient_id -> list of observations (already sorted newest first)\n    by_patient = {}\n    for e in entries:\n        obs = e['resource']\n        ref = obs.get('subject', {}).get('reference', '')\n        pid = ref.split('\u002F')[-1] if '\u002F' in ref else ref\n        if pid not in by_patient:\n            by_patient[pid] = obs  # keep only the most recent per patient\n    return by_patient\n```\n\n### Pattern 2: Multi-patient query parameter\n\nSome FHIR servers accept comma-separated patient references:\n\n```\nGET \u002FObservation?patient=Patient\u002FX,Patient\u002FY,Patient\u002FZ&code={loinc}&_count=500\n```\n\nThe SMART test server supports this. Use it when you have a specific list of patient IDs and want to avoid fetching observations for patients not in your cohort.\n\n### Pattern 3: FHIR Batch Bundle\n\nFor heterogeneous queries (different resource types per patient), POST a Bundle of type `batch` to the server root:\n\n```python\ndef fhir_batch(requests_list):\n    \"\"\"Execute multiple FHIR queries in a single HTTP call using a batch Bundle.\n    requests_list: list of {\"method\": \"GET\", \"url\": \"Observation?patient=X&code=Y\"} dicts.\n    \"\"\"\n    bundle = {\n        \"resourceType\": \"Bundle\",\n        \"type\": \"batch\",\n        \"entry\": [{\"request\": req} for req in requests_list]\n    }\n    import subprocess, json\n    r = subprocess.run(\n        [\"curl\", \"-sf\", \"--max-time\", \"60\",\n         \"-X\", \"POST\", \"-H\", \"Content-Type: application\u002Ffhir+json\",\n         \"-d\", json.dumps(bundle), f\"{BASE_URL}\"],\n        capture_output=True, text=True, timeout=65\n    )\n    if r.returncode != 0 or not r.stdout.strip():\n        return []\n    result = json.loads(r.stdout)\n    return result.get('entry', [])\n```\n\n### When to use which pattern\n\n| Scenario | Pattern | Why |\n|----------|---------|-----|\n| Labs for a cohort (same LOINC, many patients) | Pattern 1: code-only query | One call gets everything; filter in Python |\n| Labs for a specific patient list | Pattern 2: comma-separated patients | Scoped to your cohort; one call |\n| Mixed data (labs + meds + conditions per patient) | Pattern 3: batch Bundle | Multiple queries, single HTTP round-trip |\n| Single patient lookup | Individual GET | Fine for 1-2 patients |\n\n## Bulk FHIR (Production-Scale)\n\nFor production population health workflows (not used in this demo, but important context): FHIR Bulk Data Access (SMART\u002FHL7) allows exporting entire patient populations as NDJSON files via an async `$export` operation. This is how real quality measure engines work at scale -- they don't query patient-by-patient. The demo uses individual queries for clarity and because the public test server doesn't support Bulk FHIR.\n\n## Error Handling\n\n- Always check `response.status_code` before parsing JSON\n- Check if `entry` exists in the response before iterating: `bundle.get('entry', [])`\n- Some fields may be missing -- use `.get()` with sensible defaults\n- Never fabricate data. If a field is absent, report \"Not recorded\"\n- Handle `OperationOutcome` responses (FHIR error format):\n  ```python\n  if response.json().get('resourceType') == 'OperationOutcome':\n      issues = response.json().get('issue', [])\n      error_msg = issues[0].get('diagnostics', 'Unknown FHIR error') if issues else 'Unknown error'\n  ```\n- Rate limiting: The public SMART test server has no rate limits, but production endpoints may. Add a small delay (0.1-0.5s) between calls in tight loops\n- Timeout: Use `--max-time 30` with curl; FHIR servers can be slow under load\n",{"data":35,"body":41},{"name":4,"description":6,"metadata":36},{"openclaw":37},{"requires":38},{"bins":39},[40],"python3",{"type":42,"children":43},"root",[44,53,105,110,117,128,133,159,165,213,219,226,238,244,253,280,286,295,301,310,316,325,331,340,346,717,723,729,734,1144,1164,1170,1277,1283,1481,1487,1499,1687,1693,1726,1827,1852,2082,2088,2235,2241,2246,2427,2440,2446,2456,2462,2467,2476,2481,2584,2590,2595,2604,2609,2615,2628,2795,2801,2900,2906,2919,2925,3037],{"type":45,"tag":46,"props":47,"children":49},"element","h1",{"id":48},"fhir-data-retrieval",[50],{"type":51,"value":52},"text","FHIR Data Retrieval",{"type":45,"tag":54,"props":55,"children":56},"p",{},[57,63,65,72,74,79,81,87,89,95,97,103],{"type":45,"tag":58,"props":59,"children":60},"strong",{},[61],{"type":51,"value":62},"Important",{"type":51,"value":64},": In this sandbox, run Python scripts with ",{"type":45,"tag":66,"props":67,"children":69},"code",{"className":68},[],[70],{"type":51,"value":71},"python",{"type":51,"value":73}," (not ",{"type":45,"tag":66,"props":75,"children":77},{"className":76},[],[78],{"type":51,"value":40},{"type":51,"value":80},"). Use ",{"type":45,"tag":66,"props":82,"children":84},{"className":83},[],[85],{"type":51,"value":86},"subprocess.run([\"curl\", \"-sf\", url], capture_output=True, text=True)",{"type":51,"value":88}," for all FHIR HTTP calls — the ",{"type":45,"tag":66,"props":90,"children":92},{"className":91},[],[93],{"type":51,"value":94},"requests",{"type":51,"value":96}," library does NOT work through the sandbox proxy. Always parse the output with ",{"type":45,"tag":66,"props":98,"children":100},{"className":99},[],[101],{"type":51,"value":102},"json.loads()",{"type":51,"value":104},".",{"type":45,"tag":54,"props":106,"children":107},{},[108],{"type":51,"value":109},"FHIR (Fast Healthcare Interoperability Resources) R4 is the standard API format mandated by the 21st Century Cures Act for US healthcare interoperability. ~70% of US hospitals expose FHIR R4 endpoints (ONC 2024). All queries use REST GET requests returning JSON Bundles.",{"type":45,"tag":111,"props":112,"children":114},"h2",{"id":113},"default-fhir-endpoint",[115],{"type":51,"value":116},"Default FHIR Endpoint",{"type":45,"tag":54,"props":118,"children":119},{},[120,122],{"type":51,"value":121},"Unless the user specifies a different FHIR server, always use: ",{"type":45,"tag":66,"props":123,"children":125},{"className":124},[],[126],{"type":51,"value":127},"https:\u002F\u002Fr4.smarthealthit.org",{"type":45,"tag":54,"props":129,"children":130},{},[131],{"type":51,"value":132},"This is the SMART on FHIR public test server with synthetic (Synthea) patient data. No authentication required.",{"type":45,"tag":54,"props":134,"children":135},{},[136,141,143,149,151,157],{"type":45,"tag":58,"props":137,"children":138},{},[139],{"type":51,"value":140},"Query format for this server",{"type":51,"value":142},": Use bare codes without system URIs. Example: ",{"type":45,"tag":66,"props":144,"children":146},{"className":145},[],[147],{"type":51,"value":148},"code=44054006",{"type":51,"value":150}," NOT ",{"type":45,"tag":66,"props":152,"children":154},{"className":153},[],[155],{"type":51,"value":156},"code=http:\u002F\u002Fsnomed.info\u002Fsct|44054006",{"type":51,"value":158},". The test server does not support system-qualified code searches and will return empty results.",{"type":45,"tag":111,"props":160,"children":162},{"id":161},"authentication",[163],{"type":51,"value":164},"Authentication",{"type":45,"tag":166,"props":167,"children":168},"ul",{},[169,187],{"type":45,"tag":170,"props":171,"children":172},"li",{},[173,178,180,185],{"type":45,"tag":58,"props":174,"children":175},{},[176],{"type":51,"value":177},"Public test servers",{"type":51,"value":179}," (e.g., ",{"type":45,"tag":66,"props":181,"children":183},{"className":182},[],[184],{"type":51,"value":127},{"type":51,"value":186},"): No authentication required. Synthetic data, real FHIR format.",{"type":45,"tag":170,"props":188,"children":189},{},[190,195,197,203,205,211],{"type":45,"tag":58,"props":191,"children":192},{},[193],{"type":51,"value":194},"Production hospital endpoints",{"type":51,"value":196},": Use SMART on FHIR OAuth2 flows. Requires a ",{"type":45,"tag":66,"props":198,"children":200},{"className":199},[],[201],{"type":51,"value":202},"client_id",{"type":51,"value":204},", redirect URI, and scope negotiation. Access tokens are passed as ",{"type":45,"tag":66,"props":206,"children":208},{"className":207},[],[209],{"type":51,"value":210},"Authorization: Bearer {token}",{"type":51,"value":212}," headers.",{"type":45,"tag":111,"props":214,"children":216},{"id":215},"resource-endpoints-and-search-parameters",[217],{"type":51,"value":218},"Resource Endpoints and Search Parameters",{"type":45,"tag":220,"props":221,"children":223},"h3",{"id":222},"patient",[224],{"type":51,"value":225},"Patient",{"type":45,"tag":227,"props":228,"children":232},"pre",{"className":229,"code":231,"language":51},[230],"language-text","GET \u002FPatient                              -- all patients (paginated)\nGET \u002FPatient?name=Smith                   -- search by family or given name\nGET \u002FPatient?name=John&name=Smith         -- search by given AND family name\nGET \u002FPatient?birthdate=1970-01-01         -- exact birthdate\nGET \u002FPatient?birthdate=ge1960-01-01&birthdate=le1970-12-31  -- date range\nGET \u002FPatient?gender=male                  -- filter by gender\nGET \u002FPatient\u002F{id}                         -- get a specific patient by ID\nGET \u002FPatient?_count=50                    -- control page size\n",[233],{"type":45,"tag":66,"props":234,"children":236},{"__ignoreMap":235},"",[237],{"type":51,"value":231},{"type":45,"tag":220,"props":239,"children":241},{"id":240},"condition-diagnoses",[242],{"type":51,"value":243},"Condition (Diagnoses)",{"type":45,"tag":227,"props":245,"children":248},{"className":246,"code":247,"language":51},[230],"GET \u002FCondition?patient={id}                           -- all conditions for a patient\nGET \u002FCondition?patient={id}&clinical-status=active     -- only active conditions\nGET \u002FCondition?code={snomed_code}                      -- all patients with a condition (cohort query)\nGET \u002FCondition?code=44054006&_count=200                -- paginated cohort (bare code for test server)\n",[249],{"type":45,"tag":66,"props":250,"children":251},{"__ignoreMap":235},[252],{"type":51,"value":247},{"type":45,"tag":54,"props":254,"children":255},{},[256,258,264,266,271,273,278],{"type":51,"value":257},"For the default test server (",{"type":45,"tag":66,"props":259,"children":261},{"className":260},[],[262],{"type":51,"value":263},"r4.smarthealthit.org",{"type":51,"value":265},"), always use bare codes (e.g., ",{"type":45,"tag":66,"props":267,"children":269},{"className":268},[],[270],{"type":51,"value":148},{"type":51,"value":272},"). Production servers may require the full system URI (",{"type":45,"tag":66,"props":274,"children":276},{"className":275},[],[277],{"type":51,"value":156},{"type":51,"value":279},").",{"type":45,"tag":220,"props":281,"children":283},{"id":282},"observation-labs-and-vitals",[284],{"type":51,"value":285},"Observation (Labs and Vitals)",{"type":45,"tag":227,"props":287,"children":290},{"className":288,"code":289,"language":51},[230],"GET \u002FObservation?patient={id}                            -- all observations\nGET \u002FObservation?patient={id}&code={loinc}               -- specific lab by LOINC\nGET \u002FObservation?patient={id}&code={loinc}&_sort=-date&_count=1  -- most recent only\nGET \u002FObservation?patient={id}&category=vital-signs       -- vitals only\nGET \u002FObservation?patient={id}&category=laboratory        -- labs only\nGET \u002FObservation?patient={id}&date=ge2023-01-01          -- after a date\n",[291],{"type":45,"tag":66,"props":292,"children":293},{"__ignoreMap":235},[294],{"type":51,"value":289},{"type":45,"tag":220,"props":296,"children":298},{"id":297},"medicationrequest-prescriptions",[299],{"type":51,"value":300},"MedicationRequest (Prescriptions)",{"type":45,"tag":227,"props":302,"children":305},{"className":303,"code":304,"language":51},[230],"GET \u002FMedicationRequest?patient={id}                  -- all prescriptions\nGET \u002FMedicationRequest?patient={id}&status=active    -- current prescriptions only\nGET \u002FMedicationRequest?patient={id}&_count=100       -- increase page size\n",[306],{"type":45,"tag":66,"props":307,"children":308},{"__ignoreMap":235},[309],{"type":51,"value":304},{"type":45,"tag":220,"props":311,"children":313},{"id":312},"encounter-visits",[314],{"type":51,"value":315},"Encounter (Visits)",{"type":45,"tag":227,"props":317,"children":320},{"className":318,"code":319,"language":51},[230],"GET \u002FEncounter?patient={id}                          -- all encounters\nGET \u002FEncounter?patient={id}&_sort=-date&_count=5     -- 5 most recent visits\nGET \u002FEncounter?patient={id}&type=office              -- office visits only\n",[321],{"type":45,"tag":66,"props":322,"children":323},{"__ignoreMap":235},[324],{"type":51,"value":319},{"type":45,"tag":220,"props":326,"children":328},{"id":327},"diagnosticreport-lab-reports-imaging",[329],{"type":51,"value":330},"DiagnosticReport (Lab Reports, Imaging)",{"type":45,"tag":227,"props":332,"children":335},{"className":333,"code":334,"language":51},[230],"GET \u002FDiagnosticReport?patient={id}                   -- all reports\nGET \u002FDiagnosticReport?patient={id}&category=LAB      -- lab reports\nGET \u002FDiagnosticReport?patient={id}&category=imaging  -- imaging reports\n",[336],{"type":45,"tag":66,"props":337,"children":338},{"__ignoreMap":235},[339],{"type":51,"value":334},{"type":45,"tag":111,"props":341,"children":343},{"id":342},"key-loinc-codes",[344],{"type":51,"value":345},"Key LOINC Codes",{"type":45,"tag":347,"props":348,"children":349},"table",{},[350,374],{"type":45,"tag":351,"props":352,"children":353},"thead",{},[354],{"type":45,"tag":355,"props":356,"children":357},"tr",{},[358,364,369],{"type":45,"tag":359,"props":360,"children":361},"th",{},[362],{"type":51,"value":363},"LOINC",{"type":45,"tag":359,"props":365,"children":366},{},[367],{"type":51,"value":368},"Lab\u002FVital",{"type":45,"tag":359,"props":370,"children":371},{},[372],{"type":51,"value":373},"Notes",{"type":45,"tag":375,"props":376,"children":377},"tbody",{},[378,397,415,433,451,469,486,503,520,538,556,573,591,609,627,645,663,681,699],{"type":45,"tag":355,"props":379,"children":380},{},[381,387,392],{"type":45,"tag":382,"props":383,"children":384},"td",{},[385],{"type":51,"value":386},"4548-4",{"type":45,"tag":382,"props":388,"children":389},{},[390],{"type":51,"value":391},"Hemoglobin A1c (HbA1c)",{"type":45,"tag":382,"props":393,"children":394},{},[395],{"type":51,"value":396},"Primary diabetes monitoring",{"type":45,"tag":355,"props":398,"children":399},{},[400,405,410],{"type":45,"tag":382,"props":401,"children":402},{},[403],{"type":51,"value":404},"2345-7",{"type":45,"tag":382,"props":406,"children":407},{},[408],{"type":51,"value":409},"Glucose",{"type":45,"tag":382,"props":411,"children":412},{},[413],{"type":51,"value":414},"Fasting or random",{"type":45,"tag":355,"props":416,"children":417},{},[418,423,428],{"type":45,"tag":382,"props":419,"children":420},{},[421],{"type":51,"value":422},"2160-0",{"type":45,"tag":382,"props":424,"children":425},{},[426],{"type":51,"value":427},"Creatinine",{"type":45,"tag":382,"props":429,"children":430},{},[431],{"type":51,"value":432},"Kidney function",{"type":45,"tag":355,"props":434,"children":435},{},[436,441,446],{"type":45,"tag":382,"props":437,"children":438},{},[439],{"type":51,"value":440},"33914-3",{"type":45,"tag":382,"props":442,"children":443},{},[444],{"type":51,"value":445},"eGFR (CKD-EPI)",{"type":45,"tag":382,"props":447,"children":448},{},[449],{"type":51,"value":450},"Kidney function staging",{"type":45,"tag":355,"props":452,"children":453},{},[454,459,464],{"type":45,"tag":382,"props":455,"children":456},{},[457],{"type":51,"value":458},"2093-3",{"type":45,"tag":382,"props":460,"children":461},{},[462],{"type":51,"value":463},"Total Cholesterol",{"type":45,"tag":382,"props":465,"children":466},{},[467],{"type":51,"value":468},"Lipid panel",{"type":45,"tag":355,"props":470,"children":471},{},[472,477,482],{"type":45,"tag":382,"props":473,"children":474},{},[475],{"type":51,"value":476},"2571-8",{"type":45,"tag":382,"props":478,"children":479},{},[480],{"type":51,"value":481},"Triglycerides",{"type":45,"tag":382,"props":483,"children":484},{},[485],{"type":51,"value":468},{"type":45,"tag":355,"props":487,"children":488},{},[489,494,499],{"type":45,"tag":382,"props":490,"children":491},{},[492],{"type":51,"value":493},"2085-9",{"type":45,"tag":382,"props":495,"children":496},{},[497],{"type":51,"value":498},"HDL Cholesterol",{"type":45,"tag":382,"props":500,"children":501},{},[502],{"type":51,"value":468},{"type":45,"tag":355,"props":504,"children":505},{},[506,511,516],{"type":45,"tag":382,"props":507,"children":508},{},[509],{"type":51,"value":510},"18262-6",{"type":45,"tag":382,"props":512,"children":513},{},[514],{"type":51,"value":515},"LDL Cholesterol",{"type":45,"tag":382,"props":517,"children":518},{},[519],{"type":51,"value":468},{"type":45,"tag":355,"props":521,"children":522},{},[523,528,533],{"type":45,"tag":382,"props":524,"children":525},{},[526],{"type":51,"value":527},"85354-9",{"type":45,"tag":382,"props":529,"children":530},{},[531],{"type":51,"value":532},"Blood Pressure panel",{"type":45,"tag":382,"props":534,"children":535},{},[536],{"type":51,"value":537},"Component observation (see below)",{"type":45,"tag":355,"props":539,"children":540},{},[541,546,551],{"type":45,"tag":382,"props":542,"children":543},{},[544],{"type":51,"value":545},"8480-6",{"type":45,"tag":382,"props":547,"children":548},{},[549],{"type":51,"value":550},"Systolic Blood Pressure",{"type":45,"tag":382,"props":552,"children":553},{},[554],{"type":51,"value":555},"Component of BP panel, or standalone",{"type":45,"tag":355,"props":557,"children":558},{},[559,564,569],{"type":45,"tag":382,"props":560,"children":561},{},[562],{"type":51,"value":563},"8462-4",{"type":45,"tag":382,"props":565,"children":566},{},[567],{"type":51,"value":568},"Diastolic Blood Pressure",{"type":45,"tag":382,"props":570,"children":571},{},[572],{"type":51,"value":555},{"type":45,"tag":355,"props":574,"children":575},{},[576,581,586],{"type":45,"tag":382,"props":577,"children":578},{},[579],{"type":51,"value":580},"42637-9",{"type":45,"tag":382,"props":582,"children":583},{},[584],{"type":51,"value":585},"BNP (B-type Natriuretic Peptide)",{"type":45,"tag":382,"props":587,"children":588},{},[589],{"type":51,"value":590},"Heart failure marker",{"type":45,"tag":355,"props":592,"children":593},{},[594,599,604],{"type":45,"tag":382,"props":595,"children":596},{},[597],{"type":51,"value":598},"33762-6",{"type":45,"tag":382,"props":600,"children":601},{},[602],{"type":51,"value":603},"NT-proBNP",{"type":45,"tag":382,"props":605,"children":606},{},[607],{"type":51,"value":608},"Heart failure marker (alternative to BNP)",{"type":45,"tag":355,"props":610,"children":611},{},[612,617,622],{"type":45,"tag":382,"props":613,"children":614},{},[615],{"type":51,"value":616},"6690-2",{"type":45,"tag":382,"props":618,"children":619},{},[620],{"type":51,"value":621},"WBC Count",{"type":45,"tag":382,"props":623,"children":624},{},[625],{"type":51,"value":626},"Infection\u002Finflammation",{"type":45,"tag":355,"props":628,"children":629},{},[630,635,640],{"type":45,"tag":382,"props":631,"children":632},{},[633],{"type":51,"value":634},"718-7",{"type":45,"tag":382,"props":636,"children":637},{},[638],{"type":51,"value":639},"Hemoglobin",{"type":45,"tag":382,"props":641,"children":642},{},[643],{"type":51,"value":644},"Anemia screening",{"type":45,"tag":355,"props":646,"children":647},{},[648,653,658],{"type":45,"tag":382,"props":649,"children":650},{},[651],{"type":51,"value":652},"2823-3",{"type":45,"tag":382,"props":654,"children":655},{},[656],{"type":51,"value":657},"Potassium",{"type":45,"tag":382,"props":659,"children":660},{},[661],{"type":51,"value":662},"Electrolyte; critical for ACEi\u002FARB\u002FMRA monitoring",{"type":45,"tag":355,"props":664,"children":665},{},[666,671,676],{"type":45,"tag":382,"props":667,"children":668},{},[669],{"type":51,"value":670},"2951-2",{"type":45,"tag":382,"props":672,"children":673},{},[674],{"type":51,"value":675},"Sodium",{"type":45,"tag":382,"props":677,"children":678},{},[679],{"type":51,"value":680},"Electrolyte",{"type":45,"tag":355,"props":682,"children":683},{},[684,689,694],{"type":45,"tag":382,"props":685,"children":686},{},[687],{"type":51,"value":688},"1742-6",{"type":45,"tag":382,"props":690,"children":691},{},[692],{"type":51,"value":693},"ALT",{"type":45,"tag":382,"props":695,"children":696},{},[697],{"type":51,"value":698},"Liver function",{"type":45,"tag":355,"props":700,"children":701},{},[702,707,712],{"type":45,"tag":382,"props":703,"children":704},{},[705],{"type":51,"value":706},"14959-1",{"type":45,"tag":382,"props":708,"children":709},{},[710],{"type":51,"value":711},"Microalbumin\u002FCreatinine Ratio (urine)",{"type":45,"tag":382,"props":713,"children":714},{},[715],{"type":51,"value":716},"Diabetic nephropathy screening",{"type":45,"tag":111,"props":718,"children":720},{"id":719},"parsing-fhir-json-responses",[721],{"type":51,"value":722},"Parsing FHIR JSON Responses",{"type":45,"tag":220,"props":724,"children":726},{"id":725},"bundle-structure",[727],{"type":51,"value":728},"Bundle Structure",{"type":45,"tag":54,"props":730,"children":731},{},[732],{"type":51,"value":733},"Every search returns a Bundle:",{"type":45,"tag":227,"props":735,"children":739},{"className":736,"code":737,"language":738,"meta":235,"style":235},"language-json shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","{\n  \"resourceType\": \"Bundle\",\n  \"type\": \"searchset\",\n  \"total\": 42,\n  \"entry\": [ { \"resource\": { ... } }, ... ],\n  \"link\": [\n    { \"relation\": \"self\", \"url\": \"...\" },\n    { \"relation\": \"next\", \"url\": \"...\" }\n  ]\n}\n","json",[740],{"type":45,"tag":66,"props":741,"children":742},{"__ignoreMap":235},[743,755,800,838,869,947,973,1052,1126,1135],{"type":45,"tag":744,"props":745,"children":748},"span",{"class":746,"line":747},"line",1,[749],{"type":45,"tag":744,"props":750,"children":752},{"style":751},"--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF",[753],{"type":51,"value":754},"{\n",{"type":45,"tag":744,"props":756,"children":758},{"class":746,"line":757},2,[759,764,770,775,780,785,791,795],{"type":45,"tag":744,"props":760,"children":761},{"style":751},[762],{"type":51,"value":763},"  \"",{"type":45,"tag":744,"props":765,"children":767},{"style":766},"--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA",[768],{"type":51,"value":769},"resourceType",{"type":45,"tag":744,"props":771,"children":772},{"style":751},[773],{"type":51,"value":774},"\"",{"type":45,"tag":744,"props":776,"children":777},{"style":751},[778],{"type":51,"value":779},":",{"type":45,"tag":744,"props":781,"children":782},{"style":751},[783],{"type":51,"value":784}," \"",{"type":45,"tag":744,"props":786,"children":788},{"style":787},"--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D",[789],{"type":51,"value":790},"Bundle",{"type":45,"tag":744,"props":792,"children":793},{"style":751},[794],{"type":51,"value":774},{"type":45,"tag":744,"props":796,"children":797},{"style":751},[798],{"type":51,"value":799},",\n",{"type":45,"tag":744,"props":801,"children":803},{"class":746,"line":802},3,[804,808,813,817,821,825,830,834],{"type":45,"tag":744,"props":805,"children":806},{"style":751},[807],{"type":51,"value":763},{"type":45,"tag":744,"props":809,"children":810},{"style":766},[811],{"type":51,"value":812},"type",{"type":45,"tag":744,"props":814,"children":815},{"style":751},[816],{"type":51,"value":774},{"type":45,"tag":744,"props":818,"children":819},{"style":751},[820],{"type":51,"value":779},{"type":45,"tag":744,"props":822,"children":823},{"style":751},[824],{"type":51,"value":784},{"type":45,"tag":744,"props":826,"children":827},{"style":787},[828],{"type":51,"value":829},"searchset",{"type":45,"tag":744,"props":831,"children":832},{"style":751},[833],{"type":51,"value":774},{"type":45,"tag":744,"props":835,"children":836},{"style":751},[837],{"type":51,"value":799},{"type":45,"tag":744,"props":839,"children":841},{"class":746,"line":840},4,[842,846,851,855,859,865],{"type":45,"tag":744,"props":843,"children":844},{"style":751},[845],{"type":51,"value":763},{"type":45,"tag":744,"props":847,"children":848},{"style":766},[849],{"type":51,"value":850},"total",{"type":45,"tag":744,"props":852,"children":853},{"style":751},[854],{"type":51,"value":774},{"type":45,"tag":744,"props":856,"children":857},{"style":751},[858],{"type":51,"value":779},{"type":45,"tag":744,"props":860,"children":862},{"style":861},"--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C",[863],{"type":51,"value":864}," 42",{"type":45,"tag":744,"props":866,"children":867},{"style":751},[868],{"type":51,"value":799},{"type":45,"tag":744,"props":870,"children":872},{"class":746,"line":871},5,[873,877,882,886,890,895,900,904,910,914,918,922,928,933,938,942],{"type":45,"tag":744,"props":874,"children":875},{"style":751},[876],{"type":51,"value":763},{"type":45,"tag":744,"props":878,"children":879},{"style":766},[880],{"type":51,"value":881},"entry",{"type":45,"tag":744,"props":883,"children":884},{"style":751},[885],{"type":51,"value":774},{"type":45,"tag":744,"props":887,"children":888},{"style":751},[889],{"type":51,"value":779},{"type":45,"tag":744,"props":891,"children":892},{"style":751},[893],{"type":51,"value":894}," [",{"type":45,"tag":744,"props":896,"children":897},{"style":751},[898],{"type":51,"value":899}," {",{"type":45,"tag":744,"props":901,"children":902},{"style":751},[903],{"type":51,"value":784},{"type":45,"tag":744,"props":905,"children":907},{"style":906},"--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B",[908],{"type":51,"value":909},"resource",{"type":45,"tag":744,"props":911,"children":912},{"style":751},[913],{"type":51,"value":774},{"type":45,"tag":744,"props":915,"children":916},{"style":751},[917],{"type":51,"value":779},{"type":45,"tag":744,"props":919,"children":920},{"style":751},[921],{"type":51,"value":899},{"type":45,"tag":744,"props":923,"children":925},{"style":924},"--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8",[926],{"type":51,"value":927}," ... ",{"type":45,"tag":744,"props":929,"children":930},{"style":751},[931],{"type":51,"value":932},"}",{"type":45,"tag":744,"props":934,"children":935},{"style":751},[936],{"type":51,"value":937}," },",{"type":45,"tag":744,"props":939,"children":940},{"style":924},[941],{"type":51,"value":927},{"type":45,"tag":744,"props":943,"children":944},{"style":751},[945],{"type":51,"value":946},"],\n",{"type":45,"tag":744,"props":948,"children":950},{"class":746,"line":949},6,[951,955,960,964,968],{"type":45,"tag":744,"props":952,"children":953},{"style":751},[954],{"type":51,"value":763},{"type":45,"tag":744,"props":956,"children":957},{"style":766},[958],{"type":51,"value":959},"link",{"type":45,"tag":744,"props":961,"children":962},{"style":751},[963],{"type":51,"value":774},{"type":45,"tag":744,"props":965,"children":966},{"style":751},[967],{"type":51,"value":779},{"type":45,"tag":744,"props":969,"children":970},{"style":751},[971],{"type":51,"value":972}," [\n",{"type":45,"tag":744,"props":974,"children":976},{"class":746,"line":975},7,[977,982,986,991,995,999,1003,1008,1012,1017,1021,1026,1030,1034,1038,1043,1047],{"type":45,"tag":744,"props":978,"children":979},{"style":751},[980],{"type":51,"value":981},"    {",{"type":45,"tag":744,"props":983,"children":984},{"style":751},[985],{"type":51,"value":784},{"type":45,"tag":744,"props":987,"children":988},{"style":906},[989],{"type":51,"value":990},"relation",{"type":45,"tag":744,"props":992,"children":993},{"style":751},[994],{"type":51,"value":774},{"type":45,"tag":744,"props":996,"children":997},{"style":751},[998],{"type":51,"value":779},{"type":45,"tag":744,"props":1000,"children":1001},{"style":751},[1002],{"type":51,"value":784},{"type":45,"tag":744,"props":1004,"children":1005},{"style":787},[1006],{"type":51,"value":1007},"self",{"type":45,"tag":744,"props":1009,"children":1010},{"style":751},[1011],{"type":51,"value":774},{"type":45,"tag":744,"props":1013,"children":1014},{"style":751},[1015],{"type":51,"value":1016},",",{"type":45,"tag":744,"props":1018,"children":1019},{"style":751},[1020],{"type":51,"value":784},{"type":45,"tag":744,"props":1022,"children":1023},{"style":906},[1024],{"type":51,"value":1025},"url",{"type":45,"tag":744,"props":1027,"children":1028},{"style":751},[1029],{"type":51,"value":774},{"type":45,"tag":744,"props":1031,"children":1032},{"style":751},[1033],{"type":51,"value":779},{"type":45,"tag":744,"props":1035,"children":1036},{"style":751},[1037],{"type":51,"value":784},{"type":45,"tag":744,"props":1039,"children":1040},{"style":787},[1041],{"type":51,"value":1042},"...",{"type":45,"tag":744,"props":1044,"children":1045},{"style":751},[1046],{"type":51,"value":774},{"type":45,"tag":744,"props":1048,"children":1049},{"style":751},[1050],{"type":51,"value":1051}," },\n",{"type":45,"tag":744,"props":1053,"children":1055},{"class":746,"line":1054},8,[1056,1060,1064,1068,1072,1076,1080,1085,1089,1093,1097,1101,1105,1109,1113,1117,1121],{"type":45,"tag":744,"props":1057,"children":1058},{"style":751},[1059],{"type":51,"value":981},{"type":45,"tag":744,"props":1061,"children":1062},{"style":751},[1063],{"type":51,"value":784},{"type":45,"tag":744,"props":1065,"children":1066},{"style":906},[1067],{"type":51,"value":990},{"type":45,"tag":744,"props":1069,"children":1070},{"style":751},[1071],{"type":51,"value":774},{"type":45,"tag":744,"props":1073,"children":1074},{"style":751},[1075],{"type":51,"value":779},{"type":45,"tag":744,"props":1077,"children":1078},{"style":751},[1079],{"type":51,"value":784},{"type":45,"tag":744,"props":1081,"children":1082},{"style":787},[1083],{"type":51,"value":1084},"next",{"type":45,"tag":744,"props":1086,"children":1087},{"style":751},[1088],{"type":51,"value":774},{"type":45,"tag":744,"props":1090,"children":1091},{"style":751},[1092],{"type":51,"value":1016},{"type":45,"tag":744,"props":1094,"children":1095},{"style":751},[1096],{"type":51,"value":784},{"type":45,"tag":744,"props":1098,"children":1099},{"style":906},[1100],{"type":51,"value":1025},{"type":45,"tag":744,"props":1102,"children":1103},{"style":751},[1104],{"type":51,"value":774},{"type":45,"tag":744,"props":1106,"children":1107},{"style":751},[1108],{"type":51,"value":779},{"type":45,"tag":744,"props":1110,"children":1111},{"style":751},[1112],{"type":51,"value":784},{"type":45,"tag":744,"props":1114,"children":1115},{"style":787},[1116],{"type":51,"value":1042},{"type":45,"tag":744,"props":1118,"children":1119},{"style":751},[1120],{"type":51,"value":774},{"type":45,"tag":744,"props":1122,"children":1123},{"style":751},[1124],{"type":51,"value":1125}," }\n",{"type":45,"tag":744,"props":1127,"children":1129},{"class":746,"line":1128},9,[1130],{"type":45,"tag":744,"props":1131,"children":1132},{"style":751},[1133],{"type":51,"value":1134},"  ]\n",{"type":45,"tag":744,"props":1136,"children":1138},{"class":746,"line":1137},10,[1139],{"type":45,"tag":744,"props":1140,"children":1141},{"style":751},[1142],{"type":51,"value":1143},"}\n",{"type":45,"tag":54,"props":1145,"children":1146},{},[1147,1149,1155,1157,1162],{"type":51,"value":1148},"Always check ",{"type":45,"tag":66,"props":1150,"children":1152},{"className":1151},[],[1153],{"type":51,"value":1154},"bundle.get('entry', [])",{"type":51,"value":1156}," before iterating -- an empty result returns a Bundle with no ",{"type":45,"tag":66,"props":1158,"children":1160},{"className":1159},[],[1161],{"type":51,"value":881},{"type":51,"value":1163}," key.",{"type":45,"tag":220,"props":1165,"children":1167},{"id":1166},"patient-resource",[1168],{"type":51,"value":1169},"Patient Resource",{"type":45,"tag":227,"props":1171,"children":1174},{"className":1172,"code":1173,"language":71,"meta":235,"style":235},"language-python shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","patient = entry['resource']\npatient_id = patient['id']\ngiven = patient['name'][0].get('given', [''])[0]\nfamily = patient['name'][0].get('family', '')\nfull_name = f\"{given} {family}\"\nbirth_date = patient.get('birthDate', 'Unknown')\ngender = patient.get('gender', 'Unknown')\n\n# Address (optional)\naddress = patient.get('address', [{}])[0]\ncity = address.get('city', '')\nstate = address.get('state', '')\n",[1175],{"type":45,"tag":66,"props":1176,"children":1177},{"__ignoreMap":235},[1178,1186,1194,1202,1210,1218,1226,1234,1243,1251,1259,1268],{"type":45,"tag":744,"props":1179,"children":1180},{"class":746,"line":747},[1181],{"type":45,"tag":744,"props":1182,"children":1183},{},[1184],{"type":51,"value":1185},"patient = entry['resource']\n",{"type":45,"tag":744,"props":1187,"children":1188},{"class":746,"line":757},[1189],{"type":45,"tag":744,"props":1190,"children":1191},{},[1192],{"type":51,"value":1193},"patient_id = patient['id']\n",{"type":45,"tag":744,"props":1195,"children":1196},{"class":746,"line":802},[1197],{"type":45,"tag":744,"props":1198,"children":1199},{},[1200],{"type":51,"value":1201},"given = patient['name'][0].get('given', [''])[0]\n",{"type":45,"tag":744,"props":1203,"children":1204},{"class":746,"line":840},[1205],{"type":45,"tag":744,"props":1206,"children":1207},{},[1208],{"type":51,"value":1209},"family = patient['name'][0].get('family', '')\n",{"type":45,"tag":744,"props":1211,"children":1212},{"class":746,"line":871},[1213],{"type":45,"tag":744,"props":1214,"children":1215},{},[1216],{"type":51,"value":1217},"full_name = f\"{given} {family}\"\n",{"type":45,"tag":744,"props":1219,"children":1220},{"class":746,"line":949},[1221],{"type":45,"tag":744,"props":1222,"children":1223},{},[1224],{"type":51,"value":1225},"birth_date = patient.get('birthDate', 'Unknown')\n",{"type":45,"tag":744,"props":1227,"children":1228},{"class":746,"line":975},[1229],{"type":45,"tag":744,"props":1230,"children":1231},{},[1232],{"type":51,"value":1233},"gender = patient.get('gender', 'Unknown')\n",{"type":45,"tag":744,"props":1235,"children":1236},{"class":746,"line":1054},[1237],{"type":45,"tag":744,"props":1238,"children":1240},{"emptyLinePlaceholder":1239},true,[1241],{"type":51,"value":1242},"\n",{"type":45,"tag":744,"props":1244,"children":1245},{"class":746,"line":1128},[1246],{"type":45,"tag":744,"props":1247,"children":1248},{},[1249],{"type":51,"value":1250},"# Address (optional)\n",{"type":45,"tag":744,"props":1252,"children":1253},{"class":746,"line":1137},[1254],{"type":45,"tag":744,"props":1255,"children":1256},{},[1257],{"type":51,"value":1258},"address = patient.get('address', [{}])[0]\n",{"type":45,"tag":744,"props":1260,"children":1262},{"class":746,"line":1261},11,[1263],{"type":45,"tag":744,"props":1264,"children":1265},{},[1266],{"type":51,"value":1267},"city = address.get('city', '')\n",{"type":45,"tag":744,"props":1269,"children":1271},{"class":746,"line":1270},12,[1272],{"type":45,"tag":744,"props":1273,"children":1274},{},[1275],{"type":51,"value":1276},"state = address.get('state', '')\n",{"type":45,"tag":220,"props":1278,"children":1280},{"id":1279},"condition-resource",[1281],{"type":51,"value":1282},"Condition Resource",{"type":45,"tag":227,"props":1284,"children":1286},{"className":1172,"code":1285,"language":71,"meta":235,"style":235},"condition = entry['resource']\n\n# Code -- check ALL coding entries, not just [0]\ncodings = condition.get('code', {}).get('coding', [])\nfor coding in codings:\n    system = coding.get('system', '')\n    code = coding.get('code', '')\n    display = coding.get('display', '')\n    if 'snomed' in system:\n        snomed_code = code\n    elif 'icd' in system.lower():\n        icd_code = code\n\n# Clinical status\nstatus_codings = condition.get('clinicalStatus', {}).get('coding', [])\nclinical_status = status_codings[0]['code'] if status_codings else 'unknown'\n# Values: \"active\", \"recurrence\", \"relapse\", \"inactive\", \"remission\", \"resolved\"\n\n# Onset\nonset = condition.get('onsetDateTime', condition.get('onsetPeriod', {}).get('start', 'Unknown'))\n\n# Verification status (confirmed, unconfirmed, provisional, differential, refuted)\nverification = condition.get('verificationStatus', {}).get('coding', [{}])[0].get('code', 'unknown')\n",[1287],{"type":45,"tag":66,"props":1288,"children":1289},{"__ignoreMap":235},[1290,1298,1305,1313,1321,1329,1337,1345,1353,1361,1369,1377,1385,1393,1402,1411,1420,1429,1437,1446,1455,1463,1472],{"type":45,"tag":744,"props":1291,"children":1292},{"class":746,"line":747},[1293],{"type":45,"tag":744,"props":1294,"children":1295},{},[1296],{"type":51,"value":1297},"condition = entry['resource']\n",{"type":45,"tag":744,"props":1299,"children":1300},{"class":746,"line":757},[1301],{"type":45,"tag":744,"props":1302,"children":1303},{"emptyLinePlaceholder":1239},[1304],{"type":51,"value":1242},{"type":45,"tag":744,"props":1306,"children":1307},{"class":746,"line":802},[1308],{"type":45,"tag":744,"props":1309,"children":1310},{},[1311],{"type":51,"value":1312},"# Code -- check ALL coding entries, not just [0]\n",{"type":45,"tag":744,"props":1314,"children":1315},{"class":746,"line":840},[1316],{"type":45,"tag":744,"props":1317,"children":1318},{},[1319],{"type":51,"value":1320},"codings = condition.get('code', {}).get('coding', [])\n",{"type":45,"tag":744,"props":1322,"children":1323},{"class":746,"line":871},[1324],{"type":45,"tag":744,"props":1325,"children":1326},{},[1327],{"type":51,"value":1328},"for coding in codings:\n",{"type":45,"tag":744,"props":1330,"children":1331},{"class":746,"line":949},[1332],{"type":45,"tag":744,"props":1333,"children":1334},{},[1335],{"type":51,"value":1336},"    system = coding.get('system', '')\n",{"type":45,"tag":744,"props":1338,"children":1339},{"class":746,"line":975},[1340],{"type":45,"tag":744,"props":1341,"children":1342},{},[1343],{"type":51,"value":1344},"    code = coding.get('code', '')\n",{"type":45,"tag":744,"props":1346,"children":1347},{"class":746,"line":1054},[1348],{"type":45,"tag":744,"props":1349,"children":1350},{},[1351],{"type":51,"value":1352},"    display = coding.get('display', '')\n",{"type":45,"tag":744,"props":1354,"children":1355},{"class":746,"line":1128},[1356],{"type":45,"tag":744,"props":1357,"children":1358},{},[1359],{"type":51,"value":1360},"    if 'snomed' in system:\n",{"type":45,"tag":744,"props":1362,"children":1363},{"class":746,"line":1137},[1364],{"type":45,"tag":744,"props":1365,"children":1366},{},[1367],{"type":51,"value":1368},"        snomed_code = code\n",{"type":45,"tag":744,"props":1370,"children":1371},{"class":746,"line":1261},[1372],{"type":45,"tag":744,"props":1373,"children":1374},{},[1375],{"type":51,"value":1376},"    elif 'icd' in system.lower():\n",{"type":45,"tag":744,"props":1378,"children":1379},{"class":746,"line":1270},[1380],{"type":45,"tag":744,"props":1381,"children":1382},{},[1383],{"type":51,"value":1384},"        icd_code = code\n",{"type":45,"tag":744,"props":1386,"children":1388},{"class":746,"line":1387},13,[1389],{"type":45,"tag":744,"props":1390,"children":1391},{"emptyLinePlaceholder":1239},[1392],{"type":51,"value":1242},{"type":45,"tag":744,"props":1394,"children":1396},{"class":746,"line":1395},14,[1397],{"type":45,"tag":744,"props":1398,"children":1399},{},[1400],{"type":51,"value":1401},"# Clinical status\n",{"type":45,"tag":744,"props":1403,"children":1405},{"class":746,"line":1404},15,[1406],{"type":45,"tag":744,"props":1407,"children":1408},{},[1409],{"type":51,"value":1410},"status_codings = condition.get('clinicalStatus', {}).get('coding', [])\n",{"type":45,"tag":744,"props":1412,"children":1414},{"class":746,"line":1413},16,[1415],{"type":45,"tag":744,"props":1416,"children":1417},{},[1418],{"type":51,"value":1419},"clinical_status = status_codings[0]['code'] if status_codings else 'unknown'\n",{"type":45,"tag":744,"props":1421,"children":1423},{"class":746,"line":1422},17,[1424],{"type":45,"tag":744,"props":1425,"children":1426},{},[1427],{"type":51,"value":1428},"# Values: \"active\", \"recurrence\", \"relapse\", \"inactive\", \"remission\", \"resolved\"\n",{"type":45,"tag":744,"props":1430,"children":1432},{"class":746,"line":1431},18,[1433],{"type":45,"tag":744,"props":1434,"children":1435},{"emptyLinePlaceholder":1239},[1436],{"type":51,"value":1242},{"type":45,"tag":744,"props":1438,"children":1440},{"class":746,"line":1439},19,[1441],{"type":45,"tag":744,"props":1442,"children":1443},{},[1444],{"type":51,"value":1445},"# Onset\n",{"type":45,"tag":744,"props":1447,"children":1449},{"class":746,"line":1448},20,[1450],{"type":45,"tag":744,"props":1451,"children":1452},{},[1453],{"type":51,"value":1454},"onset = condition.get('onsetDateTime', condition.get('onsetPeriod', {}).get('start', 'Unknown'))\n",{"type":45,"tag":744,"props":1456,"children":1458},{"class":746,"line":1457},21,[1459],{"type":45,"tag":744,"props":1460,"children":1461},{"emptyLinePlaceholder":1239},[1462],{"type":51,"value":1242},{"type":45,"tag":744,"props":1464,"children":1466},{"class":746,"line":1465},22,[1467],{"type":45,"tag":744,"props":1468,"children":1469},{},[1470],{"type":51,"value":1471},"# Verification status (confirmed, unconfirmed, provisional, differential, refuted)\n",{"type":45,"tag":744,"props":1473,"children":1475},{"class":746,"line":1474},23,[1476],{"type":45,"tag":744,"props":1477,"children":1478},{},[1479],{"type":51,"value":1480},"verification = condition.get('verificationStatus', {}).get('coding', [{}])[0].get('code', 'unknown')\n",{"type":45,"tag":220,"props":1482,"children":1484},{"id":1483},"observation-resource-simple-single-value",[1485],{"type":51,"value":1486},"Observation Resource -- Simple (single value)",{"type":45,"tag":54,"props":1488,"children":1489},{},[1490,1492,1498],{"type":51,"value":1491},"Most labs return a single value in ",{"type":45,"tag":66,"props":1493,"children":1495},{"className":1494},[],[1496],{"type":51,"value":1497},"valueQuantity",{"type":51,"value":779},{"type":45,"tag":227,"props":1500,"children":1502},{"className":1172,"code":1501,"language":71,"meta":235,"style":235},"obs = entry['resource']\nlab_name = obs['code']['coding'][0]['display']\nloinc_code = obs['code']['coding'][0]['code']\ndate = obs.get('effectiveDateTime', 'Unknown')\n\n# Value -- multiple possible formats\nif 'valueQuantity' in obs:\n    value = obs['valueQuantity']['value']\n    unit = obs['valueQuantity'].get('unit', '')\nelif 'valueString' in obs:\n    value = obs['valueString']    # qualitative result like \"negative\"\n    unit = ''\nelif 'valueCodeableConcept' in obs:\n    value = obs['valueCodeableConcept'].get('text', 'See coding')\n    unit = ''\nelse:\n    value = None  # check component (see below)\n\n# Reference range (from the lab, more accurate than general tables)\nref_ranges = obs.get('referenceRange', [])\nif ref_ranges:\n    low = ref_ranges[0].get('low', {}).get('value')\n    high = ref_ranges[0].get('high', {}).get('value')\n",[1503],{"type":45,"tag":66,"props":1504,"children":1505},{"__ignoreMap":235},[1506,1514,1522,1530,1538,1545,1553,1561,1569,1577,1585,1593,1601,1609,1617,1624,1632,1640,1647,1655,1663,1671,1679],{"type":45,"tag":744,"props":1507,"children":1508},{"class":746,"line":747},[1509],{"type":45,"tag":744,"props":1510,"children":1511},{},[1512],{"type":51,"value":1513},"obs = entry['resource']\n",{"type":45,"tag":744,"props":1515,"children":1516},{"class":746,"line":757},[1517],{"type":45,"tag":744,"props":1518,"children":1519},{},[1520],{"type":51,"value":1521},"lab_name = obs['code']['coding'][0]['display']\n",{"type":45,"tag":744,"props":1523,"children":1524},{"class":746,"line":802},[1525],{"type":45,"tag":744,"props":1526,"children":1527},{},[1528],{"type":51,"value":1529},"loinc_code = obs['code']['coding'][0]['code']\n",{"type":45,"tag":744,"props":1531,"children":1532},{"class":746,"line":840},[1533],{"type":45,"tag":744,"props":1534,"children":1535},{},[1536],{"type":51,"value":1537},"date = obs.get('effectiveDateTime', 'Unknown')\n",{"type":45,"tag":744,"props":1539,"children":1540},{"class":746,"line":871},[1541],{"type":45,"tag":744,"props":1542,"children":1543},{"emptyLinePlaceholder":1239},[1544],{"type":51,"value":1242},{"type":45,"tag":744,"props":1546,"children":1547},{"class":746,"line":949},[1548],{"type":45,"tag":744,"props":1549,"children":1550},{},[1551],{"type":51,"value":1552},"# Value -- multiple possible formats\n",{"type":45,"tag":744,"props":1554,"children":1555},{"class":746,"line":975},[1556],{"type":45,"tag":744,"props":1557,"children":1558},{},[1559],{"type":51,"value":1560},"if 'valueQuantity' in obs:\n",{"type":45,"tag":744,"props":1562,"children":1563},{"class":746,"line":1054},[1564],{"type":45,"tag":744,"props":1565,"children":1566},{},[1567],{"type":51,"value":1568},"    value = obs['valueQuantity']['value']\n",{"type":45,"tag":744,"props":1570,"children":1571},{"class":746,"line":1128},[1572],{"type":45,"tag":744,"props":1573,"children":1574},{},[1575],{"type":51,"value":1576},"    unit = obs['valueQuantity'].get('unit', '')\n",{"type":45,"tag":744,"props":1578,"children":1579},{"class":746,"line":1137},[1580],{"type":45,"tag":744,"props":1581,"children":1582},{},[1583],{"type":51,"value":1584},"elif 'valueString' in obs:\n",{"type":45,"tag":744,"props":1586,"children":1587},{"class":746,"line":1261},[1588],{"type":45,"tag":744,"props":1589,"children":1590},{},[1591],{"type":51,"value":1592},"    value = obs['valueString']    # qualitative result like \"negative\"\n",{"type":45,"tag":744,"props":1594,"children":1595},{"class":746,"line":1270},[1596],{"type":45,"tag":744,"props":1597,"children":1598},{},[1599],{"type":51,"value":1600},"    unit = ''\n",{"type":45,"tag":744,"props":1602,"children":1603},{"class":746,"line":1387},[1604],{"type":45,"tag":744,"props":1605,"children":1606},{},[1607],{"type":51,"value":1608},"elif 'valueCodeableConcept' in obs:\n",{"type":45,"tag":744,"props":1610,"children":1611},{"class":746,"line":1395},[1612],{"type":45,"tag":744,"props":1613,"children":1614},{},[1615],{"type":51,"value":1616},"    value = obs['valueCodeableConcept'].get('text', 'See coding')\n",{"type":45,"tag":744,"props":1618,"children":1619},{"class":746,"line":1404},[1620],{"type":45,"tag":744,"props":1621,"children":1622},{},[1623],{"type":51,"value":1600},{"type":45,"tag":744,"props":1625,"children":1626},{"class":746,"line":1413},[1627],{"type":45,"tag":744,"props":1628,"children":1629},{},[1630],{"type":51,"value":1631},"else:\n",{"type":45,"tag":744,"props":1633,"children":1634},{"class":746,"line":1422},[1635],{"type":45,"tag":744,"props":1636,"children":1637},{},[1638],{"type":51,"value":1639},"    value = None  # check component (see below)\n",{"type":45,"tag":744,"props":1641,"children":1642},{"class":746,"line":1431},[1643],{"type":45,"tag":744,"props":1644,"children":1645},{"emptyLinePlaceholder":1239},[1646],{"type":51,"value":1242},{"type":45,"tag":744,"props":1648,"children":1649},{"class":746,"line":1439},[1650],{"type":45,"tag":744,"props":1651,"children":1652},{},[1653],{"type":51,"value":1654},"# Reference range (from the lab, more accurate than general tables)\n",{"type":45,"tag":744,"props":1656,"children":1657},{"class":746,"line":1448},[1658],{"type":45,"tag":744,"props":1659,"children":1660},{},[1661],{"type":51,"value":1662},"ref_ranges = obs.get('referenceRange', [])\n",{"type":45,"tag":744,"props":1664,"children":1665},{"class":746,"line":1457},[1666],{"type":45,"tag":744,"props":1667,"children":1668},{},[1669],{"type":51,"value":1670},"if ref_ranges:\n",{"type":45,"tag":744,"props":1672,"children":1673},{"class":746,"line":1465},[1674],{"type":45,"tag":744,"props":1675,"children":1676},{},[1677],{"type":51,"value":1678},"    low = ref_ranges[0].get('low', {}).get('value')\n",{"type":45,"tag":744,"props":1680,"children":1681},{"class":746,"line":1474},[1682],{"type":45,"tag":744,"props":1683,"children":1684},{},[1685],{"type":51,"value":1686},"    high = ref_ranges[0].get('high', {}).get('value')\n",{"type":45,"tag":220,"props":1688,"children":1690},{"id":1689},"observation-resource-component-blood-pressure",[1691],{"type":51,"value":1692},"Observation Resource -- Component (Blood Pressure)",{"type":45,"tag":54,"props":1694,"children":1695},{},[1696,1698,1703,1705,1710,1712,1718,1720,1725],{"type":51,"value":1697},"Blood pressure in FHIR is typically a ",{"type":45,"tag":58,"props":1699,"children":1700},{},[1701],{"type":51,"value":1702},"component Observation",{"type":51,"value":1704}," with LOINC ",{"type":45,"tag":66,"props":1706,"children":1708},{"className":1707},[],[1709],{"type":51,"value":527},{"type":51,"value":1711}," (BP panel). Systolic and diastolic are nested inside ",{"type":45,"tag":66,"props":1713,"children":1715},{"className":1714},[],[1716],{"type":51,"value":1717},"component[]",{"type":51,"value":1719},", NOT in ",{"type":45,"tag":66,"props":1721,"children":1723},{"className":1722},[],[1724],{"type":51,"value":1497},{"type":51,"value":779},{"type":45,"tag":227,"props":1727,"children":1729},{"className":1172,"code":1728,"language":71,"meta":235,"style":235},"obs = entry['resource']\npanel_code = obs['code']['coding'][0]['code']\n\nif panel_code == '85354-9' or 'component' in obs:\n    systolic = None\n    diastolic = None\n    for comp in obs.get('component', []):\n        comp_code = comp['code']['coding'][0]['code']\n        if comp_code == '8480-6':  # systolic\n            systolic = comp['valueQuantity']['value']\n        elif comp_code == '8462-4':  # diastolic\n            diastolic = comp['valueQuantity']['value']\n",[1730],{"type":45,"tag":66,"props":1731,"children":1732},{"__ignoreMap":235},[1733,1740,1748,1755,1763,1771,1779,1787,1795,1803,1811,1819],{"type":45,"tag":744,"props":1734,"children":1735},{"class":746,"line":747},[1736],{"type":45,"tag":744,"props":1737,"children":1738},{},[1739],{"type":51,"value":1513},{"type":45,"tag":744,"props":1741,"children":1742},{"class":746,"line":757},[1743],{"type":45,"tag":744,"props":1744,"children":1745},{},[1746],{"type":51,"value":1747},"panel_code = obs['code']['coding'][0]['code']\n",{"type":45,"tag":744,"props":1749,"children":1750},{"class":746,"line":802},[1751],{"type":45,"tag":744,"props":1752,"children":1753},{"emptyLinePlaceholder":1239},[1754],{"type":51,"value":1242},{"type":45,"tag":744,"props":1756,"children":1757},{"class":746,"line":840},[1758],{"type":45,"tag":744,"props":1759,"children":1760},{},[1761],{"type":51,"value":1762},"if panel_code == '85354-9' or 'component' in obs:\n",{"type":45,"tag":744,"props":1764,"children":1765},{"class":746,"line":871},[1766],{"type":45,"tag":744,"props":1767,"children":1768},{},[1769],{"type":51,"value":1770},"    systolic = None\n",{"type":45,"tag":744,"props":1772,"children":1773},{"class":746,"line":949},[1774],{"type":45,"tag":744,"props":1775,"children":1776},{},[1777],{"type":51,"value":1778},"    diastolic = None\n",{"type":45,"tag":744,"props":1780,"children":1781},{"class":746,"line":975},[1782],{"type":45,"tag":744,"props":1783,"children":1784},{},[1785],{"type":51,"value":1786},"    for comp in obs.get('component', []):\n",{"type":45,"tag":744,"props":1788,"children":1789},{"class":746,"line":1054},[1790],{"type":45,"tag":744,"props":1791,"children":1792},{},[1793],{"type":51,"value":1794},"        comp_code = comp['code']['coding'][0]['code']\n",{"type":45,"tag":744,"props":1796,"children":1797},{"class":746,"line":1128},[1798],{"type":45,"tag":744,"props":1799,"children":1800},{},[1801],{"type":51,"value":1802},"        if comp_code == '8480-6':  # systolic\n",{"type":45,"tag":744,"props":1804,"children":1805},{"class":746,"line":1137},[1806],{"type":45,"tag":744,"props":1807,"children":1808},{},[1809],{"type":51,"value":1810},"            systolic = comp['valueQuantity']['value']\n",{"type":45,"tag":744,"props":1812,"children":1813},{"class":746,"line":1261},[1814],{"type":45,"tag":744,"props":1815,"children":1816},{},[1817],{"type":51,"value":1818},"        elif comp_code == '8462-4':  # diastolic\n",{"type":45,"tag":744,"props":1820,"children":1821},{"class":746,"line":1270},[1822],{"type":45,"tag":744,"props":1823,"children":1824},{},[1825],{"type":51,"value":1826},"            diastolic = comp['valueQuantity']['value']\n",{"type":45,"tag":54,"props":1828,"children":1829},{},[1830,1835,1837,1843,1845,1850],{"type":45,"tag":58,"props":1831,"children":1832},{},[1833],{"type":51,"value":1834},"Critical",{"type":51,"value":1836},": When querying for systolic BP (LOINC 8480-6), some FHIR servers return the panel Observation (85354-9) where systolic is inside ",{"type":45,"tag":66,"props":1838,"children":1840},{"className":1839},[],[1841],{"type":51,"value":1842},"component",{"type":51,"value":1844},". Others return a standalone Observation with ",{"type":45,"tag":66,"props":1846,"children":1848},{"className":1847},[],[1849],{"type":51,"value":1497},{"type":51,"value":1851},". Your code must handle both:",{"type":45,"tag":227,"props":1853,"children":1855},{"className":1172,"code":1854,"language":71,"meta":235,"style":235},"def get_bp(patient_id, base_url):\n    \"\"\"Get most recent blood pressure, handling both panel and standalone formats.\"\"\"\n    # Try panel first\n    r = fhir_get(\"Observation\",\n                     params={\"patient\": patient_id, \"code\": \"85354-9\",\n                             \"_sort\": \"-date\", \"_count\": \"1\"}).json()\n    if r.get('entry'):\n        obs = r['entry'][0]['resource']\n        systolic = diastolic = None\n        for comp in obs.get('component', []):\n            c = comp['code']['coding'][0]['code']\n            if c == '8480-6':\n                systolic = comp['valueQuantity']['value']\n            elif c == '8462-4':\n                diastolic = comp['valueQuantity']['value']\n        if systolic is not None:\n            return systolic, diastolic, obs.get('effectiveDateTime', 'Unknown')\n\n    # Fallback: standalone systolic\n    r = fhir_get(\"Observation\",\n                     params={\"patient\": patient_id, \"code\": \"8480-6\",\n                             \"_sort\": \"-date\", \"_count\": \"1\"}).json()\n    if r.get('entry'):\n        obs = r['entry'][0]['resource']\n        systolic = obs.get('valueQuantity', {}).get('value')\n        return systolic, None, obs.get('effectiveDateTime', 'Unknown')\n\n    return None, None, None\n",[1856],{"type":45,"tag":66,"props":1857,"children":1858},{"__ignoreMap":235},[1859,1867,1875,1883,1891,1899,1907,1915,1923,1931,1939,1947,1955,1963,1971,1979,1987,1995,2002,2010,2017,2025,2032,2039,2047,2056,2065,2073],{"type":45,"tag":744,"props":1860,"children":1861},{"class":746,"line":747},[1862],{"type":45,"tag":744,"props":1863,"children":1864},{},[1865],{"type":51,"value":1866},"def get_bp(patient_id, base_url):\n",{"type":45,"tag":744,"props":1868,"children":1869},{"class":746,"line":757},[1870],{"type":45,"tag":744,"props":1871,"children":1872},{},[1873],{"type":51,"value":1874},"    \"\"\"Get most recent blood pressure, handling both panel and standalone formats.\"\"\"\n",{"type":45,"tag":744,"props":1876,"children":1877},{"class":746,"line":802},[1878],{"type":45,"tag":744,"props":1879,"children":1880},{},[1881],{"type":51,"value":1882},"    # Try panel first\n",{"type":45,"tag":744,"props":1884,"children":1885},{"class":746,"line":840},[1886],{"type":45,"tag":744,"props":1887,"children":1888},{},[1889],{"type":51,"value":1890},"    r = fhir_get(\"Observation\",\n",{"type":45,"tag":744,"props":1892,"children":1893},{"class":746,"line":871},[1894],{"type":45,"tag":744,"props":1895,"children":1896},{},[1897],{"type":51,"value":1898},"                     params={\"patient\": patient_id, \"code\": \"85354-9\",\n",{"type":45,"tag":744,"props":1900,"children":1901},{"class":746,"line":949},[1902],{"type":45,"tag":744,"props":1903,"children":1904},{},[1905],{"type":51,"value":1906},"                             \"_sort\": \"-date\", \"_count\": \"1\"}).json()\n",{"type":45,"tag":744,"props":1908,"children":1909},{"class":746,"line":975},[1910],{"type":45,"tag":744,"props":1911,"children":1912},{},[1913],{"type":51,"value":1914},"    if r.get('entry'):\n",{"type":45,"tag":744,"props":1916,"children":1917},{"class":746,"line":1054},[1918],{"type":45,"tag":744,"props":1919,"children":1920},{},[1921],{"type":51,"value":1922},"        obs = r['entry'][0]['resource']\n",{"type":45,"tag":744,"props":1924,"children":1925},{"class":746,"line":1128},[1926],{"type":45,"tag":744,"props":1927,"children":1928},{},[1929],{"type":51,"value":1930},"        systolic = diastolic = None\n",{"type":45,"tag":744,"props":1932,"children":1933},{"class":746,"line":1137},[1934],{"type":45,"tag":744,"props":1935,"children":1936},{},[1937],{"type":51,"value":1938},"        for comp in obs.get('component', []):\n",{"type":45,"tag":744,"props":1940,"children":1941},{"class":746,"line":1261},[1942],{"type":45,"tag":744,"props":1943,"children":1944},{},[1945],{"type":51,"value":1946},"            c = comp['code']['coding'][0]['code']\n",{"type":45,"tag":744,"props":1948,"children":1949},{"class":746,"line":1270},[1950],{"type":45,"tag":744,"props":1951,"children":1952},{},[1953],{"type":51,"value":1954},"            if c == '8480-6':\n",{"type":45,"tag":744,"props":1956,"children":1957},{"class":746,"line":1387},[1958],{"type":45,"tag":744,"props":1959,"children":1960},{},[1961],{"type":51,"value":1962},"                systolic = comp['valueQuantity']['value']\n",{"type":45,"tag":744,"props":1964,"children":1965},{"class":746,"line":1395},[1966],{"type":45,"tag":744,"props":1967,"children":1968},{},[1969],{"type":51,"value":1970},"            elif c == '8462-4':\n",{"type":45,"tag":744,"props":1972,"children":1973},{"class":746,"line":1404},[1974],{"type":45,"tag":744,"props":1975,"children":1976},{},[1977],{"type":51,"value":1978},"                diastolic = comp['valueQuantity']['value']\n",{"type":45,"tag":744,"props":1980,"children":1981},{"class":746,"line":1413},[1982],{"type":45,"tag":744,"props":1983,"children":1984},{},[1985],{"type":51,"value":1986},"        if systolic is not None:\n",{"type":45,"tag":744,"props":1988,"children":1989},{"class":746,"line":1422},[1990],{"type":45,"tag":744,"props":1991,"children":1992},{},[1993],{"type":51,"value":1994},"            return systolic, diastolic, obs.get('effectiveDateTime', 'Unknown')\n",{"type":45,"tag":744,"props":1996,"children":1997},{"class":746,"line":1431},[1998],{"type":45,"tag":744,"props":1999,"children":2000},{"emptyLinePlaceholder":1239},[2001],{"type":51,"value":1242},{"type":45,"tag":744,"props":2003,"children":2004},{"class":746,"line":1439},[2005],{"type":45,"tag":744,"props":2006,"children":2007},{},[2008],{"type":51,"value":2009},"    # Fallback: standalone systolic\n",{"type":45,"tag":744,"props":2011,"children":2012},{"class":746,"line":1448},[2013],{"type":45,"tag":744,"props":2014,"children":2015},{},[2016],{"type":51,"value":1890},{"type":45,"tag":744,"props":2018,"children":2019},{"class":746,"line":1457},[2020],{"type":45,"tag":744,"props":2021,"children":2022},{},[2023],{"type":51,"value":2024},"                     params={\"patient\": patient_id, \"code\": \"8480-6\",\n",{"type":45,"tag":744,"props":2026,"children":2027},{"class":746,"line":1465},[2028],{"type":45,"tag":744,"props":2029,"children":2030},{},[2031],{"type":51,"value":1906},{"type":45,"tag":744,"props":2033,"children":2034},{"class":746,"line":1474},[2035],{"type":45,"tag":744,"props":2036,"children":2037},{},[2038],{"type":51,"value":1914},{"type":45,"tag":744,"props":2040,"children":2042},{"class":746,"line":2041},24,[2043],{"type":45,"tag":744,"props":2044,"children":2045},{},[2046],{"type":51,"value":1922},{"type":45,"tag":744,"props":2048,"children":2050},{"class":746,"line":2049},25,[2051],{"type":45,"tag":744,"props":2052,"children":2053},{},[2054],{"type":51,"value":2055},"        systolic = obs.get('valueQuantity', {}).get('value')\n",{"type":45,"tag":744,"props":2057,"children":2059},{"class":746,"line":2058},26,[2060],{"type":45,"tag":744,"props":2061,"children":2062},{},[2063],{"type":51,"value":2064},"        return systolic, None, obs.get('effectiveDateTime', 'Unknown')\n",{"type":45,"tag":744,"props":2066,"children":2068},{"class":746,"line":2067},27,[2069],{"type":45,"tag":744,"props":2070,"children":2071},{"emptyLinePlaceholder":1239},[2072],{"type":51,"value":1242},{"type":45,"tag":744,"props":2074,"children":2076},{"class":746,"line":2075},28,[2077],{"type":45,"tag":744,"props":2078,"children":2079},{},[2080],{"type":51,"value":2081},"    return None, None, None\n",{"type":45,"tag":220,"props":2083,"children":2085},{"id":2084},"medicationrequest-resource",[2086],{"type":51,"value":2087},"MedicationRequest Resource",{"type":45,"tag":227,"props":2089,"children":2091},{"className":1172,"code":2090,"language":71,"meta":235,"style":235},"med = entry['resource']\n\n# Medication name -- check multiple locations\nmed_name = (\n    med.get('medicationCodeableConcept', {}).get('text')\n    or med.get('medicationCodeableConcept', {}).get('coding', [{}])[0].get('display')\n    or 'Unknown medication'\n)\n\n# Status\nstatus = med.get('status', 'unknown')  # active, on-hold, cancelled, completed, stopped\n\n# Dosage\ndosage_instructions = med.get('dosageInstruction', [{}])\ndosage_text = dosage_instructions[0].get('text', 'No dosage recorded') if dosage_instructions else 'No dosage recorded'\n\n# Authored date\nauthored = med.get('authoredOn', 'Unknown')\n",[2092],{"type":45,"tag":66,"props":2093,"children":2094},{"__ignoreMap":235},[2095,2103,2110,2118,2126,2134,2142,2150,2158,2165,2173,2181,2188,2196,2204,2212,2219,2227],{"type":45,"tag":744,"props":2096,"children":2097},{"class":746,"line":747},[2098],{"type":45,"tag":744,"props":2099,"children":2100},{},[2101],{"type":51,"value":2102},"med = entry['resource']\n",{"type":45,"tag":744,"props":2104,"children":2105},{"class":746,"line":757},[2106],{"type":45,"tag":744,"props":2107,"children":2108},{"emptyLinePlaceholder":1239},[2109],{"type":51,"value":1242},{"type":45,"tag":744,"props":2111,"children":2112},{"class":746,"line":802},[2113],{"type":45,"tag":744,"props":2114,"children":2115},{},[2116],{"type":51,"value":2117},"# Medication name -- check multiple locations\n",{"type":45,"tag":744,"props":2119,"children":2120},{"class":746,"line":840},[2121],{"type":45,"tag":744,"props":2122,"children":2123},{},[2124],{"type":51,"value":2125},"med_name = (\n",{"type":45,"tag":744,"props":2127,"children":2128},{"class":746,"line":871},[2129],{"type":45,"tag":744,"props":2130,"children":2131},{},[2132],{"type":51,"value":2133},"    med.get('medicationCodeableConcept', {}).get('text')\n",{"type":45,"tag":744,"props":2135,"children":2136},{"class":746,"line":949},[2137],{"type":45,"tag":744,"props":2138,"children":2139},{},[2140],{"type":51,"value":2141},"    or med.get('medicationCodeableConcept', {}).get('coding', [{}])[0].get('display')\n",{"type":45,"tag":744,"props":2143,"children":2144},{"class":746,"line":975},[2145],{"type":45,"tag":744,"props":2146,"children":2147},{},[2148],{"type":51,"value":2149},"    or 'Unknown medication'\n",{"type":45,"tag":744,"props":2151,"children":2152},{"class":746,"line":1054},[2153],{"type":45,"tag":744,"props":2154,"children":2155},{},[2156],{"type":51,"value":2157},")\n",{"type":45,"tag":744,"props":2159,"children":2160},{"class":746,"line":1128},[2161],{"type":45,"tag":744,"props":2162,"children":2163},{"emptyLinePlaceholder":1239},[2164],{"type":51,"value":1242},{"type":45,"tag":744,"props":2166,"children":2167},{"class":746,"line":1137},[2168],{"type":45,"tag":744,"props":2169,"children":2170},{},[2171],{"type":51,"value":2172},"# Status\n",{"type":45,"tag":744,"props":2174,"children":2175},{"class":746,"line":1261},[2176],{"type":45,"tag":744,"props":2177,"children":2178},{},[2179],{"type":51,"value":2180},"status = med.get('status', 'unknown')  # active, on-hold, cancelled, completed, stopped\n",{"type":45,"tag":744,"props":2182,"children":2183},{"class":746,"line":1270},[2184],{"type":45,"tag":744,"props":2185,"children":2186},{"emptyLinePlaceholder":1239},[2187],{"type":51,"value":1242},{"type":45,"tag":744,"props":2189,"children":2190},{"class":746,"line":1387},[2191],{"type":45,"tag":744,"props":2192,"children":2193},{},[2194],{"type":51,"value":2195},"# Dosage\n",{"type":45,"tag":744,"props":2197,"children":2198},{"class":746,"line":1395},[2199],{"type":45,"tag":744,"props":2200,"children":2201},{},[2202],{"type":51,"value":2203},"dosage_instructions = med.get('dosageInstruction', [{}])\n",{"type":45,"tag":744,"props":2205,"children":2206},{"class":746,"line":1404},[2207],{"type":45,"tag":744,"props":2208,"children":2209},{},[2210],{"type":51,"value":2211},"dosage_text = dosage_instructions[0].get('text', 'No dosage recorded') if dosage_instructions else 'No dosage recorded'\n",{"type":45,"tag":744,"props":2213,"children":2214},{"class":746,"line":1413},[2215],{"type":45,"tag":744,"props":2216,"children":2217},{"emptyLinePlaceholder":1239},[2218],{"type":51,"value":1242},{"type":45,"tag":744,"props":2220,"children":2221},{"class":746,"line":1422},[2222],{"type":45,"tag":744,"props":2223,"children":2224},{},[2225],{"type":51,"value":2226},"# Authored date\n",{"type":45,"tag":744,"props":2228,"children":2229},{"class":746,"line":1431},[2230],{"type":45,"tag":744,"props":2231,"children":2232},{},[2233],{"type":51,"value":2234},"authored = med.get('authoredOn', 'Unknown')\n",{"type":45,"tag":111,"props":2236,"children":2238},{"id":2237},"pagination",[2239],{"type":51,"value":2240},"Pagination",{"type":45,"tag":54,"props":2242,"children":2243},{},[2244],{"type":51,"value":2245},"FHIR responses default to 20 results per page (server-dependent). Always handle pagination for cohort queries:",{"type":45,"tag":227,"props":2247,"children":2249},{"className":1172,"code":2248,"language":71,"meta":235,"style":235},"def get_all_pages(url, params=None):\n    \"\"\"Fetch all pages of a FHIR Bundle search.\"\"\"\n    all_entries = []\n    if params:\n        r = fhir_get(url, params)\n    else:\n        r = fhir_get(url)\n    all_entries.extend(r.get('entry', []))\n\n    # Follow 'next' links\n    while True:\n        next_url = None\n        for link in r.get('link', []):\n            if link.get('relation') == 'next':\n                next_url = link['url']\n                break\n        if not next_url:\n            break\n        r = fhir_get(next_url)\n        all_entries.extend(r.get('entry', []))\n\n    return all_entries\n",[2250],{"type":45,"tag":66,"props":2251,"children":2252},{"__ignoreMap":235},[2253,2261,2269,2277,2285,2293,2301,2309,2317,2324,2332,2340,2348,2356,2364,2372,2380,2388,2396,2404,2412,2419],{"type":45,"tag":744,"props":2254,"children":2255},{"class":746,"line":747},[2256],{"type":45,"tag":744,"props":2257,"children":2258},{},[2259],{"type":51,"value":2260},"def get_all_pages(url, params=None):\n",{"type":45,"tag":744,"props":2262,"children":2263},{"class":746,"line":757},[2264],{"type":45,"tag":744,"props":2265,"children":2266},{},[2267],{"type":51,"value":2268},"    \"\"\"Fetch all pages of a FHIR Bundle search.\"\"\"\n",{"type":45,"tag":744,"props":2270,"children":2271},{"class":746,"line":802},[2272],{"type":45,"tag":744,"props":2273,"children":2274},{},[2275],{"type":51,"value":2276},"    all_entries = []\n",{"type":45,"tag":744,"props":2278,"children":2279},{"class":746,"line":840},[2280],{"type":45,"tag":744,"props":2281,"children":2282},{},[2283],{"type":51,"value":2284},"    if params:\n",{"type":45,"tag":744,"props":2286,"children":2287},{"class":746,"line":871},[2288],{"type":45,"tag":744,"props":2289,"children":2290},{},[2291],{"type":51,"value":2292},"        r = fhir_get(url, params)\n",{"type":45,"tag":744,"props":2294,"children":2295},{"class":746,"line":949},[2296],{"type":45,"tag":744,"props":2297,"children":2298},{},[2299],{"type":51,"value":2300},"    else:\n",{"type":45,"tag":744,"props":2302,"children":2303},{"class":746,"line":975},[2304],{"type":45,"tag":744,"props":2305,"children":2306},{},[2307],{"type":51,"value":2308},"        r = fhir_get(url)\n",{"type":45,"tag":744,"props":2310,"children":2311},{"class":746,"line":1054},[2312],{"type":45,"tag":744,"props":2313,"children":2314},{},[2315],{"type":51,"value":2316},"    all_entries.extend(r.get('entry', []))\n",{"type":45,"tag":744,"props":2318,"children":2319},{"class":746,"line":1128},[2320],{"type":45,"tag":744,"props":2321,"children":2322},{"emptyLinePlaceholder":1239},[2323],{"type":51,"value":1242},{"type":45,"tag":744,"props":2325,"children":2326},{"class":746,"line":1137},[2327],{"type":45,"tag":744,"props":2328,"children":2329},{},[2330],{"type":51,"value":2331},"    # Follow 'next' links\n",{"type":45,"tag":744,"props":2333,"children":2334},{"class":746,"line":1261},[2335],{"type":45,"tag":744,"props":2336,"children":2337},{},[2338],{"type":51,"value":2339},"    while True:\n",{"type":45,"tag":744,"props":2341,"children":2342},{"class":746,"line":1270},[2343],{"type":45,"tag":744,"props":2344,"children":2345},{},[2346],{"type":51,"value":2347},"        next_url = None\n",{"type":45,"tag":744,"props":2349,"children":2350},{"class":746,"line":1387},[2351],{"type":45,"tag":744,"props":2352,"children":2353},{},[2354],{"type":51,"value":2355},"        for link in r.get('link', []):\n",{"type":45,"tag":744,"props":2357,"children":2358},{"class":746,"line":1395},[2359],{"type":45,"tag":744,"props":2360,"children":2361},{},[2362],{"type":51,"value":2363},"            if link.get('relation') == 'next':\n",{"type":45,"tag":744,"props":2365,"children":2366},{"class":746,"line":1404},[2367],{"type":45,"tag":744,"props":2368,"children":2369},{},[2370],{"type":51,"value":2371},"                next_url = link['url']\n",{"type":45,"tag":744,"props":2373,"children":2374},{"class":746,"line":1413},[2375],{"type":45,"tag":744,"props":2376,"children":2377},{},[2378],{"type":51,"value":2379},"                break\n",{"type":45,"tag":744,"props":2381,"children":2382},{"class":746,"line":1422},[2383],{"type":45,"tag":744,"props":2384,"children":2385},{},[2386],{"type":51,"value":2387},"        if not next_url:\n",{"type":45,"tag":744,"props":2389,"children":2390},{"class":746,"line":1431},[2391],{"type":45,"tag":744,"props":2392,"children":2393},{},[2394],{"type":51,"value":2395},"            break\n",{"type":45,"tag":744,"props":2397,"children":2398},{"class":746,"line":1439},[2399],{"type":45,"tag":744,"props":2400,"children":2401},{},[2402],{"type":51,"value":2403},"        r = fhir_get(next_url)\n",{"type":45,"tag":744,"props":2405,"children":2406},{"class":746,"line":1448},[2407],{"type":45,"tag":744,"props":2408,"children":2409},{},[2410],{"type":51,"value":2411},"        all_entries.extend(r.get('entry', []))\n",{"type":45,"tag":744,"props":2413,"children":2414},{"class":746,"line":1457},[2415],{"type":45,"tag":744,"props":2416,"children":2417},{"emptyLinePlaceholder":1239},[2418],{"type":51,"value":1242},{"type":45,"tag":744,"props":2420,"children":2421},{"class":746,"line":1465},[2422],{"type":45,"tag":744,"props":2423,"children":2424},{},[2425],{"type":51,"value":2426},"    return all_entries\n",{"type":45,"tag":54,"props":2428,"children":2429},{},[2430,2432,2438],{"type":51,"value":2431},"For large cohorts, set ",{"type":45,"tag":66,"props":2433,"children":2435},{"className":2434},[],[2436],{"type":51,"value":2437},"_count=200",{"type":51,"value":2439}," to reduce the number of pages. The SMART test server caps at ~1000 results regardless.",{"type":45,"tag":111,"props":2441,"children":2443},{"id":2442},"batched-and-multi-patient-queries-critical-for-performance",[2444],{"type":51,"value":2445},"Batched and Multi-Patient Queries (CRITICAL for Performance)",{"type":45,"tag":54,"props":2447,"children":2448},{},[2449,2454],{"type":45,"tag":58,"props":2450,"children":2451},{},[2452],{"type":51,"value":2453},"Never loop over patients making individual FHIR calls.",{"type":51,"value":2455}," Each HTTP call through the sandbox proxy adds 1-3 seconds of latency. For 24 patients x 4 LOINC codes, that is 96 sequential calls = 5+ minutes. Instead, fetch all observations for a LOINC code in one request and filter client-side in Python.",{"type":45,"tag":220,"props":2457,"children":2459},{"id":2458},"pattern-1-fetch-all-observations-for-a-loinc-code-preferred",[2460],{"type":51,"value":2461},"Pattern 1: Fetch all Observations for a LOINC code (preferred)",{"type":45,"tag":54,"props":2463,"children":2464},{},[2465],{"type":51,"value":2466},"Query Observation by code alone (no patient filter) to get results for ALL patients in one call:",{"type":45,"tag":227,"props":2468,"children":2471},{"className":2469,"code":2470,"language":51},[230],"GET \u002FObservation?code={loinc}&_count=500&_sort=-date\n",[2472],{"type":45,"tag":66,"props":2473,"children":2474},{"__ignoreMap":235},[2475],{"type":51,"value":2470},{"type":45,"tag":54,"props":2477,"children":2478},{},[2479],{"type":51,"value":2480},"Then filter in Python by patient reference:",{"type":45,"tag":227,"props":2482,"children":2484},{"className":1172,"code":2483,"language":71,"meta":235,"style":235},"def get_all_obs_for_code(loinc_code, count=500):\n    \"\"\"Fetch ALL observations for a LOINC code across all patients in one call.\"\"\"\n    entries = get_all_pages(\"Observation\", {\"code\": loinc_code, \"_count\": str(count), \"_sort\": \"-date\"})\n    # Build dict: patient_id -> list of observations (already sorted newest first)\n    by_patient = {}\n    for e in entries:\n        obs = e['resource']\n        ref = obs.get('subject', {}).get('reference', '')\n        pid = ref.split('\u002F')[-1] if '\u002F' in ref else ref\n        if pid not in by_patient:\n            by_patient[pid] = obs  # keep only the most recent per patient\n    return by_patient\n",[2485],{"type":45,"tag":66,"props":2486,"children":2487},{"__ignoreMap":235},[2488,2496,2504,2512,2520,2528,2536,2544,2552,2560,2568,2576],{"type":45,"tag":744,"props":2489,"children":2490},{"class":746,"line":747},[2491],{"type":45,"tag":744,"props":2492,"children":2493},{},[2494],{"type":51,"value":2495},"def get_all_obs_for_code(loinc_code, count=500):\n",{"type":45,"tag":744,"props":2497,"children":2498},{"class":746,"line":757},[2499],{"type":45,"tag":744,"props":2500,"children":2501},{},[2502],{"type":51,"value":2503},"    \"\"\"Fetch ALL observations for a LOINC code across all patients in one call.\"\"\"\n",{"type":45,"tag":744,"props":2505,"children":2506},{"class":746,"line":802},[2507],{"type":45,"tag":744,"props":2508,"children":2509},{},[2510],{"type":51,"value":2511},"    entries = get_all_pages(\"Observation\", {\"code\": loinc_code, \"_count\": str(count), \"_sort\": \"-date\"})\n",{"type":45,"tag":744,"props":2513,"children":2514},{"class":746,"line":840},[2515],{"type":45,"tag":744,"props":2516,"children":2517},{},[2518],{"type":51,"value":2519},"    # Build dict: patient_id -> list of observations (already sorted newest first)\n",{"type":45,"tag":744,"props":2521,"children":2522},{"class":746,"line":871},[2523],{"type":45,"tag":744,"props":2524,"children":2525},{},[2526],{"type":51,"value":2527},"    by_patient = {}\n",{"type":45,"tag":744,"props":2529,"children":2530},{"class":746,"line":949},[2531],{"type":45,"tag":744,"props":2532,"children":2533},{},[2534],{"type":51,"value":2535},"    for e in entries:\n",{"type":45,"tag":744,"props":2537,"children":2538},{"class":746,"line":975},[2539],{"type":45,"tag":744,"props":2540,"children":2541},{},[2542],{"type":51,"value":2543},"        obs = e['resource']\n",{"type":45,"tag":744,"props":2545,"children":2546},{"class":746,"line":1054},[2547],{"type":45,"tag":744,"props":2548,"children":2549},{},[2550],{"type":51,"value":2551},"        ref = obs.get('subject', {}).get('reference', '')\n",{"type":45,"tag":744,"props":2553,"children":2554},{"class":746,"line":1128},[2555],{"type":45,"tag":744,"props":2556,"children":2557},{},[2558],{"type":51,"value":2559},"        pid = ref.split('\u002F')[-1] if '\u002F' in ref else ref\n",{"type":45,"tag":744,"props":2561,"children":2562},{"class":746,"line":1137},[2563],{"type":45,"tag":744,"props":2564,"children":2565},{},[2566],{"type":51,"value":2567},"        if pid not in by_patient:\n",{"type":45,"tag":744,"props":2569,"children":2570},{"class":746,"line":1261},[2571],{"type":45,"tag":744,"props":2572,"children":2573},{},[2574],{"type":51,"value":2575},"            by_patient[pid] = obs  # keep only the most recent per patient\n",{"type":45,"tag":744,"props":2577,"children":2578},{"class":746,"line":1270},[2579],{"type":45,"tag":744,"props":2580,"children":2581},{},[2582],{"type":51,"value":2583},"    return by_patient\n",{"type":45,"tag":220,"props":2585,"children":2587},{"id":2586},"pattern-2-multi-patient-query-parameter",[2588],{"type":51,"value":2589},"Pattern 2: Multi-patient query parameter",{"type":45,"tag":54,"props":2591,"children":2592},{},[2593],{"type":51,"value":2594},"Some FHIR servers accept comma-separated patient references:",{"type":45,"tag":227,"props":2596,"children":2599},{"className":2597,"code":2598,"language":51},[230],"GET \u002FObservation?patient=Patient\u002FX,Patient\u002FY,Patient\u002FZ&code={loinc}&_count=500\n",[2600],{"type":45,"tag":66,"props":2601,"children":2602},{"__ignoreMap":235},[2603],{"type":51,"value":2598},{"type":45,"tag":54,"props":2605,"children":2606},{},[2607],{"type":51,"value":2608},"The SMART test server supports this. Use it when you have a specific list of patient IDs and want to avoid fetching observations for patients not in your cohort.",{"type":45,"tag":220,"props":2610,"children":2612},{"id":2611},"pattern-3-fhir-batch-bundle",[2613],{"type":51,"value":2614},"Pattern 3: FHIR Batch Bundle",{"type":45,"tag":54,"props":2616,"children":2617},{},[2618,2620,2626],{"type":51,"value":2619},"For heterogeneous queries (different resource types per patient), POST a Bundle of type ",{"type":45,"tag":66,"props":2621,"children":2623},{"className":2622},[],[2624],{"type":51,"value":2625},"batch",{"type":51,"value":2627}," to the server root:",{"type":45,"tag":227,"props":2629,"children":2631},{"className":1172,"code":2630,"language":71,"meta":235,"style":235},"def fhir_batch(requests_list):\n    \"\"\"Execute multiple FHIR queries in a single HTTP call using a batch Bundle.\n    requests_list: list of {\"method\": \"GET\", \"url\": \"Observation?patient=X&code=Y\"} dicts.\n    \"\"\"\n    bundle = {\n        \"resourceType\": \"Bundle\",\n        \"type\": \"batch\",\n        \"entry\": [{\"request\": req} for req in requests_list]\n    }\n    import subprocess, json\n    r = subprocess.run(\n        [\"curl\", \"-sf\", \"--max-time\", \"60\",\n         \"-X\", \"POST\", \"-H\", \"Content-Type: application\u002Ffhir+json\",\n         \"-d\", json.dumps(bundle), f\"{BASE_URL}\"],\n        capture_output=True, text=True, timeout=65\n    )\n    if r.returncode != 0 or not r.stdout.strip():\n        return []\n    result = json.loads(r.stdout)\n    return result.get('entry', [])\n",[2632],{"type":45,"tag":66,"props":2633,"children":2634},{"__ignoreMap":235},[2635,2643,2651,2659,2667,2675,2683,2691,2699,2707,2715,2723,2731,2739,2747,2755,2763,2771,2779,2787],{"type":45,"tag":744,"props":2636,"children":2637},{"class":746,"line":747},[2638],{"type":45,"tag":744,"props":2639,"children":2640},{},[2641],{"type":51,"value":2642},"def fhir_batch(requests_list):\n",{"type":45,"tag":744,"props":2644,"children":2645},{"class":746,"line":757},[2646],{"type":45,"tag":744,"props":2647,"children":2648},{},[2649],{"type":51,"value":2650},"    \"\"\"Execute multiple FHIR queries in a single HTTP call using a batch Bundle.\n",{"type":45,"tag":744,"props":2652,"children":2653},{"class":746,"line":802},[2654],{"type":45,"tag":744,"props":2655,"children":2656},{},[2657],{"type":51,"value":2658},"    requests_list: list of {\"method\": \"GET\", \"url\": \"Observation?patient=X&code=Y\"} dicts.\n",{"type":45,"tag":744,"props":2660,"children":2661},{"class":746,"line":840},[2662],{"type":45,"tag":744,"props":2663,"children":2664},{},[2665],{"type":51,"value":2666},"    \"\"\"\n",{"type":45,"tag":744,"props":2668,"children":2669},{"class":746,"line":871},[2670],{"type":45,"tag":744,"props":2671,"children":2672},{},[2673],{"type":51,"value":2674},"    bundle = {\n",{"type":45,"tag":744,"props":2676,"children":2677},{"class":746,"line":949},[2678],{"type":45,"tag":744,"props":2679,"children":2680},{},[2681],{"type":51,"value":2682},"        \"resourceType\": \"Bundle\",\n",{"type":45,"tag":744,"props":2684,"children":2685},{"class":746,"line":975},[2686],{"type":45,"tag":744,"props":2687,"children":2688},{},[2689],{"type":51,"value":2690},"        \"type\": \"batch\",\n",{"type":45,"tag":744,"props":2692,"children":2693},{"class":746,"line":1054},[2694],{"type":45,"tag":744,"props":2695,"children":2696},{},[2697],{"type":51,"value":2698},"        \"entry\": [{\"request\": req} for req in requests_list]\n",{"type":45,"tag":744,"props":2700,"children":2701},{"class":746,"line":1128},[2702],{"type":45,"tag":744,"props":2703,"children":2704},{},[2705],{"type":51,"value":2706},"    }\n",{"type":45,"tag":744,"props":2708,"children":2709},{"class":746,"line":1137},[2710],{"type":45,"tag":744,"props":2711,"children":2712},{},[2713],{"type":51,"value":2714},"    import subprocess, json\n",{"type":45,"tag":744,"props":2716,"children":2717},{"class":746,"line":1261},[2718],{"type":45,"tag":744,"props":2719,"children":2720},{},[2721],{"type":51,"value":2722},"    r = subprocess.run(\n",{"type":45,"tag":744,"props":2724,"children":2725},{"class":746,"line":1270},[2726],{"type":45,"tag":744,"props":2727,"children":2728},{},[2729],{"type":51,"value":2730},"        [\"curl\", \"-sf\", \"--max-time\", \"60\",\n",{"type":45,"tag":744,"props":2732,"children":2733},{"class":746,"line":1387},[2734],{"type":45,"tag":744,"props":2735,"children":2736},{},[2737],{"type":51,"value":2738},"         \"-X\", \"POST\", \"-H\", \"Content-Type: application\u002Ffhir+json\",\n",{"type":45,"tag":744,"props":2740,"children":2741},{"class":746,"line":1395},[2742],{"type":45,"tag":744,"props":2743,"children":2744},{},[2745],{"type":51,"value":2746},"         \"-d\", json.dumps(bundle), f\"{BASE_URL}\"],\n",{"type":45,"tag":744,"props":2748,"children":2749},{"class":746,"line":1404},[2750],{"type":45,"tag":744,"props":2751,"children":2752},{},[2753],{"type":51,"value":2754},"        capture_output=True, text=True, timeout=65\n",{"type":45,"tag":744,"props":2756,"children":2757},{"class":746,"line":1413},[2758],{"type":45,"tag":744,"props":2759,"children":2760},{},[2761],{"type":51,"value":2762},"    )\n",{"type":45,"tag":744,"props":2764,"children":2765},{"class":746,"line":1422},[2766],{"type":45,"tag":744,"props":2767,"children":2768},{},[2769],{"type":51,"value":2770},"    if r.returncode != 0 or not r.stdout.strip():\n",{"type":45,"tag":744,"props":2772,"children":2773},{"class":746,"line":1431},[2774],{"type":45,"tag":744,"props":2775,"children":2776},{},[2777],{"type":51,"value":2778},"        return []\n",{"type":45,"tag":744,"props":2780,"children":2781},{"class":746,"line":1439},[2782],{"type":45,"tag":744,"props":2783,"children":2784},{},[2785],{"type":51,"value":2786},"    result = json.loads(r.stdout)\n",{"type":45,"tag":744,"props":2788,"children":2789},{"class":746,"line":1448},[2790],{"type":45,"tag":744,"props":2791,"children":2792},{},[2793],{"type":51,"value":2794},"    return result.get('entry', [])\n",{"type":45,"tag":220,"props":2796,"children":2798},{"id":2797},"when-to-use-which-pattern",[2799],{"type":51,"value":2800},"When to use which pattern",{"type":45,"tag":347,"props":2802,"children":2803},{},[2804,2825],{"type":45,"tag":351,"props":2805,"children":2806},{},[2807],{"type":45,"tag":355,"props":2808,"children":2809},{},[2810,2815,2820],{"type":45,"tag":359,"props":2811,"children":2812},{},[2813],{"type":51,"value":2814},"Scenario",{"type":45,"tag":359,"props":2816,"children":2817},{},[2818],{"type":51,"value":2819},"Pattern",{"type":45,"tag":359,"props":2821,"children":2822},{},[2823],{"type":51,"value":2824},"Why",{"type":45,"tag":375,"props":2826,"children":2827},{},[2828,2846,2864,2882],{"type":45,"tag":355,"props":2829,"children":2830},{},[2831,2836,2841],{"type":45,"tag":382,"props":2832,"children":2833},{},[2834],{"type":51,"value":2835},"Labs for a cohort (same LOINC, many patients)",{"type":45,"tag":382,"props":2837,"children":2838},{},[2839],{"type":51,"value":2840},"Pattern 1: code-only query",{"type":45,"tag":382,"props":2842,"children":2843},{},[2844],{"type":51,"value":2845},"One call gets everything; filter in Python",{"type":45,"tag":355,"props":2847,"children":2848},{},[2849,2854,2859],{"type":45,"tag":382,"props":2850,"children":2851},{},[2852],{"type":51,"value":2853},"Labs for a specific patient list",{"type":45,"tag":382,"props":2855,"children":2856},{},[2857],{"type":51,"value":2858},"Pattern 2: comma-separated patients",{"type":45,"tag":382,"props":2860,"children":2861},{},[2862],{"type":51,"value":2863},"Scoped to your cohort; one call",{"type":45,"tag":355,"props":2865,"children":2866},{},[2867,2872,2877],{"type":45,"tag":382,"props":2868,"children":2869},{},[2870],{"type":51,"value":2871},"Mixed data (labs + meds + conditions per patient)",{"type":45,"tag":382,"props":2873,"children":2874},{},[2875],{"type":51,"value":2876},"Pattern 3: batch Bundle",{"type":45,"tag":382,"props":2878,"children":2879},{},[2880],{"type":51,"value":2881},"Multiple queries, single HTTP round-trip",{"type":45,"tag":355,"props":2883,"children":2884},{},[2885,2890,2895],{"type":45,"tag":382,"props":2886,"children":2887},{},[2888],{"type":51,"value":2889},"Single patient lookup",{"type":45,"tag":382,"props":2891,"children":2892},{},[2893],{"type":51,"value":2894},"Individual GET",{"type":45,"tag":382,"props":2896,"children":2897},{},[2898],{"type":51,"value":2899},"Fine for 1-2 patients",{"type":45,"tag":111,"props":2901,"children":2903},{"id":2902},"bulk-fhir-production-scale",[2904],{"type":51,"value":2905},"Bulk FHIR (Production-Scale)",{"type":45,"tag":54,"props":2907,"children":2908},{},[2909,2911,2917],{"type":51,"value":2910},"For production population health workflows (not used in this demo, but important context): FHIR Bulk Data Access (SMART\u002FHL7) allows exporting entire patient populations as NDJSON files via an async ",{"type":45,"tag":66,"props":2912,"children":2914},{"className":2913},[],[2915],{"type":51,"value":2916},"$export",{"type":51,"value":2918}," operation. This is how real quality measure engines work at scale -- they don't query patient-by-patient. The demo uses individual queries for clarity and because the public test server doesn't support Bulk FHIR.",{"type":45,"tag":111,"props":2920,"children":2922},{"id":2921},"error-handling",[2923],{"type":51,"value":2924},"Error Handling",{"type":45,"tag":166,"props":2926,"children":2927},{},[2928,2940,2957,2970,2975,3019,3024],{"type":45,"tag":170,"props":2929,"children":2930},{},[2931,2932,2938],{"type":51,"value":1148},{"type":45,"tag":66,"props":2933,"children":2935},{"className":2934},[],[2936],{"type":51,"value":2937},"response.status_code",{"type":51,"value":2939}," before parsing JSON",{"type":45,"tag":170,"props":2941,"children":2942},{},[2943,2945,2950,2952],{"type":51,"value":2944},"Check if ",{"type":45,"tag":66,"props":2946,"children":2948},{"className":2947},[],[2949],{"type":51,"value":881},{"type":51,"value":2951}," exists in the response before iterating: ",{"type":45,"tag":66,"props":2953,"children":2955},{"className":2954},[],[2956],{"type":51,"value":1154},{"type":45,"tag":170,"props":2958,"children":2959},{},[2960,2962,2968],{"type":51,"value":2961},"Some fields may be missing -- use ",{"type":45,"tag":66,"props":2963,"children":2965},{"className":2964},[],[2966],{"type":51,"value":2967},".get()",{"type":51,"value":2969}," with sensible defaults",{"type":45,"tag":170,"props":2971,"children":2972},{},[2973],{"type":51,"value":2974},"Never fabricate data. If a field is absent, report \"Not recorded\"",{"type":45,"tag":170,"props":2976,"children":2977},{},[2978,2980,2986,2988],{"type":51,"value":2979},"Handle ",{"type":45,"tag":66,"props":2981,"children":2983},{"className":2982},[],[2984],{"type":51,"value":2985},"OperationOutcome",{"type":51,"value":2987}," responses (FHIR error format):\n",{"type":45,"tag":227,"props":2989,"children":2991},{"className":1172,"code":2990,"language":71,"meta":235,"style":235},"if response.json().get('resourceType') == 'OperationOutcome':\n    issues = response.json().get('issue', [])\n    error_msg = issues[0].get('diagnostics', 'Unknown FHIR error') if issues else 'Unknown error'\n",[2992],{"type":45,"tag":66,"props":2993,"children":2994},{"__ignoreMap":235},[2995,3003,3011],{"type":45,"tag":744,"props":2996,"children":2997},{"class":746,"line":747},[2998],{"type":45,"tag":744,"props":2999,"children":3000},{},[3001],{"type":51,"value":3002},"if response.json().get('resourceType') == 'OperationOutcome':\n",{"type":45,"tag":744,"props":3004,"children":3005},{"class":746,"line":757},[3006],{"type":45,"tag":744,"props":3007,"children":3008},{},[3009],{"type":51,"value":3010},"    issues = response.json().get('issue', [])\n",{"type":45,"tag":744,"props":3012,"children":3013},{"class":746,"line":802},[3014],{"type":45,"tag":744,"props":3015,"children":3016},{},[3017],{"type":51,"value":3018},"    error_msg = issues[0].get('diagnostics', 'Unknown FHIR error') if issues else 'Unknown error'\n",{"type":45,"tag":170,"props":3020,"children":3021},{},[3022],{"type":51,"value":3023},"Rate limiting: The public SMART test server has no rate limits, but production endpoints may. Add a small delay (0.1-0.5s) between calls in tight loops",{"type":45,"tag":170,"props":3025,"children":3026},{},[3027,3029,3035],{"type":51,"value":3028},"Timeout: Use ",{"type":45,"tag":66,"props":3030,"children":3032},{"className":3031},[],[3033],{"type":51,"value":3034},"--max-time 30",{"type":51,"value":3036}," with curl; FHIR servers can be slow under load",{"type":45,"tag":3038,"props":3039,"children":3040},"style",{},[3041],{"type":51,"value":3042},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"items":3044,"total":1261},[3045,3060,3073,3088,3103,3114,3131],{"slug":3046,"name":3046,"fn":3047,"description":3048,"org":3049,"tags":3050,"stars":23,"repoUrl":24,"updatedAt":3059},"analysis-methods","write Python analysis code for FHIR data","Teaches the analyst agent how to write correct, robust Python analysis code for FHIR clinical data using pandas, matplotlib, and scipy.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[3051,3054,3055,3056,3057],{"name":3052,"slug":3053,"type":15},"Data Analysis","data-analysis",{"name":18,"slug":19,"type":15},{"name":13,"slug":14,"type":15},{"name":9,"slug":8,"type":15},{"name":3058,"slug":71,"type":15},"Python","2026-07-14T05:35:59.037962",{"slug":3061,"name":3061,"fn":3062,"description":3063,"org":3064,"tags":3065,"stars":23,"repoUrl":24,"updatedAt":3072},"case-summary","summarize clinical patient cases from FHIR","Prepare a complete clinical case summary for a patient from FHIR endpoints. Use when asked to summarize a patient, compile a case, or prepare for tumor board.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[3066,3067,3068,3069],{"name":18,"slug":19,"type":15},{"name":13,"slug":14,"type":15},{"name":9,"slug":8,"type":15},{"name":3070,"slug":3071,"type":15},"Summarization","summarization","2026-07-14T05:35:52.790528",{"slug":3074,"name":3074,"fn":3075,"description":3076,"org":3077,"tags":3078,"stars":23,"repoUrl":24,"updatedAt":3087},"clinical-delegation","delegate clinical tasks to specialist agents","How to delegate clinical tasks to specialist agents. Always use sub-agent runtime with explicit agentId — never ACP. Never call FHIR via web_fetch.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[3079,3082,3083,3086],{"name":3080,"slug":3081,"type":15},"Agents","agents",{"name":13,"slug":14,"type":15},{"name":3084,"slug":3085,"type":15},"Multi-Agent","multi-agent",{"name":9,"slug":8,"type":15},"2026-07-14T05:35:55.294972",{"slug":3089,"name":3089,"fn":3090,"description":3091,"org":3092,"tags":3093,"stars":23,"repoUrl":24,"updatedAt":3102},"clinical-knowledge","provide clinical reference and regulatory context","Teaches agents clinical reference ranges, condition codes, quality measure definitions, drug classifications, and regulatory context so they can flag abnormal values and identify care gaps.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[3094,3097,3098,3099],{"name":3095,"slug":3096,"type":15},"Clinical Trials","clinical-trials",{"name":13,"slug":14,"type":15},{"name":9,"slug":8,"type":15},{"name":3100,"slug":3101,"type":15},"Regulatory Compliance","regulatory-compliance","2026-07-14T05:35:56.550833",{"slug":3104,"name":3104,"fn":3105,"description":3106,"org":3107,"tags":3108,"stars":23,"repoUrl":24,"updatedAt":3113},"cohort-compare","analyze patient cohorts from FHIR endpoints","Analyze a cohort of patients from FHIR endpoints to find care gaps and patterns. Use when asked to compare patients, find quality gaps, or analyze a population.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[3109,3110,3111,3112],{"name":3052,"slug":3053,"type":15},{"name":18,"slug":19,"type":15},{"name":13,"slug":14,"type":15},{"name":9,"slug":8,"type":15},"2026-07-14T05:35:51.543095",{"slug":3115,"name":3115,"fn":3116,"description":3117,"org":3118,"tags":3119,"stars":23,"repoUrl":24,"updatedAt":3130},"dgx-diagnose","diagnose NVIDIA DGX Station hardware issues","Diagnose common DGX Station GB300 issues — CUDA crashes, wrong-GPU targeting, vLLM\u002FSGLang container bugs, MIG state problems, NVLink\u002FFabric Manager errors, X\u002FVulkan failures, HuggingFace auth, and port conflicts. Use when the user reports a GPU error, inference server crash, MIG problem, or any unexplained DGX Station failure.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[3120,3123,3126,3127],{"name":3121,"slug":3122,"type":15},"AI Infrastructure","ai-infrastructure",{"name":3124,"slug":3125,"type":15},"Debugging","debugging",{"name":9,"slug":8,"type":15},{"name":3128,"slug":3129,"type":15},"Observability","observability","2026-07-14T05:31:04.085598",{"slug":4,"name":4,"fn":5,"description":6,"org":3132,"tags":3133,"stars":23,"repoUrl":24,"updatedAt":25},{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[3134,3135,3136,3137],{"name":21,"slug":22,"type":15},{"name":18,"slug":19,"type":15},{"name":13,"slug":14,"type":15},{"name":9,"slug":8,"type":15},{"items":3139,"total":3294},[3140,3158,3174,3185,3197,3209,3222,3236,3249,3260,3274,3283],{"slug":3141,"name":3141,"fn":3142,"description":3143,"org":3144,"tags":3145,"stars":3155,"repoUrl":3156,"updatedAt":3157},"nemoclaw-user-guide","retrieve NemoClaw documentation and configuration","Guides human users' AI agents to the NemoClaw docs MCP server and canonical Fern documentation in Markdown form. Use when users ask how to install, configure, operate, troubleshoot, secure, or learn NemoClaw with an AI coding assistant. Trigger keywords - nemoclaw docs, use nemoclaw with ai agent, nemoclaw mcp docs, nemoclaw install help, nemoclaw quickstart, nemoclaw markdown docs, llms.txt, agent skills.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[3146,3149,3152],{"name":3147,"slug":3148,"type":15},"Documentation","documentation",{"name":3150,"slug":3151,"type":15},"MCP","mcp",{"name":3153,"slug":3154,"type":15},"Search","search",21777,"https:\u002F\u002Fgithub.com\u002FNVIDIA\u002FNemoClaw","2026-07-20T06:00:01.461044",{"slug":3159,"name":3159,"fn":3160,"description":3161,"org":3162,"tags":3163,"stars":3171,"repoUrl":3172,"updatedAt":3173},"mcore-build-and-dependency","manage Megatron-LM development environments","Container-based dev environment setup and dependency management for Megatron-LM. Covers acquiring and launching the CI container, uv package management, and updating uv.lock.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[3164,3167,3170],{"name":3165,"slug":3166,"type":15},"Containers","containers",{"name":3168,"slug":3169,"type":15},"Deployment","deployment",{"name":3058,"slug":71,"type":15},17049,"https:\u002F\u002Fgithub.com\u002FNVIDIA\u002FMegatron-LM","2026-07-27T06:06:11.249662",{"slug":3175,"name":3175,"fn":3176,"description":3177,"org":3178,"tags":3179,"stars":3171,"repoUrl":3172,"updatedAt":3184},"mcore-bump-base-image","update NVIDIA PyTorch base images","Bump the NVIDIA PyTorch base image (`nvcr.io\u002Fnvidia\u002Fpytorch:YY.MM-py3`) used by Megatron-LM CI. Covers the two pin sites (GitHub CI in `docker\u002F.ngc_version.dev` and GitLab CI in `.gitlab\u002Fstages\u002F01.build.yml`), the post-bump CI loop (re-run functional tests, refresh golden values, mark broken tests), and the gotchas that bit PRs",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[3180,3183],{"name":3181,"slug":3182,"type":15},"CI\u002FCD","ci-cd",{"name":3168,"slug":3169,"type":15},"2026-07-14T05:25:59.97109",{"slug":3186,"name":3186,"fn":3187,"description":3188,"org":3189,"tags":3190,"stars":3171,"repoUrl":3172,"updatedAt":3196},"mcore-cicd","manage CI\u002FCD pipelines for Megatron-LM","CI\u002FCD reference for Megatron-LM. Covers CI pipeline structure, PR scope labels, triggering internal GitLab CI (which force-pushes the current branch to a pull-request\u002FBRANCH ref — always dry-run and verify the destination first; never run against shared or protected branches), and CI failure investigation.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[3191,3192,3193],{"name":3181,"slug":3182,"type":15},{"name":3168,"slug":3169,"type":15},{"name":3194,"slug":3195,"type":15},"GitHub","github","2026-07-27T06:06:12.278222",{"slug":3198,"name":3198,"fn":3199,"description":3200,"org":3201,"tags":3202,"stars":3171,"repoUrl":3172,"updatedAt":3208},"mcore-create-issue","investigate CI failures and create issues","Investigate a failing GitHub Actions run or job and create a GitHub issue for the failure.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[3203,3204,3205],{"name":3124,"slug":3125,"type":15},{"name":3194,"slug":3195,"type":15},{"name":3206,"slug":3207,"type":15},"Triage","triage","2026-07-14T05:25:57.442089",{"slug":3210,"name":3210,"fn":3211,"description":3212,"org":3213,"tags":3214,"stars":3171,"repoUrl":3172,"updatedAt":3221},"mcore-linting-and-formatting","lint and format Megatron-LM code","Linting and formatting for Megatron-LM. Covers running autoformat.sh, tools (ruff, black, isort, pylint, mypy), and code style rules.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[3215,3218],{"name":3216,"slug":3217,"type":15},"Best Practices","best-practices",{"name":3219,"slug":3220,"type":15},"Code Analysis","code-analysis","2026-07-14T05:25:56.18433",{"slug":3223,"name":3223,"fn":3224,"description":3225,"org":3226,"tags":3227,"stars":3171,"repoUrl":3172,"updatedAt":3235},"mcore-migrate-gpt-to-hybrid","migrate Megatron-LM models to HybridModel","Migration guide for moving Megatron Core GPTModel checkpoints, model providers, training commands, and layer mappings to HybridModel.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[3228,3231,3234],{"name":3229,"slug":3230,"type":15},"Machine Learning","machine-learning",{"name":3232,"slug":3233,"type":15},"Migration","migration",{"name":9,"slug":8,"type":15},"2026-07-17T06:07:11.777011",{"slug":3237,"name":3237,"fn":3238,"description":3239,"org":3240,"tags":3241,"stars":3171,"repoUrl":3172,"updatedAt":3248},"mcore-onboard-gb200-1node-tests","onboard functional tests for GB200","Onboard 1-node GitHub MR functional tests for GB200 from existing mr-scoped 2-node tests.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[3242,3245],{"name":3243,"slug":3244,"type":15},"QA","qa",{"name":3246,"slug":3247,"type":15},"Testing","testing","2026-07-14T05:25:53.673039",{"slug":3250,"name":3250,"fn":3251,"description":3252,"org":3253,"tags":3254,"stars":3171,"repoUrl":3172,"updatedAt":3259},"mcore-run-on-slurm","launch distributed training jobs on SLURM","How to launch distributed Megatron-LM training jobs on a SLURM cluster. Covers a minimal sbatch skeleton, environment-variable setup for torch.distributed.run, CUDA_DEVICE_MAX_CONNECTIONS rules across hardware and parallelism modes, container conventions, monitoring, and per-rank failure diagnosis.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[3255,3256],{"name":3168,"slug":3169,"type":15},{"name":3257,"slug":3258,"type":15},"Infrastructure","infrastructure","2026-07-14T05:25:49.362534",{"slug":3261,"name":3261,"fn":3262,"description":3263,"org":3264,"tags":3265,"stars":3171,"repoUrl":3172,"updatedAt":3273},"mcore-split-pr","split pull requests to reduce review load","Split a PR into multiple PRs to reduce the number of required CODEOWNERS reviewer groups.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[3266,3269,3270],{"name":3267,"slug":3268,"type":15},"Code Review","code-review",{"name":3194,"slug":3195,"type":15},{"name":3271,"slug":3272,"type":15},"Pull Requests","pull-requests","2026-07-14T05:26:01.226578",{"slug":3275,"name":3275,"fn":3276,"description":3277,"org":3278,"tags":3279,"stars":3171,"repoUrl":3172,"updatedAt":3282},"mcore-testing","run and manage Megatron-LM tests","Test system for Megatron-LM. Covers test layout, recipe YAML structure, adding and running unit and functional tests, golden values, marker filters, and CI parity.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[3280,3281],{"name":3243,"slug":3244,"type":15},{"name":3246,"slug":3247,"type":15},"2026-07-14T05:25:54.928983",{"slug":3284,"name":3284,"fn":3285,"description":3286,"org":3287,"tags":3288,"stars":3171,"repoUrl":3172,"updatedAt":3293},"nightly-sync","manage nightly main-to-dev sync workflows","Domain knowledge for the nightly main-to-dev sync workflow. Covers merge strategy, CI architecture, failure investigation, and known issues.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":9},[3289,3292],{"name":3290,"slug":3291,"type":15},"Automation","automation",{"name":3181,"slug":3182,"type":15},"2026-07-30T05:29:03.275638",496]