meta-edc 0.3.36__py3-none-any.whl → 0.3.38__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 (37) hide show
  1. meta_analytics/__init__.py +1 -1
  2. meta_analytics/dataframes/__init__.py +1 -0
  3. meta_analytics/dataframes/constants.py +1 -1
  4. meta_analytics/dataframes/get_eos_df.py +26 -0
  5. meta_analytics/dataframes/glucose_endpoints/glucose_endpoints_by_date.py +102 -79
  6. meta_analytics/dataframes/screening/get_screening_df.py +42 -6
  7. meta_analytics/get_tables.py +4 -28
  8. meta_edc/settings/debug.py +2 -2
  9. meta_edc-0.3.38.dist-info/METADATA +766 -0
  10. {meta_edc-0.3.36.dist-info → meta_edc-0.3.38.dist-info}/RECORD +36 -20
  11. {meta_edc-0.3.36.dist-info → meta_edc-0.3.38.dist-info}/WHEEL +1 -1
  12. meta_pharmacy/admin/__init__.py +3 -0
  13. meta_pharmacy/admin/label_admin.py +0 -0
  14. meta_pharmacy/admin/lot_number_admin.py +43 -0
  15. meta_pharmacy/admin/rx_admin.py +75 -0
  16. meta_pharmacy/{admin.py → admin/substitutions_admin.py} +3 -71
  17. meta_pharmacy/labels/__init__.py +2 -0
  18. meta_pharmacy/labels/get_label_data.py +30 -0
  19. meta_pharmacy/labels/print_sheets.py +86 -0
  20. meta_pharmacy/migrations/0006_lotnumber_label.py +289 -0
  21. meta_pharmacy/migrations/0007_lotnumber_medication.py +24 -0
  22. meta_pharmacy/models/__init__.py +4 -0
  23. meta_pharmacy/models/label.py +50 -0
  24. meta_pharmacy/models/lot_number.py +25 -0
  25. meta_pharmacy/models/rx.py +18 -0
  26. meta_pharmacy/{models.py → models/substitutions.py} +2 -16
  27. meta_reports/admin/endpoints_admin.py +1 -1
  28. meta_reports/admin/modeladmin_mixins.py +5 -5
  29. meta_reports/migrations/0050_alter_endpoints_created.py +19 -0
  30. meta_reports/migrations/0051_remove_endpoints_baseline_datetime_and_more.py +40 -0
  31. meta_reports/models/dbviews/imp_substitutions/unmanaged_model.py +3 -1
  32. meta_reports/models/endpoints.py +3 -3
  33. meta_visit_schedule/visit_schedules/phase_three/crfs.py +1 -0
  34. meta_edc-0.3.36.dist-info/METADATA +0 -94
  35. {meta_edc-0.3.36.dist-info → meta_edc-0.3.38.dist-info}/AUTHORS +0 -0
  36. {meta_edc-0.3.36.dist-info → meta_edc-0.3.38.dist-info}/LICENSE +0 -0
  37. {meta_edc-0.3.36.dist-info → meta_edc-0.3.38.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,289 @@
1
+ # Generated by Django 5.1 on 2024-10-07 22:05
2
+
3
+ import _socket
4
+ import django.db.models.deletion
5
+ import django_audit_fields.fields.hostname_modification_field
6
+ import django_audit_fields.fields.userfield
7
+ import django_audit_fields.fields.uuid_auto_field
8
+ import django_audit_fields.models.audit_model_mixin
9
+ import django_revision.revision_field
10
+ from django.db import migrations, models
11
+
12
+
13
+ class Migration(migrations.Migration):
14
+
15
+ dependencies = [
16
+ ("meta_pharmacy", "0005_auto_20240911_0352"),
17
+ ]
18
+
19
+ operations = [
20
+ migrations.CreateModel(
21
+ name="LotNumber",
22
+ fields=[
23
+ (
24
+ "revision",
25
+ django_revision.revision_field.RevisionField(
26
+ blank=True,
27
+ editable=False,
28
+ help_text="System field. Git repository tag:branch:commit.",
29
+ max_length=75,
30
+ null=True,
31
+ verbose_name="Revision",
32
+ ),
33
+ ),
34
+ (
35
+ "created",
36
+ models.DateTimeField(
37
+ blank=True, default=django_audit_fields.models.audit_model_mixin.utcnow
38
+ ),
39
+ ),
40
+ (
41
+ "modified",
42
+ models.DateTimeField(
43
+ blank=True, default=django_audit_fields.models.audit_model_mixin.utcnow
44
+ ),
45
+ ),
46
+ (
47
+ "user_created",
48
+ django_audit_fields.fields.userfield.UserField(
49
+ blank=True,
50
+ help_text="Updated by admin.save_model",
51
+ max_length=50,
52
+ verbose_name="user created",
53
+ ),
54
+ ),
55
+ (
56
+ "user_modified",
57
+ django_audit_fields.fields.userfield.UserField(
58
+ blank=True,
59
+ help_text="Updated by admin.save_model",
60
+ max_length=50,
61
+ verbose_name="user modified",
62
+ ),
63
+ ),
64
+ (
65
+ "hostname_created",
66
+ models.CharField(
67
+ blank=True,
68
+ default=_socket.gethostname,
69
+ help_text="System field. (modified on create only)",
70
+ max_length=60,
71
+ verbose_name="Hostname created",
72
+ ),
73
+ ),
74
+ (
75
+ "hostname_modified",
76
+ django_audit_fields.fields.hostname_modification_field.HostnameModificationField(
77
+ blank=True,
78
+ help_text="System field. (modified on every save)",
79
+ max_length=50,
80
+ verbose_name="Hostname modified",
81
+ ),
82
+ ),
83
+ (
84
+ "device_created",
85
+ models.CharField(blank=True, max_length=10, verbose_name="Device created"),
86
+ ),
87
+ (
88
+ "device_modified",
89
+ models.CharField(
90
+ blank=True, max_length=10, verbose_name="Device modified"
91
+ ),
92
+ ),
93
+ (
94
+ "locale_created",
95
+ models.CharField(
96
+ blank=True,
97
+ help_text="Auto-updated by Modeladmin",
98
+ max_length=10,
99
+ null=True,
100
+ verbose_name="Locale created",
101
+ ),
102
+ ),
103
+ (
104
+ "locale_modified",
105
+ models.CharField(
106
+ blank=True,
107
+ help_text="Auto-updated by Modeladmin",
108
+ max_length=10,
109
+ null=True,
110
+ verbose_name="Locale modified",
111
+ ),
112
+ ),
113
+ (
114
+ "id",
115
+ django_audit_fields.fields.uuid_auto_field.UUIDAutoField(
116
+ blank=True,
117
+ editable=False,
118
+ help_text="System auto field. UUID primary key.",
119
+ primary_key=True,
120
+ serialize=False,
121
+ ),
122
+ ),
123
+ ("lot_no", models.CharField(max_length=25, unique=True)),
124
+ (
125
+ "allocation",
126
+ models.CharField(
127
+ choices=[("active", "Active"), ("placebo", "Placebo")], max_length=25
128
+ ),
129
+ ),
130
+ ("expiration_date", models.DateField()),
131
+ ("qty", models.IntegerField(null=True)),
132
+ ],
133
+ options={
134
+ "verbose_name": "Lot Number",
135
+ "verbose_name_plural": "Lot Numbers",
136
+ "abstract": False,
137
+ "default_permissions": ("add", "change", "delete", "view", "export", "import"),
138
+ "default_manager_name": "objects",
139
+ "indexes": [
140
+ models.Index(
141
+ fields=["modified", "created"], name="meta_pharma_modifie_a98e60_idx"
142
+ ),
143
+ models.Index(
144
+ fields=["user_modified", "user_created"],
145
+ name="meta_pharma_user_mo_1be860_idx",
146
+ ),
147
+ ],
148
+ },
149
+ ),
150
+ migrations.CreateModel(
151
+ name="Label",
152
+ fields=[
153
+ (
154
+ "revision",
155
+ django_revision.revision_field.RevisionField(
156
+ blank=True,
157
+ editable=False,
158
+ help_text="System field. Git repository tag:branch:commit.",
159
+ max_length=75,
160
+ null=True,
161
+ verbose_name="Revision",
162
+ ),
163
+ ),
164
+ (
165
+ "created",
166
+ models.DateTimeField(
167
+ blank=True, default=django_audit_fields.models.audit_model_mixin.utcnow
168
+ ),
169
+ ),
170
+ (
171
+ "modified",
172
+ models.DateTimeField(
173
+ blank=True, default=django_audit_fields.models.audit_model_mixin.utcnow
174
+ ),
175
+ ),
176
+ (
177
+ "user_created",
178
+ django_audit_fields.fields.userfield.UserField(
179
+ blank=True,
180
+ help_text="Updated by admin.save_model",
181
+ max_length=50,
182
+ verbose_name="user created",
183
+ ),
184
+ ),
185
+ (
186
+ "user_modified",
187
+ django_audit_fields.fields.userfield.UserField(
188
+ blank=True,
189
+ help_text="Updated by admin.save_model",
190
+ max_length=50,
191
+ verbose_name="user modified",
192
+ ),
193
+ ),
194
+ (
195
+ "hostname_created",
196
+ models.CharField(
197
+ blank=True,
198
+ default=_socket.gethostname,
199
+ help_text="System field. (modified on create only)",
200
+ max_length=60,
201
+ verbose_name="Hostname created",
202
+ ),
203
+ ),
204
+ (
205
+ "hostname_modified",
206
+ django_audit_fields.fields.hostname_modification_field.HostnameModificationField(
207
+ blank=True,
208
+ help_text="System field. (modified on every save)",
209
+ max_length=50,
210
+ verbose_name="Hostname modified",
211
+ ),
212
+ ),
213
+ (
214
+ "device_created",
215
+ models.CharField(blank=True, max_length=10, verbose_name="Device created"),
216
+ ),
217
+ (
218
+ "device_modified",
219
+ models.CharField(
220
+ blank=True, max_length=10, verbose_name="Device modified"
221
+ ),
222
+ ),
223
+ (
224
+ "locale_created",
225
+ models.CharField(
226
+ blank=True,
227
+ help_text="Auto-updated by Modeladmin",
228
+ max_length=10,
229
+ null=True,
230
+ verbose_name="Locale created",
231
+ ),
232
+ ),
233
+ (
234
+ "locale_modified",
235
+ models.CharField(
236
+ blank=True,
237
+ help_text="Auto-updated by Modeladmin",
238
+ max_length=10,
239
+ null=True,
240
+ verbose_name="Locale modified",
241
+ ),
242
+ ),
243
+ (
244
+ "id",
245
+ django_audit_fields.fields.uuid_auto_field.UUIDAutoField(
246
+ blank=True,
247
+ editable=False,
248
+ help_text="System auto field. UUID primary key.",
249
+ primary_key=True,
250
+ serialize=False,
251
+ ),
252
+ ),
253
+ ("rx_label_reference", models.CharField(max_length=15, unique=True)),
254
+ ("printed_datetime", models.DateTimeField(null=True)),
255
+ ("printed", models.BooleanField(default=False)),
256
+ ("scanned", models.BooleanField(default=False)),
257
+ ("scanned_datetime", models.DateTimeField(null=True)),
258
+ (
259
+ "rx",
260
+ models.ForeignKey(
261
+ on_delete=django.db.models.deletion.PROTECT, to="meta_pharmacy.rx"
262
+ ),
263
+ ),
264
+ (
265
+ "lot_no",
266
+ models.ForeignKey(
267
+ on_delete=django.db.models.deletion.PROTECT,
268
+ to="meta_pharmacy.lotnumber",
269
+ ),
270
+ ),
271
+ ],
272
+ options={
273
+ "verbose_name": "Label",
274
+ "verbose_name_plural": "Labels",
275
+ "abstract": False,
276
+ "default_permissions": ("add", "change", "delete", "view", "export", "import"),
277
+ "default_manager_name": "objects",
278
+ "indexes": [
279
+ models.Index(
280
+ fields=["modified", "created"], name="meta_pharma_modifie_ebebcc_idx"
281
+ ),
282
+ models.Index(
283
+ fields=["user_modified", "user_created"],
284
+ name="meta_pharma_user_mo_cd7246_idx",
285
+ ),
286
+ ],
287
+ },
288
+ ),
289
+ ]
@@ -0,0 +1,24 @@
1
+ # Generated by Django 5.1.2 on 2024-10-10 04:23
2
+
3
+ import django.db.models.deletion
4
+ from django.db import migrations, models
5
+
6
+
7
+ class Migration(migrations.Migration):
8
+
9
+ dependencies = [
10
+ ("edc_pharmacy", "0023_remove_rx_edc_pharmac_modifie_986021_idx_and_more"),
11
+ ("meta_pharmacy", "0006_lotnumber_label"),
12
+ ]
13
+
14
+ operations = [
15
+ migrations.AddField(
16
+ model_name="lotnumber",
17
+ name="medication",
18
+ field=models.ForeignKey(
19
+ null=True,
20
+ on_delete=django.db.models.deletion.PROTECT,
21
+ to="edc_pharmacy.medication",
22
+ ),
23
+ ),
24
+ ]
@@ -0,0 +1,4 @@
1
+ from .label import Label
2
+ from .lot_number import LotNumber
3
+ from .rx import Rx
4
+ from .substitutions import MyManager, Substitutions
@@ -0,0 +1,50 @@
1
+ from django.db import models
2
+ from edc_identifier.simple_identifier import SimpleUniqueIdentifier
3
+ from edc_model.models import BaseUuidModel
4
+
5
+ from .lot_number import LotNumber
6
+ from .rx import Rx
7
+
8
+
9
+ class LabelIdentifier(SimpleUniqueIdentifier):
10
+ random_string_length = 6
11
+ identifier_type = "rx_label_reference"
12
+ template = "{random_string}"
13
+
14
+
15
+ class Label(BaseUuidModel):
16
+
17
+ identifier_cls = LabelIdentifier
18
+ identifier_field_name: str = "rx_label_reference"
19
+
20
+ rx = models.ForeignKey(Rx, on_delete=models.PROTECT)
21
+ lot_no = models.ForeignKey(LotNumber, on_delete=models.PROTECT)
22
+ rx_label_reference = models.CharField(max_length=15, unique=True)
23
+
24
+ printed_datetime = models.DateTimeField(null=True)
25
+ printed = models.BooleanField(default=False)
26
+ scanned = models.BooleanField(default=False)
27
+ scanned_datetime = models.DateTimeField(null=True)
28
+
29
+ def __str__(self):
30
+ return self.rx_label_reference
31
+
32
+ def save(self, *args, **kwargs):
33
+ """Label referenceis always allocated."""
34
+ if not self.id:
35
+ setattr(
36
+ self,
37
+ self.identifier_field_name,
38
+ self.identifier_cls().identifier,
39
+ )
40
+ super().save(*args, **kwargs) # type:ignore
41
+
42
+ @property
43
+ def human_readable_identifier(self):
44
+ """Returns a humanized screening identifier."""
45
+ x = self.screening_identifier
46
+ return f"{x[0:4]}-{x[4:]}"
47
+
48
+ class Meta(BaseUuidModel.Meta):
49
+ verbose_name = "Label"
50
+ verbose_name_plural = "Labels"
@@ -0,0 +1,25 @@
1
+ from django.db import models
2
+ from edc_model.models import BaseUuidModel
3
+ from edc_pharmacy.models import Medication
4
+ from edc_randomization.constants import ACTIVE, PLACEBO
5
+
6
+
7
+ class LotNumber(BaseUuidModel):
8
+
9
+ lot_no = models.CharField(max_length=25, unique=True)
10
+
11
+ medication = models.ForeignKey(
12
+ Medication, on_delete=models.PROTECT, null=True, blank=False
13
+ )
14
+
15
+ allocation = models.CharField(
16
+ max_length=25, choices=((ACTIVE, "Active"), (PLACEBO, "Placebo"))
17
+ )
18
+
19
+ expiration_date = models.DateField()
20
+
21
+ qty = models.IntegerField(null=True)
22
+
23
+ class Meta(BaseUuidModel.Meta):
24
+ verbose_name = "Lot Number"
25
+ verbose_name_plural = "Lot Numbers"
@@ -0,0 +1,18 @@
1
+ from edc_pharmacy.models import Rx as BaseRx
2
+
3
+
4
+ class Rx(BaseRx):
5
+ """A proxy model of edc_pharmacy.Rx.
6
+
7
+ A model for the prescription.
8
+
9
+ For autocomplete only.
10
+ """
11
+
12
+ def save(self, *args, **kwargs):
13
+ raise NotImplementedError(
14
+ "This proxy model may not be saved. Permissions should be view only"
15
+ )
16
+
17
+ class Meta:
18
+ proxy = True
@@ -5,33 +5,19 @@ from edc_constants.choices import YES_NO_NOT_EVALUATED
5
5
  from edc_constants.constants import NO, NOT_EVALUATED, YES
6
6
  from edc_identifier.model_mixins import NonUniqueSubjectIdentifierFieldMixin
7
7
  from edc_model.models import BaseUuidModel, HistoricalRecords
8
- from edc_pharmacy.models import Rx as BaseRx
9
8
  from edc_sites.managers import CurrentSiteManager
10
9
  from edc_sites.model_mixins import SiteModelMixin
11
10
 
12
11
  from meta_pharmacy.constants import MISSING_SUBJECT_IDENTIFIER
13
12
  from meta_rando.models import RandomizationList
14
13
 
14
+ from .rx import Rx
15
+
15
16
 
16
17
  class MyManager(models.Manager):
17
18
  use_in_migrations = True
18
19
 
19
20
 
20
- class Rx(BaseRx):
21
- """A proxy model of edc_pharmacy.Rx.
22
-
23
- For autocomplete only.
24
- """
25
-
26
- def save(self, *args, **kwargs):
27
- raise NotImplementedError(
28
- "This proxy model may not be saved. Permissions should be view only"
29
- )
30
-
31
- class Meta:
32
- proxy = True
33
-
34
-
35
21
  class Substitutions(NonUniqueSubjectIdentifierFieldMixin, SiteModelMixin, BaseUuidModel):
36
22
  """A model to capture a CSV file that lists IMP substitutions
37
23
  made where a bottle of `sid` is substituted with a bottle of
@@ -8,7 +8,7 @@ from .modeladmin_mixins import EndpointsModelAdminMixin
8
8
 
9
9
  @admin.register(Endpoints, site=meta_reports_admin)
10
10
  class EndpointsAdmin(EndpointsModelAdminMixin, admin.ModelAdmin):
11
- queryset_filter = dict(offstudy_datetime__isnull=True)
11
+ queryset_filter = dict(offstudy_date__isnull=True)
12
12
 
13
13
  def rendered_change_list_note(self):
14
14
  return render_to_string("meta_reports/endpoints_change_list_note.html")
@@ -37,7 +37,7 @@ class EndpointsModelAdminMixin(
37
37
  queryset_filter: dict | None = None
38
38
  actions = [update_endpoints_table_action]
39
39
  qa_report_list_display_insert_pos = 3
40
- ordering = ["-fbg_datetime"]
40
+ ordering = ["-fbg_date"]
41
41
  list_display = [
42
42
  "dashboard",
43
43
  "subject",
@@ -48,7 +48,7 @@ class EndpointsModelAdminMixin(
48
48
  "ogtt",
49
49
  "endpoint",
50
50
  "last_updated",
51
- "offstudy_datetime",
51
+ "offstudy_date",
52
52
  "offstudy_reason",
53
53
  ]
54
54
 
@@ -79,9 +79,9 @@ class EndpointsModelAdminMixin(
79
79
  def visit(self, obj=None):
80
80
  return obj.visit_code
81
81
 
82
- @admin.display(description="FBG DATE", ordering="fbg_datetime")
83
- def fbg_date(self, obj=None):
84
- return obj.fbg_datetime.date() if obj.fbg_datetime else None
82
+ # @admin.display(description="FBG DATE", ordering="fbg_date")
83
+ # def fbg_date(self, obj=None):
84
+ # return obj.fbg_datetime.date() if obj.fbg_datetime else None
85
85
 
86
86
  @admin.display(description="FAST", ordering="fasting")
87
87
  def fast(self, obj=None):
@@ -0,0 +1,19 @@
1
+ # Generated by Django 5.1 on 2024-10-07 22:02
2
+
3
+ import edc_utils.date
4
+ from django.db import migrations, models
5
+
6
+
7
+ class Migration(migrations.Migration):
8
+
9
+ dependencies = [
10
+ ("meta_reports", "0049_auto_20240911_0327"),
11
+ ]
12
+
13
+ operations = [
14
+ migrations.AlterField(
15
+ model_name="endpoints",
16
+ name="created",
17
+ field=models.DateTimeField(default=edc_utils.date.get_utcnow),
18
+ ),
19
+ ]
@@ -0,0 +1,40 @@
1
+ # Generated by Django 5.1 on 2024-10-09 16:04
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+
8
+ dependencies = [
9
+ ("meta_reports", "0050_alter_endpoints_created"),
10
+ ]
11
+
12
+ operations = [
13
+ migrations.RemoveField(
14
+ model_name="endpoints",
15
+ name="baseline_datetime",
16
+ ),
17
+ migrations.RemoveField(
18
+ model_name="endpoints",
19
+ name="fbg_datetime",
20
+ ),
21
+ migrations.RemoveField(
22
+ model_name="endpoints",
23
+ name="offstudy_datetime",
24
+ ),
25
+ migrations.AddField(
26
+ model_name="endpoints",
27
+ name="baseline_date",
28
+ field=models.DateField(null=True),
29
+ ),
30
+ migrations.AddField(
31
+ model_name="endpoints",
32
+ name="fbg_date",
33
+ field=models.DateField(null=True),
34
+ ),
35
+ migrations.AddField(
36
+ model_name="endpoints",
37
+ name="offstudy_date",
38
+ field=models.DateField(null=True),
39
+ ),
40
+ ]
@@ -16,7 +16,9 @@ class ImpSubstitutions(QaReportModelMixin, DBView):
16
16
  dispensed_sid = models.IntegerField(verbose_name="Dispensed SID", null=True)
17
17
 
18
18
  arm_match = models.CharField(
19
- max_length=15, choices=YES_NO_NOT_EVALUATED, default=NOT_EVALUATED
19
+ max_length=15,
20
+ choices=YES_NO_NOT_EVALUATED,
21
+ default=NOT_EVALUATED,
20
22
  )
21
23
 
22
24
  report_datetime = models.DateTimeField(null=True)
@@ -11,7 +11,7 @@ class Endpoints(QaReportModelMixin, models.Model):
11
11
 
12
12
  fasting = models.CharField(max_length=10, null=True)
13
13
 
14
- fbg_datetime = models.DateTimeField(null=True)
14
+ fbg_date = models.DateField(null=True)
15
15
 
16
16
  fbg_value = models.FloatField(null=True)
17
17
 
@@ -19,9 +19,9 @@ class Endpoints(QaReportModelMixin, models.Model):
19
19
 
20
20
  endpoint_label = models.CharField(max_length=250, null=True)
21
21
 
22
- baseline_datetime = models.DateTimeField(null=True)
22
+ baseline_date = models.DateField(null=True)
23
23
 
24
- offstudy_datetime = models.DateTimeField(null=True)
24
+ offstudy_date = models.DateField(null=True)
25
25
 
26
26
  offstudy_reason = models.CharField(max_length=250, null=True)
27
27
 
@@ -8,6 +8,7 @@ crfs_prn = CrfCollection(
8
8
  Crf(show_order=245, model="meta_subject.bloodresultsrft"),
9
9
  Crf(show_order=255, model="meta_subject.bloodresultslft"),
10
10
  Crf(show_order=265, model="meta_subject.bloodresultslipids"),
11
+ Crf(show_order=268, model="meta_subject.bloodresultsins"),
11
12
  Crf(show_order=275, model="meta_subject.hepatitistest"),
12
13
  Crf(show_order=285, model="meta_subject.malariatest"),
13
14
  Crf(show_order=295, model="meta_subject.urinedipsticktest"),