
    LHh                         d dl Zd dlmZ d dlmZ d dlmZ  eej                  Z	 ej
        dd          d	             Z ej
        dd          d
             ZdS )    N)elb_hcpi_speciality)BigQueryExecution)config)
project_idiQ F)ttlshow_spinnerc            
      x   	 dd                     t                    z   dz   } d|  d}d|  d}d|  d}d|  d}d|  d}d	|  d}d
|  d}d}t                              |          d         j                                        t                              |          d         j                                        t                              |          d         j                                        t                              |          d         j                                        t                              |          d         j                                        t                              |          d         j                                        t                              |          d         j                                        t                              |          d         j                                        d}	|	S # t          $ r,}
t          j        d|
            g g g g g g g g dcY d}
~
S d}
~
ww xY w)z
    Initialize provider and payer lists when the application starts.
    This is cached for 24 hours to balance freshness and performance.
    'z','zselect distinct Specialty 
            from ASF_Med_AI_CLARIVATE_2023_12_29_Partitioned.Provider
            where sProv_Entity_Type = "individual"
            and Specialty in (z)
            order by 1zselect distinct sProv_Specialty_Desc
            FROM ASF_Med_AI_CLARIVATE_2023_12_29_Partitioned.Provider
            where sProv_Entity_Type = "individual"
            and Specialty in (zselect distinct State
            FROM ASF_Med_AI_CLARIVATE_2023_12_29_Partitioned.Provider
            where sProv_Entity_Type = "individual" and State is not null
            and Specialty in (zselect distinct Specialty
            from ASF_Med_AI_CLARIVATE_2023_12_29_Partitioned.Provider
            where sProv_Entity_Type = "organization"
            and Specialty in (zselect distinct sProv_Specialty_Desc
            from ASF_Med_AI_CLARIVATE_2023_12_29_Partitioned.Provider
            where sProv_Entity_Type = "organization"
            and Specialty in (zselect distinct State
            FROM ASF_Med_AI_CLARIVATE_2023_12_29_Partitioned.Provider
            where sProv_Entity_Type = "organization" and State is not null
            and Specialty in (zselect distinct sProv_Name
            FROM ASF_Med_AI_CLARIVATE_2023_12_29_Partitioned.Provider
            where sProv_Entity_Type = "organization"
            and Specialty in (zselect distinct Plan_Type
            FROM ASF_Med_AI_CLARIVATE_2023_12_29_Partitioned.Medication
            where Plan_Type is not null
            order by 1	SpecialtysProv_Specialty_DescState
sProv_Name	Plan_Type)zHCPI Speciality ClasszHCPI Speciality Group
HCPI StatezHCPO Speciality ClasszHCPO Speciality Group
HCPO State	HCPO Name
Payer NameAn error occurred: )zHCPI Specialty ClasszHCPI Specialty Groupr   zHCPO Specialty ClasszHCPO Specialty Groupr   r   r   N)	joinr   bq	run_queryvaluestolist	Exceptionsterror)elb_hcpi_speciality_stringhcpi_speciality_class_queryhcpi_speciality_group_queryhcpi_state_queryhcpo_speciality_class_queryhcpo_speciality_group_queryhcpo_state_queryhcpo_name_querypayers_name_query
lists_dictes              G/Users/yp/Desktop/SRS/askmed.ai/askmedaiapp/app/../core/global_state.pyinitialize_provider_listsr)      s   H
%(5::6I+J+J%JS%P"'  :' ' '#'  :' ' '#  :  '  :' ' '#'  :' ' '#  :    :   &(\\2M%N%N{%[%b%i%i%k%k%'\\2M%N%NOe%f%m%t%t%v%v,,'788AHOOQQ%'\\2M%N%N{%[%b%i%i%k%k%'\\2M%N%NOe%f%m%t%t%v%v,,'788AHOOQQo66|DKRRTT,,'899+FMTTVV	
 	

  
 
 

*q**+++$&$&$&$&	
 	
 		
 		
 		
 		
 		
 		

s   H H 
H9!H4.H94H9c                     	 d} d}d}d}d}t                               |           }|d         j                                        }t                               |          }|d         j                                        }t                               |          }	|	d         j                                        }
t                               |          }|d	         j                                        }t                               |          }|d
         j                                        }|||
||d}|S # t          $ r)}t          j        d|            g g g g g dcY d }~S d }~ww xY w)Nzselect distinct Diagnosis_ICD10_Group_Desc
from ASF_Med_AI_CLARIVATE_P_AND_C_3.Diagnosis_Aggregated
where Diagnosis_ICD10_Group_Desc != ""
order by 1
zselect distinct concat(Diagnosis_ICD10," ", Diagnosis_Desc) as Diagnosis_ICD10_Desc
from ASF_Med_AI_CLARIVATE_P_AND_C_3.Diagnosis_Aggregated
where Diagnosis_ICD10 != "Total"
order by 1
zfselect distinct Medication_Class
from ASF_Med_AI_CLARIVATE_P_AND_C_3.Medication_Aggregated
order by 1
zselect distinct Medication_Generic
from ASF_Med_AI_CLARIVATE_P_AND_C_3.Medication_Aggregated
where Medication_Generic != "Total"
order by 1
zselect distinct Medication_Brand
from ASF_Med_AI_CLARIVATE_P_AND_C_3.Medication_Aggregated
where Medication_Brand not in ("Total", "Sold As Generic")
order by 1
Diagnosis_ICD10_Group_DescDiagnosis_ICD10_DescMedication_ClassMedication_GenericMedication_Brand)zDiagnosis code groupzDiagnosis codezMedication classzMedication generic namezMedication brand namer   )r   r   r   r   r   r   r   )dx_group_querydx_code_queryrx_class_queryrx_generic_queryrx_brand_querydx_group_dfdx_group_list
dx_code_dfdx_code_listrx_class_dfrx_class_listrx_generic_dfrx_generic_listrx_brand_dfrx_brand_listr&   r'   s                    r(   get_dx_rx_listsr?   X   s   :
)
()+
)
 ll>22#$@AHOOQQ\\-00
!"89@GGIIll>22#$67>EEGG%566'(<=DKKMMll>22#$67>EEGG %2* -'6%2
 

  
 
 

*q**+++$&  "')%'
 
 	
 	
 	
 	
 	
 	

s   D0D3 3
E&=E!E&!E&)	streamlitr   )analytics.reports.utils.p_and_c_variablesr   ai.sql.executorr   core.configr   GCP_PROJECTr   
cache_datar)   r?        r(   <module>rH      s        I I I I I I - - - - - -      &"45557///M
 M
 0/M
^ 7///;
 ;
 0/;
 ;
 ;
rG   