Esempio n. 1
0
 def get_prescriptions_repartition(self,
                                   limit_date,
                                   start_date,
                                   include_null_dates=None):
     active_list = ActiveList(self.fuchia_database)
     visits = active_list.filter_visits_by_category(
         limit_date,
         start_date=start_date,
         include_null_dates=include_null_dates)
     last_visits = visits.groupby('patient_id')['visit_date'].idxmax()
     drugs = visits.loc[last_visits].groupby(
         'arv_received')['patient_id'].count()
     return drugs.sort_values(ascending=False)
Esempio n. 2
0
 def filter_patients_dataframe(self, limit_date, start_date=None,
                               include_null_dates=False):
     followed = FollowedPatients(
         self.fuchia_database
     ).get_filtered_patients_dataframe(
         limit_date,
         start_date=start_date,
         include_null_dates=include_null_dates
     )
     visits = self.filter_visits_by_category(
         limit_date,
         start_date=None,
         include_null_dates=include_null_dates
     )
     c1 = (visits['visit_date'] >= start_date)
     c2 = (visits['visit_date'] <= limit_date)
     visits = visits[c1 & c2]
     visits = visits[visits['patient_id'].isin(followed.index)]
     cd4 = visits['cd4'] <= 500
     oms = visits['stade_oms'] >= 2
     visits = visits[cd4 | oms]
     patient_ids = visits['patient_id'].unique()
     active_list = ActiveList(
         self.fuchia_database
     ).get_filtered_patients_dataframe(
         limit_date,
         start_date=start_date,
         include_null_dates=include_null_dates
     )
     ids = pd.Index(patient_ids).difference(active_list.index)
     return followed.loc[ids], None
Esempio n. 3
0
 def filter_patients_dataframe(self,
                               limit_date,
                               start_date=None,
                               include_null_dates=False):
     stopped_prev = ArvStopped(self.fuchia_database)
     n_limit = limit_date - relativedelta(months=1)
     n_start = start_date - relativedelta(months=1)
     stopped_prev_patients = stopped_prev.get_filtered_patients_dataframe(
         getLastDayOfPeriod(n_limit.month, n_limit.year),
         start_date=getFirstDayOfPeriod(n_start.month, n_start.year),
         include_null_dates=include_null_dates)
     al = ActiveList(self.fuchia_database)
     active_list = al.get_filtered_patients_dataframe(
         limit_date,
         start_date=start_date,
         include_null_dates=include_null_dates)
     idx = stopped_prev_patients.index.intersection(active_list.index)
     return active_list.loc[idx], None
Esempio n. 4
0
 def filter_patients_dataframe(self,
                               limit_date,
                               start_date=None,
                               include_null_dates=False):
     tb_treatment = UnderTbTreatmentPatients(self.fuchia_database)
     active_list = ActiveList(self.fuchia_database)
     arv_and_tb_treatment = (tb_treatment & active_list)
     return arv_and_tb_treatment.get_filtered_patients_dataframe(
         limit_date,
         start_date=start_date,
         include_null_dates=include_null_dates), None
Esempio n. 5
0
 def get_active_list_repartition(self,
                                 limit_date,
                                 start_date,
                                 include_null_dates=None):
     active_list = ActiveList(self.fuchia_database)
     patients = active_list.get_filtered_patients_dataframe(
         limit_date,
         start_date=start_date,
         include_null_dates=include_null_dates)
     visits = active_list.filter_visits_by_category(
         limit_date, start_date=None, include_null_dates=include_null_dates)
     visits = visits[pd.notnull(visits['arv_received'])]
     last_visits = visits.groupby('patient_id')['visit_date'].idxmax()
     last_visits = last_visits.loc[patients.index]
     # Patient drugs
     diff = patients.index.difference(visits.loc[last_visits]['patient_id'])
     patients = patients.loc[diff]['arv_drugs']
     patients = patients.value_counts()
     drugs = visits.loc[last_visits].groupby(
         'arv_received')['patient_id'].count()
     drugs.loc[patients.index] = drugs + patients
     return drugs.sort_values(ascending=False)
Esempio n. 6
0
 def filter_patients_dataframe(self, limit_date, start_date=None,
                               include_null_dates=False):
     active_list = ActiveList(
         self.fuchia_database
     ).get_filtered_patients_dataframe(
         limit_date,
         start_date=start_date,
         include_null_dates=include_null_dates
     )
     visits_tb = self.fuchia_database.visit_tb_dataframe
     c1 = visits_tb['treatment_start'] >= start_date
     c2 = visits_tb['treatment_start'] <= limit_date
     visits_tb = visits_tb[c1 & c2]
     ids = pd.Index(visits_tb['patient_id'].unique())
     tb_index = active_list.index.intersection(ids)
     return active_list.loc[tb_index], None
Esempio n. 7
0
 def filter_patients_dataframe(self,
                               limit_date,
                               start_date=None,
                               include_null_dates=False):
     active_list = ActiveList(
         self.fuchia_database).get_filtered_patients_dataframe(
             limit_date,
             start_date=start_date,
             include_null_dates=include_null_dates)
     p_limit = limit_date - relativedelta(months=self.retention_duration)
     p_start = start_date - relativedelta(months=self.retention_duration)
     p_limit = getLastDayOfPeriod(p_limit.month, p_limit.year)
     p_start = getFirstDayOfPeriod(p_start.month, p_start.year)
     arv_started = ArvStartedDuringPeriod(
         self.fuchia_database).get_filtered_patients_dataframe(
             p_limit,
             start_date=p_start,
             include_null_dates=include_null_dates)
     intersection = active_list.index.intersection(arv_started.index)
     return active_list.loc[intersection], None