Endpoints — Validation

← Back to Platform Architecture

Endpoints — Validation

Validation endpoints for running quality gates before appeal submission and export.

POST /api/validation/validate-appeal-decision

Validate an appeal against PR-U (pre-upstream) quality gates before submission. Authentication: Required Authorization: Any authenticated user

Request Body

{
  "denial_id": "denial-uuid",
  "denial_reason_code": "FREQ_LIMIT",
  "payer_id": "payer-uuid",
  "proposed_evidence_elements": [
    { "type": "clinical_notes", "present": true },
    { "type": "gaf_assessment", "present": true },
    { "type": "psychiatric_evaluation", "present": false }
  ],
  "precedent_ids": ["prec-uuid-1", "prec-uuid-2"],
  "appeal_narrative": "Patient with GAF score 35 demonstrates ongoing need for IOP-level care..."
}

Response (200 OK)

{
  "validation_status": "warnings",
  "checks_passed": [
    "has_narrative",
    "has_precedents",
    "valid_precedents"
  ],
  "warnings": [
    {
      "check": "narrative_length",
      "message": "Narrative seems short (50+ words recommended)",
      "guidance": "Expand with clinical detail: GAF score, functional impact, evidence integration"
    },
    {
      "check": "precedent_relevance",
      "message": "Some precedents are for different denials (Cigna vs. UHC). Verify relevance.",
      "guidance": "Appeals are strongest when precedents are for same payer/denial type"
    }
  ],
  "errors": [],
  "precedent_confidence_summary": {
    "high_confidence": 1,
    "medium_confidence": 1,
    "stale_precedents": 0
  }
}

PR-U Gates (Validation Checks)

Validation Statuses


POST /api/validation/export

Validate before export (PR-D gates, final validation). Authentication: Required Authorization: admin, biller roles

Request Body

{
  "precedent_ids": ["prec-uuid-1", "prec-uuid-2"],
  "export_format": "json",
  "deidentify": true
}

Response (200 OK)

{
  "validation_status": "warnings",
  "errors": [],
  "warnings": [
    {
      "precedent_id": "prec-uuid-1",
      "check": "outcome_resolution",
      "message": "Outcome still pending — data is incomplete",
      "guidance": "This precedent will be more valuable once appeal resolves"
    }
  ],
  "export_readiness": true
}

PR-D Gates (Export Validation)

CheckConditionSeverityMessage
has_narrativenarrative IS NOT NULL AND LENGTH > 0ERRORProvide appeal narrative (50+ chars)
has_precedentsselected_precedent_ids.length > 0ERRORSelect at least one precedent
valid_precedentsAll IDs exist in precedent_objectsERROROne or more precedents no longer exist
narrative_lengthLENGTH(narrative) >= 50WARNINGNarrative seems short (50+ words)
precedent_relevancePrecedent payer/denial_type match appealWARNINGSome precedents are for different denials
CheckConditionSeverityMessage
evidence_score_setevidence_score IS NOT NULLERRORRate evidence strength (Minimal/Moderate/Strong)
outcome_setIF status='Complete' THEN outcome IS NOT NULLERRORSet outcome (Won/Lost/Partial)
policy_reference_completepolicy_reference.section AND .exact_languageWARNINGInclude specific policy section and quoted language
denial_trigger_specifieddenial_trigger IS NOT NULL AND LENGTH > 0ERRORSpecify exact denial trigger
evidence_kit_nonemptyevidence_kit.required OR .recommendedWARNINGPopulate evidence kit so others know what to gather
CheckConditionSeverityMessage
outcome_resolutionIF status='Complete' THEN outcome != 'Pending'WARNINGOutcome pending — data incomplete
sud_complianceIF data_origin_type='SUD' THEN sharing_restrictions != 'none'ERRORSUD data cannot export without consent
traceability_completetraceability_ledger.length >= 2WARNINGTraceability ledger sparse — missing decision history
submission_readinessAll PR-U gates pass + no urgent warningsERRORAppeal not ready to submit

Error Responses

Validation Error (422)

{
  "status": "error",
  "type": "validation_failed",
  "message": "Validation failed. Please address errors below.",
  "validation_result": {
    "status": "errors",
    "errors": [
      {
        "check": "has_narrative",
        "message": "Narrative is required",
        "guidance": "Provide 50+ word clinical justification"
      }
    ]
  }
}

Invalid Request (400)

{
  "status": "error",
  "type": "invalid_request",
  "message": "Validation schema error",
  "details": [
    { "path": "precedent_ids", "message": "Expected array" }
  ]
}

See Also

  • PREVENTION-RULES-ENGINE.md — Full gate definitions
  • ENDPOINTS-APPEALS.md — Appeal submission flow
  • ENDPOINTS-PRECEDENTS.md — Precedent export and validation