[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-aws-labs-pa-decision-automation":3,"mdc-th3h4v-key":53,"related-repo-aws-labs-pa-decision-automation":3603,"related-org-aws-labs-pa-decision-automation":3700},{"slug":4,"name":4,"fn":5,"description":6,"org":7,"tags":12,"stars":29,"repoUrl":30,"updatedAt":31,"license":32,"forks":33,"topics":34,"repo":48,"sourceUrl":51,"mdContent":52},"pa-decision-automation","automate prior authorization decision workflows","Pipeline skill for automating prior authorization decision workflows. Use when the user asks to parse PA request data (X12 278 or FHIR PAS bundles), extract clinical features for adjudication, build rules-based PA decision engines, train ML classifiers on historical PA decisions, analyze denial patterns, or generate SHAP explanations for PA outcomes. Triggers include \"parse 278\", \"FHIR PAS bundle\", \"PA automation\", \"adjudication logic\", \"PA classifier\", \"denial analysis\", \"prior auth ML\", \"SHAP explainability\", \"PA feature extraction\", \"rules engine PA\", \"PA decision pipeline\", \"authorization workflow\", \"clinical criteria extraction\", \"denial pattern mining\", \"PA turnaround time\".\n",{"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,26],{"name":14,"slug":15,"type":16},"Healthcare","healthcare","tag",{"name":18,"slug":19,"type":16},"Automation","automation",{"name":21,"slug":22,"type":16},"FHIR","fhir",{"name":24,"slug":25,"type":16},"Insurance","insurance",{"name":27,"slug":28,"type":16},"AWS","aws",4,"https:\u002F\u002Fgithub.com\u002Fawslabs\u002Fhcls-agent-skills","2026-07-12T08:38:10.555568",null,0,[35,36,37,38,39,40,41,42,43,44,45,46,47],"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":30,"stars":29,"forks":33,"topics":49,"description":50},[35,36,37,38,39,40,41,42,43,44,45,46,47],"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\u002Fpa-decision-automation","---\nname: pa-decision-automation\ndescription: >\n  Pipeline skill for automating prior authorization decision workflows. Use when the user asks to\n  parse PA request data (X12 278 or FHIR PAS bundles), extract clinical features for adjudication,\n  build rules-based PA decision engines, train ML classifiers on historical PA decisions, analyze\n  denial patterns, or generate SHAP explanations for PA outcomes. Triggers include \"parse 278\",\n  \"FHIR PAS bundle\", \"PA automation\", \"adjudication logic\", \"PA classifier\", \"denial analysis\",\n  \"prior auth ML\", \"SHAP explainability\", \"PA feature extraction\", \"rules engine PA\",\n  \"PA decision pipeline\", \"authorization workflow\", \"clinical criteria extraction\",\n  \"denial pattern mining\", \"PA turnaround time\".\nusage: Use when building or running prior authorization automation pipelines including parsing, classification, and denial analysis.\nversion: 1.0.0\nvalidated_against:\n  date: 2025-01-15\n  packages: {fhir-resources: \"R4\", scikit-learn: \"1.4\"}\ntags: [skill, category:pipeline, prior-authorization, automation, hcls]\n---\n\n# Prior Authorization Decision Automation Pipeline\n\n## Overview\n\nProvide deterministic code snippets and pipeline recipes for automating prior authorization\n(PA) workflows: parsing inbound requests, extracting clinical features, applying rules-based\nadjudication, training ML classifiers, and analyzing denial patterns.\n\n## Usage\n\n- Building or debugging X12 278 or FHIR PAS bundle parsers for PA intake\n- Training ML classifiers on historical PA decisions or generating SHAP explanations\n- Analyzing denial patterns to identify systemic documentation or policy gaps\n\n## Core Concepts\n\n### Automation Approach Selection\n\n| Condition | Approach | Rationale |\n|-----------|----------|-----------|\n| Clear-cut policy rules (step therapy, age, lab threshold) | Rules engine | Auditable, deterministic, regulatory-safe |\n| Ambiguous cases with soft criteria | ML classifier + SHAP | Handles nuance; SHAP provides explainability |\n| \u003C 1000 historical decisions available | Rules engine only | Insufficient data for reliable ML training |\n| Multi-payer deployment | Separate model per payer | Policies differ; cross-payer models fail |\n| Input is X12 278 (EDI) | `parse_278()` → segment iteration | Pipe-delimited, segment-based |\n| Input is FHIR PAS Bundle | `parse_pas_bundle()` → resource extraction | JSON, resource-typed entries |\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## 1. PA Request Parsing\n\n### 1.1 Parse X12 278 Transaction\n\nThe X12 278 Health Care Services Review transaction carries PA requests and responses.\n\n```python\n\"\"\"Parse X12 278 prior authorization request into structured dict.\"\"\"\nimport re\nfrom dataclasses import dataclass, field\nfrom typing import Optional\n\n\n@dataclass\nclass PA278Request:\n    member_id: str = \"\"\n    provider_npi: str = \"\"\n    diagnosis_codes: list[str] = field(default_factory=list)\n    procedure_codes: list[str] = field(default_factory=list)\n    service_date: str = \"\"\n    quantity: int = 0\n    place_of_service: str = \"\"\n\n\ndef parse_278(raw: str) -> PA278Request:\n    \"\"\"Parse X12 278 segments into a PA278Request.\"\"\"\n    req = PA278Request()\n    segments = raw.replace(\"\\n\", \"\").split(\"~\")\n    for seg in segments:\n        elements = seg.strip().split(\"*\")\n        seg_id = elements[0] if elements else \"\"\n        if seg_id == \"NM1\" and len(elements) > 9:\n            qualifier = elements[1]\n            if qualifier == \"IL\":  # insured\u002Fmember\n                req.member_id = elements[9] if len(elements) > 9 else \"\"\n            elif qualifier == \"1P\":  # provider\n                req.provider_npi = elements[9] if len(elements) > 9 else \"\"\n        elif seg_id == \"HI\":\n            for el in elements[1:]:\n                parts = el.split(\":\")\n                if len(parts) >= 2:\n                    code_qualifier, code = parts[0], parts[1]\n                    if code_qualifier in (\"ABK\", \"ABF\"):  # ICD-10\n                        req.diagnosis_codes.append(code)\n        elif seg_id == \"SV1\" and len(elements) > 1:\n            svc_parts = elements[1].split(\":\")\n            if len(svc_parts) >= 2:\n                req.procedure_codes.append(svc_parts[1])\n        elif seg_id == \"DTP\" and len(elements) > 3:\n            if elements[1] == \"472\":  # service date\n                req.service_date = elements[3]\n    return req\n```\n\n### 1.2 Parse FHIR Da Vinci PAS Bundle\n\n```python\n\"\"\"Extract PA fields from a FHIR Da Vinci PAS Bundle.\"\"\"\nimport json\nfrom dataclasses import dataclass, field\n\n\n@dataclass\nclass PASRequest:\n    member_id: str = \"\"\n    provider_npi: str = \"\"\n    diagnosis_codes: list[str] = field(default_factory=list)\n    service_codes: list[str] = field(default_factory=list)\n    supporting_info_types: list[str] = field(default_factory=list)\n\n\ndef parse_pas_bundle(bundle: dict) -> PASRequest:\n    \"\"\"Extract PA data from a FHIR PAS transaction Bundle.\"\"\"\n    req = PASRequest()\n    resources = {\n        entry[\"resource\"][\"resourceType\"]: entry[\"resource\"]\n        for entry in bundle.get(\"entry\", [])\n        if \"resource\" in entry\n    }\n    # Patient \u002F member\n    patient = resources.get(\"Patient\", {})\n    for ident in patient.get(\"identifier\", []):\n        if ident.get(\"type\", {}).get(\"coding\", [{}])[0].get(\"code\") == \"MB\":\n            req.member_id = ident.get(\"value\", \"\")\n            break\n    # Practitioner \u002F provider NPI\n    practitioner = resources.get(\"Practitioner\", {})\n    for ident in practitioner.get(\"identifier\", []):\n        if ident.get(\"system\", \"\").endswith(\"\u002Fnpi\"):\n            req.provider_npi = ident.get(\"value\", \"\")\n            break\n    # Claim resource — core of the PA request\n    claim = resources.get(\"Claim\", {})\n    for dx in claim.get(\"diagnosis\", []):\n        coding = dx.get(\"diagnosisCodeableConcept\", {}).get(\"coding\", [])\n        for c in coding:\n            req.diagnosis_codes.append(c.get(\"code\", \"\"))\n    for item in claim.get(\"item\", []):\n        svc_coding = item.get(\"productOrService\", {}).get(\"coding\", [])\n        for c in svc_coding:\n            req.service_codes.append(c.get(\"code\", \"\"))\n    for info in claim.get(\"supportingInfo\", []):\n        cat_coding = info.get(\"category\", {}).get(\"coding\", [])\n        for c in cat_coding:\n            req.supporting_info_types.append(c.get(\"code\", \"\"))\n    return req\n```\n\n## 2. Clinical Feature Extraction\n\n### 2.1 Feature Set for PA Adjudication\n\n| Feature | Source | Type | Description |\n|---------|--------|------|-------------|\n| `dx_specificity` | Diagnosis codes | int | ICD-10 code length (3=category, 4-7=specific) |\n| `drug_class` | Service code (NDC\u002FHCPCS) | categorical | Therapeutic class (e.g., biologic, opioid) |\n| `prior_treatment_count` | Claims history | int | Number of prior drugs tried in same class |\n| `step_therapy_complete` | Claims + formulary | bool | All required prior steps documented |\n| `days_since_last_treatment` | Claims history | int | Gap since last related treatment |\n| `lab_value_in_range` | Lab results | bool | Key lab (e.g., HbA1c) meets threshold |\n| `provider_specialty` | Provider data | categorical | Specialty of ordering provider |\n| `place_of_service` | Claim | categorical | Office, outpatient, inpatient, home |\n| `prior_pa_denials` | PA history | int | Count of prior denials for same service |\n| `documentation_score` | Supporting info | float | Completeness score (0-1) based on required docs |\n\n### 2.2 Feature Extraction Code\n\n```python\n\"\"\"Extract clinical features from parsed PA request + claims history.\"\"\"\nimport pandas as pd\nfrom datetime import datetime\n\n\ndef extract_features(\n    pa_request: dict,\n    claims_history: pd.DataFrame,\n    formulary: pd.DataFrame,\n    lab_results: pd.DataFrame,\n) -> dict:\n    \"\"\"Build feature vector for PA adjudication model.\n\n    Args:\n        pa_request: Parsed PA request (from parse_278 or parse_pas_bundle).\n        claims_history: Member's prior claims with columns:\n            [member_id, service_date, drug_class, ndc, diagnosis_code].\n        formulary: Formulary table with columns:\n            [ndc, tier, step_therapy_required, prior_drugs_required].\n        lab_results: Lab results with columns:\n            [member_id, test_code, result_value, result_date].\n    \"\"\"\n    member_id = pa_request.get(\"member_id\", \"\")\n    dx_codes = pa_request.get(\"diagnosis_codes\", [])\n    svc_codes = pa_request.get(\"service_codes\", [])\n\n    # Diagnosis specificity: max ICD-10 code length\n    dx_specificity = max((len(c.replace(\".\", \"\")) for c in dx_codes), default=3)\n\n    # Prior treatment count in same drug class\n    requested_drug = svc_codes[0] if svc_codes else \"\"\n    drug_info = formulary[formulary[\"ndc\"] == requested_drug]\n    drug_class = drug_info[\"drug_class\"].iloc[0] if len(drug_info) > 0 else \"unknown\"\n    member_claims = claims_history[claims_history[\"member_id\"] == member_id]\n    prior_treatments = member_claims[member_claims[\"drug_class\"] == drug_class]\n    prior_treatment_count = prior_treatments[\"ndc\"].nunique()\n\n    # Step therapy completion\n    required_steps = int(drug_info[\"prior_drugs_required\"].iloc[0]) if len(drug_info) > 0 else 0\n    step_therapy_complete = prior_treatment_count >= required_steps\n\n    # Days since last treatment in class\n    if len(prior_treatments) > 0:\n        last_date = pd.to_datetime(prior_treatments[\"service_date\"]).max()\n        days_since = (datetime.now() - last_date).days\n    else:\n        days_since = -1  # no prior treatment\n\n    # Lab value check (example: HbA1c for diabetes drugs)\n    member_labs = lab_results[lab_results[\"member_id\"] == member_id]\n    recent_lab = member_labs.sort_values(\"result_date\", ascending=False).head(1)\n    lab_in_range = bool(recent_lab[\"result_value\"].iloc[0] >= 7.0) if len(recent_lab) > 0 else False\n\n    # Documentation completeness score\n    supporting_info = pa_request.get(\"supporting_info_types\", [])\n    required_docs = {\"clinical-note\", \"lab-result\", \"treatment-history\", \"diagnosis\"}\n    doc_score = len(set(supporting_info) & required_docs) \u002F len(required_docs)\n\n    return {\n        \"dx_specificity\": dx_specificity,\n        \"drug_class\": drug_class,\n        \"prior_treatment_count\": prior_treatment_count,\n        \"step_therapy_complete\": step_therapy_complete,\n        \"days_since_last_treatment\": days_since,\n        \"lab_value_in_range\": lab_in_range,\n        \"documentation_score\": doc_score,\n    }\n```\n\n## 3. Rules-Based Adjudication Engine\n\n```python\n\"\"\"Rules-based PA adjudication engine.\"\"\"\nfrom dataclasses import dataclass\nfrom enum import Enum\n\n\nclass Decision(Enum):\n    APPROVE = \"approve\"\n    DENY = \"deny\"\n    PEND = \"pend\"\n\n\n@dataclass\nclass AdjudicationResult:\n    decision: Decision\n    reason_code: str\n    reason_text: str\n\n\ndef adjudicate(features: dict, policy: dict) -> AdjudicationResult:\n    \"\"\"Apply rules-based adjudication logic.\n\n    Args:\n        features: Feature dict from extract_features().\n        policy: Policy config with keys:\n            - require_step_therapy (bool)\n            - min_dx_specificity (int)\n            - min_documentation_score (float)\n            - require_lab_in_range (bool)\n    \"\"\"\n    # Rule 1: Documentation completeness\n    if features[\"documentation_score\"] \u003C policy.get(\"min_documentation_score\", 0.75):\n        return AdjudicationResult(\n            Decision.PEND, \"PEND-001\", \"Insufficient documentation; request additional clinical records\"\n        )\n    # Rule 2: Diagnosis specificity\n    if features[\"dx_specificity\"] \u003C policy.get(\"min_dx_specificity\", 4):\n        return AdjudicationResult(\n            Decision.DENY, \"DENY-DX\", \"Diagnosis code lacks required specificity\"\n        )\n    # Rule 3: Step therapy\n    if policy.get(\"require_step_therapy\", True) and not features[\"step_therapy_complete\"]:\n        return AdjudicationResult(\n            Decision.DENY, \"DENY-STEP\", \"Step therapy requirements not met\"\n        )\n    # Rule 4: Lab value threshold\n    if policy.get(\"require_lab_in_range\", False) and not features[\"lab_value_in_range\"]:\n        return AdjudicationResult(\n            Decision.DENY, \"DENY-LAB\", \"Required lab value not within criteria range\"\n        )\n    # All rules passed\n    return AdjudicationResult(Decision.APPROVE, \"APPROVE-001\", \"All clinical criteria met\")\n```\n\n## 4. ML Classifier for PA Decisions\n\n### 4.1 Training Pipeline\n\n```python\n\"\"\"Train a gradient-boosted classifier on historical PA decisions.\"\"\"\nimport pandas as pd\nfrom sklearn.model_selection import StratifiedKFold\nfrom sklearn.metrics import classification_report, roc_auc_score\nimport xgboost as xgb\n\n\ndef train_pa_classifier(\n    data: pd.DataFrame, target_col: str = \"decision\",\n    feature_cols: list[str] | None = None, n_folds: int = 5,\n) -> tuple[xgb.XGBClassifier, pd.DataFrame]:\n    \"\"\"Train XGBoost on historical PA decisions (1=approved, 0=denied).\"\"\"\n    if feature_cols is None:\n        feature_cols = [c for c in data.columns if c != target_col]\n    X, y = data[feature_cols].copy(), data[target_col].copy()\n    cat_cols = X.select_dtypes(include=[\"object\", \"category\"]).columns.tolist()\n    X[cat_cols] = X[cat_cols].astype(\"category\")\n    model = xgb.XGBClassifier(\n        n_estimators=300, max_depth=6, learning_rate=0.05,\n        subsample=0.8, colsample_bytree=0.8, enable_categorical=True,\n        eval_metric=\"logloss\", random_state=42,\n    )\n    cv_results = []\n    for fold, (ti, vi) in enumerate(StratifiedKFold(n_folds, shuffle=True, random_state=42).split(X, y)):\n        model.fit(X.iloc[ti], y.iloc[ti], eval_set=[(X.iloc[vi], y.iloc[vi])], verbose=False)\n        y_prob = model.predict_proba(X.iloc[vi])[:, 1]\n        cv_results.append({\"fold\": fold, \"auc\": roc_auc_score(y.iloc[vi], y_prob)})\n    model.fit(X, y, verbose=False)\n    return model, pd.DataFrame(cv_results)\n```\n\n### 4.2 SHAP Explainability\n\n```python\n\"\"\"Generate SHAP explanations for PA decisions.\"\"\"\nimport shap\n\n\ndef explain_pa_decision(model, X, instance_idx: int = 0) -> dict:\n    \"\"\"Generate SHAP values for a single PA decision.\"\"\"\n    explainer = shap.TreeExplainer(model)\n    shap_values = explainer.shap_values(X)\n    explanation = dict(sorted(\n        zip(X.columns, shap_values[instance_idx]),\n        key=lambda x: abs(x[1]), reverse=True,\n    ))\n    return {\n        \"base_value\": float(explainer.expected_value),\n        \"prediction\": float(model.predict_proba(X.iloc[[instance_idx]])[:, 1][0]),\n        \"feature_contributions\": explanation,\n    }\n```\n\n## 5. Denial Reason Analysis\n\n### 5.1 Denial Pattern Analysis\n\n```python\n\"\"\"Analyze PA denial patterns to identify systemic issues.\"\"\"\nimport pandas as pd\n\n\ndef analyze_denials(pa_decisions: pd.DataFrame, group_cols: list[str] | None = None) -> dict[str, pd.DataFrame]:\n    \"\"\"Analyze denial patterns across dimensions.\n\n    Args:\n        pa_decisions: DataFrame [pa_id, member_id, provider_npi, drug_class, denial_reason, decision, decision_date].\n        group_cols: Columns to group by. Defaults to [denial_reason, drug_class, provider_npi].\n    \"\"\"\n    denied = pa_decisions[pa_decisions[\"decision\"] == \"denied\"].copy()\n    if group_cols is None:\n        group_cols = [\"denial_reason\", \"drug_class\", \"provider_npi\"]\n    analyses = {}\n    for col in group_cols:\n        if col not in denied.columns:\n            continue\n        g = denied.groupby(col).agg(denial_count=(\"pa_id\", \"count\"), unique_members=(\"member_id\", \"nunique\")).sort_values(\"denial_count\", ascending=False).reset_index()\n        g[\"pct_of_denials\"] = (g[\"denial_count\"] \u002F len(denied) * 100).round(1)\n        analyses[col] = g\n    if \"denial_reason\" in denied.columns:\n        doc_gaps = denied[denied[\"denial_reason\"].str.contains(\"documentation|insufficient\", case=False, na=False)]\n        analyses[\"documentation_gaps\"] = doc_gaps.groupby(\"drug_class\").agg(gap_count=(\"pa_id\", \"count\")).sort_values(\"gap_count\", ascending=False).reset_index()\n    return analyses\n```\n\n### 5.2 Denial Reason Code Reference\n\n| Reason Code | Description | Remediation |\n|-------------|-------------|-------------|\n| DENY-STEP | Step therapy not completed | Document prior treatments with dates |\n| DENY-DX | Non-specific diagnosis | Use highest-specificity ICD-10 code |\n| DENY-LAB | Lab criteria not met | Resubmit with current lab results |\n| DENY-MN | Medical necessity not established | Submit letter of medical necessity |\n| DENY-EXP | Experimental\u002Finvestigational | Cite peer-reviewed evidence |\n| PEND-001 | Incomplete documentation | Submit clinical notes, labs, history |\n\n## 6. Parameter Reference\n\n### 6.1 XGBoost Hyperparameters for PA Classification\n\n| Parameter | Default | Range |\n|-----------|---------|-------|\n| `n_estimators` | 300 | 100–1000 |\n| `max_depth` | 6 | 3–10 |\n| `learning_rate` | 0.05 | 0.01–0.3 |\n| `subsample` | 0.8 | 0.5–1.0 |\n| `colsample_bytree` | 0.8 | 0.5–1.0 |\n| `scale_pos_weight` | 1.0 | Set to neg\u002Fpos ratio for imbalanced data |\n\n### 6.2 Documentation Completeness Scoring\n\n| Document Type | Weight | Required For |\n|---------------|--------|-------------|\n| Clinical notes | 0.30 | All PA requests |\n| Lab results | 0.25 | Drug PAs with lab criteria |\n| Treatment history | 0.25 | Step therapy drugs |\n| Diagnosis confirmation | 0.10 | All PA requests |\n| Specialist referral | 0.10 | Specialty drugs |\n\n## 7. Common Mistakes\n\n- **Wrong:** Training a PA classifier on imbalanced data without correction\n  **Right:** Set `scale_pos_weight` to the neg\u002Fpos ratio, or apply SMOTE to balance the training set\n  **Why:** PA datasets are often 70–80% approvals; without correction, the model learns to approve everything\n\n- **Wrong:** Including features derived from information not available at the time of the PA request\n  **Right:** Ensure all features use only data available before or at the moment of submission (claims history, not future outcomes)\n  **Why:** Leaking future data inflates model performance in training but fails completely in production\n\n- **Wrong:** Deploying a model trained on one payer's decisions to adjudicate another payer's requests\n  **Right:** Train and validate separate models per payer, or include payer identity as a feature with sufficient per-payer training data\n  **Why:** Each payer has independent clinical policies; a model trained on Payer A's criteria will make wrong decisions for Payer B\n\n- **Wrong:** Accepting SHAP explanations at face value without clinical validation\n  **Right:** Verify that top SHAP features align with known clinical criteria from the payer's published policy\n  **Why:** Spurious correlations in training data can produce plausible-looking but clinically meaningless explanations\n\n- **Wrong:** Hardcoding denial reason strings with free-text matching\n  **Right:** Use standardized reason codes (CARC\u002FRARC) and map them to structured enums\n  **Why:** Free-text matching is brittle — minor wording changes break the logic and cause silent failures\n\n- **Wrong:** Replacing the rules engine entirely with an ML classifier\n  **Right:** Use ML to augment deterministic policy rules; route clear-cut cases through rules and ambiguous cases through ML\n  **Why:** Auditable, explainable decisions require deterministic rules for regulatory compliance; ML alone is not audit-defensible\n",{"data":54,"body":67},{"name":4,"description":6,"usage":55,"version":56,"validated_against":57,"tags":62},"Use when building or running prior authorization automation pipelines including parsing, classification, and denial analysis.","1.0.0",{"date":58,"packages":59},"2025-01-15",{"fhir-resources":60,"scikit-learn":61},"R4","1.4",[63,64,65,19,66],"skill","category:pipeline","prior-authorization","hcls",{"type":68,"children":69},"root",[70,79,86,92,98,118,124,131,285,291,319,325,331,336,751,757,1149,1155,1161,1456,1462,2012,2018,2417,2423,2429,2665,2671,2810,2816,2822,3023,3029,3163,3169,3175,3332,3338,3451,3457,3597],{"type":71,"tag":72,"props":73,"children":75},"element","h1",{"id":74},"prior-authorization-decision-automation-pipeline",[76],{"type":77,"value":78},"text","Prior Authorization Decision Automation Pipeline",{"type":71,"tag":80,"props":81,"children":83},"h2",{"id":82},"overview",[84],{"type":77,"value":85},"Overview",{"type":71,"tag":87,"props":88,"children":89},"p",{},[90],{"type":77,"value":91},"Provide deterministic code snippets and pipeline recipes for automating prior authorization\n(PA) workflows: parsing inbound requests, extracting clinical features, applying rules-based\nadjudication, training ML classifiers, and analyzing denial patterns.",{"type":71,"tag":80,"props":93,"children":95},{"id":94},"usage",[96],{"type":77,"value":97},"Usage",{"type":71,"tag":99,"props":100,"children":101},"ul",{},[102,108,113],{"type":71,"tag":103,"props":104,"children":105},"li",{},[106],{"type":77,"value":107},"Building or debugging X12 278 or FHIR PAS bundle parsers for PA intake",{"type":71,"tag":103,"props":109,"children":110},{},[111],{"type":77,"value":112},"Training ML classifiers on historical PA decisions or generating SHAP explanations",{"type":71,"tag":103,"props":114,"children":115},{},[116],{"type":77,"value":117},"Analyzing denial patterns to identify systemic documentation or policy gaps",{"type":71,"tag":80,"props":119,"children":121},{"id":120},"core-concepts",[122],{"type":77,"value":123},"Core Concepts",{"type":71,"tag":125,"props":126,"children":128},"h3",{"id":127},"automation-approach-selection",[129],{"type":77,"value":130},"Automation Approach Selection",{"type":71,"tag":132,"props":133,"children":134},"table",{},[135,159],{"type":71,"tag":136,"props":137,"children":138},"thead",{},[139],{"type":71,"tag":140,"props":141,"children":142},"tr",{},[143,149,154],{"type":71,"tag":144,"props":145,"children":146},"th",{},[147],{"type":77,"value":148},"Condition",{"type":71,"tag":144,"props":150,"children":151},{},[152],{"type":77,"value":153},"Approach",{"type":71,"tag":144,"props":155,"children":156},{},[157],{"type":77,"value":158},"Rationale",{"type":71,"tag":160,"props":161,"children":162},"tbody",{},[163,182,200,218,236,261],{"type":71,"tag":140,"props":164,"children":165},{},[166,172,177],{"type":71,"tag":167,"props":168,"children":169},"td",{},[170],{"type":77,"value":171},"Clear-cut policy rules (step therapy, age, lab threshold)",{"type":71,"tag":167,"props":173,"children":174},{},[175],{"type":77,"value":176},"Rules engine",{"type":71,"tag":167,"props":178,"children":179},{},[180],{"type":77,"value":181},"Auditable, deterministic, regulatory-safe",{"type":71,"tag":140,"props":183,"children":184},{},[185,190,195],{"type":71,"tag":167,"props":186,"children":187},{},[188],{"type":77,"value":189},"Ambiguous cases with soft criteria",{"type":71,"tag":167,"props":191,"children":192},{},[193],{"type":77,"value":194},"ML classifier + SHAP",{"type":71,"tag":167,"props":196,"children":197},{},[198],{"type":77,"value":199},"Handles nuance; SHAP provides explainability",{"type":71,"tag":140,"props":201,"children":202},{},[203,208,213],{"type":71,"tag":167,"props":204,"children":205},{},[206],{"type":77,"value":207},"\u003C 1000 historical decisions available",{"type":71,"tag":167,"props":209,"children":210},{},[211],{"type":77,"value":212},"Rules engine only",{"type":71,"tag":167,"props":214,"children":215},{},[216],{"type":77,"value":217},"Insufficient data for reliable ML training",{"type":71,"tag":140,"props":219,"children":220},{},[221,226,231],{"type":71,"tag":167,"props":222,"children":223},{},[224],{"type":77,"value":225},"Multi-payer deployment",{"type":71,"tag":167,"props":227,"children":228},{},[229],{"type":77,"value":230},"Separate model per payer",{"type":71,"tag":167,"props":232,"children":233},{},[234],{"type":77,"value":235},"Policies differ; cross-payer models fail",{"type":71,"tag":140,"props":237,"children":238},{},[239,244,256],{"type":71,"tag":167,"props":240,"children":241},{},[242],{"type":77,"value":243},"Input is X12 278 (EDI)",{"type":71,"tag":167,"props":245,"children":246},{},[247,254],{"type":71,"tag":248,"props":249,"children":251},"code",{"className":250},[],[252],{"type":77,"value":253},"parse_278()",{"type":77,"value":255}," → segment iteration",{"type":71,"tag":167,"props":257,"children":258},{},[259],{"type":77,"value":260},"Pipe-delimited, segment-based",{"type":71,"tag":140,"props":262,"children":263},{},[264,269,280],{"type":71,"tag":167,"props":265,"children":266},{},[267],{"type":77,"value":268},"Input is FHIR PAS Bundle",{"type":71,"tag":167,"props":270,"children":271},{},[272,278],{"type":71,"tag":248,"props":273,"children":275},{"className":274},[],[276],{"type":77,"value":277},"parse_pas_bundle()",{"type":77,"value":279}," → resource extraction",{"type":71,"tag":167,"props":281,"children":282},{},[283],{"type":77,"value":284},"JSON, resource-typed entries",{"type":71,"tag":80,"props":286,"children":288},{"id":287},"response-format",[289],{"type":77,"value":290},"Response Format",{"type":71,"tag":99,"props":292,"children":293},{},[294,299,304,309,314],{"type":71,"tag":103,"props":295,"children":296},{},[297],{"type":77,"value":298},"Lead with the command or code the user needs — explain after",{"type":71,"tag":103,"props":300,"children":301},{},[302],{"type":77,"value":303},"Structure as: confirm inputs → working code → key parameters explained → gotchas",{"type":71,"tag":103,"props":305,"children":306},{},[307],{"type":77,"value":308},"One complete working example per task; do not show every alternative",{"type":71,"tag":103,"props":310,"children":311},{},[312],{"type":77,"value":313},"Keep code comments minimal and functional (what, not why-it-exists)",{"type":71,"tag":103,"props":315,"children":316},{},[317],{"type":77,"value":318},"Target: 50-100 lines of code with brief surrounding explanation",{"type":71,"tag":80,"props":320,"children":322},{"id":321},"_1-pa-request-parsing",[323],{"type":77,"value":324},"1. PA Request Parsing",{"type":71,"tag":125,"props":326,"children":328},{"id":327},"_11-parse-x12-278-transaction",[329],{"type":77,"value":330},"1.1 Parse X12 278 Transaction",{"type":71,"tag":87,"props":332,"children":333},{},[334],{"type":77,"value":335},"The X12 278 Health Care Services Review transaction carries PA requests and responses.",{"type":71,"tag":337,"props":338,"children":343},"pre",{"className":339,"code":340,"language":341,"meta":342,"style":342},"language-python shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\"\"\"Parse X12 278 prior authorization request into structured dict.\"\"\"\nimport re\nfrom dataclasses import dataclass, field\nfrom typing import Optional\n\n\n@dataclass\nclass PA278Request:\n    member_id: str = \"\"\n    provider_npi: str = \"\"\n    diagnosis_codes: list[str] = field(default_factory=list)\n    procedure_codes: list[str] = field(default_factory=list)\n    service_date: str = \"\"\n    quantity: int = 0\n    place_of_service: str = \"\"\n\n\ndef parse_278(raw: str) -> PA278Request:\n    \"\"\"Parse X12 278 segments into a PA278Request.\"\"\"\n    req = PA278Request()\n    segments = raw.replace(\"\\n\", \"\").split(\"~\")\n    for seg in segments:\n        elements = seg.strip().split(\"*\")\n        seg_id = elements[0] if elements else \"\"\n        if seg_id == \"NM1\" and len(elements) > 9:\n            qualifier = elements[1]\n            if qualifier == \"IL\":  # insured\u002Fmember\n                req.member_id = elements[9] if len(elements) > 9 else \"\"\n            elif qualifier == \"1P\":  # provider\n                req.provider_npi = elements[9] if len(elements) > 9 else \"\"\n        elif seg_id == \"HI\":\n            for el in elements[1:]:\n                parts = el.split(\":\")\n                if len(parts) >= 2:\n                    code_qualifier, code = parts[0], parts[1]\n                    if code_qualifier in (\"ABK\", \"ABF\"):  # ICD-10\n                        req.diagnosis_codes.append(code)\n        elif seg_id == \"SV1\" and len(elements) > 1:\n            svc_parts = elements[1].split(\":\")\n            if len(svc_parts) >= 2:\n                req.procedure_codes.append(svc_parts[1])\n        elif seg_id == \"DTP\" and len(elements) > 3:\n            if elements[1] == \"472\":  # service date\n                req.service_date = elements[3]\n    return req\n","python","",[344],{"type":71,"tag":248,"props":345,"children":346},{"__ignoreMap":342},[347,358,367,376,384,394,402,411,420,429,438,447,456,465,474,483,491,499,508,517,526,535,544,553,562,571,580,589,598,607,616,625,634,643,652,661,670,679,688,697,706,715,724,733,742],{"type":71,"tag":348,"props":349,"children":352},"span",{"class":350,"line":351},"line",1,[353],{"type":71,"tag":348,"props":354,"children":355},{},[356],{"type":77,"value":357},"\"\"\"Parse X12 278 prior authorization request into structured dict.\"\"\"\n",{"type":71,"tag":348,"props":359,"children":361},{"class":350,"line":360},2,[362],{"type":71,"tag":348,"props":363,"children":364},{},[365],{"type":77,"value":366},"import re\n",{"type":71,"tag":348,"props":368,"children":370},{"class":350,"line":369},3,[371],{"type":71,"tag":348,"props":372,"children":373},{},[374],{"type":77,"value":375},"from dataclasses import dataclass, field\n",{"type":71,"tag":348,"props":377,"children":378},{"class":350,"line":29},[379],{"type":71,"tag":348,"props":380,"children":381},{},[382],{"type":77,"value":383},"from typing import Optional\n",{"type":71,"tag":348,"props":385,"children":387},{"class":350,"line":386},5,[388],{"type":71,"tag":348,"props":389,"children":391},{"emptyLinePlaceholder":390},true,[392],{"type":77,"value":393},"\n",{"type":71,"tag":348,"props":395,"children":397},{"class":350,"line":396},6,[398],{"type":71,"tag":348,"props":399,"children":400},{"emptyLinePlaceholder":390},[401],{"type":77,"value":393},{"type":71,"tag":348,"props":403,"children":405},{"class":350,"line":404},7,[406],{"type":71,"tag":348,"props":407,"children":408},{},[409],{"type":77,"value":410},"@dataclass\n",{"type":71,"tag":348,"props":412,"children":414},{"class":350,"line":413},8,[415],{"type":71,"tag":348,"props":416,"children":417},{},[418],{"type":77,"value":419},"class PA278Request:\n",{"type":71,"tag":348,"props":421,"children":423},{"class":350,"line":422},9,[424],{"type":71,"tag":348,"props":425,"children":426},{},[427],{"type":77,"value":428},"    member_id: str = \"\"\n",{"type":71,"tag":348,"props":430,"children":432},{"class":350,"line":431},10,[433],{"type":71,"tag":348,"props":434,"children":435},{},[436],{"type":77,"value":437},"    provider_npi: str = \"\"\n",{"type":71,"tag":348,"props":439,"children":441},{"class":350,"line":440},11,[442],{"type":71,"tag":348,"props":443,"children":444},{},[445],{"type":77,"value":446},"    diagnosis_codes: list[str] = field(default_factory=list)\n",{"type":71,"tag":348,"props":448,"children":450},{"class":350,"line":449},12,[451],{"type":71,"tag":348,"props":452,"children":453},{},[454],{"type":77,"value":455},"    procedure_codes: list[str] = field(default_factory=list)\n",{"type":71,"tag":348,"props":457,"children":459},{"class":350,"line":458},13,[460],{"type":71,"tag":348,"props":461,"children":462},{},[463],{"type":77,"value":464},"    service_date: str = \"\"\n",{"type":71,"tag":348,"props":466,"children":468},{"class":350,"line":467},14,[469],{"type":71,"tag":348,"props":470,"children":471},{},[472],{"type":77,"value":473},"    quantity: int = 0\n",{"type":71,"tag":348,"props":475,"children":477},{"class":350,"line":476},15,[478],{"type":71,"tag":348,"props":479,"children":480},{},[481],{"type":77,"value":482},"    place_of_service: str = \"\"\n",{"type":71,"tag":348,"props":484,"children":486},{"class":350,"line":485},16,[487],{"type":71,"tag":348,"props":488,"children":489},{"emptyLinePlaceholder":390},[490],{"type":77,"value":393},{"type":71,"tag":348,"props":492,"children":494},{"class":350,"line":493},17,[495],{"type":71,"tag":348,"props":496,"children":497},{"emptyLinePlaceholder":390},[498],{"type":77,"value":393},{"type":71,"tag":348,"props":500,"children":502},{"class":350,"line":501},18,[503],{"type":71,"tag":348,"props":504,"children":505},{},[506],{"type":77,"value":507},"def parse_278(raw: str) -> PA278Request:\n",{"type":71,"tag":348,"props":509,"children":511},{"class":350,"line":510},19,[512],{"type":71,"tag":348,"props":513,"children":514},{},[515],{"type":77,"value":516},"    \"\"\"Parse X12 278 segments into a PA278Request.\"\"\"\n",{"type":71,"tag":348,"props":518,"children":520},{"class":350,"line":519},20,[521],{"type":71,"tag":348,"props":522,"children":523},{},[524],{"type":77,"value":525},"    req = PA278Request()\n",{"type":71,"tag":348,"props":527,"children":529},{"class":350,"line":528},21,[530],{"type":71,"tag":348,"props":531,"children":532},{},[533],{"type":77,"value":534},"    segments = raw.replace(\"\\n\", \"\").split(\"~\")\n",{"type":71,"tag":348,"props":536,"children":538},{"class":350,"line":537},22,[539],{"type":71,"tag":348,"props":540,"children":541},{},[542],{"type":77,"value":543},"    for seg in segments:\n",{"type":71,"tag":348,"props":545,"children":547},{"class":350,"line":546},23,[548],{"type":71,"tag":348,"props":549,"children":550},{},[551],{"type":77,"value":552},"        elements = seg.strip().split(\"*\")\n",{"type":71,"tag":348,"props":554,"children":556},{"class":350,"line":555},24,[557],{"type":71,"tag":348,"props":558,"children":559},{},[560],{"type":77,"value":561},"        seg_id = elements[0] if elements else \"\"\n",{"type":71,"tag":348,"props":563,"children":565},{"class":350,"line":564},25,[566],{"type":71,"tag":348,"props":567,"children":568},{},[569],{"type":77,"value":570},"        if seg_id == \"NM1\" and len(elements) > 9:\n",{"type":71,"tag":348,"props":572,"children":574},{"class":350,"line":573},26,[575],{"type":71,"tag":348,"props":576,"children":577},{},[578],{"type":77,"value":579},"            qualifier = elements[1]\n",{"type":71,"tag":348,"props":581,"children":583},{"class":350,"line":582},27,[584],{"type":71,"tag":348,"props":585,"children":586},{},[587],{"type":77,"value":588},"            if qualifier == \"IL\":  # insured\u002Fmember\n",{"type":71,"tag":348,"props":590,"children":592},{"class":350,"line":591},28,[593],{"type":71,"tag":348,"props":594,"children":595},{},[596],{"type":77,"value":597},"                req.member_id = elements[9] if len(elements) > 9 else \"\"\n",{"type":71,"tag":348,"props":599,"children":601},{"class":350,"line":600},29,[602],{"type":71,"tag":348,"props":603,"children":604},{},[605],{"type":77,"value":606},"            elif qualifier == \"1P\":  # provider\n",{"type":71,"tag":348,"props":608,"children":610},{"class":350,"line":609},30,[611],{"type":71,"tag":348,"props":612,"children":613},{},[614],{"type":77,"value":615},"                req.provider_npi = elements[9] if len(elements) > 9 else \"\"\n",{"type":71,"tag":348,"props":617,"children":619},{"class":350,"line":618},31,[620],{"type":71,"tag":348,"props":621,"children":622},{},[623],{"type":77,"value":624},"        elif seg_id == \"HI\":\n",{"type":71,"tag":348,"props":626,"children":628},{"class":350,"line":627},32,[629],{"type":71,"tag":348,"props":630,"children":631},{},[632],{"type":77,"value":633},"            for el in elements[1:]:\n",{"type":71,"tag":348,"props":635,"children":637},{"class":350,"line":636},33,[638],{"type":71,"tag":348,"props":639,"children":640},{},[641],{"type":77,"value":642},"                parts = el.split(\":\")\n",{"type":71,"tag":348,"props":644,"children":646},{"class":350,"line":645},34,[647],{"type":71,"tag":348,"props":648,"children":649},{},[650],{"type":77,"value":651},"                if len(parts) >= 2:\n",{"type":71,"tag":348,"props":653,"children":655},{"class":350,"line":654},35,[656],{"type":71,"tag":348,"props":657,"children":658},{},[659],{"type":77,"value":660},"                    code_qualifier, code = parts[0], parts[1]\n",{"type":71,"tag":348,"props":662,"children":664},{"class":350,"line":663},36,[665],{"type":71,"tag":348,"props":666,"children":667},{},[668],{"type":77,"value":669},"                    if code_qualifier in (\"ABK\", \"ABF\"):  # ICD-10\n",{"type":71,"tag":348,"props":671,"children":673},{"class":350,"line":672},37,[674],{"type":71,"tag":348,"props":675,"children":676},{},[677],{"type":77,"value":678},"                        req.diagnosis_codes.append(code)\n",{"type":71,"tag":348,"props":680,"children":682},{"class":350,"line":681},38,[683],{"type":71,"tag":348,"props":684,"children":685},{},[686],{"type":77,"value":687},"        elif seg_id == \"SV1\" and len(elements) > 1:\n",{"type":71,"tag":348,"props":689,"children":691},{"class":350,"line":690},39,[692],{"type":71,"tag":348,"props":693,"children":694},{},[695],{"type":77,"value":696},"            svc_parts = elements[1].split(\":\")\n",{"type":71,"tag":348,"props":698,"children":700},{"class":350,"line":699},40,[701],{"type":71,"tag":348,"props":702,"children":703},{},[704],{"type":77,"value":705},"            if len(svc_parts) >= 2:\n",{"type":71,"tag":348,"props":707,"children":709},{"class":350,"line":708},41,[710],{"type":71,"tag":348,"props":711,"children":712},{},[713],{"type":77,"value":714},"                req.procedure_codes.append(svc_parts[1])\n",{"type":71,"tag":348,"props":716,"children":718},{"class":350,"line":717},42,[719],{"type":71,"tag":348,"props":720,"children":721},{},[722],{"type":77,"value":723},"        elif seg_id == \"DTP\" and len(elements) > 3:\n",{"type":71,"tag":348,"props":725,"children":727},{"class":350,"line":726},43,[728],{"type":71,"tag":348,"props":729,"children":730},{},[731],{"type":77,"value":732},"            if elements[1] == \"472\":  # service date\n",{"type":71,"tag":348,"props":734,"children":736},{"class":350,"line":735},44,[737],{"type":71,"tag":348,"props":738,"children":739},{},[740],{"type":77,"value":741},"                req.service_date = elements[3]\n",{"type":71,"tag":348,"props":743,"children":745},{"class":350,"line":744},45,[746],{"type":71,"tag":348,"props":747,"children":748},{},[749],{"type":77,"value":750},"    return req\n",{"type":71,"tag":125,"props":752,"children":754},{"id":753},"_12-parse-fhir-da-vinci-pas-bundle",[755],{"type":77,"value":756},"1.2 Parse FHIR Da Vinci PAS Bundle",{"type":71,"tag":337,"props":758,"children":760},{"className":339,"code":759,"language":341,"meta":342,"style":342},"\"\"\"Extract PA fields from a FHIR Da Vinci PAS Bundle.\"\"\"\nimport json\nfrom dataclasses import dataclass, field\n\n\n@dataclass\nclass PASRequest:\n    member_id: str = \"\"\n    provider_npi: str = \"\"\n    diagnosis_codes: list[str] = field(default_factory=list)\n    service_codes: list[str] = field(default_factory=list)\n    supporting_info_types: list[str] = field(default_factory=list)\n\n\ndef parse_pas_bundle(bundle: dict) -> PASRequest:\n    \"\"\"Extract PA data from a FHIR PAS transaction Bundle.\"\"\"\n    req = PASRequest()\n    resources = {\n        entry[\"resource\"][\"resourceType\"]: entry[\"resource\"]\n        for entry in bundle.get(\"entry\", [])\n        if \"resource\" in entry\n    }\n    # Patient \u002F member\n    patient = resources.get(\"Patient\", {})\n    for ident in patient.get(\"identifier\", []):\n        if ident.get(\"type\", {}).get(\"coding\", [{}])[0].get(\"code\") == \"MB\":\n            req.member_id = ident.get(\"value\", \"\")\n            break\n    # Practitioner \u002F provider NPI\n    practitioner = resources.get(\"Practitioner\", {})\n    for ident in practitioner.get(\"identifier\", []):\n        if ident.get(\"system\", \"\").endswith(\"\u002Fnpi\"):\n            req.provider_npi = ident.get(\"value\", \"\")\n            break\n    # Claim resource — core of the PA request\n    claim = resources.get(\"Claim\", {})\n    for dx in claim.get(\"diagnosis\", []):\n        coding = dx.get(\"diagnosisCodeableConcept\", {}).get(\"coding\", [])\n        for c in coding:\n            req.diagnosis_codes.append(c.get(\"code\", \"\"))\n    for item in claim.get(\"item\", []):\n        svc_coding = item.get(\"productOrService\", {}).get(\"coding\", [])\n        for c in svc_coding:\n            req.service_codes.append(c.get(\"code\", \"\"))\n    for info in claim.get(\"supportingInfo\", []):\n        cat_coding = info.get(\"category\", {}).get(\"coding\", [])\n        for c in cat_coding:\n            req.supporting_info_types.append(c.get(\"code\", \"\"))\n    return req\n",[761],{"type":71,"tag":248,"props":762,"children":763},{"__ignoreMap":342},[764,772,780,787,794,801,808,816,823,830,837,845,853,860,867,875,883,891,899,907,915,923,931,939,947,955,963,971,979,987,995,1003,1011,1019,1026,1034,1042,1050,1058,1066,1074,1082,1090,1098,1106,1114,1123,1132,1141],{"type":71,"tag":348,"props":765,"children":766},{"class":350,"line":351},[767],{"type":71,"tag":348,"props":768,"children":769},{},[770],{"type":77,"value":771},"\"\"\"Extract PA fields from a FHIR Da Vinci PAS Bundle.\"\"\"\n",{"type":71,"tag":348,"props":773,"children":774},{"class":350,"line":360},[775],{"type":71,"tag":348,"props":776,"children":777},{},[778],{"type":77,"value":779},"import json\n",{"type":71,"tag":348,"props":781,"children":782},{"class":350,"line":369},[783],{"type":71,"tag":348,"props":784,"children":785},{},[786],{"type":77,"value":375},{"type":71,"tag":348,"props":788,"children":789},{"class":350,"line":29},[790],{"type":71,"tag":348,"props":791,"children":792},{"emptyLinePlaceholder":390},[793],{"type":77,"value":393},{"type":71,"tag":348,"props":795,"children":796},{"class":350,"line":386},[797],{"type":71,"tag":348,"props":798,"children":799},{"emptyLinePlaceholder":390},[800],{"type":77,"value":393},{"type":71,"tag":348,"props":802,"children":803},{"class":350,"line":396},[804],{"type":71,"tag":348,"props":805,"children":806},{},[807],{"type":77,"value":410},{"type":71,"tag":348,"props":809,"children":810},{"class":350,"line":404},[811],{"type":71,"tag":348,"props":812,"children":813},{},[814],{"type":77,"value":815},"class PASRequest:\n",{"type":71,"tag":348,"props":817,"children":818},{"class":350,"line":413},[819],{"type":71,"tag":348,"props":820,"children":821},{},[822],{"type":77,"value":428},{"type":71,"tag":348,"props":824,"children":825},{"class":350,"line":422},[826],{"type":71,"tag":348,"props":827,"children":828},{},[829],{"type":77,"value":437},{"type":71,"tag":348,"props":831,"children":832},{"class":350,"line":431},[833],{"type":71,"tag":348,"props":834,"children":835},{},[836],{"type":77,"value":446},{"type":71,"tag":348,"props":838,"children":839},{"class":350,"line":440},[840],{"type":71,"tag":348,"props":841,"children":842},{},[843],{"type":77,"value":844},"    service_codes: list[str] = field(default_factory=list)\n",{"type":71,"tag":348,"props":846,"children":847},{"class":350,"line":449},[848],{"type":71,"tag":348,"props":849,"children":850},{},[851],{"type":77,"value":852},"    supporting_info_types: list[str] = field(default_factory=list)\n",{"type":71,"tag":348,"props":854,"children":855},{"class":350,"line":458},[856],{"type":71,"tag":348,"props":857,"children":858},{"emptyLinePlaceholder":390},[859],{"type":77,"value":393},{"type":71,"tag":348,"props":861,"children":862},{"class":350,"line":467},[863],{"type":71,"tag":348,"props":864,"children":865},{"emptyLinePlaceholder":390},[866],{"type":77,"value":393},{"type":71,"tag":348,"props":868,"children":869},{"class":350,"line":476},[870],{"type":71,"tag":348,"props":871,"children":872},{},[873],{"type":77,"value":874},"def parse_pas_bundle(bundle: dict) -> PASRequest:\n",{"type":71,"tag":348,"props":876,"children":877},{"class":350,"line":485},[878],{"type":71,"tag":348,"props":879,"children":880},{},[881],{"type":77,"value":882},"    \"\"\"Extract PA data from a FHIR PAS transaction Bundle.\"\"\"\n",{"type":71,"tag":348,"props":884,"children":885},{"class":350,"line":493},[886],{"type":71,"tag":348,"props":887,"children":888},{},[889],{"type":77,"value":890},"    req = PASRequest()\n",{"type":71,"tag":348,"props":892,"children":893},{"class":350,"line":501},[894],{"type":71,"tag":348,"props":895,"children":896},{},[897],{"type":77,"value":898},"    resources = {\n",{"type":71,"tag":348,"props":900,"children":901},{"class":350,"line":510},[902],{"type":71,"tag":348,"props":903,"children":904},{},[905],{"type":77,"value":906},"        entry[\"resource\"][\"resourceType\"]: entry[\"resource\"]\n",{"type":71,"tag":348,"props":908,"children":909},{"class":350,"line":519},[910],{"type":71,"tag":348,"props":911,"children":912},{},[913],{"type":77,"value":914},"        for entry in bundle.get(\"entry\", [])\n",{"type":71,"tag":348,"props":916,"children":917},{"class":350,"line":528},[918],{"type":71,"tag":348,"props":919,"children":920},{},[921],{"type":77,"value":922},"        if \"resource\" in entry\n",{"type":71,"tag":348,"props":924,"children":925},{"class":350,"line":537},[926],{"type":71,"tag":348,"props":927,"children":928},{},[929],{"type":77,"value":930},"    }\n",{"type":71,"tag":348,"props":932,"children":933},{"class":350,"line":546},[934],{"type":71,"tag":348,"props":935,"children":936},{},[937],{"type":77,"value":938},"    # Patient \u002F member\n",{"type":71,"tag":348,"props":940,"children":941},{"class":350,"line":555},[942],{"type":71,"tag":348,"props":943,"children":944},{},[945],{"type":77,"value":946},"    patient = resources.get(\"Patient\", {})\n",{"type":71,"tag":348,"props":948,"children":949},{"class":350,"line":564},[950],{"type":71,"tag":348,"props":951,"children":952},{},[953],{"type":77,"value":954},"    for ident in patient.get(\"identifier\", []):\n",{"type":71,"tag":348,"props":956,"children":957},{"class":350,"line":573},[958],{"type":71,"tag":348,"props":959,"children":960},{},[961],{"type":77,"value":962},"        if ident.get(\"type\", {}).get(\"coding\", [{}])[0].get(\"code\") == \"MB\":\n",{"type":71,"tag":348,"props":964,"children":965},{"class":350,"line":582},[966],{"type":71,"tag":348,"props":967,"children":968},{},[969],{"type":77,"value":970},"            req.member_id = ident.get(\"value\", \"\")\n",{"type":71,"tag":348,"props":972,"children":973},{"class":350,"line":591},[974],{"type":71,"tag":348,"props":975,"children":976},{},[977],{"type":77,"value":978},"            break\n",{"type":71,"tag":348,"props":980,"children":981},{"class":350,"line":600},[982],{"type":71,"tag":348,"props":983,"children":984},{},[985],{"type":77,"value":986},"    # Practitioner \u002F provider NPI\n",{"type":71,"tag":348,"props":988,"children":989},{"class":350,"line":609},[990],{"type":71,"tag":348,"props":991,"children":992},{},[993],{"type":77,"value":994},"    practitioner = resources.get(\"Practitioner\", {})\n",{"type":71,"tag":348,"props":996,"children":997},{"class":350,"line":618},[998],{"type":71,"tag":348,"props":999,"children":1000},{},[1001],{"type":77,"value":1002},"    for ident in practitioner.get(\"identifier\", []):\n",{"type":71,"tag":348,"props":1004,"children":1005},{"class":350,"line":627},[1006],{"type":71,"tag":348,"props":1007,"children":1008},{},[1009],{"type":77,"value":1010},"        if ident.get(\"system\", \"\").endswith(\"\u002Fnpi\"):\n",{"type":71,"tag":348,"props":1012,"children":1013},{"class":350,"line":636},[1014],{"type":71,"tag":348,"props":1015,"children":1016},{},[1017],{"type":77,"value":1018},"            req.provider_npi = ident.get(\"value\", \"\")\n",{"type":71,"tag":348,"props":1020,"children":1021},{"class":350,"line":645},[1022],{"type":71,"tag":348,"props":1023,"children":1024},{},[1025],{"type":77,"value":978},{"type":71,"tag":348,"props":1027,"children":1028},{"class":350,"line":654},[1029],{"type":71,"tag":348,"props":1030,"children":1031},{},[1032],{"type":77,"value":1033},"    # Claim resource — core of the PA request\n",{"type":71,"tag":348,"props":1035,"children":1036},{"class":350,"line":663},[1037],{"type":71,"tag":348,"props":1038,"children":1039},{},[1040],{"type":77,"value":1041},"    claim = resources.get(\"Claim\", {})\n",{"type":71,"tag":348,"props":1043,"children":1044},{"class":350,"line":672},[1045],{"type":71,"tag":348,"props":1046,"children":1047},{},[1048],{"type":77,"value":1049},"    for dx in claim.get(\"diagnosis\", []):\n",{"type":71,"tag":348,"props":1051,"children":1052},{"class":350,"line":681},[1053],{"type":71,"tag":348,"props":1054,"children":1055},{},[1056],{"type":77,"value":1057},"        coding = dx.get(\"diagnosisCodeableConcept\", {}).get(\"coding\", [])\n",{"type":71,"tag":348,"props":1059,"children":1060},{"class":350,"line":690},[1061],{"type":71,"tag":348,"props":1062,"children":1063},{},[1064],{"type":77,"value":1065},"        for c in coding:\n",{"type":71,"tag":348,"props":1067,"children":1068},{"class":350,"line":699},[1069],{"type":71,"tag":348,"props":1070,"children":1071},{},[1072],{"type":77,"value":1073},"            req.diagnosis_codes.append(c.get(\"code\", \"\"))\n",{"type":71,"tag":348,"props":1075,"children":1076},{"class":350,"line":708},[1077],{"type":71,"tag":348,"props":1078,"children":1079},{},[1080],{"type":77,"value":1081},"    for item in claim.get(\"item\", []):\n",{"type":71,"tag":348,"props":1083,"children":1084},{"class":350,"line":717},[1085],{"type":71,"tag":348,"props":1086,"children":1087},{},[1088],{"type":77,"value":1089},"        svc_coding = item.get(\"productOrService\", {}).get(\"coding\", [])\n",{"type":71,"tag":348,"props":1091,"children":1092},{"class":350,"line":726},[1093],{"type":71,"tag":348,"props":1094,"children":1095},{},[1096],{"type":77,"value":1097},"        for c in svc_coding:\n",{"type":71,"tag":348,"props":1099,"children":1100},{"class":350,"line":735},[1101],{"type":71,"tag":348,"props":1102,"children":1103},{},[1104],{"type":77,"value":1105},"            req.service_codes.append(c.get(\"code\", \"\"))\n",{"type":71,"tag":348,"props":1107,"children":1108},{"class":350,"line":744},[1109],{"type":71,"tag":348,"props":1110,"children":1111},{},[1112],{"type":77,"value":1113},"    for info in claim.get(\"supportingInfo\", []):\n",{"type":71,"tag":348,"props":1115,"children":1117},{"class":350,"line":1116},46,[1118],{"type":71,"tag":348,"props":1119,"children":1120},{},[1121],{"type":77,"value":1122},"        cat_coding = info.get(\"category\", {}).get(\"coding\", [])\n",{"type":71,"tag":348,"props":1124,"children":1126},{"class":350,"line":1125},47,[1127],{"type":71,"tag":348,"props":1128,"children":1129},{},[1130],{"type":77,"value":1131},"        for c in cat_coding:\n",{"type":71,"tag":348,"props":1133,"children":1135},{"class":350,"line":1134},48,[1136],{"type":71,"tag":348,"props":1137,"children":1138},{},[1139],{"type":77,"value":1140},"            req.supporting_info_types.append(c.get(\"code\", \"\"))\n",{"type":71,"tag":348,"props":1142,"children":1144},{"class":350,"line":1143},49,[1145],{"type":71,"tag":348,"props":1146,"children":1147},{},[1148],{"type":77,"value":750},{"type":71,"tag":80,"props":1150,"children":1152},{"id":1151},"_2-clinical-feature-extraction",[1153],{"type":77,"value":1154},"2. Clinical Feature Extraction",{"type":71,"tag":125,"props":1156,"children":1158},{"id":1157},"_21-feature-set-for-pa-adjudication",[1159],{"type":77,"value":1160},"2.1 Feature Set for PA Adjudication",{"type":71,"tag":132,"props":1162,"children":1163},{},[1164,1190],{"type":71,"tag":136,"props":1165,"children":1166},{},[1167],{"type":71,"tag":140,"props":1168,"children":1169},{},[1170,1175,1180,1185],{"type":71,"tag":144,"props":1171,"children":1172},{},[1173],{"type":77,"value":1174},"Feature",{"type":71,"tag":144,"props":1176,"children":1177},{},[1178],{"type":77,"value":1179},"Source",{"type":71,"tag":144,"props":1181,"children":1182},{},[1183],{"type":77,"value":1184},"Type",{"type":71,"tag":144,"props":1186,"children":1187},{},[1188],{"type":77,"value":1189},"Description",{"type":71,"tag":160,"props":1191,"children":1192},{},[1193,1220,1247,1273,1300,1325,1351,1377,1403,1429],{"type":71,"tag":140,"props":1194,"children":1195},{},[1196,1205,1210,1215],{"type":71,"tag":167,"props":1197,"children":1198},{},[1199],{"type":71,"tag":248,"props":1200,"children":1202},{"className":1201},[],[1203],{"type":77,"value":1204},"dx_specificity",{"type":71,"tag":167,"props":1206,"children":1207},{},[1208],{"type":77,"value":1209},"Diagnosis codes",{"type":71,"tag":167,"props":1211,"children":1212},{},[1213],{"type":77,"value":1214},"int",{"type":71,"tag":167,"props":1216,"children":1217},{},[1218],{"type":77,"value":1219},"ICD-10 code length (3=category, 4-7=specific)",{"type":71,"tag":140,"props":1221,"children":1222},{},[1223,1232,1237,1242],{"type":71,"tag":167,"props":1224,"children":1225},{},[1226],{"type":71,"tag":248,"props":1227,"children":1229},{"className":1228},[],[1230],{"type":77,"value":1231},"drug_class",{"type":71,"tag":167,"props":1233,"children":1234},{},[1235],{"type":77,"value":1236},"Service code (NDC\u002FHCPCS)",{"type":71,"tag":167,"props":1238,"children":1239},{},[1240],{"type":77,"value":1241},"categorical",{"type":71,"tag":167,"props":1243,"children":1244},{},[1245],{"type":77,"value":1246},"Therapeutic class (e.g., biologic, opioid)",{"type":71,"tag":140,"props":1248,"children":1249},{},[1250,1259,1264,1268],{"type":71,"tag":167,"props":1251,"children":1252},{},[1253],{"type":71,"tag":248,"props":1254,"children":1256},{"className":1255},[],[1257],{"type":77,"value":1258},"prior_treatment_count",{"type":71,"tag":167,"props":1260,"children":1261},{},[1262],{"type":77,"value":1263},"Claims history",{"type":71,"tag":167,"props":1265,"children":1266},{},[1267],{"type":77,"value":1214},{"type":71,"tag":167,"props":1269,"children":1270},{},[1271],{"type":77,"value":1272},"Number of prior drugs tried in same class",{"type":71,"tag":140,"props":1274,"children":1275},{},[1276,1285,1290,1295],{"type":71,"tag":167,"props":1277,"children":1278},{},[1279],{"type":71,"tag":248,"props":1280,"children":1282},{"className":1281},[],[1283],{"type":77,"value":1284},"step_therapy_complete",{"type":71,"tag":167,"props":1286,"children":1287},{},[1288],{"type":77,"value":1289},"Claims + formulary",{"type":71,"tag":167,"props":1291,"children":1292},{},[1293],{"type":77,"value":1294},"bool",{"type":71,"tag":167,"props":1296,"children":1297},{},[1298],{"type":77,"value":1299},"All required prior steps documented",{"type":71,"tag":140,"props":1301,"children":1302},{},[1303,1312,1316,1320],{"type":71,"tag":167,"props":1304,"children":1305},{},[1306],{"type":71,"tag":248,"props":1307,"children":1309},{"className":1308},[],[1310],{"type":77,"value":1311},"days_since_last_treatment",{"type":71,"tag":167,"props":1313,"children":1314},{},[1315],{"type":77,"value":1263},{"type":71,"tag":167,"props":1317,"children":1318},{},[1319],{"type":77,"value":1214},{"type":71,"tag":167,"props":1321,"children":1322},{},[1323],{"type":77,"value":1324},"Gap since last related treatment",{"type":71,"tag":140,"props":1326,"children":1327},{},[1328,1337,1342,1346],{"type":71,"tag":167,"props":1329,"children":1330},{},[1331],{"type":71,"tag":248,"props":1332,"children":1334},{"className":1333},[],[1335],{"type":77,"value":1336},"lab_value_in_range",{"type":71,"tag":167,"props":1338,"children":1339},{},[1340],{"type":77,"value":1341},"Lab results",{"type":71,"tag":167,"props":1343,"children":1344},{},[1345],{"type":77,"value":1294},{"type":71,"tag":167,"props":1347,"children":1348},{},[1349],{"type":77,"value":1350},"Key lab (e.g., HbA1c) meets threshold",{"type":71,"tag":140,"props":1352,"children":1353},{},[1354,1363,1368,1372],{"type":71,"tag":167,"props":1355,"children":1356},{},[1357],{"type":71,"tag":248,"props":1358,"children":1360},{"className":1359},[],[1361],{"type":77,"value":1362},"provider_specialty",{"type":71,"tag":167,"props":1364,"children":1365},{},[1366],{"type":77,"value":1367},"Provider data",{"type":71,"tag":167,"props":1369,"children":1370},{},[1371],{"type":77,"value":1241},{"type":71,"tag":167,"props":1373,"children":1374},{},[1375],{"type":77,"value":1376},"Specialty of ordering provider",{"type":71,"tag":140,"props":1378,"children":1379},{},[1380,1389,1394,1398],{"type":71,"tag":167,"props":1381,"children":1382},{},[1383],{"type":71,"tag":248,"props":1384,"children":1386},{"className":1385},[],[1387],{"type":77,"value":1388},"place_of_service",{"type":71,"tag":167,"props":1390,"children":1391},{},[1392],{"type":77,"value":1393},"Claim",{"type":71,"tag":167,"props":1395,"children":1396},{},[1397],{"type":77,"value":1241},{"type":71,"tag":167,"props":1399,"children":1400},{},[1401],{"type":77,"value":1402},"Office, outpatient, inpatient, home",{"type":71,"tag":140,"props":1404,"children":1405},{},[1406,1415,1420,1424],{"type":71,"tag":167,"props":1407,"children":1408},{},[1409],{"type":71,"tag":248,"props":1410,"children":1412},{"className":1411},[],[1413],{"type":77,"value":1414},"prior_pa_denials",{"type":71,"tag":167,"props":1416,"children":1417},{},[1418],{"type":77,"value":1419},"PA history",{"type":71,"tag":167,"props":1421,"children":1422},{},[1423],{"type":77,"value":1214},{"type":71,"tag":167,"props":1425,"children":1426},{},[1427],{"type":77,"value":1428},"Count of prior denials for same service",{"type":71,"tag":140,"props":1430,"children":1431},{},[1432,1441,1446,1451],{"type":71,"tag":167,"props":1433,"children":1434},{},[1435],{"type":71,"tag":248,"props":1436,"children":1438},{"className":1437},[],[1439],{"type":77,"value":1440},"documentation_score",{"type":71,"tag":167,"props":1442,"children":1443},{},[1444],{"type":77,"value":1445},"Supporting info",{"type":71,"tag":167,"props":1447,"children":1448},{},[1449],{"type":77,"value":1450},"float",{"type":71,"tag":167,"props":1452,"children":1453},{},[1454],{"type":77,"value":1455},"Completeness score (0-1) based on required docs",{"type":71,"tag":125,"props":1457,"children":1459},{"id":1458},"_22-feature-extraction-code",[1460],{"type":77,"value":1461},"2.2 Feature Extraction Code",{"type":71,"tag":337,"props":1463,"children":1465},{"className":339,"code":1464,"language":341,"meta":342,"style":342},"\"\"\"Extract clinical features from parsed PA request + claims history.\"\"\"\nimport pandas as pd\nfrom datetime import datetime\n\n\ndef extract_features(\n    pa_request: dict,\n    claims_history: pd.DataFrame,\n    formulary: pd.DataFrame,\n    lab_results: pd.DataFrame,\n) -> dict:\n    \"\"\"Build feature vector for PA adjudication model.\n\n    Args:\n        pa_request: Parsed PA request (from parse_278 or parse_pas_bundle).\n        claims_history: Member's prior claims with columns:\n            [member_id, service_date, drug_class, ndc, diagnosis_code].\n        formulary: Formulary table with columns:\n            [ndc, tier, step_therapy_required, prior_drugs_required].\n        lab_results: Lab results with columns:\n            [member_id, test_code, result_value, result_date].\n    \"\"\"\n    member_id = pa_request.get(\"member_id\", \"\")\n    dx_codes = pa_request.get(\"diagnosis_codes\", [])\n    svc_codes = pa_request.get(\"service_codes\", [])\n\n    # Diagnosis specificity: max ICD-10 code length\n    dx_specificity = max((len(c.replace(\".\", \"\")) for c in dx_codes), default=3)\n\n    # Prior treatment count in same drug class\n    requested_drug = svc_codes[0] if svc_codes else \"\"\n    drug_info = formulary[formulary[\"ndc\"] == requested_drug]\n    drug_class = drug_info[\"drug_class\"].iloc[0] if len(drug_info) > 0 else \"unknown\"\n    member_claims = claims_history[claims_history[\"member_id\"] == member_id]\n    prior_treatments = member_claims[member_claims[\"drug_class\"] == drug_class]\n    prior_treatment_count = prior_treatments[\"ndc\"].nunique()\n\n    # Step therapy completion\n    required_steps = int(drug_info[\"prior_drugs_required\"].iloc[0]) if len(drug_info) > 0 else 0\n    step_therapy_complete = prior_treatment_count >= required_steps\n\n    # Days since last treatment in class\n    if len(prior_treatments) > 0:\n        last_date = pd.to_datetime(prior_treatments[\"service_date\"]).max()\n        days_since = (datetime.now() - last_date).days\n    else:\n        days_since = -1  # no prior treatment\n\n    # Lab value check (example: HbA1c for diabetes drugs)\n    member_labs = lab_results[lab_results[\"member_id\"] == member_id]\n    recent_lab = member_labs.sort_values(\"result_date\", ascending=False).head(1)\n    lab_in_range = bool(recent_lab[\"result_value\"].iloc[0] >= 7.0) if len(recent_lab) > 0 else False\n\n    # Documentation completeness score\n    supporting_info = pa_request.get(\"supporting_info_types\", [])\n    required_docs = {\"clinical-note\", \"lab-result\", \"treatment-history\", \"diagnosis\"}\n    doc_score = len(set(supporting_info) & required_docs) \u002F len(required_docs)\n\n    return {\n        \"dx_specificity\": dx_specificity,\n        \"drug_class\": drug_class,\n        \"prior_treatment_count\": prior_treatment_count,\n        \"step_therapy_complete\": step_therapy_complete,\n        \"days_since_last_treatment\": days_since,\n        \"lab_value_in_range\": lab_in_range,\n        \"documentation_score\": doc_score,\n    }\n",[1466],{"type":71,"tag":248,"props":1467,"children":1468},{"__ignoreMap":342},[1469,1477,1485,1493,1500,1507,1515,1523,1531,1539,1547,1555,1563,1570,1578,1586,1594,1602,1610,1618,1626,1634,1642,1650,1658,1666,1673,1681,1689,1696,1704,1712,1720,1728,1736,1744,1752,1759,1767,1775,1783,1790,1798,1806,1814,1822,1830,1838,1845,1853,1862,1871,1880,1888,1897,1906,1915,1924,1932,1941,1950,1959,1968,1977,1986,1995,2004],{"type":71,"tag":348,"props":1470,"children":1471},{"class":350,"line":351},[1472],{"type":71,"tag":348,"props":1473,"children":1474},{},[1475],{"type":77,"value":1476},"\"\"\"Extract clinical features from parsed PA request + claims history.\"\"\"\n",{"type":71,"tag":348,"props":1478,"children":1479},{"class":350,"line":360},[1480],{"type":71,"tag":348,"props":1481,"children":1482},{},[1483],{"type":77,"value":1484},"import pandas as pd\n",{"type":71,"tag":348,"props":1486,"children":1487},{"class":350,"line":369},[1488],{"type":71,"tag":348,"props":1489,"children":1490},{},[1491],{"type":77,"value":1492},"from datetime import datetime\n",{"type":71,"tag":348,"props":1494,"children":1495},{"class":350,"line":29},[1496],{"type":71,"tag":348,"props":1497,"children":1498},{"emptyLinePlaceholder":390},[1499],{"type":77,"value":393},{"type":71,"tag":348,"props":1501,"children":1502},{"class":350,"line":386},[1503],{"type":71,"tag":348,"props":1504,"children":1505},{"emptyLinePlaceholder":390},[1506],{"type":77,"value":393},{"type":71,"tag":348,"props":1508,"children":1509},{"class":350,"line":396},[1510],{"type":71,"tag":348,"props":1511,"children":1512},{},[1513],{"type":77,"value":1514},"def extract_features(\n",{"type":71,"tag":348,"props":1516,"children":1517},{"class":350,"line":404},[1518],{"type":71,"tag":348,"props":1519,"children":1520},{},[1521],{"type":77,"value":1522},"    pa_request: dict,\n",{"type":71,"tag":348,"props":1524,"children":1525},{"class":350,"line":413},[1526],{"type":71,"tag":348,"props":1527,"children":1528},{},[1529],{"type":77,"value":1530},"    claims_history: pd.DataFrame,\n",{"type":71,"tag":348,"props":1532,"children":1533},{"class":350,"line":422},[1534],{"type":71,"tag":348,"props":1535,"children":1536},{},[1537],{"type":77,"value":1538},"    formulary: pd.DataFrame,\n",{"type":71,"tag":348,"props":1540,"children":1541},{"class":350,"line":431},[1542],{"type":71,"tag":348,"props":1543,"children":1544},{},[1545],{"type":77,"value":1546},"    lab_results: pd.DataFrame,\n",{"type":71,"tag":348,"props":1548,"children":1549},{"class":350,"line":440},[1550],{"type":71,"tag":348,"props":1551,"children":1552},{},[1553],{"type":77,"value":1554},") -> dict:\n",{"type":71,"tag":348,"props":1556,"children":1557},{"class":350,"line":449},[1558],{"type":71,"tag":348,"props":1559,"children":1560},{},[1561],{"type":77,"value":1562},"    \"\"\"Build feature vector for PA adjudication model.\n",{"type":71,"tag":348,"props":1564,"children":1565},{"class":350,"line":458},[1566],{"type":71,"tag":348,"props":1567,"children":1568},{"emptyLinePlaceholder":390},[1569],{"type":77,"value":393},{"type":71,"tag":348,"props":1571,"children":1572},{"class":350,"line":467},[1573],{"type":71,"tag":348,"props":1574,"children":1575},{},[1576],{"type":77,"value":1577},"    Args:\n",{"type":71,"tag":348,"props":1579,"children":1580},{"class":350,"line":476},[1581],{"type":71,"tag":348,"props":1582,"children":1583},{},[1584],{"type":77,"value":1585},"        pa_request: Parsed PA request (from parse_278 or parse_pas_bundle).\n",{"type":71,"tag":348,"props":1587,"children":1588},{"class":350,"line":485},[1589],{"type":71,"tag":348,"props":1590,"children":1591},{},[1592],{"type":77,"value":1593},"        claims_history: Member's prior claims with columns:\n",{"type":71,"tag":348,"props":1595,"children":1596},{"class":350,"line":493},[1597],{"type":71,"tag":348,"props":1598,"children":1599},{},[1600],{"type":77,"value":1601},"            [member_id, service_date, drug_class, ndc, diagnosis_code].\n",{"type":71,"tag":348,"props":1603,"children":1604},{"class":350,"line":501},[1605],{"type":71,"tag":348,"props":1606,"children":1607},{},[1608],{"type":77,"value":1609},"        formulary: Formulary table with columns:\n",{"type":71,"tag":348,"props":1611,"children":1612},{"class":350,"line":510},[1613],{"type":71,"tag":348,"props":1614,"children":1615},{},[1616],{"type":77,"value":1617},"            [ndc, tier, step_therapy_required, prior_drugs_required].\n",{"type":71,"tag":348,"props":1619,"children":1620},{"class":350,"line":519},[1621],{"type":71,"tag":348,"props":1622,"children":1623},{},[1624],{"type":77,"value":1625},"        lab_results: Lab results with columns:\n",{"type":71,"tag":348,"props":1627,"children":1628},{"class":350,"line":528},[1629],{"type":71,"tag":348,"props":1630,"children":1631},{},[1632],{"type":77,"value":1633},"            [member_id, test_code, result_value, result_date].\n",{"type":71,"tag":348,"props":1635,"children":1636},{"class":350,"line":537},[1637],{"type":71,"tag":348,"props":1638,"children":1639},{},[1640],{"type":77,"value":1641},"    \"\"\"\n",{"type":71,"tag":348,"props":1643,"children":1644},{"class":350,"line":546},[1645],{"type":71,"tag":348,"props":1646,"children":1647},{},[1648],{"type":77,"value":1649},"    member_id = pa_request.get(\"member_id\", \"\")\n",{"type":71,"tag":348,"props":1651,"children":1652},{"class":350,"line":555},[1653],{"type":71,"tag":348,"props":1654,"children":1655},{},[1656],{"type":77,"value":1657},"    dx_codes = pa_request.get(\"diagnosis_codes\", [])\n",{"type":71,"tag":348,"props":1659,"children":1660},{"class":350,"line":564},[1661],{"type":71,"tag":348,"props":1662,"children":1663},{},[1664],{"type":77,"value":1665},"    svc_codes = pa_request.get(\"service_codes\", [])\n",{"type":71,"tag":348,"props":1667,"children":1668},{"class":350,"line":573},[1669],{"type":71,"tag":348,"props":1670,"children":1671},{"emptyLinePlaceholder":390},[1672],{"type":77,"value":393},{"type":71,"tag":348,"props":1674,"children":1675},{"class":350,"line":582},[1676],{"type":71,"tag":348,"props":1677,"children":1678},{},[1679],{"type":77,"value":1680},"    # Diagnosis specificity: max ICD-10 code length\n",{"type":71,"tag":348,"props":1682,"children":1683},{"class":350,"line":591},[1684],{"type":71,"tag":348,"props":1685,"children":1686},{},[1687],{"type":77,"value":1688},"    dx_specificity = max((len(c.replace(\".\", \"\")) for c in dx_codes), default=3)\n",{"type":71,"tag":348,"props":1690,"children":1691},{"class":350,"line":600},[1692],{"type":71,"tag":348,"props":1693,"children":1694},{"emptyLinePlaceholder":390},[1695],{"type":77,"value":393},{"type":71,"tag":348,"props":1697,"children":1698},{"class":350,"line":609},[1699],{"type":71,"tag":348,"props":1700,"children":1701},{},[1702],{"type":77,"value":1703},"    # Prior treatment count in same drug class\n",{"type":71,"tag":348,"props":1705,"children":1706},{"class":350,"line":618},[1707],{"type":71,"tag":348,"props":1708,"children":1709},{},[1710],{"type":77,"value":1711},"    requested_drug = svc_codes[0] if svc_codes else \"\"\n",{"type":71,"tag":348,"props":1713,"children":1714},{"class":350,"line":627},[1715],{"type":71,"tag":348,"props":1716,"children":1717},{},[1718],{"type":77,"value":1719},"    drug_info = formulary[formulary[\"ndc\"] == requested_drug]\n",{"type":71,"tag":348,"props":1721,"children":1722},{"class":350,"line":636},[1723],{"type":71,"tag":348,"props":1724,"children":1725},{},[1726],{"type":77,"value":1727},"    drug_class = drug_info[\"drug_class\"].iloc[0] if len(drug_info) > 0 else \"unknown\"\n",{"type":71,"tag":348,"props":1729,"children":1730},{"class":350,"line":645},[1731],{"type":71,"tag":348,"props":1732,"children":1733},{},[1734],{"type":77,"value":1735},"    member_claims = claims_history[claims_history[\"member_id\"] == member_id]\n",{"type":71,"tag":348,"props":1737,"children":1738},{"class":350,"line":654},[1739],{"type":71,"tag":348,"props":1740,"children":1741},{},[1742],{"type":77,"value":1743},"    prior_treatments = member_claims[member_claims[\"drug_class\"] == drug_class]\n",{"type":71,"tag":348,"props":1745,"children":1746},{"class":350,"line":663},[1747],{"type":71,"tag":348,"props":1748,"children":1749},{},[1750],{"type":77,"value":1751},"    prior_treatment_count = prior_treatments[\"ndc\"].nunique()\n",{"type":71,"tag":348,"props":1753,"children":1754},{"class":350,"line":672},[1755],{"type":71,"tag":348,"props":1756,"children":1757},{"emptyLinePlaceholder":390},[1758],{"type":77,"value":393},{"type":71,"tag":348,"props":1760,"children":1761},{"class":350,"line":681},[1762],{"type":71,"tag":348,"props":1763,"children":1764},{},[1765],{"type":77,"value":1766},"    # Step therapy completion\n",{"type":71,"tag":348,"props":1768,"children":1769},{"class":350,"line":690},[1770],{"type":71,"tag":348,"props":1771,"children":1772},{},[1773],{"type":77,"value":1774},"    required_steps = int(drug_info[\"prior_drugs_required\"].iloc[0]) if len(drug_info) > 0 else 0\n",{"type":71,"tag":348,"props":1776,"children":1777},{"class":350,"line":699},[1778],{"type":71,"tag":348,"props":1779,"children":1780},{},[1781],{"type":77,"value":1782},"    step_therapy_complete = prior_treatment_count >= required_steps\n",{"type":71,"tag":348,"props":1784,"children":1785},{"class":350,"line":708},[1786],{"type":71,"tag":348,"props":1787,"children":1788},{"emptyLinePlaceholder":390},[1789],{"type":77,"value":393},{"type":71,"tag":348,"props":1791,"children":1792},{"class":350,"line":717},[1793],{"type":71,"tag":348,"props":1794,"children":1795},{},[1796],{"type":77,"value":1797},"    # Days since last treatment in class\n",{"type":71,"tag":348,"props":1799,"children":1800},{"class":350,"line":726},[1801],{"type":71,"tag":348,"props":1802,"children":1803},{},[1804],{"type":77,"value":1805},"    if len(prior_treatments) > 0:\n",{"type":71,"tag":348,"props":1807,"children":1808},{"class":350,"line":735},[1809],{"type":71,"tag":348,"props":1810,"children":1811},{},[1812],{"type":77,"value":1813},"        last_date = pd.to_datetime(prior_treatments[\"service_date\"]).max()\n",{"type":71,"tag":348,"props":1815,"children":1816},{"class":350,"line":744},[1817],{"type":71,"tag":348,"props":1818,"children":1819},{},[1820],{"type":77,"value":1821},"        days_since = (datetime.now() - last_date).days\n",{"type":71,"tag":348,"props":1823,"children":1824},{"class":350,"line":1116},[1825],{"type":71,"tag":348,"props":1826,"children":1827},{},[1828],{"type":77,"value":1829},"    else:\n",{"type":71,"tag":348,"props":1831,"children":1832},{"class":350,"line":1125},[1833],{"type":71,"tag":348,"props":1834,"children":1835},{},[1836],{"type":77,"value":1837},"        days_since = -1  # no prior treatment\n",{"type":71,"tag":348,"props":1839,"children":1840},{"class":350,"line":1134},[1841],{"type":71,"tag":348,"props":1842,"children":1843},{"emptyLinePlaceholder":390},[1844],{"type":77,"value":393},{"type":71,"tag":348,"props":1846,"children":1847},{"class":350,"line":1143},[1848],{"type":71,"tag":348,"props":1849,"children":1850},{},[1851],{"type":77,"value":1852},"    # Lab value check (example: HbA1c for diabetes drugs)\n",{"type":71,"tag":348,"props":1854,"children":1856},{"class":350,"line":1855},50,[1857],{"type":71,"tag":348,"props":1858,"children":1859},{},[1860],{"type":77,"value":1861},"    member_labs = lab_results[lab_results[\"member_id\"] == member_id]\n",{"type":71,"tag":348,"props":1863,"children":1865},{"class":350,"line":1864},51,[1866],{"type":71,"tag":348,"props":1867,"children":1868},{},[1869],{"type":77,"value":1870},"    recent_lab = member_labs.sort_values(\"result_date\", ascending=False).head(1)\n",{"type":71,"tag":348,"props":1872,"children":1874},{"class":350,"line":1873},52,[1875],{"type":71,"tag":348,"props":1876,"children":1877},{},[1878],{"type":77,"value":1879},"    lab_in_range = bool(recent_lab[\"result_value\"].iloc[0] >= 7.0) if len(recent_lab) > 0 else False\n",{"type":71,"tag":348,"props":1881,"children":1883},{"class":350,"line":1882},53,[1884],{"type":71,"tag":348,"props":1885,"children":1886},{"emptyLinePlaceholder":390},[1887],{"type":77,"value":393},{"type":71,"tag":348,"props":1889,"children":1891},{"class":350,"line":1890},54,[1892],{"type":71,"tag":348,"props":1893,"children":1894},{},[1895],{"type":77,"value":1896},"    # Documentation completeness score\n",{"type":71,"tag":348,"props":1898,"children":1900},{"class":350,"line":1899},55,[1901],{"type":71,"tag":348,"props":1902,"children":1903},{},[1904],{"type":77,"value":1905},"    supporting_info = pa_request.get(\"supporting_info_types\", [])\n",{"type":71,"tag":348,"props":1907,"children":1909},{"class":350,"line":1908},56,[1910],{"type":71,"tag":348,"props":1911,"children":1912},{},[1913],{"type":77,"value":1914},"    required_docs = {\"clinical-note\", \"lab-result\", \"treatment-history\", \"diagnosis\"}\n",{"type":71,"tag":348,"props":1916,"children":1918},{"class":350,"line":1917},57,[1919],{"type":71,"tag":348,"props":1920,"children":1921},{},[1922],{"type":77,"value":1923},"    doc_score = len(set(supporting_info) & required_docs) \u002F len(required_docs)\n",{"type":71,"tag":348,"props":1925,"children":1927},{"class":350,"line":1926},58,[1928],{"type":71,"tag":348,"props":1929,"children":1930},{"emptyLinePlaceholder":390},[1931],{"type":77,"value":393},{"type":71,"tag":348,"props":1933,"children":1935},{"class":350,"line":1934},59,[1936],{"type":71,"tag":348,"props":1937,"children":1938},{},[1939],{"type":77,"value":1940},"    return {\n",{"type":71,"tag":348,"props":1942,"children":1944},{"class":350,"line":1943},60,[1945],{"type":71,"tag":348,"props":1946,"children":1947},{},[1948],{"type":77,"value":1949},"        \"dx_specificity\": dx_specificity,\n",{"type":71,"tag":348,"props":1951,"children":1953},{"class":350,"line":1952},61,[1954],{"type":71,"tag":348,"props":1955,"children":1956},{},[1957],{"type":77,"value":1958},"        \"drug_class\": drug_class,\n",{"type":71,"tag":348,"props":1960,"children":1962},{"class":350,"line":1961},62,[1963],{"type":71,"tag":348,"props":1964,"children":1965},{},[1966],{"type":77,"value":1967},"        \"prior_treatment_count\": prior_treatment_count,\n",{"type":71,"tag":348,"props":1969,"children":1971},{"class":350,"line":1970},63,[1972],{"type":71,"tag":348,"props":1973,"children":1974},{},[1975],{"type":77,"value":1976},"        \"step_therapy_complete\": step_therapy_complete,\n",{"type":71,"tag":348,"props":1978,"children":1980},{"class":350,"line":1979},64,[1981],{"type":71,"tag":348,"props":1982,"children":1983},{},[1984],{"type":77,"value":1985},"        \"days_since_last_treatment\": days_since,\n",{"type":71,"tag":348,"props":1987,"children":1989},{"class":350,"line":1988},65,[1990],{"type":71,"tag":348,"props":1991,"children":1992},{},[1993],{"type":77,"value":1994},"        \"lab_value_in_range\": lab_in_range,\n",{"type":71,"tag":348,"props":1996,"children":1998},{"class":350,"line":1997},66,[1999],{"type":71,"tag":348,"props":2000,"children":2001},{},[2002],{"type":77,"value":2003},"        \"documentation_score\": doc_score,\n",{"type":71,"tag":348,"props":2005,"children":2007},{"class":350,"line":2006},67,[2008],{"type":71,"tag":348,"props":2009,"children":2010},{},[2011],{"type":77,"value":930},{"type":71,"tag":80,"props":2013,"children":2015},{"id":2014},"_3-rules-based-adjudication-engine",[2016],{"type":77,"value":2017},"3. Rules-Based Adjudication Engine",{"type":71,"tag":337,"props":2019,"children":2021},{"className":339,"code":2020,"language":341,"meta":342,"style":342},"\"\"\"Rules-based PA adjudication engine.\"\"\"\nfrom dataclasses import dataclass\nfrom enum import Enum\n\n\nclass Decision(Enum):\n    APPROVE = \"approve\"\n    DENY = \"deny\"\n    PEND = \"pend\"\n\n\n@dataclass\nclass AdjudicationResult:\n    decision: Decision\n    reason_code: str\n    reason_text: str\n\n\ndef adjudicate(features: dict, policy: dict) -> AdjudicationResult:\n    \"\"\"Apply rules-based adjudication logic.\n\n    Args:\n        features: Feature dict from extract_features().\n        policy: Policy config with keys:\n            - require_step_therapy (bool)\n            - min_dx_specificity (int)\n            - min_documentation_score (float)\n            - require_lab_in_range (bool)\n    \"\"\"\n    # Rule 1: Documentation completeness\n    if features[\"documentation_score\"] \u003C policy.get(\"min_documentation_score\", 0.75):\n        return AdjudicationResult(\n            Decision.PEND, \"PEND-001\", \"Insufficient documentation; request additional clinical records\"\n        )\n    # Rule 2: Diagnosis specificity\n    if features[\"dx_specificity\"] \u003C policy.get(\"min_dx_specificity\", 4):\n        return AdjudicationResult(\n            Decision.DENY, \"DENY-DX\", \"Diagnosis code lacks required specificity\"\n        )\n    # Rule 3: Step therapy\n    if policy.get(\"require_step_therapy\", True) and not features[\"step_therapy_complete\"]:\n        return AdjudicationResult(\n            Decision.DENY, \"DENY-STEP\", \"Step therapy requirements not met\"\n        )\n    # Rule 4: Lab value threshold\n    if policy.get(\"require_lab_in_range\", False) and not features[\"lab_value_in_range\"]:\n        return AdjudicationResult(\n            Decision.DENY, \"DENY-LAB\", \"Required lab value not within criteria range\"\n        )\n    # All rules passed\n    return AdjudicationResult(Decision.APPROVE, \"APPROVE-001\", \"All clinical criteria met\")\n",[2022],{"type":71,"tag":248,"props":2023,"children":2024},{"__ignoreMap":342},[2025,2033,2041,2049,2056,2063,2071,2079,2087,2095,2102,2109,2116,2124,2132,2140,2148,2155,2162,2170,2178,2185,2192,2200,2208,2216,2224,2232,2240,2247,2255,2263,2271,2279,2287,2295,2303,2310,2318,2325,2333,2341,2348,2356,2363,2371,2379,2386,2394,2401,2409],{"type":71,"tag":348,"props":2026,"children":2027},{"class":350,"line":351},[2028],{"type":71,"tag":348,"props":2029,"children":2030},{},[2031],{"type":77,"value":2032},"\"\"\"Rules-based PA adjudication engine.\"\"\"\n",{"type":71,"tag":348,"props":2034,"children":2035},{"class":350,"line":360},[2036],{"type":71,"tag":348,"props":2037,"children":2038},{},[2039],{"type":77,"value":2040},"from dataclasses import dataclass\n",{"type":71,"tag":348,"props":2042,"children":2043},{"class":350,"line":369},[2044],{"type":71,"tag":348,"props":2045,"children":2046},{},[2047],{"type":77,"value":2048},"from enum import Enum\n",{"type":71,"tag":348,"props":2050,"children":2051},{"class":350,"line":29},[2052],{"type":71,"tag":348,"props":2053,"children":2054},{"emptyLinePlaceholder":390},[2055],{"type":77,"value":393},{"type":71,"tag":348,"props":2057,"children":2058},{"class":350,"line":386},[2059],{"type":71,"tag":348,"props":2060,"children":2061},{"emptyLinePlaceholder":390},[2062],{"type":77,"value":393},{"type":71,"tag":348,"props":2064,"children":2065},{"class":350,"line":396},[2066],{"type":71,"tag":348,"props":2067,"children":2068},{},[2069],{"type":77,"value":2070},"class Decision(Enum):\n",{"type":71,"tag":348,"props":2072,"children":2073},{"class":350,"line":404},[2074],{"type":71,"tag":348,"props":2075,"children":2076},{},[2077],{"type":77,"value":2078},"    APPROVE = \"approve\"\n",{"type":71,"tag":348,"props":2080,"children":2081},{"class":350,"line":413},[2082],{"type":71,"tag":348,"props":2083,"children":2084},{},[2085],{"type":77,"value":2086},"    DENY = \"deny\"\n",{"type":71,"tag":348,"props":2088,"children":2089},{"class":350,"line":422},[2090],{"type":71,"tag":348,"props":2091,"children":2092},{},[2093],{"type":77,"value":2094},"    PEND = \"pend\"\n",{"type":71,"tag":348,"props":2096,"children":2097},{"class":350,"line":431},[2098],{"type":71,"tag":348,"props":2099,"children":2100},{"emptyLinePlaceholder":390},[2101],{"type":77,"value":393},{"type":71,"tag":348,"props":2103,"children":2104},{"class":350,"line":440},[2105],{"type":71,"tag":348,"props":2106,"children":2107},{"emptyLinePlaceholder":390},[2108],{"type":77,"value":393},{"type":71,"tag":348,"props":2110,"children":2111},{"class":350,"line":449},[2112],{"type":71,"tag":348,"props":2113,"children":2114},{},[2115],{"type":77,"value":410},{"type":71,"tag":348,"props":2117,"children":2118},{"class":350,"line":458},[2119],{"type":71,"tag":348,"props":2120,"children":2121},{},[2122],{"type":77,"value":2123},"class AdjudicationResult:\n",{"type":71,"tag":348,"props":2125,"children":2126},{"class":350,"line":467},[2127],{"type":71,"tag":348,"props":2128,"children":2129},{},[2130],{"type":77,"value":2131},"    decision: Decision\n",{"type":71,"tag":348,"props":2133,"children":2134},{"class":350,"line":476},[2135],{"type":71,"tag":348,"props":2136,"children":2137},{},[2138],{"type":77,"value":2139},"    reason_code: str\n",{"type":71,"tag":348,"props":2141,"children":2142},{"class":350,"line":485},[2143],{"type":71,"tag":348,"props":2144,"children":2145},{},[2146],{"type":77,"value":2147},"    reason_text: str\n",{"type":71,"tag":348,"props":2149,"children":2150},{"class":350,"line":493},[2151],{"type":71,"tag":348,"props":2152,"children":2153},{"emptyLinePlaceholder":390},[2154],{"type":77,"value":393},{"type":71,"tag":348,"props":2156,"children":2157},{"class":350,"line":501},[2158],{"type":71,"tag":348,"props":2159,"children":2160},{"emptyLinePlaceholder":390},[2161],{"type":77,"value":393},{"type":71,"tag":348,"props":2163,"children":2164},{"class":350,"line":510},[2165],{"type":71,"tag":348,"props":2166,"children":2167},{},[2168],{"type":77,"value":2169},"def adjudicate(features: dict, policy: dict) -> AdjudicationResult:\n",{"type":71,"tag":348,"props":2171,"children":2172},{"class":350,"line":519},[2173],{"type":71,"tag":348,"props":2174,"children":2175},{},[2176],{"type":77,"value":2177},"    \"\"\"Apply rules-based adjudication logic.\n",{"type":71,"tag":348,"props":2179,"children":2180},{"class":350,"line":528},[2181],{"type":71,"tag":348,"props":2182,"children":2183},{"emptyLinePlaceholder":390},[2184],{"type":77,"value":393},{"type":71,"tag":348,"props":2186,"children":2187},{"class":350,"line":537},[2188],{"type":71,"tag":348,"props":2189,"children":2190},{},[2191],{"type":77,"value":1577},{"type":71,"tag":348,"props":2193,"children":2194},{"class":350,"line":546},[2195],{"type":71,"tag":348,"props":2196,"children":2197},{},[2198],{"type":77,"value":2199},"        features: Feature dict from extract_features().\n",{"type":71,"tag":348,"props":2201,"children":2202},{"class":350,"line":555},[2203],{"type":71,"tag":348,"props":2204,"children":2205},{},[2206],{"type":77,"value":2207},"        policy: Policy config with keys:\n",{"type":71,"tag":348,"props":2209,"children":2210},{"class":350,"line":564},[2211],{"type":71,"tag":348,"props":2212,"children":2213},{},[2214],{"type":77,"value":2215},"            - require_step_therapy (bool)\n",{"type":71,"tag":348,"props":2217,"children":2218},{"class":350,"line":573},[2219],{"type":71,"tag":348,"props":2220,"children":2221},{},[2222],{"type":77,"value":2223},"            - min_dx_specificity (int)\n",{"type":71,"tag":348,"props":2225,"children":2226},{"class":350,"line":582},[2227],{"type":71,"tag":348,"props":2228,"children":2229},{},[2230],{"type":77,"value":2231},"            - min_documentation_score (float)\n",{"type":71,"tag":348,"props":2233,"children":2234},{"class":350,"line":591},[2235],{"type":71,"tag":348,"props":2236,"children":2237},{},[2238],{"type":77,"value":2239},"            - require_lab_in_range (bool)\n",{"type":71,"tag":348,"props":2241,"children":2242},{"class":350,"line":600},[2243],{"type":71,"tag":348,"props":2244,"children":2245},{},[2246],{"type":77,"value":1641},{"type":71,"tag":348,"props":2248,"children":2249},{"class":350,"line":609},[2250],{"type":71,"tag":348,"props":2251,"children":2252},{},[2253],{"type":77,"value":2254},"    # Rule 1: Documentation completeness\n",{"type":71,"tag":348,"props":2256,"children":2257},{"class":350,"line":618},[2258],{"type":71,"tag":348,"props":2259,"children":2260},{},[2261],{"type":77,"value":2262},"    if features[\"documentation_score\"] \u003C policy.get(\"min_documentation_score\", 0.75):\n",{"type":71,"tag":348,"props":2264,"children":2265},{"class":350,"line":627},[2266],{"type":71,"tag":348,"props":2267,"children":2268},{},[2269],{"type":77,"value":2270},"        return AdjudicationResult(\n",{"type":71,"tag":348,"props":2272,"children":2273},{"class":350,"line":636},[2274],{"type":71,"tag":348,"props":2275,"children":2276},{},[2277],{"type":77,"value":2278},"            Decision.PEND, \"PEND-001\", \"Insufficient documentation; request additional clinical records\"\n",{"type":71,"tag":348,"props":2280,"children":2281},{"class":350,"line":645},[2282],{"type":71,"tag":348,"props":2283,"children":2284},{},[2285],{"type":77,"value":2286},"        )\n",{"type":71,"tag":348,"props":2288,"children":2289},{"class":350,"line":654},[2290],{"type":71,"tag":348,"props":2291,"children":2292},{},[2293],{"type":77,"value":2294},"    # Rule 2: Diagnosis specificity\n",{"type":71,"tag":348,"props":2296,"children":2297},{"class":350,"line":663},[2298],{"type":71,"tag":348,"props":2299,"children":2300},{},[2301],{"type":77,"value":2302},"    if features[\"dx_specificity\"] \u003C policy.get(\"min_dx_specificity\", 4):\n",{"type":71,"tag":348,"props":2304,"children":2305},{"class":350,"line":672},[2306],{"type":71,"tag":348,"props":2307,"children":2308},{},[2309],{"type":77,"value":2270},{"type":71,"tag":348,"props":2311,"children":2312},{"class":350,"line":681},[2313],{"type":71,"tag":348,"props":2314,"children":2315},{},[2316],{"type":77,"value":2317},"            Decision.DENY, \"DENY-DX\", \"Diagnosis code lacks required specificity\"\n",{"type":71,"tag":348,"props":2319,"children":2320},{"class":350,"line":690},[2321],{"type":71,"tag":348,"props":2322,"children":2323},{},[2324],{"type":77,"value":2286},{"type":71,"tag":348,"props":2326,"children":2327},{"class":350,"line":699},[2328],{"type":71,"tag":348,"props":2329,"children":2330},{},[2331],{"type":77,"value":2332},"    # Rule 3: Step therapy\n",{"type":71,"tag":348,"props":2334,"children":2335},{"class":350,"line":708},[2336],{"type":71,"tag":348,"props":2337,"children":2338},{},[2339],{"type":77,"value":2340},"    if policy.get(\"require_step_therapy\", True) and not features[\"step_therapy_complete\"]:\n",{"type":71,"tag":348,"props":2342,"children":2343},{"class":350,"line":717},[2344],{"type":71,"tag":348,"props":2345,"children":2346},{},[2347],{"type":77,"value":2270},{"type":71,"tag":348,"props":2349,"children":2350},{"class":350,"line":726},[2351],{"type":71,"tag":348,"props":2352,"children":2353},{},[2354],{"type":77,"value":2355},"            Decision.DENY, \"DENY-STEP\", \"Step therapy requirements not met\"\n",{"type":71,"tag":348,"props":2357,"children":2358},{"class":350,"line":735},[2359],{"type":71,"tag":348,"props":2360,"children":2361},{},[2362],{"type":77,"value":2286},{"type":71,"tag":348,"props":2364,"children":2365},{"class":350,"line":744},[2366],{"type":71,"tag":348,"props":2367,"children":2368},{},[2369],{"type":77,"value":2370},"    # Rule 4: Lab value threshold\n",{"type":71,"tag":348,"props":2372,"children":2373},{"class":350,"line":1116},[2374],{"type":71,"tag":348,"props":2375,"children":2376},{},[2377],{"type":77,"value":2378},"    if policy.get(\"require_lab_in_range\", False) and not features[\"lab_value_in_range\"]:\n",{"type":71,"tag":348,"props":2380,"children":2381},{"class":350,"line":1125},[2382],{"type":71,"tag":348,"props":2383,"children":2384},{},[2385],{"type":77,"value":2270},{"type":71,"tag":348,"props":2387,"children":2388},{"class":350,"line":1134},[2389],{"type":71,"tag":348,"props":2390,"children":2391},{},[2392],{"type":77,"value":2393},"            Decision.DENY, \"DENY-LAB\", \"Required lab value not within criteria range\"\n",{"type":71,"tag":348,"props":2395,"children":2396},{"class":350,"line":1143},[2397],{"type":71,"tag":348,"props":2398,"children":2399},{},[2400],{"type":77,"value":2286},{"type":71,"tag":348,"props":2402,"children":2403},{"class":350,"line":1855},[2404],{"type":71,"tag":348,"props":2405,"children":2406},{},[2407],{"type":77,"value":2408},"    # All rules passed\n",{"type":71,"tag":348,"props":2410,"children":2411},{"class":350,"line":1864},[2412],{"type":71,"tag":348,"props":2413,"children":2414},{},[2415],{"type":77,"value":2416},"    return AdjudicationResult(Decision.APPROVE, \"APPROVE-001\", \"All clinical criteria met\")\n",{"type":71,"tag":80,"props":2418,"children":2420},{"id":2419},"_4-ml-classifier-for-pa-decisions",[2421],{"type":77,"value":2422},"4. ML Classifier for PA Decisions",{"type":71,"tag":125,"props":2424,"children":2426},{"id":2425},"_41-training-pipeline",[2427],{"type":77,"value":2428},"4.1 Training Pipeline",{"type":71,"tag":337,"props":2430,"children":2432},{"className":339,"code":2431,"language":341,"meta":342,"style":342},"\"\"\"Train a gradient-boosted classifier on historical PA decisions.\"\"\"\nimport pandas as pd\nfrom sklearn.model_selection import StratifiedKFold\nfrom sklearn.metrics import classification_report, roc_auc_score\nimport xgboost as xgb\n\n\ndef train_pa_classifier(\n    data: pd.DataFrame, target_col: str = \"decision\",\n    feature_cols: list[str] | None = None, n_folds: int = 5,\n) -> tuple[xgb.XGBClassifier, pd.DataFrame]:\n    \"\"\"Train XGBoost on historical PA decisions (1=approved, 0=denied).\"\"\"\n    if feature_cols is None:\n        feature_cols = [c for c in data.columns if c != target_col]\n    X, y = data[feature_cols].copy(), data[target_col].copy()\n    cat_cols = X.select_dtypes(include=[\"object\", \"category\"]).columns.tolist()\n    X[cat_cols] = X[cat_cols].astype(\"category\")\n    model = xgb.XGBClassifier(\n        n_estimators=300, max_depth=6, learning_rate=0.05,\n        subsample=0.8, colsample_bytree=0.8, enable_categorical=True,\n        eval_metric=\"logloss\", random_state=42,\n    )\n    cv_results = []\n    for fold, (ti, vi) in enumerate(StratifiedKFold(n_folds, shuffle=True, random_state=42).split(X, y)):\n        model.fit(X.iloc[ti], y.iloc[ti], eval_set=[(X.iloc[vi], y.iloc[vi])], verbose=False)\n        y_prob = model.predict_proba(X.iloc[vi])[:, 1]\n        cv_results.append({\"fold\": fold, \"auc\": roc_auc_score(y.iloc[vi], y_prob)})\n    model.fit(X, y, verbose=False)\n    return model, pd.DataFrame(cv_results)\n",[2433],{"type":71,"tag":248,"props":2434,"children":2435},{"__ignoreMap":342},[2436,2444,2451,2459,2467,2475,2482,2489,2497,2505,2513,2521,2529,2537,2545,2553,2561,2569,2577,2585,2593,2601,2609,2617,2625,2633,2641,2649,2657],{"type":71,"tag":348,"props":2437,"children":2438},{"class":350,"line":351},[2439],{"type":71,"tag":348,"props":2440,"children":2441},{},[2442],{"type":77,"value":2443},"\"\"\"Train a gradient-boosted classifier on historical PA decisions.\"\"\"\n",{"type":71,"tag":348,"props":2445,"children":2446},{"class":350,"line":360},[2447],{"type":71,"tag":348,"props":2448,"children":2449},{},[2450],{"type":77,"value":1484},{"type":71,"tag":348,"props":2452,"children":2453},{"class":350,"line":369},[2454],{"type":71,"tag":348,"props":2455,"children":2456},{},[2457],{"type":77,"value":2458},"from sklearn.model_selection import StratifiedKFold\n",{"type":71,"tag":348,"props":2460,"children":2461},{"class":350,"line":29},[2462],{"type":71,"tag":348,"props":2463,"children":2464},{},[2465],{"type":77,"value":2466},"from sklearn.metrics import classification_report, roc_auc_score\n",{"type":71,"tag":348,"props":2468,"children":2469},{"class":350,"line":386},[2470],{"type":71,"tag":348,"props":2471,"children":2472},{},[2473],{"type":77,"value":2474},"import xgboost as xgb\n",{"type":71,"tag":348,"props":2476,"children":2477},{"class":350,"line":396},[2478],{"type":71,"tag":348,"props":2479,"children":2480},{"emptyLinePlaceholder":390},[2481],{"type":77,"value":393},{"type":71,"tag":348,"props":2483,"children":2484},{"class":350,"line":404},[2485],{"type":71,"tag":348,"props":2486,"children":2487},{"emptyLinePlaceholder":390},[2488],{"type":77,"value":393},{"type":71,"tag":348,"props":2490,"children":2491},{"class":350,"line":413},[2492],{"type":71,"tag":348,"props":2493,"children":2494},{},[2495],{"type":77,"value":2496},"def train_pa_classifier(\n",{"type":71,"tag":348,"props":2498,"children":2499},{"class":350,"line":422},[2500],{"type":71,"tag":348,"props":2501,"children":2502},{},[2503],{"type":77,"value":2504},"    data: pd.DataFrame, target_col: str = \"decision\",\n",{"type":71,"tag":348,"props":2506,"children":2507},{"class":350,"line":431},[2508],{"type":71,"tag":348,"props":2509,"children":2510},{},[2511],{"type":77,"value":2512},"    feature_cols: list[str] | None = None, n_folds: int = 5,\n",{"type":71,"tag":348,"props":2514,"children":2515},{"class":350,"line":440},[2516],{"type":71,"tag":348,"props":2517,"children":2518},{},[2519],{"type":77,"value":2520},") -> tuple[xgb.XGBClassifier, pd.DataFrame]:\n",{"type":71,"tag":348,"props":2522,"children":2523},{"class":350,"line":449},[2524],{"type":71,"tag":348,"props":2525,"children":2526},{},[2527],{"type":77,"value":2528},"    \"\"\"Train XGBoost on historical PA decisions (1=approved, 0=denied).\"\"\"\n",{"type":71,"tag":348,"props":2530,"children":2531},{"class":350,"line":458},[2532],{"type":71,"tag":348,"props":2533,"children":2534},{},[2535],{"type":77,"value":2536},"    if feature_cols is None:\n",{"type":71,"tag":348,"props":2538,"children":2539},{"class":350,"line":467},[2540],{"type":71,"tag":348,"props":2541,"children":2542},{},[2543],{"type":77,"value":2544},"        feature_cols = [c for c in data.columns if c != target_col]\n",{"type":71,"tag":348,"props":2546,"children":2547},{"class":350,"line":476},[2548],{"type":71,"tag":348,"props":2549,"children":2550},{},[2551],{"type":77,"value":2552},"    X, y = data[feature_cols].copy(), data[target_col].copy()\n",{"type":71,"tag":348,"props":2554,"children":2555},{"class":350,"line":485},[2556],{"type":71,"tag":348,"props":2557,"children":2558},{},[2559],{"type":77,"value":2560},"    cat_cols = X.select_dtypes(include=[\"object\", \"category\"]).columns.tolist()\n",{"type":71,"tag":348,"props":2562,"children":2563},{"class":350,"line":493},[2564],{"type":71,"tag":348,"props":2565,"children":2566},{},[2567],{"type":77,"value":2568},"    X[cat_cols] = X[cat_cols].astype(\"category\")\n",{"type":71,"tag":348,"props":2570,"children":2571},{"class":350,"line":501},[2572],{"type":71,"tag":348,"props":2573,"children":2574},{},[2575],{"type":77,"value":2576},"    model = xgb.XGBClassifier(\n",{"type":71,"tag":348,"props":2578,"children":2579},{"class":350,"line":510},[2580],{"type":71,"tag":348,"props":2581,"children":2582},{},[2583],{"type":77,"value":2584},"        n_estimators=300, max_depth=6, learning_rate=0.05,\n",{"type":71,"tag":348,"props":2586,"children":2587},{"class":350,"line":519},[2588],{"type":71,"tag":348,"props":2589,"children":2590},{},[2591],{"type":77,"value":2592},"        subsample=0.8, colsample_bytree=0.8, enable_categorical=True,\n",{"type":71,"tag":348,"props":2594,"children":2595},{"class":350,"line":528},[2596],{"type":71,"tag":348,"props":2597,"children":2598},{},[2599],{"type":77,"value":2600},"        eval_metric=\"logloss\", random_state=42,\n",{"type":71,"tag":348,"props":2602,"children":2603},{"class":350,"line":537},[2604],{"type":71,"tag":348,"props":2605,"children":2606},{},[2607],{"type":77,"value":2608},"    )\n",{"type":71,"tag":348,"props":2610,"children":2611},{"class":350,"line":546},[2612],{"type":71,"tag":348,"props":2613,"children":2614},{},[2615],{"type":77,"value":2616},"    cv_results = []\n",{"type":71,"tag":348,"props":2618,"children":2619},{"class":350,"line":555},[2620],{"type":71,"tag":348,"props":2621,"children":2622},{},[2623],{"type":77,"value":2624},"    for fold, (ti, vi) in enumerate(StratifiedKFold(n_folds, shuffle=True, random_state=42).split(X, y)):\n",{"type":71,"tag":348,"props":2626,"children":2627},{"class":350,"line":564},[2628],{"type":71,"tag":348,"props":2629,"children":2630},{},[2631],{"type":77,"value":2632},"        model.fit(X.iloc[ti], y.iloc[ti], eval_set=[(X.iloc[vi], y.iloc[vi])], verbose=False)\n",{"type":71,"tag":348,"props":2634,"children":2635},{"class":350,"line":573},[2636],{"type":71,"tag":348,"props":2637,"children":2638},{},[2639],{"type":77,"value":2640},"        y_prob = model.predict_proba(X.iloc[vi])[:, 1]\n",{"type":71,"tag":348,"props":2642,"children":2643},{"class":350,"line":582},[2644],{"type":71,"tag":348,"props":2645,"children":2646},{},[2647],{"type":77,"value":2648},"        cv_results.append({\"fold\": fold, \"auc\": roc_auc_score(y.iloc[vi], y_prob)})\n",{"type":71,"tag":348,"props":2650,"children":2651},{"class":350,"line":591},[2652],{"type":71,"tag":348,"props":2653,"children":2654},{},[2655],{"type":77,"value":2656},"    model.fit(X, y, verbose=False)\n",{"type":71,"tag":348,"props":2658,"children":2659},{"class":350,"line":600},[2660],{"type":71,"tag":348,"props":2661,"children":2662},{},[2663],{"type":77,"value":2664},"    return model, pd.DataFrame(cv_results)\n",{"type":71,"tag":125,"props":2666,"children":2668},{"id":2667},"_42-shap-explainability",[2669],{"type":77,"value":2670},"4.2 SHAP Explainability",{"type":71,"tag":337,"props":2672,"children":2674},{"className":339,"code":2673,"language":341,"meta":342,"style":342},"\"\"\"Generate SHAP explanations for PA decisions.\"\"\"\nimport shap\n\n\ndef explain_pa_decision(model, X, instance_idx: int = 0) -> dict:\n    \"\"\"Generate SHAP values for a single PA decision.\"\"\"\n    explainer = shap.TreeExplainer(model)\n    shap_values = explainer.shap_values(X)\n    explanation = dict(sorted(\n        zip(X.columns, shap_values[instance_idx]),\n        key=lambda x: abs(x[1]), reverse=True,\n    ))\n    return {\n        \"base_value\": float(explainer.expected_value),\n        \"prediction\": float(model.predict_proba(X.iloc[[instance_idx]])[:, 1][0]),\n        \"feature_contributions\": explanation,\n    }\n",[2675],{"type":71,"tag":248,"props":2676,"children":2677},{"__ignoreMap":342},[2678,2686,2694,2701,2708,2716,2724,2732,2740,2748,2756,2764,2772,2779,2787,2795,2803],{"type":71,"tag":348,"props":2679,"children":2680},{"class":350,"line":351},[2681],{"type":71,"tag":348,"props":2682,"children":2683},{},[2684],{"type":77,"value":2685},"\"\"\"Generate SHAP explanations for PA decisions.\"\"\"\n",{"type":71,"tag":348,"props":2687,"children":2688},{"class":350,"line":360},[2689],{"type":71,"tag":348,"props":2690,"children":2691},{},[2692],{"type":77,"value":2693},"import shap\n",{"type":71,"tag":348,"props":2695,"children":2696},{"class":350,"line":369},[2697],{"type":71,"tag":348,"props":2698,"children":2699},{"emptyLinePlaceholder":390},[2700],{"type":77,"value":393},{"type":71,"tag":348,"props":2702,"children":2703},{"class":350,"line":29},[2704],{"type":71,"tag":348,"props":2705,"children":2706},{"emptyLinePlaceholder":390},[2707],{"type":77,"value":393},{"type":71,"tag":348,"props":2709,"children":2710},{"class":350,"line":386},[2711],{"type":71,"tag":348,"props":2712,"children":2713},{},[2714],{"type":77,"value":2715},"def explain_pa_decision(model, X, instance_idx: int = 0) -> dict:\n",{"type":71,"tag":348,"props":2717,"children":2718},{"class":350,"line":396},[2719],{"type":71,"tag":348,"props":2720,"children":2721},{},[2722],{"type":77,"value":2723},"    \"\"\"Generate SHAP values for a single PA decision.\"\"\"\n",{"type":71,"tag":348,"props":2725,"children":2726},{"class":350,"line":404},[2727],{"type":71,"tag":348,"props":2728,"children":2729},{},[2730],{"type":77,"value":2731},"    explainer = shap.TreeExplainer(model)\n",{"type":71,"tag":348,"props":2733,"children":2734},{"class":350,"line":413},[2735],{"type":71,"tag":348,"props":2736,"children":2737},{},[2738],{"type":77,"value":2739},"    shap_values = explainer.shap_values(X)\n",{"type":71,"tag":348,"props":2741,"children":2742},{"class":350,"line":422},[2743],{"type":71,"tag":348,"props":2744,"children":2745},{},[2746],{"type":77,"value":2747},"    explanation = dict(sorted(\n",{"type":71,"tag":348,"props":2749,"children":2750},{"class":350,"line":431},[2751],{"type":71,"tag":348,"props":2752,"children":2753},{},[2754],{"type":77,"value":2755},"        zip(X.columns, shap_values[instance_idx]),\n",{"type":71,"tag":348,"props":2757,"children":2758},{"class":350,"line":440},[2759],{"type":71,"tag":348,"props":2760,"children":2761},{},[2762],{"type":77,"value":2763},"        key=lambda x: abs(x[1]), reverse=True,\n",{"type":71,"tag":348,"props":2765,"children":2766},{"class":350,"line":449},[2767],{"type":71,"tag":348,"props":2768,"children":2769},{},[2770],{"type":77,"value":2771},"    ))\n",{"type":71,"tag":348,"props":2773,"children":2774},{"class":350,"line":458},[2775],{"type":71,"tag":348,"props":2776,"children":2777},{},[2778],{"type":77,"value":1940},{"type":71,"tag":348,"props":2780,"children":2781},{"class":350,"line":467},[2782],{"type":71,"tag":348,"props":2783,"children":2784},{},[2785],{"type":77,"value":2786},"        \"base_value\": float(explainer.expected_value),\n",{"type":71,"tag":348,"props":2788,"children":2789},{"class":350,"line":476},[2790],{"type":71,"tag":348,"props":2791,"children":2792},{},[2793],{"type":77,"value":2794},"        \"prediction\": float(model.predict_proba(X.iloc[[instance_idx]])[:, 1][0]),\n",{"type":71,"tag":348,"props":2796,"children":2797},{"class":350,"line":485},[2798],{"type":71,"tag":348,"props":2799,"children":2800},{},[2801],{"type":77,"value":2802},"        \"feature_contributions\": explanation,\n",{"type":71,"tag":348,"props":2804,"children":2805},{"class":350,"line":493},[2806],{"type":71,"tag":348,"props":2807,"children":2808},{},[2809],{"type":77,"value":930},{"type":71,"tag":80,"props":2811,"children":2813},{"id":2812},"_5-denial-reason-analysis",[2814],{"type":77,"value":2815},"5. Denial Reason Analysis",{"type":71,"tag":125,"props":2817,"children":2819},{"id":2818},"_51-denial-pattern-analysis",[2820],{"type":77,"value":2821},"5.1 Denial Pattern Analysis",{"type":71,"tag":337,"props":2823,"children":2825},{"className":339,"code":2824,"language":341,"meta":342,"style":342},"\"\"\"Analyze PA denial patterns to identify systemic issues.\"\"\"\nimport pandas as pd\n\n\ndef analyze_denials(pa_decisions: pd.DataFrame, group_cols: list[str] | None = None) -> dict[str, pd.DataFrame]:\n    \"\"\"Analyze denial patterns across dimensions.\n\n    Args:\n        pa_decisions: DataFrame [pa_id, member_id, provider_npi, drug_class, denial_reason, decision, decision_date].\n        group_cols: Columns to group by. Defaults to [denial_reason, drug_class, provider_npi].\n    \"\"\"\n    denied = pa_decisions[pa_decisions[\"decision\"] == \"denied\"].copy()\n    if group_cols is None:\n        group_cols = [\"denial_reason\", \"drug_class\", \"provider_npi\"]\n    analyses = {}\n    for col in group_cols:\n        if col not in denied.columns:\n            continue\n        g = denied.groupby(col).agg(denial_count=(\"pa_id\", \"count\"), unique_members=(\"member_id\", \"nunique\")).sort_values(\"denial_count\", ascending=False).reset_index()\n        g[\"pct_of_denials\"] = (g[\"denial_count\"] \u002F len(denied) * 100).round(1)\n        analyses[col] = g\n    if \"denial_reason\" in denied.columns:\n        doc_gaps = denied[denied[\"denial_reason\"].str.contains(\"documentation|insufficient\", case=False, na=False)]\n        analyses[\"documentation_gaps\"] = doc_gaps.groupby(\"drug_class\").agg(gap_count=(\"pa_id\", \"count\")).sort_values(\"gap_count\", ascending=False).reset_index()\n    return analyses\n",[2826],{"type":71,"tag":248,"props":2827,"children":2828},{"__ignoreMap":342},[2829,2837,2844,2851,2858,2866,2874,2881,2888,2896,2904,2911,2919,2927,2935,2943,2951,2959,2967,2975,2983,2991,2999,3007,3015],{"type":71,"tag":348,"props":2830,"children":2831},{"class":350,"line":351},[2832],{"type":71,"tag":348,"props":2833,"children":2834},{},[2835],{"type":77,"value":2836},"\"\"\"Analyze PA denial patterns to identify systemic issues.\"\"\"\n",{"type":71,"tag":348,"props":2838,"children":2839},{"class":350,"line":360},[2840],{"type":71,"tag":348,"props":2841,"children":2842},{},[2843],{"type":77,"value":1484},{"type":71,"tag":348,"props":2845,"children":2846},{"class":350,"line":369},[2847],{"type":71,"tag":348,"props":2848,"children":2849},{"emptyLinePlaceholder":390},[2850],{"type":77,"value":393},{"type":71,"tag":348,"props":2852,"children":2853},{"class":350,"line":29},[2854],{"type":71,"tag":348,"props":2855,"children":2856},{"emptyLinePlaceholder":390},[2857],{"type":77,"value":393},{"type":71,"tag":348,"props":2859,"children":2860},{"class":350,"line":386},[2861],{"type":71,"tag":348,"props":2862,"children":2863},{},[2864],{"type":77,"value":2865},"def analyze_denials(pa_decisions: pd.DataFrame, group_cols: list[str] | None = None) -> dict[str, pd.DataFrame]:\n",{"type":71,"tag":348,"props":2867,"children":2868},{"class":350,"line":396},[2869],{"type":71,"tag":348,"props":2870,"children":2871},{},[2872],{"type":77,"value":2873},"    \"\"\"Analyze denial patterns across dimensions.\n",{"type":71,"tag":348,"props":2875,"children":2876},{"class":350,"line":404},[2877],{"type":71,"tag":348,"props":2878,"children":2879},{"emptyLinePlaceholder":390},[2880],{"type":77,"value":393},{"type":71,"tag":348,"props":2882,"children":2883},{"class":350,"line":413},[2884],{"type":71,"tag":348,"props":2885,"children":2886},{},[2887],{"type":77,"value":1577},{"type":71,"tag":348,"props":2889,"children":2890},{"class":350,"line":422},[2891],{"type":71,"tag":348,"props":2892,"children":2893},{},[2894],{"type":77,"value":2895},"        pa_decisions: DataFrame [pa_id, member_id, provider_npi, drug_class, denial_reason, decision, decision_date].\n",{"type":71,"tag":348,"props":2897,"children":2898},{"class":350,"line":431},[2899],{"type":71,"tag":348,"props":2900,"children":2901},{},[2902],{"type":77,"value":2903},"        group_cols: Columns to group by. Defaults to [denial_reason, drug_class, provider_npi].\n",{"type":71,"tag":348,"props":2905,"children":2906},{"class":350,"line":440},[2907],{"type":71,"tag":348,"props":2908,"children":2909},{},[2910],{"type":77,"value":1641},{"type":71,"tag":348,"props":2912,"children":2913},{"class":350,"line":449},[2914],{"type":71,"tag":348,"props":2915,"children":2916},{},[2917],{"type":77,"value":2918},"    denied = pa_decisions[pa_decisions[\"decision\"] == \"denied\"].copy()\n",{"type":71,"tag":348,"props":2920,"children":2921},{"class":350,"line":458},[2922],{"type":71,"tag":348,"props":2923,"children":2924},{},[2925],{"type":77,"value":2926},"    if group_cols is None:\n",{"type":71,"tag":348,"props":2928,"children":2929},{"class":350,"line":467},[2930],{"type":71,"tag":348,"props":2931,"children":2932},{},[2933],{"type":77,"value":2934},"        group_cols = [\"denial_reason\", \"drug_class\", \"provider_npi\"]\n",{"type":71,"tag":348,"props":2936,"children":2937},{"class":350,"line":476},[2938],{"type":71,"tag":348,"props":2939,"children":2940},{},[2941],{"type":77,"value":2942},"    analyses = {}\n",{"type":71,"tag":348,"props":2944,"children":2945},{"class":350,"line":485},[2946],{"type":71,"tag":348,"props":2947,"children":2948},{},[2949],{"type":77,"value":2950},"    for col in group_cols:\n",{"type":71,"tag":348,"props":2952,"children":2953},{"class":350,"line":493},[2954],{"type":71,"tag":348,"props":2955,"children":2956},{},[2957],{"type":77,"value":2958},"        if col not in denied.columns:\n",{"type":71,"tag":348,"props":2960,"children":2961},{"class":350,"line":501},[2962],{"type":71,"tag":348,"props":2963,"children":2964},{},[2965],{"type":77,"value":2966},"            continue\n",{"type":71,"tag":348,"props":2968,"children":2969},{"class":350,"line":510},[2970],{"type":71,"tag":348,"props":2971,"children":2972},{},[2973],{"type":77,"value":2974},"        g = denied.groupby(col).agg(denial_count=(\"pa_id\", \"count\"), unique_members=(\"member_id\", \"nunique\")).sort_values(\"denial_count\", ascending=False).reset_index()\n",{"type":71,"tag":348,"props":2976,"children":2977},{"class":350,"line":519},[2978],{"type":71,"tag":348,"props":2979,"children":2980},{},[2981],{"type":77,"value":2982},"        g[\"pct_of_denials\"] = (g[\"denial_count\"] \u002F len(denied) * 100).round(1)\n",{"type":71,"tag":348,"props":2984,"children":2985},{"class":350,"line":528},[2986],{"type":71,"tag":348,"props":2987,"children":2988},{},[2989],{"type":77,"value":2990},"        analyses[col] = g\n",{"type":71,"tag":348,"props":2992,"children":2993},{"class":350,"line":537},[2994],{"type":71,"tag":348,"props":2995,"children":2996},{},[2997],{"type":77,"value":2998},"    if \"denial_reason\" in denied.columns:\n",{"type":71,"tag":348,"props":3000,"children":3001},{"class":350,"line":546},[3002],{"type":71,"tag":348,"props":3003,"children":3004},{},[3005],{"type":77,"value":3006},"        doc_gaps = denied[denied[\"denial_reason\"].str.contains(\"documentation|insufficient\", case=False, na=False)]\n",{"type":71,"tag":348,"props":3008,"children":3009},{"class":350,"line":555},[3010],{"type":71,"tag":348,"props":3011,"children":3012},{},[3013],{"type":77,"value":3014},"        analyses[\"documentation_gaps\"] = doc_gaps.groupby(\"drug_class\").agg(gap_count=(\"pa_id\", \"count\")).sort_values(\"gap_count\", ascending=False).reset_index()\n",{"type":71,"tag":348,"props":3016,"children":3017},{"class":350,"line":564},[3018],{"type":71,"tag":348,"props":3019,"children":3020},{},[3021],{"type":77,"value":3022},"    return analyses\n",{"type":71,"tag":125,"props":3024,"children":3026},{"id":3025},"_52-denial-reason-code-reference",[3027],{"type":77,"value":3028},"5.2 Denial Reason Code Reference",{"type":71,"tag":132,"props":3030,"children":3031},{},[3032,3052],{"type":71,"tag":136,"props":3033,"children":3034},{},[3035],{"type":71,"tag":140,"props":3036,"children":3037},{},[3038,3043,3047],{"type":71,"tag":144,"props":3039,"children":3040},{},[3041],{"type":77,"value":3042},"Reason Code",{"type":71,"tag":144,"props":3044,"children":3045},{},[3046],{"type":77,"value":1189},{"type":71,"tag":144,"props":3048,"children":3049},{},[3050],{"type":77,"value":3051},"Remediation",{"type":71,"tag":160,"props":3053,"children":3054},{},[3055,3073,3091,3109,3127,3145],{"type":71,"tag":140,"props":3056,"children":3057},{},[3058,3063,3068],{"type":71,"tag":167,"props":3059,"children":3060},{},[3061],{"type":77,"value":3062},"DENY-STEP",{"type":71,"tag":167,"props":3064,"children":3065},{},[3066],{"type":77,"value":3067},"Step therapy not completed",{"type":71,"tag":167,"props":3069,"children":3070},{},[3071],{"type":77,"value":3072},"Document prior treatments with dates",{"type":71,"tag":140,"props":3074,"children":3075},{},[3076,3081,3086],{"type":71,"tag":167,"props":3077,"children":3078},{},[3079],{"type":77,"value":3080},"DENY-DX",{"type":71,"tag":167,"props":3082,"children":3083},{},[3084],{"type":77,"value":3085},"Non-specific diagnosis",{"type":71,"tag":167,"props":3087,"children":3088},{},[3089],{"type":77,"value":3090},"Use highest-specificity ICD-10 code",{"type":71,"tag":140,"props":3092,"children":3093},{},[3094,3099,3104],{"type":71,"tag":167,"props":3095,"children":3096},{},[3097],{"type":77,"value":3098},"DENY-LAB",{"type":71,"tag":167,"props":3100,"children":3101},{},[3102],{"type":77,"value":3103},"Lab criteria not met",{"type":71,"tag":167,"props":3105,"children":3106},{},[3107],{"type":77,"value":3108},"Resubmit with current lab results",{"type":71,"tag":140,"props":3110,"children":3111},{},[3112,3117,3122],{"type":71,"tag":167,"props":3113,"children":3114},{},[3115],{"type":77,"value":3116},"DENY-MN",{"type":71,"tag":167,"props":3118,"children":3119},{},[3120],{"type":77,"value":3121},"Medical necessity not established",{"type":71,"tag":167,"props":3123,"children":3124},{},[3125],{"type":77,"value":3126},"Submit letter of medical necessity",{"type":71,"tag":140,"props":3128,"children":3129},{},[3130,3135,3140],{"type":71,"tag":167,"props":3131,"children":3132},{},[3133],{"type":77,"value":3134},"DENY-EXP",{"type":71,"tag":167,"props":3136,"children":3137},{},[3138],{"type":77,"value":3139},"Experimental\u002Finvestigational",{"type":71,"tag":167,"props":3141,"children":3142},{},[3143],{"type":77,"value":3144},"Cite peer-reviewed evidence",{"type":71,"tag":140,"props":3146,"children":3147},{},[3148,3153,3158],{"type":71,"tag":167,"props":3149,"children":3150},{},[3151],{"type":77,"value":3152},"PEND-001",{"type":71,"tag":167,"props":3154,"children":3155},{},[3156],{"type":77,"value":3157},"Incomplete documentation",{"type":71,"tag":167,"props":3159,"children":3160},{},[3161],{"type":77,"value":3162},"Submit clinical notes, labs, history",{"type":71,"tag":80,"props":3164,"children":3166},{"id":3165},"_6-parameter-reference",[3167],{"type":77,"value":3168},"6. Parameter Reference",{"type":71,"tag":125,"props":3170,"children":3172},{"id":3171},"_61-xgboost-hyperparameters-for-pa-classification",[3173],{"type":77,"value":3174},"6.1 XGBoost Hyperparameters for PA Classification",{"type":71,"tag":132,"props":3176,"children":3177},{},[3178,3199],{"type":71,"tag":136,"props":3179,"children":3180},{},[3181],{"type":71,"tag":140,"props":3182,"children":3183},{},[3184,3189,3194],{"type":71,"tag":144,"props":3185,"children":3186},{},[3187],{"type":77,"value":3188},"Parameter",{"type":71,"tag":144,"props":3190,"children":3191},{},[3192],{"type":77,"value":3193},"Default",{"type":71,"tag":144,"props":3195,"children":3196},{},[3197],{"type":77,"value":3198},"Range",{"type":71,"tag":160,"props":3200,"children":3201},{},[3202,3224,3246,3268,3290,3310],{"type":71,"tag":140,"props":3203,"children":3204},{},[3205,3214,3219],{"type":71,"tag":167,"props":3206,"children":3207},{},[3208],{"type":71,"tag":248,"props":3209,"children":3211},{"className":3210},[],[3212],{"type":77,"value":3213},"n_estimators",{"type":71,"tag":167,"props":3215,"children":3216},{},[3217],{"type":77,"value":3218},"300",{"type":71,"tag":167,"props":3220,"children":3221},{},[3222],{"type":77,"value":3223},"100–1000",{"type":71,"tag":140,"props":3225,"children":3226},{},[3227,3236,3241],{"type":71,"tag":167,"props":3228,"children":3229},{},[3230],{"type":71,"tag":248,"props":3231,"children":3233},{"className":3232},[],[3234],{"type":77,"value":3235},"max_depth",{"type":71,"tag":167,"props":3237,"children":3238},{},[3239],{"type":77,"value":3240},"6",{"type":71,"tag":167,"props":3242,"children":3243},{},[3244],{"type":77,"value":3245},"3–10",{"type":71,"tag":140,"props":3247,"children":3248},{},[3249,3258,3263],{"type":71,"tag":167,"props":3250,"children":3251},{},[3252],{"type":71,"tag":248,"props":3253,"children":3255},{"className":3254},[],[3256],{"type":77,"value":3257},"learning_rate",{"type":71,"tag":167,"props":3259,"children":3260},{},[3261],{"type":77,"value":3262},"0.05",{"type":71,"tag":167,"props":3264,"children":3265},{},[3266],{"type":77,"value":3267},"0.01–0.3",{"type":71,"tag":140,"props":3269,"children":3270},{},[3271,3280,3285],{"type":71,"tag":167,"props":3272,"children":3273},{},[3274],{"type":71,"tag":248,"props":3275,"children":3277},{"className":3276},[],[3278],{"type":77,"value":3279},"subsample",{"type":71,"tag":167,"props":3281,"children":3282},{},[3283],{"type":77,"value":3284},"0.8",{"type":71,"tag":167,"props":3286,"children":3287},{},[3288],{"type":77,"value":3289},"0.5–1.0",{"type":71,"tag":140,"props":3291,"children":3292},{},[3293,3302,3306],{"type":71,"tag":167,"props":3294,"children":3295},{},[3296],{"type":71,"tag":248,"props":3297,"children":3299},{"className":3298},[],[3300],{"type":77,"value":3301},"colsample_bytree",{"type":71,"tag":167,"props":3303,"children":3304},{},[3305],{"type":77,"value":3284},{"type":71,"tag":167,"props":3307,"children":3308},{},[3309],{"type":77,"value":3289},{"type":71,"tag":140,"props":3311,"children":3312},{},[3313,3322,3327],{"type":71,"tag":167,"props":3314,"children":3315},{},[3316],{"type":71,"tag":248,"props":3317,"children":3319},{"className":3318},[],[3320],{"type":77,"value":3321},"scale_pos_weight",{"type":71,"tag":167,"props":3323,"children":3324},{},[3325],{"type":77,"value":3326},"1.0",{"type":71,"tag":167,"props":3328,"children":3329},{},[3330],{"type":77,"value":3331},"Set to neg\u002Fpos ratio for imbalanced data",{"type":71,"tag":125,"props":3333,"children":3335},{"id":3334},"_62-documentation-completeness-scoring",[3336],{"type":77,"value":3337},"6.2 Documentation Completeness Scoring",{"type":71,"tag":132,"props":3339,"children":3340},{},[3341,3362],{"type":71,"tag":136,"props":3342,"children":3343},{},[3344],{"type":71,"tag":140,"props":3345,"children":3346},{},[3347,3352,3357],{"type":71,"tag":144,"props":3348,"children":3349},{},[3350],{"type":77,"value":3351},"Document Type",{"type":71,"tag":144,"props":3353,"children":3354},{},[3355],{"type":77,"value":3356},"Weight",{"type":71,"tag":144,"props":3358,"children":3359},{},[3360],{"type":77,"value":3361},"Required For",{"type":71,"tag":160,"props":3363,"children":3364},{},[3365,3383,3400,3417,3434],{"type":71,"tag":140,"props":3366,"children":3367},{},[3368,3373,3378],{"type":71,"tag":167,"props":3369,"children":3370},{},[3371],{"type":77,"value":3372},"Clinical notes",{"type":71,"tag":167,"props":3374,"children":3375},{},[3376],{"type":77,"value":3377},"0.30",{"type":71,"tag":167,"props":3379,"children":3380},{},[3381],{"type":77,"value":3382},"All PA requests",{"type":71,"tag":140,"props":3384,"children":3385},{},[3386,3390,3395],{"type":71,"tag":167,"props":3387,"children":3388},{},[3389],{"type":77,"value":1341},{"type":71,"tag":167,"props":3391,"children":3392},{},[3393],{"type":77,"value":3394},"0.25",{"type":71,"tag":167,"props":3396,"children":3397},{},[3398],{"type":77,"value":3399},"Drug PAs with lab criteria",{"type":71,"tag":140,"props":3401,"children":3402},{},[3403,3408,3412],{"type":71,"tag":167,"props":3404,"children":3405},{},[3406],{"type":77,"value":3407},"Treatment history",{"type":71,"tag":167,"props":3409,"children":3410},{},[3411],{"type":77,"value":3394},{"type":71,"tag":167,"props":3413,"children":3414},{},[3415],{"type":77,"value":3416},"Step therapy drugs",{"type":71,"tag":140,"props":3418,"children":3419},{},[3420,3425,3430],{"type":71,"tag":167,"props":3421,"children":3422},{},[3423],{"type":77,"value":3424},"Diagnosis confirmation",{"type":71,"tag":167,"props":3426,"children":3427},{},[3428],{"type":77,"value":3429},"0.10",{"type":71,"tag":167,"props":3431,"children":3432},{},[3433],{"type":77,"value":3382},{"type":71,"tag":140,"props":3435,"children":3436},{},[3437,3442,3446],{"type":71,"tag":167,"props":3438,"children":3439},{},[3440],{"type":77,"value":3441},"Specialist referral",{"type":71,"tag":167,"props":3443,"children":3444},{},[3445],{"type":77,"value":3429},{"type":71,"tag":167,"props":3447,"children":3448},{},[3449],{"type":77,"value":3450},"Specialty drugs",{"type":71,"tag":80,"props":3452,"children":3454},{"id":3453},"_7-common-mistakes",[3455],{"type":77,"value":3456},"7. Common Mistakes",{"type":71,"tag":99,"props":3458,"children":3459},{},[3460,3492,3513,3534,3555,3576],{"type":71,"tag":103,"props":3461,"children":3462},{},[3463,3469,3471,3476,3478,3483,3485,3490],{"type":71,"tag":3464,"props":3465,"children":3466},"strong",{},[3467],{"type":77,"value":3468},"Wrong:",{"type":77,"value":3470}," Training a PA classifier on imbalanced data without correction\n",{"type":71,"tag":3464,"props":3472,"children":3473},{},[3474],{"type":77,"value":3475},"Right:",{"type":77,"value":3477}," Set ",{"type":71,"tag":248,"props":3479,"children":3481},{"className":3480},[],[3482],{"type":77,"value":3321},{"type":77,"value":3484}," to the neg\u002Fpos ratio, or apply SMOTE to balance the training set\n",{"type":71,"tag":3464,"props":3486,"children":3487},{},[3488],{"type":77,"value":3489},"Why:",{"type":77,"value":3491}," PA datasets are often 70–80% approvals; without correction, the model learns to approve everything",{"type":71,"tag":103,"props":3493,"children":3494},{},[3495,3499,3501,3505,3507,3511],{"type":71,"tag":3464,"props":3496,"children":3497},{},[3498],{"type":77,"value":3468},{"type":77,"value":3500}," Including features derived from information not available at the time of the PA request\n",{"type":71,"tag":3464,"props":3502,"children":3503},{},[3504],{"type":77,"value":3475},{"type":77,"value":3506}," Ensure all features use only data available before or at the moment of submission (claims history, not future outcomes)\n",{"type":71,"tag":3464,"props":3508,"children":3509},{},[3510],{"type":77,"value":3489},{"type":77,"value":3512}," Leaking future data inflates model performance in training but fails completely in production",{"type":71,"tag":103,"props":3514,"children":3515},{},[3516,3520,3522,3526,3528,3532],{"type":71,"tag":3464,"props":3517,"children":3518},{},[3519],{"type":77,"value":3468},{"type":77,"value":3521}," Deploying a model trained on one payer's decisions to adjudicate another payer's requests\n",{"type":71,"tag":3464,"props":3523,"children":3524},{},[3525],{"type":77,"value":3475},{"type":77,"value":3527}," Train and validate separate models per payer, or include payer identity as a feature with sufficient per-payer training data\n",{"type":71,"tag":3464,"props":3529,"children":3530},{},[3531],{"type":77,"value":3489},{"type":77,"value":3533}," Each payer has independent clinical policies; a model trained on Payer A's criteria will make wrong decisions for Payer B",{"type":71,"tag":103,"props":3535,"children":3536},{},[3537,3541,3543,3547,3549,3553],{"type":71,"tag":3464,"props":3538,"children":3539},{},[3540],{"type":77,"value":3468},{"type":77,"value":3542}," Accepting SHAP explanations at face value without clinical validation\n",{"type":71,"tag":3464,"props":3544,"children":3545},{},[3546],{"type":77,"value":3475},{"type":77,"value":3548}," Verify that top SHAP features align with known clinical criteria from the payer's published policy\n",{"type":71,"tag":3464,"props":3550,"children":3551},{},[3552],{"type":77,"value":3489},{"type":77,"value":3554}," Spurious correlations in training data can produce plausible-looking but clinically meaningless explanations",{"type":71,"tag":103,"props":3556,"children":3557},{},[3558,3562,3564,3568,3570,3574],{"type":71,"tag":3464,"props":3559,"children":3560},{},[3561],{"type":77,"value":3468},{"type":77,"value":3563}," Hardcoding denial reason strings with free-text matching\n",{"type":71,"tag":3464,"props":3565,"children":3566},{},[3567],{"type":77,"value":3475},{"type":77,"value":3569}," Use standardized reason codes (CARC\u002FRARC) and map them to structured enums\n",{"type":71,"tag":3464,"props":3571,"children":3572},{},[3573],{"type":77,"value":3489},{"type":77,"value":3575}," Free-text matching is brittle — minor wording changes break the logic and cause silent failures",{"type":71,"tag":103,"props":3577,"children":3578},{},[3579,3583,3585,3589,3591,3595],{"type":71,"tag":3464,"props":3580,"children":3581},{},[3582],{"type":77,"value":3468},{"type":77,"value":3584}," Replacing the rules engine entirely with an ML classifier\n",{"type":71,"tag":3464,"props":3586,"children":3587},{},[3588],{"type":77,"value":3475},{"type":77,"value":3590}," Use ML to augment deterministic policy rules; route clear-cut cases through rules and ambiguous cases through ML\n",{"type":71,"tag":3464,"props":3592,"children":3593},{},[3594],{"type":77,"value":3489},{"type":77,"value":3596}," Auditable, explainable decisions require deterministic rules for regulatory compliance; ML alone is not audit-defensible",{"type":71,"tag":3598,"props":3599,"children":3600},"style",{},[3601],{"type":77,"value":3602},"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":3604,"total":699},[3605,3622,3637,3651,3666,3679,3690],{"slug":3606,"name":3606,"fn":3607,"description":3608,"org":3609,"tags":3610,"stars":29,"repoUrl":30,"updatedAt":3621},"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},[3611,3614,3615,3616,3618],{"name":3612,"slug":3613,"type":16},"Architecture","architecture",{"name":27,"slug":28,"type":16},{"name":14,"slug":15,"type":16},{"name":3617,"slug":44,"type":16},"Life Sciences",{"name":3619,"slug":3620,"type":16},"LLM","llm","2026-07-12T08:38:07.975937",{"slug":3623,"name":3623,"fn":3624,"description":3625,"org":3626,"tags":3627,"stars":29,"repoUrl":30,"updatedAt":3636},"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},[3628,3629,3632,3633],{"name":27,"slug":28,"type":16},{"name":3630,"slug":3631,"type":16},"Bioinformatics","bioinformatics",{"name":3617,"slug":44,"type":16},{"name":3634,"slug":3635,"type":16},"Research","research","2026-07-12T08:37:49.295301",{"slug":3638,"name":3638,"fn":3639,"description":3640,"org":3641,"tags":3642,"stars":29,"repoUrl":30,"updatedAt":3650},"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},[3643,3646,3647],{"name":3644,"slug":3645,"type":16},"Clinical Trials","clinical-trials",{"name":3617,"slug":44,"type":16},{"name":3648,"slug":3649,"type":16},"Regulatory Compliance","regulatory-compliance","2026-07-12T08:37:33.35594",{"slug":3652,"name":3652,"fn":3653,"description":3654,"org":3655,"tags":3656,"stars":29,"repoUrl":30,"updatedAt":3665},"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},[3657,3658,3661,3662],{"name":3630,"slug":3631,"type":16},{"name":3659,"slug":3660,"type":16},"Data Analysis","data-analysis",{"name":3617,"slug":44,"type":16},{"name":3663,"slug":3664,"type":16},"RNA-seq","rna-seq","2026-07-12T08:38:05.443454",{"slug":3667,"name":3667,"fn":3668,"description":3669,"org":3670,"tags":3671,"stars":29,"repoUrl":30,"updatedAt":3678},"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},[3672,3673,3676,3677],{"name":3630,"slug":3631,"type":16},{"name":3674,"slug":3675,"type":16},"Chemistry","chemistry",{"name":3659,"slug":3660,"type":16},{"name":3634,"slug":3635,"type":16},"2026-07-12T08:37:28.334619",{"slug":3680,"name":3680,"fn":3681,"description":3682,"org":3683,"tags":3684,"stars":29,"repoUrl":30,"updatedAt":3689},"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},[3685,3686,3687,3688],{"name":3659,"slug":3660,"type":16},{"name":14,"slug":15,"type":16},{"name":24,"slug":25,"type":16},{"name":3617,"slug":44,"type":16},"2026-07-12T08:37:34.815088",{"slug":3691,"name":3691,"fn":3692,"description":3693,"org":3694,"tags":3695,"stars":29,"repoUrl":30,"updatedAt":3699},"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},[3696,3697,3698],{"name":14,"slug":15,"type":16},{"name":24,"slug":25,"type":16},{"name":3648,"slug":3649,"type":16},"2026-07-12T08:38:28.210856",{"items":3701,"total":3875},[3702,3721,3742,3752,3765,3778,3788,3798,3819,3834,3849,3862],{"slug":3703,"name":3703,"fn":3704,"description":3705,"org":3706,"tags":3707,"stars":3718,"repoUrl":3719,"updatedAt":3720},"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},[3708,3709,3712,3715],{"name":27,"slug":28,"type":16},{"name":3710,"slug":3711,"type":16},"Debugging","debugging",{"name":3713,"slug":3714,"type":16},"Logs","logs",{"name":3716,"slug":3717,"type":16},"Observability","observability",9427,"https:\u002F\u002Fgithub.com\u002Fawslabs\u002Fmcp","2026-07-12T08:37:22.601527",{"slug":3722,"name":3723,"fn":3724,"description":3725,"org":3726,"tags":3727,"stars":3718,"repoUrl":3719,"updatedAt":3741},"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},[3728,3731,3732,3735,3738],{"name":3729,"slug":3730,"type":16},"Aurora","aurora",{"name":27,"slug":28,"type":16},{"name":3733,"slug":3734,"type":16},"Database","database",{"name":3736,"slug":3737,"type":16},"Serverless","serverless",{"name":3739,"slug":3740,"type":16},"SQL","sql","2026-07-12T08:36:45.053393",{"slug":3743,"name":3744,"fn":3724,"description":3725,"org":3745,"tags":3746,"stars":3718,"repoUrl":3719,"updatedAt":3751},"aurora-dsql","aurora dsql",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3747,3748,3749,3750],{"name":27,"slug":28,"type":16},{"name":3733,"slug":3734,"type":16},{"name":3736,"slug":3737,"type":16},{"name":3739,"slug":3740,"type":16},"2026-07-12T08:36:42.694299",{"slug":3753,"name":3754,"fn":3724,"description":3725,"org":3755,"tags":3756,"stars":3718,"repoUrl":3719,"updatedAt":3764},"aws-dsql","aws dsql",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3757,3758,3759,3762,3763],{"name":27,"slug":28,"type":16},{"name":3733,"slug":3734,"type":16},{"name":3760,"slug":3761,"type":16},"Migration","migration",{"name":3736,"slug":3737,"type":16},{"name":3739,"slug":3740,"type":16},"2026-07-12T08:36:38.584057",{"slug":3766,"name":3767,"fn":3724,"description":3725,"org":3768,"tags":3769,"stars":3718,"repoUrl":3719,"updatedAt":3777},"distributed-postgres","distributed postgres",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3770,3771,3772,3775,3776],{"name":27,"slug":28,"type":16},{"name":3733,"slug":3734,"type":16},{"name":3773,"slug":3774,"type":16},"PostgreSQL","postgresql",{"name":3736,"slug":3737,"type":16},{"name":3739,"slug":3740,"type":16},"2026-07-12T08:36:46.530743",{"slug":3779,"name":3780,"fn":3724,"description":3725,"org":3781,"tags":3782,"stars":3718,"repoUrl":3719,"updatedAt":3787},"distributed-sql","distributed sql",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3783,3784,3785,3786],{"name":27,"slug":28,"type":16},{"name":3733,"slug":3734,"type":16},{"name":3736,"slug":3737,"type":16},{"name":3739,"slug":3740,"type":16},"2026-07-12T08:36:48.104182",{"slug":3789,"name":3789,"fn":3724,"description":3725,"org":3790,"tags":3791,"stars":3718,"repoUrl":3719,"updatedAt":3797},"dsql",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[3792,3793,3794,3795,3796],{"name":27,"slug":28,"type":16},{"name":3733,"slug":3734,"type":16},{"name":3760,"slug":3761,"type":16},{"name":3736,"slug":3737,"type":16},{"name":3739,"slug":3740,"type":16},"2026-07-12T08:36:36.374512",{"slug":3799,"name":3799,"fn":3800,"description":3801,"org":3802,"tags":3803,"stars":3816,"repoUrl":3817,"updatedAt":3818},"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},[3804,3807,3810,3813],{"name":3805,"slug":3806,"type":16},"Accounting","accounting",{"name":3808,"slug":3809,"type":16},"Analytics","analytics",{"name":3811,"slug":3812,"type":16},"Cost Optimization","cost-optimization",{"name":3814,"slug":3815,"type":16},"Finance","finance",3176,"https:\u002F\u002Fgithub.com\u002Fawslabs\u002Fagentcore-samples","2026-07-12T08:40:03.29555",{"slug":3820,"name":3820,"fn":3821,"description":3822,"org":3823,"tags":3824,"stars":3816,"repoUrl":3817,"updatedAt":3833},"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},[3825,3826,3827,3830],{"name":27,"slug":28,"type":16},{"name":3814,"slug":3815,"type":16},{"name":3828,"slug":3829,"type":16},"Management","management",{"name":3831,"slug":3832,"type":16},"Reporting","reporting","2026-07-12T08:40:02.066471",{"slug":3835,"name":3835,"fn":3836,"description":3837,"org":3838,"tags":3839,"stars":3816,"repoUrl":3817,"updatedAt":3848},"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},[3840,3841,3842,3845],{"name":3808,"slug":3809,"type":16},{"name":3814,"slug":3815,"type":16},{"name":3843,"slug":3844,"type":16},"Financial Statements","financial-statements",{"name":3846,"slug":3847,"type":16},"Variance Analysis","variance-analysis","2026-07-12T08:40:00.79141",{"slug":3850,"name":3850,"fn":3851,"description":3852,"org":3853,"tags":3854,"stars":3816,"repoUrl":3817,"updatedAt":3861},"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},[3855,3856,3859],{"name":18,"slug":19,"type":16},{"name":3857,"slug":3858,"type":16},"Documents","documents",{"name":3860,"slug":3850,"type":16},"PDF","2026-07-12T08:41:44.135656",{"slug":3863,"name":3863,"fn":3864,"description":3865,"org":3866,"tags":3867,"stars":3816,"repoUrl":3817,"updatedAt":3874},"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},[3868,3869,3870,3871],{"name":3805,"slug":3806,"type":16},{"name":3659,"slug":3660,"type":16},{"name":3814,"slug":3815,"type":16},{"name":3872,"slug":3873,"type":16},"KPI","kpi","2026-07-12T08:39:59.54971",150]