Spaces:
Runtime error
Runtime error
Roland Ding commited on
Commit ·
498a219
1
Parent(s): 3a74227
updated the latestcontent of:
Browse filesrevised the UI of the app to add dropdown for IFU
added features for incorporating IFU data in prompting
updated upload conditions as per latest search_term sheet.
On branch main
Changes to be committed:
modified: __pycache__/supplier.cpython-310.pyc
modified: __pycache__/utility.cpython-310.pyc
modified: backend_update.ipynb
modified: chains.py
modified: features.py
modified: ui_study.py
- __pycache__/supplier.cpython-310.pyc +0 -0
- __pycache__/utility.cpython-310.pyc +0 -0
- backend_update.ipynb +747 -5
- chains.py +1 -1
- features.py +15 -6
- ui_study.py +9 -3
__pycache__/supplier.cpython-310.pyc
CHANGED
|
Binary files a/__pycache__/supplier.cpython-310.pyc and b/__pycache__/supplier.cpython-310.pyc differ
|
|
|
__pycache__/utility.cpython-310.pyc
CHANGED
|
Binary files a/__pycache__/utility.cpython-310.pyc and b/__pycache__/utility.cpython-310.pyc differ
|
|
|
backend_update.ipynb
CHANGED
|
@@ -25,7 +25,7 @@
|
|
| 25 |
},
|
| 26 |
{
|
| 27 |
"cell_type": "code",
|
| 28 |
-
"execution_count":
|
| 29 |
"metadata": {},
|
| 30 |
"outputs": [],
|
| 31 |
"source": [
|
|
@@ -39,7 +39,7 @@
|
|
| 39 |
},
|
| 40 |
{
|
| 41 |
"cell_type": "code",
|
| 42 |
-
"execution_count":
|
| 43 |
"metadata": {},
|
| 44 |
"outputs": [],
|
| 45 |
"source": [
|
|
@@ -68,7 +68,7 @@
|
|
| 68 |
},
|
| 69 |
{
|
| 70 |
"cell_type": "code",
|
| 71 |
-
"execution_count":
|
| 72 |
"metadata": {},
|
| 73 |
"outputs": [],
|
| 74 |
"source": [
|
|
@@ -225,6 +225,741 @@
|
|
| 225 |
"instruction_objects_other_summary = get_table(\"other-summary-com\")"
|
| 226 |
]
|
| 227 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
{
|
| 229 |
"cell_type": "markdown",
|
| 230 |
"metadata": {},
|
|
@@ -234,7 +969,7 @@
|
|
| 234 |
},
|
| 235 |
{
|
| 236 |
"cell_type": "code",
|
| 237 |
-
"execution_count":
|
| 238 |
"metadata": {},
|
| 239 |
"outputs": [
|
| 240 |
{
|
|
@@ -243,7 +978,7 @@
|
|
| 243 |
"dict_keys(['Checklist', 'Revision', 'terms', 'prompts', 'prompt_agg', 'prompt_sum', 'Overview', 'Overview Command', 'Overview Summary Com.', 'Clinical', 'Clinical Command', 'Clin Summary Com', 'Radiologic', 'Radiologic Command', 'parser_safety', 'Units', 'Notes', 'Rad Summary Com', 'Safety', 'Safety Command', 'Safety Summary Com', 'Other', 'Other Command', 'Oth Summary Com'])"
|
| 244 |
]
|
| 245 |
},
|
| 246 |
-
"execution_count":
|
| 247 |
"metadata": {},
|
| 248 |
"output_type": "execute_result"
|
| 249 |
}
|
|
@@ -255,6 +990,13 @@
|
|
| 255 |
"raw.keys()"
|
| 256 |
]
|
| 257 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 258 |
{
|
| 259 |
"cell_type": "markdown",
|
| 260 |
"metadata": {},
|
|
|
|
| 25 |
},
|
| 26 |
{
|
| 27 |
"cell_type": "code",
|
| 28 |
+
"execution_count": 4,
|
| 29 |
"metadata": {},
|
| 30 |
"outputs": [],
|
| 31 |
"source": [
|
|
|
|
| 39 |
},
|
| 40 |
{
|
| 41 |
"cell_type": "code",
|
| 42 |
+
"execution_count": 2,
|
| 43 |
"metadata": {},
|
| 44 |
"outputs": [],
|
| 45 |
"source": [
|
|
|
|
| 68 |
},
|
| 69 |
{
|
| 70 |
"cell_type": "code",
|
| 71 |
+
"execution_count": 9,
|
| 72 |
"metadata": {},
|
| 73 |
"outputs": [],
|
| 74 |
"source": [
|
|
|
|
| 225 |
"instruction_objects_other_summary = get_table(\"other-summary-com\")"
|
| 226 |
]
|
| 227 |
},
|
| 228 |
+
{
|
| 229 |
+
"cell_type": "markdown",
|
| 230 |
+
"metadata": {},
|
| 231 |
+
"source": [
|
| 232 |
+
"# Load the latest search terms and prompts after the merging"
|
| 233 |
+
]
|
| 234 |
+
},
|
| 235 |
+
{
|
| 236 |
+
"cell_type": "code",
|
| 237 |
+
"execution_count": 2,
|
| 238 |
+
"metadata": {},
|
| 239 |
+
"outputs": [
|
| 240 |
+
{
|
| 241 |
+
"data": {
|
| 242 |
+
"text/plain": [
|
| 243 |
+
"dict_keys(['Checklist', 'Revision', 'terms', 'prompts', 'prompt_agg', 'prompt_sum', 'Overview', 'Overview Command', 'Overview Summary Com.', 'Clinical', 'Clinical Command', 'Clin Summary Com', 'Radiologic', 'Radiologic Command', 'parser_safety', 'Units', 'Notes', 'Rad Summary Com', 'Safety', 'Safety Command', 'Safety Summary Com', 'Other', 'Other Command', 'Oth Summary Com'])"
|
| 244 |
+
]
|
| 245 |
+
},
|
| 246 |
+
"execution_count": 2,
|
| 247 |
+
"metadata": {},
|
| 248 |
+
"output_type": "execute_result"
|
| 249 |
+
}
|
| 250 |
+
],
|
| 251 |
+
"source": [
|
| 252 |
+
"import pandas as pd\n",
|
| 253 |
+
"\n",
|
| 254 |
+
"raw = pd.read_excel(\".data/AMRA AI Reader_Search Term_V14m.xlsx\",sheet_name=None)\n",
|
| 255 |
+
"raw.keys()"
|
| 256 |
+
]
|
| 257 |
+
},
|
| 258 |
+
{
|
| 259 |
+
"cell_type": "code",
|
| 260 |
+
"execution_count": 25,
|
| 261 |
+
"metadata": {},
|
| 262 |
+
"outputs": [
|
| 263 |
+
{
|
| 264 |
+
"data": {
|
| 265 |
+
"text/html": [
|
| 266 |
+
"<div>\n",
|
| 267 |
+
"<style scoped>\n",
|
| 268 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 269 |
+
" vertical-align: middle;\n",
|
| 270 |
+
" }\n",
|
| 271 |
+
"\n",
|
| 272 |
+
" .dataframe tbody tr th {\n",
|
| 273 |
+
" vertical-align: top;\n",
|
| 274 |
+
" }\n",
|
| 275 |
+
"\n",
|
| 276 |
+
" .dataframe thead th {\n",
|
| 277 |
+
" text-align: right;\n",
|
| 278 |
+
" }\n",
|
| 279 |
+
"</style>\n",
|
| 280 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 281 |
+
" <thead>\n",
|
| 282 |
+
" <tr style=\"text-align: right;\">\n",
|
| 283 |
+
" <th></th>\n",
|
| 284 |
+
" <th>assessment</th>\n",
|
| 285 |
+
" <th>region</th>\n",
|
| 286 |
+
" <th>instruction</th>\n",
|
| 287 |
+
" <th>indication_terms</th>\n",
|
| 288 |
+
" <th>prompting_term</th>\n",
|
| 289 |
+
" <th>outcome_term</th>\n",
|
| 290 |
+
" <th>outcome_summary_term</th>\n",
|
| 291 |
+
" </tr>\n",
|
| 292 |
+
" </thead>\n",
|
| 293 |
+
" <tbody>\n",
|
| 294 |
+
" <tr>\n",
|
| 295 |
+
" <th>0</th>\n",
|
| 296 |
+
" <td>overview</td>\n",
|
| 297 |
+
" <td>extremity</td>\n",
|
| 298 |
+
" <td>Study-FIN</td>\n",
|
| 299 |
+
" <td>NaN</td>\n",
|
| 300 |
+
" <td>NaN</td>\n",
|
| 301 |
+
" <td>NaN</td>\n",
|
| 302 |
+
" <td>NaN</td>\n",
|
| 303 |
+
" </tr>\n",
|
| 304 |
+
" <tr>\n",
|
| 305 |
+
" <th>1</th>\n",
|
| 306 |
+
" <td>overview</td>\n",
|
| 307 |
+
" <td>extremity</td>\n",
|
| 308 |
+
" <td>Time Frame-FIN</td>\n",
|
| 309 |
+
" <td>NaN</td>\n",
|
| 310 |
+
" <td>NaN</td>\n",
|
| 311 |
+
" <td>NaN</td>\n",
|
| 312 |
+
" <td>NaN</td>\n",
|
| 313 |
+
" </tr>\n",
|
| 314 |
+
" <tr>\n",
|
| 315 |
+
" <th>2</th>\n",
|
| 316 |
+
" <td>overview</td>\n",
|
| 317 |
+
" <td>extremity</td>\n",
|
| 318 |
+
" <td>Device-Extremity-FIN</td>\n",
|
| 319 |
+
" <td>NaN</td>\n",
|
| 320 |
+
" <td>NaN</td>\n",
|
| 321 |
+
" <td>NaN</td>\n",
|
| 322 |
+
" <td>NaN</td>\n",
|
| 323 |
+
" </tr>\n",
|
| 324 |
+
" <tr>\n",
|
| 325 |
+
" <th>3</th>\n",
|
| 326 |
+
" <td>overview</td>\n",
|
| 327 |
+
" <td>extremity</td>\n",
|
| 328 |
+
" <td>Bone Graft-FIN</td>\n",
|
| 329 |
+
" <td>NaN</td>\n",
|
| 330 |
+
" <td>NaN</td>\n",
|
| 331 |
+
" <td>NaN</td>\n",
|
| 332 |
+
" <td>NaN</td>\n",
|
| 333 |
+
" </tr>\n",
|
| 334 |
+
" <tr>\n",
|
| 335 |
+
" <th>4</th>\n",
|
| 336 |
+
" <td>overview</td>\n",
|
| 337 |
+
" <td>extremity</td>\n",
|
| 338 |
+
" <td>Procedure-Extremity-FIN</td>\n",
|
| 339 |
+
" <td>NaN</td>\n",
|
| 340 |
+
" <td>NaN</td>\n",
|
| 341 |
+
" <td>NaN</td>\n",
|
| 342 |
+
" <td>NaN</td>\n",
|
| 343 |
+
" </tr>\n",
|
| 344 |
+
" </tbody>\n",
|
| 345 |
+
"</table>\n",
|
| 346 |
+
"</div>"
|
| 347 |
+
],
|
| 348 |
+
"text/plain": [
|
| 349 |
+
" assessment region instruction indication_terms \\\n",
|
| 350 |
+
"0 overview extremity Study-FIN NaN \n",
|
| 351 |
+
"1 overview extremity Time Frame-FIN NaN \n",
|
| 352 |
+
"2 overview extremity Device-Extremity-FIN NaN \n",
|
| 353 |
+
"3 overview extremity Bone Graft-FIN NaN \n",
|
| 354 |
+
"4 overview extremity Procedure-Extremity-FIN NaN \n",
|
| 355 |
+
"\n",
|
| 356 |
+
" prompting_term outcome_term outcome_summary_term \n",
|
| 357 |
+
"0 NaN NaN NaN \n",
|
| 358 |
+
"1 NaN NaN NaN \n",
|
| 359 |
+
"2 NaN NaN NaN \n",
|
| 360 |
+
"3 NaN NaN NaN \n",
|
| 361 |
+
"4 NaN NaN NaN "
|
| 362 |
+
]
|
| 363 |
+
},
|
| 364 |
+
"metadata": {},
|
| 365 |
+
"output_type": "display_data"
|
| 366 |
+
},
|
| 367 |
+
{
|
| 368 |
+
"data": {
|
| 369 |
+
"text/html": [
|
| 370 |
+
"<div>\n",
|
| 371 |
+
"<style scoped>\n",
|
| 372 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 373 |
+
" vertical-align: middle;\n",
|
| 374 |
+
" }\n",
|
| 375 |
+
"\n",
|
| 376 |
+
" .dataframe tbody tr th {\n",
|
| 377 |
+
" vertical-align: top;\n",
|
| 378 |
+
" }\n",
|
| 379 |
+
"\n",
|
| 380 |
+
" .dataframe thead th {\n",
|
| 381 |
+
" text-align: right;\n",
|
| 382 |
+
" }\n",
|
| 383 |
+
"</style>\n",
|
| 384 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 385 |
+
" <thead>\n",
|
| 386 |
+
" <tr style=\"text-align: right;\">\n",
|
| 387 |
+
" <th></th>\n",
|
| 388 |
+
" <th>assessment</th>\n",
|
| 389 |
+
" <th>region</th>\n",
|
| 390 |
+
" <th>instruction</th>\n",
|
| 391 |
+
" <th>indication_terms</th>\n",
|
| 392 |
+
" <th>prompting_term</th>\n",
|
| 393 |
+
" <th>outcome_term</th>\n",
|
| 394 |
+
" <th>outcome_summary_term</th>\n",
|
| 395 |
+
" </tr>\n",
|
| 396 |
+
" </thead>\n",
|
| 397 |
+
" <tbody>\n",
|
| 398 |
+
" <tr>\n",
|
| 399 |
+
" <th>0</th>\n",
|
| 400 |
+
" <td>overview</td>\n",
|
| 401 |
+
" <td>extremity</td>\n",
|
| 402 |
+
" <td>[Study-FIN]</td>\n",
|
| 403 |
+
" <td>overview Study-FIN</td>\n",
|
| 404 |
+
" <td></td>\n",
|
| 405 |
+
" <td></td>\n",
|
| 406 |
+
" <td></td>\n",
|
| 407 |
+
" </tr>\n",
|
| 408 |
+
" <tr>\n",
|
| 409 |
+
" <th>1</th>\n",
|
| 410 |
+
" <td>overview</td>\n",
|
| 411 |
+
" <td>extremity</td>\n",
|
| 412 |
+
" <td>[Time Frame-FIN]</td>\n",
|
| 413 |
+
" <td>overview Time Frame-FIN</td>\n",
|
| 414 |
+
" <td></td>\n",
|
| 415 |
+
" <td></td>\n",
|
| 416 |
+
" <td></td>\n",
|
| 417 |
+
" </tr>\n",
|
| 418 |
+
" <tr>\n",
|
| 419 |
+
" <th>2</th>\n",
|
| 420 |
+
" <td>overview</td>\n",
|
| 421 |
+
" <td>extremity</td>\n",
|
| 422 |
+
" <td>[Device-Extremity-FIN]</td>\n",
|
| 423 |
+
" <td>overview Device-Extremity-FIN</td>\n",
|
| 424 |
+
" <td></td>\n",
|
| 425 |
+
" <td></td>\n",
|
| 426 |
+
" <td></td>\n",
|
| 427 |
+
" </tr>\n",
|
| 428 |
+
" <tr>\n",
|
| 429 |
+
" <th>3</th>\n",
|
| 430 |
+
" <td>overview</td>\n",
|
| 431 |
+
" <td>extremity</td>\n",
|
| 432 |
+
" <td>[Bone Graft-FIN]</td>\n",
|
| 433 |
+
" <td>overview Bone Graft-FIN</td>\n",
|
| 434 |
+
" <td></td>\n",
|
| 435 |
+
" <td></td>\n",
|
| 436 |
+
" <td></td>\n",
|
| 437 |
+
" </tr>\n",
|
| 438 |
+
" <tr>\n",
|
| 439 |
+
" <th>4</th>\n",
|
| 440 |
+
" <td>overview</td>\n",
|
| 441 |
+
" <td>extremity</td>\n",
|
| 442 |
+
" <td>[Procedure-Extremity-FIN]</td>\n",
|
| 443 |
+
" <td>overview Procedure-Extremity-FIN</td>\n",
|
| 444 |
+
" <td></td>\n",
|
| 445 |
+
" <td></td>\n",
|
| 446 |
+
" <td></td>\n",
|
| 447 |
+
" </tr>\n",
|
| 448 |
+
" <tr>\n",
|
| 449 |
+
" <th>...</th>\n",
|
| 450 |
+
" <td>...</td>\n",
|
| 451 |
+
" <td>...</td>\n",
|
| 452 |
+
" <td>...</td>\n",
|
| 453 |
+
" <td>...</td>\n",
|
| 454 |
+
" <td>...</td>\n",
|
| 455 |
+
" <td>...</td>\n",
|
| 456 |
+
" <td>...</td>\n",
|
| 457 |
+
" </tr>\n",
|
| 458 |
+
" <tr>\n",
|
| 459 |
+
" <th>3488</th>\n",
|
| 460 |
+
" <td>other</td>\n",
|
| 461 |
+
" <td>all</td>\n",
|
| 462 |
+
" <td>[Length of Hospital Stay]</td>\n",
|
| 463 |
+
" <td>LOS, hospital stay</td>\n",
|
| 464 |
+
" <td>Length of Hospital Stay</td>\n",
|
| 465 |
+
" <td>Length of Hospital Stay</td>\n",
|
| 466 |
+
" <td></td>\n",
|
| 467 |
+
" </tr>\n",
|
| 468 |
+
" <tr>\n",
|
| 469 |
+
" <th>3489</th>\n",
|
| 470 |
+
" <td>other</td>\n",
|
| 471 |
+
" <td>all</td>\n",
|
| 472 |
+
" <td>[Length of Hospital Stay]</td>\n",
|
| 473 |
+
" <td>ICU, LOS, hospital stay</td>\n",
|
| 474 |
+
" <td>Length of Hospital Stay</td>\n",
|
| 475 |
+
" <td>Length of Hospital Stay</td>\n",
|
| 476 |
+
" <td></td>\n",
|
| 477 |
+
" </tr>\n",
|
| 478 |
+
" <tr>\n",
|
| 479 |
+
" <th>3490</th>\n",
|
| 480 |
+
" <td>other</td>\n",
|
| 481 |
+
" <td>all</td>\n",
|
| 482 |
+
" <td>[Operation Time]</td>\n",
|
| 483 |
+
" <td>Operation time, hrs</td>\n",
|
| 484 |
+
" <td>Operation Time</td>\n",
|
| 485 |
+
" <td>Operation Time</td>\n",
|
| 486 |
+
" <td></td>\n",
|
| 487 |
+
" </tr>\n",
|
| 488 |
+
" <tr>\n",
|
| 489 |
+
" <th>3491</th>\n",
|
| 490 |
+
" <td>other</td>\n",
|
| 491 |
+
" <td>all</td>\n",
|
| 492 |
+
" <td>[Operation Time]</td>\n",
|
| 493 |
+
" <td>Operative time, hrs</td>\n",
|
| 494 |
+
" <td>Operation Time</td>\n",
|
| 495 |
+
" <td>Operation Time</td>\n",
|
| 496 |
+
" <td></td>\n",
|
| 497 |
+
" </tr>\n",
|
| 498 |
+
" <tr>\n",
|
| 499 |
+
" <th>3492</th>\n",
|
| 500 |
+
" <td>other</td>\n",
|
| 501 |
+
" <td>all</td>\n",
|
| 502 |
+
" <td>[Length of Hospital Stay]</td>\n",
|
| 503 |
+
" <td>ICU stay</td>\n",
|
| 504 |
+
" <td>Length of Hospital Stay</td>\n",
|
| 505 |
+
" <td>Length of Hospital Stay</td>\n",
|
| 506 |
+
" <td></td>\n",
|
| 507 |
+
" </tr>\n",
|
| 508 |
+
" </tbody>\n",
|
| 509 |
+
"</table>\n",
|
| 510 |
+
"<p>3493 rows × 7 columns</p>\n",
|
| 511 |
+
"</div>"
|
| 512 |
+
],
|
| 513 |
+
"text/plain": [
|
| 514 |
+
" assessment region instruction \\\n",
|
| 515 |
+
"0 overview extremity [Study-FIN] \n",
|
| 516 |
+
"1 overview extremity [Time Frame-FIN] \n",
|
| 517 |
+
"2 overview extremity [Device-Extremity-FIN] \n",
|
| 518 |
+
"3 overview extremity [Bone Graft-FIN] \n",
|
| 519 |
+
"4 overview extremity [Procedure-Extremity-FIN] \n",
|
| 520 |
+
"... ... ... ... \n",
|
| 521 |
+
"3488 other all [Length of Hospital Stay] \n",
|
| 522 |
+
"3489 other all [Length of Hospital Stay] \n",
|
| 523 |
+
"3490 other all [Operation Time] \n",
|
| 524 |
+
"3491 other all [Operation Time] \n",
|
| 525 |
+
"3492 other all [Length of Hospital Stay] \n",
|
| 526 |
+
"\n",
|
| 527 |
+
" indication_terms prompting_term \\\n",
|
| 528 |
+
"0 overview Study-FIN \n",
|
| 529 |
+
"1 overview Time Frame-FIN \n",
|
| 530 |
+
"2 overview Device-Extremity-FIN \n",
|
| 531 |
+
"3 overview Bone Graft-FIN \n",
|
| 532 |
+
"4 overview Procedure-Extremity-FIN \n",
|
| 533 |
+
"... ... ... \n",
|
| 534 |
+
"3488 LOS, hospital stay Length of Hospital Stay \n",
|
| 535 |
+
"3489 ICU, LOS, hospital stay Length of Hospital Stay \n",
|
| 536 |
+
"3490 Operation time, hrs Operation Time \n",
|
| 537 |
+
"3491 Operative time, hrs Operation Time \n",
|
| 538 |
+
"3492 ICU stay Length of Hospital Stay \n",
|
| 539 |
+
"\n",
|
| 540 |
+
" outcome_term outcome_summary_term \n",
|
| 541 |
+
"0 \n",
|
| 542 |
+
"1 \n",
|
| 543 |
+
"2 \n",
|
| 544 |
+
"3 \n",
|
| 545 |
+
"4 \n",
|
| 546 |
+
"... ... ... \n",
|
| 547 |
+
"3488 Length of Hospital Stay \n",
|
| 548 |
+
"3489 Length of Hospital Stay \n",
|
| 549 |
+
"3490 Operation Time \n",
|
| 550 |
+
"3491 Operation Time \n",
|
| 551 |
+
"3492 Length of Hospital Stay \n",
|
| 552 |
+
"\n",
|
| 553 |
+
"[3493 rows x 7 columns]"
|
| 554 |
+
]
|
| 555 |
+
},
|
| 556 |
+
"execution_count": 25,
|
| 557 |
+
"metadata": {},
|
| 558 |
+
"output_type": "execute_result"
|
| 559 |
+
}
|
| 560 |
+
],
|
| 561 |
+
"source": [
|
| 562 |
+
"df_terms = raw[\"terms\"].copy()\n",
|
| 563 |
+
"display(df_terms.head())\n",
|
| 564 |
+
"\n",
|
| 565 |
+
"df_terms.loc[df_terms[\"assessment\"] == \"overview\", \"indication_terms\"] = df_terms.loc[df_terms[\"assessment\"] == \"overview\", \"assessment\"] + \" \" + df_terms.loc[df_terms[\"assessment\"] == \"overview\", \"instruction\"]\n",
|
| 566 |
+
"df_terms.fillna(\"\",inplace=True)\n",
|
| 567 |
+
"df_terms[\"instruction\"] = df_terms[\"instruction\"].apply(lambda x: [i.strip() for i in x.split(\",\") if i.strip()])\n",
|
| 568 |
+
"df_terms"
|
| 569 |
+
]
|
| 570 |
+
},
|
| 571 |
+
{
|
| 572 |
+
"cell_type": "code",
|
| 573 |
+
"execution_count": 26,
|
| 574 |
+
"metadata": {},
|
| 575 |
+
"outputs": [
|
| 576 |
+
{
|
| 577 |
+
"name": "stdout",
|
| 578 |
+
"output_type": "stream",
|
| 579 |
+
"text": [
|
| 580 |
+
"3493/3493\n",
|
| 581 |
+
"upload erros count: 0\n"
|
| 582 |
+
]
|
| 583 |
+
},
|
| 584 |
+
{
|
| 585 |
+
"data": {
|
| 586 |
+
"text/plain": [
|
| 587 |
+
"[]"
|
| 588 |
+
]
|
| 589 |
+
},
|
| 590 |
+
"execution_count": 26,
|
| 591 |
+
"metadata": {},
|
| 592 |
+
"output_type": "execute_result"
|
| 593 |
+
}
|
| 594 |
+
],
|
| 595 |
+
"source": [
|
| 596 |
+
"df_local_to_aws_dynamodb(\"terms\",df_terms)"
|
| 597 |
+
]
|
| 598 |
+
},
|
| 599 |
+
{
|
| 600 |
+
"cell_type": "code",
|
| 601 |
+
"execution_count": 5,
|
| 602 |
+
"metadata": {},
|
| 603 |
+
"outputs": [
|
| 604 |
+
{
|
| 605 |
+
"name": "stdout",
|
| 606 |
+
"output_type": "stream",
|
| 607 |
+
"text": [
|
| 608 |
+
"23-12-10 00:36:53 - executing function: get_table\n",
|
| 609 |
+
"23-12-10 00:36:53 - completed function: get_table, runtime: 0:00:00.667078 seconds\n"
|
| 610 |
+
]
|
| 611 |
+
}
|
| 612 |
+
],
|
| 613 |
+
"source": [
|
| 614 |
+
"# get the current prompts to update new df_prompts' section_sequence\n",
|
| 615 |
+
"current = get_table(\"prompts\")\n",
|
| 616 |
+
"current_prompts = {p[\"name\"]:p for p in current}"
|
| 617 |
+
]
|
| 618 |
+
},
|
| 619 |
+
{
|
| 620 |
+
"cell_type": "code",
|
| 621 |
+
"execution_count": 6,
|
| 622 |
+
"metadata": {},
|
| 623 |
+
"outputs": [
|
| 624 |
+
{
|
| 625 |
+
"data": {
|
| 626 |
+
"text/html": [
|
| 627 |
+
"<div>\n",
|
| 628 |
+
"<style scoped>\n",
|
| 629 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 630 |
+
" vertical-align: middle;\n",
|
| 631 |
+
" }\n",
|
| 632 |
+
"\n",
|
| 633 |
+
" .dataframe tbody tr th {\n",
|
| 634 |
+
" vertical-align: top;\n",
|
| 635 |
+
" }\n",
|
| 636 |
+
"\n",
|
| 637 |
+
" .dataframe thead th {\n",
|
| 638 |
+
" text-align: right;\n",
|
| 639 |
+
" }\n",
|
| 640 |
+
"</style>\n",
|
| 641 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 642 |
+
" <thead>\n",
|
| 643 |
+
" <tr style=\"text-align: right;\">\n",
|
| 644 |
+
" <th></th>\n",
|
| 645 |
+
" <th>name</th>\n",
|
| 646 |
+
" <th>assessment</th>\n",
|
| 647 |
+
" <th>inputs</th>\n",
|
| 648 |
+
" <th>section_sequence</th>\n",
|
| 649 |
+
" <th>chain</th>\n",
|
| 650 |
+
" </tr>\n",
|
| 651 |
+
" </thead>\n",
|
| 652 |
+
" <tbody>\n",
|
| 653 |
+
" <tr>\n",
|
| 654 |
+
" <th>0</th>\n",
|
| 655 |
+
" <td>Article ID</td>\n",
|
| 656 |
+
" <td>overview</td>\n",
|
| 657 |
+
" <td>[Authors, Acceptance Month, Acceptance Year]</td>\n",
|
| 658 |
+
" <td>1</td>\n",
|
| 659 |
+
" <td>[From the System, Perform the following tasks:...</td>\n",
|
| 660 |
+
" </tr>\n",
|
| 661 |
+
" <tr>\n",
|
| 662 |
+
" <th>1</th>\n",
|
| 663 |
+
" <td>Study-FIN</td>\n",
|
| 664 |
+
" <td>overview</td>\n",
|
| 665 |
+
" <td>[Material and Methods]</td>\n",
|
| 666 |
+
" <td>2</td>\n",
|
| 667 |
+
" <td>[From the System, Extract the following inform...</td>\n",
|
| 668 |
+
" </tr>\n",
|
| 669 |
+
" <tr>\n",
|
| 670 |
+
" <th>2</th>\n",
|
| 671 |
+
" <td>Time Frame-FIN</td>\n",
|
| 672 |
+
" <td>overview</td>\n",
|
| 673 |
+
" <td>[Material and Methods]</td>\n",
|
| 674 |
+
" <td>3</td>\n",
|
| 675 |
+
" <td>[From the System, Extract the following inform...</td>\n",
|
| 676 |
+
" </tr>\n",
|
| 677 |
+
" <tr>\n",
|
| 678 |
+
" <th>3</th>\n",
|
| 679 |
+
" <td>Device-Spine-FIN</td>\n",
|
| 680 |
+
" <td>overview</td>\n",
|
| 681 |
+
" <td>[Introduction, Material and Methods]</td>\n",
|
| 682 |
+
" <td>4</td>\n",
|
| 683 |
+
" <td>[From the System, Extract the following inform...</td>\n",
|
| 684 |
+
" </tr>\n",
|
| 685 |
+
" <tr>\n",
|
| 686 |
+
" <th>4</th>\n",
|
| 687 |
+
" <td>SupFix-Spine-FIN</td>\n",
|
| 688 |
+
" <td>overview</td>\n",
|
| 689 |
+
" <td>[Introduction, Material and Methods]</td>\n",
|
| 690 |
+
" <td>5</td>\n",
|
| 691 |
+
" <td>[From the System, Extract the following inform...</td>\n",
|
| 692 |
+
" </tr>\n",
|
| 693 |
+
" <tr>\n",
|
| 694 |
+
" <th>...</th>\n",
|
| 695 |
+
" <td>...</td>\n",
|
| 696 |
+
" <td>...</td>\n",
|
| 697 |
+
" <td>...</td>\n",
|
| 698 |
+
" <td>...</td>\n",
|
| 699 |
+
" <td>...</td>\n",
|
| 700 |
+
" </tr>\n",
|
| 701 |
+
" <tr>\n",
|
| 702 |
+
" <th>84</th>\n",
|
| 703 |
+
" <td>Length of Hospital Stay</td>\n",
|
| 704 |
+
" <td>other</td>\n",
|
| 705 |
+
" <td>[Abstract, Material and Methods, Results, Mark...</td>\n",
|
| 706 |
+
" <td></td>\n",
|
| 707 |
+
" <td>[From the System and/or previous Assistant res...</td>\n",
|
| 708 |
+
" </tr>\n",
|
| 709 |
+
" <tr>\n",
|
| 710 |
+
" <th>85</th>\n",
|
| 711 |
+
" <td>Need for ICU</td>\n",
|
| 712 |
+
" <td>other</td>\n",
|
| 713 |
+
" <td>[Abstract, Material and Methods, Results, Mark...</td>\n",
|
| 714 |
+
" <td></td>\n",
|
| 715 |
+
" <td>[From the System and/or previous Assistant res...</td>\n",
|
| 716 |
+
" </tr>\n",
|
| 717 |
+
" <tr>\n",
|
| 718 |
+
" <th>86</th>\n",
|
| 719 |
+
" <td>Operation Time</td>\n",
|
| 720 |
+
" <td>other</td>\n",
|
| 721 |
+
" <td>[Abstract, Material and Methods, Results, Mark...</td>\n",
|
| 722 |
+
" <td></td>\n",
|
| 723 |
+
" <td>[From the System and/or previous Assistant res...</td>\n",
|
| 724 |
+
" </tr>\n",
|
| 725 |
+
" <tr>\n",
|
| 726 |
+
" <th>87</th>\n",
|
| 727 |
+
" <td>Transfusion Rate</td>\n",
|
| 728 |
+
" <td>other</td>\n",
|
| 729 |
+
" <td>[Abstract, Material and Methods, Results, Mark...</td>\n",
|
| 730 |
+
" <td></td>\n",
|
| 731 |
+
" <td>[From the System and/or previous Assistant res...</td>\n",
|
| 732 |
+
" </tr>\n",
|
| 733 |
+
" <tr>\n",
|
| 734 |
+
" <th>88</th>\n",
|
| 735 |
+
" <td>Time to Readmission</td>\n",
|
| 736 |
+
" <td>other</td>\n",
|
| 737 |
+
" <td>[Abstract, Material and Methods, Results, Mark...</td>\n",
|
| 738 |
+
" <td></td>\n",
|
| 739 |
+
" <td>[From the System and/or previous Assistant res...</td>\n",
|
| 740 |
+
" </tr>\n",
|
| 741 |
+
" </tbody>\n",
|
| 742 |
+
"</table>\n",
|
| 743 |
+
"<p>89 rows × 5 columns</p>\n",
|
| 744 |
+
"</div>"
|
| 745 |
+
],
|
| 746 |
+
"text/plain": [
|
| 747 |
+
" name assessment \\\n",
|
| 748 |
+
"0 Article ID overview \n",
|
| 749 |
+
"1 Study-FIN overview \n",
|
| 750 |
+
"2 Time Frame-FIN overview \n",
|
| 751 |
+
"3 Device-Spine-FIN overview \n",
|
| 752 |
+
"4 SupFix-Spine-FIN overview \n",
|
| 753 |
+
".. ... ... \n",
|
| 754 |
+
"84 Length of Hospital Stay other \n",
|
| 755 |
+
"85 Need for ICU other \n",
|
| 756 |
+
"86 Operation Time other \n",
|
| 757 |
+
"87 Transfusion Rate other \n",
|
| 758 |
+
"88 Time to Readmission other \n",
|
| 759 |
+
"\n",
|
| 760 |
+
" inputs section_sequence \\\n",
|
| 761 |
+
"0 [Authors, Acceptance Month, Acceptance Year] 1 \n",
|
| 762 |
+
"1 [Material and Methods] 2 \n",
|
| 763 |
+
"2 [Material and Methods] 3 \n",
|
| 764 |
+
"3 [Introduction, Material and Methods] 4 \n",
|
| 765 |
+
"4 [Introduction, Material and Methods] 5 \n",
|
| 766 |
+
".. ... ... \n",
|
| 767 |
+
"84 [Abstract, Material and Methods, Results, Mark... \n",
|
| 768 |
+
"85 [Abstract, Material and Methods, Results, Mark... \n",
|
| 769 |
+
"86 [Abstract, Material and Methods, Results, Mark... \n",
|
| 770 |
+
"87 [Abstract, Material and Methods, Results, Mark... \n",
|
| 771 |
+
"88 [Abstract, Material and Methods, Results, Mark... \n",
|
| 772 |
+
"\n",
|
| 773 |
+
" chain \n",
|
| 774 |
+
"0 [From the System, Perform the following tasks:... \n",
|
| 775 |
+
"1 [From the System, Extract the following inform... \n",
|
| 776 |
+
"2 [From the System, Extract the following inform... \n",
|
| 777 |
+
"3 [From the System, Extract the following inform... \n",
|
| 778 |
+
"4 [From the System, Extract the following inform... \n",
|
| 779 |
+
".. ... \n",
|
| 780 |
+
"84 [From the System and/or previous Assistant res... \n",
|
| 781 |
+
"85 [From the System and/or previous Assistant res... \n",
|
| 782 |
+
"86 [From the System and/or previous Assistant res... \n",
|
| 783 |
+
"87 [From the System and/or previous Assistant res... \n",
|
| 784 |
+
"88 [From the System and/or previous Assistant res... \n",
|
| 785 |
+
"\n",
|
| 786 |
+
"[89 rows x 5 columns]"
|
| 787 |
+
]
|
| 788 |
+
},
|
| 789 |
+
"execution_count": 6,
|
| 790 |
+
"metadata": {},
|
| 791 |
+
"output_type": "execute_result"
|
| 792 |
+
}
|
| 793 |
+
],
|
| 794 |
+
"source": [
|
| 795 |
+
"# preprocess df_prompts before upload\n",
|
| 796 |
+
"df_prompts = raw[\"prompts\"].copy()\n",
|
| 797 |
+
"df_prompts[\"section_sequence\"] = df_prompts.apply(lambda x: current_prompts[x[\"name\"].strip()][\"section_sequence\"] if x[\"name\"] in current_prompts else \"\", axis=1)\n",
|
| 798 |
+
"df_prompts.fillna(\"\",inplace=True)\n",
|
| 799 |
+
"df_prompts.inputs = df_prompts.inputs.apply(lambda x: [i.strip() for i in x.split(\",\") if i.strip()])\n",
|
| 800 |
+
"df_prompts[\"chain\"] = df_prompts.apply(lambda x: [x[\"root\"],x[\"group\"],x[\"outcome\"],x[\"preoperative\"],x[\"postoperative\"],x[\"study_n\"]],axis=1)\n",
|
| 801 |
+
"df_prompts.drop(columns=[\"root\",\"group\",\"outcome\",\"preoperative\",\"postoperative\",\"study_n\"],inplace=True)\n",
|
| 802 |
+
"df_prompts"
|
| 803 |
+
]
|
| 804 |
+
},
|
| 805 |
+
{
|
| 806 |
+
"cell_type": "code",
|
| 807 |
+
"execution_count": 10,
|
| 808 |
+
"metadata": {},
|
| 809 |
+
"outputs": [
|
| 810 |
+
{
|
| 811 |
+
"name": "stdout",
|
| 812 |
+
"output_type": "stream",
|
| 813 |
+
"text": [
|
| 814 |
+
"89/89\n",
|
| 815 |
+
"upload erros count: 0\n"
|
| 816 |
+
]
|
| 817 |
+
},
|
| 818 |
+
{
|
| 819 |
+
"data": {
|
| 820 |
+
"text/plain": [
|
| 821 |
+
"[]"
|
| 822 |
+
]
|
| 823 |
+
},
|
| 824 |
+
"execution_count": 10,
|
| 825 |
+
"metadata": {},
|
| 826 |
+
"output_type": "execute_result"
|
| 827 |
+
}
|
| 828 |
+
],
|
| 829 |
+
"source": [
|
| 830 |
+
"df_local_to_aws_dynamodb(\"prompts\",df_prompts)"
|
| 831 |
+
]
|
| 832 |
+
},
|
| 833 |
+
{
|
| 834 |
+
"cell_type": "code",
|
| 835 |
+
"execution_count": 87,
|
| 836 |
+
"metadata": {},
|
| 837 |
+
"outputs": [
|
| 838 |
+
{
|
| 839 |
+
"data": {
|
| 840 |
+
"text/html": [
|
| 841 |
+
"<div>\n",
|
| 842 |
+
"<style scoped>\n",
|
| 843 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 844 |
+
" vertical-align: middle;\n",
|
| 845 |
+
" }\n",
|
| 846 |
+
"\n",
|
| 847 |
+
" .dataframe tbody tr th {\n",
|
| 848 |
+
" vertical-align: top;\n",
|
| 849 |
+
" }\n",
|
| 850 |
+
"\n",
|
| 851 |
+
" .dataframe thead th {\n",
|
| 852 |
+
" text-align: right;\n",
|
| 853 |
+
" }\n",
|
| 854 |
+
"</style>\n",
|
| 855 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 856 |
+
" <thead>\n",
|
| 857 |
+
" <tr style=\"text-align: right;\">\n",
|
| 858 |
+
" <th></th>\n",
|
| 859 |
+
" <th>name</th>\n",
|
| 860 |
+
" <th>assessment</th>\n",
|
| 861 |
+
" <th>inputs</th>\n",
|
| 862 |
+
" <th>chain</th>\n",
|
| 863 |
+
" </tr>\n",
|
| 864 |
+
" </thead>\n",
|
| 865 |
+
" <tbody>\n",
|
| 866 |
+
" <tr>\n",
|
| 867 |
+
" <th>0</th>\n",
|
| 868 |
+
" <td>clin-perfFUtable-FIN</td>\n",
|
| 869 |
+
" <td>clinical</td>\n",
|
| 870 |
+
" <td>Change in Probing Depth\\nFFI\\nGlobal Rating of...</td>\n",
|
| 871 |
+
" <td>[Report ALL of the CLINICAL OUTCOME informatio...</td>\n",
|
| 872 |
+
" </tr>\n",
|
| 873 |
+
" <tr>\n",
|
| 874 |
+
" <th>1</th>\n",
|
| 875 |
+
" <td>rad-perfFUtable-FIN</td>\n",
|
| 876 |
+
" <td>radiologic</td>\n",
|
| 877 |
+
" <td>Adjacent Segment ROM\\nCarpal Height Ratio\\nCer...</td>\n",
|
| 878 |
+
" <td>[Report ALL of the RADIOLOGIC OUTCOME informat...</td>\n",
|
| 879 |
+
" </tr>\n",
|
| 880 |
+
" <tr>\n",
|
| 881 |
+
" <th>2</th>\n",
|
| 882 |
+
" <td>saf-Futable-FIN</td>\n",
|
| 883 |
+
" <td>safety</td>\n",
|
| 884 |
+
" <td>abb Nonunion-NG\\nGeneric Combo-NG\\nMerged Revi...</td>\n",
|
| 885 |
+
" <td>[Report ALL of the SAFETY OUTCOME information ...</td>\n",
|
| 886 |
+
" </tr>\n",
|
| 887 |
+
" <tr>\n",
|
| 888 |
+
" <th>3</th>\n",
|
| 889 |
+
" <td>oth-perfFUtable-FIN</td>\n",
|
| 890 |
+
" <td>other</td>\n",
|
| 891 |
+
" <td>Blood Loss\\nHospital Charge\\nLength of Hospita...</td>\n",
|
| 892 |
+
" <td>[Report ALL of the OTHER OUTCOME information f...</td>\n",
|
| 893 |
+
" </tr>\n",
|
| 894 |
+
" </tbody>\n",
|
| 895 |
+
"</table>\n",
|
| 896 |
+
"</div>"
|
| 897 |
+
],
|
| 898 |
+
"text/plain": [
|
| 899 |
+
" name assessment \\\n",
|
| 900 |
+
"0 clin-perfFUtable-FIN clinical \n",
|
| 901 |
+
"1 rad-perfFUtable-FIN radiologic \n",
|
| 902 |
+
"2 saf-Futable-FIN safety \n",
|
| 903 |
+
"3 oth-perfFUtable-FIN other \n",
|
| 904 |
+
"\n",
|
| 905 |
+
" inputs \\\n",
|
| 906 |
+
"0 Change in Probing Depth\\nFFI\\nGlobal Rating of... \n",
|
| 907 |
+
"1 Adjacent Segment ROM\\nCarpal Height Ratio\\nCer... \n",
|
| 908 |
+
"2 abb Nonunion-NG\\nGeneric Combo-NG\\nMerged Revi... \n",
|
| 909 |
+
"3 Blood Loss\\nHospital Charge\\nLength of Hospita... \n",
|
| 910 |
+
"\n",
|
| 911 |
+
" chain \n",
|
| 912 |
+
"0 [Report ALL of the CLINICAL OUTCOME informatio... \n",
|
| 913 |
+
"1 [Report ALL of the RADIOLOGIC OUTCOME informat... \n",
|
| 914 |
+
"2 [Report ALL of the SAFETY OUTCOME information ... \n",
|
| 915 |
+
"3 [Report ALL of the OTHER OUTCOME information f... "
|
| 916 |
+
]
|
| 917 |
+
},
|
| 918 |
+
"execution_count": 87,
|
| 919 |
+
"metadata": {},
|
| 920 |
+
"output_type": "execute_result"
|
| 921 |
+
}
|
| 922 |
+
],
|
| 923 |
+
"source": [
|
| 924 |
+
"# update the aggregate prompts\n",
|
| 925 |
+
"df_prompts_agg = raw[\"prompt_agg\"].copy()\n",
|
| 926 |
+
"df_prompts_agg.dropna(subset=[\"name\"],inplace=True)\n",
|
| 927 |
+
"df_prompts_agg[\"chain\"] = df_prompts_agg.apply(lambda x: [x[\"root\"]],axis=1)\n",
|
| 928 |
+
"columns_to_drop = [c for c in df_prompts_agg.columns if \"Unnamed\" in c]\n",
|
| 929 |
+
"columns_to_drop.append(\"root\")\n",
|
| 930 |
+
"df_prompts_agg.drop(columns=columns_to_drop,inplace=True)\n",
|
| 931 |
+
"\n",
|
| 932 |
+
"df_prompts_agg"
|
| 933 |
+
]
|
| 934 |
+
},
|
| 935 |
+
{
|
| 936 |
+
"cell_type": "code",
|
| 937 |
+
"execution_count": 88,
|
| 938 |
+
"metadata": {},
|
| 939 |
+
"outputs": [
|
| 940 |
+
{
|
| 941 |
+
"name": "stdout",
|
| 942 |
+
"output_type": "stream",
|
| 943 |
+
"text": [
|
| 944 |
+
"4/4\n",
|
| 945 |
+
"upload erros count: 0\n"
|
| 946 |
+
]
|
| 947 |
+
},
|
| 948 |
+
{
|
| 949 |
+
"data": {
|
| 950 |
+
"text/plain": [
|
| 951 |
+
"[]"
|
| 952 |
+
]
|
| 953 |
+
},
|
| 954 |
+
"execution_count": 88,
|
| 955 |
+
"metadata": {},
|
| 956 |
+
"output_type": "execute_result"
|
| 957 |
+
}
|
| 958 |
+
],
|
| 959 |
+
"source": [
|
| 960 |
+
"df_local_to_aws_dynamodb(\"prompts_agg\",df_prompts_agg)"
|
| 961 |
+
]
|
| 962 |
+
},
|
| 963 |
{
|
| 964 |
"cell_type": "markdown",
|
| 965 |
"metadata": {},
|
|
|
|
| 969 |
},
|
| 970 |
{
|
| 971 |
"cell_type": "code",
|
| 972 |
+
"execution_count": 4,
|
| 973 |
"metadata": {},
|
| 974 |
"outputs": [
|
| 975 |
{
|
|
|
|
| 978 |
"dict_keys(['Checklist', 'Revision', 'terms', 'prompts', 'prompt_agg', 'prompt_sum', 'Overview', 'Overview Command', 'Overview Summary Com.', 'Clinical', 'Clinical Command', 'Clin Summary Com', 'Radiologic', 'Radiologic Command', 'parser_safety', 'Units', 'Notes', 'Rad Summary Com', 'Safety', 'Safety Command', 'Safety Summary Com', 'Other', 'Other Command', 'Oth Summary Com'])"
|
| 979 |
]
|
| 980 |
},
|
| 981 |
+
"execution_count": 4,
|
| 982 |
"metadata": {},
|
| 983 |
"output_type": "execute_result"
|
| 984 |
}
|
|
|
|
| 990 |
"raw.keys()"
|
| 991 |
]
|
| 992 |
},
|
| 993 |
+
{
|
| 994 |
+
"cell_type": "code",
|
| 995 |
+
"execution_count": null,
|
| 996 |
+
"metadata": {},
|
| 997 |
+
"outputs": [],
|
| 998 |
+
"source": []
|
| 999 |
+
},
|
| 1000 |
{
|
| 1001 |
"cell_type": "markdown",
|
| 1002 |
"metadata": {},
|
chains.py
CHANGED
|
@@ -91,7 +91,7 @@ def gen_chat_prompt(prompt,article):
|
|
| 91 |
messages.append(("human",prompt["chain"][i]))
|
| 92 |
else:
|
| 93 |
messages.append(("human",prompt["chain"][0]))
|
| 94 |
-
messages.append(("system",reformat_inst))
|
| 95 |
|
| 96 |
return ChatPromptTemplate.from_messages(messages=messages)
|
| 97 |
|
|
|
|
| 91 |
messages.append(("human",prompt["chain"][i]))
|
| 92 |
else:
|
| 93 |
messages.append(("human",prompt["chain"][0]))
|
| 94 |
+
# messages.append(("system",reformat_inst))
|
| 95 |
|
| 96 |
return ChatPromptTemplate.from_messages(messages=messages)
|
| 97 |
|
features.py
CHANGED
|
@@ -35,10 +35,18 @@ def init_app_data():
|
|
| 35 |
app_data["terms"] = get_table("terms")
|
| 36 |
app_data["articles"] = list_dict_to_dict(get_table("articles"),key="name")
|
| 37 |
app_data["summary"] = list_dict_to_dict(get_table("summary"),key="term")
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
@terminal_print
|
| 43 |
def get_existing_article(
|
| 44 |
article_name,
|
|
@@ -64,6 +72,7 @@ def get_existing_article(
|
|
| 64 |
@terminal_print
|
| 65 |
def process_study( # need revision
|
| 66 |
domain,
|
|
|
|
| 67 |
study_file_obj,
|
| 68 |
study_content,
|
| 69 |
):
|
|
@@ -76,7 +85,7 @@ def process_study( # need revision
|
|
| 76 |
return "No file or content provided","No file or content provided","No file or content provided"
|
| 77 |
|
| 78 |
# update the common article segment from its existing attributes.
|
| 79 |
-
update_article_segment(article)
|
| 80 |
|
| 81 |
# perform pathway logic and content extraction
|
| 82 |
process_prompts(article=article)
|
|
@@ -125,7 +134,7 @@ def create_md_tables(articles):
|
|
| 125 |
return md_text
|
| 126 |
|
| 127 |
@terminal_print
|
| 128 |
-
def update_article_segment(article):
|
| 129 |
# get the key content between article objective and discussion
|
| 130 |
raw_content = article["raw"]
|
| 131 |
index_discussion = raw_content.lower().index("discussion") if "discussion" in raw_content.lower() else len(raw_content)
|
|
@@ -137,7 +146,6 @@ def update_article_segment(article):
|
|
| 137 |
materials_and_methods, next_content = get_key_content(next_content,"methods","results")
|
| 138 |
results, _ = get_key_content(next_content,"results","discussion")
|
| 139 |
|
| 140 |
-
|
| 141 |
# update the article object
|
| 142 |
article.update({
|
| 143 |
"Abstract": abstract,
|
|
@@ -145,6 +153,7 @@ def update_article_segment(article):
|
|
| 145 |
"Material and Methods": materials_and_methods,
|
| 146 |
"Results": results,
|
| 147 |
"Meta Content": meta_content,
|
|
|
|
| 148 |
"tables": ""
|
| 149 |
})
|
| 150 |
|
|
|
|
| 35 |
app_data["terms"] = get_table("terms")
|
| 36 |
app_data["articles"] = list_dict_to_dict(get_table("articles"),key="name")
|
| 37 |
app_data["summary"] = list_dict_to_dict(get_table("summary"),key="term")
|
| 38 |
+
app_data["devices"] = list_dict_to_dict(get_table("devices"),key="device_name")
|
| 39 |
+
# with open(".data/instruction_agg_performance.json","r") as f:
|
| 40 |
+
# prompts_agg_json = json.load(f)
|
| 41 |
+
app_data["prompts_agg"] = list_dict_to_dict(get_table("prompts_agg"),key="assessment")
|
| 42 |
|
| 43 |
+
def get_ifu(device_name="TranscendTM NanoTec™ Interbody System"):
|
| 44 |
+
'''
|
| 45 |
+
This function get the IFU from the cloud S3'''
|
| 46 |
+
ifu = app_data["devices"][device_name]
|
| 47 |
+
text = f"{ifu['contraindications']}\n{ifu['indications']}\n{ifu['intended_use']}"
|
| 48 |
+
return text
|
| 49 |
+
|
| 50 |
@terminal_print
|
| 51 |
def get_existing_article(
|
| 52 |
article_name,
|
|
|
|
| 72 |
@terminal_print
|
| 73 |
def process_study( # need revision
|
| 74 |
domain,
|
| 75 |
+
device_ifu,
|
| 76 |
study_file_obj,
|
| 77 |
study_content,
|
| 78 |
):
|
|
|
|
| 85 |
return "No file or content provided","No file or content provided","No file or content provided"
|
| 86 |
|
| 87 |
# update the common article segment from its existing attributes.
|
| 88 |
+
update_article_segment(article,device_ifu)
|
| 89 |
|
| 90 |
# perform pathway logic and content extraction
|
| 91 |
process_prompts(article=article)
|
|
|
|
| 134 |
return md_text
|
| 135 |
|
| 136 |
@terminal_print
|
| 137 |
+
def update_article_segment(article,device_ifu):
|
| 138 |
# get the key content between article objective and discussion
|
| 139 |
raw_content = article["raw"]
|
| 140 |
index_discussion = raw_content.lower().index("discussion") if "discussion" in raw_content.lower() else len(raw_content)
|
|
|
|
| 146 |
materials_and_methods, next_content = get_key_content(next_content,"methods","results")
|
| 147 |
results, _ = get_key_content(next_content,"results","discussion")
|
| 148 |
|
|
|
|
| 149 |
# update the article object
|
| 150 |
article.update({
|
| 151 |
"Abstract": abstract,
|
|
|
|
| 153 |
"Material and Methods": materials_and_methods,
|
| 154 |
"Results": results,
|
| 155 |
"Meta Content": meta_content,
|
| 156 |
+
"IFU": get_ifu(device_ifu),
|
| 157 |
"tables": ""
|
| 158 |
})
|
| 159 |
|
ui_study.py
CHANGED
|
@@ -23,16 +23,21 @@ def init_study_page():
|
|
| 23 |
# user control panel
|
| 24 |
with gr.Row(equal_height=False):
|
| 25 |
with gr.Column():
|
| 26 |
-
gr.Markdown("##
|
| 27 |
gr.HTML("<hr>")
|
| 28 |
domain = gr.Radio(label="Anatomical Region",choices=anatomic_domains,value=default_region)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
upload_study = gr.File(label="Upload a clinical study report",type="file",file_count="single")
|
|
|
|
|
|
|
| 30 |
with gr.Row():
|
| 31 |
btn_reset = gr.Button(value="Reset",variant="stop")
|
| 32 |
btn_add_study = gr.Button(value="Add",variant="primary")
|
| 33 |
|
| 34 |
-
with gr.Column():
|
| 35 |
-
input_study = gr.TextArea(label="Or paste a clinical study report content",placeholder="Paste content here...",lines=5)
|
| 36 |
|
| 37 |
|
| 38 |
gr.HTML("<hr>")
|
|
@@ -84,6 +89,7 @@ def init_study_page():
|
|
| 84 |
process_study,
|
| 85 |
inputs=[
|
| 86 |
domain,
|
|
|
|
| 87 |
upload_study,
|
| 88 |
input_study,
|
| 89 |
],
|
|
|
|
| 23 |
# user control panel
|
| 24 |
with gr.Row(equal_height=False):
|
| 25 |
with gr.Column():
|
| 26 |
+
gr.Markdown("## Settings")
|
| 27 |
gr.HTML("<hr>")
|
| 28 |
domain = gr.Radio(label="Anatomical Region",choices=anatomic_domains,value=default_region)
|
| 29 |
+
select_ifu = gr.Dropdown(label="Select an IFU",choices=app_data["devices"].keys(),value=list(app_data["devices"].keys())[0])
|
| 30 |
+
|
| 31 |
+
with gr.Column():
|
| 32 |
+
gr.Markdown("## Upload")
|
| 33 |
+
gr.HTML("<hr>")
|
| 34 |
upload_study = gr.File(label="Upload a clinical study report",type="file",file_count="single")
|
| 35 |
+
input_study = gr.TextArea(label="Or paste a clinical study report content",placeholder="Paste content here...",lines=5)
|
| 36 |
+
|
| 37 |
with gr.Row():
|
| 38 |
btn_reset = gr.Button(value="Reset",variant="stop")
|
| 39 |
btn_add_study = gr.Button(value="Add",variant="primary")
|
| 40 |
|
|
|
|
|
|
|
| 41 |
|
| 42 |
|
| 43 |
gr.HTML("<hr>")
|
|
|
|
| 89 |
process_study,
|
| 90 |
inputs=[
|
| 91 |
domain,
|
| 92 |
+
select_ifu,
|
| 93 |
upload_study,
|
| 94 |
input_study,
|
| 95 |
],
|