From 00634ffb4ffb3a49294c90d5ece247ed758e7e14 Mon Sep 17 00:00:00 2001 From: <> Date: Wed, 27 Nov 2024 15:09:49 +0000 Subject: [PATCH] Deployed 261c6d8 with MkDocs version: 1.6.1 --- .nojekyll | 0 404.html | 1921 +++++ api/cda_parser/index.html | 5714 +++++++++++++ api/cds_hooks/index.html | 3791 +++++++++ api/clients/index.html | 3053 +++++++ api/component/index.html | 6851 ++++++++++++++++ api/connectors/index.html | 4025 +++++++++ api/containers/index.html | 7235 +++++++++++++++++ api/data_generators/index.html | 3958 +++++++++ api/data_models/index.html | 3071 +++++++ api/index.html | 1967 +++++ api/pipeline/index.html | 7034 ++++++++++++++++ api/service/index.html | 2370 ++++++ api/use_cases/index.html | 6505 +++++++++++++++ assets/_mkdocstrings.css | 143 + assets/images/favicon.png | Bin 0 -> 1870 bytes assets/images/healthchain_logo.png | Bin 0 -> 373000 bytes assets/images/synthetic_data_ons.png | Bin 0 -> 33429 bytes assets/javascripts/bundle.83f73b43.min.js | 16 + assets/javascripts/bundle.83f73b43.min.js.map | 7 + assets/javascripts/lunr/min/lunr.ar.min.js | 1 + assets/javascripts/lunr/min/lunr.da.min.js | 18 + assets/javascripts/lunr/min/lunr.de.min.js | 18 + assets/javascripts/lunr/min/lunr.du.min.js | 18 + assets/javascripts/lunr/min/lunr.el.min.js | 1 + assets/javascripts/lunr/min/lunr.es.min.js | 18 + assets/javascripts/lunr/min/lunr.fi.min.js | 18 + assets/javascripts/lunr/min/lunr.fr.min.js | 18 + assets/javascripts/lunr/min/lunr.he.min.js | 1 + assets/javascripts/lunr/min/lunr.hi.min.js | 1 + assets/javascripts/lunr/min/lunr.hu.min.js | 18 + assets/javascripts/lunr/min/lunr.hy.min.js | 1 + assets/javascripts/lunr/min/lunr.it.min.js | 18 + assets/javascripts/lunr/min/lunr.ja.min.js | 1 + assets/javascripts/lunr/min/lunr.jp.min.js | 1 + assets/javascripts/lunr/min/lunr.kn.min.js | 1 + assets/javascripts/lunr/min/lunr.ko.min.js | 1 + assets/javascripts/lunr/min/lunr.multi.min.js | 1 + assets/javascripts/lunr/min/lunr.nl.min.js | 18 + assets/javascripts/lunr/min/lunr.no.min.js | 18 + assets/javascripts/lunr/min/lunr.pt.min.js | 18 + assets/javascripts/lunr/min/lunr.ro.min.js | 18 + assets/javascripts/lunr/min/lunr.ru.min.js | 18 + assets/javascripts/lunr/min/lunr.sa.min.js | 1 + .../lunr/min/lunr.stemmer.support.min.js | 1 + assets/javascripts/lunr/min/lunr.sv.min.js | 18 + assets/javascripts/lunr/min/lunr.ta.min.js | 1 + assets/javascripts/lunr/min/lunr.te.min.js | 1 + assets/javascripts/lunr/min/lunr.th.min.js | 1 + assets/javascripts/lunr/min/lunr.tr.min.js | 18 + assets/javascripts/lunr/min/lunr.vi.min.js | 1 + assets/javascripts/lunr/min/lunr.zh.min.js | 1 + assets/javascripts/lunr/tinyseg.js | 206 + assets/javascripts/lunr/wordcut.js | 6708 +++++++++++++++ .../workers/search.6ce7567c.min.js | 42 + .../workers/search.6ce7567c.min.js.map | 7 + assets/stylesheets/main.6f8fc17f.min.css | 1 + assets/stylesheets/main.6f8fc17f.min.css.map | 1 + assets/stylesheets/palette.06af60db.min.css | 1 + .../stylesheets/palette.06af60db.min.css.map | 1 + blog/index.html | 1930 +++++ community/contribution_guide/index.html | 1967 +++++ community/index.html | 2025 +++++ community/resources/index.html | 1965 +++++ cookbook/cds_sandbox/index.html | 2279 ++++++ cookbook/index.html | 1972 +++++ cookbook/notereader_sandbox/index.html | 2000 +++++ distribution/index.html | 1982 +++++ index.html | 2083 +++++ installation/index.html | 1976 +++++ objects.inv | Bin 0 -> 2641 bytes quickstart/index.html | 2412 ++++++ reference/index.html | 1979 +++++ .../components/cdscardcreator/index.html | 2365 ++++++ .../pipeline/components/components/index.html | 2098 +++++ .../connectors/cdaconnector/index.html | 2112 +++++ .../connectors/cdsfhirconnector/index.html | 2105 +++++ .../pipeline/connectors/connectors/index.html | 2145 +++++ reference/pipeline/data_container/index.html | 2165 +++++ .../integrations/integrations/index.html | 2479 ++++++ reference/pipeline/pipeline/index.html | 2507 ++++++ .../medicalcoding/index.html | 1980 +++++ .../summarization/index.html | 1980 +++++ reference/sandbox/client/index.html | 2021 +++++ reference/sandbox/sandbox/index.html | 2039 +++++ reference/sandbox/service/index.html | 2038 +++++ reference/sandbox/use_cases/cds/index.html | 2333 ++++++ .../sandbox/use_cases/clindoc/index.html | 2441 ++++++ .../sandbox/use_cases/use_cases/index.html | 1986 +++++ reference/utilities/cda_parser/index.html | 2191 +++++ reference/utilities/data_generator/index.html | 2184 +++++ search/search_index.json | 1 + sitemap.xml | 3 + sitemap.xml.gz | Bin 0 -> 127 bytes stylesheets/extra.css | 125 + 95 files changed, 128783 insertions(+) create mode 100644 .nojekyll create mode 100644 404.html create mode 100644 api/cda_parser/index.html create mode 100644 api/cds_hooks/index.html create mode 100644 api/clients/index.html create mode 100644 api/component/index.html create mode 100644 api/connectors/index.html create mode 100644 api/containers/index.html create mode 100644 api/data_generators/index.html create mode 100644 api/data_models/index.html create mode 100644 api/index.html create mode 100644 api/pipeline/index.html create mode 100644 api/service/index.html create mode 100644 api/use_cases/index.html create mode 100644 assets/_mkdocstrings.css create mode 100644 assets/images/favicon.png create mode 100644 assets/images/healthchain_logo.png create mode 100644 assets/images/synthetic_data_ons.png create mode 100644 assets/javascripts/bundle.83f73b43.min.js create mode 100644 assets/javascripts/bundle.83f73b43.min.js.map create mode 100644 assets/javascripts/lunr/min/lunr.ar.min.js create mode 100644 assets/javascripts/lunr/min/lunr.da.min.js create mode 100644 assets/javascripts/lunr/min/lunr.de.min.js create mode 100644 assets/javascripts/lunr/min/lunr.du.min.js create mode 100644 assets/javascripts/lunr/min/lunr.el.min.js create mode 100644 assets/javascripts/lunr/min/lunr.es.min.js create mode 100644 assets/javascripts/lunr/min/lunr.fi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.fr.min.js create mode 100644 assets/javascripts/lunr/min/lunr.he.min.js create mode 100644 assets/javascripts/lunr/min/lunr.hi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.hu.min.js create mode 100644 assets/javascripts/lunr/min/lunr.hy.min.js create mode 100644 assets/javascripts/lunr/min/lunr.it.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ja.min.js create mode 100644 assets/javascripts/lunr/min/lunr.jp.min.js create mode 100644 assets/javascripts/lunr/min/lunr.kn.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ko.min.js create mode 100644 assets/javascripts/lunr/min/lunr.multi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.nl.min.js create mode 100644 assets/javascripts/lunr/min/lunr.no.min.js create mode 100644 assets/javascripts/lunr/min/lunr.pt.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ro.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ru.min.js create mode 100644 assets/javascripts/lunr/min/lunr.sa.min.js create mode 100644 assets/javascripts/lunr/min/lunr.stemmer.support.min.js create mode 100644 assets/javascripts/lunr/min/lunr.sv.min.js create mode 100644 assets/javascripts/lunr/min/lunr.ta.min.js create mode 100644 assets/javascripts/lunr/min/lunr.te.min.js create mode 100644 assets/javascripts/lunr/min/lunr.th.min.js create mode 100644 assets/javascripts/lunr/min/lunr.tr.min.js create mode 100644 assets/javascripts/lunr/min/lunr.vi.min.js create mode 100644 assets/javascripts/lunr/min/lunr.zh.min.js create mode 100644 assets/javascripts/lunr/tinyseg.js create mode 100644 assets/javascripts/lunr/wordcut.js create mode 100644 assets/javascripts/workers/search.6ce7567c.min.js create mode 100644 assets/javascripts/workers/search.6ce7567c.min.js.map create mode 100644 assets/stylesheets/main.6f8fc17f.min.css create mode 100644 assets/stylesheets/main.6f8fc17f.min.css.map create mode 100644 assets/stylesheets/palette.06af60db.min.css create mode 100644 assets/stylesheets/palette.06af60db.min.css.map create mode 100644 blog/index.html create mode 100644 community/contribution_guide/index.html create mode 100644 community/index.html create mode 100644 community/resources/index.html create mode 100644 cookbook/cds_sandbox/index.html create mode 100644 cookbook/index.html create mode 100644 cookbook/notereader_sandbox/index.html create mode 100644 distribution/index.html create mode 100644 index.html create mode 100644 installation/index.html create mode 100644 objects.inv create mode 100644 quickstart/index.html create mode 100644 reference/index.html create mode 100644 reference/pipeline/components/cdscardcreator/index.html create mode 100644 reference/pipeline/components/components/index.html create mode 100644 reference/pipeline/connectors/cdaconnector/index.html create mode 100644 reference/pipeline/connectors/cdsfhirconnector/index.html create mode 100644 reference/pipeline/connectors/connectors/index.html create mode 100644 reference/pipeline/data_container/index.html create mode 100644 reference/pipeline/integrations/integrations/index.html create mode 100644 reference/pipeline/pipeline/index.html create mode 100644 reference/pipeline/prebuilt_pipelines/medicalcoding/index.html create mode 100644 reference/pipeline/prebuilt_pipelines/summarization/index.html create mode 100644 reference/sandbox/client/index.html create mode 100644 reference/sandbox/sandbox/index.html create mode 100644 reference/sandbox/service/index.html create mode 100644 reference/sandbox/use_cases/cds/index.html create mode 100644 reference/sandbox/use_cases/clindoc/index.html create mode 100644 reference/sandbox/use_cases/use_cases/index.html create mode 100644 reference/utilities/cda_parser/index.html create mode 100644 reference/utilities/data_generator/index.html create mode 100644 search/search_index.json create mode 100644 sitemap.xml create mode 100644 sitemap.xml.gz create mode 100644 stylesheets/extra.css diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/404.html b/404.html new file mode 100644 index 0000000..666efeb --- /dev/null +++ b/404.html @@ -0,0 +1,1921 @@ + + + +
+ + + + + + + + + + + + + + + + + + +CdaAnnotator
+
+
+Annotates a Clinical Document Architecture (CDA) document.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ cda_data
+ |
+
+
+
+ The CDA document data. +
+
+ TYPE:
+ |
+
+ fallback
+ |
+
+
+
+ The fallback value. Defaults to "LLM". +
+
+ TYPE:
+ |
+
ATTRIBUTE | +DESCRIPTION | +
---|---|
clinical_document |
+
+
+
+ The CDA document data. +
+
+ TYPE:
+ |
+
fallback |
+
+
+
+ The fallback value. +
+
+ TYPE:
+ |
+
problem_list |
+
+
+
+ The list of problems extracted from the CDA document. +
+
+ TYPE:
+ |
+
medication_list |
+
+
+
+ The list of medications extracted from the CDA document. +
+
+ TYPE:
+ |
+
allergy_list |
+
+
+
+ The list of allergies extracted from the CDA document. +
+
+ TYPE:
+ |
+
note |
+
+
+
+ The note extracted from the CDA document. +
+
+ TYPE:
+ |
+
METHOD | +DESCRIPTION | +
---|---|
from_dict |
+
+
+
+ Dict): Creates a CdaAnnotator instance from a dictionary. + |
+
from_xml |
+
+
+
+ str): Creates a CdaAnnotator instance from an XML string. + |
+
add_to_problem_list |
+
+
+
+ List[ProblemConcept], overwrite: bool = False) -> None: Adds a list of problem concepts to the problems section. + |
+
export |
+
+
+
+ bool = True) -> str: Exports the CDA document as an XML string. + |
+
healthchain/cda_parser/cdaannotator.py
158 + 159 + 160 + 161 + 162 + 163 + 164 + 165 + 166 + 167 + 168 + 169 + 170 + 171 + 172 + 173 + 174 + 175 + 176 + 177 + 178 + 179 + 180 + 181 + 182 + 183 + 184 + 185 + 186 + 187 + 188 + 189 + 190 + 191 + 192 + 193 + 194 + 195 + 196 + 197 + 198 + 199 + 200 + 201 + 202 + 203 + 204 + 205 + 206 + 207 + 208 + 209 + 210 + 211 + 212 + 213 + 214 + 215 + 216 + 217 + 218 + 219 + 220 + 221 + 222 + 223 + 224 + 225 + 226 + 227 + 228 + 229 + 230 + 231 + 232 + 233 + 234 + 235 + 236 + 237 + 238 + 239 + 240 + 241 + 242 + 243 + 244 + 245 + 246 + 247 + 248 + 249 + 250 + 251 + 252 + 253 + 254 + 255 + 256 + 257 + 258 + 259 + 260 + 261 + 262 + 263 + 264 + 265 + 266 + 267 + 268 + 269 + 270 + 271 + 272 + 273 + 274 + 275 + 276 + 277 + 278 + 279 + 280 + 281 + 282 + 283 + 284 + 285 + 286 + 287 + 288 + 289 + 290 + 291 + 292 + 293 + 294 + 295 + 296 + 297 + 298 + 299 + 300 + 301 + 302 + 303 + 304 + 305 + 306 + 307 + 308 + 309 + 310 + 311 + 312 + 313 + 314 + 315 + 316 + 317 + 318 + 319 + 320 + 321 + 322 + 323 + 324 + 325 + 326 + 327 + 328 + 329 + 330 + 331 + 332 + 333 + 334 + 335 + 336 + 337 + 338 + 339 + 340 + 341 + 342 + 343 + 344 + 345 + 346 + 347 + 348 + 349 + 350 + 351 + 352 + 353 + 354 + 355 + 356 + 357 + 358 + 359 + 360 + 361 + 362 + 363 + 364 + 365 + 366 + 367 + 368 + 369 + 370 + 371 + 372 + 373 + 374 + 375 + 376 + 377 + 378 + 379 + 380 + 381 + 382 + 383 + 384 + 385 + 386 + 387 + 388 + 389 + 390 + 391 + 392 + 393 + 394 + 395 + 396 + 397 + 398 + 399 + 400 + 401 + 402 + 403 + 404 + 405 + 406 + 407 + 408 + 409 + 410 + 411 + 412 + 413 + 414 + 415 + 416 + 417 + 418 + 419 + 420 + 421 + 422 + 423 + 424 + 425 + 426 + 427 + 428 + 429 + 430 + 431 + 432 + 433 + 434 + 435 + 436 + 437 + 438 + 439 + 440 + 441 + 442 + 443 + 444 + 445 + 446 + 447 + 448 + 449 + 450 + 451 + 452 + 453 + 454 + 455 + 456 + 457 + 458 + 459 + 460 + 461 + 462 + 463 + 464 + 465 + 466 + 467 + 468 + 469 + 470 + 471 + 472 + 473 + 474 + 475 + 476 + 477 + 478 + 479 + 480 + 481 + 482 + 483 + 484 + 485 + 486 + 487 + 488 + 489 + 490 + 491 + 492 + 493 + 494 + 495 + 496 + 497 + 498 + 499 + 500 + 501 + 502 + 503 + 504 + 505 + 506 + 507 + 508 + 509 + 510 + 511 + 512 + 513 + 514 + 515 + 516 + 517 + 518 + 519 + 520 + 521 + 522 + 523 + 524 + 525 + 526 + 527 + 528 + 529 + 530 + 531 + 532 + 533 + 534 + 535 + 536 + 537 + 538 + 539 + 540 + 541 + 542 + 543 + 544 + 545 + 546 + 547 + 548 + 549 + 550 + 551 + 552 + 553 + 554 + 555 + 556 + 557 + 558 + 559 + 560 + 561 + 562 + 563 + 564 + 565 + 566 + 567 + 568 + 569 + 570 + 571 + 572 + 573 + 574 + 575 + 576 + 577 + 578 + 579 + 580 + 581 + 582 + 583 + 584 + 585 + 586 + 587 + 588 + 589 + 590 + 591 + 592 + 593 + 594 + 595 + 596 + 597 + 598 + 599 + 600 + 601 + 602 + 603 + 604 + 605 + 606 + 607 + 608 + 609 + 610 + 611 + 612 + 613 + 614 + 615 + 616 + 617 + 618 + 619 + 620 + 621 + 622 + 623 + 624 + 625 + 626 + 627 + 628 + 629 + 630 + 631 + 632 + 633 + 634 + 635 + 636 + 637 + 638 + 639 + 640 + 641 + 642 + 643 + 644 + 645 + 646 + 647 + 648 + 649 + 650 + 651 + 652 + 653 + 654 + 655 + 656 + 657 + 658 + 659 + 660 + 661 + 662 + 663 + 664 + 665 + 666 + 667 + 668 + 669 + 670 + 671 + 672 + 673 + 674 + 675 + 676 + 677 + 678 + 679 + 680 + 681 + 682 + 683 + 684 + 685 + 686 + 687 + 688 + 689 + 690 + 691 + 692 + 693 + 694 + 695 + 696 + 697 + 698 + 699 + 700 + 701 + 702 + 703 + 704 + 705 + 706 + 707 + 708 + 709 + 710 + 711 + 712 + 713 + 714 + 715 + 716 + 717 + 718 + 719 + 720 + 721 + 722 + 723 + 724 + 725 + 726 + 727 + 728 + 729 + 730 + 731 + 732 + 733 + 734 + 735 + 736 + 737 + 738 + 739 + 740 + 741 + 742 + 743 + 744 + 745 + 746 + 747 + 748 + 749 + 750 + 751 + 752 + 753 + 754 + 755 + 756 + 757 + 758 + 759 + 760 + 761 + 762 + 763 + 764 + 765 + 766 + 767 + 768 + 769 + 770 + 771 + 772 + 773 + 774 + 775 + 776 + 777 + 778 + 779 + 780 + 781 + 782 + 783 + 784 + 785 + 786 + 787 + 788 + 789 + 790 + 791 + 792 + 793 + 794 + 795 + 796 + 797 + 798 + 799 + 800 + 801 + 802 + 803 + 804 + 805 + 806 + 807 + 808 + 809 + 810 + 811 + 812 + 813 + 814 + 815 + 816 + 817 + 818 + 819 + 820 + 821 + 822 + 823 + 824 + 825 + 826 + 827 + 828 + 829 + 830 + 831 + 832 + 833 + 834 + 835 + 836 + 837 + 838 + 839 + 840 + 841 + 842 + 843 + 844 + 845 + 846 + 847 + 848 + 849 + 850 + 851 + 852 + 853 + 854 + 855 + 856 + 857 + 858 + 859 + 860 + 861 + 862 + 863 + 864 + 865 + 866 + 867 + 868 + 869 + 870 + 871 + 872 + 873 + 874 + 875 + 876 + 877 + 878 + 879 + 880 + 881 + 882 + 883 + 884 + 885 + 886 + 887 + 888 + 889 + 890 + 891 + 892 + 893 + 894 + 895 + 896 + 897 + 898 + 899 + 900 + 901 + 902 + 903 + 904 + 905 + 906 + 907 + 908 + 909 + 910 + 911 + 912 + 913 + 914 + 915 + 916 + 917 + 918 + 919 + 920 + 921 + 922 + 923 + 924 + 925 + 926 + 927 + 928 + 929 + 930 + 931 + 932 + 933 + 934 + 935 + 936 + 937 + 938 + 939 + 940 + 941 + 942 + 943 + 944 + 945 + 946 + 947 + 948 + 949 + 950 + 951 + 952 + 953 + 954 + 955 + 956 + 957 + 958 + 959 + 960 + 961 + 962 + 963 + 964 + 965 + 966 + 967 + 968 + 969 + 970 + 971 + 972 + 973 + 974 + 975 + 976 + 977 + 978 + 979 + 980 + 981 + 982 + 983 + 984 + 985 + 986 + 987 + 988 + 989 + 990 + 991 + 992 + 993 + 994 + 995 + 996 + 997 + 998 + 999 +1000 +1001 +1002 +1003 +1004 +1005 +1006 +1007 +1008 +1009 +1010 +1011 +1012 +1013 +1014 +1015 +1016 +1017 +1018 +1019 +1020 +1021 +1022 +1023 +1024 +1025 +1026 +1027 +1028 +1029 +1030 +1031 +1032 +1033 +1034 +1035 +1036 +1037 +1038 +1039 +1040 +1041 +1042 +1043 +1044 +1045 +1046 +1047 +1048 +1049 +1050 +1051 +1052 +1053 +1054 +1055 +1056 +1057 +1058 +1059 +1060 +1061 +1062 +1063 +1064 +1065 +1066 +1067 +1068 +1069 +1070 +1071 +1072 +1073 +1074 +1075 +1076 +1077 +1078 +1079 +1080 +1081 +1082 +1083 +1084 +1085 +1086 +1087 +1088 +1089 +1090 +1091 +1092 +1093 +1094 +1095 +1096 +1097 +1098 +1099 +1100 +1101 +1102 +1103 +1104 +1105 +1106 +1107 +1108 +1109 +1110 +1111 +1112 +1113 +1114 +1115 +1116 +1117 +1118 +1119 +1120 +1121 +1122 +1123 +1124 +1125 +1126 +1127 +1128 +1129 +1130 +1131 +1132 +1133 +1134 +1135 +1136 +1137 +1138 +1139 +1140 +1141 +1142 +1143 +1144 +1145 +1146 +1147 +1148 +1149 +1150 +1151 +1152 +1153 +1154 +1155 +1156 +1157 +1158 +1159 +1160 +1161 +1162 +1163 +1164 +1165 +1166 +1167 +1168 +1169 +1170 +1171 +1172 +1173 +1174 +1175 +1176 +1177 +1178 +1179 +1180 +1181 +1182 +1183 +1184 +1185 +1186 +1187 +1188 +1189 +1190 +1191 +1192 +1193 +1194 +1195 +1196 +1197 +1198 +1199 +1200 +1201 |
|
add_to_medication_list(medications, overwrite=False)
+
+Adds medications to the medication list.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ medications
+ |
+
+
+
+ A list of MedicationConcept objects representing the medications to be added. +
+
+ TYPE:
+ |
+
+ overwrite
+ |
+
+
+
+ If True, the existing medication list will be overwritten. Defaults to False. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ None
+
+ |
+
+
+
+ None + |
+
healthchain/cda_parser/cdaannotator.py
add_to_problem_list(problems, overwrite=False)
+
+Adds a list of problem lists to the problems section.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ problems
+ |
+
+
+
+ A list of problem concepts to be added. +
+
+ TYPE:
+ |
+
+ overwrite
+ |
+
+
+
+ If True, the existing problem list will be overwritten. +Defaults to False. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ None
+
+ |
+
+
+
+ None + |
+
healthchain/cda_parser/cdaannotator.py
export(pretty_print=True)
+
+Exports CDA document as an XML string
+ +healthchain/cda_parser/cdaannotator.py
from_dict(data)
+
+
+ classmethod
+
+
+Creates an instance of the class from a dictionary.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ data
+ |
+
+
+
+ The dictionary containing the dictionary representation of the cda xml (using xmltodict.parse). +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ CdaAnnotator
+ |
+
+
+
+ An instance of the class initialized with the data from the dictionary. +
+
+ TYPE:
+ |
+
healthchain/cda_parser/cdaannotator.py
from_xml(data)
+
+
+ classmethod
+
+
+Creates an instance of the CDAAnnotator class from an XML string.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ data
+ |
+
+
+
+ The XML string representing the CDA document. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ CDAAnnotator
+ |
+
+
+
+ An instance of the CDAAnnotator class initialized with the parsed CDA data. +
+
+ TYPE:
+ |
+
healthchain/cda_parser/cdaannotator.py
check_for_entry_observation(entry)
+
+Checks if the given entry contains an observation.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ entry
+ |
+
+
+
+ The entry to check. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ bool
+
+ |
+
+
+
+ True if the entry contains an observation, False otherwise. + |
+
healthchain/cda_parser/cdaannotator.py
check_has_template_id(section, template_id)
+
+Check if the given section has a matching template ID.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ section
+ |
+
+
+
+ The section to check. +
+
+ TYPE:
+ |
+
+ template_id
+ |
+
+
+
+ The template ID to match. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ bool
+
+ |
+
+
+
+ True if the section has a matching template ID, False otherwise. + |
+
healthchain/cda_parser/cdaannotator.py
get_time_range_from_cda_value(value)
+
+Converts a dictionary representing a time range from a CDA value into a Range object.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ value
+ |
+
+
+
+ A dictionary representing the CDA value. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ Range
+ |
+
+
+
+ A Range object representing the time range. +
+
+ TYPE:
+ |
+
healthchain/cda_parser/cdaannotator.py
get_value_from_entry_relationship(entry_relationship)
+
+Retrieves the values from the given entry_relationship.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ entry_relationship
+ |
+
+
+
+ The entry_relationship object to extract values from. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ List
+
+ |
+
+
+
+ A list of values extracted from the entry_relationship. + |
+
healthchain/cda_parser/cdaannotator.py
EncounterDischargeContext
+
+
+
+ Bases: BaseHookContext
Workflow: +This hook is triggered during the discharge process for typically inpatient encounters. It can be invoked +at any point from the start to the end of the discharge process. The purpose is to allow hook services to +intervene in various aspects of the discharge decision. This includes verifying discharge medications, +ensuring continuity of care planning, and verifying necessary documentation for discharge processing.
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
userId |
+
+
+
+ REQUIRED. The ID of the current user, expected to be a Practitioner or PractitionerRole. + For example, 'Practitioner/123'. +
+
+ TYPE:
+ |
+
patientId |
+
+
+
+ REQUIRED. The FHIR Patient.id of the patient being discharged. +
+
+ TYPE:
+ |
+
encounterId |
+
+
+
+ REQUIRED. The FHIR Encounter.id of the encounter being ended. +
+
+ TYPE:
+ |
+
Documentation: https://cds-hooks.org/hooks/encounter-discharge/
+ + + + + + +healthchain/models/hooks/encounterdischarge.py
OrderSelectContext
+
+
+
+ Bases: BaseHookContext
Workflow: The order-select hook occurs after the clinician selects the order and before signing. +This hook occurs when a clinician initially selects one or more new orders from a list of +potential orders for a specific patient (including orders for medications, procedures, labs +and other orders). The newly selected order defines that medication, procedure, lab, etc, +but may or may not define the additional details necessary to finalize the order.
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
userId |
+
+
+
+ REQUIRED. An identifier of the current user, in the format [ResourceType]/[id], + where ResourceType is either 'Practitioner' or 'PractitionerRole'. Examples: 'PractitionerRole/123', + 'Practitioner/abc'. +
+
+ TYPE:
+ |
+
patientId |
+
+
+
+ REQUIRED. The FHIR Patient.id representing the current patient in context. +
+
+ TYPE:
+ |
+
encounterId |
+
+
+
+ OPTIONAL. The FHIR Encounter.id representing the current encounter in context, + if applicable. +
+
+ TYPE:
+ |
+
selections |
+
+
+
+ REQUIRED. A list of the FHIR id(s) of the newly selected orders, referencing resources + in the draftOrders Bundle. Example: 'MedicationRequest/103'. +
+
+ TYPE:
+ |
+
draftOrders |
+
+
+
+ REQUIRED. A Bundle of FHIR request resources with a draft status, representing all unsigned + orders from the current session, including newly selected orders. +
+
+ TYPE:
+ |
+
Documentation: https://cds-hooks.org/hooks/order-select/
+ + + + + + +healthchain/models/hooks/orderselect.py
OrderSignContext
+
+
+
+ Bases: BaseHookContext
Workflow: +The order-sign hook is triggered when a clinician is ready to sign one or more orders for a patient. +This includes orders for medications, procedures, labs, and other orders. It is one of the last workflow +events before an order is promoted from a draft status. The context includes all order details such as +dose, quantity, route, etc., even though the order is still in a draft status. This hook is also applicable +for re-signing revised orders, which may have a status other than 'draft'. The hook replaces the +medication-prescribe and order-review hooks.
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
userId |
+
+
+
+ REQUIRED. The ID of the current user, expected to be of type 'Practitioner' or 'PractitionerRole'. + Examples include 'PractitionerRole/123' or 'Practitioner/abc'. +
+
+ TYPE:
+ |
+
patientId |
+
+
+
+ REQUIRED. The FHIR Patient.id representing the current patient in context. +
+
+ TYPE:
+ |
+
encounterId |
+
+
+
+ OPTIONAL. The FHIR Encounter.id of the current encounter in context. +
+
+ TYPE:
+ |
+
draftOrders |
+
+
+
+ REQUIRED. A Bundle of FHIR request resources with a draft status, representing orders that + aren't yet signed from the current ordering session. +
+
+ TYPE:
+ |
+
Documentation: https://cds-hooks.org/hooks/order-sign/
+ + + + + + +healthchain/models/hooks/ordersign.py
PatientViewContext
+
+
+
+ Bases: BaseHookContext
Workflow: The user has just opened a patient's record; typically called only once at the beginning of a user's +interaction with a specific patient's record.
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
userId |
+
+
+
+ An identifier of the current user, in the format [ResourceType]/[id], + where ResourceType is one of 'Practitioner', 'PractitionerRole', 'Patient', + or 'RelatedPerson'. Examples: 'Practitioner/abc', 'Patient/123'. +
+
+ TYPE:
+ |
+
patientId |
+
+
+
+ The FHIR Patient.id representing the current patient in context. +
+
+ TYPE:
+ |
+
encounterId |
+
+
+
+ The FHIR Encounter.id representing the current encounter in context, + if applicable. This field is optional. +
+
+ TYPE:
+ |
+
Documentation: https://cds-hooks.org/hooks/patient-view/
+ + + + + + +healthchain/models/hooks/patientview.py
https://cds-hooks.org/specification/current/#discovery
+ + + + + + + + +CDSService
+
+
+
+ Bases: BaseModel
A model representing a CDS service configuration.
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
hook |
+
+
+
+ The hook this service should be invoked on. This should correspond to one of the predefined hooks. +
+
+ TYPE:
+ |
+
title |
+
+
+
+ The human-friendly name of this service. It is recommended to provide this for better usability. +
+
+ TYPE:
+ |
+
description |
+
+
+
+ A detailed description of what this service does and its purpose within the CDS framework. +
+
+ TYPE:
+ |
+
id |
+
+
+
+ The unique identifier of this service. It forms part of the URL as {baseUrl}/cds-services/{id}. +
+
+ TYPE:
+ |
+
prefetch |
+
+
+
+ Optional FHIR queries that the service requests the CDS Client to perform + and provide on each service call. Keys describe the type of data and values are the actual FHIR query strings. +
+
+ TYPE:
+ |
+
usageRequirements |
+
+
+
+ Human-friendly description of any preconditions for the use of this CDS service. +
+
+ TYPE:
+ |
+
Documentation: https://cds-hooks.org/specification/current/#response
+ + + + + + +healthchain/models/responses/cdsdiscovery.py
CDSServiceInformation
+
+
+
+ Bases: BaseModel
A CDS Service is discoverable via a stable endpoint by CDS Clients. The Discovery endpoint includes information such as a +description of the CDS Service, when it should be invoked, and any data that is requested to be prefetched.
+ + + + + + +healthchain/models/responses/cdsdiscovery.py
This is not compulsary
+https://cds-hooks.org/specification/current/#feedback
+ + + + + + + + +CDSFeedback
+
+
+
+ Bases: BaseModel
A feedback endpoint enables suggestion tracking & analytics. +A CDS Service MAY support a feedback endpoint; a CDS Client SHOULD be capable of sending feedback.
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
card |
+
+
+
+ The card.uuid from the CDS Hooks response. Uniquely identifies the card. +
+
+ TYPE:
+ |
+
outcome |
+
+
+
+ The outcome of the action, either 'accepted' or 'overridden'. +
+
+ TYPE:
+ |
+
acceptedSuggestions |
+
+
+
+ An array of accepted suggestions, required if the outcome is 'accepted'. +
+
+ TYPE:
+ |
+
overrideReason |
+
+
+
+ The reason for overriding, including any coding and comments. +
+
+ TYPE:
+ |
+
outcomeTimestamp |
+
+
+
+ The ISO8601 timestamp of when the action was taken on the card. +
+
+ TYPE:
+ |
+
Documentation: https://cds-hooks.org/specification/current/#feedback
+ + + + + + +healthchain/models/responses/cdsfeedback.py
EHRClient
+
+
+
+ Bases: BaseClient
healthchain/clients/ehrclient.py
100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 |
|
__init__(func, workflow, strategy, timeout=10.0)
+
+Initializes the EHRClient with a data generator function and optional workflow and use case. +Should be a subclass of BaseUseCase. Example - ClinicalDecisionSupport()
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ func
+ |
+
+
+
+ A function to generate data for requests. +
+
+ TYPE:
+ |
+
+ workflow
+ |
+
+
+
+ The workflow context to apply to the data generator. +
+
+ TYPE:
+ |
+
+ strategy
+ |
+
+
+
+ The strategy object to construct requests based on the generated data. +
+
+ TYPE:
+ |
+
+ timeout
+ |
+
+
+
+ The maximum time in seconds to wait for a response from the server. This parameter determines how long the client will wait before considering a request timed out. +
+
+ TYPE:
+ |
+
healthchain/clients/ehrclient.py
generate_request(*args, **kwargs)
+
+Generates a request using the data produced by the data generator function, +and appends it to the internal request queue.
+Parameters:
+ *args (Any): Positional arguments passed to the data generator function.
+ **kwargs (Any): Keyword arguments passed to the data generator function.
+
+Raises:
+ ValueError: If the use case is not configured.
+
healthchain/clients/ehrclient.py
send_request(url)
+
+
+ async
+
+
+Sends all queued requests to the specified URL and collects the responses.
+Parameters:
+ url (str): The URL to which the requests will be sent.
+Returns:
+ List[dict]: A list of JSON responses from the server.
+Notes:
+ This method logs errors rather than raising them, to avoid interrupting the batch processing of requests.
+
healthchain/clients/ehrclient.py
ehr(func=None, *, workflow, num=1)
+
+A decorator that wraps around a data generator function and returns an EHRClient
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ func
+ |
+
+
+
+ The function to be decorated. If None, this allows the decorator to + be used with arguments. +
+
+ TYPE:
+ |
+
+ workflow
+ |
+
+
+
+ The workflow identifier which should match an item in the Workflow enum. + This specifies the context in which the EHR function will operate. +
+
+ TYPE:
+ |
+
+ num
+ |
+
+
+
+ The number of requests to generate in the queue; defaults to 1. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ Callable
+ |
+
+
+
+ A decorated callable that incorporates EHR functionality or the decorator itself + if 'func' is None, allowing it to be used as a parameterized decorator. +
+
+ TYPE:
+ |
+
RAISES | +DESCRIPTION | +
---|---|
+
+ ValueError
+
+ |
+
+
+
+ If the workflow does not correspond to any defined enum or if use case is not configured. + |
+
+
+ NotImplementedError
+
+ |
+
+
+
+ If the use case class is not one of the supported types. + |
+
@ehr(workflow='patient-view', num=2) +def generate_data(self, config): + # Function implementation
+healthchain/clients/ehrclient.py
20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 |
|
BaseComponent
+
+
+
+ Bases: Generic[T]
, ABC
Abstract base class for all components in the pipeline.
+This class should be subclassed to create specific components. +Subclasses must implement the call method.
+ + + + + + +healthchain/pipeline/components/base.py
__call__(data)
+
+
+ abstractmethod
+
+
+Process the input data and return the processed data.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ data
+ |
+
+
+
+ The input data to be processed. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ DataContainer[T]
+
+ |
+
+
+
+ DataContainer[T]: The processed data. + |
+
healthchain/pipeline/components/base.py
Component
+
+
+
+ Bases: BaseComponent[T]
A concrete implementation of the BaseComponent class.
+This class can be used as a base for creating specific components +that do not require any additional processing logic.
+ + +METHOD | +DESCRIPTION | +
---|---|
__call__ |
+
+
+
+ DataContainer[T]) -> DataContainer[T]: +Process the input data and return the processed data. +In this implementation, the input data is returned unmodified. + |
+
healthchain/pipeline/components/base.py
HFTransformer
+
+
+
+ Bases: BaseComponent[str]
A component that integrates Hugging Face transformers models into the pipeline.
+This component allows using any Hugging Face model and task within the pipeline +by wrapping the transformers.pipeline API. The model outputs are stored in the +document's model_outputs container under the "huggingface" source key.
+Note that this component is only recommended for non-conversational language tasks. +For chat-based tasks, consider using LangChainLLM instead.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ pipeline
+ |
+
+
+
+ A pre-configured HuggingFace pipeline object to use for inference. +Must be an instance of transformers.pipelines.base.Pipeline. +
+
+ TYPE:
+ |
+
ATTRIBUTE | +DESCRIPTION | +
---|---|
task |
+
+
+
+ The task name of the underlying pipeline, e.g. "sentiment-analysis", "ner". +Automatically extracted from the pipeline object. +
+
+ TYPE:
+ |
+
RAISES | +DESCRIPTION | +
---|---|
+
+ ImportError
+
+ |
+
+
+
+ If the transformers package is not installed + |
+
+
+ TypeError
+
+ |
+
+
+
+ If pipeline is not a valid HuggingFace Pipeline instance + |
+
++++++Initialize for sentiment analysis
+from transformers import pipeline +nlp = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english") +component = HFTransformer(pipeline=nlp) +doc = component(doc) # Analyzes sentiment of doc.data
+Or use the factory method
+component = HFTransformer.from_model_id( +... model="facebook/bart-large-cnn", +... task="summarization", +... max_length=130, +... min_length=30, +... do_sample=False +... ) +doc = component(doc) # Generates summary of doc.data
+
healthchain/pipeline/components/integrations.py
136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 |
|
__call__(doc)
+
+Process the document using the Hugging Face pipeline. Adds outputs to .model_outputs['huggingface'].
+ +healthchain/pipeline/components/integrations.py
__init__(pipeline)
+
+Initialize with a pre-configured HuggingFace pipeline.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ pipeline
+ |
+
+
+
+ A pre-configured HuggingFace pipeline object from transformers.pipeline(). + Must be an instance of transformers.pipelines.base.Pipeline. +
+
+ TYPE:
+ |
+
RAISES | +DESCRIPTION | +
---|---|
+
+ ImportError
+
+ |
+
+
+
+ If transformers package is not installed + |
+
+
+ TypeError
+
+ |
+
+
+
+ If pipeline is not a valid HuggingFace Pipeline instance + |
+
healthchain/pipeline/components/integrations.py
from_model_id(model, task, **kwargs)
+
+
+ classmethod
+
+
+Create a transformer component from a model identifier.
+Factory method that initializes a HuggingFace pipeline with the specified model and task, +then wraps it in a HFTransformer component.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ model
+ |
+
+
+
+ The model identifier or path to load. Can be: +- A model ID from the HuggingFace Hub (e.g. "bert-base-uncased") +- A local path to a saved model +
+
+ TYPE:
+ |
+
+ task
+ |
+
+
+
+ The task to run (e.g. "text-classification", "token-classification", "summarization") +
+
+ TYPE:
+ |
+
+ **kwargs
+ |
+
+
+
+ Additional configuration options passed to transformers.pipeline() +Common options include: +- device: Device to run on ("cpu", "cuda", etc.) +- batch_size: Batch size for inference +- model_kwargs: Dict of model-specific args +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ HFTransformer
+ |
+
+
+
+ Initialized transformer component wrapping the pipeline +
+
+ TYPE:
+ |
+
RAISES | +DESCRIPTION | +
---|---|
+
+ TypeError
+
+ |
+
+
+
+ If invalid kwargs are passed to pipeline initialization + |
+
+
+ ValueError
+
+ |
+
+
+
+ If pipeline initialization fails for any other reason + |
+
+
+ ImportError
+
+ |
+
+
+
+ If transformers package is not installed + |
+
healthchain/pipeline/components/integrations.py
LangChainLLM
+
+
+
+ Bases: BaseComponent[str]
A component that integrates LangChain chains into the pipeline.
+This component allows using any LangChain chain within the pipeline by wrapping +the chain's invoke method. The chain outputs are stored in the document's +model_outputs container under the "langchain" source key.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ chain
+ |
+
+
+
+ The LangChain chain to run on the document text. +Must be a Runnable object from the LangChain library. +
+
+ TYPE:
+ |
+
+ task
+ |
+
+
+
+ The task name to use when storing outputs, e.g. "summarization", "chat". +Used as key to organize model outputs in the document's model container. +
+
+ TYPE:
+ |
+
+ **kwargs
+ |
+
+
+
+ Additional parameters to pass to the chain's invoke method. +These are forwarded directly to the chain's invoke() call. +
+
+ TYPE:
+ |
+
RAISES | +DESCRIPTION | +
---|---|
+
+ TypeError
+
+ |
+
+
+
+ If chain is not a LangChain Runnable object or if invalid kwargs are passed + |
+
+
+ ValueError
+
+ |
+
+
+
+ If there is an error during chain invocation + |
+
+
+ ImportError
+
+ |
+
+
+
+ If langchain-core package is not installed + |
+
++++++from langchain_core.prompts import ChatPromptTemplate +from langchain_openai import ChatOpenAI
+chain = ChatPromptTemplate.from_template("What is {input}?") | ChatOpenAI() +component = LangChainLLM(chain=chain, task="chat") +doc = component(doc) # Runs the chain on doc.data and stores output
+
healthchain/pipeline/components/integrations.py
__call__(doc)
+
+Process the document using the LangChain chain. Adds outputs to .model_outputs['langchain'].
+ +healthchain/pipeline/components/integrations.py
__init__(chain, task, **kwargs)
+
+Initialize with a LangChain chain.
+ +healthchain/pipeline/components/integrations.py
SpacyNLP
+
+
+
+ Bases: BaseComponent[str]
A component that integrates spaCy models into the pipeline.
+This component allows using any spaCy model within the pipeline by loading +and applying it to process text documents. The spaCy doc outputs are stored +in the document's nlp annotations container under .spacy_docs.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ nlp
+ |
+
+
+
+ A pre-configured spaCy Language object. +
+
+ TYPE:
+ |
+
++++++Using pre-configured pipeline
+import spacy +nlp = spacy.load("en_core_web_sm", disable=["parser"]) +component = SpacyNLP(nlp) +doc = component(doc)
+Or using model name
+component = SpacyNLP.from_model_id("en_core_web_sm", disable=["parser"]) +doc = component(doc)
+
healthchain/pipeline/components/integrations.py
38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 |
|
__call__(doc)
+
+Process the document using the spaCy pipeline. Adds outputs to nlp.spacy_docs.
+ +healthchain/pipeline/components/integrations.py
__init__(nlp)
+
+from_model_id(model, **kwargs)
+
+
+ classmethod
+
+
+Create a SpacyNLP component from a model identifier.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ model
+ |
+
+
+
+ The name or path of the spaCy model to load. +Can be a model name like 'en_core_web_sm' or path to saved model. +
+
+ TYPE:
+ |
+
+ **kwargs
+ |
+
+
+
+ Additional configuration options passed to spacy.load. +Common options include disable, exclude, enable. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ SpacyNLP
+ |
+
+
+
+ Initialized spaCy component +
+
+ TYPE:
+ |
+
RAISES | +DESCRIPTION | +
---|---|
+
+ ImportError
+
+ |
+
+
+
+ If spaCy or the specified model is not installed + |
+
+
+ TypeError
+
+ |
+
+
+
+ If invalid kwargs are passed to spacy.load + |
+
healthchain/pipeline/components/integrations.py
requires_package(package_name, import_path)
+
+Decorator to check if an optional package is available.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ package_name
+ |
+
+
+
+ Name of the package to install (e.g., 'langchain-core') +
+
+ TYPE:
+ |
+
+ import_path
+ |
+
+
+
+ Import path to check (e.g., 'langchain_core.runnables') +
+
+ TYPE:
+ |
+
healthchain/pipeline/components/integrations.py
TextPreProcessor
+
+
+
+ Bases: BaseComponent[Document]
A component for preprocessing text documents.
+This class applies various cleaning and tokenization steps to a Document object, +based on the provided configuration.
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
tokenizer |
+
+
+
+ The tokenizer to use. Can be "basic" or a custom +tokenization function that takes a string and returns a list of tokens. Defaults to "basic". +
+
+ TYPE:
+ |
+
lowercase |
+
+
+
+ Whether to convert text to lowercase. Defaults to False. +
+
+ TYPE:
+ |
+
remove_punctuation |
+
+
+
+ Whether to remove punctuation. Defaults to False. +
+
+ TYPE:
+ |
+
standardize_spaces |
+
+
+
+ Whether to standardize spaces. Defaults to False. +
+
+ TYPE:
+ |
+
regex |
+
+
+
+ List of regex patterns and replacements. Defaults to an empty list. +
+
+ TYPE:
+ |
+
tokenizer_func |
+
+
+
+ The tokenization function. +
+
+ TYPE:
+ |
+
cleaning_steps |
+
+
+
+ List of text cleaning functions. +
+
+ TYPE:
+ |
+
healthchain/pipeline/components/preprocessors.py
9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 |
|
__call__(doc)
+
+Preprocess the given Document.
+This method applies the configured cleaning steps and tokenization to the document's text (in that order).
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ doc
+ |
+
+
+
+ The document to preprocess. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ Document
+ |
+
+
+
+ The preprocessed document with updated tokens and preprocessed text. +
+
+ TYPE:
+ |
+
healthchain/pipeline/components/preprocessors.py
__init__(tokenizer='basic', lowercase=False, remove_punctuation=False, standardize_spaces=False, regex=None)
+
+Initialize the TextPreprocessor with the given configuration.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ tokenizer
+ |
+
+
+
+ The tokenizer to use. Can be "basic" or a custom +tokenization function that takes a string and returns a list of tokens. Defaults to "basic". +
+
+ TYPE:
+ |
+
+ lowercase
+ |
+
+
+
+ Whether to convert text to lowercase. Defaults to False. +
+
+ TYPE:
+ |
+
+ remove_punctuation
+ |
+
+
+
+ Whether to remove punctuation. Defaults to False. +
+
+ TYPE:
+ |
+
+ standardize_spaces
+ |
+
+
+
+ Whether to standardize spaces. Defaults to False. +
+
+ TYPE:
+ |
+
+ regex
+ |
+
+
+
+ List of regex patterns and replacements. Defaults to None. +
+
+ TYPE:
+ |
+
healthchain/pipeline/components/preprocessors.py
TextPostProcessor
+
+
+
+ Bases: BaseComponent[Document]
A component for post-processing text documents, specifically for refining entities.
+This class applies post-coordination rules to entities in a Document object, +replacing entities with their refined versions based on a lookup dictionary.
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
entity_lookup |
+
+
+
+ A dictionary for entity refinement lookups. +
+
+ TYPE:
+ |
+
healthchain/pipeline/components/postprocessors.py
__call__(doc)
+
+Apply post-processing to the given Document.
+This method refines the entities in the document based on the entity_lookup. +If an entity exists in the lookup, it is replaced with its refined version.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ doc
+ |
+
+
+
+ The document to be post-processed. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ Document
+ |
+
+
+
+ The post-processed document with refined entities. +
+
+ TYPE:
+ |
+
If the entity_lookup is empty or the document has no 'entities' attribute, +the document is returned unchanged.
+healthchain/pipeline/components/postprocessors.py
__init__(postcoordination_lookup=None)
+
+Initialize the TextPostProcessor with an optional postcoordination lookup.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ postcoordination_lookup
+ |
+
+
+
+ A dictionary for entity refinement lookups. +If not provided, an empty dictionary will be used. +
+
+ TYPE:
+ |
+
healthchain/pipeline/components/postprocessors.py
CdsCardCreator
+
+
+
+ Bases: BaseComponent[str]
Component that creates CDS Hooks cards from model outputs or static content.
+
+This component formats text into CDS Hooks cards that can be displayed in an EHR system.
+It can create cards from either:
+1. Model-generated text stored in a document's model outputs container
+2. Static content provided during initialization
+
+The component uses Jinja2 templates to format the text into valid CDS Hooks card JSON.
+The generated cards are added to the document's CDS container.
+
+Args:
+ template (str, optional): Jinja2 template string for card creation. If not provided,
+ uses a default template that creates an info card.
+ template_path (Union[str, Path], optional): Path to a Jinja2 template file.
+ static_content (str, optional): Static text to use instead of model output.
+ source (str, optional): Source framework to get model output from (e.g. "huggingface").
+ task (str, optional): Task name to get model output from (e.g. "summarization").
+ delimiter (str, optional): String to split model output into multiple cards.
+ default_source (Dict[str, Any], optional): Default source info for cards.
+ Defaults to {"label": "Card Generated by HealthChain"}.
+
+Example:
+ >>> # Create cards from model output
+ >>> creator = CdsCardCreator(source="huggingface", task="summarization")
+ >>> doc = creator(doc) # Creates cards from model output
+ >>>
+ >>> # Create cards with static content
+ >>> creator = CdsCardCreator(static_content="Static card message")
+ >>> doc = creator(doc) # Creates card with static content
+ >>>
+ >>> # Create cards with custom template
+ >>> template = '''
+ ... {
+ ... "summary": "{{ model_output[:140] }}",
+ ... "indicator": "info",
+ ... "source": {{ default_source | tojson }},
+ ... "detail": "{{ model_output }}"
+ ... }
+ ... '''
+ >>> creator = CdsCardCreator(
+ ... template=template,
+ ... source="langchain",
+ ... task="chat",
+ ... delimiter="
+
" + ... ) + >>> doc = creator(doc) # Creates cards split by newlines
+ + + + + + +healthchain/pipeline/components/cdscardcreator.py
15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 |
|
__call__(doc)
+
+Process a document and create CDS Hooks cards from model outputs or static content.
+Creates cards in one of two ways: +1. From model-generated text stored in the document's model outputs container, + accessed using the configured source and task +2. From static content provided during initialization
+The generated text can optionally be split into multiple cards using a delimiter. +Each piece of text is formatted using the configured template into a CDS Hooks card +and added to the document's CDS container.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ doc
+ |
+
+
+
+ Document containing model outputs and CDS container +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ Document
+ |
+
+
+
+ The input document with generated CDS cards added to its CDS container +
+
+ TYPE:
+ |
+
RAISES | +DESCRIPTION | +
---|---|
+
+ ValueError
+
+ |
+
+
+
+ If neither model configuration (source and task) nor static content +is provided for card creation + |
+
healthchain/pipeline/components/cdscardcreator.py
create_card(content)
+
+Creates a CDS Card using the template and model output.
+ +healthchain/pipeline/components/cdscardcreator.py
BaseConnector
+
+
+
+ Bases: Generic[T]
, ABC
Abstract base class for all connectors in the pipeline.
+This class should be subclassed to create specific connectors. +Subclasses must implement the input and output methods.
+ + + + + + +healthchain/io/base.py
input(data)
+
+
+ abstractmethod
+
+
+Convert input data to the pipeline's internal format.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ data
+ |
+
+
+
+ The input data to be converted. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ DataContainer[T]
+
+ |
+
+
+
+ DataContainer[T]: The converted data. + |
+
healthchain/io/base.py
output(data)
+
+
+ abstractmethod
+
+
+Convert pipeline's internal format to output data.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ data
+ |
+
+
+
+ The data to be converted for output. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ DataContainer[T]
+
+ |
+
+
+
+ DataContainer[T]: The converted output data. + |
+
healthchain/io/base.py
CdaConnector
+
+
+
+ Bases: BaseConnector
CDAConnector class for handling CDA (Clinical Document Architecture) documents.
+This connector is responsible for parsing CDA documents, extracting relevant +clinical data, and updating the document with new information. It serves as +both an input and output connector in the pipeline.
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
overwrite |
+
+
+
+ Flag to determine if existing data should be overwritten + when updating the CDA document. +
+
+ TYPE:
+ |
+
cda_doc |
+
+
+
+ The parsed CDA document. +
+
+ TYPE:
+ |
+
METHOD | +DESCRIPTION | +
---|---|
input |
+
+
+
+ Parses the input CDA document and extracts clinical data. + |
+
output |
+
+
+
+ Updates the CDA document with new data and returns the response. + |
+
healthchain/io/cdaconnector.py
13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 |
|
input(in_data)
+
+Parse the input CDA document and extract clinical data.
+This method takes a CdaRequest object containing the CDA document as input, +parses it using the CdaAnnotator, and extracts relevant clinical data. +The extracted data is then used to create a CcdData object and a healthchain +Document object, which is returned.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ in_data
+ |
+
+
+
+ The input request containing the CDA document. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ Document
+ |
+
+
+
+ A Document object containing the extracted clinical data + and the original note text. +
+
+ TYPE:
+ |
+
healthchain/io/cdaconnector.py
output(out_data)
+
+Update the CDA document with new data and return the response.
+This method takes a Document object containing updated clinical data, +updates the CDA document with this new information, and returns a +CdaResponse object with the updated CDA document.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ out_data
+ |
+
+
+
+ A Document object containing the updated + clinical data (problems, allergies, medications). +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ CdaResponse
+ |
+
+
+
+ A response object containing the updated CDA document. +
+
+ TYPE:
+ |
+
The method updates the CDA document with new problems, allergies,
+and medications if they are present in the input Document object.
+The update behavior (overwrite or append) is determined by the
+overwrite
attribute of the CdaConnector instance.
healthchain/io/cdaconnector.py
CdsFhirConnector
+
+
+
+ Bases: BaseConnector
CdsFhirConnector class for handling FHIR (Fast Healthcare Interoperability Resources) documents +for CDS Hooks.
+This connector facilitates the conversion between CDSRequest objects and Document objects, +as well as the creation of CDSResponse objects from processed Documents.
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
hook_name |
+
+
+
+ The name of the CDS Hook being used. +
+
+ TYPE:
+ |
+
healthchain/io/cdsfhirconnector.py
13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 |
|
input(in_data)
+
+Converts a CDSRequest object into a Document object containing FHIR resources.
+This method takes a CDSRequest object as input, extracts the context and prefetch data, +and creates a CdsFhirData object. It then returns a Document object containing the FHIR data +and any extracted text content from DocumentReference resources.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ in_data
+ |
+
+
+
+ The input CDSRequest object containing context and prefetch data. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ Document
+ |
+
+
+
+ A Document object with the following attributes: +- data: Either a string representation of the prefetch data, or if a DocumentReference + is present, the text content from that resource +- hl7: Contains the CdsFhirData object with context and prefetch data +
+
+ TYPE:
+ |
+
RAISES | +DESCRIPTION | +
---|---|
+
+ ValueError
+
+ |
+
+
+
+ If neither prefetch nor fhirServer is provided in the input data + |
+
+
+ NotImplementedError
+
+ |
+
+
+
+ If fhirServer is provided (not yet implemented) + |
+
+
+ ValueError
+
+ |
+
+
+
+ If the provided prefetch data is invalid + |
+
The method currently only supports prefetch data and does not handle FHIR server interactions. +When a DocumentReference resource is present in the prefetch data, its text content will be +extracted and stored as the Document's data field.
+healthchain/io/cdsfhirconnector.py
output(out_data)
+
+Generates a CDSResponse object from a processed Document object.
+This method takes a Document object that has been processed and potentially +contains CDS cards and system actions. It creates and returns a CDSResponse +object based on the contents of the Document.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ out_data
+ |
+
+
+
+ A Document object potentially containing CDS cards + and system actions. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ CDSResponse
+ |
+
+
+
+ A response object containing CDS cards and optional system actions. + If no cards are found in the Document, an empty list of cards is returned. +
+
+ TYPE:
+ |
+
healthchain/io/cdsfhirconnector.py
BaseDocument
+
+
+
+ dataclass
+
+
+
+ Bases: DataContainer[str]
Base document container for raw text content.
+ + + + + + +healthchain/io/containers/base.py
DataContainer
+
+
+
+ dataclass
+
+
+
+ Bases: Generic[T]
A generic container for data.
+This class represents a container for data with a specific type T.
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
data |
+
+
+
+ The data stored in the container. +
+
+ TYPE:
+ |
+
METHOD | +DESCRIPTION | +
---|---|
to_dict |
+
+
+
+ Converts the container's data to a dictionary. + |
+
to_json |
+
+
+
+ Converts the container's data to a JSON string. + |
+
from_dict |
+
+
+
+ Dict[str, Any]) -> "DataContainer": +Creates a DataContainer instance from a dictionary. + |
+
from_json |
+
+
+
+ str) -> "DataContainer": +Creates a DataContainer instance from a JSON string. + |
+
healthchain/io/containers/base.py
Document
+
+
+
+ dataclass
+
+
+
+ Bases: BaseDocument
A document container that extends BaseDocument with rich annotation capabilities.
+This class extends BaseDocument to handle textual document data and annotations from +various sources. It serves as the main data structure passed through processing pipelines, +accumulating annotations and analysis results at each step.
+The Document class provides a comprehensive representation that can include: +- Raw text and basic tokenization +- NLP annotations (tokens, entities, embeddings, spaCy docs) +- Clinical concepts (problems, medications, allergies) +- Structured clinical documents (CCD, FHIR) +- Clinical decision support results (cards, actions) +- ML model outputs (Hugging Face, LangChain)
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
nlp |
+
+
+
+ Container for NLP-related annotations like tokens and entities +
+
+ TYPE:
+ |
+
concepts |
+
+
+
+ Container for extracted medical concepts +
+
+ TYPE:
+ |
+
hl7 |
+
+
+
+ Container for structured clinical documents (CCD, FHIR) +
+
+ TYPE:
+ |
+
cds |
+
+
+
+ Container for clinical decision support results +
+
+ TYPE:
+ |
+
models |
+
+
+
+ Container for ML model outputs +
+
+ TYPE:
+ |
+
The class provides methods to: +- Add and access medical concepts +- Generate structured clinical documents +- Get basic text statistics +- Iterate over tokens +- Access raw text
+ + +BaseDocument: Provides base document functionality and raw text storage
+healthchain/io/containers/document.py
308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 |
|
__post_init__()
+
+Initialize the document with basic tokenization if needed.
+ +healthchain/io/containers/document.py
add_concepts(problems=None, medications=None, allergies=None)
+
+Add extracted medical concepts to the document.
+This method adds medical concepts (problems, medications, allergies) to their +respective lists in the document's concepts container. Each concept type is +optional and will only be added if provided.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ problems
+ |
+
+
+
+ List of medical problems/conditions +to add to the document. Defaults to None. +
+
+ TYPE:
+ |
+
+ medications
+ |
+
+
+
+ List of medications +to add to the document. Defaults to None. +
+
+ TYPE:
+ |
+
+ allergies
+ |
+
+
+
+ List of allergies +to add to the document. Defaults to None. +
+
+ TYPE:
+ |
+
++++++doc.add_concepts( +... problems=[ProblemConcept(display_name="Hypertension")], +... medications=[MedicationConcept(display_name="Aspirin")] +... )
+
healthchain/io/containers/document.py
generate_ccd(overwrite=False)
+
+Generate a CCD (Continuity of Care Document) from the current medical concepts.
+This method creates or updates a CCD in the hl7 container using the +medical concepts (problems, medications, allergies) currently stored in the document. +The CCD is a standard format for exchanging clinical information.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ overwrite
+ |
+
+
+
+ If True, overwrites any existing CCD data. +If False, merges with existing CCD data. Defaults to False. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ CcdData
+ |
+
+
+
+ The generated CCD data. +
+
+ TYPE:
+ |
+
++++++doc.add_concepts(problems=[ProblemConcept(display_name="Hypertension")]) +doc.generate_ccd() # Creates CCD with the hypertension problem
+
healthchain/io/containers/document.py
Tabular
+
+
+
+ dataclass
+
+
+
+ Bases: DataContainer[DataFrame]
A container for tabular data, wrapping a pandas DataFrame.
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
data |
+
+
+
+ The pandas DataFrame containing the tabular data. +
+
+ TYPE:
+ |
+
METHOD | +DESCRIPTION | +
---|---|
__post_init__ |
+
+
+
+ Validates that the data is a pandas DataFrame. + |
+
columns |
+
+
+
+ Property that returns a list of column names. + |
+
index |
+
+
+
+ Property that returns the DataFrame's index. + |
+
dtypes |
+
+
+
+ Property that returns a dictionary of column names and their data types. + |
+
column_count |
+
+
+
+ Returns the number of columns in the DataFrame. + |
+
row_count |
+
+
+
+ Returns the number of rows in the DataFrame. + |
+
get_dtype |
+
+
+
+ str): Returns the data type of a specific column. + |
+
__iter__ |
+
+
+
+ Returns an iterator over the column names. + |
+
__len__ |
+
+
+
+ Returns the number of rows in the DataFrame. + |
+
describe |
+
+
+
+ Returns a string description of the tabular data. + |
+
remove_column |
+
+
+
+ str): Removes a column from the DataFrame. + |
+
from_csv |
+
+
+
+ str, **kwargs): Class method to create a Tabular object from a CSV file. + |
+
from_dict |
+
+
+
+ Dict[str, Any]): Class method to create a Tabular object from a dictionary. + |
+
to_csv |
+
+
+
+ str, **kwargs): Saves the DataFrame to a CSV file. + |
+
healthchain/io/containers/tabular.py
base
+
+
+BaseDocument
+
+
+
+ dataclass
+
+
+
+ Bases: DataContainer[str]
Base document container for raw text content.
+ + + + + + +healthchain/io/containers/base.py
DataContainer
+
+
+
+ dataclass
+
+
+
+ Bases: Generic[T]
A generic container for data.
+This class represents a container for data with a specific type T.
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
data |
+
+
+
+ The data stored in the container. +
+
+ TYPE:
+ |
+
METHOD | +DESCRIPTION | +
---|---|
to_dict |
+
+
+
+ Converts the container's data to a dictionary. + |
+
to_json |
+
+
+
+ Converts the container's data to a JSON string. + |
+
from_dict |
+
+
+
+ Dict[str, Any]) -> "DataContainer": +Creates a DataContainer instance from a dictionary. + |
+
from_json |
+
+
+
+ str) -> "DataContainer": +Creates a DataContainer instance from a JSON string. + |
+
healthchain/io/containers/base.py
document
+
+
+CdsAnnotations
+
+
+
+ dataclass
+
+
+Container for Clinical Decision Support (CDS) results.
+This class stores the outputs from clinical decision support systems, +including CDS Hooks cards and suggested clinical actions. The cards contain +recommendations, warnings, and other decision support content that can be +displayed to clinicians. Actions represent specific clinical tasks or +interventions that are suggested based on the analysis.
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
_cards |
+
+
+
+ Internal storage for CDS Hooks cards containing +clinical recommendations, warnings, or other decision support content. +
+
+ TYPE:
+ |
+
_actions |
+
+
+
+ Internal storage for suggested clinical actions +that could be taken based on the CDS analysis. +
+
+ TYPE:
+ |
+
METHOD | +DESCRIPTION | +
---|---|
set_cards |
+
+
+
+ List[Card]): Sets the list of CDS Hooks cards + |
+
get_cards |
+
+
+
+ Returns the current list of cards if any exist + |
+
set_actions |
+
+
+
+ List[Action]): Sets the list of suggested clinical actions + |
+
get_actions |
+
+
+
+ Returns the current list of actions if any exist + |
+
healthchain/io/containers/document.py
Document
+
+
+
+ dataclass
+
+
+
+ Bases: BaseDocument
A document container that extends BaseDocument with rich annotation capabilities.
+This class extends BaseDocument to handle textual document data and annotations from +various sources. It serves as the main data structure passed through processing pipelines, +accumulating annotations and analysis results at each step.
+The Document class provides a comprehensive representation that can include: +- Raw text and basic tokenization +- NLP annotations (tokens, entities, embeddings, spaCy docs) +- Clinical concepts (problems, medications, allergies) +- Structured clinical documents (CCD, FHIR) +- Clinical decision support results (cards, actions) +- ML model outputs (Hugging Face, LangChain)
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
nlp |
+
+
+
+ Container for NLP-related annotations like tokens and entities +
+
+ TYPE:
+ |
+
concepts |
+
+
+
+ Container for extracted medical concepts +
+
+ TYPE:
+ |
+
hl7 |
+
+
+
+ Container for structured clinical documents (CCD, FHIR) +
+
+ TYPE:
+ |
+
cds |
+
+
+
+ Container for clinical decision support results +
+
+ TYPE:
+ |
+
models |
+
+
+
+ Container for ML model outputs +
+
+ TYPE:
+ |
+
The class provides methods to: +- Add and access medical concepts +- Generate structured clinical documents +- Get basic text statistics +- Iterate over tokens +- Access raw text
+ + +BaseDocument: Provides base document functionality and raw text storage
+healthchain/io/containers/document.py
308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 |
|
__post_init__()
+
+Initialize the document with basic tokenization if needed.
+ +healthchain/io/containers/document.py
add_concepts(problems=None, medications=None, allergies=None)
+
+Add extracted medical concepts to the document.
+This method adds medical concepts (problems, medications, allergies) to their +respective lists in the document's concepts container. Each concept type is +optional and will only be added if provided.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ problems
+ |
+
+
+
+ List of medical problems/conditions +to add to the document. Defaults to None. +
+
+ TYPE:
+ |
+
+ medications
+ |
+
+
+
+ List of medications +to add to the document. Defaults to None. +
+
+ TYPE:
+ |
+
+ allergies
+ |
+
+
+
+ List of allergies +to add to the document. Defaults to None. +
+
+ TYPE:
+ |
+
++++++doc.add_concepts( +... problems=[ProblemConcept(display_name="Hypertension")], +... medications=[MedicationConcept(display_name="Aspirin")] +... )
+
healthchain/io/containers/document.py
generate_ccd(overwrite=False)
+
+Generate a CCD (Continuity of Care Document) from the current medical concepts.
+This method creates or updates a CCD in the hl7 container using the +medical concepts (problems, medications, allergies) currently stored in the document. +The CCD is a standard format for exchanging clinical information.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ overwrite
+ |
+
+
+
+ If True, overwrites any existing CCD data. +If False, merges with existing CCD data. Defaults to False. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ CcdData
+ |
+
+
+
+ The generated CCD data. +
+
+ TYPE:
+ |
+
++++++doc.add_concepts(problems=[ProblemConcept(display_name="Hypertension")]) +doc.generate_ccd() # Creates CCD with the hypertension problem
+
healthchain/io/containers/document.py
HL7Data
+
+
+
+ dataclass
+
+
+Container for structured clinical document formats.
+This class stores and manages structured clinical data in different formats, +including CCD (Continuity of Care Document) and FHIR (Fast Healthcare +Interoperability Resources).
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
_ccd_data |
+
+
+
+ Clinical data in CCD format, containing +problems, medications, allergies and other clinical information. +
+
+ TYPE:
+ |
+
_fhir_data |
+
+
+
+ Clinical data in FHIR format for +clinical decision support. +
+
+ TYPE:
+ |
+
METHOD | +DESCRIPTION | +
---|---|
update_ccd_from_concepts |
+
+
+
+ ConceptLists, overwrite: bool = False) -> CcdData: +Updates the CCD data with new clinical concepts, either by overwriting or extending +existing data. + |
+
get_fhir_data |
+
+
+
+ Returns the FHIR format clinical data if it exists, otherwise None. + |
+
get_ccd_data |
+
+
+
+ Returns the CCD format clinical data if it exists, otherwise None. + |
+
healthchain/io/containers/document.py
194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 |
|
update_ccd_from_concepts(concepts, overwrite=False)
+
+Updates the CCD data with new clinical concepts.
+This method takes a ConceptLists object containing problems, medications, +and allergies, and updates the internal CCD data accordingly. If no CCD +data exists, it creates a new CcdData instance.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ concepts
+ |
+
+
+
+ The new clinical concepts to add, containing +problems, medications, and allergies lists. +
+
+ TYPE:
+ |
+
+ overwrite
+ |
+
+
+
+ If True, replaces existing concepts. +If False, extends the existing lists. Defaults to False. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ CcdData
+ |
+
+
+
+ The updated CCD data. +
+
+ TYPE:
+ |
+
healthchain/io/containers/document.py
ModelOutputs
+
+
+
+ dataclass
+
+
+Container for storing and managing third-party integration model outputs.
+This class stores outputs from different NLP/ML frameworks like Hugging Face +and LangChain, organizing them by task type. It also maintains a list of +generated text outputs across frameworks.
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
_huggingface_results |
+
+
+
+ Dictionary storing Hugging Face model +outputs, keyed by task name. +
+
+ TYPE:
+ |
+
_langchain_results |
+
+
+
+ Dictionary storing LangChain outputs, +keyed by task name. +
+
+ TYPE:
+ |
+
METHOD | +DESCRIPTION | +
---|---|
add_output |
+
+
+
+ str, task: str, output: Any): Adds a model output for a +specific source and task. For text generation tasks, also extracts and +stores the generated text. + |
+
get_output |
+
+
+
+ str, task: str, default: Any = None) -> Any: Gets the model +output for a specific source and task. Returns default if not found. + |
+
get_generated_text |
+
+
+
+ Returns the list of generated text outputs + |
+
healthchain/io/containers/document.py
86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 |
|
get_generated_text(source, task)
+
+Returns generated text outputs for a given source and task.
+Handles different output formats for Hugging Face and LangChain. For +Hugging Face, it extracts the last message content from chat-style +outputs and common keys like "generated_text", "summary_text", and +"translation". For LangChain, it converts JSON outputs to strings, and returns +the output as is if it is already a string.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ source
+ |
+
+
+
+ Framework name (e.g., "huggingface", "langchain"). +
+
+ TYPE:
+ |
+
+ task
+ |
+
+
+
+ Task name for retrieving generated text. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ List[str]
+
+ |
+
+
+
+ List[str]: List of generated text outputs, or an empty list if none. + |
+
healthchain/io/containers/document.py
128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 |
|
NlpAnnotations
+
+
+
+ dataclass
+
+
+Container for NLP-specific annotations and results.
+This class stores various NLP annotations and processing results from text analysis, +including preprocessed text, tokens, named entities, embeddings and spaCy documents.
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
_preprocessed_text |
+
+
+
+ The preprocessed version of the input text. +
+
+ TYPE:
+ |
+
_tokens |
+
+
+
+ List of tokenized words from the text. +
+
+ TYPE:
+ |
+
_entities |
+
+
+
+ Named entities extracted from the text, with their labels and positions. +
+
+ TYPE:
+ |
+
_embeddings |
+
+
+
+ Vector embeddings generated from the text. +
+
+ TYPE:
+ |
+
_spacy_doc |
+
+
+
+ The processed spaCy Doc object. +
+
+ TYPE:
+ |
+
METHOD | +DESCRIPTION | +
---|---|
add_spacy_doc |
+
+
+
+ SpacyDoc): Processes a spaCy Doc to extract tokens and entities. + |
+
get_spacy_doc |
+
+
+
+ Returns the stored spaCy Doc object. + |
+
get_tokens |
+
+
+
+ Returns the list of tokens. + |
+
set_tokens |
+
+
+
+ List[str]): Sets the token list. + |
+
set_entities |
+
+
+
+ List[Dict[str, Any]]): Sets the named entities list. + |
+
get_entities |
+
+
+
+ Returns the list of named entities. + |
+
get_embeddings |
+
+
+
+ Returns the vector embeddings. + |
+
set_embeddings |
+
+
+
+ List[float]): Sets the vector embeddings. + |
+
healthchain/io/containers/document.py
tabular
+
+
+Tabular
+
+
+
+ dataclass
+
+
+
+ Bases: DataContainer[DataFrame]
A container for tabular data, wrapping a pandas DataFrame.
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
data |
+
+
+
+ The pandas DataFrame containing the tabular data. +
+
+ TYPE:
+ |
+
METHOD | +DESCRIPTION | +
---|---|
__post_init__ |
+
+
+
+ Validates that the data is a pandas DataFrame. + |
+
columns |
+
+
+
+ Property that returns a list of column names. + |
+
index |
+
+
+
+ Property that returns the DataFrame's index. + |
+
dtypes |
+
+
+
+ Property that returns a dictionary of column names and their data types. + |
+
column_count |
+
+
+
+ Returns the number of columns in the DataFrame. + |
+
row_count |
+
+
+
+ Returns the number of rows in the DataFrame. + |
+
get_dtype |
+
+
+
+ str): Returns the data type of a specific column. + |
+
__iter__ |
+
+
+
+ Returns an iterator over the column names. + |
+
__len__ |
+
+
+
+ Returns the number of rows in the DataFrame. + |
+
describe |
+
+
+
+ Returns a string description of the tabular data. + |
+
remove_column |
+
+
+
+ str): Removes a column from the DataFrame. + |
+
from_csv |
+
+
+
+ str, **kwargs): Class method to create a Tabular object from a CSV file. + |
+
from_dict |
+
+
+
+ Dict[str, Any]): Class method to create a Tabular object from a dictionary. + |
+
to_csv |
+
+
+
+ str, **kwargs): Saves the DataFrame to a CSV file. + |
+
healthchain/io/containers/tabular.py
CdsDataGenerator
+
+
+A class to generate CDS (Clinical Decision Support) data based on specified workflows and constraints.
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
registry |
+
+
+
+ A registry of data generators. +
+
+ TYPE:
+ |
+
mappings |
+
+
+
+ A mapping of workflows to their respective data generators. +
+
+ TYPE:
+ |
+
data |
+
+
+
+ The generated CDS FHIR data. +
+
+ TYPE:
+ |
+
healthchain/data_generators/cdsdatagenerator.py
19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 |
|
fetch_generator(generator_name)
+
+Fetches a data generator function by its name from the registry.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ generator_name
+ |
+
+
+
+ The name of the data generator to fetch. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ Callable
+ |
+
+
+
+ The data generator function. +
+
+ TYPE:
+ |
+
healthchain/data_generators/cdsdatagenerator.py
free_text_parser(path_to_csv, column_name)
+
+Parses free text data from a CSV file and converts it into a list of DocumentReference models.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ path_to_csv
+ |
+
+
+
+ The path to the CSV file containing free text data. +
+
+ TYPE:
+ |
+
+ column_name
+ |
+
+
+
+ The column name in the CSV file to use for free text data. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ dict
+ |
+
+
+
+ A dictionary of parsed free text data converted into DocumentReference models. +
+
+ TYPE:
+ |
+
healthchain/data_generators/cdsdatagenerator.py
generate(constraints=None, free_text_path=None, column_name=None, random_seed=None)
+
+Generates CDS data based on the current workflow, constraints, and optional free text data.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ constraints
+ |
+
+
+
+ A list of constraints to apply to the data generation. +
+
+ TYPE:
+ |
+
+ free_text_path
+ |
+
+
+
+ The path to a CSV file containing free text data. +
+
+ TYPE:
+ |
+
+ column_name
+ |
+
+
+
+ The column name in the CSV file to use for free text data. +
+
+ TYPE:
+ |
+
+ random_seed
+ |
+
+
+
+ The random seed to use for reproducible data generation. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ BaseModel
+ |
+
+
+
+ The generated CDS FHIR data. +
+
+ TYPE:
+ |
+
healthchain/data_generators/cdsdatagenerator.py
set_workflow(workflow)
+
+Sets the current workflow to be used for data generation.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ workflow
+ |
+
+
+
+ The name of the workflow to set. +
+
+ TYPE:
+ |
+
healthchain/data_generators/cdsdatagenerator.py
ClassGenerator
+
+
+
+ Bases: BaseGenerator
A generator class for creating FHIR Class resources.
+ + +METHOD | +DESCRIPTION | +
---|---|
generate |
+
+
+
+ Generates a FHIR Class resource. + |
+
healthchain/data_generators/encountergenerators.py
EncounterGenerator
+
+
+
+ Bases: BaseGenerator
A generator class for creating FHIR Encounter resources.
+ + +METHOD | +DESCRIPTION | +
---|---|
generate |
+
+
+
+ Optional[list] = None, random_seed: Optional[int] = None) -> Encounter: +Generates a FHIR Encounter resource with optional constraints and random_seed. + |
+
healthchain/data_generators/encountergenerators.py
EncounterLocationGenerator
+
+
+
+ Bases: BaseGenerator
A generator class for creating FHIR EncounterLocation resources.
+ + +METHOD | +DESCRIPTION | +
---|---|
generate |
+
+
+
+ Generates a FHIR EncounterLocation resource. + |
+
healthchain/data_generators/encountergenerators.py
EncounterPriorityGenerator
+
+
+
+ Bases: BaseGenerator
A generator class for creating FHIR EncounterPriority resources.
+ + +METHOD | +DESCRIPTION | +
---|---|
generate |
+
+
+
+ Generates a FHIR EncounterPriority resource. + |
+
healthchain/data_generators/encountergenerators.py
EncounterTypeGenerator
+
+
+
+ Bases: BaseGenerator
A generator class for creating FHIR EncounterType resources.
+ + +METHOD | +DESCRIPTION | +
---|---|
generate |
+
+
+
+ Generates a FHIR EncounterType resource. + |
+
healthchain/data_generators/encountergenerators.py
PeriodGenerator
+
+
+
+ Bases: BaseGenerator
A generator class for creating FHIR Period resources.
+ + +METHOD | +DESCRIPTION | +
---|---|
generate |
+
+
+
+ Generates a FHIR Period resource with random start and end times. + |
+
healthchain/data_generators/encountergenerators.py
CcdData
+
+
+
+ Bases: BaseModel
Data model for CCD (Continuity of Care Document) that can be converted to CDA.
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
concepts |
+
+
+
+ Container for medical concepts (problems, allergies, medications) +extracted from the document. Defaults to empty ConceptLists. +
+
+ TYPE:
+ |
+
note |
+
+
+
+ The clinical note text, either as a string or +dictionary of sections. Defaults to None. +
+
+ TYPE:
+ |
+
cda_xml |
+
+
+
+ The raw CDA XML string representation of the document. +Defaults to None. +
+
+ TYPE:
+ |
+
healthchain/models/data/ccddata.py
CdsFhirData
+
+
+
+ Bases: BaseModel
Data model for CDS FHIR data, matching the expected fields in CDSRequests.
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
context |
+
+
+
+ A dictionary containing contextual information for the CDS request. +
+
+ TYPE:
+ |
+
prefetch |
+
+
+
+ A Bundle object containing prefetched FHIR resources. +
+
+ TYPE:
+ |
+
METHOD | +DESCRIPTION | +
---|---|
create |
+
+
+
+ Dict, prefetch: Dict): Class method to create a CdsFhirData instance. + |
+
model_dump |
+
+
+
+ Returns a dictionary representation of the model. + |
+
model_dump_json |
+
+
+
+ Returns a JSON string representation of the model. + |
+
model_dump_prefetch |
+
+
+
+ Returns a dictionary representation of the prefetch Bundle. + |
+
healthchain/models/data/cdsfhirdata.py
AllergyConcept
+
+
+
+ Bases: Concept
Contains allergy specific fields
+Defaults allergy type to propensity to adverse reactions in SNOMED CT
+ + + + + + +healthchain/models/data/concept.py
Concept
+
+
+
+ Bases: BaseModel
A more lenient, system agnostic representation of a concept e.g. problems, medications, allergies +that can be converted to CDA or FHIR
+ + + + + + +healthchain/models/data/concept.py
ConceptLists
+
+
+
+ Bases: BaseModel
Container for lists of medical concepts extracted from text.
+ + + + + + +healthchain/models/data/concept.py
DataType
+
+
+MedicationConcept
+
+
+
+ Bases: Concept
Contains medication specific fields
+ + + + + + +healthchain/models/data/concept.py
ProblemConcept
+
+
+
+ Bases: Concept
Contains problem/condition specific fields
+ + + + + + +healthchain/models/data/concept.py
BasePipeline
+
+
+
+ Bases: Generic[T]
, ABC
Abstract base class for creating and managing data processing pipelines.
+The BasePipeline class provides a framework for building modular data processing pipelines +by allowing users to add, remove, and configure components with defined dependencies and +execution order. Components can be added at specific positions, grouped into stages, and +connected via input/output connectors.
+This is an abstract base class that should be subclassed to create specific pipeline +implementations.
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
_components |
+
+
+
+ Ordered list of pipeline components +
+
+ TYPE:
+ |
+
_stages |
+
+
+
+ Components grouped by processing stage +
+
+ TYPE:
+ |
+
_built_pipeline |
+
+
+
+ Compiled pipeline function +
+
+ TYPE:
+ |
+
_input_connector |
+
+
+
+ Connector for processing input data +
+
+ TYPE:
+ |
+
_output_connector |
+
+
+
+ Connector for processing output data +
+
+ TYPE:
+ |
+
_output_template |
+
+
+
+ Template string for formatting pipeline outputs +
+
+ TYPE:
+ |
+
_model_config |
+
+
+
+ Configuration for the pipeline model +
+
+ TYPE:
+ |
+
++++++class MyPipeline(BasePipeline[str]): +... def configure_pipeline(self, config: ModelConfig) -> None: +... self.add_node(preprocess, stage="preprocessing") +... self.add_node(process, stage="processing") +... self.add_node(postprocess, stage="postprocessing") +... +pipeline = MyPipeline() +result = pipeline("input text")
+
healthchain/pipeline/base.py
77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 +520 +521 +522 +523 +524 +525 +526 +527 +528 +529 +530 +531 +532 +533 +534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 +548 +549 +550 +551 +552 +553 +554 +555 +556 +557 +558 +559 +560 +561 +562 +563 +564 +565 +566 +567 +568 +569 +570 +571 +572 +573 +574 +575 +576 +577 +578 +579 +580 +581 +582 +583 +584 +585 +586 +587 +588 +589 +590 +591 +592 +593 +594 +595 +596 +597 +598 +599 +600 +601 +602 +603 +604 +605 +606 +607 +608 +609 +610 +611 +612 +613 +614 +615 +616 +617 +618 +619 +620 +621 +622 +623 +624 +625 +626 +627 +628 +629 +630 +631 +632 +633 +634 +635 +636 +637 +638 +639 +640 +641 +642 +643 +644 +645 +646 +647 +648 +649 +650 +651 +652 +653 +654 +655 +656 +657 +658 +659 +660 +661 +662 +663 +664 +665 +666 +667 +668 +669 +670 +671 +672 +673 +674 +675 +676 +677 +678 +679 +680 +681 +682 +683 +684 +685 +686 +687 +688 +689 +690 +691 +692 +693 +694 +695 +696 +697 +698 +699 +700 +701 +702 +703 +704 +705 +706 +707 +708 +709 +710 +711 +712 +713 +714 +715 +716 +717 +718 +719 +720 +721 +722 +723 +724 +725 +726 +727 +728 +729 +730 +731 +732 +733 +734 +735 +736 +737 +738 +739 +740 +741 +742 +743 +744 +745 +746 +747 +748 +749 +750 +751 +752 +753 +754 +755 +756 +757 +758 +759 +760 +761 +762 +763 +764 +765 +766 +767 +768 +769 +770 +771 +772 +773 +774 +775 +776 +777 +778 +779 +780 +781 +782 +783 +784 +785 +786 +787 +788 +789 |
|
stages
+
+
+ property
+ writable
+
+
+Returns a human-readable representation of the pipeline stages.
+add_input(connector)
+
+Adds an input connector to the pipeline.
+This method sets the input connector for the pipeline, which is responsible +for processing the input data before it's passed to the pipeline components.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ connector
+ |
+
+
+
+ The input connector to be added to the pipeline. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ None
+
+ |
+
+
+
+ None + |
+
Only one input connector can be set for the pipeline. If this method is +called multiple times, the last connector will overwrite the previous ones.
+healthchain/pipeline/base.py
add_node(component=None, *, position='default', reference=None, stage=None, name=None, input_model=None, output_model=None, dependencies=[])
+
+Adds a component node to the pipeline.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ component
+ |
+
+
+
+ The component to be added. It can be either a BaseComponent object or a callable function. +Defaults to None. +
+
+ TYPE:
+ |
+
+ position
+ |
+
+
+
+ The position at which the component should be added in the pipeline. +Valid values are "default", "first", "last", "after", and "before". +Defaults to "default". +
+
+ TYPE:
+ |
+
+ reference
+ |
+
+
+
+ The name of the component after or before which the new component should be added. +Only applicable when position is "after" or "before". +Defaults to None. +
+
+ TYPE:
+ |
+
+ stage
+ |
+
+
+
+ The stage to which the component belongs. +Defaults to None. +
+
+ TYPE:
+ |
+
+ name
+ |
+
+
+
+ The name of the component. +Defaults to None, in which case the name of the function will be used. +
+
+ TYPE:
+ |
+
+ input_model
+ |
+
+
+
+ The input Pydantic model class for validating the input data. +Defaults to None. +
+
+ TYPE:
+ |
+
+ output_model
+ |
+
+
+
+ The output Pydantic model class for validating the output data. +Defaults to None. +
+
+ TYPE:
+ |
+
+ dependencies
+ |
+
+
+
+ The list of component names that this component depends on. +Defaults to an empty list. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ None
+
+ |
+
+
+
+ The original component if component is None, otherwise the wrapper function. + |
+
healthchain/pipeline/base.py
460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 +520 +521 +522 +523 +524 +525 +526 +527 +528 +529 +530 +531 +532 +533 +534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 +548 +549 +550 +551 +552 +553 +554 +555 +556 +557 +558 +559 +560 +561 +562 +563 +564 +565 +566 |
|
add_output(connector)
+
+Adds an output connector to the pipeline.
+This method sets the output connector for the pipeline, which is responsible +for processing the output data after it has passed through all pipeline components.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ connector
+ |
+
+
+
+ The output connector to be added to the pipeline. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ None
+
+ |
+
+
+
+ None + |
+
Only one output connector can be set for the pipeline. If this method is +called multiple times, the last connector will overwrite the previous ones.
+healthchain/pipeline/base.py
build()
+
+Builds and returns a pipeline function that applies a series of components to the input data. +Returns: + pipeline: A function that takes input data and applies the ordered components to it. +Raises: + ValueError: If a circular dependency is detected among the components.
+ +healthchain/pipeline/base.py
configure_pipeline(model_config)
+
+
+ abstractmethod
+
+
+Configure the pipeline based on the provided model configuration.
+This method should be implemented by subclasses to add specific components +and configure the pipeline according to the given model configuration. +The configuration typically involves: +1. Setting up input/output connectors +2. Adding model components based on the model source +3. Adding any additional processing nodes +4. Configuring the pipeline stages and execution order
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ model_config
+ |
+
+
+
+ Configuration object containing: +- source: Model source (e.g. huggingface, spacy, langchain) +- model: Model identifier or path +- task: Optional task name (e.g. summarization, ner) +- path: Optional local path to model files +- kwargs: Additional model configuration parameters +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ None
+
+ |
+
+
+
+ None + |
+
RAISES | +DESCRIPTION | +
---|---|
+
+ NotImplementedError
+
+ |
+
+
+
+ If the method is not implemented by a subclass. + |
+
++++++def configure_pipeline(self, config: ModelConfig): +... # Add FHIR connector for input/output +... connector = FhirConnector() +... self.add_input(connector) +... +... # Add model component +... model = self.get_model_component(config) +... self.add_node(model, stage="processing") +... +... # Add output formatting +... self.add_node(OutputFormatter(), stage="formatting") +... self.add_output(connector)
+
healthchain/pipeline/base.py
from_local_model(path, source, task=None, template=None, template_path=None, **kwargs)
+
+
+ classmethod
+
+
+Load pipeline from a local model path.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ path
+ |
+
+
+
+ Path to local model files/directory +
+
+ TYPE:
+ |
+
+ source
+ |
+
+
+
+ Model source (e.g. "huggingface", "spacy") +
+
+ TYPE:
+ |
+
+ task
+ |
+
+
+
+ Task identifier for the model. Defaults to None. +
+
+ TYPE:
+ |
+
+ template
+ |
+
+
+
+ Optional template string for formatting model output. +
+
+ TYPE:
+ |
+
+ template_path
+ |
+
+
+
+ Optional path to template file for formatting model output. +
+
+ TYPE:
+ |
+
+ **kwargs
+ |
+
+
+
+ Additional configuration options passed to the model. e.g. temperature, max_length, etc. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ BasePipeline
+ |
+
+
+
+ Configured pipeline instance. +
+
+ TYPE:
+ |
+
RAISES | +DESCRIPTION | +
---|---|
+
+ ValueError
+
+ |
+
+
+
+ If source is not a valid ModelSource. + |
+
Examples:
+>>> # Load local HuggingFace model
+>>> pipeline = Pipeline.from_local_model(
+... "models/my_summarizer",
+... source="huggingface",
+... task="summarization",
+... temperature=0.7
+... )
+>>>
+>>> # Load local SpaCy model
+>>> pipeline = Pipeline.from_local_model(
+... "models/en_core_sci_md",
+... source="spacy",
+... disable=["parser"]
+... )
+>>>
+>>> # Load with output template
+>>> template = '''{"summary": "{{ model_output }}"}'''
+>>> pipeline = Pipeline.from_local_model(
+... "models/gpt_model",
+... source="huggingface",
+... template=template
+... )
+
healthchain/pipeline/base.py
279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 |
|
from_model_id(model_id, source='huggingface', task='text-generation', template=None, template_path=None, **kwargs)
+
+
+ classmethod
+
+
+Load pipeline from a model identifier.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ model_id
+ |
+
+
+
+ Model identifier (e.g. HuggingFace model ID, SpaCy model name) +
+
+ TYPE:
+ |
+
+ source
+ |
+
+
+
+ Model source. Defaults to "huggingface". +Can be "huggingface", "spacy". +
+
+ TYPE:
+ |
+
+ task
+ |
+
+
+
+ Task identifier for the model. Defaults to "text-generation". +
+
+ TYPE:
+ |
+
+ template
+ |
+
+
+
+ Optional template string for formatting model output. +
+
+ TYPE:
+ |
+
+ template_path
+ |
+
+
+
+ Optional path to template file for formatting model output. +
+
+ TYPE:
+ |
+
+ **kwargs
+ |
+
+
+
+ Additional configuration options passed to the model. e.g. temperature, max_length, etc. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ BasePipeline
+ |
+
+
+
+ Configured pipeline instance. +
+
+ TYPE:
+ |
+
RAISES | +DESCRIPTION | +
---|---|
+
+ ValueError
+
+ |
+
+
+
+ If source is not a valid ModelSource. + |
+
Examples:
+>>> # Load HuggingFace model
+>>> pipeline = Pipeline.from_model_id(
+... "facebook/bart-large-cnn",
+... task="summarization",
+... temperature=0.7
+... )
+>>>
+>>> # Load SpaCy model
+>>> pipeline = Pipeline.from_model_id(
+... "en_core_sci_md",
+... source="spacy",
+... disable=["parser"]
+... )
+>>>
+>>> # Load with output template
+>>> template = '''{"summary": "{{ model_output }}"}'''
+>>> pipeline = Pipeline.from_model_id(
+... "gpt-3.5-turbo",
+... source="huggingface",
+... template=template
+... )
+
healthchain/pipeline/base.py
214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 |
|
load(pipeline, source, task='text-generation', template=None, template_path=None, **kwargs)
+
+
+ classmethod
+
+
+Load a pipeline from a pre-built pipeline object (e.g. LangChain chain or HuggingFace pipeline).
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ pipeline
+ |
+
+
+
+ A callable pipeline object (e.g. LangChain chain, HuggingFace pipeline) +
+
+ TYPE:
+ |
+
+ source
+ |
+
+
+
+ Source of the pipeline. Can be "langchain" or "huggingface". +
+
+ TYPE:
+ |
+
+ task
+ |
+
+
+
+ Task identifier used to retrieve model outputs. +Defaults to "text-generation". +
+
+ TYPE:
+ |
+
+ template
+ |
+
+
+
+ Template string for formatting outputs. +Defaults to None. +
+
+ TYPE:
+ |
+
+ template_path
+ |
+
+
+
+ Path to template file. +Defaults to None. +
+
+ TYPE:
+ |
+
+ **kwargs
+ |
+
+
+
+ Additional configuration options passed to the pipeline. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ BasePipeline
+ |
+
+
+
+ Configured pipeline instance. +
+
+ TYPE:
+ |
+
RAISES | +DESCRIPTION | +
---|---|
+
+ ValueError
+
+ |
+
+
+
+ If pipeline is not callable or source is invalid. + |
+
Examples:
+>>> # Load LangChain pipeline
+>>> from langchain_core.prompts import ChatPromptTemplate
+>>> from langchain_openai import ChatOpenAI
+>>> chain = ChatPromptTemplate.from_template("What is {input}?") | ChatOpenAI()
+>>> pipeline = Pipeline.load(chain, source="langchain", temperature=0.7)
+>>>
+>>> # Load HuggingFace pipeline
+>>> from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
+>>> tokenizer = AutoTokenizer.from_pretrained("gpt2")
+>>> model = AutoModelForCausalLM.from_pretrained("gpt2")
+>>> pipe = pipeline("text-generation", model=model, tokenizer=tokenizer, max_new_tokens=10)
+>>> pipeline = Pipeline.load(pipe, source="huggingface")
+
healthchain/pipeline/base.py
141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 |
|
remove(component_name)
+
+Removes a component from the pipeline.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ component_name
+ |
+
+
+
+ The name of the component to be removed. +
+
+ TYPE:
+ |
+
RAISES | +DESCRIPTION | +
---|---|
+
+ ValueError
+
+ |
+
+
+
+ If the component is not found in the pipeline. + |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ None
+
+ |
+
+
+
+ None + |
+
DEBUG: When the component is successfully removed. +WARNING: If the component fails to be removed after attempting to do so.
+healthchain/pipeline/base.py
replace(old_component_name, new_component)
+
+Replaces a component in the pipeline with a new component.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ old_component_name
+ |
+
+
+
+ The name of the component to be replaced. +
+
+ TYPE:
+ |
+
+ new_component
+ |
+
+
+
+ The new component to replace the old component with. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+
+ None
+
+ |
+
+
+
+ None + |
+
RAISES | +DESCRIPTION | +
---|---|
+
+ ValueError
+
+ |
+
+
+
+ If the old component is not found in the pipeline. + |
+
+
+ ValueError
+
+ |
+
+
+
+ If the new component is not a BaseComponent or a callable. + |
+
+
+ ValueError
+
+ |
+
+
+
+ If the new component callable doesn't have the correct signature. + |
+
DEBUG: When the component is successfully replaced.
+healthchain/pipeline/base.py
666 +667 +668 +669 +670 +671 +672 +673 +674 +675 +676 +677 +678 +679 +680 +681 +682 +683 +684 +685 +686 +687 +688 +689 +690 +691 +692 +693 +694 +695 +696 +697 +698 +699 +700 +701 +702 +703 +704 +705 +706 +707 +708 +709 +710 +711 +712 +713 +714 +715 +716 +717 +718 +719 +720 +721 +722 +723 +724 +725 +726 +727 +728 +729 +730 +731 +732 +733 +734 +735 +736 +737 |
|
ModelConfig
+
+
+
+ dataclass
+
+
+Configuration for model initialization
+ + + + + + +healthchain/pipeline/base.py
ModelSource
+
+
+
+ Bases: Enum
Enumeration of supported model sources
+ + + + + + +healthchain/pipeline/base.py
Pipeline
+
+
+
+ Bases: BasePipeline
, Generic[T]
Default Pipeline class for creating a basic data processing pipeline. +This class inherits from BasePipeline and provides a default implementation +of the configure_pipeline method, which does not add any specific components.
+ + + + + + +healthchain/pipeline/base.py
configure_pipeline(model_path)
+
+Configures the pipeline by adding components based on the provided model path. +This default implementation does not add any specific components.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ model_path
+ |
+
+
+
+ The path to the model used for configuring the pipeline. +
+
+ TYPE:
+ |
+
healthchain/pipeline/base.py
PipelineNode
+
+
+
+ dataclass
+
+
+
+ Bases: Generic[T]
Represents a node in a pipeline.
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
func |
+
+
+
+ The function to be applied to the data. +
+
+ TYPE:
+ |
+
position |
+
+
+
+ The position of the node in the pipeline. Defaults to "default". +
+
+ TYPE:
+ |
+
reference |
+
+
+
+ The reference for the relative position of the node. Name should be the "name" attribute of another node. Defaults to None. +
+
+ TYPE:
+ |
+
stage |
+
+
+
+ The stage of the node in the pipeline. Group nodes by stage e.g. "preprocessing". Defaults to None. +
+
+ TYPE:
+ |
+
name |
+
+
+
+ The name of the node. Defaults to None. +
+
+ TYPE:
+ |
+
dependencies |
+
+
+
+ The list of dependencies for the node. Defaults to an empty list. +
+
+ TYPE:
+ |
+
healthchain/pipeline/base.py
Service
+
+
+A service wrapper which registers routes and starts a FastAPI service
+Parameters: +endpoints (Dict[str, Enpoint]): the list of endpoints to register, must be a dictionary +of Endpoint objects. Should have human-readable keys e.g. ["info", "service_mount"]
+ + + + + + +healthchain/service/service.py
21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 + 37 + 38 + 39 + 40 + 41 + 42 + 43 + 44 + 45 + 46 + 47 + 48 + 49 + 50 + 51 + 52 + 53 + 54 + 55 + 56 + 57 + 58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 |
|
run(config=None)
+
+Starts server on uvicorn.
+Parameters: +config (Dict): kwargs to pass into uvicorn.
+ +healthchain/service/service.py
ClinicalDecisionSupport
+
+
+
+ Bases: BaseUseCase
Implements EHR backend simulator for Clinical Decision Support (CDS)
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ service_api
+ |
+
+
+
+ the function body to inject into the main service +
+
+ TYPE:
+ |
+
+ service_config
+ |
+
+
+
+ the config kwargs for the uvicorn server passed into service +
+
+ TYPE:
+ |
+
+ service
+ |
+
+
+
+ the service runner object +
+
+ TYPE:
+ |
+
+ client
+ |
+
+
+
+ the client runner object +
+
+ TYPE:
+ |
+
See https://cds-hooks.org/ for specification
+ + + + + + +healthchain/use_cases/cds.py
85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 |
|
cds_discovery()
+
+CDS discovery endpoint for FastAPI app, should be mounted to /cds-services
+ +healthchain/use_cases/cds.py
cds_service(id, request)
+
+CDS service endpoint for FastAPI app, mounted to /cds-services/{id}
+This method handles the execution of a specific CDS service. It validates the +service configuration, checks the input parameters, executes the service +function, and ensures the correct response type is returned.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ id
+ |
+
+
+
+ The unique identifier of the CDS service to be executed. +
+
+ TYPE:
+ |
+
+ request
+ |
+
+
+
+ The request object containing the input data for the CDS service. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ CDSResponse
+ |
+
+
+
+ The response object containing the cards generated by the CDS service. +
+
+ TYPE:
+ |
+
RAISES | +DESCRIPTION | +
---|---|
+
+ AssertionError
+
+ |
+
+
+
+ If the service function is not properly configured. + |
+
+
+ TypeError
+
+ |
+
+
+
+ If the input or output types do not match the expected types. + |
+
This method performs several checks to ensure the integrity of the service: +1. Verifies that the service API is configured. +2. Validates the signature of the service function. +3. Ensures the service function accepts a CDSRequest as its first argument. +4. Verifies that the service function returns a CDSResponse.
+healthchain/use_cases/cds.py
ClinicalDecisionSupportStrategy
+
+
+
+ Bases: BaseStrategy
Handles the request construction and validation
+ + + + + + +healthchain/use_cases/cds.py
construct_request(data, workflow)
+
+Constructs a HL7-compliant CDS request based on workflow.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ data
+ |
+
+
+
+ FHIR data to be injected in request. +
+
+ TYPE:
+ |
+
+ workflow
+ |
+
+
+
+ The CDS hook name, e.g. patient-view. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ CDSRequest
+ |
+
+
+
+ A Pydantic model that wraps a CDS request for REST +
+
+ TYPE:
+ |
+
RAISES | +DESCRIPTION | +
---|---|
+
+ ValueError
+
+ |
+
+
+
+ If the workflow is invalid or the data does not validate properly. + |
+
healthchain/use_cases/cds.py
CDSRequest
+
+
+
+ Bases: BaseModel
A model representing the data structure for a CDS service call, triggered by specific hooks +within a healthcare application.
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
hook |
+
+
+
+ The hook that triggered this CDS Service call. For example, 'patient-view'. +
+
+ TYPE:
+ |
+
hookInstance |
+
+
+
+ A universally unique identifier for this particular hook call. +
+
+ TYPE:
+ |
+
fhirServer |
+
+
+
+ The base URL of the CDS Client's FHIR server. This field is required if
+
+ TYPE:
+ |
+
fhirAuthorization |
+
+
+
+ Optional authorization details providing a bearer access token for FHIR resources. +
+
+ TYPE:
+ |
+
context |
+
+
+
+ Hook-specific contextual data required by the CDS service. +
+
+ TYPE:
+ |
+
prefetch |
+
+
+
+ Optional FHIR data that was prefetched by the CDS Client. +
+
+ TYPE:
+ |
+
Documentation: https://cds-hooks.org/specification/current/#http-request_1
+ + + + + + +healthchain/models/requests/cdsrequest.py
Action
+
+
+
+ Bases: BaseModel
Within a suggestion, all actions are logically AND'd together, such that a user selecting a +suggestion selects all of the actions within it. When a suggestion contains multiple actions, +the actions SHOULD be processed as per FHIR's rules for processing transactions with the CDS +Client's fhirServer as the base url for the inferred full URL of the transaction bundle entries.
+https://cds-hooks.org/specification/current/#action
+ + + + + + +healthchain/models/responses/cdsresponse.py
ActionTypeEnum
+
+
+
+ Bases: str
, Enum
The type of action being performed
+ + + + + + +healthchain/models/responses/cdsresponse.py
CDSResponse
+
+
+
+ Bases: BaseModel
Represents the response from a CDS service.
+This class models the structure of a CDS Hooks response, which includes +cards for displaying information or suggestions to the user, and optional +system actions that can be executed automatically.
+ + +ATTRIBUTE | +DESCRIPTION | +
---|---|
cards |
+
+
+
+ A list of Card objects to be displayed to the end user. +Default is an empty list. +
+
+ TYPE:
+ |
+
systemActions |
+
+
+
+ A list of Action objects representing +actions that the CDS Client should execute as part of performing +the decision support requested. This field is optional. +
+
+ TYPE:
+ |
+
For more information, see: +https://cds-hooks.org/specification/current/#cds-service-response
+ + + + + + +healthchain/models/responses/cdsresponse.py
Card
+
+
+
+ Bases: BaseModel
Cards can provide a combination of information (for reading), suggested actions +(to be applied if a user selects them), and links (to launch an app if the user selects them). +The CDS Client decides how to display cards, but this specification recommends displaying suggestions +using buttons, and links using underlined text.
+https://cds-hooks.org/specification/current/#card-attributes
+ + + + + + +healthchain/models/responses/cdsresponse.py
IndicatorEnum
+
+
+
+ Bases: str
, Enum
Urgency/importance of what Card conveys. +Allowed values, in order of increasing urgency, are: info, warning, critical. +The CDS Client MAY use this field to help make UI display decisions such as sort order or coloring.
+ + + + + + +healthchain/models/responses/cdsresponse.py
Link
+
+
+
+ Bases: BaseModel
CDS Client support for appContext requires additional coordination with the authorization +server that is not described or specified in CDS Hooks nor SMART.
+Autolaunchable is experimental
+https://cds-hooks.org/specification/current/#link
+ + + + + + +healthchain/models/responses/cdsresponse.py
LinkTypeEnum
+
+
+
+ Bases: str
, Enum
The type of the given URL. There are two possible values for this field. +A type of absolute indicates that the URL is absolute and should be treated as-is. +A type of smart indicates that the URL is a SMART app launch URL and the CDS Client +should ensure the SMART app launch URL is populated with the appropriate SMART +launch parameters.
+ + + + + + +healthchain/models/responses/cdsresponse.py
SelectionBehaviorEnum
+
+
+
+ Bases: str
, Enum
Describes the intended selection behavior of the suggestions in the card. +Allowed values are: at-most-one, indicating that the user may choose none or +at most one of the suggestions; any, indicating that the end user may choose +any number of suggestions including none of them and all of them. +CDS Clients that do not understand the value MUST treat the card as an error.
+ + + + + + +healthchain/models/responses/cdsresponse.py
SimpleCoding
+
+
+
+ Bases: BaseModel
The Coding data type captures the concept of a code. This coding type is a standalone data type +in CDS Hooks modeled after a trimmed down version of the FHIR Coding data type.
+ + + + + + +healthchain/models/responses/cdsresponse.py
Source
+
+
+
+ Bases: BaseModel
Grouping structure for the Source of the information displayed on this card. +The source should be the primary source of guidance for the decision support Card represents.
+https://cds-hooks.org/specification/current/#source
+ + + + + + +healthchain/models/responses/cdsresponse.py
Suggestion
+
+
+
+ Bases: BaseModel
Allows a service to suggest a set of changes in the context of the current activity +(e.g. changing the dose of a medication currently being prescribed, for the order-sign activity). +If suggestions are present, selectionBehavior MUST also be provided.
+https://cds-hooks.org/specification/current/#suggestion
+ + + + + + +healthchain/models/responses/cdsresponse.py
ClinicalDocumentation
+
+
+
+ Bases: BaseUseCase
Implements EHR backend strategy for clinical documentation (NoteReader)
+This class represents the backend strategy for clinical documentation using the NoteReader system.
+It inherits from the BaseUseCase
class and provides methods for processing NoteReader documents.
ATTRIBUTE | +DESCRIPTION | +
---|---|
service_api |
+
+
+
+ The service API method to be used for processing the documents. +
+
+ TYPE:
+ |
+
service_config |
+
+
+
+ The configuration for the service. +
+
+ TYPE:
+ |
+
service |
+
+
+
+ The service to be used for processing the documents. +
+
+ TYPE:
+ |
+
client |
+
+
+
+ The client to be used for communication with the service. +
+
+ TYPE:
+ |
+
overwrite |
+
+
+
+ Whether to overwrite existing data in the CDA document. +
+
+ TYPE:
+ |
+
healthchain/use_cases/clindoc.py
84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 |
|
process_notereader_document(request)
+
+Process the NoteReader document using the configured service API.
+This method handles the execution of the NoteReader service. It validates the +service configuration, checks the input parameters, executes the service +function, and ensures the correct response type is returned.
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ request
+ |
+
+
+
+ The request object containing the CDA document to be processed. +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ CdaResponse
+ |
+
+
+
+ The response object containing the processed CDA document. +
+
+ TYPE:
+ |
+
RAISES | +DESCRIPTION | +
---|---|
+
+ AssertionError
+
+ |
+
+
+
+ If the service function is not properly configured. + |
+
+
+ TypeError
+
+ |
+
+
+
+ If the output type does not match the expected CdaResponse type. + |
+
This method performs several checks to ensure the integrity of the service: +1. Verifies that the service API is configured. +2. Validates the signature of the service function. +3. Ensures the service function accepts a CdaRequest as its argument. +4. Verifies that the service function returns a CdaResponse.
+healthchain/use_cases/clindoc.py
ClinicalDocumentationStrategy
+
+
+
+ Bases: BaseStrategy
Handles the request construction and validation of a NoteReader CDA file
+ + + + + + +healthchain/use_cases/clindoc.py
construct_cda_xml_document()
+
+This function should wrap FHIR data from CcdFhirData into a template CDA file (dep. vendor +TODO: implement this function
+ + +construct_request(data, workflow)
+
+Constructs a CDA request for clinical documentation use cases (NoteReader)
+ + +PARAMETER | +DESCRIPTION | +
---|---|
+ data
+ |
+
+
+
+ CDA data to be injected in the request +
+
+ TYPE:
+ |
+
+ workflow
+ |
+
+
+
+ The NoteReader workflow type, e.g. notereader-sign-inpatient +
+
+ TYPE:
+ |
+
RETURNS | +DESCRIPTION | +
---|---|
+ CdaRequest
+ |
+
+
+
+ A Pydantic model that wraps CDA data for SOAP request +
+
+ TYPE:
+ |
+
RAISES | +DESCRIPTION | +
---|---|
+
+ ValueError
+
+ |
+
+
+
+ If the workflow is invalid or the data does not validate properly. + |
+
healthchain/use_cases/clindoc.py
CdaRequest
+
+
+
+ Bases: BaseModel
healthchain/models/requests/cdarequest.py
from_dict(data)
+
+
+ classmethod
+
+
+model_dump(*args, **kwargs)
+
+model_dump_xml(*args, **kwargs)
+
+Decodes and dumps document as an xml string
+ +healthchain/models/requests/cdarequest.py
CdaResponse
+
+
+
+ Bases: BaseModel
healthchain/models/responses/cdaresponse.py
from_dict(data)
+
+
+ classmethod
+
+
+model_dump(*args, **kwargs)
+
+model_dump_xml(*args, **kwargs)
+
+Decodes and dumps document as an xml string
+ +healthchain/models/responses/cdaresponse.py
=kdiR4zywxk$us@x0Auwth8!0632ZD
z-{|X9Fw)jSG&r);ZL0_=s8_FM+{LfmLx2e{ZTjt1({{=zztEGoT|C|=fa&489;Go_
z8meyDRllrPUXX90D2Q;tK~r4RqmIWW;@AapVHgBY0QX4LsIAmw$ {imyCBygp-pZx-yglXa&*M*fD
z?(Vt-;~F<`e-|{#$Ra`+c@Hf3(vb%dKUiQ*hl+Fs0*U}R=0C2$ Dm8lwH49sQXV^ip#C0x
zglD{{@p|)a4|jaw&MFMb2CR3sR#(j7A&p8zG};1l|K`wENfy<`&6WKehnJwY*%?z~
zbZ$w&!T8`(+zPB1e)Qo3a}8%3hcGBp$1)ukS!LcwnkZjTFU5OM+Hnh9sg2ADl*Oi;
zc(<>lCyRd%P2=-X8m@kXHw{Vmi{K=4Nq_qKPV4TYWLz0C4-Aw7*F3Q3!5EF+Zg$&8
zJD9c`WL8BRfQi~#@4|a9&Xitz*`3$)0U0JZVSy`H-gBxG?@r37YXYADaLqj56|~=(
z{PN*s#V#6tR=LxKD?aJ#WGBobz|rR(dTt$*Gh5se2&D@;6mt7GspqF-wsol|}EBgg#JruQ2X&{PL*SJ$j-~SiNC(CF@I}gp
Cjtc?%{QaE_?o
z@0l(PpA3Y+P7ST9%5)A=*(
zFRF!4sW0
O5fv|Jv4aKJ22OAS@QL3
zSIo6b7jbtN`V#sO$6X=sAzvu!V|XoeT8F}fL4rKoj|*eAboukQ9evp)Ov=w`|Idb)
zD{vv(kZV|f^ltO+@8rQK;}(a39CER^LQBX77NK_jCWgl^l4x*#p-&ALj|Z!;CE*ad
z)J-}-Ik~vbAFw)!Xqvn&g__3o