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,146 @@
|
|
1
|
+
from django.contrib.sites.models import Site
|
2
|
+
from django.core.exceptions import ObjectDoesNotExist
|
3
|
+
from django_pylabels.models import LabelSpecification
|
4
|
+
from edc_pharmacy.models import (
|
5
|
+
Assignment,
|
6
|
+
Container,
|
7
|
+
ContainerType,
|
8
|
+
ContainerUnits,
|
9
|
+
Formulation,
|
10
|
+
Location,
|
11
|
+
Product,
|
12
|
+
Supplier,
|
13
|
+
)
|
14
|
+
from edc_pylabels.models import LabelConfiguration
|
15
|
+
from edc_pylabels.site_label_configs import site_label_configs
|
16
|
+
|
17
|
+
|
18
|
+
def update_initial_pharmacy_data():
|
19
|
+
update_assignment()
|
20
|
+
update_container()
|
21
|
+
update_location()
|
22
|
+
update_product()
|
23
|
+
update_supplier()
|
24
|
+
update_labels()
|
25
|
+
|
26
|
+
|
27
|
+
def update_assignment():
|
28
|
+
"""For a trial with just active and placebo.
|
29
|
+
|
30
|
+
Better to get these labels from edc_randomizer.
|
31
|
+
"""
|
32
|
+
for assignment in ["placebo", "active"]:
|
33
|
+
try:
|
34
|
+
Assignment.objects.get(name=assignment)
|
35
|
+
except ObjectDoesNotExist:
|
36
|
+
Assignment.objects.create(name=assignment, display_name=assignment.title())
|
37
|
+
|
38
|
+
|
39
|
+
def update_container():
|
40
|
+
"""Here we order a number of tablets. The manufacturer sends
|
41
|
+
the order in large containers, barrels of about 30K tablets
|
42
|
+
per barrel. We repack/decant into bottles of 128 tablets
|
43
|
+
"""
|
44
|
+
tablet_type = ContainerType.objects.get(name="tablet")
|
45
|
+
bottle_type = ContainerType.objects.get(name="bottle")
|
46
|
+
units = ContainerUnits.objects.get(name="tablet")
|
47
|
+
opts = {
|
48
|
+
"tablet": dict(
|
49
|
+
name="tablet",
|
50
|
+
display_name="Tablet",
|
51
|
+
container_type=tablet_type,
|
52
|
+
units=units,
|
53
|
+
qty=1,
|
54
|
+
may_order_as=True,
|
55
|
+
max_per_subject=0,
|
56
|
+
),
|
57
|
+
"bottle30k": dict(
|
58
|
+
name="bottle30k",
|
59
|
+
display_name="Barrel 30K",
|
60
|
+
container_type=bottle_type,
|
61
|
+
units=units,
|
62
|
+
qty=30000,
|
63
|
+
may_receive_as=True,
|
64
|
+
max_per_subject=0,
|
65
|
+
),
|
66
|
+
"bottle128": dict(
|
67
|
+
name="bottle128",
|
68
|
+
display_name="Bottle 128",
|
69
|
+
container_type=bottle_type,
|
70
|
+
units=units,
|
71
|
+
qty=128,
|
72
|
+
max_per_subject=3,
|
73
|
+
may_repack_as=True,
|
74
|
+
may_request_as=True,
|
75
|
+
may_dispense_as=True,
|
76
|
+
),
|
77
|
+
}
|
78
|
+
for name, data in opts.items():
|
79
|
+
try:
|
80
|
+
Container.objects.get(name=name)
|
81
|
+
except ObjectDoesNotExist:
|
82
|
+
Container.objects.create(**data)
|
83
|
+
|
84
|
+
|
85
|
+
def update_location():
|
86
|
+
"""Base the locations on the sites in the trial plus
|
87
|
+
a "central" pharmacy"""
|
88
|
+
for obj in Location.objects.exclude(name="central"):
|
89
|
+
obj.site_id = Site.objects.get(name=obj.name).id
|
90
|
+
obj.save(update_fields=["site_id"])
|
91
|
+
|
92
|
+
|
93
|
+
def update_product():
|
94
|
+
"""Define the product, in this case just two; active and placebo.
|
95
|
+
|
96
|
+
Formulation is defined before running this script.
|
97
|
+
|
98
|
+
In this case the formulation is just the study drug/IMP.
|
99
|
+
"""
|
100
|
+
formulation = Formulation.objects.get()
|
101
|
+
active = Assignment.objects.get(name="active")
|
102
|
+
placebo = Assignment.objects.get(name="placebo")
|
103
|
+
try:
|
104
|
+
Product.objects.get(formulation=formulation, assignment=active)
|
105
|
+
except ObjectDoesNotExist:
|
106
|
+
Product(assignment=active, formulation=formulation).save()
|
107
|
+
try:
|
108
|
+
Product.objects.get(formulation=formulation, assignment=placebo)
|
109
|
+
except ObjectDoesNotExist:
|
110
|
+
Product(assignment=placebo, formulation=formulation).save()
|
111
|
+
|
112
|
+
|
113
|
+
def update_supplier():
|
114
|
+
"""In this case MERCK"""
|
115
|
+
try:
|
116
|
+
Supplier.objects.get(name="merck")
|
117
|
+
except ObjectDoesNotExist:
|
118
|
+
Supplier(name="merck").save()
|
119
|
+
|
120
|
+
|
121
|
+
def update_labels():
|
122
|
+
"""The default label spec is a 2 x 6 label sheet
|
123
|
+
|
124
|
+
Add "label congigs" as registered in the "site_label_configs"
|
125
|
+
global. In this case there are three labels:
|
126
|
+
* a bulk label for the barrels
|
127
|
+
* a generic vertical label for decanted stock (bottles of 128)
|
128
|
+
* a patient label for allocated stock (bottles of 128)
|
129
|
+
|
130
|
+
The patient label will be placed over the generic vertical label
|
131
|
+
once the stock item is allocated to a subject.
|
132
|
+
"""
|
133
|
+
try:
|
134
|
+
default = LabelSpecification.objects.get(name="default")
|
135
|
+
except ObjectDoesNotExist:
|
136
|
+
LabelSpecification().save()
|
137
|
+
default = LabelSpecification.objects.get(name="default")
|
138
|
+
|
139
|
+
for name, label_config in site_label_configs.registry.items():
|
140
|
+
LabelConfiguration.objects.create(name=name, label_specification=default)
|
141
|
+
for label_configuration in LabelConfiguration.objects.filter(name__contains="patient"):
|
142
|
+
label_configuration.requires_allocation = True
|
143
|
+
label_configuration.save()
|
144
|
+
|
145
|
+
|
146
|
+
__all__ = ["update_initial_pharmacy_data"]
|
meta_prn/action_items.py
CHANGED
@@ -27,6 +27,7 @@ from .constants import (
|
|
27
27
|
OFFSCHEDULE_PREGNANCY_ACTION,
|
28
28
|
OFFSTUDY_MEDICATION_ACTION,
|
29
29
|
PREGNANCY_NOTIFICATION_ACTION,
|
30
|
+
REFERRAL,
|
30
31
|
UNBLINDING_REQUEST_ACTION,
|
31
32
|
UNBLINDING_REVIEW_ACTION,
|
32
33
|
)
|
@@ -136,7 +137,7 @@ class DmReferralAction(ActionWithNotification):
|
|
136
137
|
name = DM_REFFERAL_ACTION
|
137
138
|
display_name = "Diabetes referral"
|
138
139
|
notification_display_name = "Diabetes referral"
|
139
|
-
parent_action_names =
|
140
|
+
parent_action_names = [OFFSTUDY_MEDICATION_ACTION]
|
140
141
|
reference_model = "meta_prn.dmreferral"
|
141
142
|
show_link_to_changelist = True
|
142
143
|
show_link_to_add = True
|
@@ -182,6 +183,13 @@ class OffStudyMedicationAction(ActionWithNotification):
|
|
182
183
|
priority = HIGH_PRIORITY
|
183
184
|
singleton = True
|
184
185
|
|
186
|
+
def get_next_actions(self):
|
187
|
+
if self.reference_obj.reason == REFERRAL:
|
188
|
+
next_actions = [DM_REFFERAL_ACTION]
|
189
|
+
else:
|
190
|
+
next_actions = [END_OF_STUDY_ACTION]
|
191
|
+
return next_actions
|
192
|
+
|
185
193
|
|
186
194
|
class UnblindingRequestAction(ActionWithNotification):
|
187
195
|
name = UNBLINDING_REQUEST_ACTION
|
@@ -57,11 +57,15 @@ class PregnancyNotificationAdmin(
|
|
57
57
|
"subject_identifier",
|
58
58
|
"dashboard",
|
59
59
|
"edd",
|
60
|
-
"
|
60
|
+
"contact_agreed",
|
61
61
|
)
|
62
62
|
return custom_fields + tuple(f for f in list_display if f not in custom_fields)
|
63
63
|
|
64
64
|
def get_list_filter(self, request) -> Tuple[str, ...]:
|
65
|
-
list_filter = super().
|
65
|
+
list_filter = super().get_list_filter(request)
|
66
66
|
custom_fields = ("edd", "may_contact")
|
67
67
|
return custom_fields + tuple(f for f in list_filter if f not in custom_fields)
|
68
|
+
|
69
|
+
@admin.display(description="May contact?", ordering="may_contact")
|
70
|
+
def contact_agreed(self, obj):
|
71
|
+
return obj.may_contact
|
@@ -37,9 +37,9 @@ def update_for_protocol_incident(apps, schema_editor):
|
|
37
37
|
).update(action_type=action_type)
|
38
38
|
|
39
39
|
# update crf metadata if there is any
|
40
|
-
action_item_model_cls.objects.filter(
|
41
|
-
|
42
|
-
).update(reference_model="meta_prn.protocolincident")
|
40
|
+
# action_item_model_cls.objects.filter(
|
41
|
+
# reference_model="meta_prn.protocoldeviationviolation"
|
42
|
+
# ).update(reference_model="meta_prn.protocolincident")
|
43
43
|
|
44
44
|
|
45
45
|
class Migration(migrations.Migration):
|
@@ -18,70 +18,73 @@ def create_missing_offschedule(apps, schema_editor):
|
|
18
18
|
subject_schedule_history_model_cls = apps.get_model(
|
19
19
|
"edc_visit_schedule.subjectschedulehistory"
|
20
20
|
)
|
21
|
-
|
21
|
+
try:
|
22
|
+
action_type = action_type_model_cls.objects.get(name=OFFSCHEDULE_ACTION)
|
23
|
+
except ObjectDoesNotExist:
|
24
|
+
pass
|
25
|
+
else:
|
26
|
+
# update subject_schedule_history
|
27
|
+
subject_schedule_history_model_cls.objects.filter(
|
28
|
+
offschedule_model="meta_prn.endofstudy"
|
29
|
+
).update(offschedule_model="meta_prn.offschedule")
|
22
30
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
"Select eos.id, eos.subject_identifier from meta_prn_endofstudy as eos "
|
30
|
-
"left join meta_prn_offschedule as off on eos.subject_identifier = off.subject_identifier "
|
31
|
-
"where off.id is null"
|
32
|
-
)
|
33
|
-
qs = eos_model_cls.objects.raw(sql)
|
31
|
+
sql = (
|
32
|
+
"Select eos.id, eos.subject_identifier from meta_prn_endofstudy as eos "
|
33
|
+
"left join meta_prn_offschedule as off on eos.subject_identifier = off.subject_identifier "
|
34
|
+
"where off.id is null"
|
35
|
+
)
|
36
|
+
qs = eos_model_cls.objects.raw(sql)
|
34
37
|
|
35
|
-
|
36
|
-
|
38
|
+
qs = [obj for obj in qs]
|
39
|
+
total = len(qs)
|
37
40
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
41
|
+
# create missing offschedule model instances
|
42
|
+
for eos in tqdm(qs, total=total):
|
43
|
+
# create action items model instances
|
44
|
+
tracking_identifier = uuid4().hex
|
45
|
+
try:
|
46
|
+
action_item = action_item_model_cls.objects.get(
|
47
|
+
subject_identifier=eos.subject_identifier, action_type=action_type
|
48
|
+
)
|
49
|
+
except ObjectDoesNotExist:
|
50
|
+
action_item = action_item_model_cls(
|
51
|
+
action_identifier=uuid4().hex.upper(),
|
52
|
+
subject_identifier=eos.subject_identifier,
|
53
|
+
action_type=action_type,
|
54
|
+
report_datetime=eos.offschedule_datetime,
|
55
|
+
priority=HIGH_PRIORITY,
|
56
|
+
status=NEW,
|
57
|
+
auto_created=True,
|
58
|
+
reference_model="meta_prn.offschedule",
|
59
|
+
)
|
60
|
+
action_item.save()
|
61
|
+
action_item.refresh_from_db()
|
62
|
+
if not action_item.action_identifier:
|
63
|
+
raise ValueError("Action identifier cannot be null")
|
64
|
+
action_item.status = NEW
|
65
|
+
action_item.save()
|
66
|
+
action_item.refresh_from_db()
|
67
|
+
offschedule = offschedule_model_cls(
|
49
68
|
subject_identifier=eos.subject_identifier,
|
50
|
-
|
69
|
+
action_identifier=action_item.action_identifier,
|
70
|
+
tracking_identifier=tracking_identifier,
|
71
|
+
action_item=action_item,
|
51
72
|
report_datetime=eos.offschedule_datetime,
|
52
|
-
|
53
|
-
|
54
|
-
auto_created=True,
|
55
|
-
reference_model="meta_prn.offschedule",
|
73
|
+
offschedule_datetime=eos.offschedule_datetime,
|
74
|
+
site_id=eos.site.id,
|
56
75
|
)
|
76
|
+
action_item.status = CLOSED
|
57
77
|
action_item.save()
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
subject_identifier=eos.subject_identifier,
|
66
|
-
action_identifier=action_item.action_identifier,
|
67
|
-
tracking_identifier=tracking_identifier,
|
68
|
-
action_item=action_item,
|
69
|
-
report_datetime=eos.offschedule_datetime,
|
70
|
-
offschedule_datetime=eos.offschedule_datetime,
|
71
|
-
site_id=eos.site.id,
|
72
|
-
)
|
73
|
-
action_item.status = CLOSED
|
74
|
-
action_item.save()
|
75
|
-
offschedule.save()
|
76
|
-
eos.parent_action_item = action_item
|
77
|
-
eos.action_item.status = NEW
|
78
|
-
eos.action_item.save()
|
79
|
-
eos.action_item.refresh_from_db()
|
80
|
-
eos.refresh_from_db()
|
81
|
-
eos.save()
|
78
|
+
offschedule.save()
|
79
|
+
eos.parent_action_item = action_item
|
80
|
+
eos.action_item.status = NEW
|
81
|
+
eos.action_item.save()
|
82
|
+
eos.action_item.refresh_from_db()
|
83
|
+
eos.refresh_from_db()
|
84
|
+
eos.save()
|
82
85
|
|
83
|
-
|
84
|
-
|
86
|
+
for obj in eos_model_cls.objects.all():
|
87
|
+
obj.save()
|
85
88
|
|
86
89
|
|
87
90
|
class Migration(migrations.Migration):
|
@@ -1,6 +1,6 @@
|
|
1
1
|
from dateutil.relativedelta import relativedelta
|
2
2
|
from django.core.exceptions import ObjectDoesNotExist
|
3
|
-
from django.test import TestCase
|
3
|
+
from django.test import TestCase
|
4
4
|
from edc_action_item.models import ActionItem
|
5
5
|
from edc_appointment.constants import COMPLETE_APPT
|
6
6
|
from edc_appointment.models import Appointment
|
@@ -18,11 +18,10 @@ from meta_prn.constants import (
|
|
18
18
|
from meta_prn.models import DmReferral, OnScheduleDmReferral
|
19
19
|
from meta_screening.tests.meta_test_case_mixin import MetaTestCaseMixin
|
20
20
|
from meta_subject.constants import DM_FOLLOWUP_ACTION
|
21
|
-
from meta_subject.models import
|
21
|
+
from meta_subject.models import DmEndpoint, DmFollowup, SubjectVisit
|
22
22
|
from meta_visit_schedule.constants import DM_BASELINE, DM_FOLLOWUP, SCHEDULE_DM_REFERRAL
|
23
23
|
|
24
24
|
|
25
|
-
@tag("1")
|
26
25
|
class TestDmReferral(MetaTestCaseMixin, TestCase):
|
27
26
|
def setUp(self):
|
28
27
|
super().setUp()
|
@@ -49,7 +48,6 @@ class TestDmReferral(MetaTestCaseMixin, TestCase):
|
|
49
48
|
except ObjectDoesNotExist:
|
50
49
|
self.fail("OnScheduleDmReferral unexpectedly does not exist")
|
51
50
|
|
52
|
-
@tag("1")
|
53
51
|
def test_dm_referral_action_creates_offschedule_action(self):
|
54
52
|
subject_visit = self.get_next_subject_visit(self.subject_visit)
|
55
53
|
subject_visit = self.get_next_subject_visit(subject_visit)
|
@@ -117,7 +115,6 @@ class TestDmReferral(MetaTestCaseMixin, TestCase):
|
|
117
115
|
except ObjectDoesNotExist:
|
118
116
|
self.fail(f"{DM_FOLLOWUP_ACTION} Action item unexpectedly does not exist")
|
119
117
|
|
120
|
-
@tag("1")
|
121
118
|
def test_dm_referral2(self):
|
122
119
|
subject_visit = self.get_next_subject_visit(self.subject_visit)
|
123
120
|
subject_visit = self.get_next_subject_visit(subject_visit)
|
@@ -146,7 +143,7 @@ class TestDmReferral(MetaTestCaseMixin, TestCase):
|
|
146
143
|
info_source=PATIENT,
|
147
144
|
)
|
148
145
|
|
149
|
-
|
146
|
+
DmEndpoint.objects.create(
|
150
147
|
subject_visit=subject_visit,
|
151
148
|
report_datetime=get_utcnow(),
|
152
149
|
dx_date=referral_datetime.date(),
|
meta_reports/__init__.py
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
from .tasks import update_endpoints_table
|
@@ -0,0 +1,15 @@
|
|
1
|
+
from .dbviews import (
|
2
|
+
GlucoseSummaryAdmin,
|
3
|
+
ImpSubstitutionsAdmin,
|
4
|
+
MissingOgttNoteModelAdmin,
|
5
|
+
MissingScreeningOgttAdmin,
|
6
|
+
OnStudyMissingLabValuesAdmin,
|
7
|
+
OnStudyMissingValuesAdmin,
|
8
|
+
PatientHistoryMissingBaselineCd4Admin,
|
9
|
+
UnattendedThreeInRow2Admin,
|
10
|
+
UnattendedThreeInRowAdmin,
|
11
|
+
UnattendedTwoInRowAdmin,
|
12
|
+
)
|
13
|
+
from .endpoints_admin import EndpointsAdmin
|
14
|
+
from .endpoints_all_admin import EndpointsAllAdmin
|
15
|
+
from .last_imp_refill_admin import LastImpRefillAdmin
|
@@ -0,0 +1,14 @@
|
|
1
|
+
from .glucose_summary_admin import GlucoseSummaryAdmin
|
2
|
+
from .imp_substitutions_admin import ImpSubstitutionsAdmin
|
3
|
+
from .missing_screening_ogtt_admin import (
|
4
|
+
MissingOgttNoteModelAdmin,
|
5
|
+
MissingScreeningOgttAdmin,
|
6
|
+
)
|
7
|
+
from .on_study_missing_lab_values_admin import OnStudyMissingLabValuesAdmin
|
8
|
+
from .on_study_missing_values_admin import OnStudyMissingValuesAdmin
|
9
|
+
from .patient_history_missing_baseline_cd4_admin import (
|
10
|
+
PatientHistoryMissingBaselineCd4Admin,
|
11
|
+
)
|
12
|
+
from .unattended_three_in_row2_admin import UnattendedThreeInRow2Admin
|
13
|
+
from .unattended_three_in_row_admin import UnattendedThreeInRowAdmin
|
14
|
+
from .unattended_two_in_row_admin import UnattendedTwoInRowAdmin
|
@@ -0,0 +1,116 @@
|
|
1
|
+
from django.contrib import admin
|
2
|
+
from django.core.exceptions import ObjectDoesNotExist
|
3
|
+
from django.template.loader import render_to_string
|
4
|
+
from django.urls import reverse
|
5
|
+
from edc_constants.constants import YES
|
6
|
+
from edc_glucose.list_filters import FbgListFilter, OgttListFilter
|
7
|
+
from edc_model_admin.dashboard import ModelAdminDashboardMixin
|
8
|
+
from edc_model_admin.mixins import TemplatesModelAdminMixin
|
9
|
+
from edc_qareports.modeladmin_mixins import QaReportModelAdminMixin
|
10
|
+
from edc_sites.admin import SiteModelAdminMixin
|
11
|
+
from edc_visit_schedule.admin import ScheduleStatusListFilter
|
12
|
+
|
13
|
+
from ...admin_site import meta_reports_admin
|
14
|
+
from ...models import Endpoints, EndpointsProxy, GlucoseSummary
|
15
|
+
from ..list_filters import EndpointListFilter
|
16
|
+
|
17
|
+
|
18
|
+
@admin.register(GlucoseSummary, site=meta_reports_admin)
|
19
|
+
class GlucoseSummaryAdmin(
|
20
|
+
QaReportModelAdminMixin,
|
21
|
+
SiteModelAdminMixin,
|
22
|
+
ModelAdminDashboardMixin,
|
23
|
+
TemplatesModelAdminMixin,
|
24
|
+
admin.ModelAdmin,
|
25
|
+
):
|
26
|
+
ordering = ["site", "subject_identifier", "fbg_datetime"]
|
27
|
+
include_note_column = False
|
28
|
+
list_display = [
|
29
|
+
"dashboard",
|
30
|
+
"subject_identifier_link",
|
31
|
+
"site",
|
32
|
+
"visit",
|
33
|
+
"fasted",
|
34
|
+
"fbg_date",
|
35
|
+
"fbg_value",
|
36
|
+
"ogtt_value",
|
37
|
+
"ogtt_date",
|
38
|
+
"endpoint",
|
39
|
+
"offstudy_date",
|
40
|
+
]
|
41
|
+
|
42
|
+
list_filter = [
|
43
|
+
ScheduleStatusListFilter,
|
44
|
+
"fasted",
|
45
|
+
FbgListFilter,
|
46
|
+
OgttListFilter,
|
47
|
+
"fbg_datetime",
|
48
|
+
"ogtt_datetime",
|
49
|
+
EndpointListFilter,
|
50
|
+
]
|
51
|
+
|
52
|
+
search_fields = ["subject_identifier"]
|
53
|
+
|
54
|
+
@admin.display(description="visit", ordering="visit_code")
|
55
|
+
def visit(self, obj=None):
|
56
|
+
return f"{obj.visit_code}.{obj.visit_code_sequence}"
|
57
|
+
|
58
|
+
@admin.display(description="Endpoint")
|
59
|
+
def endpoint(self, obj=None):
|
60
|
+
try:
|
61
|
+
endpoint_obj = Endpoints.objects.get(subject_identifier=obj.subject_identifier)
|
62
|
+
except ObjectDoesNotExist:
|
63
|
+
value = None
|
64
|
+
else:
|
65
|
+
if endpoint_obj.offstudy_date:
|
66
|
+
url = reverse("meta_reports_admin:meta_reports_endpointsproxy_changelist")
|
67
|
+
title = f"Go to {EndpointsProxy._meta.verbose_name}"
|
68
|
+
else:
|
69
|
+
url = reverse("meta_reports_admin:meta_reports_endpoints_changelist")
|
70
|
+
title = f"Go to {Endpoints._meta.verbose_name}"
|
71
|
+
value = render_to_string(
|
72
|
+
"meta_reports/columns/subject_identifier_column.html",
|
73
|
+
{
|
74
|
+
"subject_identifier": obj.subject_identifier,
|
75
|
+
"url": url,
|
76
|
+
"label": YES,
|
77
|
+
"title": title,
|
78
|
+
},
|
79
|
+
)
|
80
|
+
return value
|
81
|
+
|
82
|
+
@admin.display(description="Subject Idenfifier", ordering="subject_identifier")
|
83
|
+
def subject_identifier_link(self, obj=None):
|
84
|
+
url = reverse("meta_reports_admin:meta_reports_glucosesummary_changelist")
|
85
|
+
return render_to_string(
|
86
|
+
"meta_reports/columns/subject_identifier_column.html",
|
87
|
+
{
|
88
|
+
"subject_identifier": obj.subject_identifier,
|
89
|
+
"url": url,
|
90
|
+
"title": "Click to filter for this subject only",
|
91
|
+
},
|
92
|
+
)
|
93
|
+
|
94
|
+
def get_subject_dashboard_url_kwargs(self, obj) -> dict:
|
95
|
+
return dict(
|
96
|
+
subject_identifier=obj.subject_identifier,
|
97
|
+
appointment=obj.appointment_id,
|
98
|
+
)
|
99
|
+
|
100
|
+
@admin.display(description="Fbg date", ordering="fbg_datetime")
|
101
|
+
def fbg_date(self, obj):
|
102
|
+
if obj.fbg_datetime:
|
103
|
+
return obj.fbg_datetime.date()
|
104
|
+
return None
|
105
|
+
|
106
|
+
@admin.display(description="OGTT date", ordering="ogtt_datetime")
|
107
|
+
def ogtt_date(self, obj):
|
108
|
+
if obj.ogtt_datetime:
|
109
|
+
return obj.ogtt_datetime.date()
|
110
|
+
return None
|
111
|
+
|
112
|
+
@admin.display(description="Offstudy date", ordering="offstudy_datetime")
|
113
|
+
def offstudy_date(self, obj):
|
114
|
+
if obj.offstudy_datetime:
|
115
|
+
return obj.offstudy_datetime.date()
|
116
|
+
return None
|
@@ -0,0 +1,101 @@
|
|
1
|
+
from django.apps import apps as django_apps
|
2
|
+
from django.contrib import admin
|
3
|
+
from django.core.exceptions import ObjectDoesNotExist
|
4
|
+
from django.template.loader import render_to_string
|
5
|
+
from django.urls import reverse
|
6
|
+
from django.utils.translation import gettext_lazy as _
|
7
|
+
from edc_appointment.models import Appointment
|
8
|
+
from edc_model_admin.dashboard import ModelAdminDashboardMixin
|
9
|
+
from edc_model_admin.list_filters import ReportDateListFilter
|
10
|
+
from edc_model_admin.mixins import TemplatesModelAdminMixin
|
11
|
+
from edc_qareports.modeladmin_mixins import QaReportModelAdminMixin
|
12
|
+
from edc_sites.admin import SiteModelAdminMixin
|
13
|
+
from edc_visit_schedule.admin import ScheduleStatusListFilter
|
14
|
+
from edc_visit_schedule.constants import DAY1
|
15
|
+
|
16
|
+
from ...admin_site import meta_reports_admin
|
17
|
+
from ...models import ImpSubstitutions
|
18
|
+
|
19
|
+
|
20
|
+
@admin.register(ImpSubstitutions, site=meta_reports_admin)
|
21
|
+
class ImpSubstitutionsAdmin(
|
22
|
+
QaReportModelAdminMixin,
|
23
|
+
SiteModelAdminMixin,
|
24
|
+
ModelAdminDashboardMixin,
|
25
|
+
TemplatesModelAdminMixin,
|
26
|
+
admin.ModelAdmin,
|
27
|
+
):
|
28
|
+
ordering = ["site", "subject_identifier"]
|
29
|
+
list_display = [
|
30
|
+
"dashboard",
|
31
|
+
"render_button",
|
32
|
+
"subject",
|
33
|
+
"sid",
|
34
|
+
"dispensed_sid",
|
35
|
+
"report_date",
|
36
|
+
"arm_match",
|
37
|
+
"allocated_date",
|
38
|
+
"user_created",
|
39
|
+
"user_modified",
|
40
|
+
"modified",
|
41
|
+
]
|
42
|
+
|
43
|
+
list_filter = [
|
44
|
+
"arm_match",
|
45
|
+
ScheduleStatusListFilter,
|
46
|
+
ReportDateListFilter,
|
47
|
+
"allocated_datetime",
|
48
|
+
]
|
49
|
+
|
50
|
+
search_fields = ["subject_identifier", "sid", "dispensed_sid"]
|
51
|
+
|
52
|
+
def dashboard(self, obj=None, label=None) -> str:
|
53
|
+
kwargs = self.get_subject_dashboard_url_kwargs(obj)
|
54
|
+
try:
|
55
|
+
kwargs.update(
|
56
|
+
appointment=str(
|
57
|
+
Appointment.objects.get(
|
58
|
+
subject_identifier=obj.subject_identifier,
|
59
|
+
visit_code=DAY1,
|
60
|
+
visit_code_sequence=0,
|
61
|
+
).id
|
62
|
+
)
|
63
|
+
)
|
64
|
+
except ObjectDoesNotExist:
|
65
|
+
pass
|
66
|
+
url = reverse(self.get_subject_dashboard_url_name(obj=obj), kwargs=kwargs)
|
67
|
+
context = dict(title=_("Go to subject's dashboard@1000"), url=url, label=label)
|
68
|
+
return render_to_string("dashboard_button.html", context=context)
|
69
|
+
|
70
|
+
@admin.display(description="Subject", ordering="subject_identifier")
|
71
|
+
def subject(self, obj):
|
72
|
+
return obj.subject_identifier
|
73
|
+
|
74
|
+
@admin.display(description="Allocated", ordering="allocated_datetime")
|
75
|
+
def allocated_date(self, obj=None):
|
76
|
+
return obj.allocated_datetime.date() if obj.allocated_datetime else None
|
77
|
+
|
78
|
+
@admin.display(description="Update")
|
79
|
+
def render_button(self, obj=None):
|
80
|
+
crf_model_cls = django_apps.get_model("meta_pharmacy", "substitutions")
|
81
|
+
url = reverse(
|
82
|
+
f"meta_pharmacy_admin:{crf_model_cls._meta.label_lower.replace('.', '_')}_change",
|
83
|
+
args=(obj.original_id,),
|
84
|
+
)
|
85
|
+
url = (
|
86
|
+
f"{url}?next={self.admin_site.name}:"
|
87
|
+
f"{self.model._meta.label_lower.replace('.', '_')}_changelist"
|
88
|
+
)
|
89
|
+
title = _(f"View {crf_model_cls._meta.verbose_name}")
|
90
|
+
label = _("View")
|
91
|
+
crf_button = render_to_string(
|
92
|
+
"edc_qareports/columns/change_button.html",
|
93
|
+
context=dict(title=title, url=url, label=label),
|
94
|
+
)
|
95
|
+
return crf_button
|
96
|
+
|
97
|
+
@admin.display(description="Report date", ordering="report_datetime")
|
98
|
+
def report_date(self, obj) -> str | None:
|
99
|
+
if obj.report_datetime:
|
100
|
+
return obj.report_datetime.date()
|
101
|
+
return None
|