| export type FieldStatus = "confirmed" | "needs_review" | "flagged"; |
|
|
| |
| |
| export interface Project { |
| project_id: string; |
| name: string; |
| case_count: number; |
| } |
|
|
| |
| export interface ProjectList { |
| projects: Project[]; |
| default: string; |
| } |
|
|
| |
| |
| |
| export interface FieldSpec { |
| name: string; |
| label: string; |
| value_type: "string" | "number" | "boolean"; |
| enum_values: string[] | null; |
| } |
|
|
| export type CaseStatus = |
| | "queued" |
| | "processing" |
| | "ready_for_review" |
| | "in_review" |
| | "confirmed" |
| | "exported" |
| | "flagged"; |
|
|
| export interface EvidenceSpan { |
| quote: string; |
| char_start: number | null; |
| char_end: number | null; |
| page_number: number | null; |
| source: string; |
| } |
|
|
| export interface ChecklistField { |
| value: unknown; |
| confidence: number | null; |
| evidence: EvidenceSpan | null; |
| status: FieldStatus; |
| applicable: boolean; |
| not_applicable_reason: string | null; |
| search_log: string[]; |
| } |
|
|
| export interface WorklistRow { |
| case_barcode: string; |
| patient_filename: string | null; |
| status: CaseStatus; |
| } |
|
|
| |
| export interface Escalation { |
| case_barcode: string; |
| field_name: string; |
| value: unknown; |
| escalated_by: string; |
| role: string; |
| note: string | null; |
| escalated_at: string; |
| } |
|
|
| |
| |
| export interface ModelCall { |
| id: string; |
| provider: string; |
| model: string | null; |
| response_model: string | null; |
| request_id: string | null; |
| input_tokens: number | null; |
| output_tokens: number | null; |
| cache_creation_input_tokens: number | null; |
| cache_read_input_tokens: number | null; |
| latency_ms: number | null; |
| context: string | null; |
| created_at: string; |
| } |
|
|
| export interface TraceSummary { |
| call_count: number; |
| input_tokens: number; |
| output_tokens: number; |
| cache_creation_input_tokens: number; |
| cache_read_input_tokens: number; |
| models: string[]; |
| providers: string[]; |
| mean_latency_ms: number | null; |
| } |
|
|
| export interface TraceResponse { |
| calls: ModelCall[]; |
| summary: TraceSummary; |
| } |
|
|
| |
| |
| export interface CoverageRecordType { |
| record_type_id: string; |
| name: string; |
| source_class: string; |
| blurb: string | null; |
| } |
|
|
| export interface CoverageField { |
| name: string; |
| label: string; |
| section: string | null; |
| source: string; |
| fill: { via: "checklist" | "outcome"; key: string } | null; |
| } |
|
|
| export interface CoverageExtraction { |
| case: string; |
| field: string; |
| value: string; |
| evidence: string | null; |
| } |
|
|
| export interface CoverageResponse { |
| dictionary_id: string; |
| record_types: CoverageRecordType[]; |
| fields: CoverageField[]; |
| |
| extractions: Record<string, CoverageExtraction[]>; |
| } |
|
|
| export interface CaseDetail { |
| case_barcode: string; |
| patient_filename: string | null; |
| report_date: string | null; |
| staging_edition: string; |
| status: CaseStatus; |
| page_count: number; |
| fields: Record<string, ChecklistField>; |
| } |
|
|
| export interface VisualEvidence { |
| evidence: EvidenceSpan; |
| score: number; |
| } |
|
|
| |
| export interface TextSourceOption { |
| id: string; |
| label: string; |
| } |
|
|
| |
| |
| export interface DictionaryVariable { |
| name: string; |
| label: string | null; |
| permitted_values: string[] | null; |
| licence_required: boolean; |
| } |
|
|
| export interface DataDictionary { |
| id: string; |
| title: string; |
| variables: DictionaryVariable[]; |
| } |
|
|
| export type ReportSourceKind = "prepared_corpus" | "folder"; |
|
|
| export interface IngestionRunRequest { |
| source: { kind: ReportSourceKind; folder_path?: string | null }; |
| dictionary?: DataDictionary | null; |
| text_source?: string | null; |
| } |
|
|
| |
| |
| |
| export interface IngestionJob { |
| id: string; |
| kind: string; |
| ticket: string; |
| status: string; |
| dictionary_id: string; |
| source_kind: string; |
| case_count: number; |
| variable_count: number; |
| error?: string | null; |
| created_at: string; |
| started_at?: string | null; |
| finished_at?: string | null; |
| } |
|
|
| |
| |
| |
| export interface DictionaryOption { |
| id: string; |
| title: string; |
| builtin: boolean; |
| ready: boolean; |
| } |
|
|
| export interface IngestionRunResult { |
| ingested: number; |
| failures: number; |
| seeded: { queued: number; flagged: number }; |
| source: { kind: ReportSourceKind; folder_path?: string | null }; |
| text_source: TextSourceOption; |
| dictionary: { |
| id: string; |
| title: string; |
| variable_count: number; |
| licence_required_variables: string[]; |
| }; |
| enqueued: IngestionJob[]; |
| } |
|
|
| export interface FieldSummary { |
| field_name: string; |
| total: number; |
| confirmed: number; |
| needs_review: number; |
| flagged: number; |
| avg_confidence: number | null; |
| } |
|
|
| |
| |
| |
| |
|
|
| export interface ValueCount { |
| value: string; |
| count: number; |
| } |
|
|
| export interface AbsenceCount { |
| reason: AbsentReason; |
| count: number; |
| } |
|
|
| |
| |
| export interface AssociationRow { |
| stratum: string; |
| present: number; |
| absent: number; |
| total: number; |
| absent_rate: number; |
| } |
|
|
| |
| |
| export interface FieldAssociation { |
| stratifier: string; |
| rows: AssociationRow[]; |
| signal: boolean; |
| detail: string | null; |
| } |
|
|
| |
| |
| export interface FieldComponentDistribution { |
| dimension: string; |
| values: ValueCount[]; |
| } |
|
|
| export interface FieldDistribution { |
| field_name: string; |
| label: string; |
| |
| |
| value_type: string; |
| confirmed: number; |
| pending: number; |
| absent: number; |
| total: number; |
| values: ValueCount[]; |
| absence: AbsenceCount[]; |
| association: FieldAssociation; |
| |
| components: FieldComponentDistribution[]; |
| } |
|
|
| export interface RequiresSlidesVariable { |
| field_name: string; |
| label: string; |
| } |
|
|
| |
| |
| export interface RequiresSlidesCase { |
| case_barcode: string; |
| verdict: string | null; |
| |
| |
| verdict_basis: "confirmed" | "draft" | null; |
| stage: string | null; |
| variables: RequiresSlidesVariable[]; |
| count: number; |
| join_variables: RequiresSlidesVariable[]; |
| } |
|
|
| export interface DashboardStratifier { |
| field_name: string; |
| label: string; |
| strata: string[]; |
| } |
|
|
| export interface DashboardSummary { |
| total_cases: number; |
| done_cases: number; |
| completion_rate: number; |
| fields: FieldSummary[]; |
| absence_vocabulary: AbsentReason[]; |
| stratifier: DashboardStratifier; |
| field_distributions: FieldDistribution[]; |
| requires_slides: RequiresSlidesCase[]; |
| requires_slides_case_count: number; |
| } |
|
|
| export interface ProvenanceRow { |
| case_barcode: string; |
| field_name: string; |
| value: unknown; |
| confidence: number | null; |
| status: FieldStatus; |
| applicable: boolean; |
| not_applicable_reason: string | null; |
| evidence_quote: string | null; |
| evidence_page: number | null; |
| evidence_source: string | null; |
| } |
|
|
| |
| |
| |
| |
| export type AbsentReason = |
| | "not_applicable" |
| | "not_stated" |
| | "indeterminate" |
| | "determined_by_join" |
| | "constrained"; |
|
|
| export type ExportColumnKind = "identifier" | "value" | "absent_reason"; |
|
|
| export interface ExportColumn { |
| key: string; |
| label: string; |
| kind: ExportColumnKind; |
| |
| concept_id?: string; |
| category?: string; |
| assertion_type?: AssertionType; |
| cardinality?: Cardinality; |
| cited_to?: string; |
| derived?: DerivedRule | null; |
| absent_reason_key?: string; |
| of?: string; |
| |
| sourced_via?: "join"; |
| join_source?: string; |
| note?: string; |
| } |
|
|
| export interface ExportBundle { |
| target_schema: { name: string; concept_count: number; schema_checksum: string }; |
| staging_edition: { selected: string; per_case_editions: string[] }; |
| generated_at: string; |
| rule_versions: { dependency_graph_checksum: string; named_rules: string[] }; |
| model_versions: { extraction: string }; |
| coding_systems: { stage: string; value_sets: string }; |
| sources: { case_barcode: string; source_document: string | null; evidence_checksum: string }[]; |
| reproduction: string; |
| } |
|
|
| export interface ExportFile { |
| filename: string; |
| media_type: string; |
| content?: string; |
| content_base64?: string; |
| } |
|
|
| export interface ExportResult { |
| columns: ExportColumn[]; |
| rows: Record<string, unknown>[]; |
| provenance: ProvenanceRow[]; |
| bundle: ExportBundle; |
| files: { csv: ExportFile; json: ExportFile; xlsx: ExportFile }; |
| } |
|
|
| |
| export interface StagingEditionOption { |
| id: string; |
| label: string; |
| } |
|
|
| |
| |
| |
| export interface StageProjection { |
| kind: "determined" | "constrained" | "indeterminate"; |
| code?: string; |
| modifier?: string | null; |
| candidates?: string[]; |
| reason?: string; |
| system_id?: string | null; |
| confidence?: number | null; |
| derivation?: { rule: string; edition: string; inputs: string[] }; |
| } |
|
|
| |
| |
| |
| |
|
|
| export type AssertionType = "asserted" | "derived"; |
| export type Cardinality = "exactly_one" | "zero_or_one" | "zero_or_more"; |
| export type RuleKind = "formula" | "threshold" | "membership" | "algorithm"; |
|
|
| export interface DerivedRule { |
| inputs: string[]; |
| rule: string; |
| rule_kind: RuleKind; |
| } |
|
|
| export interface ConceptSource { |
| source_id: string; |
| title: string | null; |
| year: string | null; |
| url: string | null; |
| license: string | null; |
| } |
|
|
| |
| |
| |
| export interface ConceptEvidence { |
| kind: "extraction" | "doc_section" | "unresolved"; |
| cited_to: string; |
| prose_only: boolean; |
| doc_section?: string; |
| extraction_id?: string; |
| source_id?: string; |
| page?: number | null; |
| verbatim_text?: string | null; |
| extracted_by?: string | null; |
| note?: string | null; |
| source?: ConceptSource | null; |
| } |
|
|
| export interface ConceptRef { |
| concept_id: string; |
| label: string; |
| relation: string; |
| } |
|
|
| export interface ConceptRelationships { |
| computed_from: ConceptRef[]; |
| feeds_into: ConceptRef[]; |
| gated_by: ConceptRef[]; |
| gates: ConceptRef[]; |
| } |
|
|
| export interface ConceptDecision { |
| decision_id: string; |
| date: string | null; |
| question: string | null; |
| decision: string | null; |
| rationale: string | null; |
| decided_in: string | null; |
| } |
|
|
| |
| |
| export type CrosswalkKind = |
| | "exactMatch" |
| | "broadMatch" |
| | "narrowMatch" |
| | "relatedMatch" |
| | "noMatch" |
| | "conflict"; |
|
|
| |
| export interface CrosswalkSide { |
| standard: string; |
| label: string; |
| } |
|
|
| |
| |
| |
| export interface CrosswalkEdge { |
| from: CrosswalkSide; |
| to: CrosswalkSide; |
| kind: CrosswalkKind; |
| certainty: "certain" | "uncertain"; |
| rationale: string; |
| } |
|
|
| export interface RegistryConcept { |
| concept_id: string; |
| category: string; |
| label: string; |
| assertion_type: AssertionType; |
| cardinality: Cardinality; |
| derived: DerivedRule | null; |
| cited_to: string; |
| evidence: ConceptEvidence; |
| relationships: ConceptRelationships; |
| decisions: ConceptDecision[]; |
| crosswalk: CrosswalkEdge[]; |
| } |
|
|
| export interface RegistryCategory { |
| id: string; |
| concept_count: number; |
| open_count: number; |
| } |
|
|
| export interface ConceptRegistry { |
| categories: RegistryCategory[]; |
| concepts: RegistryConcept[]; |
| } |
|
|
| |
| |
| |
| |
|
|
| |
| |
| |
| export interface MappingResolutionCandidate { |
| label: string; |
| concept_id: string | null; |
| relation: string; |
| tradeoff: string; |
| } |
|
|
| |
| export interface MappingReviewDraft { |
| question: string; |
| candidates: MappingResolutionCandidate[]; |
| } |
|
|
| |
| |
| export type MappingDisposition = "confirmed" | "flagged" | "deferred"; |
|
|
| |
| export type MappingDecidedVia = "candidate" | "written" | "chat" | "flag" | "defer"; |
|
|
| |
| |
| export type MappingAttention = "confident" | "needs_judgment"; |
|
|
| export interface MappingConfirmation { |
| mapping_id: string; |
| source_field: string; |
| concept_id: string | null; |
| relation: string; |
| predicate: string; |
| confirmed_by: string; |
| role: string; |
| note: string | null; |
| licence_required: boolean; |
| confirmed_at: string; |
| disposition: MappingDisposition; |
| decided_via: MappingDecidedVia | null; |
| question: string | null; |
| options_json: string | null; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| export interface MappingEdgeComponent { |
| concept_id: string; |
| concept_label: string; |
| relation: string; |
| predicate: string; |
| category: string | null; |
| } |
|
|
| export interface MappingEdge { |
| mapping_id: string; |
| source_std: string; |
| source_field: string; |
| source_label: string; |
| concept_id: string | null; |
| concept_label: string | null; |
| category: string | null; |
| relation: string; |
| predicate: string; |
| confidence: number; |
| note: string; |
| is_unresolved: boolean; |
| queued: boolean; |
| attention: MappingAttention; |
| review: MappingReviewDraft | null; |
| confirmation: MappingConfirmation | null; |
| |
| components: MappingEdgeComponent[]; |
| } |
|
|
| |
| |
| |
| export interface MappingDecision { |
| mapping_id: string; |
| source_field: string; |
| source_label: string; |
| disposition: MappingDisposition; |
| decided_via: MappingDecidedVia | null; |
| question: string | null; |
| options: string[]; |
| concept_id: string | null; |
| concept_label: string | null; |
| relation: string; |
| predicate: string; |
| note: string | null; |
| confirmed_by: string; |
| role: string; |
| confirmed_at: string; |
| filed_to: { edge: string; table: string }; |
| } |
|
|
| |
| export interface MappingProposalComponent { |
| concept_id: string; |
| relation: string; |
| concept_label: string; |
| } |
|
|
| |
| |
| |
| |
| export interface MappingProposal { |
| summary: string; |
| concept_id: string | null; |
| relation: string; |
| concept_label: string | null; |
| components: MappingProposalComponent[]; |
| } |
|
|
| |
| export interface MappingChatTurn { |
| role: "user" | "assistant"; |
| text: string; |
| } |
|
|
| export interface MappingChatRequest { |
| mapping_id: string; |
| question: string; |
| history: MappingChatTurn[]; |
| } |
|
|
| |
| |
| export interface MappingChatResponse { |
| mapping_id: string; |
| reply: string; |
| proposal: MappingProposal | null; |
| } |
|
|
| export interface MappingConcept { |
| concept_id: string; |
| label: string; |
| category: string; |
| assertion_type: AssertionType; |
| } |
|
|
| export interface MappingSourceField { |
| name: string; |
| label: string; |
| licence_required: boolean; |
| } |
|
|
| |
| |
| |
| export interface MappingFieldSetRow { |
| source_field: string; |
| source_label: string; |
| concept_id: string | null; |
| relation: string; |
| predicate: string; |
| licence_required: boolean; |
| confirmed_by: string | null; |
| confirmed_at: string | null; |
| origin: "confirmed" | "candidate"; |
| } |
|
|
| |
| |
| |
|
|
| export type FieldCardKind = "confirmed" | "derived" | "not_applicable"; |
| export type FieldAttention = "confident" | "needs_judgment"; |
| export type FieldPromotion = "confirmed_eligible" | "needs_review"; |
| export type FieldExtractionState = |
| | "present" |
| | "not_applicable" |
| | "not_stated" |
| | "indeterminate" |
| | "determined_by_join" |
| | "constrained"; |
|
|
| |
| export interface ValidationCheck { |
| name: "type" | "enum" | "cardinality" | "state"; |
| status: "pass" | "fail" | "not_applicable"; |
| detail: string; |
| } |
|
|
| |
| export interface FieldDerivation { |
| status: |
| | "not_derived" |
| | "matched" |
| | "mismatched" |
| | "inputs_absent" |
| | "rule_not_implemented" |
| | "not_checked"; |
| rule: string | null; |
| inputs: string[]; |
| input_labels: { concept_id: string; label: string }[]; |
| recomputed: unknown; |
| extracted: unknown; |
| detail: string; |
| } |
|
|
| |
| |
| export interface FieldValidation { |
| concept_id: string; |
| assertion_type: AssertionType; |
| cardinality: Cardinality; |
| state: FieldExtractionState; |
| value: unknown; |
| evidence: EvidenceSpan | null; |
| checks: ValidationCheck[]; |
| derivation: FieldDerivation; |
| promotion: FieldPromotion; |
| reasons: string[]; |
| } |
|
|
| |
| |
| export interface CaseFieldDecision { |
| field_name: string; |
| label: string; |
| value: unknown; |
| status: FieldStatus; |
| disposition: string; |
| decided_via: string | null; |
| question: string | null; |
| options: string[]; |
| note: string | null; |
| confirmed_by: string; |
| role: string; |
| confirmed_at: string; |
| filed_to: { field: string; table: string }; |
| } |
|
|
| |
| |
| export interface CaseFieldBlock { |
| field_name: string; |
| label: string; |
| value: unknown; |
| value_type: "string" | "number" | "boolean"; |
| enum_values: string[] | null; |
| evidence: EvidenceSpan | null; |
| status: FieldStatus; |
| applicable: boolean; |
| not_applicable_reason: string | null; |
| concept_id: string | null; |
| concept_label: string | null; |
| assertion_type: AssertionType | null; |
| card_kind: FieldCardKind; |
| attention: FieldAttention; |
| validation: FieldValidation; |
| decision: CaseFieldDecision | null; |
| } |
|
|
| export interface CaseReviewSection { |
| title: string; |
| fields: CaseFieldBlock[]; |
| } |
|
|
| export interface CaseReviewData { |
| case_barcode: string; |
| patient_filename: string | null; |
| report_date: string | null; |
| staging_edition: string; |
| status: CaseStatus; |
| page_count: number; |
| sections: CaseReviewSection[]; |
| progress: { confirmed: number; applicable: number; confirmed_eligible: number; total: number }; |
| ledger: CaseFieldDecision[]; |
| } |
|
|
| |
| |
| export interface FieldDecisionContext { |
| confirmer: string; |
| role: string; |
| note?: string | null; |
| decided_via?: string | null; |
| question?: string | null; |
| options?: string[] | null; |
| } |
|
|
| |
| export interface FieldChatEvidence { |
| fact: string; |
| source: string; |
| } |
|
|
| export interface FieldChatTurn { |
| role: "user" | "assistant"; |
| text: string; |
| } |
|
|
| export interface FieldChatRequest { |
| question: string; |
| history: FieldChatTurn[]; |
| } |
|
|
| |
| |
| export interface FieldChatResponse { |
| field_name: string; |
| answer: string; |
| reasoning: string; |
| evidence: FieldChatEvidence[]; |
| suggested_value: unknown; |
| suggested_state: string | null; |
| } |
|
|
| export interface MappingReview { |
| source_std: string; |
| source: { std: string; title: string; version: string }; |
| threshold: number; |
| categories: string[]; |
| concepts: MappingConcept[]; |
| source_fields: MappingSourceField[]; |
| edges: MappingEdge[]; |
| queue: { total: number; resolved: number; remaining: number; parked: number }; |
| confirmed: boolean; |
| field_set: MappingFieldSetRow[] | null; |
| ledger: MappingDecision[]; |
| } |
|
|
| export interface MappingConfirmRequest { |
| mapping_id: string; |
| concept_id: string | null; |
| relation: string; |
| confirmer: string; |
| role: string; |
| note?: string | null; |
| licence_required?: boolean; |
| disposition?: MappingDisposition; |
| decided_via?: MappingDecidedVia | null; |
| question?: string | null; |
| options?: string[] | null; |
| |
| |
| components?: { concept_id: string; relation: string }[]; |
| } |
|
|