meta-edc 0.3.33__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.
Files changed (41) hide show
  1. meta_auth/auth_objects.py +15 -0
  2. meta_auth/auths.py +5 -2
  3. meta_edc/settings/debug.py +2 -2
  4. meta_edc/settings/defaults.py +4 -0
  5. meta_edc/urls.py +1 -0
  6. {meta_edc-0.3.33.dist-info → meta_edc-0.3.34.dist-info}/METADATA +6 -3
  7. {meta_edc-0.3.33.dist-info → meta_edc-0.3.34.dist-info}/RECORD +40 -29
  8. {meta_edc-0.3.33.dist-info → meta_edc-0.3.34.dist-info}/WHEEL +1 -1
  9. meta_pharmacy/admin.py +128 -0
  10. meta_pharmacy/admin_site.py +5 -0
  11. meta_pharmacy/apps.py +3 -0
  12. meta_pharmacy/constants.py +10 -0
  13. meta_pharmacy/forms.py +65 -0
  14. meta_pharmacy/migrations/0002_initial.py +693 -0
  15. meta_pharmacy/migrations/0003_auto_20240909_2335.py +64 -0
  16. meta_pharmacy/models.py +102 -0
  17. meta_pharmacy/urls.py +8 -0
  18. meta_prn/action_items.py +9 -1
  19. meta_reports/admin/__init__.py +1 -0
  20. meta_reports/admin/dbviews/__init__.py +1 -0
  21. meta_reports/admin/dbviews/imp_substitutions_admin.py +88 -0
  22. meta_reports/migrations/0017_auto_20240819_1711.py +1 -0
  23. meta_reports/migrations/0047_impsubstitutions.py +56 -0
  24. meta_reports/migrations/0048_auto_20240909_2338.py +48 -0
  25. meta_reports/models/__init__.py +1 -0
  26. meta_reports/models/dbviews/__init__.py +1 -0
  27. meta_reports/models/dbviews/imp_substitutions/__init__.py +1 -0
  28. meta_reports/models/dbviews/imp_substitutions/unmanaged_model.py +37 -0
  29. meta_reports/models/dbviews/imp_substitutions/view_definition.py +20 -0
  30. meta_reports/models/dbviews/on_study_missing_values/qa_cases.py +0 -1
  31. meta_sites/tests/test_sites.py +1 -1
  32. meta_subject/migrations/0107_auto_20220415_0043.py +28 -22
  33. meta_subject/migrations/0126_auto_20220719_2142.py +4 -4
  34. meta_subject/migrations/0131_auto_20220722_0411.py +28 -23
  35. meta_subject/migrations/0132_auto_20220722_1825.py +10 -6
  36. meta_subject/migrations/0135_auto_20220722_2212.py +39 -35
  37. meta_subject/migrations/0150_auto_20220914_0039.py +15 -11
  38. meta_analytics/notebooks/meta_endpoints.ipynb +0 -286
  39. {meta_edc-0.3.33.dist-info → meta_edc-0.3.34.dist-info}/AUTHORS +0 -0
  40. {meta_edc-0.3.33.dist-info → meta_edc-0.3.34.dist-info}/LICENSE +0 -0
  41. {meta_edc-0.3.33.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
- medication = medication_model_cls.objects.get(name=METFORMIN)
13
- total = rx_model_cls.objects.filter(medications__isnull=True).count()
14
- for obj in tqdm(rx_model_cls.objects.filter(medications__isnull=True), total=total):
15
- if not obj.medications.all().exists():
16
- obj.medications.add(medication)
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
- subjectscreening_model_cls = apps.get_model("meta_screening.subjectscreening")
13
- total = bloodresultrft_model_cls.objects.all().count()
14
- for obj in tqdm(bloodresultrft_model_cls.objects.all(), total=total):
15
- subject_visit = subjectvisit_model_cls.objects.get(id=obj.subject_visit_id)
16
- subject_screening = subjectscreening_model_cls.objects.get(
17
- subject_identifier=subject_visit.subject_identifier
18
- )
19
- try:
20
- baseline_obj = bloodresultrft_model_cls.objects.get(
21
- subject_visit__subject_identifier=subject_visit.subject_identifier,
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
- total = subject_consent_model_cls.objects.all().count()
11
- for subject_consent in tqdm(subject_consent_model_cls.objects.all(), total=total):
12
- subject_screening = subject_screening_model_cls.objects.get(
13
- subject_identifier=subject_consent.subject_identifier
14
- )
15
- register_subject = register_subject_model_cls.objects.get(
16
- subject_identifier=subject_consent.subject_identifier
17
- )
18
- register_subject.ethnicity = subject_screening.ethnicity
19
- register_subject.save(update_fields=["ethnicity"])
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,286 +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": "b0ebcb02-9d70-43b2-8614-b97ce6fc5aac",
80
- "metadata": {},
81
- "outputs": [],
82
- "source": [
83
- "kb_subjects = [\n",
84
- " \"105-10-0156-6\",\n",
85
- " \"105-10-0020-4\",\n",
86
- " \"105-10-0061-8\",\n",
87
- " \"105-10-0009-7\",\n",
88
- " \"105-10-0074-1\",\n",
89
- " \"105-10-0136-8\",\n",
90
- " \"105-10-0162-4\",\n",
91
- " \"105-10-0054-3\",\n",
92
- " \"105-10-0080-8\",\n",
93
- " \"105-10-0097-2\",\n",
94
- " \"105-20-0159-9\",\n",
95
- " \"105-20-0236-5\",\n",
96
- " \"105-20-0009-6\",\n",
97
- " \"105-20-0197-9\",\n",
98
- " \"105-20-0354-6\",\n",
99
- " \"105-20-0067-4\",\n",
100
- " \"105-20-0015-3\",\n",
101
- " \"105-30-0044-2\",\n",
102
- " \"105-30-0037-6\",\n",
103
- " \"105-30-0147-3\",\n",
104
- " \"105-30-0052-5\",\n",
105
- " \"105-40-0034-2\",\n",
106
- " \"105-40-0246-2\",\n",
107
- " \"105-40-0160-5\",\n",
108
- " \"105-40-0153-0\",\n",
109
- " \"105-40-0054-0\",\n",
110
- " \"105-40-0390-8\",\n",
111
- " \"105-40-0389-0\",\n",
112
- " \"105-40-0379-1\",\n",
113
- " \"105-40-0036-7\",\n",
114
- " \"105-40-0024-3\",\n",
115
- " \"105-40-0233-0\",\n",
116
- " \"105-40-0202-5\",\n",
117
- " \"105-40-0028-4\",\n",
118
- " \"105-40-0010-2\",\n",
119
- " \"105-40-0029-2\",\n",
120
- " \"105-40-0215-7\",\n",
121
- " \"105-40-0274-4\",\n",
122
- " \"105-40-0124-1\",\n",
123
- " \"105-40-0186-0\",\n",
124
- " \"105-40-0219-9\",\n",
125
- " \"105-40-0336-1\",\n",
126
- " \"105-40-0304-9\",\n",
127
- " \"105-40-0214-0\",\n",
128
- " \"105-40-0111-8\",\n",
129
- " \"105-40-0361-9\",\n",
130
- " \"105-40-0121-7\",\n",
131
- " \"105-40-0158-9\",\n",
132
- " \"105-40-0048-2\",\n",
133
- " \"105-40-0273-6\",\n",
134
- " \"105-40-0333-8\",\n",
135
- " \"105-40-0298-3\",\n",
136
- " \"105-40-0021-9\",\n",
137
- " \"105-40-0494-8\",\n",
138
- " \"105-40-0171-2\",\n",
139
- " \"105-40-0303-1\",\n",
140
- " \"105-40-0109-2\",\n",
141
- " \"105-60-0173-6\",\n",
142
- " \"105-60-0104-1\",\n",
143
- " \"105-60-0144-7\",\n",
144
- " \"105-60-0163-7\",\n",
145
- " \"105-60-0121-5\",\n",
146
- " \"105-60-0198-3\",\n",
147
- " \"105-60-0145-4\",\n",
148
- " \"105-60-0155-3\",\n",
149
- " \"105-60-0146-2\",\n",
150
- " \"105-60-0076-1\",\n",
151
- " \"105-60-0172-8\",\n",
152
- " \"105-60-0024-1\",\n",
153
- " \"105-60-0201-5\",\n",
154
- " \"105-60-0029-0\",\n",
155
- " \"105-60-0166-0\",\n",
156
- " \"105-60-0212-2\",\n",
157
- " \"105-60-0106-6\",\n",
158
- "]"
159
- ]
160
- },
161
- {
162
- "cell_type": "code",
163
- "execution_count": null,
164
- "id": "5bee69bb-30db-4b51-9e81-b391ccb63c42",
165
- "metadata": {},
166
- "outputs": [],
167
- "source": [
168
- "kb_extras = [s for s in cls.endpoint_only_df[\"subject_identifier\"] if s not in kb_subjects]\n",
169
- "ew_extras = [s for s in kb_subjects if s not in list(cls.endpoint_only_df[\"subject_identifier\"])]"
170
- ]
171
- },
172
- {
173
- "cell_type": "code",
174
- "execution_count": null,
175
- "id": "b3856dc1-cd6e-4886-a89b-e73c064b5f56",
176
- "metadata": {},
177
- "outputs": [],
178
- "source": [
179
- "kb_extras"
180
- ]
181
- },
182
- {
183
- "cell_type": "code",
184
- "execution_count": null,
185
- "id": "ecb272b1-341b-4488-90dd-25ce98087dcc",
186
- "metadata": {},
187
- "outputs": [],
188
- "source": [
189
- "ew_extras"
190
- ]
191
- },
192
- {
193
- "cell_type": "code",
194
- "execution_count": null,
195
- "id": "df519e75-d536-435e-8c1e-d4087b99d174",
196
- "metadata": {},
197
- "outputs": [],
198
- "source": []
199
- },
200
- {
201
- "cell_type": "code",
202
- "execution_count": null,
203
- "id": "526b5f1a-cc77-4182-b9b4-c17c297344f6",
204
- "metadata": {},
205
- "outputs": [],
206
- "source": []
207
- },
208
- {
209
- "cell_type": "code",
210
- "execution_count": null,
211
- "id": "b914aef9-5a27-4474-8359-2d8e0509720b",
212
- "metadata": {},
213
- "outputs": [],
214
- "source": []
215
- },
216
- {
217
- "cell_type": "code",
218
- "execution_count": null,
219
- "id": "66064ddd-51b6-4474-9664-42ecd471e9ce",
220
- "metadata": {},
221
- "outputs": [],
222
- "source": []
223
- },
224
- {
225
- "cell_type": "code",
226
- "execution_count": null,
227
- "id": "a8a9da26-84f0-4cc3-a33b-83bf1c292380",
228
- "metadata": {},
229
- "outputs": [],
230
- "source": []
231
- },
232
- {
233
- "cell_type": "code",
234
- "execution_count": null,
235
- "id": "f97dcfa7-4575-43c1-8614-9f51eb4adff5",
236
- "metadata": {},
237
- "outputs": [],
238
- "source": []
239
- },
240
- {
241
- "cell_type": "code",
242
- "execution_count": null,
243
- "id": "b394252c-443c-49a9-9f32-77a686d00067",
244
- "metadata": {},
245
- "outputs": [],
246
- "source": []
247
- },
248
- {
249
- "cell_type": "code",
250
- "execution_count": null,
251
- "id": "82634927-c2bf-4745-9fdf-841a1fec008b",
252
- "metadata": {},
253
- "outputs": [],
254
- "source": []
255
- },
256
- {
257
- "cell_type": "code",
258
- "execution_count": null,
259
- "id": "dc597ae7-d66e-4e1f-9f69-b35dd2d28ec4",
260
- "metadata": {},
261
- "outputs": [],
262
- "source": []
263
- }
264
- ],
265
- "metadata": {
266
- "kernelspec": {
267
- "display_name": "Python 3 (ipykernel)",
268
- "language": "python",
269
- "name": "python3"
270
- },
271
- "language_info": {
272
- "codemirror_mode": {
273
- "name": "ipython",
274
- "version": 3
275
- },
276
- "file_extension": ".py",
277
- "mimetype": "text/x-python",
278
- "name": "python",
279
- "nbconvert_exporter": "python",
280
- "pygments_lexer": "ipython3",
281
- "version": "3.12.4"
282
- }
283
- },
284
- "nbformat": 4,
285
- "nbformat_minor": 5
286
- }