// ENUMS
import {Country, DiagnosisQuestionItem} from "../../core/commonTypes";

// ENUMS
export enum PatientMgmtEventType {
    Patient = "patient",
    Encounter = "encounter",
    Appointment = "appointment",
    Other = "other",
}

export enum PatientMgmtCatalogType {
    UserHcw = "user_chw",
    Patient = "patient"
}

export enum HcwSiteCategory {
    Facility = "facility",
    Community = "community",
    PatientAddress = "patient_address",
    Virtual = "virtual",
    Other = "other"
}

export enum AppointmentFollowupType {
    PhoneCall = "phone_call",
    SMS = "sms",
    WhatsApp = "whatsapp",
    HouseVisit = "house_visit",
    Other = "other"
}

export enum AppointmentStatus {
    Upcoming = "upcoming",
    Missed = "missed",
    Attended = "attended",
    Other = "other"
}

export enum CounselingType {
    Lifestyle = "lifestyle",
    Psychological = "psychological",
    Other = "other"
}

export enum DiagnosisCategory {
    Computed = "computed",
    Given = "given",
    Other = "other"
}

export enum DiagnosisQuestionnaireCategory {
    MedicalReview = "medical_review",
    Assessment = "assessment",
    Diagnostic = "diagnostic",
    Other = "other"
}

export enum DiagnosisQuestionnaireOutcomeType {
    RiskStatus = "risk_status",
    RiskScore = "risk_score",
    Other = "other"
}

export enum DiagnosisStatusValueType {
    Positive= "positive",
    Negative= "negative",
    Recovered= "recovered",
    Unknown= "unknown",
    NA = "n_a",
    Other = "other"
}

export enum DiagnosisStatusRiskType {
    Low = "low",
    High = "high",
    Unknown = "unknown",
    NA = "n_a",
    Other = "other"
}

export enum DiagnosisSubType {
    Age = "age",
    Gender = "gender",
    Height = "height",
    Weight = "weight",
    Smoker = "smoker",
    BloodPressure = "blood_pressure",
    BloodPressureSystolic = "blood_pressure_systolic",
    BloodPressureDiastolic = "blood_pressure_diastolic",
    MUAC = "muac",
    BloodGlucose = "blood_glucose",
    HbA1c = "hbA1c",
    Temperature = "temperature",
    Bmi = "bmi",
    Cvd = "cvd",
    Phq4 = "phq_4",
    Phq9 = "phq_9",
    Gad7 = "gad_7",
    PregnancyStatus = "pregnancy_status",
    PregnancyDangerSigns = "pregnancy_danger_signs",
    SuicidalIdeation = "suicidal_ideation",
    HighRiskPregnancy = "high_risk_pregnancy",
    Other = "other"
}

export enum DiagnosisSymptomType {
    Bio = "bio",
    HIV = "hiv",
    NCD = "ncd",
    TB = "tb",
    ECD = "ecd",
    Diabetes = "diabetes",
    Hypertension = "hypertension",
    Pregnancy = "pregnancy",
    MentalHealth = "mental_health",
    SubstanceUseDisorder = "substance_use_disorder",
    AdolescentHealth = "adolescent_health",
    GeneralScreening = "general_screening",
    Gynecologic = "gynecologic",
    Antenatal = "antenatal",
    Postnatal = "postnatal",
    CervicalCancer = "cervical_cancer",
    Lifestyle = "lifestyle",
    Psychological = "psychological",
    GenderBasedViolence = "gender_based_violence",
    SexualBehaviour = "sexual_behaviour",
    EconomicStrength = "economic_strengthening",
    Other = "other",
}

export enum DiagnosisType {
    Bio = "bio",
    HIV = "hiv",
    NCD = "ncd",
    TB = "tb",
    ECD = "ecd",
    Diabetes = "diabetes",
    Hypertension = "hypertension",
    Pregnancy = "pregnancy",
    MentalHealth = "mental_health",
    SubstanceUseDisorder = "substance_use_disorder",
    AdolescentHealth = "adolescent_health",
    GeneralScreening = "general_screening",
    Gynecologic = "gynecologic",
    Antenatal = "antenatal",
    Postnatal = "postnatal",
    CervicalCancer = "cervical_cancer",
    Lifestyle = "lifestyle",
    Psychological = "psychological",
    GenderBasedViolence = "gender_based_violence",
    SexualBehaviour = "sexual_behaviour",
    EconomicStrength = "economic_strengthening",
    Other = "other",
}


export enum EncounterType {
    Screening = "screening",
    Assessment = "assessment",
    Enrolment = "enrolment",
    MedicalReview = "medical_review",
    Counseling = "counseling",
    Other = "other"
}

export enum FrequencyType {
    Daily = "daily",
    Days = "days",
    Weeks = "weeks",
    Months = "months",
    Other = "other"
}

export enum HcwItemAction {
    View = "view",
    Add = "add",
    Update = "update",
    Remove = "remove",
    Done = "done",
    Other = "other"
}

export enum PatientType {
    Triage = "triage",
    Outpatient = "outpatient",
    Inpatient = "inpatient",
    Pharmacy = "pharmacy",
    DoorToDoor = "door_to_door",
    Camp = "camp",
    Other = "other"
}

export enum PrescriptionItemFrequency {
    AM = "AM",
    PM = "PM",
    OD = "OD",
    BD = "BD",
    TDS = "TDS",
    QDS = "QDS",
    OM = "OM",
    ON = "ON",
    CC = "CC",
    PC = "PC",
    AC = "AC",
    PRN = "PRN",
    Other = "other"
}

export enum PrescriptionItemFormulationType {
    Tablet = "tablet",
    Capsule = "capsule",
    Syrup = "syrup",
    Injection = "injection",
    Insulin = "insulin",
    Contraceptive = "contraceptive",
    Other = "other"
}

export enum ScheduleItemType {
    MedicalReview = "medical_review",
    Assessment = "assessment",
    Other = "other"
}

// Item Objects

export interface AppointmentItem {
    id: string,
    hcw_id: string,
    category: HcwSiteCategory,
    status: AppointmentStatus,
    time: number,
    is_time_sensitive: boolean,
    type_list: Array<ScheduleItemType>,
    sub_type_list: Array<DiagnosisType>,
    update?: AppointmentUpdateItem,
    missed?: AppointmentMissedItem,
}

export interface AppointmentUpdateItem {
    id: string,
    reason: string,
    prev_time: number,
}

export interface AppointmentMissedItem {
    id: string,
    type: AppointmentFollowupType,
    time: number,
    response: string,
}

export interface CounselingPlanItem {
    name: string,
    action: HcwItemAction,
    clinician_notes?: string,
    assessment_remarks?: string,
    counselor_notes?: string,
    referral_date?: number,
    assessment_date?: number,
    referred_by?: string,
    assessed_by?: string,
    remarks?: string
}

export interface ImmunizationItem {
    id: string,
    action: HcwItemAction,
    type: string,
    dose: number,
    status: boolean,
    date?: number,
    remarks?: string
}

export interface DiagnosisItem {
    type: DiagnosisType,
    sub_type: DiagnosisSubType,
    category: DiagnosisCategory,
    value: any,
    unit: string,
    observation_time?: number,
    remarks?: string,
}

export interface DiagnosisOutcomeItem {
    type: DiagnosisQuestionnaireOutcomeType,
    sub_type?: string,
    value: any,
    remarks?: string,
}

export interface DiagnosisQuestionnaireObject {
    type: DiagnosisType,
    sub_type: DiagnosisSubType,
    category: DiagnosisQuestionnaireCategory,
    question_list: Array<DiagnosisQuestionItem>,
    outcome_list: Array<DiagnosisOutcomeItem>,
    remarks?: string,
}

export interface DiagnosisStatusItem {
    type: DiagnosisType,
    sub_type?: string,
    action: HcwItemAction,
    status: DiagnosisStatusValueType,
    risk: DiagnosisStatusRiskType,
    diagnosis_date: number,
    is_confirmed?: boolean,
    remarks?: string,
    stage?: string,
    treatment_status?: string
}

export interface DiagnosisSymptomItem {
    type: DiagnosisSymptomType,
    symptoms_list: Array<string>,
    remarks?: string
}

export interface DiagnosticElementItem {
    id: string,
    investigation_list: Array<InvestigationItem>,
    biometric_list: Array<DiagnosisItem>,
    sign_symptom_list: Array<DiagnosisSymptomItem>,
    treatment_adherence_list: Array<TreatmentAdherenceItem>,
    health_questionnaire_list: Array<DiagnosisQuestionnaireObject>
}

export interface EncounterSummaryObject {
    id: string,
    appointment_id?: string,
    encounter_time: number,
    hcw_id_list: Array<string>,
    prev_diagnosis_status_list: Array<DiagnosisStatusItem>,
    diagnosis_status_list: Array<DiagnosisStatusItem>,
    prev_treatment_plan?: TreatmentPlanItem,
    treatment_plan?: TreatmentPlanItem,
    main_complaints_list: Array<string>,
    diagnostic_elements?: DiagnosticElementItem,
    pregnancy_details?: PregnancyDetailObject,
    counseling_list?: Array<CounselingPlanItem>,
    immunization_list?: Array<ImmunizationItem>,
    remarks?: string,
    is_followup_id?: string,
    is_referral_id?: string,
    has_followup?: boolean,
    has_referral?: boolean,
}

export interface InvestigationItem {
    name: string,
    test_value: string,
    test_unit: string,
    ordered_date: number,
    tested_date: number,
    action: HcwItemAction,
    remarks: string
}

export interface PregnancyDetailObject {
    pregnancy_status: boolean,
    last_menstrual_period?: number,
    high_risk: boolean,
    gravida?: number,
    parity?: number,
    n_fetus?: number,
    neonatal_outcome?: string,
    maternal_outcome?: string,
}

export interface PrescriptionItem {
    id: string,
    name: string,
    dosage_value?: number,
    dosage_unit: string,
    formulation: PrescriptionItemFormulationType,
    type: DiagnosisType,
    frequency: PrescriptionItemFrequency,
    prescribed_days?: number,
    dispensed_days?: number,
    prescription_date?: number,
    action: HcwItemAction,
    remarks?: string
}

export interface ScheduleItem {
    type: ScheduleItemType,
    sub_type: DiagnosisType,
    value: number,
    frequency: FrequencyType,
    action: HcwItemAction,
    remarks?: string
    start_date?: number,
    end_date?: number
}

export interface TreatmentAdherenceItem {
    type: string,
    medication_adherence: string,
    lack_adherence_reason?: string
    remarks?: string
}

export interface TreatmentPlanItem {
    followup_list: Array<ScheduleItem>,
    prescription_list: Array<PrescriptionItem>,
    investigation_list: Array<InvestigationItem>
}



// EVENT PROPERTIES

export interface PatientProperties {
    patient_id: string,
    site_id: string,
    action: HcwItemAction,
    is_from_gho: boolean,
    category: HcwSiteCategory,
    type: PatientType,
    sub_type?: string,
    biometric_list?: Array<DiagnosisItem>,
    pregnancy_details?: PregnancyDetailObject,
    registration_date?: number,
    meta?: any
}

export interface EncounterProperties {
    patient_id: string,
    site_id: string,
    action: HcwItemAction,
    category: HcwSiteCategory,
    type: EncounterType,
    sub_type: DiagnosisType,
    encounter_summary: EncounterSummaryObject,
    meta?: any
}

export interface AppointmentProperties {
    patient_id: string,
    site_id: string,
    action: HcwItemAction,
    appointment: AppointmentItem,
    meta?: any
}


// CATALOG VALUES

export interface HcwCatalogModel {
    id : string,
    name?: string,
    role?: string,
    site_id_list?: Array<string>,
    supervisor_id_list?: Array<string>
}

export interface PatientCatalogModel {
    id : string,
    country?: Country,
    region_state?: string,
    city?: string,
    profession?: string,
    education_level?: string,
    site_id_list?: Array<string>,
    insurance_id?: string,
    insurance_type?: string,
    insurance_status?: boolean,
    landmark?: string,
    phone_number_category?: string,
    program_id?: string,
    family_id?: string,
    hw_id_list?: Array<string>,
    buddy_id_list?: Array<string>,
    transport_mode?: string,
    marital_status?: string,
    employment_status?: string,
    nationality?: string,
    has_whatsapp?: boolean,
    has_email?: boolean,
}

