diff --git a/CHANGELOG.md b/CHANGELOG.md index 85abb2a6..effe4b5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - When cloning a repo with Configure, that repo's embedded-git-config file will overwrite previous settings (#819) - Settings page no longer removes remote when saving after cloning (#858) +- Fixed import of HL7 and LUT files added at the same time as their mappings (#864) ## [2.13.1] - 2025-09-16 diff --git a/cls/SourceControl/Git/File.cls b/cls/SourceControl/Git/File.cls index 9ace3374..caaece98 100644 --- a/cls/SourceControl/Git/File.cls +++ b/cls/SourceControl/Git/File.cls @@ -35,6 +35,11 @@ ClassMethod ExternalNameToInternalName(ExternalName As %String) As %String } new %SourceControl //don't trigger source hooks with this test load to get the Name set sc=$system.OBJ.Load(ExternalName,"-d",,.outName,1) + // If the test load was unsuccessful then it may be due to an unsupported + // file type (e.g. hl7 or lut) that we may otherwise be able to handle + if $$$ISERR(sc) { + set outName = ..ParseFileForInternalName(ExternalName) + } set itemIsPTD = 0 if $data(outName) = 11 { set key = $order(outName("")) @@ -59,6 +64,40 @@ ClassMethod ExternalNameToInternalName(ExternalName As %String) As %String quit internalName } +/// Attempt to determine the internal name of a given file based on its content +/// Intended to be used in situations where $system.OBJ.Load is unable to +ClassMethod ParseFileForInternalName(fileName As %String) As %String [ Private ] +{ + Set internalName = "" + + Set fileExtension = $ZCONVERT($PIECE(fileName,".",*),"U") + If (fileExtension = "HL7") { + Set tSC = ##class(%XML.TextReader).ParseFile(fileName, .textReader) + If ($$$ISOK(tSC)) { + // The HL7 schema name is in the 'name' attribute of the 'Category' element + // Example: + If (textReader.ReadStartElement("Category") && textReader.MoveToAttributeName("name")) { + If (textReader.Value '= "") { + Set internalName = textReader.Value_"."_fileExtension + } + } + } + } ElseIf (fileExtension = "LUT") { + Set tSC = ##class(%XML.TextReader).ParseFile(fileName, .textReader) + If $$$ISOK(tSC) { + // The lookup table name is in the 'table' attribute of any 'entry' element + // Example: + If (textReader.ReadStartElement("entry") && textReader.MoveToAttributeName("table")) { + If (textReader.Value '= "") { + Set internalName = textReader.Value_"."_fileExtension + } + } + } + } + + Quit internalName +} + Storage Default {