meta-edc 0.3.15__py3-none-any.whl → 0.3.50__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- meta_ae/action_items.py +2 -2
- meta_ae/migrations/0017_auto_20221130_2257.py +12 -7
- meta_ae/tests/holidays.csv +1 -1
- meta_analytics/README.rst +17 -0
- meta_analytics/dataframes/__init__.py +19 -0
- meta_analytics/dataframes/constants.py +33 -0
- meta_analytics/dataframes/enrolled/__init__.py +1 -0
- meta_analytics/dataframes/enrolled/get_glucose_df.py +122 -0
- meta_analytics/dataframes/get_eos_df.py +26 -0
- meta_analytics/dataframes/get_last_imp_visits_df.py +101 -0
- meta_analytics/dataframes/glucose_endpoints/__init__.py +2 -0
- meta_analytics/dataframes/glucose_endpoints/endpoint_by_date.py +183 -0
- meta_analytics/dataframes/glucose_endpoints/glucose_endpoints_by_date.py +531 -0
- meta_analytics/dataframes/screening/__init__.py +2 -0
- meta_analytics/dataframes/screening/get_glucose_tested_only_df.py +20 -0
- meta_analytics/dataframes/screening/get_screening_df.py +163 -0
- meta_analytics/dataframes/utils.py +65 -0
- meta_analytics/get_tables.py +81 -0
- meta_analytics/tables/__init__.py +2 -0
- meta_analytics/tables/eligible.py +106 -0
- meta_analytics/tables/enrolled/__init__.py +0 -0
- meta_analytics/tables/enrolled/glucose.py +28 -0
- meta_analytics/tables/has_dm.py +61 -0
- meta_analytics/tests/__init__.py +0 -0
- meta_analytics/tests/test_endpoints_by_date.py +94 -0
- meta_auth/auth_objects.py +22 -0
- meta_auth/auths.py +18 -3
- meta_consent/action_items.py +18 -1
- meta_consent/admin/__init__.py +1 -0
- meta_consent/admin/subject_consent_v1_ext_admin.py +45 -0
- meta_consent/baker_recipes.py +1 -0
- meta_consent/consents.py +20 -1
- meta_consent/constants.py +1 -0
- meta_consent/forms/__init__.py +1 -0
- meta_consent/forms/subject_consent_v1_ext_form.py +16 -0
- meta_consent/locale/lg/LC_MESSAGES/django.po +69 -0
- meta_consent/locale/sw/LC_MESSAGES/django.po +12 -12
- meta_consent/migrations/0026_historicalsubjectconsentv1ext_subjectconsentv1ext.py +544 -0
- meta_consent/migrations/0027_auto_20250111_0344.py +30 -0
- meta_consent/models/__init__.py +1 -0
- meta_consent/models/signals.py +18 -0
- meta_consent/models/subject_consent_v1_ext.py +29 -0
- meta_consent/tests/holidays.csv +1 -1
- meta_dashboard/locale/lg/LC_MESSAGES/django.po +30 -0
- meta_dashboard/locale/sw/LC_MESSAGES/django.po +11 -2
- meta_dashboard/navbars.py +3 -1
- meta_dashboard/templates/meta_dashboard/bootstrap3/buttons/eligibility_button.html +1 -1
- meta_dashboard/templates/meta_dashboard/bootstrap3/buttons/screening_button.html +1 -1
- meta_dashboard/templates/meta_dashboard/bootstrap3/subject/dashboard/sidebar.html +24 -0
- meta_dashboard/templates/meta_dashboard/bootstrap3/subject/dashboard.html +3 -0
- meta_dashboard/templatetags/meta_dashboard_extras.py +1 -1
- meta_dashboard/tests/holidays.csv +1 -1
- meta_dashboard/tests/urls.py +0 -1
- meta_dashboard/view_utils/__init__.py +6 -0
- meta_dashboard/view_utils/subject_screening_button.py +2 -2
- meta_dashboard/views/subject/dashboard/dashboard_view.py +38 -0
- meta_edc/__init__.py +7 -0
- meta_edc/celery.py +4 -13
- meta_edc/celery_live.py +18 -0
- meta_edc/celery_uat.py +24 -0
- meta_edc/management/commands/update_forms_reference.py +6 -2
- meta_edc/migrations/__init__.py +0 -0
- meta_edc/navbars.py +2 -1
- meta_edc/settings/debug.py +10 -2
- meta_edc/settings/defaults.py +58 -43
- meta_edc/templates/meta_edc/bootstrap3/home.html +5 -2
- meta_edc/tests/tests/test_endpoints.py +2 -0
- meta_edc/urls.py +4 -1
- meta_edc/wsgi.py +1 -1
- meta_edc/wsgi_live.py +1 -1
- meta_edc/wsgi_uat.py +1 -1
- meta_edc-0.3.50.dist-info/AUTHORS +0 -0
- meta_edc-0.3.50.dist-info/METADATA +766 -0
- {meta_edc-0.3.15.dist-info → meta_edc-0.3.50.dist-info}/RECORD +316 -127
- {meta_edc-0.3.15.dist-info → meta_edc-0.3.50.dist-info}/WHEEL +1 -1
- {meta_edc-0.3.15.dist-info → meta_edc-0.3.50.dist-info}/top_level.txt +1 -0
- meta_pharmacy/admin/__init__.py +2 -0
- meta_pharmacy/admin/rx_admin.py +75 -0
- meta_pharmacy/admin/substitutions_admin.py +67 -0
- meta_pharmacy/admin_site.py +9 -0
- meta_pharmacy/apps.py +5 -0
- meta_pharmacy/constants.py +10 -0
- meta_pharmacy/forms/__init__.py +2 -0
- meta_pharmacy/forms/rx_form.py +16 -0
- meta_pharmacy/forms/substitutions_form.py +54 -0
- meta_pharmacy/label_configs.py +30 -0
- meta_pharmacy/labels/__init__.py +5 -0
- meta_pharmacy/labels/draw_label_for_subject_with_barcode.py +62 -0
- meta_pharmacy/labels/draw_label_for_subject_with_code128.py +14 -0
- meta_pharmacy/labels/draw_label_with_test_data.py +26 -0
- meta_pharmacy/labels/label_data.py +14 -0
- meta_pharmacy/labels/print_sheets.py +97 -0
- meta_pharmacy/list_data.py +8 -0
- meta_pharmacy/management/__init__.py +0 -0
- meta_pharmacy/management/commands/__init__.py +0 -0
- meta_pharmacy/management/commands/update_initial_pharmacy_data.py +10 -0
- meta_pharmacy/migrations/0002_initial.py +695 -0
- meta_pharmacy/migrations/0003_auto_20240909_2335.py +64 -0
- meta_pharmacy/migrations/0004_alter_historicalsubstitutions_report_datetime_and_more.py +23 -0
- meta_pharmacy/migrations/0005_auto_20240911_0352.py +17 -0
- meta_pharmacy/migrations/0006_lotnumber_label.py +289 -0
- meta_pharmacy/migrations/0007_lotnumber_medication.py +24 -0
- meta_pharmacy/migrations/0008_remove_lotnumber_medication_and_more.py +390 -0
- meta_pharmacy/migrations/0009_remove_historicalrx_slug.py +17 -0
- meta_pharmacy/models/__init__.py +3 -0
- meta_pharmacy/models/label_data.py +38 -0
- meta_pharmacy/models/rx.py +18 -0
- meta_pharmacy/models/rx_label.py +39 -0
- meta_pharmacy/models/substitutions.py +88 -0
- meta_pharmacy/urls.py +8 -0
- meta_pharmacy/utils/__init__.py +1 -0
- meta_pharmacy/utils/update_initial_pharmacy_data.py +146 -0
- meta_prn/action_items.py +9 -1
- meta_prn/admin/pregnancy_notification_admin.py +6 -2
- meta_prn/migrations/0034_auto_20220630_1110.py +3 -3
- meta_prn/migrations/0035_auto_20220630_1140.py +59 -56
- meta_prn/tests/tests/test_dm_referral.py +3 -6
- meta_reports/__init__.py +1 -0
- meta_reports/admin/__init__.py +15 -0
- meta_reports/admin/dbviews/__init__.py +14 -0
- meta_reports/admin/dbviews/glucose_summary_admin.py +116 -0
- meta_reports/admin/dbviews/imp_substitutions_admin.py +101 -0
- meta_reports/admin/dbviews/missing_screening_ogtt_admin/__init__.py +2 -0
- meta_reports/admin/dbviews/missing_screening_ogtt_admin/note_model_admin.py +53 -0
- meta_reports/admin/dbviews/missing_screening_ogtt_admin/unmanaged_model_admin.py +84 -0
- meta_reports/admin/dbviews/on_study_missing_lab_values_admin/__init__.py +1 -0
- meta_reports/admin/dbviews/on_study_missing_lab_values_admin/unmanaged_model_admin.py +13 -0
- meta_reports/admin/dbviews/on_study_missing_values_admin/__init__.py +1 -0
- meta_reports/admin/dbviews/on_study_missing_values_admin/unmanaged_model_admin.py +13 -0
- meta_reports/admin/dbviews/patient_history_missing_baseline_cd4_admin.py +58 -0
- meta_reports/admin/dbviews/unattended_three_in_row2_admin.py +47 -0
- meta_reports/admin/dbviews/unattended_three_in_row_admin.py +35 -0
- meta_reports/admin/dbviews/unattended_two_in_row_admin.py +34 -0
- meta_reports/admin/endpoints_admin.py +14 -0
- meta_reports/admin/endpoints_all_admin.py +13 -0
- meta_reports/admin/last_imp_refill_admin.py +181 -0
- meta_reports/admin/list_filters.py +30 -0
- meta_reports/admin/modeladmin_mixins.py +112 -0
- meta_reports/admin_site.py +5 -0
- meta_reports/apps.py +1 -16
- meta_reports/forms/__init__.py +1 -0
- meta_reports/forms/missing_ogtt_note_form.py +33 -0
- meta_reports/management/__init__.py +0 -0
- meta_reports/management/commands/__init__.py +0 -0
- meta_reports/management/commands/generate_endpoints.py +13 -0
- meta_reports/migrations/0001_initial.py +87 -0
- meta_reports/migrations/0002_patienthistorymissingbaselinecd4_and_more.py +64 -0
- meta_reports/migrations/0003_auto_20240618_0505.py +12 -0
- meta_reports/migrations/0004_alter_patienthistorymissingbaselinecd4_table.py +17 -0
- meta_reports/migrations/0005_endpoints.py +47 -0
- meta_reports/migrations/0006_endpoints_baseline_datetime.py +18 -0
- meta_reports/migrations/0007_alter_endpoints_endpoint_label_and_more.py +43 -0
- meta_reports/migrations/0008_alter_endpoints_endpoint_label.py +18 -0
- meta_reports/migrations/0009_alter_endpoints_options.py +21 -0
- meta_reports/migrations/0010_alter_patienthistorymissingbaselinecd4_options_and_more.py +49 -0
- meta_reports/migrations/0011_auto_20240813_0156.py +54 -0
- meta_reports/migrations/0012_auto_20240813_1516.py +48 -0
- meta_reports/migrations/0013_auto_20240813_1516.py +48 -0
- meta_reports/migrations/0014_auto_20240813_1517.py +48 -0
- meta_reports/migrations/0015_alter_endpoints_site.py +22 -0
- meta_reports/migrations/0016_missingscreeningogtt.py +47 -0
- meta_reports/migrations/0017_auto_20240819_1711.py +166 -0
- meta_reports/migrations/0018_auto_20240819_1713.py +54 -0
- meta_reports/migrations/0019_auto_20240819_1721.py +54 -0
- meta_reports/migrations/0020_auto_20240819_1811.py +54 -0
- meta_reports/migrations/0021_auto_20240819_1817.py +54 -0
- meta_reports/migrations/0022_auto_20240819_1832.py +54 -0
- meta_reports/migrations/0023_endpoints_meta_report_subject_a56b22_idx.py +20 -0
- meta_reports/migrations/0024_glucosesummary.py +38 -0
- meta_reports/migrations/0025_auto_20240822_0115.py +87 -0
- meta_reports/migrations/0026_auto_20240822_0120.py +54 -0
- meta_reports/migrations/0027_auto_20240822_0140.py +54 -0
- meta_reports/migrations/0028_alter_glucosesummary_options.py +22 -0
- meta_reports/migrations/0029_auto_20240822_0149.py +54 -0
- meta_reports/migrations/0030_auto_20240822_1637.py +54 -0
- meta_reports/migrations/0031_endpointsproxy.py +25 -0
- meta_reports/migrations/0032_alter_endpointsproxy_options.py +21 -0
- meta_reports/migrations/0033_auto_20240823_0012.py +54 -0
- meta_reports/migrations/0034_auto_20240823_1642.py +54 -0
- meta_reports/migrations/0035_historicalmissingogttnote_missingogttnote.py +457 -0
- meta_reports/migrations/0036_historicalmissingogttnote_fasting_and_more.py +86 -0
- meta_reports/migrations/0037_historicalmissingogttnote_result_status_and_more.py +51 -0
- meta_reports/migrations/0038_alter_historicalmissingogttnote_fasting_and_more.py +33 -0
- meta_reports/migrations/0039_onstudymissingvalues.py +44 -0
- meta_reports/migrations/0040_auto_20240824_0412.py +282 -0
- meta_reports/migrations/0041_auto_20240828_2229.py +14 -0
- meta_reports/migrations/0042_onstudymissinglabvalues.py +43 -0
- meta_reports/migrations/0043_auto_20240828_2309.py +88 -0
- meta_reports/migrations/0044_auto_20240828_2323.py +93 -0
- meta_reports/migrations/0045_auto_20240829_0248.py +54 -0
- meta_reports/migrations/0046_auto_20240829_0250.py +54 -0
- meta_reports/migrations/0047_impsubstitutions.py +56 -0
- meta_reports/migrations/0048_auto_20240909_2338.py +48 -0
- meta_reports/migrations/0049_auto_20240911_0327.py +54 -0
- meta_reports/migrations/0050_alter_endpoints_created.py +19 -0
- meta_reports/migrations/0051_remove_endpoints_baseline_datetime_and_more.py +40 -0
- meta_reports/migrations/0052_lastimpvisit.py +57 -0
- meta_reports/migrations/0053_rename_lastimpvisit_lastimprefill_and_more.py +31 -0
- meta_reports/models/__init__.py +16 -0
- meta_reports/models/dbviews/README +14 -0
- meta_reports/models/dbviews/__init__.py +9 -0
- meta_reports/models/dbviews/glucose_summary/__init__.py +2 -0
- meta_reports/models/dbviews/glucose_summary/unmanaged_model.py +35 -0
- meta_reports/models/dbviews/glucose_summary/view_definition.py +28 -0
- meta_reports/models/dbviews/imp_substitutions/__init__.py +1 -0
- meta_reports/models/dbviews/imp_substitutions/unmanaged_model.py +41 -0
- meta_reports/models/dbviews/imp_substitutions/view_definition.py +21 -0
- meta_reports/models/dbviews/missing_screening_ogtt/__init__.py +2 -0
- meta_reports/models/dbviews/missing_screening_ogtt/note_model.py +57 -0
- meta_reports/models/dbviews/missing_screening_ogtt/unmanaged_model.py +41 -0
- meta_reports/models/dbviews/missing_screening_ogtt/view_definition.py +20 -0
- meta_reports/models/dbviews/on_study_missing_lab_values/__init__.py +1 -0
- meta_reports/models/dbviews/on_study_missing_lab_values/qa_cases.py +53 -0
- meta_reports/models/dbviews/on_study_missing_lab_values/unmanged_model.py +20 -0
- meta_reports/models/dbviews/on_study_missing_lab_values/view_definition.py +17 -0
- meta_reports/models/dbviews/on_study_missing_values/__init__.py +1 -0
- meta_reports/models/dbviews/on_study_missing_values/qa_cases.py +54 -0
- meta_reports/models/dbviews/on_study_missing_values/unmanged_model.py +20 -0
- meta_reports/models/dbviews/on_study_missing_values/view_definition.py +17 -0
- meta_reports/models/dbviews/patient_history_missing_baseline_cd4/__init__.py +1 -0
- meta_reports/models/dbviews/patient_history_missing_baseline_cd4/unmanaged_model.py +31 -0
- meta_reports/models/dbviews/patient_history_missing_baseline_cd4/view_definition.py +21 -0
- meta_reports/models/dbviews/unattended_three_in_row/__init__.py +1 -0
- meta_reports/models/dbviews/unattended_three_in_row/unmanaged_model.py +29 -0
- meta_reports/models/dbviews/unattended_three_in_row/view_definition.py +31 -0
- meta_reports/models/dbviews/unattended_three_in_row2/__init__.py +1 -0
- meta_reports/models/dbviews/unattended_three_in_row2/unmanaged_model.py +29 -0
- meta_reports/models/dbviews/unattended_three_in_row2/view_definition.py +50 -0
- meta_reports/models/dbviews/unattended_two_in_row/__init__.py +1 -0
- meta_reports/models/dbviews/unattended_two_in_row/unmanaged_model.py +27 -0
- meta_reports/models/dbviews/unattended_two_in_row/view_definition.py +30 -0
- meta_reports/models/endpoints.py +31 -0
- meta_reports/models/endpoints_proxy.py +11 -0
- meta_reports/models/last_imp_refill.py +34 -0
- meta_reports/tasks.py +12 -0
- meta_reports/templates/meta_reports/columns/subject_identifier_column.html +1 -0
- meta_reports/templates/meta_reports/endpoints_all_change_list_note.html +12 -0
- meta_reports/templates/meta_reports/endpoints_change_list_note.html +12 -0
- meta_reports/tests/test_sql_gen.py +5 -0
- meta_reports/urls.py +8 -0
- meta_reports/utils.py +0 -0
- meta_screening/admin/subject_screening_admin.py +1 -0
- meta_screening/migrations/0067_alter_historicalscreeningpartone_report_datetime_and_more.py +84 -0
- meta_screening/tests/holidays.csv +1 -1
- meta_screening/tests/meta_test_case_mixin.py +15 -0
- meta_sites/tests/test_sites.py +1 -1
- meta_subject/action_items.py +2 -2
- meta_subject/admin/__init__.py +2 -1
- meta_subject/admin/birth_outcome_admin.py +2 -0
- meta_subject/admin/blood_results/__init__.py +1 -1
- meta_subject/admin/blood_results/{blood_results_lipid_admin.py → blood_results_lipids_admin.py} +7 -7
- meta_subject/admin/diabetes/__init__.py +1 -1
- meta_subject/admin/diabetes/dm_endpoint_admin.py +35 -0
- meta_subject/admin/glucose_fbg_admin.py +4 -0
- meta_subject/admin/other_arv_regimens_admin.py +2 -0
- meta_subject/admin/study_medication_admin.py +10 -0
- meta_subject/form_validators/__init__.py +1 -1
- meta_subject/form_validators/dm_endpoint_form_validator.py +35 -0
- meta_subject/forms/__init__.py +2 -2
- meta_subject/forms/blood_results/__init__.py +1 -1
- meta_subject/forms/blood_results/{blood_results_lipid_form.py → blood_results_lipids_form.py} +5 -5
- meta_subject/forms/diabetes/__init__.py +1 -2
- meta_subject/forms/diabetes/dm_endpoint_form.py +13 -0
- meta_subject/forms/study_medication_form.py +35 -0
- meta_subject/locale/lg/LC_MESSAGES/django.po +470 -0
- meta_subject/locale/sw/LC_MESSAGES/django.po +191 -89
- meta_subject/metadata_rules/metadata_rules.py +7 -0
- meta_subject/metadata_rules/predicates.py +45 -8
- meta_subject/migrations/0107_auto_20220415_0043.py +28 -22
- meta_subject/migrations/0126_auto_20220719_2142.py +4 -4
- meta_subject/migrations/0131_auto_20220722_0411.py +28 -23
- meta_subject/migrations/0132_auto_20220722_1825.py +10 -6
- meta_subject/migrations/0135_auto_20220722_2212.py +39 -35
- meta_subject/migrations/0150_auto_20220914_0039.py +15 -11
- meta_subject/migrations/0207_alter_historicalphysicalexam_waist_circumference_and_more.py +46 -0
- meta_subject/migrations/0208_birthoutcomes_crf_status_and_more.py +62 -0
- meta_subject/migrations/0209_remove_historicaldmdxresult_dm_diagnosis_and_more.py +37 -0
- meta_subject/migrations/0210_remove_dmdxresult_dm_diagnosis_and_more.py +123 -0
- meta_subject/migrations/0211_dmendpoint_endpoint_reached_and_more.py +45 -0
- meta_subject/migrations/0212_auto_20240827_2222.py +23 -0
- meta_subject/migrations/0213_rename_bloodresultslipid_bloodresultslipids_and_more.py +35 -0
- meta_subject/migrations/0214_historicalstudymedication_stock_codes_and_more.py +44 -0
- meta_subject/migrations/0215_alter_historicalstudymedication_stock_codes_and_more.py +46 -0
- meta_subject/model_mixins/arv_history_model_mixin.py +3 -3
- meta_subject/models/__init__.py +3 -2
- meta_subject/models/birth_outcomes.py +6 -1
- meta_subject/models/blood_results/__init__.py +1 -1
- meta_subject/models/blood_results/{blood_results_lipid.py → blood_results_lipids.py} +3 -3
- meta_subject/models/diabetes/__init__.py +1 -2
- meta_subject/models/diabetes/dm_endpoint.py +61 -0
- meta_subject/models/glucose.py +4 -1
- meta_subject/models/physical_exam.py +1 -0
- meta_subject/models/signals.py +19 -0
- meta_subject/models/todo.txt +1 -1
- meta_subject/static/meta_subject/slider.css +1 -1
- meta_subject/templates/meta_subject/endpoint_review_instructions.html +1 -1
- meta_subject/templates/meta_subject/widgets/slider.html +0 -1
- meta_subject/tests/holidays.csv +1 -1
- meta_subject/tests/tests/test_medication_adherence.py +5 -1
- meta_subject/tests/tests/test_metadata_rules.py +2 -2
- meta_subject/tests/tests/test_mnsi.py +212 -121
- meta_subject/tests/tests/test_sf12.py +0 -12
- meta_visit_schedule/constants.py +4 -0
- meta_visit_schedule/tests/tests/test_schedule.py +4 -0
- meta_visit_schedule/visit_schedules/phase_three/crfs.py +75 -13
- meta_visit_schedule/visit_schedules/phase_three/requisitions.py +12 -0
- meta_visit_schedule/visit_schedules/phase_three/schedule.py +65 -2
- meta_visit_schedule/visit_schedules/phase_three/schedule_dm_referral.py +1 -1
- tests/etc/randomization_list.csv +1 -1
- {meta_edc/tests → tests}/etc/randomization_list_phase_three.csv +4 -4
- tests/holidays.csv +1 -1
- {meta_edc/tests → tests}/test_settings.py +16 -6
- meta_edc/tests/etc/user-aes-local.key +0 -1
- meta_edc/tests/etc/user-aes-restricted.key +0 -0
- meta_edc/tests/etc/user-rsa-local-private.pem +0 -27
- meta_edc/tests/etc/user-rsa-local-public.pem +0 -9
- meta_edc/tests/etc/user-rsa-restricted-private.pem +0 -27
- meta_edc/tests/etc/user-rsa-restricted-public.pem +0 -9
- meta_edc/tests/etc/user-salt-local.key +0 -0
- meta_edc/tests/etc/user-salt-restricted.key +0 -0
- meta_edc-0.3.15.dist-info/METADATA +0 -88
- meta_reports/tests/holidays.csv +0 -15
- meta_subject/admin/diabetes/dm_diagnosis_admin.py +0 -89
- meta_subject/form_validators/dm_diagnosis_form_validator.py +0 -38
- meta_subject/form_validators/dm_dx_result_form_validator.py +0 -7
- meta_subject/forms/diabetes/dm_diagnosis_form.py +0 -13
- meta_subject/forms/diabetes/dm_dx_result_form.py +0 -11
- meta_subject/models/diabetes/dm_diagnosis.py +0 -50
- meta_subject/models/diabetes/dm_dx_result.py +0 -70
- /meta_edc-0.3.15.dist-info/AUTHORS → /meta_analytics/__init__.py +0 -0
- /meta_pharmacy/models.py → /meta_analytics/constants.py +0 -0
- /meta_reports/models.py → /meta_analytics/notebooks/cleaning/__init__.py +0 -0
- {meta_edc-0.3.15.dist-info → meta_edc-0.3.50.dist-info}/LICENSE +0 -0
@@ -0,0 +1,163 @@
|
|
1
|
+
import numpy as np
|
2
|
+
import pandas as pd
|
3
|
+
from django_pandas.io import read_frame
|
4
|
+
|
5
|
+
from meta_screening.models import SubjectScreening
|
6
|
+
from meta_subject.models import PhysicalExam, SubjectVisit
|
7
|
+
|
8
|
+
|
9
|
+
def get_screening_df(df: pd.DataFrame | None = None) -> pd.DataFrame:
|
10
|
+
df = pd.DataFrame() if not hasattr(df, "empty") else df
|
11
|
+
if df.empty:
|
12
|
+
cols = [
|
13
|
+
f.name
|
14
|
+
for f in SubjectScreening._meta.get_fields()
|
15
|
+
if f.name
|
16
|
+
not in [
|
17
|
+
"contact_number",
|
18
|
+
"initials",
|
19
|
+
"hospital_identifier",
|
20
|
+
"modified",
|
21
|
+
"user_created",
|
22
|
+
"user_modified",
|
23
|
+
"hostname_created",
|
24
|
+
"hostname_modified",
|
25
|
+
"device_created",
|
26
|
+
"device_modified",
|
27
|
+
"locale_created",
|
28
|
+
"locale_modified",
|
29
|
+
"slug",
|
30
|
+
]
|
31
|
+
]
|
32
|
+
qs_screening = SubjectScreening.objects.values(*cols).all()
|
33
|
+
df = read_frame(qs_screening, verbose=False)
|
34
|
+
df = df.drop(df[df["hiv_pos"] == "No"].index) # removes 2 rows
|
35
|
+
df = df.reset_index(drop=True)
|
36
|
+
|
37
|
+
# convert all to float
|
38
|
+
num_cols = [
|
39
|
+
"age_in_years",
|
40
|
+
"calculated_bmi_value",
|
41
|
+
"converted_fbg2_value",
|
42
|
+
"converted_fbg_value",
|
43
|
+
"converted_ogtt2_value",
|
44
|
+
"converted_ogtt_value",
|
45
|
+
"dia_blood_pressure_avg",
|
46
|
+
"fbg2_value",
|
47
|
+
"fbg_value",
|
48
|
+
"hba1c_value",
|
49
|
+
"ogtt2_value",
|
50
|
+
"ogtt_value",
|
51
|
+
"sys_blood_pressure_avg",
|
52
|
+
"waist_circumference",
|
53
|
+
]
|
54
|
+
df[num_cols] = df[num_cols].apply(pd.to_numeric)
|
55
|
+
|
56
|
+
df["reasons_ineligible_part_one"] = df["reasons_ineligible_part_one"].apply(
|
57
|
+
lambda x: None if x == "" else x
|
58
|
+
)
|
59
|
+
df["reasons_ineligible_part_two"] = df["reasons_ineligible_part_two"].apply(
|
60
|
+
lambda x: None if x == "" else x
|
61
|
+
)
|
62
|
+
df["reasons_ineligible_part_two"] = df["reasons_ineligible_part_two"].str.replace(
|
63
|
+
"Has Dm", "Diabetes"
|
64
|
+
)
|
65
|
+
df["reasons_ineligible_part_two"] = df["reasons_ineligible_part_two"].str.replace(
|
66
|
+
"On Dm Medication", "taking anti-diabetic medications"
|
67
|
+
)
|
68
|
+
df["reasons_ineligible_part_three"] = df["reasons_ineligible_part_three"].apply(
|
69
|
+
lambda x: None if x == "" else x
|
70
|
+
)
|
71
|
+
|
72
|
+
# condition to include any glucose test
|
73
|
+
|
74
|
+
# has_dm fillna with unk
|
75
|
+
df["has_dm"] = df["has_dm"].apply(lambda x: "unk" if not x else x)
|
76
|
+
|
77
|
+
na = "Not applicable, subject is not eligible based on the criteria above"
|
78
|
+
df["already_fasted"] = df["already_fasted"].apply(lambda x: "N/A" if x == na else x)
|
79
|
+
|
80
|
+
# create a column that summarizes lives_nearby and staying_nearby_12
|
81
|
+
df["in_catchment"] = (df["lives_nearby"] == "Yes") & (df["staying_nearby_12"] == "Yes")
|
82
|
+
|
83
|
+
# create ogtt column
|
84
|
+
df["ogtt"] = df["converted_ogtt_value"]
|
85
|
+
df.loc[df["ogtt"].notna() & df["converted_ogtt2_value"].notna(), "ogtt"] = df[
|
86
|
+
"converted_ogtt2_value"
|
87
|
+
]
|
88
|
+
|
89
|
+
# create fbg column
|
90
|
+
df["fbg"] = df["converted_fbg_value"]
|
91
|
+
df.loc[df["fbg"].notna() & df["converted_fbg2_value"].notna(), "fbg"] = df[
|
92
|
+
"converted_fbg2_value"
|
93
|
+
]
|
94
|
+
|
95
|
+
# fasting columns
|
96
|
+
df["fasting_fbg_hrs"] = np.nan
|
97
|
+
df["fasting_fbg_hrs"] = df["fasting_duration_delta"].apply(
|
98
|
+
lambda x: x.total_seconds() / 3600
|
99
|
+
)
|
100
|
+
df.loc[df["fbg"].notna() & df["converted_fbg2_value"].notna(), "fasting_fbg_hrs"] = df[
|
101
|
+
"repeat_fasting_duration_delta"
|
102
|
+
].apply(lambda x: x.total_seconds() / 3600)
|
103
|
+
df["fasting_ogtt_hrs"] = np.nan
|
104
|
+
df["fasting_ogtt_hrs"] = df["fasting_duration_delta"].apply(
|
105
|
+
lambda x: x.total_seconds() / 3600
|
106
|
+
)
|
107
|
+
df.loc[df["ogtt"].notna() & df["converted_ogtt2_value"].notna(), "fasting_ogtt_hrs"] = df[
|
108
|
+
"repeat_fasting_duration_delta"
|
109
|
+
].apply(lambda x: x.total_seconds() / 3600)
|
110
|
+
|
111
|
+
# bmi
|
112
|
+
# subject SR9E8B4D has eligible part two == No but subject has a glucose value
|
113
|
+
df.loc[(df["screening_identifier"] == "SR9E8B4D"), "eligible_part_two"] = "Yes"
|
114
|
+
|
115
|
+
# merge with physical exam to get waist circumference if taken at baseline
|
116
|
+
subject_identifiers = list(df["subject_identifier"])
|
117
|
+
qs_subject_visit = SubjectVisit.objects.filter(subject_identifier__in=subject_identifiers)
|
118
|
+
df_subject_visit = read_frame(qs_subject_visit)
|
119
|
+
df_subject_visit.rename(columns={"id": "subject_visit"}, inplace=True)
|
120
|
+
qs_physical_exam = PhysicalExam.objects.filter(
|
121
|
+
subject_visit__subject_identifier__in=subject_identifiers
|
122
|
+
)
|
123
|
+
df_physical_exam = read_frame(qs_physical_exam)
|
124
|
+
# merge w/ subject visit to get subject_identifier
|
125
|
+
df_physical_exam = pd.merge(
|
126
|
+
df_physical_exam,
|
127
|
+
df_subject_visit[
|
128
|
+
["subject_visit", "subject_identifier", "visit_code", "visit_code_sequence"]
|
129
|
+
],
|
130
|
+
on="subject_visit",
|
131
|
+
how="left",
|
132
|
+
)
|
133
|
+
df_physical_exam = df_physical_exam[
|
134
|
+
["subject_identifier", "visit_code", "visit_code_sequence", "waist_circumference"]
|
135
|
+
]
|
136
|
+
df_physical_exam[["waist_circumference"]] = df_physical_exam[
|
137
|
+
["waist_circumference"]
|
138
|
+
].apply(pd.to_numeric)
|
139
|
+
# rename column to waist_circumference_baseline
|
140
|
+
df_physical_exam["waist_circumference_baseline"] = df_physical_exam["waist_circumference"]
|
141
|
+
df_physical_exam.drop(columns=["waist_circumference"])
|
142
|
+
df_physical_exam[["waist_circumference_baseline"]] = df_physical_exam[
|
143
|
+
["waist_circumference_baseline"]
|
144
|
+
].apply(pd.to_numeric)
|
145
|
+
# merge on subject_identifier with main DF
|
146
|
+
df = pd.merge(
|
147
|
+
df,
|
148
|
+
df_physical_exam[["subject_identifier", "waist_circumference_baseline"]],
|
149
|
+
on="subject_identifier",
|
150
|
+
how="left",
|
151
|
+
)
|
152
|
+
df.reset_index(drop=True, inplace=True)
|
153
|
+
# set waist_circumference=waist_circumference_baseline
|
154
|
+
# if `waist_circumference` is none and `waist_circumference_baseline` is not
|
155
|
+
df.loc[
|
156
|
+
(df["waist_circumference"].isna()) & (df["waist_circumference_baseline"].notna()),
|
157
|
+
"waist_circumference",
|
158
|
+
] = df["waist_circumference_baseline"]
|
159
|
+
|
160
|
+
# drop waist_circumference_baseline
|
161
|
+
df.drop(columns=["waist_circumference_baseline"], inplace=True)
|
162
|
+
|
163
|
+
return df
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import pandas as pd
|
2
|
+
|
3
|
+
from .constants import endpoint_columns
|
4
|
+
|
5
|
+
|
6
|
+
def get_test_string(s):
|
7
|
+
if pd.notna(s["fbg_value"]) and pd.notna(s["ogtt_value"]):
|
8
|
+
return "fbg_ogtt"
|
9
|
+
if pd.notna(s["fbg_value"]) and pd.isna(s["ogtt_value"]):
|
10
|
+
return "fbg_only"
|
11
|
+
if pd.isna(s["fbg_value"]) and pd.notna(s["ogtt_value"]):
|
12
|
+
return "ogtt_only"
|
13
|
+
if pd.isna(s["fbg_value"]) and pd.isna(s["ogtt_value"]):
|
14
|
+
return "not_tested"
|
15
|
+
return "???"
|
16
|
+
|
17
|
+
|
18
|
+
def get_empty_endpoint_df() -> pd.DataFrame:
|
19
|
+
endpoint_df = pd.DataFrame(columns=endpoint_columns)
|
20
|
+
endpoint_df[
|
21
|
+
[
|
22
|
+
"visit_code",
|
23
|
+
"interval_in_days",
|
24
|
+
"fbg_value",
|
25
|
+
"ogtt_value",
|
26
|
+
"endpoint",
|
27
|
+
"endpoint_type",
|
28
|
+
]
|
29
|
+
] = endpoint_df[
|
30
|
+
[
|
31
|
+
"visit_code",
|
32
|
+
"interval_in_days",
|
33
|
+
"fbg_value",
|
34
|
+
"ogtt_value",
|
35
|
+
"endpoint",
|
36
|
+
"endpoint_type",
|
37
|
+
]
|
38
|
+
].apply(
|
39
|
+
pd.to_numeric
|
40
|
+
)
|
41
|
+
endpoint_df[
|
42
|
+
["baseline_datetime", "visit_datetime", "fbg_datetime", "offstudy_datetime"]
|
43
|
+
] = endpoint_df[
|
44
|
+
["baseline_datetime", "visit_datetime", "fbg_datetime", "offstudy_datetime"]
|
45
|
+
].apply(
|
46
|
+
pd.to_datetime
|
47
|
+
)
|
48
|
+
endpoint_df["visit_code"] = endpoint_df["visit_code"].astype(float)
|
49
|
+
return endpoint_df
|
50
|
+
|
51
|
+
|
52
|
+
def get_unique_visit_codes(df: pd.DataFrame) -> pd.DataFrame:
|
53
|
+
stats_df = df[df["visit_code"] % 1 == 0]["visit_code"].value_counts().to_frame()
|
54
|
+
stats_df = stats_df.reset_index()
|
55
|
+
stats_df["visit_code"] = stats_df["visit_code"].astype(float)
|
56
|
+
stats_df = stats_df.sort_values(["visit_code"])
|
57
|
+
stats_df = stats_df.reset_index(drop=True)
|
58
|
+
return stats_df
|
59
|
+
|
60
|
+
|
61
|
+
def get_unique_subject_identifiers(df: pd.DataFrame) -> pd.DataFrame:
|
62
|
+
values_df = pd.DataFrame(df["subject_identifier"].unique(), columns=["subject_identifier"])
|
63
|
+
values_df = values_df.sort_values(["subject_identifier"])
|
64
|
+
values_df = values_df.reset_index()
|
65
|
+
return values_df
|
@@ -0,0 +1,81 @@
|
|
1
|
+
import pandas as pd
|
2
|
+
from edc_analytics.custom_tables import (
|
3
|
+
AgeTable,
|
4
|
+
ArtTable,
|
5
|
+
BmiTable,
|
6
|
+
BpTable,
|
7
|
+
FastingTable,
|
8
|
+
FbgOgttTable,
|
9
|
+
FbgTable,
|
10
|
+
GenderTable,
|
11
|
+
HbA1cTable,
|
12
|
+
OgttTable,
|
13
|
+
WaistCircumferenceTable,
|
14
|
+
)
|
15
|
+
from edc_analytics.data import Data
|
16
|
+
|
17
|
+
from .dataframes import get_glucose_tested_only_df, get_screening_df
|
18
|
+
from .tables import EligibleP12Table, HasDmTable
|
19
|
+
|
20
|
+
|
21
|
+
def get_tables() -> dict[str, Data]:
|
22
|
+
"""
|
23
|
+
results = get_table()
|
24
|
+
results.get("fbg").to_csv(folder="/Users/erikvw/Documents/")
|
25
|
+
"""
|
26
|
+
df_screening = get_screening_df()
|
27
|
+
df_has_dm = df_screening[(df_screening["has_dm"] == "Yes")]
|
28
|
+
df_no_dm = df_screening[(df_screening["has_dm"] == "No")]
|
29
|
+
df_fbg = get_glucose_tested_only_df(df_screening)
|
30
|
+
|
31
|
+
df_not_tested = df_no_dm.copy()
|
32
|
+
df_not_eligible_p1p2 = df_not_tested[
|
33
|
+
~(
|
34
|
+
(df_not_tested["eligible_part_one"] == "Yes")
|
35
|
+
& (df_not_tested["eligible_part_two"] == "Yes")
|
36
|
+
)
|
37
|
+
]
|
38
|
+
df_not_tested.drop(df_not_eligible_p1p2.index, inplace=True)
|
39
|
+
df_not_tested.drop(df_fbg.index, inplace=True)
|
40
|
+
|
41
|
+
df_stats = pd.DataFrame(
|
42
|
+
{
|
43
|
+
"df": ["df_screening", "df_has_dm", "df_no_dm", "df_not_tested", "df_fbg"],
|
44
|
+
"count": [
|
45
|
+
len(df_screening),
|
46
|
+
len(df_has_dm),
|
47
|
+
len(df_no_dm),
|
48
|
+
len(df_not_tested),
|
49
|
+
len(df_fbg),
|
50
|
+
],
|
51
|
+
}
|
52
|
+
)
|
53
|
+
|
54
|
+
results = {"stats": df_stats}
|
55
|
+
for key, df in {
|
56
|
+
"screening": df_screening,
|
57
|
+
"has_dm": df_has_dm,
|
58
|
+
"no_dm": df_no_dm,
|
59
|
+
"not_tested": df_not_tested,
|
60
|
+
"fbg": df_fbg,
|
61
|
+
}.items():
|
62
|
+
dfs = []
|
63
|
+
for tbl_cls in [
|
64
|
+
GenderTable,
|
65
|
+
AgeTable,
|
66
|
+
WaistCircumferenceTable,
|
67
|
+
BmiTable,
|
68
|
+
BpTable,
|
69
|
+
ArtTable,
|
70
|
+
FastingTable,
|
71
|
+
FbgTable,
|
72
|
+
OgttTable,
|
73
|
+
FbgOgttTable,
|
74
|
+
HbA1cTable,
|
75
|
+
EligibleP12Table,
|
76
|
+
HasDmTable,
|
77
|
+
]:
|
78
|
+
tbl = tbl_cls(main_df=df)
|
79
|
+
dfs.append(tbl.table_df)
|
80
|
+
results.update({key: Data(key, pd.concat(list(dfs)), df, "meta3")})
|
81
|
+
return results
|
@@ -0,0 +1,106 @@
|
|
1
|
+
import pandas as pd
|
2
|
+
from edc_analytics.constants import N_ONLY, N_WITH_COL_PROP, N_WITH_ROW_PROP
|
3
|
+
from edc_analytics.row import RowDefinition, RowDefinitions
|
4
|
+
from edc_analytics.table import Table
|
5
|
+
|
6
|
+
|
7
|
+
class EligibleP12Table(Table):
|
8
|
+
def __init__(self, main_df: pd.DataFrame = None):
|
9
|
+
super().__init__(colname="", main_df=main_df, title="Eligible by Part 1/2")
|
10
|
+
|
11
|
+
@property
|
12
|
+
def row_definitions(self) -> RowDefinitions:
|
13
|
+
df_tmp = self.main_df.copy()
|
14
|
+
row_defs = RowDefinitions(reverse_rows=False)
|
15
|
+
row0 = RowDefinition(
|
16
|
+
title=self.title,
|
17
|
+
label=self.default_sublabel,
|
18
|
+
condition=(df_tmp["gender"].notna()),
|
19
|
+
columns={
|
20
|
+
"F": (N_ONLY, 2),
|
21
|
+
"M": (N_ONLY, 2),
|
22
|
+
"All": (N_ONLY, 2),
|
23
|
+
},
|
24
|
+
drop=False,
|
25
|
+
)
|
26
|
+
row_defs.add(row0)
|
27
|
+
columns = {
|
28
|
+
"F": (N_WITH_COL_PROP, 2),
|
29
|
+
"M": (N_WITH_COL_PROP, 2),
|
30
|
+
"All": (N_WITH_ROW_PROP, 2),
|
31
|
+
}
|
32
|
+
row_defs.add(
|
33
|
+
RowDefinition(
|
34
|
+
label="Eligible P1",
|
35
|
+
condition=(df_tmp["eligible_part_one"] == "Yes"),
|
36
|
+
columns=columns,
|
37
|
+
drop=False,
|
38
|
+
)
|
39
|
+
)
|
40
|
+
row_defs.add(
|
41
|
+
RowDefinition(
|
42
|
+
label="Eligible P2",
|
43
|
+
condition=(df_tmp["eligible_part_two"] == "Yes"),
|
44
|
+
columns=columns,
|
45
|
+
drop=False,
|
46
|
+
)
|
47
|
+
)
|
48
|
+
|
49
|
+
row_defs.add(
|
50
|
+
RowDefinition(
|
51
|
+
label="Eligible P1 & P2",
|
52
|
+
condition=(df_tmp["eligible_part_one"] == "Yes")
|
53
|
+
& (df_tmp["eligible_part_two"] == "Yes"),
|
54
|
+
columns=columns,
|
55
|
+
drop=False,
|
56
|
+
)
|
57
|
+
)
|
58
|
+
# note already_fasted accepts Y/N/NA
|
59
|
+
row_defs.add(
|
60
|
+
RowDefinition(
|
61
|
+
label="Glucose tested (fasted on day)",
|
62
|
+
condition=(
|
63
|
+
(df_tmp["already_fasted"] == "Yes")
|
64
|
+
& ((df_tmp["fbg"].notna()) | (df_tmp["ogtt"].notna()))
|
65
|
+
),
|
66
|
+
columns=columns,
|
67
|
+
drop=True,
|
68
|
+
)
|
69
|
+
)
|
70
|
+
|
71
|
+
row_defs.add(
|
72
|
+
RowDefinition(
|
73
|
+
label="Glucose tested (returned fasted)",
|
74
|
+
condition=(
|
75
|
+
(df_tmp["already_fasted"] == "No")
|
76
|
+
& ((df_tmp["fbg"].notna()) | (df_tmp["ogtt"].notna()))
|
77
|
+
),
|
78
|
+
columns=columns,
|
79
|
+
drop=True,
|
80
|
+
)
|
81
|
+
)
|
82
|
+
|
83
|
+
row_defs.add(
|
84
|
+
RowDefinition(
|
85
|
+
label="Glucose tested (N/A)",
|
86
|
+
condition=(df_tmp["already_fasted"] == "N/A")
|
87
|
+
& ((df_tmp["fbg"].notna()) | (df_tmp["ogtt"].notna())),
|
88
|
+
columns=columns,
|
89
|
+
drop=True,
|
90
|
+
)
|
91
|
+
)
|
92
|
+
|
93
|
+
row_defs.add(
|
94
|
+
RowDefinition(
|
95
|
+
label="No glucose test (not fasted on day and did not return)",
|
96
|
+
condition=(
|
97
|
+
(df_tmp["eligible_part_one"] == "Yes")
|
98
|
+
& (df_tmp["eligible_part_two"] == "Yes")
|
99
|
+
& (df_tmp["fbg"].isna())
|
100
|
+
& (df_tmp["ogtt"].isna())
|
101
|
+
),
|
102
|
+
columns=columns,
|
103
|
+
drop=False,
|
104
|
+
)
|
105
|
+
)
|
106
|
+
return row_defs
|
File without changes
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import pandas as pd
|
2
|
+
from edc_analytics.custom_tables import AgeTable, GenderTable
|
3
|
+
from edc_analytics.table import Table
|
4
|
+
|
5
|
+
|
6
|
+
class GlucoseTable(Table):
|
7
|
+
"""
|
8
|
+
gender
|
9
|
+
age
|
10
|
+
fasting
|
11
|
+
fbg mean
|
12
|
+
ogtt mean
|
13
|
+
fbg + ogtt count
|
14
|
+
"""
|
15
|
+
|
16
|
+
def __init__(self, main_df: pd.DataFrame = None):
|
17
|
+
super().__init__(colname="", main_df=main_df, title="Glucose (enrolled)")
|
18
|
+
|
19
|
+
def build_table_df(self) -> None:
|
20
|
+
super().build_table_df()
|
21
|
+
df = self.main_df
|
22
|
+
s = df.groupby("subject_identifier")[["age_in_years", "gender"]].value_counts()
|
23
|
+
df_tmp = s.to_frame()
|
24
|
+
df_tmp = df_tmp.reset_index()
|
25
|
+
gender_tbl = GenderTable(main_df=df_tmp).table_df
|
26
|
+
age_tbl = AgeTable(main_df=df_tmp).table_df
|
27
|
+
self.table_df = pd.concat([self.table_df, gender_tbl, age_tbl])
|
28
|
+
self.table_df.reset_index(drop=True, inplace=True)
|
@@ -0,0 +1,61 @@
|
|
1
|
+
import pandas as pd
|
2
|
+
from edc_analytics.constants import N_ONLY, N_WITH_COL_PROP, N_WITH_ROW_PROP
|
3
|
+
from edc_analytics.row import RowDefinition, RowDefinitions
|
4
|
+
from edc_analytics.table import Table
|
5
|
+
|
6
|
+
|
7
|
+
class HasDmTable(Table):
|
8
|
+
def __init__(self, main_df: pd.DataFrame = None):
|
9
|
+
super().__init__(
|
10
|
+
colname="", main_df=main_df, title="Subjects reporting having Diabetes"
|
11
|
+
)
|
12
|
+
|
13
|
+
@property
|
14
|
+
def row_definitions(self) -> RowDefinitions:
|
15
|
+
df_tmp = self.main_df.copy()
|
16
|
+
row_defs = RowDefinitions(reverse_rows=False)
|
17
|
+
row0 = RowDefinition(
|
18
|
+
title=self.title,
|
19
|
+
label=self.default_sublabel,
|
20
|
+
condition=(df_tmp["gender"].notna()),
|
21
|
+
columns={
|
22
|
+
"F": (N_ONLY, 2),
|
23
|
+
"M": (N_ONLY, 2),
|
24
|
+
"All": (N_ONLY, 2),
|
25
|
+
},
|
26
|
+
drop=False,
|
27
|
+
)
|
28
|
+
row_defs.add(row0)
|
29
|
+
columns = {
|
30
|
+
"F": (N_WITH_COL_PROP, 2),
|
31
|
+
"M": (N_WITH_COL_PROP, 2),
|
32
|
+
"All": (N_WITH_ROW_PROP, 2),
|
33
|
+
}
|
34
|
+
row_defs.add(
|
35
|
+
RowDefinition(
|
36
|
+
label="Yes",
|
37
|
+
condition=(df_tmp["has_dm"] == "Yes"),
|
38
|
+
columns=columns,
|
39
|
+
drop=True,
|
40
|
+
)
|
41
|
+
)
|
42
|
+
|
43
|
+
row_defs.add(
|
44
|
+
RowDefinition(
|
45
|
+
label="No",
|
46
|
+
condition=(df_tmp["has_dm"] == "No"),
|
47
|
+
columns=columns,
|
48
|
+
drop=True,
|
49
|
+
)
|
50
|
+
)
|
51
|
+
|
52
|
+
row_defs.add(
|
53
|
+
RowDefinition(
|
54
|
+
label="Not evaluated",
|
55
|
+
condition=(df_tmp["has_dm"] == "unk"),
|
56
|
+
columns=columns,
|
57
|
+
drop=True,
|
58
|
+
)
|
59
|
+
)
|
60
|
+
|
61
|
+
return row_defs
|
File without changes
|
@@ -0,0 +1,94 @@
|
|
1
|
+
from datetime import datetime
|
2
|
+
|
3
|
+
import numpy as np
|
4
|
+
import pandas as pd
|
5
|
+
from dateutil.relativedelta import relativedelta
|
6
|
+
from django.test import TestCase
|
7
|
+
from edc_constants.constants import YES
|
8
|
+
|
9
|
+
from meta_analytics.dataframes import EndpointByDate
|
10
|
+
|
11
|
+
|
12
|
+
class TestEndpointsByDate(TestCase):
|
13
|
+
def test_case_one(self):
|
14
|
+
def d(m: int, w: int | None = None):
|
15
|
+
if w:
|
16
|
+
return datetime.now() - relativedelta(months=m, weeks=w)
|
17
|
+
return datetime.now() - relativedelta(months=m)
|
18
|
+
|
19
|
+
def append_to(subject_df, endpoint_df):
|
20
|
+
if endpoint_df.empty:
|
21
|
+
endpoint_df = subject_df.copy()
|
22
|
+
elif subject_df.empty:
|
23
|
+
pass
|
24
|
+
else:
|
25
|
+
endpoint_df = pd.concat([endpoint_df, subject_df])
|
26
|
+
endpoint_df = self.endpoint_df.sort_values(
|
27
|
+
by=["subject_identifier", "visit_code"]
|
28
|
+
)
|
29
|
+
endpoint_df.reset_index(drop=True, inplace=True)
|
30
|
+
|
31
|
+
subject_identifier = "101-1"
|
32
|
+
data = {
|
33
|
+
"subject_identifier": [subject_identifier] * 10,
|
34
|
+
"visit_code": [
|
35
|
+
1000.0,
|
36
|
+
1005.0,
|
37
|
+
1010.0,
|
38
|
+
1030.0,
|
39
|
+
1060.0,
|
40
|
+
1090.0,
|
41
|
+
1120.0,
|
42
|
+
1115.0,
|
43
|
+
1118.0,
|
44
|
+
1210.0,
|
45
|
+
],
|
46
|
+
"fasting": [YES] * 10,
|
47
|
+
"fbg_datetime": [
|
48
|
+
d(0),
|
49
|
+
d(0, 2),
|
50
|
+
d(1),
|
51
|
+
d(3),
|
52
|
+
d(6),
|
53
|
+
d(9),
|
54
|
+
d(12),
|
55
|
+
d(15),
|
56
|
+
d(18),
|
57
|
+
d(21),
|
58
|
+
],
|
59
|
+
"fbg_value": [np.nan, 6.9, 6.9, 7.1, 7.1, 6.4, 7.0, np.nan, 8.1, np.nan],
|
60
|
+
"ogtt_value": [
|
61
|
+
np.nan,
|
62
|
+
np.nan,
|
63
|
+
np.nan,
|
64
|
+
np.nan,
|
65
|
+
np.nan,
|
66
|
+
np.nan,
|
67
|
+
np.nan,
|
68
|
+
np.nan,
|
69
|
+
7.9,
|
70
|
+
np.nan,
|
71
|
+
],
|
72
|
+
}
|
73
|
+
|
74
|
+
fbgs = [np.nan, 6.9, 6.9, 7.1, 7.1, 6.4, 7.0, np.nan, 8.1, np.nan]
|
75
|
+
ogtts = [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, 7.9, np.nan]
|
76
|
+
|
77
|
+
fbgs = [np.nan, 6.9, 6.9, 7.1, 7.1, 6.4, 7.0, 8.1, np.nan, np.nan]
|
78
|
+
ogtts = [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, np.nan, 7.9, np.nan, np.nan]
|
79
|
+
|
80
|
+
data.update(fbg_values=fbgs, ogtt_values=ogtts)
|
81
|
+
subject_df = pd.DataFrame(data)
|
82
|
+
subject_df["fasting"] = subject_df.apply(
|
83
|
+
lambda r: np.nan if pd.isna(r.fbg_value) else r.fbg_value, axis=1
|
84
|
+
)
|
85
|
+
subject_df["fbg_datetime"] = subject_df.apply(
|
86
|
+
lambda r: np.nan if pd.isna(r.fbg_value) else r.fbg_datetime, axis=1
|
87
|
+
)
|
88
|
+
|
89
|
+
endpoint_df = pd.DataFrame()
|
90
|
+
for index, row in subject_df.iterrows():
|
91
|
+
cls = EndpointByDate(index, row, fbg_threshhold=7.0, ogtt_threshhold=11.1)
|
92
|
+
append_to(cls.subject_df, endpoint_df)
|
93
|
+
|
94
|
+
endpoint_df
|
meta_auth/auth_objects.py
CHANGED
@@ -1,10 +1,32 @@
|
|
1
1
|
from django.conf import settings
|
2
2
|
from edc_auth.get_app_codenames import get_app_codenames
|
3
3
|
|
4
|
+
META_REPORTS = "META_REPORTS"
|
5
|
+
META_REPORTS_AUDIT = "META_REPORTS_AUDIT"
|
6
|
+
META_PHARMACIST = "META_PHARMACIST"
|
7
|
+
|
8
|
+
|
4
9
|
clinic_codenames = get_app_codenames(
|
5
10
|
"meta_prn", "meta_subject", "meta_consent", list_app="meta_lists"
|
6
11
|
)
|
7
12
|
|
13
|
+
reports_codenames = get_app_codenames("meta_reports")
|
14
|
+
reports_codenames.remove("meta_reports.view_impsubstitutions")
|
15
|
+
|
16
|
+
meta_pharmacy_codenames = get_app_codenames("meta_pharmacy")
|
17
|
+
meta_pharmacy_codenames.extend(get_app_codenames("django_pylabels"))
|
18
|
+
meta_pharmacy_codenames.append("meta_reports.view_impsubstitutions")
|
19
|
+
meta_pharmacy_codenames.append("meta_reports.viewallsites_impsubstitutions")
|
20
|
+
excluded_meta_pharmacy_codenames = [
|
21
|
+
"meta_pharmacy.add_rx",
|
22
|
+
"meta_pharmacy.change_rx",
|
23
|
+
"meta_pharmacy.delete_rx",
|
24
|
+
]
|
25
|
+
|
26
|
+
meta_pharmacy_codenames = [
|
27
|
+
c for c in meta_pharmacy_codenames if c not in excluded_meta_pharmacy_codenames
|
28
|
+
]
|
29
|
+
|
8
30
|
add_perms = []
|
9
31
|
if not settings.LIVE_SYSTEM:
|
10
32
|
add_perms = [
|
meta_auth/auths.py
CHANGED
@@ -20,13 +20,26 @@ from edc_pharmacy.auth_objects import (
|
|
20
20
|
PHARMACY_PRESCRIBER,
|
21
21
|
SITE_PHARMACIST_ROLE,
|
22
22
|
)
|
23
|
+
from edc_qareports.auth_objects import QA_REPORTS_AUDIT_ROLE, QA_REPORTS_ROLE
|
23
24
|
from edc_qol.auth_objects import QOL, QOL_SUPER, QOL_VIEW
|
24
25
|
from edc_randomization.auth_objects import RANDO_BLINDED, RANDO_UNBLINDED
|
25
26
|
from edc_screening.auth_objects import SCREENING, SCREENING_SUPER, SCREENING_VIEW
|
26
27
|
from edc_subject_dashboard.auths import SUBJECT_VIEW
|
27
28
|
from edc_unblinding.auth_objects import UNBLINDING_REQUESTORS
|
28
29
|
|
29
|
-
from .auth_objects import
|
30
|
+
from .auth_objects import (
|
31
|
+
META_PHARMACIST,
|
32
|
+
META_REPORTS,
|
33
|
+
META_REPORTS_AUDIT,
|
34
|
+
clinic_codenames,
|
35
|
+
meta_pharmacy_codenames,
|
36
|
+
reports_codenames,
|
37
|
+
screening_codenames,
|
38
|
+
)
|
39
|
+
|
40
|
+
site_auths.add_group(*reports_codenames, name=META_REPORTS)
|
41
|
+
site_auths.add_group(*reports_codenames, name=META_REPORTS_AUDIT, view_only=True)
|
42
|
+
site_auths.add_group(*meta_pharmacy_codenames, name=META_PHARMACIST)
|
30
43
|
|
31
44
|
# update edc_auth default groups
|
32
45
|
site_auths.update_group(*clinic_codenames, name=AUDITOR, view_only=True)
|
@@ -59,9 +72,11 @@ site_auths.update_role(
|
|
59
72
|
DATA_MANAGER_EXPORT,
|
60
73
|
name=DATA_EXPORTER_ROLE,
|
61
74
|
)
|
62
|
-
site_auths.update_role(RANDO_UNBLINDED, PII, name=PHARMACIST_ROLE)
|
63
|
-
site_auths.update_role(RANDO_BLINDED, PII, name=SITE_PHARMACIST_ROLE)
|
75
|
+
site_auths.update_role(RANDO_UNBLINDED, PII, META_PHARMACIST, name=PHARMACIST_ROLE)
|
76
|
+
site_auths.update_role(RANDO_BLINDED, PII, META_PHARMACIST, name=SITE_PHARMACIST_ROLE)
|
64
77
|
site_auths.update_role(SUBJECT_VIEW, SCREENING_VIEW, name=DATA_MANAGER_ROLE)
|
65
78
|
site_auths.update_role(
|
66
79
|
SUBJECT_VIEW, SCREENING_VIEW, ACTION_ITEM, UNBLINDING_REQUESTORS, name=TMG_ROLE
|
67
80
|
)
|
81
|
+
site_auths.update_role(META_REPORTS, name=QA_REPORTS_ROLE)
|
82
|
+
site_auths.update_role(META_REPORTS_AUDIT, name=QA_REPORTS_AUDIT_ROLE)
|