Utilities API Reference¶
Utility classes and helpers.
Code Systems¶
CodeSystemRegistry
¶
Central registry for code systems with metadata.
This class provides utilities for working with healthcare code systems, including OID lookup, reverse lookup, format validation, and metadata retrieval.
Functions¶
get_oid(name)
staticmethod
¶
Get OID for code system name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Code system name (e.g., "LOINC", "SNOMED") |
required |
Returns:
| Type | Description |
|---|---|
Optional[str]
|
OID string if found, None otherwise |
Example
CodeSystemRegistry.get_oid("LOINC") '2.16.840.1.113883.6.1'
get_name(oid)
staticmethod
¶
Get code system name from OID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
oid
|
str
|
OID string (e.g., "2.16.840.1.113883.6.1") |
required |
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Code system name if found, None otherwise |
Example
CodeSystemRegistry.get_name("2.16.840.1.113883.6.1") 'LOINC'
validate_code_format(code, system)
staticmethod
¶
Validate code format for specific system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
Code value to validate |
required |
system
|
str
|
Code system name |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if code matches expected format, False otherwise |
bool
|
Returns True if no format pattern is defined for the system |
Example
CodeSystemRegistry.validate_code_format("12345-6", "LOINC") True CodeSystemRegistry.validate_code_format("invalid", "LOINC") False
get_system_info(system)
staticmethod
¶
Get metadata about a code system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
str
|
Code system name |
required |
Returns:
| Type | Description |
|---|---|
Optional[dict]
|
Dictionary with system metadata (oid, name, description, url, format_pattern) |
Optional[dict]
|
Returns None if system not found |
Example
info = CodeSystemRegistry.get_system_info("LOINC") info["description"] 'International standard for identifying medical laboratory observations'
list_systems()
staticmethod
¶
Get list of all supported code system names.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of code system names |
Example
systems = CodeSystemRegistry.list_systems() "LOINC" in systems True
get_systems_by_category()
staticmethod
¶
Get code systems grouped by category.
Returns:
| Type | Description |
|---|---|
dict[str, list[str]]
|
Dictionary mapping category names to lists of system names |
Example
categories = CodeSystemRegistry.get_systems_by_category() "LOINC" in categories["Clinical terminology systems"] True
Value Sets¶
ValueSetRegistry
¶
Central registry for C-CDA value sets with validation and lookup capabilities.
This class provides utilities for working with healthcare value sets, including validation, display name lookup, and value set management. Value sets define the allowed codes for specific clinical concepts.
Source code in ccdakit/utils/value_sets.py
8 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 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 | |
Functions¶
validate_code(value_set, code)
staticmethod
¶
Validate that a code exists in a specific value set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value_set
|
str
|
Name of the value set (e.g., "PROBLEM_STATUS") |
required |
code
|
str
|
Code to validate |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if code is valid for the value set, False otherwise |
Example
ValueSetRegistry.validate_code("PROBLEM_STATUS", "55561003") True ValueSetRegistry.validate_code("PROBLEM_STATUS", "invalid") False
Source code in ccdakit/utils/value_sets.py
get_display_name(value_set, code)
staticmethod
¶
Get the display name for a code in a value set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value_set
|
str
|
Name of the value set |
required |
code
|
str
|
Code to look up |
required |
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Display name string if found, None otherwise |
Example
ValueSetRegistry.get_display_name("PROBLEM_STATUS", "55561003") 'Active' ValueSetRegistry.get_display_name("PROBLEM_STATUS", "invalid") None
Source code in ccdakit/utils/value_sets.py
get_code_system(value_set, code)
staticmethod
¶
Get the code system for a code in a value set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value_set
|
str
|
Name of the value set |
required |
code
|
str
|
Code to look up |
required |
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Code system name if found, None otherwise |
Example
ValueSetRegistry.get_code_system("PROBLEM_STATUS", "55561003") 'SNOMED'
Source code in ccdakit/utils/value_sets.py
get_code_info(value_set, code)
staticmethod
¶
Get complete information for a code in a value set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value_set
|
str
|
Name of the value set |
required |
code
|
str
|
Code to look up |
required |
Returns:
| Type | Description |
|---|---|
Optional[dict]
|
Dictionary with 'display' and 'system' keys if found, None otherwise |
Example
info = ValueSetRegistry.get_code_info("PROBLEM_STATUS", "55561003") info["display"] 'Active' info["system"] 'SNOMED'
Source code in ccdakit/utils/value_sets.py
get_value_set(name)
staticmethod
¶
Get complete value set definition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Value set name |
required |
Returns:
| Type | Description |
|---|---|
Optional[dict[str, Any]]
|
Dictionary with value set metadata and codes if found, None otherwise |
Example
vs = ValueSetRegistry.get_value_set("PROBLEM_STATUS") vs["oid"] '2.16.840.1.113883.1.11.15933' len(vs["codes"]) 3
Source code in ccdakit/utils/value_sets.py
get_value_set_by_oid(oid)
staticmethod
¶
Get value set definition by OID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
oid
|
str
|
Value set OID |
required |
Returns:
| Type | Description |
|---|---|
Optional[dict[str, Any]]
|
Dictionary with value set metadata and codes if found, None otherwise |
Example
vs = ValueSetRegistry.get_value_set_by_oid("2.16.840.1.113883.1.11.15933") vs["name"] 'Problem Status'
Source code in ccdakit/utils/value_sets.py
list_value_sets()
staticmethod
¶
Get list of all available value set names.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of value set names |
Example
value_sets = ValueSetRegistry.list_value_sets() "PROBLEM_STATUS" in value_sets True len(value_sets) 18
Source code in ccdakit/utils/value_sets.py
get_codes(value_set)
staticmethod
¶
Get all valid codes for a value set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value_set
|
str
|
Name of the value set |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
List of valid codes, empty list if value set not found |
Example
codes = ValueSetRegistry.get_codes("ADMINISTRATIVE_GENDER") "M" in codes True "F" in codes True
Source code in ccdakit/utils/value_sets.py
search_by_display(value_set, display_text, case_sensitive=False)
staticmethod
¶
Search for codes by display name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value_set
|
str
|
Name of the value set |
required |
display_text
|
str
|
Display text to search for (partial match supported) |
required |
case_sensitive
|
bool
|
Whether search is case-sensitive (default: False) |
False
|
Returns:
| Type | Description |
|---|---|
list[str]
|
List of matching codes |
Example
codes = ValueSetRegistry.search_by_display("PROBLEM_STATUS", "active") "55561003" in codes True
Source code in ccdakit/utils/value_sets.py
load_from_json(file_path)
staticmethod
¶
Load value set from JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Path to JSON file |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with value set data |
Example JSON format
{ "oid": "2.16.840.1.113883.1.11.15933", "name": "Custom Value Set", "description": "Description of the value set", "codes": { "code1": {"display": "Display 1", "system": "SNOMED"}, "code2": {"display": "Display 2", "system": "LOINC"} } }
Source code in ccdakit/utils/value_sets.py
save_to_json(value_set_name, file_path)
staticmethod
¶
Save value set to JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value_set_name
|
str
|
Name of the value set to save |
required |
file_path
|
str
|
Path where JSON file should be saved |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If value set not found |
Source code in ccdakit/utils/value_sets.py
Sample Data Generator¶
SampleDataGenerator
¶
Generate realistic sample data for C-CDA documents.
This class provides methods to generate various types of clinical data including patient demographics, problems, medications, allergies, vital signs, and immunizations. All generated data includes appropriate medical terminology codes (SNOMED CT, RxNorm, CVX, LOINC, etc.).
Attributes:
| Name | Type | Description |
|---|---|---|
faker |
Faker instance for generating realistic data |
|
seed |
Random seed for reproducibility (optional) |
Example
Generate reproducible sample data¶
gen = SampleDataGenerator(seed=42) patient = gen.generate_patient() print(f"Patient: {patient['first_name']} {patient['last_name']}")
Generate a complete patient record¶
record = gen.generate_complete_patient_record() print(f"Generated {len(record['problems'])} problems")
Source code in ccdakit/utils/test_data.py
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 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 | |
Functions¶
__init__(seed=None)
¶
Initialize test data generator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seed
|
Optional[int]
|
Optional random seed for reproducible data generation. If provided, all generated data will be deterministic. |
None
|
Source code in ccdakit/utils/test_data.py
generate_address()
¶
Generate a realistic address.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing address fields compatible with AddressProtocol: |
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
Source code in ccdakit/utils/test_data.py
generate_telecom()
¶
Generate a realistic telecom (contact method).
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing telecom fields compatible with TelecomProtocol: |
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
Source code in ccdakit/utils/test_data.py
generate_patient()
¶
Generate realistic patient demographics.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing patient demographic data compatible with PatientProtocol: |
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
Source code in ccdakit/utils/test_data.py
generate_problem()
¶
Generate a realistic clinical problem/condition.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing problem data compatible with ProblemProtocol: |
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
Source code in ccdakit/utils/test_data.py
generate_medication()
¶
Generate a realistic medication.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing medication data compatible with MedicationProtocol: |
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
Source code in ccdakit/utils/test_data.py
generate_allergy()
¶
Generate a realistic allergy.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing allergy data compatible with AllergyProtocol: |
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
Source code in ccdakit/utils/test_data.py
generate_vital_signs(count=None)
¶
Generate realistic vital signs readings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
count
|
Optional[int]
|
Number of vital signs to generate. If None, generates 3-6 signs. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing vital signs data compatible with VitalSignsOrganizerProtocol: |
dict[str, Any]
|
|
dict[str, Any]
|
|
Source code in ccdakit/utils/test_data.py
generate_immunization()
¶
Generate a realistic immunization record.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing immunization data compatible with ImmunizationProtocol: |
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
Source code in ccdakit/utils/test_data.py
generate_complete_patient_record(num_problems=3, num_medications=2, num_allergies=2, num_vital_signs_sets=1, num_immunizations=3)
¶
Generate a complete patient record with all clinical data.
This method generates a comprehensive patient record including demographics and all major clinical sections: problems, medications, allergies, vital signs, and immunizations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_problems
|
int
|
Number of problems to generate (default: 3) |
3
|
num_medications
|
int
|
Number of medications to generate (default: 2) |
2
|
num_allergies
|
int
|
Number of allergies to generate (default: 2) |
2
|
num_vital_signs_sets
|
int
|
Number of vital signs observation sets (default: 1) |
1
|
num_immunizations
|
int
|
Number of immunizations to generate (default: 3) |
3
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing complete patient record: |
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
Source code in ccdakit/utils/test_data.py
Builders Utilities¶
SimplePatientBuilder
¶
Fluent API for building patient data that satisfies PatientProtocol.
This builder creates dictionary-based patient data with a fluent interface. The resulting dictionary can be converted to a class instance that satisfies the PatientProtocol.
Example
patient = ( ... SimplePatientBuilder() ... .name("John", "Doe", "Q") ... .birth_date(date(1970, 5, 15)) ... .gender("M") ... .race("2106-3") # White (CDC Race Code) ... .ethnicity("2186-5") # Not Hispanic or Latino ... .language("eng") ... .ssn("123-45-6789") ... .marital_status("M") # Married ... .address("123 Main St", "Boston", "MA", "02101") ... .phone("617-555-1234", "home") ... .email("[email protected]", "home") ... .build() ... )
Source code in ccdakit/utils/builders.py
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 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 | |
Functions¶
__init__()
¶
name(first, last, middle=None)
¶
Set patient name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
first
|
str
|
First name |
required |
last
|
str
|
Last name |
required |
middle
|
Optional[str]
|
Middle name or initial (optional) |
None
|
Returns:
| Type | Description |
|---|---|
SimplePatientBuilder
|
Self for method chaining |
Source code in ccdakit/utils/builders.py
birth_date(birth_date)
¶
Set date of birth.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
birth_date
|
date
|
Patient's date of birth |
required |
Returns:
| Type | Description |
|---|---|
SimplePatientBuilder
|
Self for method chaining |
gender(sex)
¶
Set administrative sex.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sex
|
str
|
Administrative sex code ('M', 'F', or 'UN') |
required |
Returns:
| Type | Description |
|---|---|
SimplePatientBuilder
|
Self for method chaining |
race(race_code)
¶
Set race code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
race_code
|
str
|
CDC Race and Ethnicity code (e.g., '2106-3' for White) |
required |
Returns:
| Type | Description |
|---|---|
SimplePatientBuilder
|
Self for method chaining |
Source code in ccdakit/utils/builders.py
ethnicity(ethnicity_code)
¶
Set ethnicity code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ethnicity_code
|
str
|
CDC Race and Ethnicity code (e.g., '2186-5' for Not Hispanic or Latino) |
required |
Returns:
| Type | Description |
|---|---|
SimplePatientBuilder
|
Self for method chaining |
Source code in ccdakit/utils/builders.py
language(language_code)
¶
Set preferred language.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
language_code
|
str
|
ISO 639-2 language code (e.g., 'eng' for English) |
required |
Returns:
| Type | Description |
|---|---|
SimplePatientBuilder
|
Self for method chaining |
Source code in ccdakit/utils/builders.py
ssn(ssn)
¶
Set Social Security Number or national ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ssn
|
str
|
Social Security Number or national ID |
required |
Returns:
| Type | Description |
|---|---|
SimplePatientBuilder
|
Self for method chaining |
Source code in ccdakit/utils/builders.py
marital_status(status)
¶
Set marital status.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status
|
str
|
HL7 MaritalStatus code (e.g., 'M' for Married, 'S' for Single) |
required |
Returns:
| Type | Description |
|---|---|
SimplePatientBuilder
|
Self for method chaining |
Source code in ccdakit/utils/builders.py
address(street, city, state, zip_code, country='US', street2=None)
¶
Add an address.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
street
|
str
|
Street address line 1 |
required |
city
|
str
|
City name |
required |
state
|
str
|
State/province code (e.g., 'MA', 'CA') |
required |
zip_code
|
str
|
ZIP/postal code |
required |
country
|
str
|
Country code (ISO 3166-1 alpha-2, default: 'US') |
'US'
|
street2
|
Optional[str]
|
Street address line 2 (optional) |
None
|
Returns:
| Type | Description |
|---|---|
SimplePatientBuilder
|
Self for method chaining |
Source code in ccdakit/utils/builders.py
phone(number, use='home')
¶
Add a phone number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
number
|
str
|
Phone number |
required |
use
|
str
|
Use code ('home', 'work', 'mobile') |
'home'
|
Returns:
| Type | Description |
|---|---|
SimplePatientBuilder
|
Self for method chaining |
Source code in ccdakit/utils/builders.py
email(email, use='home')
¶
Add an email address.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
email
|
str
|
Email address |
required |
use
|
str
|
Use code ('home', 'work') |
'home'
|
Returns:
| Type | Description |
|---|---|
SimplePatientBuilder
|
Self for method chaining |
Source code in ccdakit/utils/builders.py
build()
¶
Build patient data dictionary.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary containing all patient data |
SimpleProblemBuilder
¶
Fluent API for building problem/condition data that satisfies ProblemProtocol.
Example
problem = ( ... SimpleProblemBuilder() ... .name("Essential Hypertension") ... .code("59621000", "SNOMED") ... .status("active") ... .onset_date(date(2018, 5, 10)) ... .build() ... )
Source code in ccdakit/utils/builders.py
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 | |
Functions¶
__init__()
¶
name(problem_name)
¶
Set problem name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem_name
|
str
|
Human-readable problem name |
required |
Returns:
| Type | Description |
|---|---|
SimpleProblemBuilder
|
Self for method chaining |
code(code, code_system)
¶
Set problem code and code system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
Problem code (SNOMED CT or ICD-10) |
required |
code_system
|
str
|
Code system name ('SNOMED' or 'ICD-10') |
required |
Returns:
| Type | Description |
|---|---|
SimpleProblemBuilder
|
Self for method chaining |
Source code in ccdakit/utils/builders.py
status(status)
¶
Set problem status.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status
|
str
|
Status ('active', 'inactive', 'resolved') |
required |
Returns:
| Type | Description |
|---|---|
SimpleProblemBuilder
|
Self for method chaining |
onset_date(onset)
¶
Set onset date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
onset
|
date
|
Date problem was identified/started |
required |
Returns:
| Type | Description |
|---|---|
SimpleProblemBuilder
|
Self for method chaining |
resolved_date(resolved)
¶
Set resolved date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resolved
|
date
|
Date problem was resolved |
required |
Returns:
| Type | Description |
|---|---|
SimpleProblemBuilder
|
Self for method chaining |
Source code in ccdakit/utils/builders.py
persistent_id(root, extension)
¶
Set persistent identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
str
|
OID or UUID identifying the assigning authority |
required |
extension
|
str
|
Unique identifier within the root's namespace |
required |
Returns:
| Type | Description |
|---|---|
SimpleProblemBuilder
|
Self for method chaining |
Source code in ccdakit/utils/builders.py
build()
¶
Build problem data dictionary.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary containing all problem data |
SimpleMedicationBuilder
¶
Fluent API for building medication data that satisfies MedicationProtocol.
Example
medication = ( ... SimpleMedicationBuilder() ... .name("Lisinopril 10mg oral tablet") ... .code("314076") # RxNorm code ... .dosage("10 mg") ... .route("oral") ... .frequency("once daily") ... .start_date(date(2018, 6, 1)) ... .status("active") ... .instructions("Take in the morning") ... .build() ... )
Source code in ccdakit/utils/builders.py
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 | |
Functions¶
__init__()
¶
name(medication_name)
¶
Set medication name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
medication_name
|
str
|
Human-readable medication name |
required |
Returns:
| Type | Description |
|---|---|
SimpleMedicationBuilder
|
Self for method chaining |
Source code in ccdakit/utils/builders.py
code(rxnorm_code)
¶
Set RxNorm code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rxnorm_code
|
str
|
RxNorm code for the medication |
required |
Returns:
| Type | Description |
|---|---|
SimpleMedicationBuilder
|
Self for method chaining |
dosage(dosage_amount)
¶
Set dosage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dosage_amount
|
str
|
Dosage amount (e.g., "10 mg", "1 tablet") |
required |
Returns:
| Type | Description |
|---|---|
SimpleMedicationBuilder
|
Self for method chaining |
Source code in ccdakit/utils/builders.py
route(route_of_admin)
¶
Set route of administration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
route_of_admin
|
str
|
Route (e.g., "oral", "IV", "topical") |
required |
Returns:
| Type | Description |
|---|---|
SimpleMedicationBuilder
|
Self for method chaining |
Source code in ccdakit/utils/builders.py
frequency(freq)
¶
Set frequency of administration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
freq
|
str
|
Frequency (e.g., "twice daily", "every 6 hours") |
required |
Returns:
| Type | Description |
|---|---|
SimpleMedicationBuilder
|
Self for method chaining |
Source code in ccdakit/utils/builders.py
start_date(start)
¶
Set start date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
date
|
Date medication was started |
required |
Returns:
| Type | Description |
|---|---|
SimpleMedicationBuilder
|
Self for method chaining |
end_date(end)
¶
Set end date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
end
|
date
|
Date medication was stopped |
required |
Returns:
| Type | Description |
|---|---|
SimpleMedicationBuilder
|
Self for method chaining |
status(status)
¶
Set medication status.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status
|
str
|
Status ('active', 'completed', 'discontinued') |
required |
Returns:
| Type | Description |
|---|---|
SimpleMedicationBuilder
|
Self for method chaining |
Source code in ccdakit/utils/builders.py
instructions(patient_instructions)
¶
Set patient instructions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
patient_instructions
|
str
|
Instructions for patient |
required |
Returns:
| Type | Description |
|---|---|
SimpleMedicationBuilder
|
Self for method chaining |
Source code in ccdakit/utils/builders.py
build()
¶
Build medication data dictionary.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary containing all medication data |
Converters¶
Conversion utilities are available in ccdakit.utils.converters module.
Templates¶
Template utilities are available in ccdakit.utils.templates module.
Factories¶
Factory utilities are available in ccdakit.utils.factories module.
See the source code for detailed documentation of these utility modules.