Update rwd_code_for_opt.py
Browse files- rwd_code_for_opt.py +23 -23
rwd_code_for_opt.py
CHANGED
|
@@ -1,29 +1,29 @@
|
|
| 1 |
def date_dict(df, pif_key):
|
| 2 |
-
date = df.loc[df['pif_key'].astype(str)==str(pif_key), 'encounter_date'].values[0]
|
| 3 |
-
date_insert_dict = {
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
| 11 |
return date_insert_dict
|
| 12 |
|
| 13 |
def report_date_check(dict_list, df):
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
if col['attribute_name'] == 'pif_key'
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
date_insert_dict = date_dict(df, pif_key)
|
| 21 |
-
dict_list = dict_list + [date_insert_dict]
|
| 22 |
-
# dict_list = dict_list.insert(1, date_insert_dict)
|
| 23 |
return dict_list
|
|
|
|
| 24 |
def json_report_date_insertion(json_data, df):
|
| 25 |
-
for
|
| 26 |
-
for
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
return json_data
|
|
|
|
| 1 |
def date_dict(df, pif_key):
|
| 2 |
+
date = df.loc[df['pif_key'].astype(str) == str(pif_key), 'encounter_date'].values[0]
|
| 3 |
+
date_insert_dict = {
|
| 4 |
+
'attribute_name': 'report_date',
|
| 5 |
+
'attribute_method': 'cv',
|
| 6 |
+
'attribute_normalized_prediction': '',
|
| 7 |
+
'attribute_prediction': str(date),
|
| 8 |
+
'attribute_version': 'v2_090523',
|
| 9 |
+
'attribute_vocab': '',
|
| 10 |
+
'attribute_code': '',
|
| 11 |
+
'date_of_service': ''
|
| 12 |
+
}
|
| 13 |
return date_insert_dict
|
| 14 |
|
| 15 |
def report_date_check(dict_list, df):
|
| 16 |
+
col_names = {col['attribute_name'] for col in dict_list}
|
| 17 |
+
if 'report_date' not in col_names:
|
| 18 |
+
pif_key = next((col['attribute_prediction'] for col in dict_list if col['attribute_name'] == 'pif_key'), None)
|
| 19 |
+
if pif_key is not None:
|
| 20 |
+
date_insert_dict = date_dict(df, pif_key)
|
| 21 |
+
dict_list.append(date_insert_dict)
|
|
|
|
|
|
|
|
|
|
| 22 |
return dict_list
|
| 23 |
+
|
| 24 |
def json_report_date_insertion(json_data, df):
|
| 25 |
+
for biomarker_detail in json_data['patient_level']['biomarkers']['details']:
|
| 26 |
+
for attribute in biomarker_detail['attribute']:
|
| 27 |
+
attribute_details = attribute['attribute_details']
|
| 28 |
+
attribute['attribute_details'] = report_date_check(attribute_details, df)
|
| 29 |
+
return json_data
|