Builders API Reference¶
Document and common builders.
Document Builder¶
ClinicalDocument
¶
Bases: CDAElement
Top-level C-CDA Clinical Document builder.
Functions¶
__init__(patient, author, custodian, sections=None, document_id=None, title='Clinical Summary', effective_time=None, **kwargs)
¶
Initialize ClinicalDocument builder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
patient
|
PatientProtocol
|
Patient data satisfying PatientProtocol |
required |
author
|
AuthorProtocol
|
Author data satisfying AuthorProtocol |
required |
custodian
|
OrganizationProtocol
|
Custodian organization data satisfying OrganizationProtocol |
required |
sections
|
Optional[Sequence[CDAElement]]
|
List of section builders (optional) |
None
|
document_id
|
Optional[str]
|
Document UUID (generated if not provided) |
None
|
title
|
str
|
Document title |
'Clinical Summary'
|
effective_time
|
Optional[datetime]
|
Document creation time (current time if not provided) |
None
|
**kwargs
|
Additional arguments passed to CDAElement |
{}
|
build()
¶
Build ClinicalDocument XML element.
Returns:
| Type | Description |
|---|---|
Element
|
lxml Element for ClinicalDocument |
to_xml_string(pretty=True)
¶
Convert to XML string with declaration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pretty
|
bool
|
Whether to pretty-print XML |
True
|
Returns:
| Type | Description |
|---|---|
str
|
Complete XML document with declaration |
Common Builders¶
Code
¶
Bases: CDAElement
Reusable code element builder.
Source code in ccdakit/builders/common.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 | |
Functions¶
__init__(code=None, system=None, display_name=None, null_flavor=None, **kwargs)
¶
Initialize Code builder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
Optional[str]
|
Code value |
None
|
system
|
Optional[str]
|
Code system (name or OID) |
None
|
display_name
|
Optional[str]
|
Human-readable display name |
None
|
null_flavor
|
Optional[str]
|
Null flavor if code is not available |
None
|
**kwargs
|
Additional arguments passed to CDAElement |
{}
|
Source code in ccdakit/builders/common.py
build()
¶
Build code XML element.
Returns:
| Type | Description |
|---|---|
Element
|
lxml Element for code |
Raises:
| Type | Description |
|---|---|
ValueError
|
If both code and null_flavor are missing |
Source code in ccdakit/builders/common.py
EffectiveTime
¶
Bases: CDAElement
Reusable effectiveTime element with support for points and intervals.
Source code in ccdakit/builders/common.py
Functions¶
__init__(value=None, low=None, high=None, null_flavor=None, **kwargs)
¶
Initialize EffectiveTime builder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Optional[datetime]
|
Point in time |
None
|
low
|
Optional[datetime]
|
Start of interval |
None
|
high
|
Optional[datetime]
|
End of interval |
None
|
null_flavor
|
Optional[str]
|
Null flavor if time is not available |
None
|
**kwargs
|
Additional arguments passed to CDAElement |
{}
|
Source code in ccdakit/builders/common.py
build()
¶
Build effectiveTime XML element.
Returns:
| Type | Description |
|---|---|
Element
|
lxml Element for effectiveTime |
Source code in ccdakit/builders/common.py
Identifier
¶
Bases: CDAElement
Reusable ID element builder.
Source code in ccdakit/builders/common.py
Functions¶
__init__(root, extension=None, null_flavor=None, **kwargs)
¶
Initialize Identifier builder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
str
|
OID or UUID root |
required |
extension
|
Optional[str]
|
Extension within the root namespace |
None
|
null_flavor
|
Optional[str]
|
Null flavor if ID is not available |
None
|
**kwargs
|
Additional arguments passed to CDAElement |
{}
|
Source code in ccdakit/builders/common.py
build()
¶
Build id XML element.
Returns:
| Type | Description |
|---|---|
Element
|
lxml Element for id |
Source code in ccdakit/builders/common.py
StatusCode
¶
Bases: CDAElement
Reusable statusCode element builder.
Source code in ccdakit/builders/common.py
Functions¶
__init__(code, **kwargs)
¶
Initialize StatusCode builder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
Status code value (e.g., 'completed', 'active') |
required |
**kwargs
|
Additional arguments passed to CDAElement |
{}
|
Source code in ccdakit/builders/common.py
build()
¶
Build statusCode XML element.
Returns:
| Type | Description |
|---|---|
Element
|
lxml Element for statusCode |
Demographic Builders¶
Address
¶
Bases: CDAElement
Builder for CDA address elements.
Source code in ccdakit/builders/demographics.py
Functions¶
__init__(address, use=None, **kwargs)
¶
Initialize Address builder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
address
|
AddressProtocol
|
Address data satisfying AddressProtocol |
required |
use
|
str
|
Use code ('home', 'work', etc.) or HL7 code directly |
None
|
**kwargs
|
Additional arguments passed to CDAElement |
{}
|
Source code in ccdakit/builders/demographics.py
build()
¶
Build address XML element.
Returns:
| Type | Description |
|---|---|
Element
|
lxml Element for addr |
Source code in ccdakit/builders/demographics.py
Telecom
¶
Bases: CDAElement
Builder for CDA telecom (contact) elements.
Source code in ccdakit/builders/demographics.py
|
Functions¶
__init__(telecom, **kwargs)
¶
Initialize Telecom builder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
telecom
|
TelecomProtocol
|
Telecom data satisfying TelecomProtocol |
required |
**kwargs
|
Additional arguments passed to CDAElement |
{}
|
Source code in ccdakit/builders/demographics.py
build()
¶
Build telecom XML element.
Returns:
| Type | Description |
|---|---|
Element
|
lxml Element for telecom |
Source code in ccdakit/builders/demographics.py
Header Builders¶
Header builders are used internally by the ClinicalDocument builder.
See the ClinicalDocument API for usage.