from SpectrumCommon.Const.IH import *
import SpectrumCommon.Const.IH.IHTags as ihmvt
from SpectrumCommon.Modvars.GB.GBDefs import *
# from SpectrumCommon.Modvars.IH.IHIndices import *


ih_program_area_types_dim = 'program_area_types'
ih_program_area_types_ids = {
    IH_MATERNAL_NEWBORN_HEALTH_MST_ID : 'IH_MATERNAL_NEWBORN_HEALTH_MST_ID'   ,
    IH_SEXUAL_REPROD_HEALTH_MST_ID    : 'IH_SEXUAL_REPROD_HEALTH_MST_ID',
    UH_ChildHealthMstID               : 'UH_ChildHealthMstID',
    UH_VaccinationMstID               : 'UH_VaccinationMstID',
    UH_MalariaMstID                   : 'UH_MalariaMstID',
    IH_TB_MST_ID                      : 'IH_TB_MST_ID',
    IH_HIV_AIDS_MST_ID                : 'IH_HIV_AIDS_MST_ID',
    UH_NutritionMstID                 : 'UH_NutritionMstID',
    UH_WASHMstID                      : 'UH_WASHMstID',
    IH_NCD_MST_ID                     : 'IH_NCD_MST_ID',
    UH_MentalNueroSubsUseDisMstID     : 'UH_MentalNueroSubsUseDisMstID',
    UH_AdolescentHealthMstID          : 'UH_AdolescentHealthMstID',
    IH_NTD_MST_ID                     : 'IH_NTD_MST_ID'
}

ih_subgroup_types_dim = 'subgroup_types'
ih_subgroup_types_ids = {
    5: "Management of ectopic pregnancy care",
    6: "Pregancy care - ANC",
    7: "Pregnancy care - Treatment of pregnancy complications",
    8: "Childbirth care - Facility births",
    9: "Childbirth care - Home births",
    10: "Childbirth care - Other",
    11: "Postpartum care - Treatment of sepsis",
    12: "Postpartum care - Treatment of newborn sepsis",
    13: "Postpartum care - Other",
    14: "Other sexual and reproductive health",
    42: "Other",
    112: "Family planning",
    113: "Abortion",
    85: "General",
    16: "Diarrhea management",
    17: "Pneumonia",
    18: "Malaria",
    19: "Measles",
    86: "General",
    79: "Prevention",
    80: "Case management",
    90: "Screening (provider-initiated)",
    91: "TB infection prevention, testing (provider-initiated)",
    92: "TB infection prevention, medication (provider-initiated)",
    93: "Case finding (patient-initiated)",
    94: "Diagnosis (patient-initiated)",
    95: "Diagnosis (provider-initiated)",
    96: "Drug resistance detection",
    97: "Treatment, drug-susceptible",
    98: "Treatment, drug-resistant",
    99: "Surgery",
    100: "First-line drug treatment monitoring ",
    101: "Second-line drug treatment monitoring ",
    102: "Adverse events treatment",
    103: "Non-medical support",
    104: "Palliative care",
    108: "TB and other diseases infection prevention, medication",
    109: "HIV treatment, first-line",
    110: "Vaccination",
    105: "Prevention",
    106: "Testing, treatment and care",
    107: "Social enablers",
    53: "Women of reproductive age and adolescent girls",
    54: "Pregnant and lactating women",
    55: "Adults",
    56: "All populations",
    57: "Children",
    87: "General",
    34: "CVD & diabetes",
    35: "Breast cancer",
    36: "Cervical cancer",
    72: "Colorectal cancer",
    39: "Oral care and cancer",
    40: "Respiratory disease",
    41: "Emergency care",
    70: "Risk Factors",
    71: "Policy interventions - Under Programme Costing",
    68: "Anxiety disorders",
    43: "Depression",
    44: "Psychosis",
    45: "Bipolar disorder",
    46: "Epilepsy",
    47: "Developmental disorders",
    48: "Conduct disorders",
    67: "Attention disorders",
    49: "Dementia",
    50: "Alcohol use/dependence",
    51: "Drug use/dependence",
    52: "Self-harm/suicide",
    88: "General",
    75: "Mass drug administration",
    76: "Disease management",
    77: "Vector control",
    78: "Veterinary public health"
}


ih_deliv_chan_types_dim = 'delivery_channel_types'
ih_deliv_chan_types_ids = {
    1: "Community",
    2: "Outreach",
    5: "Prehospital emergency",
    6: "General outpatient services",
    4: "First referral",
    7: "Second referral and above",
}

ih_health_sys_admin_unit_types_dim = 'health_sys_admin_unit_types'
ih_health_sys_admin_unit_types_ids = {
    1: "National",
    2: "Province",
    3: "District",
    4: "Admin level 4",
    5: "Admin level 5",
}

ih_staff_types_dim = 'staff_types'
ih_staff_types_ids = {
    HW_GENERAL_MEDICAL_PRACTITIONERS_CURR_ID           : 'General medical practitioners',
    HW_SPECIAL_MEDICAL_PRACTITIONERS_CURR_ID           : 'Special medical practitioners',
    HW_CLINIC_OFF_SURG_TECHS_CURR_ID                   : 'Clinic off surg techs',
    HW_NURSING_PROFESSIONALS_CURR_ID                   : 'Nursing professionals',
    HW_MIDWIFERY_PROFESSIONALS_CURR_ID                 : 'Midwifery professionals',
    HW_MIDWIFERY_ASSOCIATE_PROFESSIONALS_CURR_ID       : 'Midwifery associate professionals',
    HW_NURSING_ASSOCIATE_PROFESSIONALS_CURR_ID         : 'Nursing associate professionals',
    HW_MED_PATH_LAB_TECHS_CURR_ID                      : 'Med path lab techs',
    HW_PHARM_TECHS_ASSIST_CURR_ID                      : 'Pharm techs assist',
    HW_MED_IMAGING_THERA_EQUIP_TECHS_CURR_ID           : 'Med imaging thera equip techs',
    HW_AMBULANCE_WORKERS_CURR_ID                       : 'Ambulance workers',
    HW_COMM_HLTH_WORKERS_CURR_ID                       : 'Comm hlth workers',
    HW_OTHER_STAFF_TYPE_CURR_ID                        : 'Other staff type',
    HW_DENTISTS_CURR_ID                                : 'Dentists',
    HW_DENTAL_ASSIST_THERAPISTS_CURR_ID                : 'Dental assist therapists',
    HW_MED_DENTAL_PROSTHETIC_REL_TECHS_CURR_ID         : 'Med dental prosthetic rel techs',
    HW_PHARMACISTS_CURR_ID                             : 'Pharmacists',
    HW_PARAMED_PRACTITIONERS_CURR_ID                   : 'Paramed practitioners',
    HW_ENVIRON_OCCUPAT_HEALTH_HYGIENE_PROF_CURR_ID     : 'Environ occupat health hygiene prof',
    HW_DIETICIANS_NUTRITIONISTS_CURR_ID                : 'Dieticians nutritionists',
    HW_AUDIOLOGISTS_SPEECH_THERAPISTS_CURR_ID          : 'Audiologists speech therapists',
    HW_OPTOMETRISTS_OPHTHALMIC_OPTICIANS_CURR_ID       : 'Optometrists ophthalmic opticians',
    HW_DISPENSING_OPTICIANS_CURR_ID                    : 'Dispensing opticians',
    HW_ENVIRON_OCCUPAT_HEALTH_INSPEC_ASSO_CURR_IDC     : 'Environ occupat health inspec asso curr idc',
    HW_TRAD_COMP_MED_PROF_CURR_ID                      : 'Trad comp med prof',
    HW_TRAD_COMP_MED_ASSOC_PROF_CURR_ID                : 'Trad comp med assoc prof',
    HW_HEALTH_CARE_ASSISTS_CURR_ID                     : 'Health care assists',
    HW_HOME_BASED_PERS_CARE_WORKERS_CURR_ID            : 'Home based pers care workers',
    HW_PERS_CARE_WORKERS_HEALTH_SERV_NOT_CLASS_CURR_ID : 'Pers care workers health serv not class',
    HW_PHYSIOTHERAPISTS_CURR_ID                        : 'Physiotherapists',
    HW_PHYSIOTHERAPY_TECHS_ASSISTS_CURR_ID             : 'Physiotherapy techs assists',
    HW_HEALTH_ASSOC_PROF_NOT_CLASS_CURR_ID             : 'Health assoc prof not class',
    HW_PSYCHOLOGISTS_CURR_ID                           : 'Psychologists',
    HW_SOCIAL_WORK_COUNSELLING_PROF_CURR_ID            : 'Social work counselling prof',
    HW_SOCIAL_WORK_ASSOC_PROF_CURR_ID                  : 'Social work assoc prof',
}
# tb_patient_shape = lambda d, **kwargs : gb_shape(d,'1D float',
#                                                   dim=['tb_patient'], 
#                                                   indices=[tb_patient_indices], **kwargs)


IH_modvar_shapes = {
    
        ihmvt.IH_VERSION_TAG_V1                                    : gb_int_shape('IHT version, may be deprecated'),
        ihmvt.IH_HLTH_SERV_ANAL_MODE_MST_ID_TAG_V1                 : gb_int_shape('Health serv analyses mode master id'),  # Programme or Delivery Channel Mode
        ihmvt.IH_PROG_AREA_DELIV_CHAN_FILTER_MST_ID_TAG_V1         : gb_int_shape('Program area/delivery channel filter master id'), # programme area or delivery channel mstID
        ihmvt.IH_MAX_CUST_INTERV_MST_ID_TAG_V1                     : gb_int_shape('Maximum custom intervention master id'),      
        ihmvt.IH_MOH_BUDGET_TAG_V1                                 : gb_float_shape('MOH budget'),                 
        ihmvt.IH_DATA_CHANGED_TAG_V1                               : gb_bool_shape('Data changed, may be deprecated'), 
        ihmvt.IH_PROJ_VALID_TAG_V1                                 : gb_bool_shape('Projection valid, may be deprecated'), 
        ihmvt.IH_USING_ADOL_STRATA_MODE_TAG_V1                     : gb_bool_shape('Use adol strata flag'),
        ihmvt.IH_USING_DIS_SPEC_COST_MODE_TAG_V1                   : gb_bool_shape('Use Dis Spec Codst flag'), 
        ihmvt.IH_USING_PHC_MODE_TAG_V1                             : gb_bool_shape('Use PHC flag'), 
        ihmvt.IH_USING_DEF_MED_STAFF_TYPES_TAG_V1                  : gb_bool_shape('Use default medical staff types flag'), 
        ihmvt.IH_USING_DEF_FAC_TYPES_TAG_V1                        : gb_bool_shape('Use default facility types flag'), 
        ihmvt.IH_USING_MOH_BUDGET_RES_TAG_V1                       : gb_bool_shape('Use MOH budget res flag flag'), 
        ihmvt.IH_USING_HPV_PROG_AREA_TAG_V1                        : gb_bool_shape('Use HPV program areas flag flag'), 
        ihmvt.IH_USING_WORK_HLTH_PROG_AREA_TAG_V1                  : gb_bool_shape('Use work health program area flag'), 
        ihmvt.IH_USING_TP_FROM_TIME_TAG_V1                         : gb_bool_shape('Use TB from time flag'), 
        ihmvt.IH_USING_TB_IMPACT_CALCS_TP_TAG_V1                   : gb_bool_shape('Use TB impact calcs flag'), 
        ihmvt.IH_USING_TB_DAT_TP_TAG_V1                            : gb_bool_shape('Use TB data TP flag'), 
        ihmvt.IH_USING_LOCAL_CURR_TAG_V1                           : gb_bool_shape('Use local currrency flag'), 
        ihmvt.IH_FILE_NAME_TAG_V1                                  : gb_str_shape('File name, may be deprecated'),                         
        ihmvt.IH_PROJ_VALID_DATE_TAG_V1                            : gb_str_shape('projection date, may be deprecated'),           
        ihmvt.IH_PROG_AREA_RECORDS_TAG_V1                          : gb_shape('Program area records', type='1D dict', 
                                                                            dim=[ih_program_area_types_dim],
                                                                            indices=[ih_program_area_types_ids], 
                                                                            innerShape={
                                                                                'progAreaID'  : gb_shape('Program area ID', type='str'),
                                                                                'name'  : gb_shape('Program area name', type='str'),
                                                                                'stringConstant'  : gb_shape('string constant', type='str'),
                                                                                'subgroupRecords'  : gb_shape('subgroup records', type='1D dict', 
                                                                                                            dim=[ih_subgroup_types_dim],
                                                                                                            indices=[ih_subgroup_types_ids], 
                                                                                                            innerShape={
                                                                                                                'subgroupID'  : gb_shape('Subgroup ID', type='str'),
                                                                                                                'name'  : gb_shape('Subgroup name', type='str'),
                                                                                                                'stringConstant'  : gb_shape('string constant', type='str'),
                                                                                                                'active'  : gb_bool_shape('active flag'),
                                                                                                                'custom'  : gb_bool_shape('Custom area flag'),
                                                                                                                }),
                                                                                'active'  : gb_bool_shape('active flag'),
                                                                                'custom'  : gb_bool_shape('Custom area flag'),
                                                                            },
                                                                            has_default=False
                                                                        ),       
        ihmvt.IH_DELIV_CHAN_RECORDS_TAG_V1                         : gb_shape('Delivery channel records', type='1D dict', 
                                                                            dim=[ih_deliv_chan_types_dim],
                                                                            indices=[ih_deliv_chan_types_ids],
                                                                            innerShape={
                                                                                'delivChanID'  : gb_shape('Delivery channel ID', type='str'),
                                                                                'name'  : gb_shape('Delivery channel name', type='str'),
                                                                                'stringConstant'  : gb_shape('string constant', type='str'),
                                                                                'active'  : gb_bool_shape('active flag'),
                                                                                'custom'  : gb_bool_shape('Custom area flag'),
                                                                            },
                                                                            has_default=False
                                                                        ),       
                                                                                        
        ihmvt.IH_PERC_PROG_MGMT_COSTS_PHC_VIS_TAG_V1               : gb_bool_shape('Percentage program management costs per PHC visit flag'),       
        ihmvt.IH_HR_FACTOR_PHC_TAG_V1                              : gb_float_shape('Health resource factor per PHC visit'),         
        ihmvt.IH_LG_PERC_DRUG_SUPP_COSTS_PHC_TAG_V1                : gb_int_shape('Logistics percentage drug/supply costs per PHC visit'),    
        ihmvt.IH_SHOW_INACTIVE_PROG_AREAS_EXIST_INTERV_V1          : gb_bool_shape('Show inactive program areas exist interventions flag'),
        ihmvt.IH_SHOW_INACTIVE_PROG_AREAS_EXIST_DRUG_SUPP_V1       : gb_bool_shape('Show inactive program areas exist drugs/supply flag'),
        ihmvt.IH_ENTER_UNIT_COSTS_ALL_YEARS_DRUG_SUPP_V1           : gb_bool_shape('Enter unit costs all years drug/supply flag'),
        ihmvt.IH_HEALTH_SYS_ADMIN_UNIT_RECORDS_TAG                 : gb_shape('Health system records', type='1D dict', 
                                                                            dim=[ih_health_sys_admin_unit_types_dim],
                                                                            indices=[ih_health_sys_admin_unit_types_ids],
                                                                            innerShape={
                                                                                'healthSysAdminUnitID'  : gb_shape('Health system ID', type='str'),
                                                                                'name'  : gb_shape('Health system name', type='str'),
                                                                                'stringConstant'  : gb_shape('string constant', type='str'),
                                                                                'active'  : gb_bool_shape('active flag'),
                                                                                'custom'  : gb_bool_shape('Custom area flag'),
                                                                                'number'  : gb_int_shape('Health system number'),
                                                                            },
                                                                            has_default=False
                                                                        ), 

        # Results
        ihmvt.IH_RES_STAFF_CAP_UTILIZATION_STATIC_TAG_V1           : gb_shape('Staff capacity utilization static results', '3D float',
                                                                    dim=[ih_program_area_types_dim, ih_staff_types_dim, gb_year_dim], 
                                                                    indices=[ih_program_area_types_ids, ih_staff_types_ids, gb_year_indices]),
        ihmvt.IH_RES_STAFF_CAP_UTILIZATION_DYNAMIC_TAG_V1          : gb_shape('Staff capacity utilization dynamic results', '3D float',
                                                                    dim=[ih_program_area_types_dim, ih_staff_types_dim, gb_year_dim], 
                                                                    indices=[ih_program_area_types_ids, ih_staff_types_ids, gb_year_indices]),
}