Skip to content

Commit 0c0b64c

Browse files
authored
Merge pull request #865 from raymond-rebbeck/main
Attempt to parse HL7 and LUT files to determine their internal name
2 parents 18999e9 + 28decac commit 0c0b64c

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515
### Fixed
1616
- When cloning a repo with Configure, that repo's embedded-git-config file will overwrite previous settings (#819)
1717
- Settings page no longer removes remote when saving after cloning (#858)
18+
- Fixed import of HL7 and LUT files added at the same time as their mappings (#864)
1819

1920
## [2.13.1] - 2025-09-16
2021

cls/SourceControl/Git/File.cls

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ ClassMethod ExternalNameToInternalName(ExternalName As %String) As %String
3535
}
3636
new %SourceControl //don't trigger source hooks with this test load to get the Name
3737
set sc=$system.OBJ.Load(ExternalName,"-d",,.outName,1)
38+
// If the test load was unsuccessful then it may be due to an unsupported
39+
// file type (e.g. hl7 or lut) that we may otherwise be able to handle
40+
if $$$ISERR(sc) {
41+
set outName = ..ParseFileForInternalName(ExternalName)
42+
}
3843
set itemIsPTD = 0
3944
if $data(outName) = 11 {
4045
set key = $order(outName(""))
@@ -59,6 +64,40 @@ ClassMethod ExternalNameToInternalName(ExternalName As %String) As %String
5964
quit internalName
6065
}
6166

67+
/// Attempt to determine the internal name of a given file based on its content
68+
/// Intended to be used in situations where $system.OBJ.Load is unable to
69+
ClassMethod ParseFileForInternalName(fileName As %String) As %String [ Private ]
70+
{
71+
Set internalName = ""
72+
73+
Set fileExtension = $ZCONVERT($PIECE(fileName,".",*),"U")
74+
If (fileExtension = "HL7") {
75+
Set tSC = ##class(%XML.TextReader).ParseFile(fileName, .textReader)
76+
If ($$$ISOK(tSC)) {
77+
// The HL7 schema name is in the 'name' attribute of the 'Category' element
78+
// Example: <Category name="...">
79+
If (textReader.ReadStartElement("Category") && textReader.MoveToAttributeName("name")) {
80+
If (textReader.Value '= "") {
81+
Set internalName = textReader.Value_"."_fileExtension
82+
}
83+
}
84+
}
85+
} ElseIf (fileExtension = "LUT") {
86+
Set tSC = ##class(%XML.TextReader).ParseFile(fileName, .textReader)
87+
If $$$ISOK(tSC) {
88+
// The lookup table name is in the 'table' attribute of any 'entry' element
89+
// Example: <entry table="...">
90+
If (textReader.ReadStartElement("entry") && textReader.MoveToAttributeName("table")) {
91+
If (textReader.Value '= "") {
92+
Set internalName = textReader.Value_"."_fileExtension
93+
}
94+
}
95+
}
96+
}
97+
98+
Quit internalName
99+
}
100+
62101
Storage Default
63102
{
64103
<Data name="FileDefaultData">

0 commit comments

Comments
 (0)