diff --git a/PROMS/VEPROMS User Interface/dlgExportImport.cs b/PROMS/VEPROMS User Interface/dlgExportImport.cs index e5ff639a..d18edc30 100644 --- a/PROMS/VEPROMS User Interface/dlgExportImport.cs +++ b/PROMS/VEPROMS User Interface/dlgExportImport.cs @@ -36,6 +36,10 @@ namespace VEPROMS private bool _DidConvertROsToText = false; private bool _DidUCF = false; + //C2025-024 Proms EP XML Output + //this will hold if a specific unit was selected + protected int _UnitIndex = 0; + private ItemInfo _ExternalTransitionItem = null; public ItemInfo ExternalTransitionItem { @@ -62,9 +66,9 @@ namespace VEPROMS } private string PEIPath; private string _MyMode; - private FolderInfo MyFolder = null; - private DocVersionInfo MyDocVersion = null; - private ProcedureInfo MyProcedure = null; + protected FolderInfo MyFolder = null; + protected DocVersionInfo MyDocVersion = null; + protected ProcedureInfo MyProcedure = null; protected XmlAttribute AddAttribute(XmlDocument xd, string name, string value) { XmlAttribute xa = xd.CreateAttribute(name); @@ -1885,8 +1889,13 @@ namespace VEPROMS UserID */ XmlElement xe = xn.OwnerDocument.CreateElement(nodename); - // strip the link information if we are convertingthe RO and Transitions to text - string ciText = (_ConvertROsAndTransitionsToText) ? ItemInfo.StripLinks(ci.Text) : ci.Text; + + //C2025-024 PROMS EP XML output + //if multiunit with ROs, need to actually resolve those / not just strip links + string ciText = ResolveMultiUnitROs(ci); + + // strip the link information if we are converting the RO and Transitions to text + ciText = _ConvertROsAndTransitionsToText ? ItemInfo.StripLinks(ciText) : ciText; string formatFileName = (ci.MyFormat != null) ? ci.MyFormat.Name : ""; xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "contentid", ci.ContentID.ToString())); @@ -1926,7 +1935,51 @@ namespace VEPROMS ExportPart(xe, pi, ((E_FromTypes)pi.FromType).ToString().ToLower()); } - private void ExportContentAudits(XmlElement xn, ContentInfo ci) + //C2025-024 PROMS Electronic Procedure XML output + //if multi unit with ROs, need to actually resolve those / not just strip links + private string ResolveMultiUnitROs(ContentInfo ci) + { + string ciText = ci.Text; + + if (_UnitIndex != 0 && ci.ContentRoUsageCount > 0) + { + ROFSTLookup lookup = null; + if (MyProcedure?.MyDocVersion != null) + { + lookup = MyProcedure.MyDocVersion.DocVersionAssociations[0].MyROFst.GetROFSTLookup(MyProcedure.MyDocVersion); + } + else if (MyDocVersion != null) + { + lookup = MyDocVersion.DocVersionAssociations[0].MyROFst.GetROFSTLookup(MyDocVersion); + } + else if (MyFolder.FolderDocVersions != null && MyFolder.FolderDocVersions.Count > 0) + { + lookup = MyFolder.FolderDocVersions[0].DocVersionAssociations[0].MyROFst.GetROFSTLookup(MyFolder.FolderDocVersions[0]); + } + + if (lookup != null) + { + foreach (var RO in ci.ContentRoUsages) + { + string roid = ROFSTLookup.FormatRoidKey(RO.ROID, true); + ROFSTLookup.rochild roc = lookup.GetRoChild(roid); + //need to search / replace in content info + string lookFor = string.Format(@"()", RO.ROUsageID); + Match m = Regex.Match(ciText, lookFor, RegexOptions.Singleline); + if (m != null && m.Groups.Count > 1) + { + ciText = ciText.Replace($"{m.Groups[1].Value}{m.Groups[5].Value}{m.Groups[6].Value}", $"{m.Groups[1].Value}{roc.value}{m.Groups[6].Value}"); + } + } + } + + } + + + return ciText; + } + + private void ExportContentAudits(XmlElement xn, ContentInfo ci) { if (cbxExportAudits.Checked) { diff --git a/PROMS/VEPROMS User Interface/dlgExportImportEP.cs b/PROMS/VEPROMS User Interface/dlgExportImportEP.cs index 4f7d0887..c13203e5 100644 --- a/PROMS/VEPROMS User Interface/dlgExportImportEP.cs +++ b/PROMS/VEPROMS User Interface/dlgExportImportEP.cs @@ -17,31 +17,48 @@ namespace VEPROMS #pragma warning restore S101 // Types should be named in PascalCase { private readonly AnnotationTypeInfo _AnnotationType; - private readonly int _UnitIndex; private readonly string multiseparator = ","; private static Regex _ROAccPageTokenPattern = new Regex("[<][^<>-]+-[^<>]+[>]"); - public dlgExportImportEP(string mode, FolderInfo folderInfo, frmVEPROMS myFrmVEPROMS, int annotationTypeId, int unitIndex) : base(mode, folderInfo, myFrmVEPROMS, (E_UCFImportOptions) 0) + public dlgExportImportEP(string mode, FolderInfo folderInfo, frmVEPROMS myFrmVEPROMS, int annotationTypeId, int unitIndex) : base(mode, folderInfo, myFrmVEPROMS, (E_UCFImportOptions)0) { - _AnnotationType = AnnotationTypeInfo.Get(annotationTypeId); - _UnitIndex = unitIndex; - _ExportBothConvertedandNot = true; - DocReplace = new Dictionary(); - FormClosed += OnClose; - Text = $"{mode} Electronic Procedure ({_AnnotationType.Name}) Dialog for {folderInfo.Name}"; - } + _AnnotationType = AnnotationTypeInfo.Get(annotationTypeId); + _UnitIndex = unitIndex; + _ExportBothConvertedandNot = true; + DocReplace = new Dictionary(); + FormClosed += OnClose; + Text = $"{mode} Electronic Procedure ({_AnnotationType.Name}) Dialog for {folderInfo.Name}"; - public dlgExportImportEP(string mode, DocVersionInfo docVersionInfo, frmVEPROMS myFrmVEPROMS, int annotationTypeId, int unitIndex) : base(mode, docVersionInfo, myFrmVEPROMS, (E_UCFImportOptions)0) - { - _AnnotationType = AnnotationTypeInfo.Get(annotationTypeId); - _UnitIndex = unitIndex; - _ExportBothConvertedandNot = true; - DocReplace = new Dictionary(); - FormClosed += OnClose; - Text = $"{mode} Electronic Procedure ({_AnnotationType.Name}) Dialog for {docVersionInfo.Name} of {docVersionInfo.MyFolder.Name}"; + if (_UnitIndex > 0) + { + foreach (DocVersionInfo docver in MyFolder.FolderDocVersions) + { + docver.DocVersionConfig.SelectedSlave = _UnitIndex; + + foreach (ItemInfo proc in docver.Procedures) + proc.MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave = _UnitIndex; + } + } } - public dlgExportImportEP(string mode, ProcedureInfo procedureInfo, frmVEPROMS myFrmVEPROMS, int annotationTypeId, int unitIndex) : base(mode, procedureInfo, myFrmVEPROMS, (E_UCFImportOptions)0) + public dlgExportImportEP(string mode, DocVersionInfo docVersionInfo, frmVEPROMS myFrmVEPROMS, int annotationTypeId, int unitIndex) : base(mode, docVersionInfo, myFrmVEPROMS, (E_UCFImportOptions)0) + { + _AnnotationType = AnnotationTypeInfo.Get(annotationTypeId); + _UnitIndex = unitIndex; + _ExportBothConvertedandNot = true; + DocReplace = new Dictionary(); + FormClosed += OnClose; + Text = $"{mode} Electronic Procedure ({_AnnotationType.Name}) Dialog for {docVersionInfo.Name} of {docVersionInfo.MyFolder.Name}"; + + if (_UnitIndex > 0) + { + MyDocVersion.DocVersionConfig.SelectedSlave = _UnitIndex; + + foreach (ItemInfo proc in MyDocVersion.Procedures) + proc.MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave = _UnitIndex; + } + } + public dlgExportImportEP(string mode, ProcedureInfo procedureInfo, frmVEPROMS myFrmVEPROMS, int annotationTypeId, int unitIndex) : base(mode, procedureInfo, myFrmVEPROMS, (E_UCFImportOptions)0) { _AnnotationType = AnnotationTypeInfo.Get(annotationTypeId); _UnitIndex = unitIndex; @@ -49,6 +66,13 @@ namespace VEPROMS DocReplace = new Dictionary(); FormClosed += OnClose; Text = $"{mode} Electronic Procedure ({_AnnotationType.Name}) Dialog for {procedureInfo.DisplayNumber}"; + + if (_UnitIndex > 0) + { + MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave = _UnitIndex; + MyProcedure.MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave = _UnitIndex; + } + } //Overridden function to handle export of EP data @@ -320,8 +344,32 @@ namespace VEPROMS } //clear objects to release memory + //and unset the unit (SelectedSlave) private void OnClose(object sender, EventArgs e) { + if (MyProcedure != null) + { + MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave = 0; + MyProcedure.MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave = 0; + } + if (MyDocVersion != null) + { + MyDocVersion.DocVersionConfig.SelectedSlave = 0; + + foreach (ItemInfo proc in MyDocVersion.Procedures) + proc.MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave = _UnitIndex; + } + if (MyFolder != null) + { + foreach (DocVersionInfo docver in MyFolder.FolderDocVersions) + { + docver.DocVersionConfig.SelectedSlave = _UnitIndex; + + foreach (ItemInfo proc in docver.Procedures) + proc.MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave = _UnitIndex; + } + } + DocReplace.Clear(); DocReplace = null; }