Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
07b5c56
Initial checkin
BradySkylight Mar 23, 2026
701643c
added more details to enum for applications - added and updated funct…
BradySkylight Mar 24, 2026
1413515
Update augmenter.py
BradySkylight Mar 24, 2026
f914554
fixed enum model and added some tests
BradySkylight Mar 24, 2026
d978720
update samples - add comments - update tests
BradySkylight Mar 24, 2026
ce6f716
Update augmenter.py
BradySkylight Mar 24, 2026
98c69f3
fixed types and type for system - fixed tests
BradySkylight Mar 24, 2026
15b0582
Merge branch 'main' into brady/363/augmentation-update
BradySkylight Mar 24, 2026
fad6d60
Updated Comments
BradySkylight Mar 25, 2026
087cb7b
Update application.py
BradySkylight Mar 25, 2026
f016eaa
Update augmenter.py
BradySkylight Mar 25, 2026
7a734f6
Merge branch 'main' into brady/363/augmentation-update
BradySkylight Mar 25, 2026
ee562d8
Merge branch 'main' into brady/363/augmentation-update
BradySkylight Mar 25, 2026
65462bc
fixed issues based upon PR feedback
BradySkylight Mar 26, 2026
f76196c
Update application.py
BradySkylight Mar 26, 2026
a87e502
Update application.py
BradySkylight Mar 26, 2026
474c3cf
fixed typing issues with enum for applications
BradySkylight Mar 26, 2026
afa8596
add new input that is defined for the enum to solve typing issue
BradySkylight Mar 26, 2026
feac0a4
Update application.py
BradySkylight Mar 26, 2026
d24d786
Merge branch 'main' into brady/363/augmentation-update
BradySkylight Mar 26, 2026
2d55fe1
Merge branch 'main' into brady/363/augmentation-update
BradySkylight Mar 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion packages/augmentation/src/augmentation/models/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,18 @@
class ApplicationCode(StrEnum):
"""The list of applications that will leveraging Augmentation functionality."""

TEXT_TO_CODE = "text-to-code"
# element 0 - Application Code
# element 1 - Application Code Display Name (for human readability)
TEXT_TO_CODE = ("text-to-code", "Text-to-Code")

def __new__(cls, code: str, display: str) -> "ApplicationCode":
"""Create a new instance of the ApplicationCode enum with code and display attributes."""
# use the base type's __new__ to create the enum instance
obj = str.__new__(cls, code)
obj._value_ = code
obj.display = display
obj.code = code
return obj


class NonstandardCodeInstanceMetadata(NonstandardCodeInstance):
Expand Down
2 changes: 1 addition & 1 deletion packages/augmentation/src/augmentation/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class TTCAugmenterConfig(AugmenterConfig):
}
# TODO: The function code is currently a constant (used for both lab orders and results), but will need to be dynamic when additional fields with different function codes are introduced.
author_function_code: str = "code-text-to-code"
author_function_code_system: str = "2.16.840.1.113663.10.20.15.2.7.1"
author_function_code_system: str = "2.16.840.1.113883.10.20.15.2.7.1"
author_function_code_system_name: str = "eCRDataAugmentation"

@model_validator(mode="after")
Expand Down
11 changes: 10 additions & 1 deletion packages/augmentation/src/augmentation/services/augmenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,16 @@ def document_payload_not_none(cls, v: str) -> Element:
return clean_xml_tree(v)

def _get_application_code_value(self) -> str:
return self.application_code.value
# added this check to satisfy the type checker
if hasattr(self.application_code, "code"):
return self.application_code.code
raise Exception("we will never return an ''")

def _get_application_code_display(self) -> str:
# added this check to satisfy the type checker
if hasattr(self.application_code, "display"):
return self.application_code.display
raise Exception("we will never return an ''")

@abstractmethod
def augment(self) -> Metadata:
Expand Down
30 changes: 14 additions & 16 deletions packages/augmentation/src/augmentation/services/eicr_augmenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,24 +229,15 @@ def _get_old_xrfm_related_document(self) -> Element | None:
def _generate_author(self, level: str = "header") -> Element:
null_flavor_comment = " set to nullFlavor 'NA' "
author = etree.Element("author")
function_code = etree.SubElement(author, "functionCode")
function_code.set("code", value=self.config.author_function_code)
function_code.set("codeSystem", value=self.config.author_function_code_system)
function_code.set("codeSystemName", value=self.config.author_function_code_system_name)
# TODO: Eventually we wwill not only separate by header vs. data_element
# TODO: Eventually we will not only separate by header vs. data_element
# but will also separate out the various comments by the various data element
# type being modified. This can easily be stored in the model for the data elemnts
# For now we are hard coding for code-text-to-code and observation in the comment
if level == "header":
self._add_previous_element_comment(
(
"functionCode specifies type of change "
"'text-to-code' which signifies this document has been transformed using the "
"text-to-code data augmentation tool "
),
function_code,
)
else:
if level != "header":
function_code = etree.SubElement(author, "functionCode")
function_code.set("code", value=self.config.author_function_code)
function_code.set("codeSystem", value=self.config.author_function_code_system)
function_code.set("codeSystemName", value=self.config.author_function_code_system_name)
self._add_previous_element_comment(
(
"functionCode specifies type of change "
Expand Down Expand Up @@ -283,7 +274,14 @@ def _generate_author(self, level: str = "header") -> Element:
" set to 'Data Augmentation Tool' ", assigned_authoring_device
)
software_name = etree.SubElement(assigned_authoring_device, "softwareName")
software_name.set("displayName", "Data Augmentation Tool")
software_name.set("code", value=self._get_application_code_value())
software_name.set("codeSystem", value=self.config.author_function_code_system)
software_name.set("codeSystemName", value=self.config.author_function_code_system_name)
software_name.set("displayName", self._get_application_code_display())
self._add_previous_element_comment(
" assignedAuthoringDevice/softwareName specifies that this document has been transformed using the Text-to-Code data augmentation tool",
software_name,
)

return author

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</code>
<author>
<!--DATA AUGMENTATION: functionCode specifies type of change 'code-text-to-code' which signifies that the code in this observation has been augmented with a code derived from the text in the code element -->
<functionCode code="code-text-to-code" codeSystem="2.16.840.1.113663.10.20.15.2.7.1" codeSystemName="eCRDataAugmentation"/>
<functionCode code="code-text-to-code" codeSystem="2.16.840.1.113883.10.20.15.2.7.1" codeSystemName="eCRDataAugmentation"/>
<!--DATA AUGMENTATION: time of data augmentation operation -->
<effectiveTime value="20260213152757"/>
<assignedAuthor>
Expand All @@ -40,7 +40,8 @@
<telecom nullFlavor="NA"/>
<!--DATA AUGMENTATION: set to 'Data Augmentation Tool' -->
<assignedAuthoringDevice>
<softwareName displayName="Data Augmentation Tool"/>
<!--DATA AUGMENTATION: assignedAuthoringDevice/softwareName specifies that this document has been transformed using the Text-to-Code data augmentation tool -->
<softwareName code="text-to-code" codeSystem="2.16.840.1.113883.10.20.15.2.7.1" codeSystemName="eCRDataAugmentation" displayName="Text-to-Code"/>
</assignedAuthoringDevice>
</assignedAuthor>
</author>
Expand All @@ -64,8 +65,6 @@
</parentDocument>
</relatedDocument>
<author>
<!--DATA AUGMENTATION: functionCode specifies type of change 'text-to-code' which signifies this document has been transformed using the text-to-code data augmentation tool -->
<functionCode code="code-text-to-code" codeSystem="2.16.840.1.113663.10.20.15.2.7.1" codeSystemName="eCRDataAugmentation"/>
<!--DATA AUGMENTATION: time of data augmentation operation -->
<effectiveTime value="20260213152757"/>
<assignedAuthor>
Expand All @@ -77,7 +76,8 @@
<telecom nullFlavor="NA"/>
<!--DATA AUGMENTATION: set to 'Data Augmentation Tool' -->
<assignedAuthoringDevice>
<softwareName displayName="Data Augmentation Tool"/>
<!--DATA AUGMENTATION: assignedAuthoringDevice/softwareName specifies that this document has been transformed using the Text-to-Code data augmentation tool -->
<softwareName code="text-to-code" codeSystem="2.16.840.1.113883.10.20.15.2.7.1" codeSystemName="eCRDataAugmentation" displayName="Text-to-Code"/>
</assignedAuthoringDevice>
</assignedAuthor>
</author>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</code>
<author>
<!--DATA AUGMENTATION: functionCode specifies type of change 'code-text-to-code' which signifies that the code in this observation has been augmented with a code derived from the text in the code element -->
<functionCode code="code-text-to-code" codeSystem="2.16.840.1.113663.10.20.15.2.7.1" codeSystemName="eCRDataAugmentation"/>
<functionCode code="code-text-to-code" codeSystem="2.16.840.1.113883.10.20.15.2.7.1" codeSystemName="eCRDataAugmentation"/>
<!--DATA AUGMENTATION: time of data augmentation operation -->
<effectiveTime value="20260213152757"/>
<assignedAuthor>
Expand All @@ -47,7 +47,8 @@
<telecom nullFlavor="NA"/>
<!--DATA AUGMENTATION: set to 'Data Augmentation Tool' -->
<assignedAuthoringDevice>
<softwareName displayName="Data Augmentation Tool"/>
<!--DATA AUGMENTATION: assignedAuthoringDevice/softwareName specifies that this document has been transformed using the Text-to-Code data augmentation tool -->
<softwareName code="text-to-code" codeSystem="2.16.840.1.113883.10.20.15.2.7.1" codeSystemName="eCRDataAugmentation" displayName="Text-to-Code"/>
</assignedAuthoringDevice>
</assignedAuthor>
</author>
Expand All @@ -71,8 +72,6 @@
</parentDocument>
</relatedDocument>
<author>
<!--DATA AUGMENTATION: functionCode specifies type of change 'text-to-code' which signifies this document has been transformed using the text-to-code data augmentation tool -->
<functionCode code="code-text-to-code" codeSystem="2.16.840.1.113663.10.20.15.2.7.1" codeSystemName="eCRDataAugmentation"/>
<!--DATA AUGMENTATION: time of data augmentation operation -->
<effectiveTime value="20260213152757"/>
<assignedAuthor>
Expand All @@ -84,7 +83,8 @@
<telecom nullFlavor="NA"/>
<!--DATA AUGMENTATION: set to 'Data Augmentation Tool' -->
<assignedAuthoringDevice>
<softwareName displayName="Data Augmentation Tool"/>
<!--DATA AUGMENTATION: assignedAuthoringDevice/softwareName specifies that this document has been transformed using the Text-to-Code data augmentation tool -->
<softwareName code="text-to-code" codeSystem="2.16.840.1.113883.10.20.15.2.7.1" codeSystemName="eCRDataAugmentation" displayName="Text-to-Code"/>
</assignedAuthoringDevice>
</assignedAuthor>
</author>
Expand Down
2 changes: 2 additions & 0 deletions packages/augmentation/tests/unit/test_model_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ def test_application_code(self):
"""Basic unit test for ApplicationCode enum."""
app_enum = ApplicationCode
assert app_enum.TEXT_TO_CODE.value == "text-to-code"
assert app_enum.TEXT_TO_CODE.display == "Text-to-Code"
assert app_enum.TEXT_TO_CODE.code == "text-to-code"
Loading