import { ViewDefinition } from '@medplum/fhirtypes';
export const eobClaimsOverview = {
resourceType: 'ViewDefinition',
resource: 'ExplanationOfBenefit',
name: 'eob-claims-overview',
status: 'active',
description: 'Lightweight overview of all EOB types for search and filtering',
select: [
{
column: [
{
name: 'id',
path: 'getResourceKey()',
description: 'Unique identifier for the EOB resource',
},
{
name: 'type',
path: "type.coding.where(system='http://terminology.hl7.org/CodeSystem/claim-type').code.first()",
description: 'Claim type: pharmacy, institutional, professional, or vision',
},
{
name: 'subType',
path: 'subType.coding.code.first()',
description: 'Claim subtype (e.g., inpatient, outpatient)',
},
{
name: 'status',
path: 'status',
description: 'Status of the EOB',
},
{
name: 'outcome',
path: 'outcome',
description: 'Outcome of the EOB',
},
{
name: 'billablePeriod_start',
path: 'billablePeriod.start',
description: 'Service start date',
},
{
name: 'billablePeriod_end',
path: 'billablePeriod.end',
description: 'Service end date',
},
{
name: 'created',
path: 'created',
description: 'Date the EOB resource was created',
},
{
name: 'payment_date',
path: 'payment.date',
description: 'Date when payment was made',
},
{
name: 'diagnosis_codes',
path: 'diagnosis.diagnosisCodeableConcept.coding.code.distinct()',
collection: true,
description: 'All diagnosis codes from this claim',
},
{
name: 'diagnosis_systems',
path: 'diagnosis.diagnosisCodeableConcept.coding.system.distinct()',
collection: true,
description: 'Code systems for diagnoses (e.g., ICD-10)',
},
{
name: 'procedure_codes',
path: 'procedure.procedureCodeableConcept.coding.code.distinct()',
collection: true,
description: 'All procedure codes from this claim',
},
{
name: 'procedure_systems',
path: 'procedure.procedureCodeableConcept.coding.system.distinct()',
collection: true,
description: 'Code systems for procedures (e.g., ICD-10-PCS)',
},
{
name: 'service_codes',
path: 'item.productOrService.coding.code.distinct()',
collection: true,
description: 'Service/product codes (CPT, HCPCS, NDC, etc.)',
},
{
name: 'service_systems',
path: 'item.productOrService.coding.system.distinct()',
collection: true,
description: 'Code systems for services',
},
{
name: 'medication_codes',
path: "item.where(productOrService.coding.system.contains('ndc')).productOrService.coding.code.distinct()",
collection: true,
description: 'NDC codes for medications (pharmacy claims only)',
},
{
name: 'item_productOrService_display',
path: 'item.productOrService.coding.display.distinct()',
collection: true,
description: 'Display names for products/services/medications from items',
},
{
name: 'provider_reference',
path: 'provider.reference',
description: 'Reference to the primary provider',
},
{
name: 'provider_display',
path: 'provider.display',
description: 'Provider display name if available',
},
{
name: 'insurer_reference',
path: 'insurer.reference',
description: 'Reference to the insurance organization',
},
{
name: 'insurer_display',
path: 'insurer.display',
description: 'Insurer display name if available',
},
{
name: 'facility_reference',
path: 'facility.reference',
description: 'Reference to the facility (institutional claims)',
},
{
name: 'facility_display',
path: 'facility.display',
description: 'Facility display name if available',
},
{
name: 'careTeam_provider_references',
path: "careTeam.provider.reference.join(',')",
description: 'References to all care team members',
},
{
name: 'careTeam_provider_displays',
path: "careTeam.provider.display.join(',')",
description: 'Display names for care team members',
},
{
name: 'total_submitted',
path: "total.where(category.coding.where(system='http://terminology.hl7.org/CodeSystem/adjudication').code='submitted').amount.value.first()",
description: 'Total amount submitted',
},
{
name: 'total_benefit',
path: "total.where(category.coding.where(system='http://terminology.hl7.org/CodeSystem/adjudication').code='benefit').amount.value.first()",
description: 'Total benefit amount paid by insurance',
},
{
name: 'total_memberliability',
path: "total.where(category.coding.where(system='http://hl7.org/fhir/us/carin-bb/CodeSystem/C4BBAdjudication').code='memberliability').amount.value.first()",
description: 'Total amount patient is responsible for',
},
{
name: 'total_deductible',
path: "total.where(category.coding.where(system='http://terminology.hl7.org/CodeSystem/adjudication').code='deductible').amount.value.first()",
description: 'Total deductible amount',
},
{
name: 'total_copay',
path: "total.where(category.coding.where(system='http://hl7.org/fhir/us/carin-bb/CodeSystem/C4BBAdjudication').code='copay').amount.value.first()",
description: 'Total copay amount',
},
{
name: 'claim_type_details',
path: "supportingInfo.where(category.coding.code='typeofbill').code.coding.code.first()",
description: 'Type of bill code for institutional claims',
},
],
},
],
} as ViewDefinition;