dotimplement / HealthChain

Simplify testing and validating AI and NLP applications in a healthcare context 💫 🏥
https://dotimplement.github.io/HealthChain/
Apache License 2.0
25 stars 15 forks source link

Add utility function and validation (used ValueSetEntry class instead of Dictionary) #90

Closed ni9999 closed 3 weeks ago

ni9999 commented 1 month ago

Fixes #75

Description

Implemented .add_code() and .load_from_json() utility function and to the ValueSet class Usage:

from healthchain.data_generators import CdsDataGenerator
from healthchain.base import Workflow
from healthchain.data_generators.value_sets.medicationcodes import MedicationRequestMedication
from healthchain.data_generators.value_sets.procedurecodes import ProcedureCodeSimple, ProcedureCodeComplex
from healthchain.data_generators.value_sets.conditioncodes import ConditionCodeSimple, ConditionCodeComplex
import json

med = MedicationRequestMedication()

med.add_code("123", "medication1")
med.load_from_json("./meds.json")

print(med.value_set)

proc = ProcedureCodeSimple()

proc.add_code("123", "simpleproc1")
proc.load_from_json("./proc_simple.json")    

print(proc.value_set)

proc = ProcedureCodeComplex()

proc.add_code("123", "complexproc1")
proc.load_from_json("./proc_complex.json")

print(proc.value_set)

cond = ConditionCodeSimple()    

cond.add_code("123", "simplecond1")
cond.load_from_json("./cond_simple.json")

print(cond.value_set)

cond = ConditionCodeComplex()

cond.add_code("123", "complexcond1")
cond.load_from_json("./cond_complex.json")

print(cond.value_set)

data_generator = CdsDataGenerator()

# Generate FHIR resources for use case workflow
data_generator.set_workflow(Workflow.encounter_discharge)
data = data_generator.generate()

print(json.dumps(data.model_dump()))

Changes Made

Testing

Tested using the code in the description by adding codes directly and by json. Then reviewed generated data to see if these changes remain

Checklist

Additional Notes