Skip to content

Commit

Permalink
Add Medication and Allergy CDA fields (#51)
Browse files Browse the repository at this point in the history
* Add medication and allergy extractors

* finishing medication and allergies

* Added validation and add_to method for medications

* added allergies to cda

* Tweaked allergy parsing and refactored meds parsing function

* Fixed tuple typing error in 3.8

* Added more test conditions for allergy entries

* Bug fixes, logging, and added meds and allergies to clindoc use case function body

* Updated tests

* Update example use and added more example cda

---------

Co-authored-by: jennferjiangkells <[email protected]>
  • Loading branch information
adamkells and jennferjiangkells authored Aug 5, 2024
1 parent 3471ff0 commit 3d661a3
Show file tree
Hide file tree
Showing 10 changed files with 3,530 additions and 128 deletions.
60 changes: 53 additions & 7 deletions example_use.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import healthchain as hc
import logging

from healthchain.models.data.ccddata import CcdData
from healthchain.models.data.concept import ProblemConcept
from healthchain.models.data.concept import (
AllergyConcept,
Concept,
MedicationConcept,
ProblemConcept,
Quantity,
)
from healthchain.use_cases import ClinicalDecisionSupport
from healthchain.data_generators import CdsDataGenerator
from healthchain.models import Card, CdsFhirData, CDSRequest
Expand All @@ -17,6 +24,10 @@
load_dotenv()


log = logging.getLogger("healthchain")
log.setLevel(logging.DEBUG)


@hc.sandbox
class MyCoolSandbox(ClinicalDecisionSupport):
def __init__(self, testing=True):
Expand Down Expand Up @@ -56,31 +67,66 @@ def my_service(self, request: CDSRequest) -> List[Card]:

@hc.sandbox
class NotereaderSandbox(ClinicalDocumentation):
def __init__(self, testing=True):
self.testing = testing
def __init__(self):
self.overwrite = True

@hc.ehr(workflow="sign-note-inpatient")
def load_data_in_client(self) -> CcdData:
# data = self.data_generator.generate()
# return data

with open("./resources/epic_cda.xml", "r") as file:
with open("./resources/uclh_cda.xml", "r") as file:
xml_string = file.read()

return CcdData(cda_xml=xml_string)

@hc.api
def my_service(self, ccd_data: CcdData) -> CcdData:
# if self.testing:
# result = "test"
print(ccd_data.problems)
print(ccd_data.medications)
print(ccd_data.allergies)

new_problem = ProblemConcept(
code="38341003",
code_system="2.16.840.1.113883.6.96",
code_system_name="SNOMED CT",
display_name="Hypertension",
)
ccd_data.problems = [new_problem]
new_other_problem = ProblemConcept(
code="12341",
code_system="2.16.840.1.113883.6.96",
code_system_name="SNOMED CT",
display_name="Diabetes",
)
new_allergy = AllergyConcept(
code="70618",
code_system="2.16.840.1.113883.6.96",
code_system_name="SNOMED CT",
display_name="Allergy to peanuts",
)
another_allergy = AllergyConcept(
code="12344",
code_system="2.16.840.1.113883.6.96",
code_system_name="SNOMED CT",
display_name="CATS",
)
new_medication = MedicationConcept(
code="197361",
code_system="2.16.840.1.113883.6.88",
code_system_name="RxNorm",
display_name="Lisinopril 10 MG Oral Tablet",
dosage=Quantity(value=10, unit="mg"),
route=Concept(
code="26643006",
code_system="2.16.840.1.113883.6.96",
code_system_name="SNOMED CT",
display_name="Oral",
),
)
ccd_data.problems = [new_problem, new_other_problem]
ccd_data.allergies = [new_allergy, another_allergy]
ccd_data.medications = [new_medication]

print(ccd_data.note)

return ccd_data
Expand Down
Loading

0 comments on commit 3d661a3

Please sign in to comment.