meta-edc 0.3.32__py3-none-any.whl → 0.3.34__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- meta_analytics/dataframes/__init__.py +15 -0
- meta_analytics/dataframes/glucose_endpoints/endpoint_by_date.py +22 -13
- meta_analytics/dataframes/glucose_endpoints/glucose_endpoints_by_date.py +49 -21
- meta_auth/auth_objects.py +15 -0
- meta_auth/auths.py +5 -2
- meta_edc/settings/debug.py +2 -2
- meta_edc/settings/defaults.py +4 -0
- meta_edc/urls.py +1 -0
- {meta_edc-0.3.32.dist-info → meta_edc-0.3.34.dist-info}/METADATA +6 -3
- {meta_edc-0.3.32.dist-info → meta_edc-0.3.34.dist-info}/RECORD +45 -34
- {meta_edc-0.3.32.dist-info → meta_edc-0.3.34.dist-info}/WHEEL +1 -1
- meta_pharmacy/admin.py +128 -0
- meta_pharmacy/admin_site.py +5 -0
- meta_pharmacy/apps.py +3 -0
- meta_pharmacy/constants.py +10 -0
- meta_pharmacy/forms.py +65 -0
- meta_pharmacy/migrations/0002_initial.py +693 -0
- meta_pharmacy/migrations/0003_auto_20240909_2335.py +64 -0
- meta_pharmacy/models.py +102 -0
- meta_pharmacy/urls.py +8 -0
- meta_prn/action_items.py +9 -1
- meta_reports/admin/__init__.py +1 -0
- meta_reports/admin/dbviews/__init__.py +1 -0
- meta_reports/admin/dbviews/imp_substitutions_admin.py +88 -0
- meta_reports/migrations/0017_auto_20240819_1711.py +1 -0
- meta_reports/migrations/0047_impsubstitutions.py +56 -0
- meta_reports/migrations/0048_auto_20240909_2338.py +48 -0
- meta_reports/models/__init__.py +1 -0
- meta_reports/models/dbviews/__init__.py +1 -0
- meta_reports/models/dbviews/imp_substitutions/__init__.py +1 -0
- meta_reports/models/dbviews/imp_substitutions/unmanaged_model.py +37 -0
- meta_reports/models/dbviews/imp_substitutions/view_definition.py +20 -0
- meta_reports/models/dbviews/on_study_missing_values/qa_cases.py +0 -1
- meta_sites/tests/test_sites.py +1 -1
- 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_analytics/notebooks/meta_endpoints.ipynb +0 -201
- /meta_analytics/dataframes/{glucose_endpoints/constants.py → constants.py} +0 -0
- /meta_analytics/dataframes/{glucose_endpoints/utils.py → utils.py} +0 -0
- {meta_edc-0.3.32.dist-info → meta_edc-0.3.34.dist-info}/AUTHORS +0 -0
- {meta_edc-0.3.32.dist-info → meta_edc-0.3.34.dist-info}/LICENSE +0 -0
- {meta_edc-0.3.32.dist-info → meta_edc-0.3.34.dist-info}/top_level.txt +0 -0
@@ -1,5 +1,5 @@
|
|
1
1
|
# Generated by Django 3.2.11 on 2022-07-22 15:25
|
2
|
-
|
2
|
+
from django.core.exceptions import ObjectDoesNotExist
|
3
3
|
from django.db import migrations
|
4
4
|
from tqdm import tqdm
|
5
5
|
|
@@ -9,11 +9,15 @@ from meta_pharmacy.constants import METFORMIN
|
|
9
9
|
def update_rx_missing_medication(apps, schema_editor):
|
10
10
|
medication_model_cls = apps.get_model("edc_pharmacy.medication")
|
11
11
|
rx_model_cls = apps.get_model("edc_pharmacy.rx")
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
try:
|
13
|
+
medication = medication_model_cls.objects.get(name=METFORMIN)
|
14
|
+
except ObjectDoesNotExist:
|
15
|
+
pass
|
16
|
+
else:
|
17
|
+
total = rx_model_cls.objects.filter(medications__isnull=True).count()
|
18
|
+
for obj in tqdm(rx_model_cls.objects.filter(medications__isnull=True), total=total):
|
19
|
+
if not obj.medications.all().exists():
|
20
|
+
obj.medications.add(medication)
|
17
21
|
|
18
22
|
|
19
23
|
class Migration(migrations.Migration):
|
@@ -9,42 +9,46 @@ from tqdm import tqdm
|
|
9
9
|
def update_revised_egrf(apps, schema_editor):
|
10
10
|
bloodresultrft_model_cls = apps.get_model("meta_subject.bloodresultsrft")
|
11
11
|
subjectvisit_model_cls = apps.get_model("meta_subject.subjectvisit")
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
subject_visit__visit_code=DAY1,
|
23
|
-
subject_visit__visit_code_sequence=0,
|
24
|
-
)
|
25
|
-
except ObjectDoesNotExist:
|
26
|
-
pass
|
27
|
-
else:
|
28
|
-
obj.old_egfr_value = obj.egfr_value
|
29
|
-
obj.old_egfr_drop_value = obj.egfr_drop_value
|
30
|
-
obj.egfr_value = EgfrCkdEpi(
|
31
|
-
gender=subject_screening.gender,
|
32
|
-
ethnicity=subject_screening.ethnicity,
|
33
|
-
age_in_years=subject_screening.age_in_years,
|
34
|
-
creatinine_value=obj.creatinine_value,
|
35
|
-
creatinine_units=obj.creatinine_units,
|
36
|
-
).value
|
37
|
-
obj.egfr_drop_value = egfr_percent_change(
|
38
|
-
float(obj.egfr_value), float(baseline_obj.egfr_value)
|
39
|
-
)
|
40
|
-
obj.save_base(
|
41
|
-
update_fields=[
|
42
|
-
"egfr_value",
|
43
|
-
"egfr_drop_value",
|
44
|
-
"old_egfr_value",
|
45
|
-
"old_egfr_drop_value",
|
46
|
-
]
|
12
|
+
try:
|
13
|
+
subjectscreening_model_cls = apps.get_model("meta_screening.subjectscreening")
|
14
|
+
except LookupError:
|
15
|
+
pass
|
16
|
+
else:
|
17
|
+
total = bloodresultrft_model_cls.objects.all().count()
|
18
|
+
for obj in tqdm(bloodresultrft_model_cls.objects.all(), total=total):
|
19
|
+
subject_visit = subjectvisit_model_cls.objects.get(id=obj.subject_visit_id)
|
20
|
+
subject_screening = subjectscreening_model_cls.objects.get(
|
21
|
+
subject_identifier=subject_visit.subject_identifier
|
47
22
|
)
|
23
|
+
try:
|
24
|
+
baseline_obj = bloodresultrft_model_cls.objects.get(
|
25
|
+
subject_visit__subject_identifier=subject_visit.subject_identifier,
|
26
|
+
subject_visit__visit_code=DAY1,
|
27
|
+
subject_visit__visit_code_sequence=0,
|
28
|
+
)
|
29
|
+
except ObjectDoesNotExist:
|
30
|
+
pass
|
31
|
+
else:
|
32
|
+
obj.old_egfr_value = obj.egfr_value
|
33
|
+
obj.old_egfr_drop_value = obj.egfr_drop_value
|
34
|
+
obj.egfr_value = EgfrCkdEpi(
|
35
|
+
gender=subject_screening.gender,
|
36
|
+
ethnicity=subject_screening.ethnicity,
|
37
|
+
age_in_years=subject_screening.age_in_years,
|
38
|
+
creatinine_value=obj.creatinine_value,
|
39
|
+
creatinine_units=obj.creatinine_units,
|
40
|
+
).value
|
41
|
+
obj.egfr_drop_value = egfr_percent_change(
|
42
|
+
float(obj.egfr_value), float(baseline_obj.egfr_value)
|
43
|
+
)
|
44
|
+
obj.save_base(
|
45
|
+
update_fields=[
|
46
|
+
"egfr_value",
|
47
|
+
"egfr_drop_value",
|
48
|
+
"old_egfr_value",
|
49
|
+
"old_egfr_drop_value",
|
50
|
+
]
|
51
|
+
)
|
48
52
|
|
49
53
|
|
50
54
|
class Migration(migrations.Migration):
|
@@ -5,18 +5,22 @@ from tqdm import tqdm
|
|
5
5
|
|
6
6
|
def update_rs_missing_ethnicity(apps, schema_editor):
|
7
7
|
register_subject_model_cls = apps.get_model("edc_registration.registeredsubject")
|
8
|
-
subject_screening_model_cls = apps.get_model("meta_screening.subjectscreening")
|
9
8
|
subject_consent_model_cls = apps.get_model("meta_consent.subjectconsent")
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
9
|
+
try:
|
10
|
+
subject_screening_model_cls = apps.get_model("meta_screening.subjectscreening")
|
11
|
+
except LookupError:
|
12
|
+
pass
|
13
|
+
else:
|
14
|
+
total = subject_consent_model_cls.objects.all().count()
|
15
|
+
for subject_consent in tqdm(subject_consent_model_cls.objects.all(), total=total):
|
16
|
+
subject_screening = subject_screening_model_cls.objects.get(
|
17
|
+
subject_identifier=subject_consent.subject_identifier
|
18
|
+
)
|
19
|
+
register_subject = register_subject_model_cls.objects.get(
|
20
|
+
subject_identifier=subject_consent.subject_identifier
|
21
|
+
)
|
22
|
+
register_subject.ethnicity = subject_screening.ethnicity
|
23
|
+
register_subject.save(update_fields=["ethnicity"])
|
20
24
|
|
21
25
|
|
22
26
|
class Migration(migrations.Migration):
|
@@ -1,201 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"cells": [
|
3
|
-
{
|
4
|
-
"cell_type": "code",
|
5
|
-
"execution_count": null,
|
6
|
-
"id": "28e21930-b943-4a08-a79a-ff2712ae9215",
|
7
|
-
"metadata": {},
|
8
|
-
"outputs": [],
|
9
|
-
"source": [
|
10
|
-
"%%capture\n",
|
11
|
-
"import os\n",
|
12
|
-
"import pandas as pd\n",
|
13
|
-
"import numpy as np\n",
|
14
|
-
"from datetime import datetime\n",
|
15
|
-
"from django_pandas.io import read_frame\n",
|
16
|
-
"from pathlib import Path\n",
|
17
|
-
"\n",
|
18
|
-
"\n",
|
19
|
-
"from dj_notebook import activate\n",
|
20
|
-
"\n",
|
21
|
-
"# pd.options.mode.copy_on_write = True\n",
|
22
|
-
"# pd.options.mode.chained_assignment = \"raise\"\n",
|
23
|
-
"env_file = os.environ[\"META_ENV\"]\n",
|
24
|
-
"report_folder = os.environ[\"META_DOCUMENTS_FOLDER\"]\n",
|
25
|
-
"report_folder = Path(report_folder)\n",
|
26
|
-
"\n",
|
27
|
-
"plus = activate(dotenv_file=env_file)\n",
|
28
|
-
"\n",
|
29
|
-
"# output is suppressed ut normally would spew out all the edc loading messages"
|
30
|
-
]
|
31
|
-
},
|
32
|
-
{
|
33
|
-
"cell_type": "code",
|
34
|
-
"execution_count": null,
|
35
|
-
"id": "52d4bb98-18a5-4528-be8d-e8370b1b5d1e",
|
36
|
-
"metadata": {},
|
37
|
-
"outputs": [],
|
38
|
-
"source": [
|
39
|
-
"from edc_constants.constants import YES\n",
|
40
|
-
"from edc_pdutils.dataframes import get_crf\n",
|
41
|
-
"\n",
|
42
|
-
"from meta_subject.models import Glucose, GlucoseFbg\n",
|
43
|
-
"from meta_analytics.dataframes import GlucoseEndpointsByDate"
|
44
|
-
]
|
45
|
-
},
|
46
|
-
{
|
47
|
-
"cell_type": "code",
|
48
|
-
"execution_count": null,
|
49
|
-
"id": "7df19192-923c-4848-85e2-72b9d2489673",
|
50
|
-
"metadata": {},
|
51
|
-
"outputs": [],
|
52
|
-
"source": [
|
53
|
-
"cls = GlucoseEndpointsByDate()"
|
54
|
-
]
|
55
|
-
},
|
56
|
-
{
|
57
|
-
"cell_type": "code",
|
58
|
-
"execution_count": null,
|
59
|
-
"id": "1eea8cf7-f52c-46d0-b49c-b875e11f9ae0",
|
60
|
-
"metadata": {},
|
61
|
-
"outputs": [],
|
62
|
-
"source": [
|
63
|
-
"cls.run()"
|
64
|
-
]
|
65
|
-
},
|
66
|
-
{
|
67
|
-
"cell_type": "code",
|
68
|
-
"execution_count": null,
|
69
|
-
"id": "7a4b0246-b082-460c-8f9a-dee8d0fc1d63",
|
70
|
-
"metadata": {},
|
71
|
-
"outputs": [],
|
72
|
-
"source": [
|
73
|
-
"len(cls.endpoint_df[\"subject_identifier\"].unique())"
|
74
|
-
]
|
75
|
-
},
|
76
|
-
{
|
77
|
-
"cell_type": "code",
|
78
|
-
"execution_count": null,
|
79
|
-
"id": "df519e75-d536-435e-8c1e-d4087b99d174",
|
80
|
-
"metadata": {},
|
81
|
-
"outputs": [],
|
82
|
-
"source": [
|
83
|
-
"cls.summarize()"
|
84
|
-
]
|
85
|
-
},
|
86
|
-
{
|
87
|
-
"cell_type": "code",
|
88
|
-
"execution_count": null,
|
89
|
-
"id": "526b5f1a-cc77-4182-b9b4-c17c297344f6",
|
90
|
-
"metadata": {},
|
91
|
-
"outputs": [],
|
92
|
-
"source": [
|
93
|
-
"# table meta_subject.glucose\n",
|
94
|
-
"fname = f\"meta-subject-glucose-{datetime.now().strftime(\"%Y-%m-%d-%H%M\")}.csv\"\n",
|
95
|
-
"get_crf(\"meta_subject.glucose\", subject_visit_model=\"meta_subject.subjectvisit\", drop_columns=[\"consent_model\"]).to_csv(report_folder / fname, sep=\"|\", encoding=\"utf8\", index=False)\n"
|
96
|
-
]
|
97
|
-
},
|
98
|
-
{
|
99
|
-
"cell_type": "code",
|
100
|
-
"execution_count": null,
|
101
|
-
"id": "b914aef9-5a27-4474-8359-2d8e0509720b",
|
102
|
-
"metadata": {},
|
103
|
-
"outputs": [],
|
104
|
-
"source": [
|
105
|
-
"# table meta_subject.glucosefbg\n",
|
106
|
-
"fname = f\"meta-subject-glucosefbg-{datetime.now().strftime(\"%Y-%m-%d-%H%M\")}.csv\"\n",
|
107
|
-
"get_crf(\"meta_subject.glucosefbg\", subject_visit_model=\"meta_subject.subjectvisit\", drop_columns=[\"consent_model\"]).to_csv(report_folder / fname, sep=\"|\", encoding=\"utf8\", index=False)\n"
|
108
|
-
]
|
109
|
-
},
|
110
|
-
{
|
111
|
-
"cell_type": "code",
|
112
|
-
"execution_count": null,
|
113
|
-
"id": "66064ddd-51b6-4474-9664-42ecd471e9ce",
|
114
|
-
"metadata": {},
|
115
|
-
"outputs": [],
|
116
|
-
"source": [
|
117
|
-
"# all glucose merged\n",
|
118
|
-
"fname = f\"glucose-merged-{datetime.now().strftime(\"%Y-%m-%d-%H%M\")}.csv\"\n",
|
119
|
-
"cls.df.to_csv(report_folder / fname, sep=\"|\", encoding=\"utf8\", index=False)\n"
|
120
|
-
]
|
121
|
-
},
|
122
|
-
{
|
123
|
-
"cell_type": "code",
|
124
|
-
"execution_count": null,
|
125
|
-
"id": "a8a9da26-84f0-4cc3-a33b-83bf1c292380",
|
126
|
-
"metadata": {},
|
127
|
-
"outputs": [],
|
128
|
-
"source": [
|
129
|
-
"# pivot of glucose readings for subjects who have reached\n",
|
130
|
-
"# an ednpoint\n",
|
131
|
-
"fname = f\"glucose-pivot-{datetime.now().strftime(\"%Y-%m-%d-%H%M\")}.csv\"\n",
|
132
|
-
"df_pivot = cls.endpoint_df.sort_values(by=[\"subject_identifier\"]).set_index(\"subject_identifier\").pivot_table(columns=[\"visit_code\"], values=[\"fbg_value\",\"ogtt_value\"], index=[\"subject_identifier\"])\n",
|
133
|
-
"df_pivot.sort_values(('visit_code'), axis=1).sort_values(\"subject_identifier\").to_csv(report_folder / fname, sep=\"|\", encoding=\"utf8\", index=True)\n"
|
134
|
-
]
|
135
|
-
},
|
136
|
-
{
|
137
|
-
"cell_type": "code",
|
138
|
-
"execution_count": null,
|
139
|
-
"id": "f97dcfa7-4575-43c1-8614-9f51eb4adff5",
|
140
|
-
"metadata": {},
|
141
|
-
"outputs": [],
|
142
|
-
"source": [
|
143
|
-
"# all subjects with endpoint data\n",
|
144
|
-
"fname = f\"endpoint_df-{datetime.now().strftime(\"%Y-%m-%d-%H%M\")}.csv\"\n",
|
145
|
-
"cls.endpoint_df.to_csv(report_folder / fname, sep=\"|\", encoding=\"utf8\", index=False)\n"
|
146
|
-
]
|
147
|
-
},
|
148
|
-
{
|
149
|
-
"cell_type": "code",
|
150
|
-
"execution_count": null,
|
151
|
-
"id": "b394252c-443c-49a9-9f32-77a686d00067",
|
152
|
-
"metadata": {},
|
153
|
-
"outputs": [],
|
154
|
-
"source": [
|
155
|
-
"# len(cls.endpoint_only_df)"
|
156
|
-
]
|
157
|
-
},
|
158
|
-
{
|
159
|
-
"cell_type": "code",
|
160
|
-
"execution_count": null,
|
161
|
-
"id": "82634927-c2bf-4745-9fdf-841a1fec008b",
|
162
|
-
"metadata": {},
|
163
|
-
"outputs": [],
|
164
|
-
"source": [
|
165
|
-
"# len(cls.endpoint_only_df[\"subject_identifier\"].unique())"
|
166
|
-
]
|
167
|
-
},
|
168
|
-
{
|
169
|
-
"cell_type": "code",
|
170
|
-
"execution_count": null,
|
171
|
-
"id": "dc597ae7-d66e-4e1f-9f69-b35dd2d28ec4",
|
172
|
-
"metadata": {},
|
173
|
-
"outputs": [],
|
174
|
-
"source": [
|
175
|
-
"# subject_identifier = \"105-10-0064-2\"\n",
|
176
|
-
"# cls.df[cls.df[\"subject_identifier\"]==subject_identifier][[\"visit_code\", \"fbg_datetime\", \"fasting\", \"fbg_value\", \"ogtt_value\"]]"
|
177
|
-
]
|
178
|
-
}
|
179
|
-
],
|
180
|
-
"metadata": {
|
181
|
-
"kernelspec": {
|
182
|
-
"display_name": "Python 3 (ipykernel)",
|
183
|
-
"language": "python",
|
184
|
-
"name": "python3"
|
185
|
-
},
|
186
|
-
"language_info": {
|
187
|
-
"codemirror_mode": {
|
188
|
-
"name": "ipython",
|
189
|
-
"version": 3
|
190
|
-
},
|
191
|
-
"file_extension": ".py",
|
192
|
-
"mimetype": "text/x-python",
|
193
|
-
"name": "python",
|
194
|
-
"nbconvert_exporter": "python",
|
195
|
-
"pygments_lexer": "ipython3",
|
196
|
-
"version": "3.12.2"
|
197
|
-
}
|
198
|
-
},
|
199
|
-
"nbformat": 4,
|
200
|
-
"nbformat_minor": 5
|
201
|
-
}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|