[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-aws-labs-ehr-data-parsing":3,"mdc-grtqca-key":50,"related-org-aws-labs-ehr-data-parsing":3299,"related-repo-aws-labs-ehr-data-parsing":3481},{"slug":4,"name":4,"fn":5,"description":6,"org":7,"tags":12,"stars":26,"repoUrl":27,"updatedAt":28,"license":29,"forks":30,"topics":31,"repo":45,"sourceUrl":48,"mdContent":49},"ehr-data-parsing","parse and extract clinical data","Parse and extract clinical data from HL7v2 messages and FHIR R4 resources using Python. Use when the user mentions HL7v2, HL7, FHIR, PID segment, OBX segment, MSH segment, Patient resource, Observation resource, Condition resource, MedicationRequest, EHR data extraction, clinical message parsing, FHIR bundle, HL7 to FHIR conversion, ADT message, ORU message, lab result extraction, or clinical data quality checks. Triggers include \"parse HL7\", \"extract FHIR\", \"HL7v2 message\", \"FHIR resource\", \"PID segment\", \"OBX segment\", \"Patient resource\", \"Observation resource\", \"EHR parsing\", \"clinical data extraction\", \"HL7 to CSV\", \"FHIR to DataFrame\".",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},"aws-labs","AWS Labs","https:\u002F\u002Fpexgzepcugksgbtrxkhf.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Forg-logos\u002Faws-labs.png","awslabs",[13,17,20,23],{"name":14,"slug":15,"type":16},"Healthcare","healthcare","tag",{"name":18,"slug":19,"type":16},"Interoperability","interoperability",{"name":21,"slug":22,"type":16},"Python","python",{"name":24,"slug":25,"type":16},"FHIR","fhir",4,"https:\u002F\u002Fgithub.com\u002Fawslabs\u002Fhcls-agent-skills","2026-07-12T08:37:36.137905",null,0,[32,33,34,35,36,37,38,39,40,41,42,43,44],"agent-skills","agentcore","ai-agents","amazon-quick-desktop","claims-processing","drug-discovery","genomics","healthcare-ai","kiro","life-sciences","medical-imaging","risk-adjustment","strands-agents",{"repoUrl":27,"stars":26,"forks":30,"topics":46,"description":47},[32,33,34,35,36,37,38,39,40,41,42,43,44],"Agent skills for healthcare and life sciences: genomics, imaging, claims, drug discovery, and more. Works with Amazon Quick, Kiro, Amazon AgentCore, AWS Strands SDK, Claude Code, Codex, and any Agent Skills-compatible platform.","https:\u002F\u002Fgithub.com\u002Fawslabs\u002Fhcls-agent-skills\u002Ftree\u002FHEAD\u002Fskills\u002Fehr-data-parsing","---\nname: ehr-data-parsing\ndescription: Parse and extract clinical data from HL7v2 messages and FHIR R4 resources using Python. Use when the user mentions HL7v2, HL7, FHIR, PID segment, OBX segment, MSH segment, Patient resource, Observation resource, Condition resource, MedicationRequest, EHR data extraction, clinical message parsing, FHIR bundle, HL7 to FHIR conversion, ADT message, ORU message, lab result extraction, or clinical data quality checks. Triggers include \"parse HL7\", \"extract FHIR\", \"HL7v2 message\", \"FHIR resource\", \"PID segment\", \"OBX segment\", \"Patient resource\", \"Observation resource\", \"EHR parsing\", \"clinical data extraction\", \"HL7 to CSV\", \"FHIR to DataFrame\".\nusage: Invoke when parsing HL7v2 messages, extracting FHIR R4 resources, converting between clinical data formats, or running data quality checks on EHR data.\nversion: 1.0.0\nvalidated_against:\n  date: 2025-01-15\n  packages: {hl7apy: \"1.3.4\", fhir-resources: \"R4\"}\ntags: [skill, category:pipeline, ehr, hl7, fhir, clinical-data, interoperability, hcls]\n---\n\n# EHR Data Parsing\n\n## Overview\n\nThis skill encodes Python pipelines for parsing clinical data from two\ndominant formats: HL7v2 (pipe-delimited messages) and FHIR R4 (JSON\nresources). It covers extraction of patient demographics, lab results,\ndiagnoses, and medications, plus format conversion and data quality checks.\n\nScope:\n- HL7v2 message parsing (MSH, PID, PV1, OBR, OBX segments)\n- FHIR R4 resource extraction (Patient, Observation, Condition, MedicationRequest)\n- HL7v2 → tabular (CSV\u002FDataFrame) conversion\n- FHIR Bundle iteration and flattening\n- Data quality checks (completeness, date validation, code system verification)\n\nOut of scope: HL7v3\u002FCDA parsing, FHIR server deployment, SMART on FHIR\nauthentication, real-time message routing.\n\n## Usage\n\nInvoke when the user asks to:\n- Parse an HL7v2 message or batch file\n- Extract patient demographics, labs, diagnoses, or medications from FHIR\n- Convert HL7v2 messages to CSV or pandas DataFrames\n- Flatten FHIR Bundles into tabular format\n- Run quality checks on clinical data extracts\n\nThe skill emits Python code using `python-hl7` for HL7v2 and `fhir.resources`\nfor FHIR R4. Install dependencies:\n\n```bash\npip install python-hl7 fhir.resources pandas\n```\n\n\n## Response Format\n\n- Lead with the command or code the user needs — explain after\n- Structure as: confirm inputs → working code → key parameters explained → gotchas\n- One complete working example per task; do not show every alternative\n- Keep code comments minimal and functional (what, not why-it-exists)\n- Target: 50-100 lines of code with brief surrounding explanation\n\n## Core Concepts\n\n### Parser Selection Decision Tree\n\n```\nWhat is the input format?\n├─ HL7v2 (pipe-delimited, segments start with MSH|PID|OBX...)\n│  ├─ Message type?\n│  │  ├─ ORU^R01 (lab results) → extract OBR + OBX segments\n│  │  ├─ ADT^A01\u002FA08 (admit\u002Fupdate) → extract PID + PV1 segments\n│  │  └─ ORM^O01 (orders) → extract ORC + OBR segments\n│  └─ Library: python-hl7 (parse → segment → field access)\n└─ FHIR R4 (JSON resources)\n   ├─ Single resource → fhir.resources model_validate(json)\n   └─ Bundle → iterate entry[], check resource_type, follow pagination (link.next)\n      ├─ Extract by system URI, not array position\n      └─ Check choice types (valueQuantity vs valueCodeableConcept)\n```\n\n### HL7v2 Message Structure\n\nHL7v2 messages are pipe-delimited, segment-based. Each segment starts with\na 3-character identifier followed by fields separated by `|`.\n\n#### Key segments\n\n| Segment | Name | Contains |\n|---|---|---|\n| MSH | Message Header | Sending\u002Freceiving app, message type, timestamp, version |\n| PID | Patient Identification | MRN, name, DOB, sex, address, phone |\n| PV1 | Patient Visit | Visit number, patient class, attending physician |\n| OBR | Observation Request | Order number, test ordered, ordering provider |\n| OBX | Observation Result | Result value, units, reference range, abnormal flag |\n| DG1 | Diagnosis | Diagnosis code, type, description |\n| AL1 | Allergy | Allergen, reaction, severity |\n\n#### Common message types\n\n| Type | Trigger | Use |\n|---|---|---|\n| ADT^A01 | Admit | Patient admission |\n| ADT^A08 | Update | Patient information update |\n| ORU^R01 | Observation | Lab\u002Fradiology results |\n| ORM^O01 | Order | New order placed |\n| MDM^T02 | Document | Document notification |\n\n### 1. Parse HL7v2 Messages\n\n```python\nimport hl7\n\nraw = (\n    \"MSH|^~\\\\&|LAB|HOSP|EHR|HOSP|20240115120000||ORU^R01|MSG001|P|2.5\\r\"\n    \"PID|1||MRN123^^^HOSP^MR||DOE^JOHN^A||19800315|M|||\"\n    \"123 MAIN ST^^ANYTOWN^CA^90210\\r\"\n    \"OBR|1|ORD001||CBC^Complete Blood Count^L|||20240115080000\\r\"\n    \"OBX|1|NM|WBC^White Blood Cell Count^L||7.5|10*3\u002FuL|4.5-11.0|N|||F\\r\"\n    \"OBX|2|NM|HGB^Hemoglobin^L||14.2|g\u002FdL|12.0-17.5|N|||F\\r\"\n    \"OBX|3|NM|PLT^Platelet Count^L||250|10*3\u002FuL|150-400|N|||F\\r\"\n)\n\nmsg = hl7.parse(raw)\n```\n\n#### Extract patient demographics from PID\n\n```python\ndef extract_pid(msg):\n    pid = msg.segment(\"PID\")\n    return {\n        \"mrn\": str(pid(3)(0)(0)),          # PID-3.1: patient ID\n        \"last_name\": str(pid(5)(0)(0)),     # PID-5.1: family name\n        \"first_name\": str(pid(5)(0)(1)),    # PID-5.2: given name\n        \"dob\": str(pid(7)),                 # PID-7: date of birth\n        \"sex\": str(pid(8)),                 # PID-8: administrative sex\n    }\n\ndemographics = extract_pid(msg)\n# {'mrn': 'MRN123', 'last_name': 'DOE', 'first_name': 'JOHN',\n#  'dob': '19800315', 'sex': 'M'}\n```\n\n#### PID field reference\n\n| Field | Position | Format |\n|---|---|---|\n| Patient ID | PID-3 | CX datatype (ID^^^authority^type) |\n| Patient Name | PID-5 | XPN: Family^Given^Middle |\n| Date of Birth | PID-7 | YYYYMMDD |\n| Sex | PID-8 | M, F, O, U |\n| Address | PID-11 | XAD: Street^City^State^Zip |\n| Phone | PID-13 | XTN datatype |\n\n#### Extract lab results from OBX segments\n\n```python\ndef extract_obx_results(msg):\n    results = []\n    for segment in msg:\n        if str(segment(0)) == \"OBX\":\n            results.append({\n                \"set_id\": str(segment(1)),\n                \"value_type\": str(segment(2)),       # NM=numeric, ST=string, CE=coded\n                \"test_code\": str(segment(3)(0)(0)),   # OBX-3.1: identifier\n                \"test_name\": str(segment(3)(0)(1)),   # OBX-3.2: text\n                \"value\": str(segment(5)),             # OBX-5: observation value\n                \"units\": str(segment(6)),             # OBX-6: units\n                \"ref_range\": str(segment(7)),         # OBX-7: reference range\n                \"abnormal_flag\": str(segment(8)),     # OBX-8: N\u002FH\u002FL\u002FA\n                \"status\": str(segment(11)),           # OBX-11: F=final, P=preliminary\n            })\n    return results\n\nlabs = extract_obx_results(msg)\n```\n\n#### OBX value types and status codes\n\n| OBX-2 | Meaning | OBX-8 | Meaning | OBX-11 | Meaning |\n|---|---|---|---|---|---|\n| NM | Numeric | N | Normal | F | Final |\n| ST | String | H | High | P | Preliminary |\n| CE | Coded entry | L | Low | C | Corrected |\n\n### 2. Batch HL7v2 Processing\n\n```python\nimport hl7\nimport pandas as pd\n\ndef parse_hl7_file(filepath):\n    \"\"\"Parse a file containing multiple HL7v2 messages separated by blank lines.\"\"\"\n    with open(filepath, \"r\") as f:\n        content = f.read()\n\n    raw_messages = content.strip().split(\"\\nMSH|\")\n    raw_messages = [raw_messages[0]] + [\"MSH|\" + m for m in raw_messages[1:]]\n\n    all_results = []\n    for raw in raw_messages:\n        raw = raw.strip().replace(\"\\n\", \"\\r\")\n        if not raw:\n            continue\n        msg = hl7.parse(raw)\n        demo = extract_pid(msg)\n        for lab in extract_obx_results(msg):\n            all_results.append({**demo, **lab})\n\n    return pd.DataFrame(all_results)\n\ndf = parse_hl7_file(\"lab_results.hl7\")\n```\n\n### 3. FHIR R4 Resource Extraction\n\n#### Parse a Patient resource\n\n```python\nfrom fhir.resources.patient import Patient\n\npatient_json = {\n    \"resourceType\": \"Patient\",\n    \"id\": \"example-001\",\n    \"identifier\": [\n        {\"system\": \"http:\u002F\u002Fhospital.example.org\u002Fmrn\", \"value\": \"MRN123\"}\n    ],\n    \"name\": [{\"family\": \"Doe\", \"given\": [\"John\", \"A\"]}],\n    \"gender\": \"male\",\n    \"birthDate\": \"1980-03-15\",\n    \"address\": [\n        {\"line\": [\"123 Main St\"], \"city\": \"Anytown\", \"state\": \"CA\", \"postalCode\": \"90210\"}\n    ],\n}\n\npatient = Patient.model_validate(patient_json)\n\ndemographics = {\n    \"id\": patient.id,\n    \"mrn\": patient.identifier[0].value if patient.identifier else None,\n    \"last_name\": patient.name[0].family if patient.name else None,\n    \"first_name\": patient.name[0].given[0] if patient.name and patient.name[0].given else None,\n    \"gender\": patient.gender,\n    \"birth_date\": str(patient.birthDate) if patient.birthDate else None,\n}\n```\n\n#### Extract Observation, Condition, MedicationRequest\n\nPattern: `model_validate(json)` → extract by system URI, not array position.\n\n```python\nfrom fhir.resources.observation import Observation\nfrom fhir.resources.condition import Condition\nfrom fhir.resources.medicationrequest import MedicationRequest\n\ndef extract_observation(obs_json):\n    obs = Observation.model_validate(obs_json)\n    return {\n        \"id\": obs.id, \"status\": obs.status,\n        \"loinc_code\": next((c.code for c in (obs.code.coding or []) if c.system == \"http:\u002F\u002Floinc.org\"), None),\n        \"display\": obs.code.coding[0].display if obs.code.coding else None,\n        \"value\": obs.valueQuantity.value if obs.valueQuantity else None,\n        \"unit\": obs.valueQuantity.unit if obs.valueQuantity else None,\n        \"effective_date\": str(obs.effectiveDateTime) if obs.effectiveDateTime else None,\n        \"patient_ref\": obs.subject.reference if obs.subject else None,\n    }\n\ndef extract_condition(cond_json):\n    cond = Condition.model_validate(cond_json)\n    return {\n        \"id\": cond.id,\n        \"status\": cond.clinicalStatus.coding[0].code if cond.clinicalStatus and cond.clinicalStatus.coding else None,\n        \"snomed_code\": next((c.code for c in (cond.code.coding or []) if c.system and \"snomed\" in c.system), None),\n        \"icd10_code\": next((c.code for c in (cond.code.coding or []) if c.system and \"icd-10\" in c.system), None),\n        \"display\": cond.code.coding[0].display if cond.code.coding else None,\n        \"onset\": str(cond.onsetDateTime) if cond.onsetDateTime else None,\n        \"patient_ref\": cond.subject.reference if cond.subject else None,\n    }\n\ndef extract_medication_request(med_json):\n    med = MedicationRequest.model_validate(med_json)\n    cc = med.medicationCodeableConcept\n    return {\n        \"id\": med.id, \"status\": med.status,\n        \"rxnorm_code\": cc.coding[0].code if cc and cc.coding else None,\n        \"display\": cc.coding[0].display if cc and cc.coding else None,\n        \"dosage_text\": med.dosageInstruction[0].text if med.dosageInstruction else None,\n        \"authored_on\": str(med.authoredOn) if med.authoredOn else None,\n        \"patient_ref\": med.subject.reference if med.subject else None,\n    }\n```\n\n### 4. FHIR Bundle Flattening\n\n```python\nimport json\nimport pandas as pd\nfrom fhir.resources.bundle import Bundle\n\ndef flatten_observation_bundle(bundle_json):\n    \"\"\"Extract all Observation resources from a FHIR Bundle into a DataFrame.\"\"\"\n    bundle = Bundle.model_validate(bundle_json)\n    rows = [extract_observation(entry.resource.model_dump())\n            for entry in (bundle.entry or [])\n            if entry.resource.resource_type == \"Observation\"]\n    return pd.DataFrame(rows)\n\nwith open(\"observations_bundle.json\") as f:\n    df = flatten_observation_bundle(json.load(f))\n```\n\n### 5. Data Quality Checks\n\n```python\nimport pandas as pd\nfrom datetime import datetime\n\ndef check_completeness(df, required_columns):\n    \"\"\"Report missing value rates for required columns.\"\"\"\n    report = {}\n    for col in required_columns:\n        if col not in df.columns:\n            report[col] = {\"status\": \"MISSING_COLUMN\", \"pct_complete\": 0.0}\n        else:\n            pct = (df[col].notna().sum() \u002F len(df)) * 100\n            report[col] = {\n                \"status\": \"OK\" if pct >= 95 else \"WARNING\" if pct >= 80 else \"FAIL\",\n                \"pct_complete\": round(pct, 1),\n            }\n    return report\n\ndef validate_dates(series, fmt=\"%Y-%m-%d\", min_date=\"1900-01-01\", max_date=None):\n    \"\"\"Validate date strings. Returns indices of invalid entries.\"\"\"\n    max_dt = datetime.strptime(max_date, fmt) if max_date else datetime.now()\n    min_dt = datetime.strptime(min_date, fmt)\n    invalid = []\n    for idx, val in series.items():\n        if pd.isna(val):\n            continue\n        try:\n            dt = datetime.strptime(str(val)[:10], fmt)\n            if dt \u003C min_dt or dt > max_dt:\n                invalid.append({\"index\": idx, \"value\": val, \"reason\": \"out_of_range\"})\n        except ValueError:\n            invalid.append({\"index\": idx, \"value\": val, \"reason\": \"parse_error\"})\n    return invalid\n\ndef verify_code_system(df, code_col, valid_codes, system_name=\"unknown\"):\n    \"\"\"Check that coded values belong to an expected set.\"\"\"\n    if code_col not in df.columns:\n        return {\"status\": \"MISSING_COLUMN\", \"invalid_count\": 0}\n    codes = df[code_col].dropna().unique()\n    invalid = [c for c in codes if c not in valid_codes]\n    return {\n        \"system\": system_name, \"total_unique\": len(codes),\n        \"invalid_codes\": invalid, \"invalid_count\": len(invalid),\n        \"status\": \"OK\" if len(invalid) == 0 else \"FAIL\",\n    }\n```\n\n#### Quality check thresholds\n\n| Check | Pass | Warning | Fail |\n|---|---|---|---|\n| Completeness (required field) | ≥ 95% | 80–95% | \u003C 80% |\n| Date validity | 0 parse errors | — | Any parse error |\n| Date range | All within expected range | — | Future dates or pre-1900 |\n| Code system membership | All codes valid | — | Any unrecognized code |\n| Duplicate patient IDs | 0 exact duplicates | — | Any duplicate MRN with conflicting demographics |\n\n### 6. HL7v2 to FHIR Conceptual Mapping\n\n| HL7v2 Segment | FHIR Resource | Key fields |\n|---|---|---|\n| PID | Patient | identifier, name, birthDate, gender |\n| PV1 | Encounter | class, period, participant |\n| OBR + OBX | Observation | code, value, effectiveDateTime, status |\n| DG1 | Condition | code, onsetDateTime, clinicalStatus |\n| ORC + RXE | MedicationRequest | medicationCodeableConcept, dosageInstruction |\n| AL1 | AllergyIntolerance | code, reaction, criticality |\n\n## Common Mistakes\n\n- **Wrong:** Assuming fixed field positions across all HL7v2 versions without checking for empty segments\n  **Right:** Always check for empty segments before accessing subfields — field positions are stable but optional fields may be absent\n  **Why:** Accessing a subfield of an empty segment raises index errors or returns incorrect data\n\n- **Wrong:** Splitting HL7v2 messages on `\\n` instead of `\\r`\n  **Right:** Normalize segment delimiters to `\\r` before parsing — many files use `\\r\\n` or `\\n`\n  **Why:** The HL7v2 standard segment delimiter is carriage return (`\\r`); incorrect splitting produces malformed segments\n\n- **Wrong:** Parsing OBX-5 without checking the value type in OBX-2\n  **Right:** Always check OBX-2 first — numeric (NM) and coded (CE) results require different parsing logic\n  **Why:** Misinterpreting a coded entry as numeric (or vice versa) produces corrupt data\n\n- **Wrong:** Treating all OBX segments as lab results\n  **Right:** Filter by OBR context or OBX-3 code system to distinguish labs from vitals, imaging impressions, and clinical notes\n  **Why:** OBX carries many observation types; assuming all are labs leads to mixed, unusable datasets\n\n- **Wrong:** Hardcoding FHIR resource field paths (e.g., always accessing `effectiveDateTime`)\n  **Right:** Check which choice type variant is present (e.g., `effectiveDateTime` vs `effectivePeriod`, `valueQuantity` vs `valueCodeableConcept`)\n  **Why:** FHIR allows choice types — hardcoded paths raise AttributeError or miss data when the alternate variant is used\n\n- **Wrong:** Including preliminary Observations (`status: \"preliminary\"`) in analysis datasets\n  **Right:** Filter on `status: \"final\"` for analysis — preliminary results may be superseded\n  **Why:** Preliminary results can be corrected or replaced, leading to duplicate or inaccurate data in analyses\n\n- **Wrong:** Extracting coded values by array position (e.g., `coding[0]`) instead of by system URI\n  **Right:** Extract by system URI (e.g., filter for `\"http:\u002F\u002Fsnomed.info\u002Fsct\"`) — a Condition may carry both SNOMED and ICD-10 codings\n  **Why:** Array order is not guaranteed; position-based access returns the wrong code system unpredictably\n\n- **Wrong:** Processing only the first page of a FHIR Bundle without checking for pagination\n  **Right:** Check `bundle.link` for `relation: \"next\"` and follow all pages until exhausted\n  **Why:** FHIR servers return paginated Bundles — stopping at page one misses most of the data\n\n- **Wrong:** Assuming all dates are ISO 8601 format across HL7v2 and FHIR\n  **Right:** Parse HL7v2 dates as `YYYYMMDD[HHmmss]` and FHIR dates with variable precision (`2024`, `2024-01`, `2024-01-15`)\n  **Why:** Format mismatches cause parse errors or silent data corruption\n\n- **Wrong:** Accepting coded values without validating the code system URI\n  **Right:** Verify that the `system` field matches the expected URI (e.g., `http:\u002F\u002Floinc.org` for LOINC codes)\n  **Why:** Codes without system URIs are ambiguous — a \"6690-2\" without system confirmation may not be LOINC\n\n## References\n\n- python-hl7: https:\u002F\u002Fpython-hl7.readthedocs.io\u002F\n- fhir.resources (Python): https:\u002F\u002Fpypi.org\u002Fproject\u002Ffhir.resources\u002F\n- FHIR R4 Specification: https:\u002F\u002Fhl7.org\u002Ffhir\u002FR4\u002F\n- LOINC: https:\u002F\u002Floinc.org\u002F\n- SNOMED CT: https:\u002F\u002Fwww.snomed.org\u002F\n",{"data":51,"body":66},{"name":4,"description":6,"usage":52,"version":53,"validated_against":54,"tags":59},"Invoke when parsing HL7v2 messages, extracting FHIR R4 resources, converting between clinical data formats, or running data quality checks on EHR data.","1.0.0",{"date":55,"packages":56},"2025-01-15",{"hl7apy":57,"fhir-resources":58},"1.3.4","R4",[60,61,62,63,25,64,19,65],"skill","category:pipeline","ehr","hl7","clinical-data","hcls",{"type":67,"children":68},"root",[69,77,84,90,95,125,130,136,141,169,191,235,241,269,275,282,292,298,311,318,477,483,600,606,729,735,845,851,986,992,1147,1153,1292,1298,1497,1503,1509,1721,1727,1740,2063,2069,2185,2191,2548,2554,2698,2704,2834,2840,3227,3233,3293],{"type":70,"tag":71,"props":72,"children":73},"element","h1",{"id":4},[74],{"type":75,"value":76},"text","EHR Data Parsing",{"type":70,"tag":78,"props":79,"children":81},"h2",{"id":80},"overview",[82],{"type":75,"value":83},"Overview",{"type":70,"tag":85,"props":86,"children":87},"p",{},[88],{"type":75,"value":89},"This skill encodes Python pipelines for parsing clinical data from two\ndominant formats: HL7v2 (pipe-delimited messages) and FHIR R4 (JSON\nresources). It covers extraction of patient demographics, lab results,\ndiagnoses, and medications, plus format conversion and data quality checks.",{"type":70,"tag":85,"props":91,"children":92},{},[93],{"type":75,"value":94},"Scope:",{"type":70,"tag":96,"props":97,"children":98},"ul",{},[99,105,110,115,120],{"type":70,"tag":100,"props":101,"children":102},"li",{},[103],{"type":75,"value":104},"HL7v2 message parsing (MSH, PID, PV1, OBR, OBX segments)",{"type":70,"tag":100,"props":106,"children":107},{},[108],{"type":75,"value":109},"FHIR R4 resource extraction (Patient, Observation, Condition, MedicationRequest)",{"type":70,"tag":100,"props":111,"children":112},{},[113],{"type":75,"value":114},"HL7v2 → tabular (CSV\u002FDataFrame) conversion",{"type":70,"tag":100,"props":116,"children":117},{},[118],{"type":75,"value":119},"FHIR Bundle iteration and flattening",{"type":70,"tag":100,"props":121,"children":122},{},[123],{"type":75,"value":124},"Data quality checks (completeness, date validation, code system verification)",{"type":70,"tag":85,"props":126,"children":127},{},[128],{"type":75,"value":129},"Out of scope: HL7v3\u002FCDA parsing, FHIR server deployment, SMART on FHIR\nauthentication, real-time message routing.",{"type":70,"tag":78,"props":131,"children":133},{"id":132},"usage",[134],{"type":75,"value":135},"Usage",{"type":70,"tag":85,"props":137,"children":138},{},[139],{"type":75,"value":140},"Invoke when the user asks to:",{"type":70,"tag":96,"props":142,"children":143},{},[144,149,154,159,164],{"type":70,"tag":100,"props":145,"children":146},{},[147],{"type":75,"value":148},"Parse an HL7v2 message or batch file",{"type":70,"tag":100,"props":150,"children":151},{},[152],{"type":75,"value":153},"Extract patient demographics, labs, diagnoses, or medications from FHIR",{"type":70,"tag":100,"props":155,"children":156},{},[157],{"type":75,"value":158},"Convert HL7v2 messages to CSV or pandas DataFrames",{"type":70,"tag":100,"props":160,"children":161},{},[162],{"type":75,"value":163},"Flatten FHIR Bundles into tabular format",{"type":70,"tag":100,"props":165,"children":166},{},[167],{"type":75,"value":168},"Run quality checks on clinical data extracts",{"type":70,"tag":85,"props":170,"children":171},{},[172,174,181,183,189],{"type":75,"value":173},"The skill emits Python code using ",{"type":70,"tag":175,"props":176,"children":178},"code",{"className":177},[],[179],{"type":75,"value":180},"python-hl7",{"type":75,"value":182}," for HL7v2 and ",{"type":70,"tag":175,"props":184,"children":186},{"className":185},[],[187],{"type":75,"value":188},"fhir.resources",{"type":75,"value":190},"\nfor FHIR R4. Install dependencies:",{"type":70,"tag":192,"props":193,"children":198},"pre",{"className":194,"code":195,"language":196,"meta":197,"style":197},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","pip install python-hl7 fhir.resources pandas\n","bash","",[199],{"type":70,"tag":175,"props":200,"children":201},{"__ignoreMap":197},[202],{"type":70,"tag":203,"props":204,"children":207},"span",{"class":205,"line":206},"line",1,[208,214,220,225,230],{"type":70,"tag":203,"props":209,"children":211},{"style":210},"--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B",[212],{"type":75,"value":213},"pip",{"type":70,"tag":203,"props":215,"children":217},{"style":216},"--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D",[218],{"type":75,"value":219}," install",{"type":70,"tag":203,"props":221,"children":222},{"style":216},[223],{"type":75,"value":224}," python-hl7",{"type":70,"tag":203,"props":226,"children":227},{"style":216},[228],{"type":75,"value":229}," fhir.resources",{"type":70,"tag":203,"props":231,"children":232},{"style":216},[233],{"type":75,"value":234}," pandas\n",{"type":70,"tag":78,"props":236,"children":238},{"id":237},"response-format",[239],{"type":75,"value":240},"Response Format",{"type":70,"tag":96,"props":242,"children":243},{},[244,249,254,259,264],{"type":70,"tag":100,"props":245,"children":246},{},[247],{"type":75,"value":248},"Lead with the command or code the user needs — explain after",{"type":70,"tag":100,"props":250,"children":251},{},[252],{"type":75,"value":253},"Structure as: confirm inputs → working code → key parameters explained → gotchas",{"type":70,"tag":100,"props":255,"children":256},{},[257],{"type":75,"value":258},"One complete working example per task; do not show every alternative",{"type":70,"tag":100,"props":260,"children":261},{},[262],{"type":75,"value":263},"Keep code comments minimal and functional (what, not why-it-exists)",{"type":70,"tag":100,"props":265,"children":266},{},[267],{"type":75,"value":268},"Target: 50-100 lines of code with brief surrounding explanation",{"type":70,"tag":78,"props":270,"children":272},{"id":271},"core-concepts",[273],{"type":75,"value":274},"Core Concepts",{"type":70,"tag":276,"props":277,"children":279},"h3",{"id":278},"parser-selection-decision-tree",[280],{"type":75,"value":281},"Parser Selection Decision Tree",{"type":70,"tag":192,"props":283,"children":287},{"className":284,"code":286,"language":75},[285],"language-text","What is the input format?\n├─ HL7v2 (pipe-delimited, segments start with MSH|PID|OBX...)\n│  ├─ Message type?\n│  │  ├─ ORU^R01 (lab results) → extract OBR + OBX segments\n│  │  ├─ ADT^A01\u002FA08 (admit\u002Fupdate) → extract PID + PV1 segments\n│  │  └─ ORM^O01 (orders) → extract ORC + OBR segments\n│  └─ Library: python-hl7 (parse → segment → field access)\n└─ FHIR R4 (JSON resources)\n   ├─ Single resource → fhir.resources model_validate(json)\n   └─ Bundle → iterate entry[], check resource_type, follow pagination (link.next)\n      ├─ Extract by system URI, not array position\n      └─ Check choice types (valueQuantity vs valueCodeableConcept)\n",[288],{"type":70,"tag":175,"props":289,"children":290},{"__ignoreMap":197},[291],{"type":75,"value":286},{"type":70,"tag":276,"props":293,"children":295},{"id":294},"hl7v2-message-structure",[296],{"type":75,"value":297},"HL7v2 Message Structure",{"type":70,"tag":85,"props":299,"children":300},{},[301,303,309],{"type":75,"value":302},"HL7v2 messages are pipe-delimited, segment-based. Each segment starts with\na 3-character identifier followed by fields separated by ",{"type":70,"tag":175,"props":304,"children":306},{"className":305},[],[307],{"type":75,"value":308},"|",{"type":75,"value":310},".",{"type":70,"tag":312,"props":313,"children":315},"h4",{"id":314},"key-segments",[316],{"type":75,"value":317},"Key segments",{"type":70,"tag":319,"props":320,"children":321},"table",{},[322,346],{"type":70,"tag":323,"props":324,"children":325},"thead",{},[326],{"type":70,"tag":327,"props":328,"children":329},"tr",{},[330,336,341],{"type":70,"tag":331,"props":332,"children":333},"th",{},[334],{"type":75,"value":335},"Segment",{"type":70,"tag":331,"props":337,"children":338},{},[339],{"type":75,"value":340},"Name",{"type":70,"tag":331,"props":342,"children":343},{},[344],{"type":75,"value":345},"Contains",{"type":70,"tag":347,"props":348,"children":349},"tbody",{},[350,369,387,405,423,441,459],{"type":70,"tag":327,"props":351,"children":352},{},[353,359,364],{"type":70,"tag":354,"props":355,"children":356},"td",{},[357],{"type":75,"value":358},"MSH",{"type":70,"tag":354,"props":360,"children":361},{},[362],{"type":75,"value":363},"Message Header",{"type":70,"tag":354,"props":365,"children":366},{},[367],{"type":75,"value":368},"Sending\u002Freceiving app, message type, timestamp, version",{"type":70,"tag":327,"props":370,"children":371},{},[372,377,382],{"type":70,"tag":354,"props":373,"children":374},{},[375],{"type":75,"value":376},"PID",{"type":70,"tag":354,"props":378,"children":379},{},[380],{"type":75,"value":381},"Patient Identification",{"type":70,"tag":354,"props":383,"children":384},{},[385],{"type":75,"value":386},"MRN, name, DOB, sex, address, phone",{"type":70,"tag":327,"props":388,"children":389},{},[390,395,400],{"type":70,"tag":354,"props":391,"children":392},{},[393],{"type":75,"value":394},"PV1",{"type":70,"tag":354,"props":396,"children":397},{},[398],{"type":75,"value":399},"Patient Visit",{"type":70,"tag":354,"props":401,"children":402},{},[403],{"type":75,"value":404},"Visit number, patient class, attending physician",{"type":70,"tag":327,"props":406,"children":407},{},[408,413,418],{"type":70,"tag":354,"props":409,"children":410},{},[411],{"type":75,"value":412},"OBR",{"type":70,"tag":354,"props":414,"children":415},{},[416],{"type":75,"value":417},"Observation Request",{"type":70,"tag":354,"props":419,"children":420},{},[421],{"type":75,"value":422},"Order number, test ordered, ordering provider",{"type":70,"tag":327,"props":424,"children":425},{},[426,431,436],{"type":70,"tag":354,"props":427,"children":428},{},[429],{"type":75,"value":430},"OBX",{"type":70,"tag":354,"props":432,"children":433},{},[434],{"type":75,"value":435},"Observation Result",{"type":70,"tag":354,"props":437,"children":438},{},[439],{"type":75,"value":440},"Result value, units, reference range, abnormal flag",{"type":70,"tag":327,"props":442,"children":443},{},[444,449,454],{"type":70,"tag":354,"props":445,"children":446},{},[447],{"type":75,"value":448},"DG1",{"type":70,"tag":354,"props":450,"children":451},{},[452],{"type":75,"value":453},"Diagnosis",{"type":70,"tag":354,"props":455,"children":456},{},[457],{"type":75,"value":458},"Diagnosis code, type, description",{"type":70,"tag":327,"props":460,"children":461},{},[462,467,472],{"type":70,"tag":354,"props":463,"children":464},{},[465],{"type":75,"value":466},"AL1",{"type":70,"tag":354,"props":468,"children":469},{},[470],{"type":75,"value":471},"Allergy",{"type":70,"tag":354,"props":473,"children":474},{},[475],{"type":75,"value":476},"Allergen, reaction, severity",{"type":70,"tag":312,"props":478,"children":480},{"id":479},"common-message-types",[481],{"type":75,"value":482},"Common message types",{"type":70,"tag":319,"props":484,"children":485},{},[486,507],{"type":70,"tag":323,"props":487,"children":488},{},[489],{"type":70,"tag":327,"props":490,"children":491},{},[492,497,502],{"type":70,"tag":331,"props":493,"children":494},{},[495],{"type":75,"value":496},"Type",{"type":70,"tag":331,"props":498,"children":499},{},[500],{"type":75,"value":501},"Trigger",{"type":70,"tag":331,"props":503,"children":504},{},[505],{"type":75,"value":506},"Use",{"type":70,"tag":347,"props":508,"children":509},{},[510,528,546,564,582],{"type":70,"tag":327,"props":511,"children":512},{},[513,518,523],{"type":70,"tag":354,"props":514,"children":515},{},[516],{"type":75,"value":517},"ADT^A01",{"type":70,"tag":354,"props":519,"children":520},{},[521],{"type":75,"value":522},"Admit",{"type":70,"tag":354,"props":524,"children":525},{},[526],{"type":75,"value":527},"Patient admission",{"type":70,"tag":327,"props":529,"children":530},{},[531,536,541],{"type":70,"tag":354,"props":532,"children":533},{},[534],{"type":75,"value":535},"ADT^A08",{"type":70,"tag":354,"props":537,"children":538},{},[539],{"type":75,"value":540},"Update",{"type":70,"tag":354,"props":542,"children":543},{},[544],{"type":75,"value":545},"Patient information update",{"type":70,"tag":327,"props":547,"children":548},{},[549,554,559],{"type":70,"tag":354,"props":550,"children":551},{},[552],{"type":75,"value":553},"ORU^R01",{"type":70,"tag":354,"props":555,"children":556},{},[557],{"type":75,"value":558},"Observation",{"type":70,"tag":354,"props":560,"children":561},{},[562],{"type":75,"value":563},"Lab\u002Fradiology results",{"type":70,"tag":327,"props":565,"children":566},{},[567,572,577],{"type":70,"tag":354,"props":568,"children":569},{},[570],{"type":75,"value":571},"ORM^O01",{"type":70,"tag":354,"props":573,"children":574},{},[575],{"type":75,"value":576},"Order",{"type":70,"tag":354,"props":578,"children":579},{},[580],{"type":75,"value":581},"New order placed",{"type":70,"tag":327,"props":583,"children":584},{},[585,590,595],{"type":70,"tag":354,"props":586,"children":587},{},[588],{"type":75,"value":589},"MDM^T02",{"type":70,"tag":354,"props":591,"children":592},{},[593],{"type":75,"value":594},"Document",{"type":70,"tag":354,"props":596,"children":597},{},[598],{"type":75,"value":599},"Document notification",{"type":70,"tag":276,"props":601,"children":603},{"id":602},"_1-parse-hl7v2-messages",[604],{"type":75,"value":605},"1. Parse HL7v2 Messages",{"type":70,"tag":192,"props":607,"children":610},{"className":608,"code":609,"language":22,"meta":197,"style":197},"language-python shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import hl7\n\nraw = (\n    \"MSH|^~\\\\&|LAB|HOSP|EHR|HOSP|20240115120000||ORU^R01|MSG001|P|2.5\\r\"\n    \"PID|1||MRN123^^^HOSP^MR||DOE^JOHN^A||19800315|M|||\"\n    \"123 MAIN ST^^ANYTOWN^CA^90210\\r\"\n    \"OBR|1|ORD001||CBC^Complete Blood Count^L|||20240115080000\\r\"\n    \"OBX|1|NM|WBC^White Blood Cell Count^L||7.5|10*3\u002FuL|4.5-11.0|N|||F\\r\"\n    \"OBX|2|NM|HGB^Hemoglobin^L||14.2|g\u002FdL|12.0-17.5|N|||F\\r\"\n    \"OBX|3|NM|PLT^Platelet Count^L||250|10*3\u002FuL|150-400|N|||F\\r\"\n)\n\nmsg = hl7.parse(raw)\n",[611],{"type":70,"tag":175,"props":612,"children":613},{"__ignoreMap":197},[614,622,632,641,649,658,667,676,685,694,703,712,720],{"type":70,"tag":203,"props":615,"children":616},{"class":205,"line":206},[617],{"type":70,"tag":203,"props":618,"children":619},{},[620],{"type":75,"value":621},"import hl7\n",{"type":70,"tag":203,"props":623,"children":625},{"class":205,"line":624},2,[626],{"type":70,"tag":203,"props":627,"children":629},{"emptyLinePlaceholder":628},true,[630],{"type":75,"value":631},"\n",{"type":70,"tag":203,"props":633,"children":635},{"class":205,"line":634},3,[636],{"type":70,"tag":203,"props":637,"children":638},{},[639],{"type":75,"value":640},"raw = (\n",{"type":70,"tag":203,"props":642,"children":643},{"class":205,"line":26},[644],{"type":70,"tag":203,"props":645,"children":646},{},[647],{"type":75,"value":648},"    \"MSH|^~\\\\&|LAB|HOSP|EHR|HOSP|20240115120000||ORU^R01|MSG001|P|2.5\\r\"\n",{"type":70,"tag":203,"props":650,"children":652},{"class":205,"line":651},5,[653],{"type":70,"tag":203,"props":654,"children":655},{},[656],{"type":75,"value":657},"    \"PID|1||MRN123^^^HOSP^MR||DOE^JOHN^A||19800315|M|||\"\n",{"type":70,"tag":203,"props":659,"children":661},{"class":205,"line":660},6,[662],{"type":70,"tag":203,"props":663,"children":664},{},[665],{"type":75,"value":666},"    \"123 MAIN ST^^ANYTOWN^CA^90210\\r\"\n",{"type":70,"tag":203,"props":668,"children":670},{"class":205,"line":669},7,[671],{"type":70,"tag":203,"props":672,"children":673},{},[674],{"type":75,"value":675},"    \"OBR|1|ORD001||CBC^Complete Blood Count^L|||20240115080000\\r\"\n",{"type":70,"tag":203,"props":677,"children":679},{"class":205,"line":678},8,[680],{"type":70,"tag":203,"props":681,"children":682},{},[683],{"type":75,"value":684},"    \"OBX|1|NM|WBC^White Blood Cell Count^L||7.5|10*3\u002FuL|4.5-11.0|N|||F\\r\"\n",{"type":70,"tag":203,"props":686,"children":688},{"class":205,"line":687},9,[689],{"type":70,"tag":203,"props":690,"children":691},{},[692],{"type":75,"value":693},"    \"OBX|2|NM|HGB^Hemoglobin^L||14.2|g\u002FdL|12.0-17.5|N|||F\\r\"\n",{"type":70,"tag":203,"props":695,"children":697},{"class":205,"line":696},10,[698],{"type":70,"tag":203,"props":699,"children":700},{},[701],{"type":75,"value":702},"    \"OBX|3|NM|PLT^Platelet Count^L||250|10*3\u002FuL|150-400|N|||F\\r\"\n",{"type":70,"tag":203,"props":704,"children":706},{"class":205,"line":705},11,[707],{"type":70,"tag":203,"props":708,"children":709},{},[710],{"type":75,"value":711},")\n",{"type":70,"tag":203,"props":713,"children":715},{"class":205,"line":714},12,[716],{"type":70,"tag":203,"props":717,"children":718},{"emptyLinePlaceholder":628},[719],{"type":75,"value":631},{"type":70,"tag":203,"props":721,"children":723},{"class":205,"line":722},13,[724],{"type":70,"tag":203,"props":725,"children":726},{},[727],{"type":75,"value":728},"msg = hl7.parse(raw)\n",{"type":70,"tag":312,"props":730,"children":732},{"id":731},"extract-patient-demographics-from-pid",[733],{"type":75,"value":734},"Extract patient demographics from PID",{"type":70,"tag":192,"props":736,"children":738},{"className":608,"code":737,"language":22,"meta":197,"style":197},"def extract_pid(msg):\n    pid = msg.segment(\"PID\")\n    return {\n        \"mrn\": str(pid(3)(0)(0)),          # PID-3.1: patient ID\n        \"last_name\": str(pid(5)(0)(0)),     # PID-5.1: family name\n        \"first_name\": str(pid(5)(0)(1)),    # PID-5.2: given name\n        \"dob\": str(pid(7)),                 # PID-7: date of birth\n        \"sex\": str(pid(8)),                 # PID-8: administrative sex\n    }\n\ndemographics = extract_pid(msg)\n# {'mrn': 'MRN123', 'last_name': 'DOE', 'first_name': 'JOHN',\n#  'dob': '19800315', 'sex': 'M'}\n",[739],{"type":70,"tag":175,"props":740,"children":741},{"__ignoreMap":197},[742,750,758,766,774,782,790,798,806,814,821,829,837],{"type":70,"tag":203,"props":743,"children":744},{"class":205,"line":206},[745],{"type":70,"tag":203,"props":746,"children":747},{},[748],{"type":75,"value":749},"def extract_pid(msg):\n",{"type":70,"tag":203,"props":751,"children":752},{"class":205,"line":624},[753],{"type":70,"tag":203,"props":754,"children":755},{},[756],{"type":75,"value":757},"    pid = msg.segment(\"PID\")\n",{"type":70,"tag":203,"props":759,"children":760},{"class":205,"line":634},[761],{"type":70,"tag":203,"props":762,"children":763},{},[764],{"type":75,"value":765},"    return {\n",{"type":70,"tag":203,"props":767,"children":768},{"class":205,"line":26},[769],{"type":70,"tag":203,"props":770,"children":771},{},[772],{"type":75,"value":773},"        \"mrn\": str(pid(3)(0)(0)),          # PID-3.1: patient ID\n",{"type":70,"tag":203,"props":775,"children":776},{"class":205,"line":651},[777],{"type":70,"tag":203,"props":778,"children":779},{},[780],{"type":75,"value":781},"        \"last_name\": str(pid(5)(0)(0)),     # PID-5.1: family name\n",{"type":70,"tag":203,"props":783,"children":784},{"class":205,"line":660},[785],{"type":70,"tag":203,"props":786,"children":787},{},[788],{"type":75,"value":789},"        \"first_name\": str(pid(5)(0)(1)),    # PID-5.2: given name\n",{"type":70,"tag":203,"props":791,"children":792},{"class":205,"line":669},[793],{"type":70,"tag":203,"props":794,"children":795},{},[796],{"type":75,"value":797},"        \"dob\": str(pid(7)),                 # PID-7: date of birth\n",{"type":70,"tag":203,"props":799,"children":800},{"class":205,"line":678},[801],{"type":70,"tag":203,"props":802,"children":803},{},[804],{"type":75,"value":805},"        \"sex\": str(pid(8)),                 # PID-8: administrative sex\n",{"type":70,"tag":203,"props":807,"children":808},{"class":205,"line":687},[809],{"type":70,"tag":203,"props":810,"children":811},{},[812],{"type":75,"value":813},"    }\n",{"type":70,"tag":203,"props":815,"children":816},{"class":205,"line":696},[817],{"type":70,"tag":203,"props":818,"children":819},{"emptyLinePlaceholder":628},[820],{"type":75,"value":631},{"type":70,"tag":203,"props":822,"children":823},{"class":205,"line":705},[824],{"type":70,"tag":203,"props":825,"children":826},{},[827],{"type":75,"value":828},"demographics = extract_pid(msg)\n",{"type":70,"tag":203,"props":830,"children":831},{"class":205,"line":714},[832],{"type":70,"tag":203,"props":833,"children":834},{},[835],{"type":75,"value":836},"# {'mrn': 'MRN123', 'last_name': 'DOE', 'first_name': 'JOHN',\n",{"type":70,"tag":203,"props":838,"children":839},{"class":205,"line":722},[840],{"type":70,"tag":203,"props":841,"children":842},{},[843],{"type":75,"value":844},"#  'dob': '19800315', 'sex': 'M'}\n",{"type":70,"tag":312,"props":846,"children":848},{"id":847},"pid-field-reference",[849],{"type":75,"value":850},"PID field reference",{"type":70,"tag":319,"props":852,"children":853},{},[854,875],{"type":70,"tag":323,"props":855,"children":856},{},[857],{"type":70,"tag":327,"props":858,"children":859},{},[860,865,870],{"type":70,"tag":331,"props":861,"children":862},{},[863],{"type":75,"value":864},"Field",{"type":70,"tag":331,"props":866,"children":867},{},[868],{"type":75,"value":869},"Position",{"type":70,"tag":331,"props":871,"children":872},{},[873],{"type":75,"value":874},"Format",{"type":70,"tag":347,"props":876,"children":877},{},[878,896,914,932,950,968],{"type":70,"tag":327,"props":879,"children":880},{},[881,886,891],{"type":70,"tag":354,"props":882,"children":883},{},[884],{"type":75,"value":885},"Patient ID",{"type":70,"tag":354,"props":887,"children":888},{},[889],{"type":75,"value":890},"PID-3",{"type":70,"tag":354,"props":892,"children":893},{},[894],{"type":75,"value":895},"CX datatype (ID^^^authority^type)",{"type":70,"tag":327,"props":897,"children":898},{},[899,904,909],{"type":70,"tag":354,"props":900,"children":901},{},[902],{"type":75,"value":903},"Patient Name",{"type":70,"tag":354,"props":905,"children":906},{},[907],{"type":75,"value":908},"PID-5",{"type":70,"tag":354,"props":910,"children":911},{},[912],{"type":75,"value":913},"XPN: Family^Given^Middle",{"type":70,"tag":327,"props":915,"children":916},{},[917,922,927],{"type":70,"tag":354,"props":918,"children":919},{},[920],{"type":75,"value":921},"Date of Birth",{"type":70,"tag":354,"props":923,"children":924},{},[925],{"type":75,"value":926},"PID-7",{"type":70,"tag":354,"props":928,"children":929},{},[930],{"type":75,"value":931},"YYYYMMDD",{"type":70,"tag":327,"props":933,"children":934},{},[935,940,945],{"type":70,"tag":354,"props":936,"children":937},{},[938],{"type":75,"value":939},"Sex",{"type":70,"tag":354,"props":941,"children":942},{},[943],{"type":75,"value":944},"PID-8",{"type":70,"tag":354,"props":946,"children":947},{},[948],{"type":75,"value":949},"M, F, O, U",{"type":70,"tag":327,"props":951,"children":952},{},[953,958,963],{"type":70,"tag":354,"props":954,"children":955},{},[956],{"type":75,"value":957},"Address",{"type":70,"tag":354,"props":959,"children":960},{},[961],{"type":75,"value":962},"PID-11",{"type":70,"tag":354,"props":964,"children":965},{},[966],{"type":75,"value":967},"XAD: Street^City^State^Zip",{"type":70,"tag":327,"props":969,"children":970},{},[971,976,981],{"type":70,"tag":354,"props":972,"children":973},{},[974],{"type":75,"value":975},"Phone",{"type":70,"tag":354,"props":977,"children":978},{},[979],{"type":75,"value":980},"PID-13",{"type":70,"tag":354,"props":982,"children":983},{},[984],{"type":75,"value":985},"XTN datatype",{"type":70,"tag":312,"props":987,"children":989},{"id":988},"extract-lab-results-from-obx-segments",[990],{"type":75,"value":991},"Extract lab results from OBX segments",{"type":70,"tag":192,"props":993,"children":995},{"className":608,"code":994,"language":22,"meta":197,"style":197},"def extract_obx_results(msg):\n    results = []\n    for segment in msg:\n        if str(segment(0)) == \"OBX\":\n            results.append({\n                \"set_id\": str(segment(1)),\n                \"value_type\": str(segment(2)),       # NM=numeric, ST=string, CE=coded\n                \"test_code\": str(segment(3)(0)(0)),   # OBX-3.1: identifier\n                \"test_name\": str(segment(3)(0)(1)),   # OBX-3.2: text\n                \"value\": str(segment(5)),             # OBX-5: observation value\n                \"units\": str(segment(6)),             # OBX-6: units\n                \"ref_range\": str(segment(7)),         # OBX-7: reference range\n                \"abnormal_flag\": str(segment(8)),     # OBX-8: N\u002FH\u002FL\u002FA\n                \"status\": str(segment(11)),           # OBX-11: F=final, P=preliminary\n            })\n    return results\n\nlabs = extract_obx_results(msg)\n",[996],{"type":70,"tag":175,"props":997,"children":998},{"__ignoreMap":197},[999,1007,1015,1023,1031,1039,1047,1055,1063,1071,1079,1087,1095,1103,1112,1121,1130,1138],{"type":70,"tag":203,"props":1000,"children":1001},{"class":205,"line":206},[1002],{"type":70,"tag":203,"props":1003,"children":1004},{},[1005],{"type":75,"value":1006},"def extract_obx_results(msg):\n",{"type":70,"tag":203,"props":1008,"children":1009},{"class":205,"line":624},[1010],{"type":70,"tag":203,"props":1011,"children":1012},{},[1013],{"type":75,"value":1014},"    results = []\n",{"type":70,"tag":203,"props":1016,"children":1017},{"class":205,"line":634},[1018],{"type":70,"tag":203,"props":1019,"children":1020},{},[1021],{"type":75,"value":1022},"    for segment in msg:\n",{"type":70,"tag":203,"props":1024,"children":1025},{"class":205,"line":26},[1026],{"type":70,"tag":203,"props":1027,"children":1028},{},[1029],{"type":75,"value":1030},"        if str(segment(0)) == \"OBX\":\n",{"type":70,"tag":203,"props":1032,"children":1033},{"class":205,"line":651},[1034],{"type":70,"tag":203,"props":1035,"children":1036},{},[1037],{"type":75,"value":1038},"            results.append({\n",{"type":70,"tag":203,"props":1040,"children":1041},{"class":205,"line":660},[1042],{"type":70,"tag":203,"props":1043,"children":1044},{},[1045],{"type":75,"value":1046},"                \"set_id\": str(segment(1)),\n",{"type":70,"tag":203,"props":1048,"children":1049},{"class":205,"line":669},[1050],{"type":70,"tag":203,"props":1051,"children":1052},{},[1053],{"type":75,"value":1054},"                \"value_type\": str(segment(2)),       # NM=numeric, ST=string, CE=coded\n",{"type":70,"tag":203,"props":1056,"children":1057},{"class":205,"line":678},[1058],{"type":70,"tag":203,"props":1059,"children":1060},{},[1061],{"type":75,"value":1062},"                \"test_code\": str(segment(3)(0)(0)),   # OBX-3.1: identifier\n",{"type":70,"tag":203,"props":1064,"children":1065},{"class":205,"line":687},[1066],{"type":70,"tag":203,"props":1067,"children":1068},{},[1069],{"type":75,"value":1070},"                \"test_name\": str(segment(3)(0)(1)),   # OBX-3.2: text\n",{"type":70,"tag":203,"props":1072,"children":1073},{"class":205,"line":696},[1074],{"type":70,"tag":203,"props":1075,"children":1076},{},[1077],{"type":75,"value":1078},"                \"value\": str(segment(5)),             # OBX-5: observation value\n",{"type":70,"tag":203,"props":1080,"children":1081},{"class":205,"line":705},[1082],{"type":70,"tag":203,"props":1083,"children":1084},{},[1085],{"type":75,"value":1086},"                \"units\": str(segment(6)),             # OBX-6: units\n",{"type":70,"tag":203,"props":1088,"children":1089},{"class":205,"line":714},[1090],{"type":70,"tag":203,"props":1091,"children":1092},{},[1093],{"type":75,"value":1094},"                \"ref_range\": str(segment(7)),         # OBX-7: reference range\n",{"type":70,"tag":203,"props":1096,"children":1097},{"class":205,"line":722},[1098],{"type":70,"tag":203,"props":1099,"children":1100},{},[1101],{"type":75,"value":1102},"                \"abnormal_flag\": str(segment(8)),     # OBX-8: N\u002FH\u002FL\u002FA\n",{"type":70,"tag":203,"props":1104,"children":1106},{"class":205,"line":1105},14,[1107],{"type":70,"tag":203,"props":1108,"children":1109},{},[1110],{"type":75,"value":1111},"                \"status\": str(segment(11)),           # OBX-11: F=final, P=preliminary\n",{"type":70,"tag":203,"props":1113,"children":1115},{"class":205,"line":1114},15,[1116],{"type":70,"tag":203,"props":1117,"children":1118},{},[1119],{"type":75,"value":1120},"            })\n",{"type":70,"tag":203,"props":1122,"children":1124},{"class":205,"line":1123},16,[1125],{"type":70,"tag":203,"props":1126,"children":1127},{},[1128],{"type":75,"value":1129},"    return results\n",{"type":70,"tag":203,"props":1131,"children":1133},{"class":205,"line":1132},17,[1134],{"type":70,"tag":203,"props":1135,"children":1136},{"emptyLinePlaceholder":628},[1137],{"type":75,"value":631},{"type":70,"tag":203,"props":1139,"children":1141},{"class":205,"line":1140},18,[1142],{"type":70,"tag":203,"props":1143,"children":1144},{},[1145],{"type":75,"value":1146},"labs = extract_obx_results(msg)\n",{"type":70,"tag":312,"props":1148,"children":1150},{"id":1149},"obx-value-types-and-status-codes",[1151],{"type":75,"value":1152},"OBX value types and status codes",{"type":70,"tag":319,"props":1154,"children":1155},{},[1156,1190],{"type":70,"tag":323,"props":1157,"children":1158},{},[1159],{"type":70,"tag":327,"props":1160,"children":1161},{},[1162,1167,1172,1177,1181,1186],{"type":70,"tag":331,"props":1163,"children":1164},{},[1165],{"type":75,"value":1166},"OBX-2",{"type":70,"tag":331,"props":1168,"children":1169},{},[1170],{"type":75,"value":1171},"Meaning",{"type":70,"tag":331,"props":1173,"children":1174},{},[1175],{"type":75,"value":1176},"OBX-8",{"type":70,"tag":331,"props":1178,"children":1179},{},[1180],{"type":75,"value":1171},{"type":70,"tag":331,"props":1182,"children":1183},{},[1184],{"type":75,"value":1185},"OBX-11",{"type":70,"tag":331,"props":1187,"children":1188},{},[1189],{"type":75,"value":1171},{"type":70,"tag":347,"props":1191,"children":1192},{},[1193,1226,1259],{"type":70,"tag":327,"props":1194,"children":1195},{},[1196,1201,1206,1211,1216,1221],{"type":70,"tag":354,"props":1197,"children":1198},{},[1199],{"type":75,"value":1200},"NM",{"type":70,"tag":354,"props":1202,"children":1203},{},[1204],{"type":75,"value":1205},"Numeric",{"type":70,"tag":354,"props":1207,"children":1208},{},[1209],{"type":75,"value":1210},"N",{"type":70,"tag":354,"props":1212,"children":1213},{},[1214],{"type":75,"value":1215},"Normal",{"type":70,"tag":354,"props":1217,"children":1218},{},[1219],{"type":75,"value":1220},"F",{"type":70,"tag":354,"props":1222,"children":1223},{},[1224],{"type":75,"value":1225},"Final",{"type":70,"tag":327,"props":1227,"children":1228},{},[1229,1234,1239,1244,1249,1254],{"type":70,"tag":354,"props":1230,"children":1231},{},[1232],{"type":75,"value":1233},"ST",{"type":70,"tag":354,"props":1235,"children":1236},{},[1237],{"type":75,"value":1238},"String",{"type":70,"tag":354,"props":1240,"children":1241},{},[1242],{"type":75,"value":1243},"H",{"type":70,"tag":354,"props":1245,"children":1246},{},[1247],{"type":75,"value":1248},"High",{"type":70,"tag":354,"props":1250,"children":1251},{},[1252],{"type":75,"value":1253},"P",{"type":70,"tag":354,"props":1255,"children":1256},{},[1257],{"type":75,"value":1258},"Preliminary",{"type":70,"tag":327,"props":1260,"children":1261},{},[1262,1267,1272,1277,1282,1287],{"type":70,"tag":354,"props":1263,"children":1264},{},[1265],{"type":75,"value":1266},"CE",{"type":70,"tag":354,"props":1268,"children":1269},{},[1270],{"type":75,"value":1271},"Coded entry",{"type":70,"tag":354,"props":1273,"children":1274},{},[1275],{"type":75,"value":1276},"L",{"type":70,"tag":354,"props":1278,"children":1279},{},[1280],{"type":75,"value":1281},"Low",{"type":70,"tag":354,"props":1283,"children":1284},{},[1285],{"type":75,"value":1286},"C",{"type":70,"tag":354,"props":1288,"children":1289},{},[1290],{"type":75,"value":1291},"Corrected",{"type":70,"tag":276,"props":1293,"children":1295},{"id":1294},"_2-batch-hl7v2-processing",[1296],{"type":75,"value":1297},"2. Batch HL7v2 Processing",{"type":70,"tag":192,"props":1299,"children":1301},{"className":608,"code":1300,"language":22,"meta":197,"style":197},"import hl7\nimport pandas as pd\n\ndef parse_hl7_file(filepath):\n    \"\"\"Parse a file containing multiple HL7v2 messages separated by blank lines.\"\"\"\n    with open(filepath, \"r\") as f:\n        content = f.read()\n\n    raw_messages = content.strip().split(\"\\nMSH|\")\n    raw_messages = [raw_messages[0]] + [\"MSH|\" + m for m in raw_messages[1:]]\n\n    all_results = []\n    for raw in raw_messages:\n        raw = raw.strip().replace(\"\\n\", \"\\r\")\n        if not raw:\n            continue\n        msg = hl7.parse(raw)\n        demo = extract_pid(msg)\n        for lab in extract_obx_results(msg):\n            all_results.append({**demo, **lab})\n\n    return pd.DataFrame(all_results)\n\ndf = parse_hl7_file(\"lab_results.hl7\")\n",[1302],{"type":70,"tag":175,"props":1303,"children":1304},{"__ignoreMap":197},[1305,1312,1320,1327,1335,1343,1351,1359,1366,1374,1382,1389,1397,1405,1413,1421,1429,1437,1445,1454,1463,1471,1480,1488],{"type":70,"tag":203,"props":1306,"children":1307},{"class":205,"line":206},[1308],{"type":70,"tag":203,"props":1309,"children":1310},{},[1311],{"type":75,"value":621},{"type":70,"tag":203,"props":1313,"children":1314},{"class":205,"line":624},[1315],{"type":70,"tag":203,"props":1316,"children":1317},{},[1318],{"type":75,"value":1319},"import pandas as pd\n",{"type":70,"tag":203,"props":1321,"children":1322},{"class":205,"line":634},[1323],{"type":70,"tag":203,"props":1324,"children":1325},{"emptyLinePlaceholder":628},[1326],{"type":75,"value":631},{"type":70,"tag":203,"props":1328,"children":1329},{"class":205,"line":26},[1330],{"type":70,"tag":203,"props":1331,"children":1332},{},[1333],{"type":75,"value":1334},"def parse_hl7_file(filepath):\n",{"type":70,"tag":203,"props":1336,"children":1337},{"class":205,"line":651},[1338],{"type":70,"tag":203,"props":1339,"children":1340},{},[1341],{"type":75,"value":1342},"    \"\"\"Parse a file containing multiple HL7v2 messages separated by blank lines.\"\"\"\n",{"type":70,"tag":203,"props":1344,"children":1345},{"class":205,"line":660},[1346],{"type":70,"tag":203,"props":1347,"children":1348},{},[1349],{"type":75,"value":1350},"    with open(filepath, \"r\") as f:\n",{"type":70,"tag":203,"props":1352,"children":1353},{"class":205,"line":669},[1354],{"type":70,"tag":203,"props":1355,"children":1356},{},[1357],{"type":75,"value":1358},"        content = f.read()\n",{"type":70,"tag":203,"props":1360,"children":1361},{"class":205,"line":678},[1362],{"type":70,"tag":203,"props":1363,"children":1364},{"emptyLinePlaceholder":628},[1365],{"type":75,"value":631},{"type":70,"tag":203,"props":1367,"children":1368},{"class":205,"line":687},[1369],{"type":70,"tag":203,"props":1370,"children":1371},{},[1372],{"type":75,"value":1373},"    raw_messages = content.strip().split(\"\\nMSH|\")\n",{"type":70,"tag":203,"props":1375,"children":1376},{"class":205,"line":696},[1377],{"type":70,"tag":203,"props":1378,"children":1379},{},[1380],{"type":75,"value":1381},"    raw_messages = [raw_messages[0]] + [\"MSH|\" + m for m in raw_messages[1:]]\n",{"type":70,"tag":203,"props":1383,"children":1384},{"class":205,"line":705},[1385],{"type":70,"tag":203,"props":1386,"children":1387},{"emptyLinePlaceholder":628},[1388],{"type":75,"value":631},{"type":70,"tag":203,"props":1390,"children":1391},{"class":205,"line":714},[1392],{"type":70,"tag":203,"props":1393,"children":1394},{},[1395],{"type":75,"value":1396},"    all_results = []\n",{"type":70,"tag":203,"props":1398,"children":1399},{"class":205,"line":722},[1400],{"type":70,"tag":203,"props":1401,"children":1402},{},[1403],{"type":75,"value":1404},"    for raw in raw_messages:\n",{"type":70,"tag":203,"props":1406,"children":1407},{"class":205,"line":1105},[1408],{"type":70,"tag":203,"props":1409,"children":1410},{},[1411],{"type":75,"value":1412},"        raw = raw.strip().replace(\"\\n\", \"\\r\")\n",{"type":70,"tag":203,"props":1414,"children":1415},{"class":205,"line":1114},[1416],{"type":70,"tag":203,"props":1417,"children":1418},{},[1419],{"type":75,"value":1420},"        if not raw:\n",{"type":70,"tag":203,"props":1422,"children":1423},{"class":205,"line":1123},[1424],{"type":70,"tag":203,"props":1425,"children":1426},{},[1427],{"type":75,"value":1428},"            continue\n",{"type":70,"tag":203,"props":1430,"children":1431},{"class":205,"line":1132},[1432],{"type":70,"tag":203,"props":1433,"children":1434},{},[1435],{"type":75,"value":1436},"        msg = hl7.parse(raw)\n",{"type":70,"tag":203,"props":1438,"children":1439},{"class":205,"line":1140},[1440],{"type":70,"tag":203,"props":1441,"children":1442},{},[1443],{"type":75,"value":1444},"        demo = extract_pid(msg)\n",{"type":70,"tag":203,"props":1446,"children":1448},{"class":205,"line":1447},19,[1449],{"type":70,"tag":203,"props":1450,"children":1451},{},[1452],{"type":75,"value":1453},"        for lab in extract_obx_results(msg):\n",{"type":70,"tag":203,"props":1455,"children":1457},{"class":205,"line":1456},20,[1458],{"type":70,"tag":203,"props":1459,"children":1460},{},[1461],{"type":75,"value":1462},"            all_results.append({**demo, **lab})\n",{"type":70,"tag":203,"props":1464,"children":1466},{"class":205,"line":1465},21,[1467],{"type":70,"tag":203,"props":1468,"children":1469},{"emptyLinePlaceholder":628},[1470],{"type":75,"value":631},{"type":70,"tag":203,"props":1472,"children":1474},{"class":205,"line":1473},22,[1475],{"type":70,"tag":203,"props":1476,"children":1477},{},[1478],{"type":75,"value":1479},"    return pd.DataFrame(all_results)\n",{"type":70,"tag":203,"props":1481,"children":1483},{"class":205,"line":1482},23,[1484],{"type":70,"tag":203,"props":1485,"children":1486},{"emptyLinePlaceholder":628},[1487],{"type":75,"value":631},{"type":70,"tag":203,"props":1489,"children":1491},{"class":205,"line":1490},24,[1492],{"type":70,"tag":203,"props":1493,"children":1494},{},[1495],{"type":75,"value":1496},"df = parse_hl7_file(\"lab_results.hl7\")\n",{"type":70,"tag":276,"props":1498,"children":1500},{"id":1499},"_3-fhir-r4-resource-extraction",[1501],{"type":75,"value":1502},"3. FHIR R4 Resource Extraction",{"type":70,"tag":312,"props":1504,"children":1506},{"id":1505},"parse-a-patient-resource",[1507],{"type":75,"value":1508},"Parse a Patient resource",{"type":70,"tag":192,"props":1510,"children":1512},{"className":608,"code":1511,"language":22,"meta":197,"style":197},"from fhir.resources.patient import Patient\n\npatient_json = {\n    \"resourceType\": \"Patient\",\n    \"id\": \"example-001\",\n    \"identifier\": [\n        {\"system\": \"http:\u002F\u002Fhospital.example.org\u002Fmrn\", \"value\": \"MRN123\"}\n    ],\n    \"name\": [{\"family\": \"Doe\", \"given\": [\"John\", \"A\"]}],\n    \"gender\": \"male\",\n    \"birthDate\": \"1980-03-15\",\n    \"address\": [\n        {\"line\": [\"123 Main St\"], \"city\": \"Anytown\", \"state\": \"CA\", \"postalCode\": \"90210\"}\n    ],\n}\n\npatient = Patient.model_validate(patient_json)\n\ndemographics = {\n    \"id\": patient.id,\n    \"mrn\": patient.identifier[0].value if patient.identifier else None,\n    \"last_name\": patient.name[0].family if patient.name else None,\n    \"first_name\": patient.name[0].given[0] if patient.name and patient.name[0].given else None,\n    \"gender\": patient.gender,\n    \"birth_date\": str(patient.birthDate) if patient.birthDate else None,\n}\n",[1513],{"type":70,"tag":175,"props":1514,"children":1515},{"__ignoreMap":197},[1516,1524,1531,1539,1547,1555,1563,1571,1579,1587,1595,1603,1611,1619,1626,1634,1641,1649,1656,1664,1672,1680,1688,1696,1704,1713],{"type":70,"tag":203,"props":1517,"children":1518},{"class":205,"line":206},[1519],{"type":70,"tag":203,"props":1520,"children":1521},{},[1522],{"type":75,"value":1523},"from fhir.resources.patient import Patient\n",{"type":70,"tag":203,"props":1525,"children":1526},{"class":205,"line":624},[1527],{"type":70,"tag":203,"props":1528,"children":1529},{"emptyLinePlaceholder":628},[1530],{"type":75,"value":631},{"type":70,"tag":203,"props":1532,"children":1533},{"class":205,"line":634},[1534],{"type":70,"tag":203,"props":1535,"children":1536},{},[1537],{"type":75,"value":1538},"patient_json = {\n",{"type":70,"tag":203,"props":1540,"children":1541},{"class":205,"line":26},[1542],{"type":70,"tag":203,"props":1543,"children":1544},{},[1545],{"type":75,"value":1546},"    \"resourceType\": \"Patient\",\n",{"type":70,"tag":203,"props":1548,"children":1549},{"class":205,"line":651},[1550],{"type":70,"tag":203,"props":1551,"children":1552},{},[1553],{"type":75,"value":1554},"    \"id\": \"example-001\",\n",{"type":70,"tag":203,"props":1556,"children":1557},{"class":205,"line":660},[1558],{"type":70,"tag":203,"props":1559,"children":1560},{},[1561],{"type":75,"value":1562},"    \"identifier\": [\n",{"type":70,"tag":203,"props":1564,"children":1565},{"class":205,"line":669},[1566],{"type":70,"tag":203,"props":1567,"children":1568},{},[1569],{"type":75,"value":1570},"        {\"system\": \"http:\u002F\u002Fhospital.example.org\u002Fmrn\", \"value\": \"MRN123\"}\n",{"type":70,"tag":203,"props":1572,"children":1573},{"class":205,"line":678},[1574],{"type":70,"tag":203,"props":1575,"children":1576},{},[1577],{"type":75,"value":1578},"    ],\n",{"type":70,"tag":203,"props":1580,"children":1581},{"class":205,"line":687},[1582],{"type":70,"tag":203,"props":1583,"children":1584},{},[1585],{"type":75,"value":1586},"    \"name\": [{\"family\": \"Doe\", \"given\": [\"John\", \"A\"]}],\n",{"type":70,"tag":203,"props":1588,"children":1589},{"class":205,"line":696},[1590],{"type":70,"tag":203,"props":1591,"children":1592},{},[1593],{"type":75,"value":1594},"    \"gender\": \"male\",\n",{"type":70,"tag":203,"props":1596,"children":1597},{"class":205,"line":705},[1598],{"type":70,"tag":203,"props":1599,"children":1600},{},[1601],{"type":75,"value":1602},"    \"birthDate\": \"1980-03-15\",\n",{"type":70,"tag":203,"props":1604,"children":1605},{"class":205,"line":714},[1606],{"type":70,"tag":203,"props":1607,"children":1608},{},[1609],{"type":75,"value":1610},"    \"address\": [\n",{"type":70,"tag":203,"props":1612,"children":1613},{"class":205,"line":722},[1614],{"type":70,"tag":203,"props":1615,"children":1616},{},[1617],{"type":75,"value":1618},"        {\"line\": [\"123 Main St\"], \"city\": \"Anytown\", \"state\": \"CA\", \"postalCode\": \"90210\"}\n",{"type":70,"tag":203,"props":1620,"children":1621},{"class":205,"line":1105},[1622],{"type":70,"tag":203,"props":1623,"children":1624},{},[1625],{"type":75,"value":1578},{"type":70,"tag":203,"props":1627,"children":1628},{"class":205,"line":1114},[1629],{"type":70,"tag":203,"props":1630,"children":1631},{},[1632],{"type":75,"value":1633},"}\n",{"type":70,"tag":203,"props":1635,"children":1636},{"class":205,"line":1123},[1637],{"type":70,"tag":203,"props":1638,"children":1639},{"emptyLinePlaceholder":628},[1640],{"type":75,"value":631},{"type":70,"tag":203,"props":1642,"children":1643},{"class":205,"line":1132},[1644],{"type":70,"tag":203,"props":1645,"children":1646},{},[1647],{"type":75,"value":1648},"patient = Patient.model_validate(patient_json)\n",{"type":70,"tag":203,"props":1650,"children":1651},{"class":205,"line":1140},[1652],{"type":70,"tag":203,"props":1653,"children":1654},{"emptyLinePlaceholder":628},[1655],{"type":75,"value":631},{"type":70,"tag":203,"props":1657,"children":1658},{"class":205,"line":1447},[1659],{"type":70,"tag":203,"props":1660,"children":1661},{},[1662],{"type":75,"value":1663},"demographics = {\n",{"type":70,"tag":203,"props":1665,"children":1666},{"class":205,"line":1456},[1667],{"type":70,"tag":203,"props":1668,"children":1669},{},[1670],{"type":75,"value":1671},"    \"id\": patient.id,\n",{"type":70,"tag":203,"props":1673,"children":1674},{"class":205,"line":1465},[1675],{"type":70,"tag":203,"props":1676,"children":1677},{},[1678],{"type":75,"value":1679},"    \"mrn\": patient.identifier[0].value if patient.identifier else None,\n",{"type":70,"tag":203,"props":1681,"children":1682},{"class":205,"line":1473},[1683],{"type":70,"tag":203,"props":1684,"children":1685},{},[1686],{"type":75,"value":1687},"    \"last_name\": patient.name[0].family if patient.name else None,\n",{"type":70,"tag":203,"props":1689,"children":1690},{"class":205,"line":1482},[1691],{"type":70,"tag":203,"props":1692,"children":1693},{},[1694],{"type":75,"value":1695},"    \"first_name\": patient.name[0].given[0] if patient.name and patient.name[0].given else None,\n",{"type":70,"tag":203,"props":1697,"children":1698},{"class":205,"line":1490},[1699],{"type":70,"tag":203,"props":1700,"children":1701},{},[1702],{"type":75,"value":1703},"    \"gender\": patient.gender,\n",{"type":70,"tag":203,"props":1705,"children":1707},{"class":205,"line":1706},25,[1708],{"type":70,"tag":203,"props":1709,"children":1710},{},[1711],{"type":75,"value":1712},"    \"birth_date\": str(patient.birthDate) if patient.birthDate else None,\n",{"type":70,"tag":203,"props":1714,"children":1716},{"class":205,"line":1715},26,[1717],{"type":70,"tag":203,"props":1718,"children":1719},{},[1720],{"type":75,"value":1633},{"type":70,"tag":312,"props":1722,"children":1724},{"id":1723},"extract-observation-condition-medicationrequest",[1725],{"type":75,"value":1726},"Extract Observation, Condition, MedicationRequest",{"type":70,"tag":85,"props":1728,"children":1729},{},[1730,1732,1738],{"type":75,"value":1731},"Pattern: ",{"type":70,"tag":175,"props":1733,"children":1735},{"className":1734},[],[1736],{"type":75,"value":1737},"model_validate(json)",{"type":75,"value":1739}," → extract by system URI, not array position.",{"type":70,"tag":192,"props":1741,"children":1743},{"className":608,"code":1742,"language":22,"meta":197,"style":197},"from fhir.resources.observation import Observation\nfrom fhir.resources.condition import Condition\nfrom fhir.resources.medicationrequest import MedicationRequest\n\ndef extract_observation(obs_json):\n    obs = Observation.model_validate(obs_json)\n    return {\n        \"id\": obs.id, \"status\": obs.status,\n        \"loinc_code\": next((c.code for c in (obs.code.coding or []) if c.system == \"http:\u002F\u002Floinc.org\"), None),\n        \"display\": obs.code.coding[0].display if obs.code.coding else None,\n        \"value\": obs.valueQuantity.value if obs.valueQuantity else None,\n        \"unit\": obs.valueQuantity.unit if obs.valueQuantity else None,\n        \"effective_date\": str(obs.effectiveDateTime) if obs.effectiveDateTime else None,\n        \"patient_ref\": obs.subject.reference if obs.subject else None,\n    }\n\ndef extract_condition(cond_json):\n    cond = Condition.model_validate(cond_json)\n    return {\n        \"id\": cond.id,\n        \"status\": cond.clinicalStatus.coding[0].code if cond.clinicalStatus and cond.clinicalStatus.coding else None,\n        \"snomed_code\": next((c.code for c in (cond.code.coding or []) if c.system and \"snomed\" in c.system), None),\n        \"icd10_code\": next((c.code for c in (cond.code.coding or []) if c.system and \"icd-10\" in c.system), None),\n        \"display\": cond.code.coding[0].display if cond.code.coding else None,\n        \"onset\": str(cond.onsetDateTime) if cond.onsetDateTime else None,\n        \"patient_ref\": cond.subject.reference if cond.subject else None,\n    }\n\ndef extract_medication_request(med_json):\n    med = MedicationRequest.model_validate(med_json)\n    cc = med.medicationCodeableConcept\n    return {\n        \"id\": med.id, \"status\": med.status,\n        \"rxnorm_code\": cc.coding[0].code if cc and cc.coding else None,\n        \"display\": cc.coding[0].display if cc and cc.coding else None,\n        \"dosage_text\": med.dosageInstruction[0].text if med.dosageInstruction else None,\n        \"authored_on\": str(med.authoredOn) if med.authoredOn else None,\n        \"patient_ref\": med.subject.reference if med.subject else None,\n    }\n",[1744],{"type":70,"tag":175,"props":1745,"children":1746},{"__ignoreMap":197},[1747,1755,1763,1771,1778,1786,1794,1801,1809,1817,1825,1833,1841,1849,1857,1864,1871,1879,1887,1894,1902,1910,1918,1926,1934,1942,1950,1958,1966,1975,1984,1993,2001,2010,2019,2028,2037,2046,2055],{"type":70,"tag":203,"props":1748,"children":1749},{"class":205,"line":206},[1750],{"type":70,"tag":203,"props":1751,"children":1752},{},[1753],{"type":75,"value":1754},"from fhir.resources.observation import Observation\n",{"type":70,"tag":203,"props":1756,"children":1757},{"class":205,"line":624},[1758],{"type":70,"tag":203,"props":1759,"children":1760},{},[1761],{"type":75,"value":1762},"from fhir.resources.condition import Condition\n",{"type":70,"tag":203,"props":1764,"children":1765},{"class":205,"line":634},[1766],{"type":70,"tag":203,"props":1767,"children":1768},{},[1769],{"type":75,"value":1770},"from fhir.resources.medicationrequest import MedicationRequest\n",{"type":70,"tag":203,"props":1772,"children":1773},{"class":205,"line":26},[1774],{"type":70,"tag":203,"props":1775,"children":1776},{"emptyLinePlaceholder":628},[1777],{"type":75,"value":631},{"type":70,"tag":203,"props":1779,"children":1780},{"class":205,"line":651},[1781],{"type":70,"tag":203,"props":1782,"children":1783},{},[1784],{"type":75,"value":1785},"def extract_observation(obs_json):\n",{"type":70,"tag":203,"props":1787,"children":1788},{"class":205,"line":660},[1789],{"type":70,"tag":203,"props":1790,"children":1791},{},[1792],{"type":75,"value":1793},"    obs = Observation.model_validate(obs_json)\n",{"type":70,"tag":203,"props":1795,"children":1796},{"class":205,"line":669},[1797],{"type":70,"tag":203,"props":1798,"children":1799},{},[1800],{"type":75,"value":765},{"type":70,"tag":203,"props":1802,"children":1803},{"class":205,"line":678},[1804],{"type":70,"tag":203,"props":1805,"children":1806},{},[1807],{"type":75,"value":1808},"        \"id\": obs.id, \"status\": obs.status,\n",{"type":70,"tag":203,"props":1810,"children":1811},{"class":205,"line":687},[1812],{"type":70,"tag":203,"props":1813,"children":1814},{},[1815],{"type":75,"value":1816},"        \"loinc_code\": next((c.code for c in (obs.code.coding or []) if c.system == \"http:\u002F\u002Floinc.org\"), None),\n",{"type":70,"tag":203,"props":1818,"children":1819},{"class":205,"line":696},[1820],{"type":70,"tag":203,"props":1821,"children":1822},{},[1823],{"type":75,"value":1824},"        \"display\": obs.code.coding[0].display if obs.code.coding else None,\n",{"type":70,"tag":203,"props":1826,"children":1827},{"class":205,"line":705},[1828],{"type":70,"tag":203,"props":1829,"children":1830},{},[1831],{"type":75,"value":1832},"        \"value\": obs.valueQuantity.value if obs.valueQuantity else None,\n",{"type":70,"tag":203,"props":1834,"children":1835},{"class":205,"line":714},[1836],{"type":70,"tag":203,"props":1837,"children":1838},{},[1839],{"type":75,"value":1840},"        \"unit\": obs.valueQuantity.unit if obs.valueQuantity else None,\n",{"type":70,"tag":203,"props":1842,"children":1843},{"class":205,"line":722},[1844],{"type":70,"tag":203,"props":1845,"children":1846},{},[1847],{"type":75,"value":1848},"        \"effective_date\": str(obs.effectiveDateTime) if obs.effectiveDateTime else None,\n",{"type":70,"tag":203,"props":1850,"children":1851},{"class":205,"line":1105},[1852],{"type":70,"tag":203,"props":1853,"children":1854},{},[1855],{"type":75,"value":1856},"        \"patient_ref\": obs.subject.reference if obs.subject else None,\n",{"type":70,"tag":203,"props":1858,"children":1859},{"class":205,"line":1114},[1860],{"type":70,"tag":203,"props":1861,"children":1862},{},[1863],{"type":75,"value":813},{"type":70,"tag":203,"props":1865,"children":1866},{"class":205,"line":1123},[1867],{"type":70,"tag":203,"props":1868,"children":1869},{"emptyLinePlaceholder":628},[1870],{"type":75,"value":631},{"type":70,"tag":203,"props":1872,"children":1873},{"class":205,"line":1132},[1874],{"type":70,"tag":203,"props":1875,"children":1876},{},[1877],{"type":75,"value":1878},"def extract_condition(cond_json):\n",{"type":70,"tag":203,"props":1880,"children":1881},{"class":205,"line":1140},[1882],{"type":70,"tag":203,"props":1883,"children":1884},{},[1885],{"type":75,"value":1886},"    cond = Condition.model_validate(cond_json)\n",{"type":70,"tag":203,"props":1888,"children":1889},{"class":205,"line":1447},[1890],{"type":70,"tag":203,"props":1891,"children":1892},{},[1893],{"type":75,"value":765},{"type":70,"tag":203,"props":1895,"children":1896},{"class":205,"line":1456},[1897],{"type":70,"tag":203,"props":1898,"children":1899},{},[1900],{"type":75,"value":1901},"        \"id\": cond.id,\n",{"type":70,"tag":203,"props":1903,"children":1904},{"class":205,"line":1465},[1905],{"type":70,"tag":203,"props":1906,"children":1907},{},[1908],{"type":75,"value":1909},"        \"status\": cond.clinicalStatus.coding[0].code if cond.clinicalStatus and cond.clinicalStatus.coding else None,\n",{"type":70,"tag":203,"props":1911,"children":1912},{"class":205,"line":1473},[1913],{"type":70,"tag":203,"props":1914,"children":1915},{},[1916],{"type":75,"value":1917},"        \"snomed_code\": next((c.code for c in (cond.code.coding or []) if c.system and \"snomed\" in c.system), None),\n",{"type":70,"tag":203,"props":1919,"children":1920},{"class":205,"line":1482},[1921],{"type":70,"tag":203,"props":1922,"children":1923},{},[1924],{"type":75,"value":1925},"        \"icd10_code\": next((c.code for c in (cond.code.coding or []) if c.system and \"icd-10\" in c.system), None),\n",{"type":70,"tag":203,"props":1927,"children":1928},{"class":205,"line":1490},[1929],{"type":70,"tag":203,"props":1930,"children":1931},{},[1932],{"type":75,"value":1933},"        \"display\": cond.code.coding[0].display if cond.code.coding else None,\n",{"type":70,"tag":203,"props":1935,"children":1936},{"class":205,"line":1706},[1937],{"type":70,"tag":203,"props":1938,"children":1939},{},[1940],{"type":75,"value":1941},"        \"onset\": str(cond.onsetDateTime) if cond.onsetDateTime else None,\n",{"type":70,"tag":203,"props":1943,"children":1944},{"class":205,"line":1715},[1945],{"type":70,"tag":203,"props":1946,"children":1947},{},[1948],{"type":75,"value":1949},"        \"patient_ref\": cond.subject.reference if cond.subject else None,\n",{"type":70,"tag":203,"props":1951,"children":1953},{"class":205,"line":1952},27,[1954],{"type":70,"tag":203,"props":1955,"children":1956},{},[1957],{"type":75,"value":813},{"type":70,"tag":203,"props":1959,"children":1961},{"class":205,"line":1960},28,[1962],{"type":70,"tag":203,"props":1963,"children":1964},{"emptyLinePlaceholder":628},[1965],{"type":75,"value":631},{"type":70,"tag":203,"props":1967,"children":1969},{"class":205,"line":1968},29,[1970],{"type":70,"tag":203,"props":1971,"children":1972},{},[1973],{"type":75,"value":1974},"def extract_medication_request(med_json):\n",{"type":70,"tag":203,"props":1976,"children":1978},{"class":205,"line":1977},30,[1979],{"type":70,"tag":203,"props":1980,"children":1981},{},[1982],{"type":75,"value":1983},"    med = MedicationRequest.model_validate(med_json)\n",{"type":70,"tag":203,"props":1985,"children":1987},{"class":205,"line":1986},31,[1988],{"type":70,"tag":203,"props":1989,"children":1990},{},[1991],{"type":75,"value":1992},"    cc = med.medicationCodeableConcept\n",{"type":70,"tag":203,"props":1994,"children":1996},{"class":205,"line":1995},32,[1997],{"type":70,"tag":203,"props":1998,"children":1999},{},[2000],{"type":75,"value":765},{"type":70,"tag":203,"props":2002,"children":2004},{"class":205,"line":2003},33,[2005],{"type":70,"tag":203,"props":2006,"children":2007},{},[2008],{"type":75,"value":2009},"        \"id\": med.id, \"status\": med.status,\n",{"type":70,"tag":203,"props":2011,"children":2013},{"class":205,"line":2012},34,[2014],{"type":70,"tag":203,"props":2015,"children":2016},{},[2017],{"type":75,"value":2018},"        \"rxnorm_code\": cc.coding[0].code if cc and cc.coding else None,\n",{"type":70,"tag":203,"props":2020,"children":2022},{"class":205,"line":2021},35,[2023],{"type":70,"tag":203,"props":2024,"children":2025},{},[2026],{"type":75,"value":2027},"        \"display\": cc.coding[0].display if cc and cc.coding else None,\n",{"type":70,"tag":203,"props":2029,"children":2031},{"class":205,"line":2030},36,[2032],{"type":70,"tag":203,"props":2033,"children":2034},{},[2035],{"type":75,"value":2036},"        \"dosage_text\": med.dosageInstruction[0].text if med.dosageInstruction else None,\n",{"type":70,"tag":203,"props":2038,"children":2040},{"class":205,"line":2039},37,[2041],{"type":70,"tag":203,"props":2042,"children":2043},{},[2044],{"type":75,"value":2045},"        \"authored_on\": str(med.authoredOn) if med.authoredOn else None,\n",{"type":70,"tag":203,"props":2047,"children":2049},{"class":205,"line":2048},38,[2050],{"type":70,"tag":203,"props":2051,"children":2052},{},[2053],{"type":75,"value":2054},"        \"patient_ref\": med.subject.reference if med.subject else None,\n",{"type":70,"tag":203,"props":2056,"children":2058},{"class":205,"line":2057},39,[2059],{"type":70,"tag":203,"props":2060,"children":2061},{},[2062],{"type":75,"value":813},{"type":70,"tag":276,"props":2064,"children":2066},{"id":2065},"_4-fhir-bundle-flattening",[2067],{"type":75,"value":2068},"4. FHIR Bundle Flattening",{"type":70,"tag":192,"props":2070,"children":2072},{"className":608,"code":2071,"language":22,"meta":197,"style":197},"import json\nimport pandas as pd\nfrom fhir.resources.bundle import Bundle\n\ndef flatten_observation_bundle(bundle_json):\n    \"\"\"Extract all Observation resources from a FHIR Bundle into a DataFrame.\"\"\"\n    bundle = Bundle.model_validate(bundle_json)\n    rows = [extract_observation(entry.resource.model_dump())\n            for entry in (bundle.entry or [])\n            if entry.resource.resource_type == \"Observation\"]\n    return pd.DataFrame(rows)\n\nwith open(\"observations_bundle.json\") as f:\n    df = flatten_observation_bundle(json.load(f))\n",[2073],{"type":70,"tag":175,"props":2074,"children":2075},{"__ignoreMap":197},[2076,2084,2091,2099,2106,2114,2122,2130,2138,2146,2154,2162,2169,2177],{"type":70,"tag":203,"props":2077,"children":2078},{"class":205,"line":206},[2079],{"type":70,"tag":203,"props":2080,"children":2081},{},[2082],{"type":75,"value":2083},"import json\n",{"type":70,"tag":203,"props":2085,"children":2086},{"class":205,"line":624},[2087],{"type":70,"tag":203,"props":2088,"children":2089},{},[2090],{"type":75,"value":1319},{"type":70,"tag":203,"props":2092,"children":2093},{"class":205,"line":634},[2094],{"type":70,"tag":203,"props":2095,"children":2096},{},[2097],{"type":75,"value":2098},"from fhir.resources.bundle import Bundle\n",{"type":70,"tag":203,"props":2100,"children":2101},{"class":205,"line":26},[2102],{"type":70,"tag":203,"props":2103,"children":2104},{"emptyLinePlaceholder":628},[2105],{"type":75,"value":631},{"type":70,"tag":203,"props":2107,"children":2108},{"class":205,"line":651},[2109],{"type":70,"tag":203,"props":2110,"children":2111},{},[2112],{"type":75,"value":2113},"def flatten_observation_bundle(bundle_json):\n",{"type":70,"tag":203,"props":2115,"children":2116},{"class":205,"line":660},[2117],{"type":70,"tag":203,"props":2118,"children":2119},{},[2120],{"type":75,"value":2121},"    \"\"\"Extract all Observation resources from a FHIR Bundle into a DataFrame.\"\"\"\n",{"type":70,"tag":203,"props":2123,"children":2124},{"class":205,"line":669},[2125],{"type":70,"tag":203,"props":2126,"children":2127},{},[2128],{"type":75,"value":2129},"    bundle = Bundle.model_validate(bundle_json)\n",{"type":70,"tag":203,"props":2131,"children":2132},{"class":205,"line":678},[2133],{"type":70,"tag":203,"props":2134,"children":2135},{},[2136],{"type":75,"value":2137},"    rows = [extract_observation(entry.resource.model_dump())\n",{"type":70,"tag":203,"props":2139,"children":2140},{"class":205,"line":687},[2141],{"type":70,"tag":203,"props":2142,"children":2143},{},[2144],{"type":75,"value":2145},"            for entry in (bundle.entry or [])\n",{"type":70,"tag":203,"props":2147,"children":2148},{"class":205,"line":696},[2149],{"type":70,"tag":203,"props":2150,"children":2151},{},[2152],{"type":75,"value":2153},"            if entry.resource.resource_type == \"Observation\"]\n",{"type":70,"tag":203,"props":2155,"children":2156},{"class":205,"line":705},[2157],{"type":70,"tag":203,"props":2158,"children":2159},{},[2160],{"type":75,"value":2161},"    return pd.DataFrame(rows)\n",{"type":70,"tag":203,"props":2163,"children":2164},{"class":205,"line":714},[2165],{"type":70,"tag":203,"props":2166,"children":2167},{"emptyLinePlaceholder":628},[2168],{"type":75,"value":631},{"type":70,"tag":203,"props":2170,"children":2171},{"class":205,"line":722},[2172],{"type":70,"tag":203,"props":2173,"children":2174},{},[2175],{"type":75,"value":2176},"with open(\"observations_bundle.json\") as f:\n",{"type":70,"tag":203,"props":2178,"children":2179},{"class":205,"line":1105},[2180],{"type":70,"tag":203,"props":2181,"children":2182},{},[2183],{"type":75,"value":2184},"    df = flatten_observation_bundle(json.load(f))\n",{"type":70,"tag":276,"props":2186,"children":2188},{"id":2187},"_5-data-quality-checks",[2189],{"type":75,"value":2190},"5. Data Quality Checks",{"type":70,"tag":192,"props":2192,"children":2194},{"className":608,"code":2193,"language":22,"meta":197,"style":197},"import pandas as pd\nfrom datetime import datetime\n\ndef check_completeness(df, required_columns):\n    \"\"\"Report missing value rates for required columns.\"\"\"\n    report = {}\n    for col in required_columns:\n        if col not in df.columns:\n            report[col] = {\"status\": \"MISSING_COLUMN\", \"pct_complete\": 0.0}\n        else:\n            pct = (df[col].notna().sum() \u002F len(df)) * 100\n            report[col] = {\n                \"status\": \"OK\" if pct >= 95 else \"WARNING\" if pct >= 80 else \"FAIL\",\n                \"pct_complete\": round(pct, 1),\n            }\n    return report\n\ndef validate_dates(series, fmt=\"%Y-%m-%d\", min_date=\"1900-01-01\", max_date=None):\n    \"\"\"Validate date strings. Returns indices of invalid entries.\"\"\"\n    max_dt = datetime.strptime(max_date, fmt) if max_date else datetime.now()\n    min_dt = datetime.strptime(min_date, fmt)\n    invalid = []\n    for idx, val in series.items():\n        if pd.isna(val):\n            continue\n        try:\n            dt = datetime.strptime(str(val)[:10], fmt)\n            if dt \u003C min_dt or dt > max_dt:\n                invalid.append({\"index\": idx, \"value\": val, \"reason\": \"out_of_range\"})\n        except ValueError:\n            invalid.append({\"index\": idx, \"value\": val, \"reason\": \"parse_error\"})\n    return invalid\n\ndef verify_code_system(df, code_col, valid_codes, system_name=\"unknown\"):\n    \"\"\"Check that coded values belong to an expected set.\"\"\"\n    if code_col not in df.columns:\n        return {\"status\": \"MISSING_COLUMN\", \"invalid_count\": 0}\n    codes = df[code_col].dropna().unique()\n    invalid = [c for c in codes if c not in valid_codes]\n    return {\n        \"system\": system_name, \"total_unique\": len(codes),\n        \"invalid_codes\": invalid, \"invalid_count\": len(invalid),\n        \"status\": \"OK\" if len(invalid) == 0 else \"FAIL\",\n    }\n",[2195],{"type":70,"tag":175,"props":2196,"children":2197},{"__ignoreMap":197},[2198,2205,2213,2220,2228,2236,2244,2252,2260,2268,2276,2284,2292,2300,2308,2316,2324,2331,2339,2347,2355,2363,2371,2379,2387,2394,2402,2410,2418,2426,2434,2442,2450,2457,2465,2473,2481,2489,2497,2505,2513,2522,2531,2540],{"type":70,"tag":203,"props":2199,"children":2200},{"class":205,"line":206},[2201],{"type":70,"tag":203,"props":2202,"children":2203},{},[2204],{"type":75,"value":1319},{"type":70,"tag":203,"props":2206,"children":2207},{"class":205,"line":624},[2208],{"type":70,"tag":203,"props":2209,"children":2210},{},[2211],{"type":75,"value":2212},"from datetime import datetime\n",{"type":70,"tag":203,"props":2214,"children":2215},{"class":205,"line":634},[2216],{"type":70,"tag":203,"props":2217,"children":2218},{"emptyLinePlaceholder":628},[2219],{"type":75,"value":631},{"type":70,"tag":203,"props":2221,"children":2222},{"class":205,"line":26},[2223],{"type":70,"tag":203,"props":2224,"children":2225},{},[2226],{"type":75,"value":2227},"def check_completeness(df, required_columns):\n",{"type":70,"tag":203,"props":2229,"children":2230},{"class":205,"line":651},[2231],{"type":70,"tag":203,"props":2232,"children":2233},{},[2234],{"type":75,"value":2235},"    \"\"\"Report missing value rates for required columns.\"\"\"\n",{"type":70,"tag":203,"props":2237,"children":2238},{"class":205,"line":660},[2239],{"type":70,"tag":203,"props":2240,"children":2241},{},[2242],{"type":75,"value":2243},"    report = {}\n",{"type":70,"tag":203,"props":2245,"children":2246},{"class":205,"line":669},[2247],{"type":70,"tag":203,"props":2248,"children":2249},{},[2250],{"type":75,"value":2251},"    for col in required_columns:\n",{"type":70,"tag":203,"props":2253,"children":2254},{"class":205,"line":678},[2255],{"type":70,"tag":203,"props":2256,"children":2257},{},[2258],{"type":75,"value":2259},"        if col not in df.columns:\n",{"type":70,"tag":203,"props":2261,"children":2262},{"class":205,"line":687},[2263],{"type":70,"tag":203,"props":2264,"children":2265},{},[2266],{"type":75,"value":2267},"            report[col] = {\"status\": \"MISSING_COLUMN\", \"pct_complete\": 0.0}\n",{"type":70,"tag":203,"props":2269,"children":2270},{"class":205,"line":696},[2271],{"type":70,"tag":203,"props":2272,"children":2273},{},[2274],{"type":75,"value":2275},"        else:\n",{"type":70,"tag":203,"props":2277,"children":2278},{"class":205,"line":705},[2279],{"type":70,"tag":203,"props":2280,"children":2281},{},[2282],{"type":75,"value":2283},"            pct = (df[col].notna().sum() \u002F len(df)) * 100\n",{"type":70,"tag":203,"props":2285,"children":2286},{"class":205,"line":714},[2287],{"type":70,"tag":203,"props":2288,"children":2289},{},[2290],{"type":75,"value":2291},"            report[col] = {\n",{"type":70,"tag":203,"props":2293,"children":2294},{"class":205,"line":722},[2295],{"type":70,"tag":203,"props":2296,"children":2297},{},[2298],{"type":75,"value":2299},"                \"status\": \"OK\" if pct >= 95 else \"WARNING\" if pct >= 80 else \"FAIL\",\n",{"type":70,"tag":203,"props":2301,"children":2302},{"class":205,"line":1105},[2303],{"type":70,"tag":203,"props":2304,"children":2305},{},[2306],{"type":75,"value":2307},"                \"pct_complete\": round(pct, 1),\n",{"type":70,"tag":203,"props":2309,"children":2310},{"class":205,"line":1114},[2311],{"type":70,"tag":203,"props":2312,"children":2313},{},[2314],{"type":75,"value":2315},"            }\n",{"type":70,"tag":203,"props":2317,"children":2318},{"class":205,"line":1123},[2319],{"type":70,"tag":203,"props":2320,"children":2321},{},[2322],{"type":75,"value":2323},"    return report\n",{"type":70,"tag":203,"props":2325,"children":2326},{"class":205,"line":1132},[2327],{"type":70,"tag":203,"props":2328,"children":2329},{"emptyLinePlaceholder":628},[2330],{"type":75,"value":631},{"type":70,"tag":203,"props":2332,"children":2333},{"class":205,"line":1140},[2334],{"type":70,"tag":203,"props":2335,"children":2336},{},[2337],{"type":75,"value":2338},"def validate_dates(series, fmt=\"%Y-%m-%d\", min_date=\"1900-01-01\", max_date=None):\n",{"type":70,"tag":203,"props":2340,"children":2341},{"class":205,"line":1447},[2342],{"type":70,"tag":203,"props":2343,"children":2344},{},[2345],{"type":75,"value":2346},"    \"\"\"Validate date strings. Returns indices of invalid entries.\"\"\"\n",{"type":70,"tag":203,"props":2348,"children":2349},{"class":205,"line":1456},[2350],{"type":70,"tag":203,"props":2351,"children":2352},{},[2353],{"type":75,"value":2354},"    max_dt = datetime.strptime(max_date, fmt) if max_date else datetime.now()\n",{"type":70,"tag":203,"props":2356,"children":2357},{"class":205,"line":1465},[2358],{"type":70,"tag":203,"props":2359,"children":2360},{},[2361],{"type":75,"value":2362},"    min_dt = datetime.strptime(min_date, fmt)\n",{"type":70,"tag":203,"props":2364,"children":2365},{"class":205,"line":1473},[2366],{"type":70,"tag":203,"props":2367,"children":2368},{},[2369],{"type":75,"value":2370},"    invalid = []\n",{"type":70,"tag":203,"props":2372,"children":2373},{"class":205,"line":1482},[2374],{"type":70,"tag":203,"props":2375,"children":2376},{},[2377],{"type":75,"value":2378},"    for idx, val in series.items():\n",{"type":70,"tag":203,"props":2380,"children":2381},{"class":205,"line":1490},[2382],{"type":70,"tag":203,"props":2383,"children":2384},{},[2385],{"type":75,"value":2386},"        if pd.isna(val):\n",{"type":70,"tag":203,"props":2388,"children":2389},{"class":205,"line":1706},[2390],{"type":70,"tag":203,"props":2391,"children":2392},{},[2393],{"type":75,"value":1428},{"type":70,"tag":203,"props":2395,"children":2396},{"class":205,"line":1715},[2397],{"type":70,"tag":203,"props":2398,"children":2399},{},[2400],{"type":75,"value":2401},"        try:\n",{"type":70,"tag":203,"props":2403,"children":2404},{"class":205,"line":1952},[2405],{"type":70,"tag":203,"props":2406,"children":2407},{},[2408],{"type":75,"value":2409},"            dt = datetime.strptime(str(val)[:10], fmt)\n",{"type":70,"tag":203,"props":2411,"children":2412},{"class":205,"line":1960},[2413],{"type":70,"tag":203,"props":2414,"children":2415},{},[2416],{"type":75,"value":2417},"            if dt \u003C min_dt or dt > max_dt:\n",{"type":70,"tag":203,"props":2419,"children":2420},{"class":205,"line":1968},[2421],{"type":70,"tag":203,"props":2422,"children":2423},{},[2424],{"type":75,"value":2425},"                invalid.append({\"index\": idx, \"value\": val, \"reason\": \"out_of_range\"})\n",{"type":70,"tag":203,"props":2427,"children":2428},{"class":205,"line":1977},[2429],{"type":70,"tag":203,"props":2430,"children":2431},{},[2432],{"type":75,"value":2433},"        except ValueError:\n",{"type":70,"tag":203,"props":2435,"children":2436},{"class":205,"line":1986},[2437],{"type":70,"tag":203,"props":2438,"children":2439},{},[2440],{"type":75,"value":2441},"            invalid.append({\"index\": idx, \"value\": val, \"reason\": \"parse_error\"})\n",{"type":70,"tag":203,"props":2443,"children":2444},{"class":205,"line":1995},[2445],{"type":70,"tag":203,"props":2446,"children":2447},{},[2448],{"type":75,"value":2449},"    return invalid\n",{"type":70,"tag":203,"props":2451,"children":2452},{"class":205,"line":2003},[2453],{"type":70,"tag":203,"props":2454,"children":2455},{"emptyLinePlaceholder":628},[2456],{"type":75,"value":631},{"type":70,"tag":203,"props":2458,"children":2459},{"class":205,"line":2012},[2460],{"type":70,"tag":203,"props":2461,"children":2462},{},[2463],{"type":75,"value":2464},"def verify_code_system(df, code_col, valid_codes, system_name=\"unknown\"):\n",{"type":70,"tag":203,"props":2466,"children":2467},{"class":205,"line":2021},[2468],{"type":70,"tag":203,"props":2469,"children":2470},{},[2471],{"type":75,"value":2472},"    \"\"\"Check that coded values belong to an expected set.\"\"\"\n",{"type":70,"tag":203,"props":2474,"children":2475},{"class":205,"line":2030},[2476],{"type":70,"tag":203,"props":2477,"children":2478},{},[2479],{"type":75,"value":2480},"    if code_col not in df.columns:\n",{"type":70,"tag":203,"props":2482,"children":2483},{"class":205,"line":2039},[2484],{"type":70,"tag":203,"props":2485,"children":2486},{},[2487],{"type":75,"value":2488},"        return {\"status\": \"MISSING_COLUMN\", \"invalid_count\": 0}\n",{"type":70,"tag":203,"props":2490,"children":2491},{"class":205,"line":2048},[2492],{"type":70,"tag":203,"props":2493,"children":2494},{},[2495],{"type":75,"value":2496},"    codes = df[code_col].dropna().unique()\n",{"type":70,"tag":203,"props":2498,"children":2499},{"class":205,"line":2057},[2500],{"type":70,"tag":203,"props":2501,"children":2502},{},[2503],{"type":75,"value":2504},"    invalid = [c for c in codes if c not in valid_codes]\n",{"type":70,"tag":203,"props":2506,"children":2508},{"class":205,"line":2507},40,[2509],{"type":70,"tag":203,"props":2510,"children":2511},{},[2512],{"type":75,"value":765},{"type":70,"tag":203,"props":2514,"children":2516},{"class":205,"line":2515},41,[2517],{"type":70,"tag":203,"props":2518,"children":2519},{},[2520],{"type":75,"value":2521},"        \"system\": system_name, \"total_unique\": len(codes),\n",{"type":70,"tag":203,"props":2523,"children":2525},{"class":205,"line":2524},42,[2526],{"type":70,"tag":203,"props":2527,"children":2528},{},[2529],{"type":75,"value":2530},"        \"invalid_codes\": invalid, \"invalid_count\": len(invalid),\n",{"type":70,"tag":203,"props":2532,"children":2534},{"class":205,"line":2533},43,[2535],{"type":70,"tag":203,"props":2536,"children":2537},{},[2538],{"type":75,"value":2539},"        \"status\": \"OK\" if len(invalid) == 0 else \"FAIL\",\n",{"type":70,"tag":203,"props":2541,"children":2543},{"class":205,"line":2542},44,[2544],{"type":70,"tag":203,"props":2545,"children":2546},{},[2547],{"type":75,"value":813},{"type":70,"tag":312,"props":2549,"children":2551},{"id":2550},"quality-check-thresholds",[2552],{"type":75,"value":2553},"Quality check thresholds",{"type":70,"tag":319,"props":2555,"children":2556},{},[2557,2583],{"type":70,"tag":323,"props":2558,"children":2559},{},[2560],{"type":70,"tag":327,"props":2561,"children":2562},{},[2563,2568,2573,2578],{"type":70,"tag":331,"props":2564,"children":2565},{},[2566],{"type":75,"value":2567},"Check",{"type":70,"tag":331,"props":2569,"children":2570},{},[2571],{"type":75,"value":2572},"Pass",{"type":70,"tag":331,"props":2574,"children":2575},{},[2576],{"type":75,"value":2577},"Warning",{"type":70,"tag":331,"props":2579,"children":2580},{},[2581],{"type":75,"value":2582},"Fail",{"type":70,"tag":347,"props":2584,"children":2585},{},[2586,2609,2632,2654,2676],{"type":70,"tag":327,"props":2587,"children":2588},{},[2589,2594,2599,2604],{"type":70,"tag":354,"props":2590,"children":2591},{},[2592],{"type":75,"value":2593},"Completeness (required field)",{"type":70,"tag":354,"props":2595,"children":2596},{},[2597],{"type":75,"value":2598},"≥ 95%",{"type":70,"tag":354,"props":2600,"children":2601},{},[2602],{"type":75,"value":2603},"80–95%",{"type":70,"tag":354,"props":2605,"children":2606},{},[2607],{"type":75,"value":2608},"\u003C 80%",{"type":70,"tag":327,"props":2610,"children":2611},{},[2612,2617,2622,2627],{"type":70,"tag":354,"props":2613,"children":2614},{},[2615],{"type":75,"value":2616},"Date validity",{"type":70,"tag":354,"props":2618,"children":2619},{},[2620],{"type":75,"value":2621},"0 parse errors",{"type":70,"tag":354,"props":2623,"children":2624},{},[2625],{"type":75,"value":2626},"—",{"type":70,"tag":354,"props":2628,"children":2629},{},[2630],{"type":75,"value":2631},"Any parse error",{"type":70,"tag":327,"props":2633,"children":2634},{},[2635,2640,2645,2649],{"type":70,"tag":354,"props":2636,"children":2637},{},[2638],{"type":75,"value":2639},"Date range",{"type":70,"tag":354,"props":2641,"children":2642},{},[2643],{"type":75,"value":2644},"All within expected range",{"type":70,"tag":354,"props":2646,"children":2647},{},[2648],{"type":75,"value":2626},{"type":70,"tag":354,"props":2650,"children":2651},{},[2652],{"type":75,"value":2653},"Future dates or pre-1900",{"type":70,"tag":327,"props":2655,"children":2656},{},[2657,2662,2667,2671],{"type":70,"tag":354,"props":2658,"children":2659},{},[2660],{"type":75,"value":2661},"Code system membership",{"type":70,"tag":354,"props":2663,"children":2664},{},[2665],{"type":75,"value":2666},"All codes valid",{"type":70,"tag":354,"props":2668,"children":2669},{},[2670],{"type":75,"value":2626},{"type":70,"tag":354,"props":2672,"children":2673},{},[2674],{"type":75,"value":2675},"Any unrecognized code",{"type":70,"tag":327,"props":2677,"children":2678},{},[2679,2684,2689,2693],{"type":70,"tag":354,"props":2680,"children":2681},{},[2682],{"type":75,"value":2683},"Duplicate patient IDs",{"type":70,"tag":354,"props":2685,"children":2686},{},[2687],{"type":75,"value":2688},"0 exact duplicates",{"type":70,"tag":354,"props":2690,"children":2691},{},[2692],{"type":75,"value":2626},{"type":70,"tag":354,"props":2694,"children":2695},{},[2696],{"type":75,"value":2697},"Any duplicate MRN with conflicting demographics",{"type":70,"tag":276,"props":2699,"children":2701},{"id":2700},"_6-hl7v2-to-fhir-conceptual-mapping",[2702],{"type":75,"value":2703},"6. HL7v2 to FHIR Conceptual Mapping",{"type":70,"tag":319,"props":2705,"children":2706},{},[2707,2728],{"type":70,"tag":323,"props":2708,"children":2709},{},[2710],{"type":70,"tag":327,"props":2711,"children":2712},{},[2713,2718,2723],{"type":70,"tag":331,"props":2714,"children":2715},{},[2716],{"type":75,"value":2717},"HL7v2 Segment",{"type":70,"tag":331,"props":2719,"children":2720},{},[2721],{"type":75,"value":2722},"FHIR Resource",{"type":70,"tag":331,"props":2724,"children":2725},{},[2726],{"type":75,"value":2727},"Key fields",{"type":70,"tag":347,"props":2729,"children":2730},{},[2731,2748,2765,2782,2799,2817],{"type":70,"tag":327,"props":2732,"children":2733},{},[2734,2738,2743],{"type":70,"tag":354,"props":2735,"children":2736},{},[2737],{"type":75,"value":376},{"type":70,"tag":354,"props":2739,"children":2740},{},[2741],{"type":75,"value":2742},"Patient",{"type":70,"tag":354,"props":2744,"children":2745},{},[2746],{"type":75,"value":2747},"identifier, name, birthDate, gender",{"type":70,"tag":327,"props":2749,"children":2750},{},[2751,2755,2760],{"type":70,"tag":354,"props":2752,"children":2753},{},[2754],{"type":75,"value":394},{"type":70,"tag":354,"props":2756,"children":2757},{},[2758],{"type":75,"value":2759},"Encounter",{"type":70,"tag":354,"props":2761,"children":2762},{},[2763],{"type":75,"value":2764},"class, period, participant",{"type":70,"tag":327,"props":2766,"children":2767},{},[2768,2773,2777],{"type":70,"tag":354,"props":2769,"children":2770},{},[2771],{"type":75,"value":2772},"OBR + OBX",{"type":70,"tag":354,"props":2774,"children":2775},{},[2776],{"type":75,"value":558},{"type":70,"tag":354,"props":2778,"children":2779},{},[2780],{"type":75,"value":2781},"code, value, effectiveDateTime, status",{"type":70,"tag":327,"props":2783,"children":2784},{},[2785,2789,2794],{"type":70,"tag":354,"props":2786,"children":2787},{},[2788],{"type":75,"value":448},{"type":70,"tag":354,"props":2790,"children":2791},{},[2792],{"type":75,"value":2793},"Condition",{"type":70,"tag":354,"props":2795,"children":2796},{},[2797],{"type":75,"value":2798},"code, onsetDateTime, clinicalStatus",{"type":70,"tag":327,"props":2800,"children":2801},{},[2802,2807,2812],{"type":70,"tag":354,"props":2803,"children":2804},{},[2805],{"type":75,"value":2806},"ORC + RXE",{"type":70,"tag":354,"props":2808,"children":2809},{},[2810],{"type":75,"value":2811},"MedicationRequest",{"type":70,"tag":354,"props":2813,"children":2814},{},[2815],{"type":75,"value":2816},"medicationCodeableConcept, dosageInstruction",{"type":70,"tag":327,"props":2818,"children":2819},{},[2820,2824,2829],{"type":70,"tag":354,"props":2821,"children":2822},{},[2823],{"type":75,"value":466},{"type":70,"tag":354,"props":2825,"children":2826},{},[2827],{"type":75,"value":2828},"AllergyIntolerance",{"type":70,"tag":354,"props":2830,"children":2831},{},[2832],{"type":75,"value":2833},"code, reaction, criticality",{"type":70,"tag":78,"props":2835,"children":2837},{"id":2836},"common-mistakes",[2838],{"type":75,"value":2839},"Common Mistakes",{"type":70,"tag":96,"props":2841,"children":2842},{},[2843,2868,2930,2951,2972,3029,3066,3103,3140,3190],{"type":70,"tag":100,"props":2844,"children":2845},{},[2846,2852,2854,2859,2861,2866],{"type":70,"tag":2847,"props":2848,"children":2849},"strong",{},[2850],{"type":75,"value":2851},"Wrong:",{"type":75,"value":2853}," Assuming fixed field positions across all HL7v2 versions without checking for empty segments\n",{"type":70,"tag":2847,"props":2855,"children":2856},{},[2857],{"type":75,"value":2858},"Right:",{"type":75,"value":2860}," Always check for empty segments before accessing subfields — field positions are stable but optional fields may be absent\n",{"type":70,"tag":2847,"props":2862,"children":2863},{},[2864],{"type":75,"value":2865},"Why:",{"type":75,"value":2867}," Accessing a subfield of an empty segment raises index errors or returns incorrect data",{"type":70,"tag":100,"props":2869,"children":2870},{},[2871,2875,2877,2883,2885,2891,2895,2897,2902,2904,2910,2912,2917,2921,2923,2928],{"type":70,"tag":2847,"props":2872,"children":2873},{},[2874],{"type":75,"value":2851},{"type":75,"value":2876}," Splitting HL7v2 messages on ",{"type":70,"tag":175,"props":2878,"children":2880},{"className":2879},[],[2881],{"type":75,"value":2882},"\\n",{"type":75,"value":2884}," instead of ",{"type":70,"tag":175,"props":2886,"children":2888},{"className":2887},[],[2889],{"type":75,"value":2890},"\\r",{"type":70,"tag":2847,"props":2892,"children":2893},{},[2894],{"type":75,"value":2858},{"type":75,"value":2896}," Normalize segment delimiters to ",{"type":70,"tag":175,"props":2898,"children":2900},{"className":2899},[],[2901],{"type":75,"value":2890},{"type":75,"value":2903}," before parsing — many files use ",{"type":70,"tag":175,"props":2905,"children":2907},{"className":2906},[],[2908],{"type":75,"value":2909},"\\r\\n",{"type":75,"value":2911}," or ",{"type":70,"tag":175,"props":2913,"children":2915},{"className":2914},[],[2916],{"type":75,"value":2882},{"type":70,"tag":2847,"props":2918,"children":2919},{},[2920],{"type":75,"value":2865},{"type":75,"value":2922}," The HL7v2 standard segment delimiter is carriage return (",{"type":70,"tag":175,"props":2924,"children":2926},{"className":2925},[],[2927],{"type":75,"value":2890},{"type":75,"value":2929},"); incorrect splitting produces malformed segments",{"type":70,"tag":100,"props":2931,"children":2932},{},[2933,2937,2939,2943,2945,2949],{"type":70,"tag":2847,"props":2934,"children":2935},{},[2936],{"type":75,"value":2851},{"type":75,"value":2938}," Parsing OBX-5 without checking the value type in OBX-2\n",{"type":70,"tag":2847,"props":2940,"children":2941},{},[2942],{"type":75,"value":2858},{"type":75,"value":2944}," Always check OBX-2 first — numeric (NM) and coded (CE) results require different parsing logic\n",{"type":70,"tag":2847,"props":2946,"children":2947},{},[2948],{"type":75,"value":2865},{"type":75,"value":2950}," Misinterpreting a coded entry as numeric (or vice versa) produces corrupt data",{"type":70,"tag":100,"props":2952,"children":2953},{},[2954,2958,2960,2964,2966,2970],{"type":70,"tag":2847,"props":2955,"children":2956},{},[2957],{"type":75,"value":2851},{"type":75,"value":2959}," Treating all OBX segments as lab results\n",{"type":70,"tag":2847,"props":2961,"children":2962},{},[2963],{"type":75,"value":2858},{"type":75,"value":2965}," Filter by OBR context or OBX-3 code system to distinguish labs from vitals, imaging impressions, and clinical notes\n",{"type":70,"tag":2847,"props":2967,"children":2968},{},[2969],{"type":75,"value":2865},{"type":75,"value":2971}," OBX carries many observation types; assuming all are labs leads to mixed, unusable datasets",{"type":70,"tag":100,"props":2973,"children":2974},{},[2975,2979,2981,2987,2988,2992,2994,2999,3001,3007,3009,3015,3016,3022,3023,3027],{"type":70,"tag":2847,"props":2976,"children":2977},{},[2978],{"type":75,"value":2851},{"type":75,"value":2980}," Hardcoding FHIR resource field paths (e.g., always accessing ",{"type":70,"tag":175,"props":2982,"children":2984},{"className":2983},[],[2985],{"type":75,"value":2986},"effectiveDateTime",{"type":75,"value":711},{"type":70,"tag":2847,"props":2989,"children":2990},{},[2991],{"type":75,"value":2858},{"type":75,"value":2993}," Check which choice type variant is present (e.g., ",{"type":70,"tag":175,"props":2995,"children":2997},{"className":2996},[],[2998],{"type":75,"value":2986},{"type":75,"value":3000}," vs ",{"type":70,"tag":175,"props":3002,"children":3004},{"className":3003},[],[3005],{"type":75,"value":3006},"effectivePeriod",{"type":75,"value":3008},", ",{"type":70,"tag":175,"props":3010,"children":3012},{"className":3011},[],[3013],{"type":75,"value":3014},"valueQuantity",{"type":75,"value":3000},{"type":70,"tag":175,"props":3017,"children":3019},{"className":3018},[],[3020],{"type":75,"value":3021},"valueCodeableConcept",{"type":75,"value":711},{"type":70,"tag":2847,"props":3024,"children":3025},{},[3026],{"type":75,"value":2865},{"type":75,"value":3028}," FHIR allows choice types — hardcoded paths raise AttributeError or miss data when the alternate variant is used",{"type":70,"tag":100,"props":3030,"children":3031},{},[3032,3036,3038,3044,3046,3050,3052,3058,3060,3064],{"type":70,"tag":2847,"props":3033,"children":3034},{},[3035],{"type":75,"value":2851},{"type":75,"value":3037}," Including preliminary Observations (",{"type":70,"tag":175,"props":3039,"children":3041},{"className":3040},[],[3042],{"type":75,"value":3043},"status: \"preliminary\"",{"type":75,"value":3045},") in analysis datasets\n",{"type":70,"tag":2847,"props":3047,"children":3048},{},[3049],{"type":75,"value":2858},{"type":75,"value":3051}," Filter on ",{"type":70,"tag":175,"props":3053,"children":3055},{"className":3054},[],[3056],{"type":75,"value":3057},"status: \"final\"",{"type":75,"value":3059}," for analysis — preliminary results may be superseded\n",{"type":70,"tag":2847,"props":3061,"children":3062},{},[3063],{"type":75,"value":2865},{"type":75,"value":3065}," Preliminary results can be corrected or replaced, leading to duplicate or inaccurate data in analyses",{"type":70,"tag":100,"props":3067,"children":3068},{},[3069,3073,3075,3081,3083,3087,3089,3095,3097,3101],{"type":70,"tag":2847,"props":3070,"children":3071},{},[3072],{"type":75,"value":2851},{"type":75,"value":3074}," Extracting coded values by array position (e.g., ",{"type":70,"tag":175,"props":3076,"children":3078},{"className":3077},[],[3079],{"type":75,"value":3080},"coding[0]",{"type":75,"value":3082},") instead of by system URI\n",{"type":70,"tag":2847,"props":3084,"children":3085},{},[3086],{"type":75,"value":2858},{"type":75,"value":3088}," Extract by system URI (e.g., filter for ",{"type":70,"tag":175,"props":3090,"children":3092},{"className":3091},[],[3093],{"type":75,"value":3094},"\"http:\u002F\u002Fsnomed.info\u002Fsct\"",{"type":75,"value":3096},") — a Condition may carry both SNOMED and ICD-10 codings\n",{"type":70,"tag":2847,"props":3098,"children":3099},{},[3100],{"type":75,"value":2865},{"type":75,"value":3102}," Array order is not guaranteed; position-based access returns the wrong code system unpredictably",{"type":70,"tag":100,"props":3104,"children":3105},{},[3106,3110,3112,3116,3118,3124,3126,3132,3134,3138],{"type":70,"tag":2847,"props":3107,"children":3108},{},[3109],{"type":75,"value":2851},{"type":75,"value":3111}," Processing only the first page of a FHIR Bundle without checking for pagination\n",{"type":70,"tag":2847,"props":3113,"children":3114},{},[3115],{"type":75,"value":2858},{"type":75,"value":3117}," Check ",{"type":70,"tag":175,"props":3119,"children":3121},{"className":3120},[],[3122],{"type":75,"value":3123},"bundle.link",{"type":75,"value":3125}," for ",{"type":70,"tag":175,"props":3127,"children":3129},{"className":3128},[],[3130],{"type":75,"value":3131},"relation: \"next\"",{"type":75,"value":3133}," and follow all pages until exhausted\n",{"type":70,"tag":2847,"props":3135,"children":3136},{},[3137],{"type":75,"value":2865},{"type":75,"value":3139}," FHIR servers return paginated Bundles — stopping at page one misses most of the data",{"type":70,"tag":100,"props":3141,"children":3142},{},[3143,3147,3149,3153,3155,3161,3163,3169,3170,3176,3177,3183,3184,3188],{"type":70,"tag":2847,"props":3144,"children":3145},{},[3146],{"type":75,"value":2851},{"type":75,"value":3148}," Assuming all dates are ISO 8601 format across HL7v2 and FHIR\n",{"type":70,"tag":2847,"props":3150,"children":3151},{},[3152],{"type":75,"value":2858},{"type":75,"value":3154}," Parse HL7v2 dates as ",{"type":70,"tag":175,"props":3156,"children":3158},{"className":3157},[],[3159],{"type":75,"value":3160},"YYYYMMDD[HHmmss]",{"type":75,"value":3162}," and FHIR dates with variable precision (",{"type":70,"tag":175,"props":3164,"children":3166},{"className":3165},[],[3167],{"type":75,"value":3168},"2024",{"type":75,"value":3008},{"type":70,"tag":175,"props":3171,"children":3173},{"className":3172},[],[3174],{"type":75,"value":3175},"2024-01",{"type":75,"value":3008},{"type":70,"tag":175,"props":3178,"children":3180},{"className":3179},[],[3181],{"type":75,"value":3182},"2024-01-15",{"type":75,"value":711},{"type":70,"tag":2847,"props":3185,"children":3186},{},[3187],{"type":75,"value":2865},{"type":75,"value":3189}," Format mismatches cause parse errors or silent data corruption",{"type":70,"tag":100,"props":3191,"children":3192},{},[3193,3197,3199,3203,3205,3211,3213,3219,3221,3225],{"type":70,"tag":2847,"props":3194,"children":3195},{},[3196],{"type":75,"value":2851},{"type":75,"value":3198}," Accepting coded values without validating the code system URI\n",{"type":70,"tag":2847,"props":3200,"children":3201},{},[3202],{"type":75,"value":2858},{"type":75,"value":3204}," Verify that the ",{"type":70,"tag":175,"props":3206,"children":3208},{"className":3207},[],[3209],{"type":75,"value":3210},"system",{"type":75,"value":3212}," field matches the expected URI (e.g., ",{"type":70,"tag":175,"props":3214,"children":3216},{"className":3215},[],[3217],{"type":75,"value":3218},"http:\u002F\u002Floinc.org",{"type":75,"value":3220}," for LOINC codes)\n",{"type":70,"tag":2847,"props":3222,"children":3223},{},[3224],{"type":75,"value":2865},{"type":75,"value":3226}," Codes without system URIs are ambiguous — a \"6690-2\" without system confirmation may not be LOINC",{"type":70,"tag":78,"props":3228,"children":3230},{"id":3229},"references",[3231],{"type":75,"value":3232},"References",{"type":70,"tag":96,"props":3234,"children":3235},{},[3236,3249,3260,3271,3282],{"type":70,"tag":100,"props":3237,"children":3238},{},[3239,3241],{"type":75,"value":3240},"python-hl7: ",{"type":70,"tag":3242,"props":3243,"children":3247},"a",{"href":3244,"rel":3245},"https:\u002F\u002Fpython-hl7.readthedocs.io\u002F",[3246],"nofollow",[3248],{"type":75,"value":3244},{"type":70,"tag":100,"props":3250,"children":3251},{},[3252,3254],{"type":75,"value":3253},"fhir.resources (Python): ",{"type":70,"tag":3242,"props":3255,"children":3258},{"href":3256,"rel":3257},"https:\u002F\u002Fpypi.org\u002Fproject\u002Ffhir.resources\u002F",[3246],[3259],{"type":75,"value":3256},{"type":70,"tag":100,"props":3261,"children":3262},{},[3263,3265],{"type":75,"value":3264},"FHIR R4 Specification: ",{"type":70,"tag":3242,"props":3266,"children":3269},{"href":3267,"rel":3268},"https:\u002F\u002Fhl7.org\u002Ffhir\u002FR4\u002F",[3246],[3270],{"type":75,"value":3267},{"type":70,"tag":100,"props":3272,"children":3273},{},[3274,3276],{"type":75,"value":3275},"LOINC: ",{"type":70,"tag":3242,"props":3277,"children":3280},{"href":3278,"rel":3279},"https:\u002F\u002Floinc.org\u002F",[3246],[3281],{"type":75,"value":3278},{"type":70,"tag":100,"props":3283,"children":3284},{},[3285,3287],{"type":75,"value":3286},"SNOMED CT: ",{"type":70,"tag":3242,"props":3288,"children":3291},{"href":3289,"rel":3290},"https:\u002F\u002Fwww.snomed.org\u002F",[3246],[3292],{"type":75,"value":3289},{"type":70,"tag":3294,"props":3295,"children":3296},"style",{},[3297],{"type":75,"value":3298},"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":3300,"total":3480},[3301,3322,3343,3353,3366,3379,3389,3399,3420,3435,3450,3465],{"slug":3302,"name":3302,"fn":3303,"description":3304,"org":3305,"tags":3306,"stars":3319,"repoUrl":3320,"updatedAt":3321},"agentcore-investigation","investigate Bedrock AgentCore runtime sessions","Investigate Bedrock AgentCore runtime sessions via CloudWatch Logs Insights — resolve session\u002Ftrace IDs, query OTEL spans, filter noise, build timelines. Use when debugging AgentCore agent sessions, tracing tool calls, or analyzing latency.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3307,3310,3313,3316],{"name":3308,"slug":3309,"type":16},"AWS","aws",{"name":3311,"slug":3312,"type":16},"Debugging","debugging",{"name":3314,"slug":3315,"type":16},"Logs","logs",{"name":3317,"slug":3318,"type":16},"Observability","observability",9427,"https:\u002F\u002Fgithub.com\u002Fawslabs\u002Fmcp","2026-07-12T08:37:22.601527",{"slug":3323,"name":3324,"fn":3325,"description":3326,"org":3327,"tags":3328,"stars":3319,"repoUrl":3320,"updatedAt":3342},"amazon-aurora-dsql","amazon aurora dsql","build applications with Aurora DSQL","Build with Aurora DSQL — manage schemas, execute queries, handle migrations, diagnose query plans, load data, and develop applications with a serverless, distributed SQL database. Covers IAM auth, multi-tenant patterns, MySQL-to-DSQL and PostgreSQL-to-DSQL schema conversion, FK replacement code generation, OCC retry patterns, ORM migration (Django\u002FHibernate\u002FRails), DDL operations, query plan explainability, SQL compatibility validation, and bulk data loading. Triggers on phrases like: DSQL, Aurora DSQL, create DSQL table, DSQL schema, migrate to DSQL, distributed SQL database, serverless PostgreSQL-compatible database, DSQL query plan, DSQL EXPLAIN ANALYZE, why is my DSQL query slow, DSQL foreign key, DSQL OCC retry, DSQL multi-region, load into DSQL, load CSV into DSQL, bulk load DSQL, aurora-dsql-loader.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3329,3332,3333,3336,3339],{"name":3330,"slug":3331,"type":16},"Aurora","aurora",{"name":3308,"slug":3309,"type":16},{"name":3334,"slug":3335,"type":16},"Database","database",{"name":3337,"slug":3338,"type":16},"Serverless","serverless",{"name":3340,"slug":3341,"type":16},"SQL","sql","2026-07-12T08:36:45.053393",{"slug":3344,"name":3345,"fn":3325,"description":3326,"org":3346,"tags":3347,"stars":3319,"repoUrl":3320,"updatedAt":3352},"aurora-dsql","aurora dsql",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3348,3349,3350,3351],{"name":3308,"slug":3309,"type":16},{"name":3334,"slug":3335,"type":16},{"name":3337,"slug":3338,"type":16},{"name":3340,"slug":3341,"type":16},"2026-07-12T08:36:42.694299",{"slug":3354,"name":3355,"fn":3325,"description":3326,"org":3356,"tags":3357,"stars":3319,"repoUrl":3320,"updatedAt":3365},"aws-dsql","aws dsql",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3358,3359,3360,3363,3364],{"name":3308,"slug":3309,"type":16},{"name":3334,"slug":3335,"type":16},{"name":3361,"slug":3362,"type":16},"Migration","migration",{"name":3337,"slug":3338,"type":16},{"name":3340,"slug":3341,"type":16},"2026-07-12T08:36:38.584057",{"slug":3367,"name":3368,"fn":3325,"description":3326,"org":3369,"tags":3370,"stars":3319,"repoUrl":3320,"updatedAt":3378},"distributed-postgres","distributed postgres",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3371,3372,3373,3376,3377],{"name":3308,"slug":3309,"type":16},{"name":3334,"slug":3335,"type":16},{"name":3374,"slug":3375,"type":16},"PostgreSQL","postgresql",{"name":3337,"slug":3338,"type":16},{"name":3340,"slug":3341,"type":16},"2026-07-12T08:36:46.530743",{"slug":3380,"name":3381,"fn":3325,"description":3326,"org":3382,"tags":3383,"stars":3319,"repoUrl":3320,"updatedAt":3388},"distributed-sql","distributed sql",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3384,3385,3386,3387],{"name":3308,"slug":3309,"type":16},{"name":3334,"slug":3335,"type":16},{"name":3337,"slug":3338,"type":16},{"name":3340,"slug":3341,"type":16},"2026-07-12T08:36:48.104182",{"slug":3390,"name":3390,"fn":3325,"description":3326,"org":3391,"tags":3392,"stars":3319,"repoUrl":3320,"updatedAt":3398},"dsql",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3393,3394,3395,3396,3397],{"name":3308,"slug":3309,"type":16},{"name":3334,"slug":3335,"type":16},{"name":3361,"slug":3362,"type":16},{"name":3337,"slug":3338,"type":16},{"name":3340,"slug":3341,"type":16},"2026-07-12T08:36:36.374512",{"slug":3400,"name":3400,"fn":3401,"description":3402,"org":3403,"tags":3404,"stars":3417,"repoUrl":3418,"updatedAt":3419},"cost-efficiency-analyzer","analyze cost efficiency and expenses","Analyzes cost structure, cost efficiency, and expense management from P&L data. Use when the user asks about costs, expenses, COGS, operating expenses, cost ratios, cost control, spending efficiency, margin compression from cost side, or wants to understand where money is going. Also use for \"are we spending too much\", \"cost breakdown\", \"expense analysis\", or \"how efficient are our operations\". NOT for revenue or top-line analysis.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3405,3408,3411,3414],{"name":3406,"slug":3407,"type":16},"Accounting","accounting",{"name":3409,"slug":3410,"type":16},"Analytics","analytics",{"name":3412,"slug":3413,"type":16},"Cost Optimization","cost-optimization",{"name":3415,"slug":3416,"type":16},"Finance","finance",3176,"https:\u002F\u002Fgithub.com\u002Fawslabs\u002Fagentcore-samples","2026-07-12T08:40:03.29555",{"slug":3421,"name":3421,"fn":3422,"description":3423,"org":3424,"tags":3425,"stars":3417,"repoUrl":3418,"updatedAt":3434},"executive-financial-briefing","generate executive financial briefings","Generates a concise executive-level financial briefing or summary suitable for a CEO, CFO, or board presentation. Use when the user asks for a summary, briefing, executive summary, board update, financial overview, financial health check, or \"how is the business doing\". Covers the full P&L picture in one page. Also use for \"give me the highlights\", \"what do I need to know\", or \"quick financial update\".",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3426,3427,3428,3431],{"name":3308,"slug":3309,"type":16},{"name":3415,"slug":3416,"type":16},{"name":3429,"slug":3430,"type":16},"Management","management",{"name":3432,"slug":3433,"type":16},"Reporting","reporting","2026-07-12T08:40:02.066471",{"slug":3436,"name":3436,"fn":3437,"description":3438,"org":3439,"tags":3440,"stars":3417,"repoUrl":3418,"updatedAt":3449},"multi-quarter-trend-analysis","analyze multi-quarter financial trends","Analyzes financial trends across multiple quarters by comparing P&L metrics over time. Use when the user wants to see trends, patterns, trajectories, or directional movement across 3 or more quarters. Also use for \"how are we trending\", \"show me the trend\", \"track performance over time\", \"quarter over quarter comparison across all quarters\", or any multi-period longitudinal analysis.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3441,3442,3443,3446],{"name":3409,"slug":3410,"type":16},{"name":3415,"slug":3416,"type":16},{"name":3444,"slug":3445,"type":16},"Financial Statements","financial-statements",{"name":3447,"slug":3448,"type":16},"Variance Analysis","variance-analysis","2026-07-12T08:40:00.79141",{"slug":3451,"name":3451,"fn":3452,"description":3453,"org":3454,"tags":3455,"stars":3417,"repoUrl":3418,"updatedAt":3464},"pdf","process and manipulate PDF documents","Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text\u002Ftables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting\u002Fdecrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3456,3459,3462],{"name":3457,"slug":3458,"type":16},"Automation","automation",{"name":3460,"slug":3461,"type":16},"Documents","documents",{"name":3463,"slug":3451,"type":16},"PDF","2026-07-12T08:41:44.135656",{"slug":3466,"name":3466,"fn":3467,"description":3468,"org":3469,"tags":3470,"stars":3417,"repoUrl":3418,"updatedAt":3479},"quarterly-kpi-calculator","calculate quarterly financial KPIs","Calculates quarterly financial KPIs from P&L data. P&L figures can be provided directly by the user or fetched from the financial data MCP server. Use when the user wants KPI calculations such as Gross Margin %, EBITDA Margin %, Operating Expense Ratio, or Revenue Growth % QoQ. Also use for quarterly performance review, P&L analysis, or interpreting financial ratios against benchmarks.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3471,3472,3475,3476],{"name":3406,"slug":3407,"type":16},{"name":3473,"slug":3474,"type":16},"Data Analysis","data-analysis",{"name":3415,"slug":3416,"type":16},{"name":3477,"slug":3478,"type":16},"KPI","kpi","2026-07-12T08:39:59.54971",150,{"items":3482,"total":2507},[3483,3500,3515,3529,3542,3555,3568],{"slug":3484,"name":3484,"fn":3485,"description":3486,"org":3487,"tags":3488,"stars":26,"repoUrl":27,"updatedAt":3499},"aws-genai-ml-architect","design AWS GenAI and ML architectures","Reasoning skill for designing AWS GenAI and ML architectures for healthcare and life sciences workloads. Use when the user asks to choose between SageMaker and Bedrock, design a RAG system over medical literature, architect clinical NLP or medical imaging inference, plan genomics or drug discovery pipelines on AWS, address HIPAA\u002FPHI compliance in ML systems, design MLOps for regulated clinical models, or optimize cost for HCLS ML workloads. Triggers include \"AWS architecture\", \"SageMaker vs Bedrock\", \"HIPAA ML\", \"clinical RAG\", \"medical imaging inference\", \"genomics on AWS\", \"PHI training\", \"MLOps healthcare\", \"Bedrock guardrails\", \"HealthLake\", \"HCLS cloud architecture\", \"BAA compliance\", \"SageMaker endpoint\", \"Bedrock knowledge base\", \"clinical NLP on AWS\", \"FDA SaMD on AWS\".",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3489,3492,3493,3494,3496],{"name":3490,"slug":3491,"type":16},"Architecture","architecture",{"name":3308,"slug":3309,"type":16},{"name":14,"slug":15,"type":16},{"name":3495,"slug":41,"type":16},"Life Sciences",{"name":3497,"slug":3498,"type":16},"LLM","llm","2026-07-12T08:38:07.975937",{"slug":3501,"name":3501,"fn":3502,"description":3503,"org":3504,"tags":3505,"stars":26,"repoUrl":27,"updatedAt":3514},"biomarker-discovery","guide biomarker discovery and validation","Reason about biomarker discovery and validation in HCLS — classifying biomarker intent, choosing feature-selection and cross-validation strategies, avoiding leakage, and planning external replication. Use when the user asks to discover, develop, or validate a biomarker; select features from high-dimensional omics or clinical data; design a validation study; choose evaluation metrics; justify sample size; combine multi-omics signals; or assess clinical utility. Triggers include \"discover a biomarker\", \"validate biomarker\", \"prognostic vs predictive\", \"feature selection\", \"LASSO vs elastic net\", \"nested cross-validation\", \"data leakage\", \"C-index\", \"time-dependent AUC\", \"decision curve analysis\", \"external validation cohort\", \"events per variable\", \"optimism-corrected\", \"multi-omics integration\", \"clinical utility of a biomarker\", \"is this biomarker ready\".",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3506,3507,3510,3511],{"name":3308,"slug":3309,"type":16},{"name":3508,"slug":3509,"type":16},"Bioinformatics","bioinformatics",{"name":3495,"slug":41,"type":16},{"name":3512,"slug":3513,"type":16},"Research","research","2026-07-12T08:37:49.295301",{"slug":3516,"name":3516,"fn":3517,"description":3518,"org":3519,"tags":3520,"stars":26,"repoUrl":27,"updatedAt":3528},"cdisc-compliance","reason about CDISC SDTM and ADaM implementation","Reason about CDISC SDTM and ADaM implementation for regulatory submissions. Use when the user asks about SDTM domain mapping, ADaM dataset design, controlled terminology versioning, define.xml completeness, FDA or PMDA submission requirements, query prioritization by clinical impact, SUPPQUAL usage, or CDISC compliance review. Triggers include \"SDTM mapping\", \"ADaM dataset\", \"CDISC compliance\", \"controlled terminology\", \"define.xml\", \"FDA submission data\", \"PMDA submission\", \"SDTM domain\", \"ADSL\", \"ADAE\", \"ADLB\", \"BDS structure\", \"SUPPQUAL\", \"RELREC\", \"value-level metadata\", \"CDISC CT\", \"regulatory submission data standards\", \"eCTD datasets\", \"SDTM 3.3\", \"ADaM 1.1\", \"query prioritization\", \"clinical data review\".\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3521,3524,3525],{"name":3522,"slug":3523,"type":16},"Clinical Trials","clinical-trials",{"name":3495,"slug":41,"type":16},{"name":3526,"slug":3527,"type":16},"Regulatory Compliance","regulatory-compliance","2026-07-12T08:37:33.35594",{"slug":3530,"name":3530,"fn":3531,"description":3532,"org":3533,"tags":3534,"stars":26,"repoUrl":27,"updatedAt":3541},"cell-type-annotation","annotate single-cell RNA-seq clusters","Generate code to assign cell type labels to single-cell RNA-seq clusters using CellTypist, SingleR, marker-based annotation, or reference label transfer (scANVI\u002Fingest). Triggers on requests to \"annotate cell types\", \"label clusters\", \"run CellTypist\", \"SingleR annotation\", \"marker gene dotplot\", \"transfer labels from reference atlas\", \"cell identity\", \"automated annotation\", \"reference mapping\", \"scANVI label transfer\", \"canonical markers\", \"immune cell types\", \"hierarchical annotation\", \"majority voting CellTypist\", \"over-clustering annotation\".",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3535,3536,3537,3538],{"name":3508,"slug":3509,"type":16},{"name":3473,"slug":3474,"type":16},{"name":3495,"slug":41,"type":16},{"name":3539,"slug":3540,"type":16},"RNA-seq","rna-seq","2026-07-12T08:38:05.443454",{"slug":3543,"name":3543,"fn":3544,"description":3545,"org":3546,"tags":3547,"stars":26,"repoUrl":27,"updatedAt":3554},"cheminformatics","calculate molecular properties with RDKit","Cheminformatics pipeline for small-molecule property calculation, filtering, and similarity analysis using RDKit. Use when the user asks to compute molecular descriptors, filter compounds by Lipinski or Veber rules, detect PAINS, calculate fingerprint similarity, run matched molecular pair analysis, generate ADMET descriptors, or process SMILES. Triggers include \"RDKit\", \"molecular descriptors\", \"Lipinski\", \"rule of five\", \"Veber\", \"PAINS\", \"pan-assay interference\", \"Morgan fingerprint\", \"Tanimoto\", \"fingerprint similarity\", \"matched molecular pair\", \"MMP\", \"mmpdb\", \"ADMET\", \"druglikeness\", \"SMILES\", \"cheminformatics\", \"compound filtering\", \"chemical similarity\".",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3548,3549,3552,3553],{"name":3508,"slug":3509,"type":16},{"name":3550,"slug":3551,"type":16},"Chemistry","chemistry",{"name":3473,"slug":3474,"type":16},{"name":3512,"slug":3513,"type":16},"2026-07-12T08:37:28.334619",{"slug":3556,"name":3556,"fn":3557,"description":3558,"org":3559,"tags":3560,"stars":26,"repoUrl":27,"updatedAt":3567},"claims-analytics","analyze and parse healthcare claims data","Pipeline skill for healthcare claims data parsing, analysis, and fraud detection. Use when the user asks to parse X12 837 or 835 claim files, manipulate ICD-10 CPT or HCPCS codes, detect billing pattern anomalies, profile providers against specialty peers, identify outlier billing behavior, validate NCCI edits programmatically, detect duplicate claims, run Benford's law analysis on charges, build claims data pipelines, or analyze E&M code distributions. Triggers include \"parse X12 837\", \"parse 835\", \"claims SQL\", \"ICD-10 manipulation\", \"CPT code analysis\", \"provider profiling\", \"billing outlier\", \"NCCI validation code\", \"duplicate claim detection\", \"Benford's law charges\", \"claims ETL\", \"E&M distribution analysis\", \"claims analytics pipeline\".\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3561,3562,3563,3566],{"name":3473,"slug":3474,"type":16},{"name":14,"slug":15,"type":16},{"name":3564,"slug":3565,"type":16},"Insurance","insurance",{"name":3495,"slug":41,"type":16},"2026-07-12T08:37:34.815088",{"slug":3569,"name":3569,"fn":3570,"description":3571,"org":3572,"tags":3573,"stars":26,"repoUrl":27,"updatedAt":3577},"claims-billing-rules","analyze healthcare claims billing rules","Reasoning skill for healthcare claims billing rules and fraud detection logic. Use when the user asks about CMS billing rules, place of service codes, global surgery periods, modifier usage (25 59 76 77), NCCI edit logic, column 1 column 2 code pairs, mutually exclusive procedures, modifier indicators, fraud waste and abuse patterns, E&M upcoding, unbundling, phantom billing, impossible day detection, coding error versus fraud distinction, FWA investigation methodology, or claims audit logic. Triggers include \"CMS billing rules\", \"NCCI edits\", \"modifier 25\", \"modifier 59\", \"global surgery period\", \"upcoding\", \"unbundling\", \"phantom billing\", \"impossible day\", \"FWA\", \"fraud waste abuse\", \"coding error vs fraud\", \"claims audit\", \"billing compliance\", \"E&M level selection\".\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3574,3575,3576],{"name":14,"slug":15,"type":16},{"name":3564,"slug":3565,"type":16},{"name":3526,"slug":3527,"type":16},"2026-07-12T08:38:28.210856"]