/*
 * File: patient.ts
 * Description: Patient-related type definitions for medical data
 * Design & Developed by Tech4Biz Solutions
 * Copyright (c) Spurrin Innovations. All rights reserved.
 */

// DICOM Patient Details Interface
export interface PatientDetails {
  Date: string;
  Name: string;
  PatID: string;
  PatAge: string;
  PatSex: string;
  Status: string;
  InstName: string;
  Modality: 'DX' | 'CT' | 'MR';
  ReportStatus: string | null;
}

// DICOM Series Interface
export interface Series {
  Path: string[];
  SerDes: string;
  ViePos: string | null;
  pngpath: string;
  SeriesNum: string;
  ImgTotalinSeries: string;
}

// Medical Case Interface (Main Patient Record)
export interface MedicalCase {
  id: number;
  patientdetails: PatientDetails | string; // Can be object or JSON string
  series: Series[] | string; // Can be array or JSON string
  created_at: string;
  updated_at: string;
  series_id: string | null;
  type: 'Critical' | 'Routine' | 'Emergency';
}

// Legacy Patient interface for backward compatibility
export interface Patient extends MedicalCase {}

export type PatientStatus = 
  | 'ACTIVE'
  | 'PENDING'
  | 'DISCHARGED'
  | 'TRANSFERRED'
  | 'CRITICAL';

export type AlertPriority = 
  | 'CRITICAL'
  | 'HIGH'
  | 'MEDIUM'
  | 'LOW';

export interface VitalSigns {
  bloodPressure: {
    systolic: number;
    diastolic: number;
    timestamp: Date;
  };
  heartRate: {
    value: number;
    timestamp: Date;
  };
  temperature: {
    value: number;
    timestamp: Date;
  };
  respiratoryRate: {
    value: number;
    timestamp: Date;
  };
  oxygenSaturation: {
    value: number;
    timestamp: Date;
  };
}

export interface Allergy {
  id: string;
  name: string;
  severity: 'MILD' | 'MODERATE' | 'SEVERE';
  reaction: string;
  notes?: string;
}

export interface Medication {
  id: string;
  name: string;
  dosage: string;
  frequency: string;
  route: string;
  startDate: Date;
  endDate?: Date;
  status: 'ACTIVE' | 'DISCONTINUED' | 'COMPLETED';
  prescribedBy: string;
}

export interface MedicalHistory {
  id: string;
  condition: string;
  diagnosisDate: Date;
  status: 'ACTIVE' | 'RESOLVED' | 'CHRONIC';
  notes?: string;
  treatingPhysician: string;
}

export interface ScanResult {
  id: string;
  patientId: string;
  scanType: 'CT' | 'MRI' | 'XRAY' | 'ULTRASOUND';
  bodyPart: string;
  status: 'PENDING' | 'IN_PROGRESS' | 'COMPLETED' | 'REVIEWED';
  orderedBy: string;
  orderedDate: Date;
  completedDate?: Date;
  reviewedBy?: string;
  reviewedDate?: Date;
  findings: string;
  aiSummary?: string;
  images: string[];
  priority: AlertPriority;
}

export interface PatientCareState {
  // Patients data (Medical Cases)
  patients: MedicalCase[];
  currentPatient: MedicalCase | null;
  
  // Loading states
  isLoading: boolean;
  isRefreshing: boolean;
  isLoadingPatientDetails: boolean;
  
  // Error handling
  error: string | null;
  
  // Search and filtering
  searchQuery: string;
  selectedFilter: 'all' | 'Critical' | 'Routine' | 'Emergency';
  sortBy: 'date' | 'name' | 'age';
  sortOrder: 'asc' | 'desc';
  
  // Pagination
  currentPage: number;
  itemsPerPage: number;
  totalItems: number;
  
  // Cache
  lastUpdated: string | null;
  cacheExpiry: string | null;
}

/*
 * End of File: patient.ts
 * Design & Developed by Tech4Biz Solutions
 * Copyright (c) Spurrin Innovations. All rights reserved.
 */ 