meta-edc 1.0.7__py3-none-any.whl → 1.1.1__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_ae/action_items.py +10 -2
- meta_ae/baker_recipes.py +1 -2
- meta_ae/tests/tests/test_actions.py +1 -2
- meta_analytics/README.rst +1 -2
- meta_analytics/notebooks/anu.ipynb +95 -0
- meta_analytics/notebooks/appointment_planning.ipynb +329 -0
- meta_analytics/notebooks/arvs.ipynb +103 -0
- meta_analytics/notebooks/cleaning/consent_v1_ext.ipynb +227 -0
- meta_analytics/notebooks/cleaning/offschedule_eos.ipynb +353 -0
- meta_analytics/notebooks/dsmc/renal_dysfunction.ipynb +435 -0
- meta_analytics/notebooks/endpoints/meta_endpoints_by_date.ipynb +664 -0
- meta_analytics/notebooks/followup_examination.ipynb +141 -0
- meta_analytics/notebooks/hba1c.ipynb +136 -0
- meta_analytics/notebooks/hiv_regimens.ipynb +122 -118
- meta_analytics/notebooks/incidence.ipynb +232 -0
- meta_analytics/notebooks/liver.ipynb +389 -0
- meta_analytics/notebooks/magreth.ipynb +645 -0
- meta_analytics/notebooks/monitoring_report.ipynb +721 -448
- meta_analytics/notebooks/pharmacy.ipynb +405 -306
- meta_analytics/notebooks/pharmacy_stock_202410.ipynb +306 -0
- meta_analytics/notebooks/steering.ipynb +61 -0
- meta_analytics/notebooks/undiagnosed/meta3_screening_consort_chart.ipynb +1176 -0
- meta_analytics/notebooks/undiagnosed/meta3_screening_undiagnosed.ipynb +519 -0
- meta_analytics/notebooks/undiagnosed/meta_screening_table2.ipynb +964 -0
- meta_analytics/notebooks/undiagnosed/screen_undiagnosed_or.ipynb +296 -0
- meta_analytics/notebooks/undiagnosed/screening.ipynb +273 -0
- meta_analytics/notebooks/undiagnosed/screening2.ipynb +958 -0
- meta_analytics/notebooks/undiagnosed/screening_undiagnosed_20241002.ipynb +958 -0
- meta_analytics/notebooks/ven.ipynb +191 -0
- meta_analytics/notebooks/vitals.ipynb +263 -0
- meta_edc/settings/debug.py +3 -2
- meta_edc/urls.py +1 -0
- {meta_edc-1.0.7.dist-info → meta_edc-1.1.1.dist-info}/METADATA +3 -3
- {meta_edc-1.0.7.dist-info → meta_edc-1.1.1.dist-info}/RECORD +62 -35
- {meta_edc-1.0.7.dist-info → meta_edc-1.1.1.dist-info}/WHEEL +1 -1
- meta_labs/reportables.py +14 -11
- meta_labs/tests/test_reportables.py +33 -12
- meta_pharmacy/notebooks/pharmacy.ipynb +41 -0
- meta_prn/admin/offschedule_pregnancy_admin.py +3 -3
- meta_prn/admin/onschedule_dm_referral_admin.py +5 -5
- meta_prn/form_validators/end_of_study.py +2 -2
- meta_prn/migrations/0063_historicaloffstudymedication_singleton_field_and_more.py +37 -0
- meta_prn/migrations/0064_auto_20250602_2143.py +18 -0
- meta_prn/models/end_of_study.py +2 -0
- meta_prn/models/off_study_medication.py +2 -0
- meta_reports/admin/last_imp_refill_admin.py +3 -2
- meta_screening/eligibility/eligibility_part_three/base_eligibility_part_three.py +59 -47
- meta_screening/form_validators/screening_part_three.py +6 -1
- meta_screening/tests/meta_test_case_mixin.py +3 -0
- meta_screening/tests/tests/test_forms.py +9 -2
- meta_screening/tests/tests/test_screening_part_three.py +11 -14
- meta_subject/action_items.py +2 -3
- meta_subject/choices.py +2 -1
- meta_subject/form_validators/delivery_form_validator.py +1 -0
- meta_subject/forms/blood_results/blood_results_rft_form.py +60 -3
- meta_subject/forms/delivery_form.py +2 -0
- meta_subject/migrations/0223_bloodresultsfbc_errors_bloodresultsgludummy_errors_and_more.py +83 -0
- meta_subject/migrations/0224_bloodresultsfbc_abnormal_summary_and_more.py +153 -0
- meta_subject/tests/tests/test_egfr.py +5 -5
- meta_analytics/dataframes/enrolled/__init__.py +0 -0
- {meta_edc-1.0.7.dist-info → meta_edc-1.1.1.dist-info}/licenses/AUTHORS.rst +0 -0
- {meta_edc-1.0.7.dist-info → meta_edc-1.1.1.dist-info}/licenses/LICENSE +0 -0
- {meta_edc-1.0.7.dist-info → meta_edc-1.1.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,389 @@
|
|
1
|
+
{
|
2
|
+
"cells": [
|
3
|
+
{
|
4
|
+
"cell_type": "code",
|
5
|
+
"execution_count": null,
|
6
|
+
"id": "0",
|
7
|
+
"metadata": {},
|
8
|
+
"outputs": [],
|
9
|
+
"source": [
|
10
|
+
"%%capture\n",
|
11
|
+
"import os\n",
|
12
|
+
"from pathlib import Path\n",
|
13
|
+
"import pandas as pd\n",
|
14
|
+
"from dj_notebook import activate\n",
|
15
|
+
"\n",
|
16
|
+
"env_file = os.environ[\"META_ENV\"]\n",
|
17
|
+
"reports_folder = Path(os.environ[\"META_REPORTS_FOLDER\"])\n",
|
18
|
+
"analysis_folder = Path(os.environ[\"META_ANALYSIS_FOLDER\"])\n",
|
19
|
+
"pharmacy_folder = Path(os.environ[\"META_PHARMACY_FOLDER\"])\n",
|
20
|
+
"plus = activate(dotenv_file=env_file)\n",
|
21
|
+
"pd.set_option('future.no_silent_downcasting', True)"
|
22
|
+
]
|
23
|
+
},
|
24
|
+
{
|
25
|
+
"cell_type": "code",
|
26
|
+
"execution_count": null,
|
27
|
+
"id": "1",
|
28
|
+
"metadata": {},
|
29
|
+
"outputs": [],
|
30
|
+
"source": [
|
31
|
+
"from datetime import date\n",
|
32
|
+
"from edc_pdutils.dataframes import get_subject_visit, get_subject_consent\n",
|
33
|
+
"from meta_analytics.dataframes import get_screening_df\n",
|
34
|
+
"from edc_pdutils.dataframes import get_crf"
|
35
|
+
]
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"cell_type": "code",
|
39
|
+
"execution_count": null,
|
40
|
+
"id": "2",
|
41
|
+
"metadata": {},
|
42
|
+
"outputs": [],
|
43
|
+
"source": [
|
44
|
+
"cutoff_date = date(2025,5, 31)"
|
45
|
+
]
|
46
|
+
},
|
47
|
+
{
|
48
|
+
"cell_type": "code",
|
49
|
+
"execution_count": null,
|
50
|
+
"id": "3",
|
51
|
+
"metadata": {},
|
52
|
+
"outputs": [],
|
53
|
+
"source": [
|
54
|
+
"df_visit = get_subject_visit(\"meta_subject.subjectvisit\").query(\"visit_code==1000.0\").reset_index(drop=True)"
|
55
|
+
]
|
56
|
+
},
|
57
|
+
{
|
58
|
+
"cell_type": "code",
|
59
|
+
"execution_count": null,
|
60
|
+
"id": "4",
|
61
|
+
"metadata": {},
|
62
|
+
"outputs": [],
|
63
|
+
"source": [
|
64
|
+
"# merge with consent for dob\n",
|
65
|
+
"df_consent = get_subject_consent(model=\"meta_consent.subjectconsent\")[[\"subject_identifier\", \"gender\", \"dob\", \"age_in_years\", \"consent_datetime\"]]\n",
|
66
|
+
"df_visit = df_visit.merge(df_consent, on=\"subject_identifier\", how=\"left\")\n",
|
67
|
+
"df_visit[\"age_in_years\"] = df_visit[\"age_in_years\"].astype(\"Int64\")\n",
|
68
|
+
"df_visit[\"dob\"] = df_visit[\"dob\"].astype(\"datetime64[ns]\")\n",
|
69
|
+
"df_visit[\"consent_datetime\"] = df_visit[\"consent_datetime\"].dt.normalize()"
|
70
|
+
]
|
71
|
+
},
|
72
|
+
{
|
73
|
+
"cell_type": "code",
|
74
|
+
"execution_count": null,
|
75
|
+
"id": "5",
|
76
|
+
"metadata": {},
|
77
|
+
"outputs": [],
|
78
|
+
"source": [
|
79
|
+
"columns = [\n",
|
80
|
+
" \"subject_identifier\",\n",
|
81
|
+
" # \"gender\",\n",
|
82
|
+
" # \"age_in_years\",\n",
|
83
|
+
" \"ethnicity\",\n",
|
84
|
+
" \"fbg_value\",\n",
|
85
|
+
" \"fbg_date\",\n",
|
86
|
+
" \"fbg_units\",\n",
|
87
|
+
" \"bmi\",\n",
|
88
|
+
" \"weight\",\n",
|
89
|
+
" \"height\",\n",
|
90
|
+
" \"severe_htn\",\n",
|
91
|
+
" \"dia_blood_pressure_avg\",\n",
|
92
|
+
" \"sys_blood_pressure_avg\",\n",
|
93
|
+
" \"waist_circumference\",\n",
|
94
|
+
"]\n",
|
95
|
+
"\n",
|
96
|
+
"df_screening = (\n",
|
97
|
+
" get_screening_df()\n",
|
98
|
+
" .query(\"subject_identifier.str.startswith('105-')\")\n",
|
99
|
+
" .rename(columns={\"calculated_bmi_value\":\"bmi\", \"fbg_datetime\":\"fbg_date\"})\n",
|
100
|
+
" .reset_index()\n",
|
101
|
+
")\n",
|
102
|
+
"df_screening[\"fbg_value\"] = df_screening[\"fbg_value\"].astype(\"Float64\")\n",
|
103
|
+
"df_screening[\"bmi\"] = df_screening[\"bmi\"].astype(\"Float64\")\n",
|
104
|
+
"df_screening[\"height\"] = df_screening[\"height\"].astype(\"Float64\")\n",
|
105
|
+
"df_screening[\"weight\"] = df_screening[\"weight\"].astype(\"Float64\")\n",
|
106
|
+
"df_screening[\"waist_circumference\"] = df_screening[\"waist_circumference\"].astype(\"Float64\")\n",
|
107
|
+
"df_screening[\"dia_blood_pressure_avg\"] = df_screening[\"dia_blood_pressure_avg\"].astype(\"Float64\")\n",
|
108
|
+
"df_screening[\"sys_blood_pressure_avg\"] = df_screening[\"sys_blood_pressure_avg\"].astype(\"Float64\")\n",
|
109
|
+
"df_screening[\"fbg_date\"] = df_screening[\"fbg_date\"].dt.tz_localize(None).dt.normalize()\n",
|
110
|
+
"\n",
|
111
|
+
"df_screening.loc[df_screening.fasting_duration_delta.dt.total_seconds()<28800, \"fbg\"] = pd.NA\n",
|
112
|
+
"df_screening.loc[df_screening.fasting_duration_delta.dt.total_seconds()<28800, \"fbg_units\"] = pd.NA\n",
|
113
|
+
"\n",
|
114
|
+
"# merge with vars from screening\n",
|
115
|
+
"df_visit = df_visit.merge(df_screening[columns], on=\"subject_identifier\", how=\"left\")"
|
116
|
+
]
|
117
|
+
},
|
118
|
+
{
|
119
|
+
"cell_type": "code",
|
120
|
+
"execution_count": null,
|
121
|
+
"id": "6",
|
122
|
+
"metadata": {},
|
123
|
+
"outputs": [],
|
124
|
+
"source": [
|
125
|
+
"columns = [\n",
|
126
|
+
" \"subject_visit_id\",\n",
|
127
|
+
" \"rft_date\",\n",
|
128
|
+
" \"crf\",\n",
|
129
|
+
" \"creatinine_value\",\n",
|
130
|
+
" \"creatinine_units\",\n",
|
131
|
+
" \"creatinine_abnormal\",\n",
|
132
|
+
" \"egfr_value\",\n",
|
133
|
+
" \"egfr_units\",\n",
|
134
|
+
" \"egfr_abnormal\",\n",
|
135
|
+
" \"urea_value\",\n",
|
136
|
+
" \"urea_units\",\n",
|
137
|
+
" \"urea_abnormal\",\n",
|
138
|
+
" \"uric_acid_value\",\n",
|
139
|
+
" \"uric_acid_units\",\n",
|
140
|
+
" \"uric_acid_abnormal\",\n",
|
141
|
+
"]\n",
|
142
|
+
"df_bloodresultsrft = get_crf(model=\"meta_subject.bloodresultsrft\", subject_visit_model=\"meta_subject.subjectvisit\").rename(columns={\"report_datetime\": \"rft_date\"}).reset_index(drop=True)\n",
|
143
|
+
"df_bloodresultsrft[\"rft_date\"] = df_bloodresultsrft[\"rft_date\"].dt.tz_localize(None).dt.normalize()\n",
|
144
|
+
"df_bloodresultsrft[\"crf\"] = \"bloodresultsrft\"\n",
|
145
|
+
"\n",
|
146
|
+
"for col in columns:\n",
|
147
|
+
" if col.endswith(\"_value\"):\n",
|
148
|
+
" df_bloodresultsrft[col] = df_bloodresultsrft[col].astype(\"Float64\")\n",
|
149
|
+
"\n",
|
150
|
+
"df_visit = df_visit.merge(df_bloodresultsrft.query(\"visit_code==1000.0\")[columns], on=\"subject_visit_id\", how=\"left\")\n"
|
151
|
+
]
|
152
|
+
},
|
153
|
+
{
|
154
|
+
"cell_type": "code",
|
155
|
+
"execution_count": null,
|
156
|
+
"id": "7",
|
157
|
+
"metadata": {},
|
158
|
+
"outputs": [],
|
159
|
+
"source": [
|
160
|
+
"columns = [\n",
|
161
|
+
" \"subject_visit_id\",\n",
|
162
|
+
" \"ast_value\",\n",
|
163
|
+
" \"ast_units\",\n",
|
164
|
+
" \"ast_abnormal\",\n",
|
165
|
+
" \"alt_value\",\n",
|
166
|
+
" \"alt_units\",\n",
|
167
|
+
" \"alt_abnormal\",\n",
|
168
|
+
" \"alp_value\",\n",
|
169
|
+
" \"alp_units\",\n",
|
170
|
+
" \"alp_abnormal\",\n",
|
171
|
+
" \"amylase_value\",\n",
|
172
|
+
" \"amylase_units\",\n",
|
173
|
+
" \"amylase_abnormal\",\n",
|
174
|
+
" \"ggt_value\",\n",
|
175
|
+
" \"ggt_units\",\n",
|
176
|
+
" \"ggt_abnormal\",\n",
|
177
|
+
" \"albumin_value\",\n",
|
178
|
+
" \"albumin_units\",\n",
|
179
|
+
" \"albumin_abnormal\",\n",
|
180
|
+
"]\n",
|
181
|
+
"df_bloodresultslft = get_crf(model=\"meta_subject.bloodresultslft\", subject_visit_model=\"meta_subject.subjectvisit\").rename(columns={\"report_datetime\":\"lft_date\"}).reset_index(drop=True)\n",
|
182
|
+
"df_bloodresultslft[\"lft_date\"] = df_bloodresultslft[\"lft_date\"].dt.tz_localize(None).dt.normalize()\n",
|
183
|
+
"df_bloodresultslft[\"crf\"] = \"bloodresultslft\"\n",
|
184
|
+
"\n",
|
185
|
+
"for col in columns:\n",
|
186
|
+
" if col.endswith(\"_value\"):\n",
|
187
|
+
" df_bloodresultslft[col] = df_bloodresultslft[col].astype(\"Float64\")\n",
|
188
|
+
"\n",
|
189
|
+
"# df_bloodresultslft.query(\"visit_code==1000.0\")[columns]\n",
|
190
|
+
"df_visit = df_visit.merge(df_bloodresultslft.query(\"visit_code==1000.0\")[columns], on=\"subject_visit_id\", how=\"left\")\n"
|
191
|
+
]
|
192
|
+
},
|
193
|
+
{
|
194
|
+
"cell_type": "code",
|
195
|
+
"execution_count": null,
|
196
|
+
"id": "8",
|
197
|
+
"metadata": {},
|
198
|
+
"outputs": [],
|
199
|
+
"source": [
|
200
|
+
"columns = [\n",
|
201
|
+
" \"subject_visit_id\",\n",
|
202
|
+
" \"lipids_date\",\n",
|
203
|
+
" \"crf\",\n",
|
204
|
+
" \"hdl_value\",\n",
|
205
|
+
" \"hdl_units\",\n",
|
206
|
+
" \"hdl_abnormal\",\n",
|
207
|
+
" \"ldl_value\",\n",
|
208
|
+
" \"ldl_units\",\n",
|
209
|
+
" \"ldl_abnormal\",\n",
|
210
|
+
" \"trig_value\",\n",
|
211
|
+
" \"trig_units\",\n",
|
212
|
+
" \"trig_abnormal\",\n",
|
213
|
+
" \"chol_value\",\n",
|
214
|
+
" \"chol_units\",\n",
|
215
|
+
" \"chol_abnormal\",\n",
|
216
|
+
"]\n",
|
217
|
+
"df_bloodresultslipids = get_crf(model=\"meta_subject.bloodresultslipids\", subject_visit_model=\"meta_subject.subjectvisit\").rename(columns={\"report_datetime\": \"lipids_date\"}).reset_index(drop=True)\n",
|
218
|
+
"df_bloodresultslipids[\"lipids_date\"] = df_bloodresultslipids[\"lipids_date\"].dt.tz_localize(None).dt.normalize()\n",
|
219
|
+
"df_bloodresultslipids[\"crf\"] = \"bloodresultslipids\"\n",
|
220
|
+
"for col in columns:\n",
|
221
|
+
" if col.endswith(\"_value\"):\n",
|
222
|
+
" df_bloodresultslipids[col] = df_bloodresultslipids[col].astype(\"Float64\")\n",
|
223
|
+
"# df_bloodresultslipids.query(\"visit_code==1000.0\")[columns]\n",
|
224
|
+
"df_visit = df_visit.merge(df_bloodresultslipids.query(\"visit_code==1000.0\")[columns], on=\"subject_visit_id\", how=\"left\")\n",
|
225
|
+
"\n"
|
226
|
+
]
|
227
|
+
},
|
228
|
+
{
|
229
|
+
"cell_type": "code",
|
230
|
+
"execution_count": null,
|
231
|
+
"id": "9",
|
232
|
+
"metadata": {},
|
233
|
+
"outputs": [],
|
234
|
+
"source": [
|
235
|
+
"columns = [\n",
|
236
|
+
" \"subject_visit_id\",\n",
|
237
|
+
" \"fbc_date\",\n",
|
238
|
+
" \"crf\",\n",
|
239
|
+
" \"haemoglobin_value\",\n",
|
240
|
+
" \"haemoglobin_units\",\n",
|
241
|
+
" \"haemoglobin_abnormal\",\n",
|
242
|
+
" \"wbc_value\",\n",
|
243
|
+
" \"wbc_units\",\n",
|
244
|
+
" \"wbc_abnormal\",\n",
|
245
|
+
" \"rbc_value\",\n",
|
246
|
+
" \"rbc_units\",\n",
|
247
|
+
" \"rbc_abnormal\",\n",
|
248
|
+
" \"platelets_value\",\n",
|
249
|
+
" \"platelets_units\",\n",
|
250
|
+
" \"platelets_abnormal\",\n",
|
251
|
+
"]\n",
|
252
|
+
"df_bloodresultsfbc = get_crf(model=\"meta_subject.bloodresultsfbc\", subject_visit_model=\"meta_subject.subjectvisit\").rename(columns={\"report_datetime\": \"fbc_date\"}).reset_index(drop=True)\n",
|
253
|
+
"df_bloodresultsfbc[\"fbc_date\"] = df_bloodresultsfbc[\"fbc_date\"].dt.tz_localize(None).dt.normalize()\n",
|
254
|
+
"df_bloodresultsfbc[\"crf\"] = \"bloodresultsfbc\"\n",
|
255
|
+
"for col in columns:\n",
|
256
|
+
" if col.endswith(\"_value\"):\n",
|
257
|
+
" df_bloodresultsfbc[col] = df_bloodresultsfbc[col].astype(\"Float64\")\n",
|
258
|
+
"\n",
|
259
|
+
"df_visit = df_visit.merge(df_bloodresultsfbc.query(\"visit_code==1000.0\")[columns], on=\"subject_visit_id\", how=\"left\")\n"
|
260
|
+
]
|
261
|
+
},
|
262
|
+
{
|
263
|
+
"cell_type": "code",
|
264
|
+
"execution_count": null,
|
265
|
+
"id": "10",
|
266
|
+
"metadata": {},
|
267
|
+
"outputs": [],
|
268
|
+
"source": [
|
269
|
+
"columns = [\n",
|
270
|
+
" \"subject_visit_id\",\n",
|
271
|
+
" \"current_smoker\",\n",
|
272
|
+
" \"former_smoker\",\n",
|
273
|
+
" \"hiv_diagnosis_date\",\n",
|
274
|
+
" \"current_arv_regimen\",\n",
|
275
|
+
" \"current_arv_regimen_start_date\",\n",
|
276
|
+
" ]\n",
|
277
|
+
"df_patient_history = get_crf(\n",
|
278
|
+
" model=\"meta_subject.patienthistory\",\n",
|
279
|
+
" subject_visit_model=\"meta_subject.subjectvisit\")\n",
|
280
|
+
"df_patient_history[\"hiv_diagnosis_date\"] = df_patient_history[\"hiv_diagnosis_date\"].dt.tz_localize(None).dt.normalize()\n",
|
281
|
+
"df_patient_history[\"current_arv_regimen_start_date\"] = df_patient_history[\"current_arv_regimen_start_date\"].dt.tz_localize(None).dt.normalize()\n",
|
282
|
+
"\n",
|
283
|
+
"df_visit = df_visit.merge(df_patient_history.query(\"visit_code==1000.0\")[columns], on=\"subject_visit_id\", how=\"left\")"
|
284
|
+
]
|
285
|
+
},
|
286
|
+
{
|
287
|
+
"cell_type": "code",
|
288
|
+
"execution_count": null,
|
289
|
+
"id": "11",
|
290
|
+
"metadata": {},
|
291
|
+
"outputs": [],
|
292
|
+
"source": [
|
293
|
+
"columns = [\"subject_visit_id\", \"weight\", \"waist_circumference\", \"severe_htn\", \"dia_blood_pressure_avg\", \"sys_blood_pressure_avg\"]\n",
|
294
|
+
"df_physical_exam = get_crf(\n",
|
295
|
+
" model=\"meta_subject.physicalexam\",\n",
|
296
|
+
" subject_visit_model=\"meta_subject.subjectvisit\",\n",
|
297
|
+
")\n",
|
298
|
+
"\n",
|
299
|
+
"df_visit = df_visit.merge(df_physical_exam[[\"subject_visit_id\", \"weight\", \"waist_circumference\"]], on=\"subject_visit_id\", how=\"left\", suffixes=(\"\", \"_physicalexam\"))\n",
|
300
|
+
"df_visit['weight_physicalexam'] = df_visit['weight_physicalexam'].astype(\"Float64\")\n",
|
301
|
+
"df_visit['waist_circumference_physicalexam'] = df_visit['waist_circumference_physicalexam'].astype(\"Float64\")\n",
|
302
|
+
"\n",
|
303
|
+
"df_visit['weight'] = df_visit['weight'].fillna(df_visit['weight_physicalexam'])\n",
|
304
|
+
"df_visit['waist_circumference'] = df_visit['waist_circumference'].fillna(df_visit['waist_circumference_physicalexam'])\n",
|
305
|
+
"\n",
|
306
|
+
"df_visit = df_visit.drop(columns=[\"weight_physicalexam\", \"waist_circumference_physicalexam\"])"
|
307
|
+
]
|
308
|
+
},
|
309
|
+
{
|
310
|
+
"cell_type": "code",
|
311
|
+
"execution_count": null,
|
312
|
+
"id": "12",
|
313
|
+
"metadata": {},
|
314
|
+
"outputs": [],
|
315
|
+
"source": [
|
316
|
+
"df_visit = (df_visit\n",
|
317
|
+
" .drop(columns=[col for col in df_visit.columns if col.endswith(\"_y\")])\n",
|
318
|
+
" .drop(columns=[col for col in df_visit.columns if col.endswith(\"_x\")])\n",
|
319
|
+
" .drop(columns=[\n",
|
320
|
+
" \"appointment_id\",\n",
|
321
|
+
" \"appt_datetime\",\n",
|
322
|
+
" \"appt_status\",\n",
|
323
|
+
" \"appt_timing\",\n",
|
324
|
+
" \"baseline_datetime\",\n",
|
325
|
+
" \"crf\",\n",
|
326
|
+
" \"endline_visit_code\",\n",
|
327
|
+
" \"endline_visit_code_str\",\n",
|
328
|
+
" \"endline_visit_datetime\",\n",
|
329
|
+
" \"followup_days\",\n",
|
330
|
+
" \"reason\",\n",
|
331
|
+
" \"reason_missed\",\n",
|
332
|
+
" \"reason_missed_other\",\n",
|
333
|
+
" \"reason_unscheduled\",\n",
|
334
|
+
" \"reason_unscheduled_other\",\n",
|
335
|
+
" \"subject_visit_id\",\n",
|
336
|
+
" \"visit_code_str\",\n",
|
337
|
+
"]))"
|
338
|
+
]
|
339
|
+
},
|
340
|
+
{
|
341
|
+
"cell_type": "code",
|
342
|
+
"execution_count": null,
|
343
|
+
"id": "13",
|
344
|
+
"metadata": {},
|
345
|
+
"outputs": [],
|
346
|
+
"source": [
|
347
|
+
"for col in [col for col in df_visit.columns if col.endswith(\"_abnormal\")]:\n",
|
348
|
+
" df_visit[col] = df_visit[col].astype(str)\n",
|
349
|
+
"for col in [col for col in df_visit.columns if col.endswith(\"_units\")]:\n",
|
350
|
+
" df_visit[col] = df_visit[col].astype(str)"
|
351
|
+
]
|
352
|
+
},
|
353
|
+
{
|
354
|
+
"cell_type": "code",
|
355
|
+
"execution_count": null,
|
356
|
+
"id": "14",
|
357
|
+
"metadata": {},
|
358
|
+
"outputs": [],
|
359
|
+
"source": [
|
360
|
+
"df_visit.to_stata(\n",
|
361
|
+
" path=analysis_folder / \"liver.dta\",\n",
|
362
|
+
" version=118,\n",
|
363
|
+
" write_index=False,\n",
|
364
|
+
")"
|
365
|
+
]
|
366
|
+
}
|
367
|
+
],
|
368
|
+
"metadata": {
|
369
|
+
"kernelspec": {
|
370
|
+
"display_name": "Python 3",
|
371
|
+
"language": "python",
|
372
|
+
"name": "python3"
|
373
|
+
},
|
374
|
+
"language_info": {
|
375
|
+
"codemirror_mode": {
|
376
|
+
"name": "ipython",
|
377
|
+
"version": 2
|
378
|
+
},
|
379
|
+
"file_extension": ".py",
|
380
|
+
"mimetype": "text/x-python",
|
381
|
+
"name": "python",
|
382
|
+
"nbconvert_exporter": "python",
|
383
|
+
"pygments_lexer": "ipython2",
|
384
|
+
"version": "2.7.6"
|
385
|
+
}
|
386
|
+
},
|
387
|
+
"nbformat": 4,
|
388
|
+
"nbformat_minor": 5
|
389
|
+
}
|