"""Global variables."""

from polars import Boolean, Datetime, Int64, Schema, String

URI = "https://apps.sjdhospitalbarcelona.org/redcap/api/"

COLNAMES = {
    "participants": [
        "record_id",
        "date_created",
        "date_updated",
        "source",
        "name",
        "age_created_months",
        "age_created_days",
        "sex",
        "twin",
        "isdropout",
        "parent1_name",
        "parent1_surname",
        "email1",
        "phone1",
        "parent2_name",
        "parent2_surname",
        "email2",
        "phone2",
        "address",
        "city",
        "postcode",
        "birth_type",
        "gest_weeks",
        "birth_weight",
        "head_circumference",
        "apgar1",
        "apgar2",
        "apgar3",
        "hearing",
        "diagnoses",
        "comments",
        "age_now_months",
        "age_now_days",
    ],
    "appointments": [
        "record_id",
        "appointment_id",
        "study",
        "status",
        "date",
        "date_created",
        "date_updated",
        "transport",
        "taxi_address",
        "taxi_isbooked",
        "confirmation_comments",
        "comments",
    ],
    "questionnaires": [
        "record_id",
        "questionnaire_id",
        "date_created",
        "date_updated",
        "isestimated",
        "lang1",
        "lang1_exp",
        "lang2",
        "lang2_exp",
        "lang3",
        "lang3_exp",
        "lang4",
        "lang4_exp",
        "comments",
        "complete",
    ],
}

FIELDS_TO_RENAME = [
    "participant_sex",
    "participant_birth_type",
    "participant_hearing",
    "participant_source",
    "appointment_study",
    "appointment_status",
    "appointment_transport",
    "language_lang1",
    "language_lang2",
    "language_lang3",
    "language_lang4",
]


INT_FIELDS = [
    "age_created_months",
    "age_created_days",
    "age_now_months",
    "age_now_days",
    "gest_weeks",
    "birth_weight",
    "head_circumference",
    "apgar1",
    "apgar2",
    "apgar3",
]

SCHEMA = {
    "participants": Schema(
        [
            ("record_id", String),
            ("date_created", Datetime(time_unit="us", time_zone=None)),
            ("date_updated", Datetime(time_unit="us", time_zone=None)),
            ("source", String),
            ("is_born", Boolean),
            ("name", String),
            ("age_created_months", Int64),
            ("age_created_days", Int64),
            ("sex", String),
            ("twin", String),
            ("isdropout", Boolean),
            ("parent1_name", String),
            ("parent1_surname", String),
            ("email1", String),
            ("phone1", String),
            ("parent2_name", String),
            ("parent2_surname", String),
            ("email2", String),
            ("phone2", String),
            ("address", String),
            ("city", String),
            ("postcode", String),
            ("birth_type", String),
            ("gest_weeks", Int64),
            ("birth_weight", Int64),
            ("head_circumference", Int64),
            ("apgar1", Int64),
            ("apgar2", Int64),
            ("apgar3", Int64),
            ("hearing", String),
            ("diagnoses", String),
            ("comments", String),
            ("age_now_months", Int64),
            ("age_now_days", Int64),
        ]
    ),
    "appointments": Schema(
        [
            ("record_id", String),
            ("redcap_repeat_instance", Int64),
            ("study", String),
            ("date_created", Datetime(time_unit="us", time_zone=None)),
            ("date_updated", Datetime(time_unit="us", time_zone=None)),
            ("date", Datetime(time_unit="us", time_zone=None)),
            ("transport", String),
            ("taxi_address", String),
            ("taxi_isbooked", Boolean),
            ("status", String),
            ("confirmation_comments", String),
            ("comments", String),
            ("id", String),
        ]
    ),
    "questionnaires": Schema(
        [
            ("record_id", String),
            ("redcap_repeat_instance", Int64),
            ("date_created", Datetime(time_unit="us", time_zone=None)),
            ("date_updated", Datetime(time_unit="us", time_zone=None)),
            ("isestimated", Boolean),
            ("lang1", String),
            ("lang1_exp", Int64),
            ("lang2", String),
            ("lang2_exp", Int64),
            ("lang3", String),
            ("lang3_exp", Int64),
            ("lang4", String),
            ("lang4_exp", Int64),
            ("comments", String),
            ("complete", String),
        ]
    ),
}
