C2025-024 Electronic Procedures Phase 2 - XML Export
Multi-Unit RO Resolution
This commit is contained in:
@@ -36,6 +36,10 @@ namespace VEPROMS
|
|||||||
private bool _DidConvertROsToText = false;
|
private bool _DidConvertROsToText = false;
|
||||||
private bool _DidUCF = 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;
|
private ItemInfo _ExternalTransitionItem = null;
|
||||||
public ItemInfo ExternalTransitionItem
|
public ItemInfo ExternalTransitionItem
|
||||||
{
|
{
|
||||||
@@ -62,9 +66,9 @@ namespace VEPROMS
|
|||||||
}
|
}
|
||||||
private string PEIPath;
|
private string PEIPath;
|
||||||
private string _MyMode;
|
private string _MyMode;
|
||||||
private FolderInfo MyFolder = null;
|
protected FolderInfo MyFolder = null;
|
||||||
private DocVersionInfo MyDocVersion = null;
|
protected DocVersionInfo MyDocVersion = null;
|
||||||
private ProcedureInfo MyProcedure = null;
|
protected ProcedureInfo MyProcedure = null;
|
||||||
protected XmlAttribute AddAttribute(XmlDocument xd, string name, string value)
|
protected XmlAttribute AddAttribute(XmlDocument xd, string name, string value)
|
||||||
{
|
{
|
||||||
XmlAttribute xa = xd.CreateAttribute(name);
|
XmlAttribute xa = xd.CreateAttribute(name);
|
||||||
@@ -1885,8 +1889,13 @@ namespace VEPROMS
|
|||||||
UserID
|
UserID
|
||||||
*/
|
*/
|
||||||
XmlElement xe = xn.OwnerDocument.CreateElement(nodename);
|
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 : "";
|
string formatFileName = (ci.MyFormat != null) ? ci.MyFormat.Name : "";
|
||||||
|
|
||||||
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "contentid", ci.ContentID.ToString()));
|
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());
|
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(@"(<START\](\\[^v \\]+)*\\v0(\\[^v '?{{}}~\\]+)*( |\\u[0-9]{{1,4}}?|\\'[0-9a-fA-F]{{2}}|\\[{{}}~]))(.*?)((\\[^v'?{{}}~ \\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>)", 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)
|
if (cbxExportAudits.Checked)
|
||||||
{
|
{
|
||||||
|
@@ -17,31 +17,48 @@ namespace VEPROMS
|
|||||||
#pragma warning restore S101 // Types should be named in PascalCase
|
#pragma warning restore S101 // Types should be named in PascalCase
|
||||||
{
|
{
|
||||||
private readonly AnnotationTypeInfo _AnnotationType;
|
private readonly AnnotationTypeInfo _AnnotationType;
|
||||||
private readonly int _UnitIndex;
|
|
||||||
private readonly string multiseparator = ",";
|
private readonly string multiseparator = ",";
|
||||||
|
|
||||||
private static Regex _ROAccPageTokenPattern = new Regex("[<][^<>-]+-[^<>]+[>]");
|
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);
|
_AnnotationType = AnnotationTypeInfo.Get(annotationTypeId);
|
||||||
_UnitIndex = unitIndex;
|
_UnitIndex = unitIndex;
|
||||||
_ExportBothConvertedandNot = true;
|
_ExportBothConvertedandNot = true;
|
||||||
DocReplace = new Dictionary<int, byte[]>();
|
DocReplace = new Dictionary<int, byte[]>();
|
||||||
FormClosed += OnClose;
|
FormClosed += OnClose;
|
||||||
Text = $"{mode} Electronic Procedure ({_AnnotationType.Name}) Dialog for {folderInfo.Name}";
|
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)
|
if (_UnitIndex > 0)
|
||||||
{
|
{
|
||||||
_AnnotationType = AnnotationTypeInfo.Get(annotationTypeId);
|
foreach (DocVersionInfo docver in MyFolder.FolderDocVersions)
|
||||||
_UnitIndex = unitIndex;
|
{
|
||||||
_ExportBothConvertedandNot = true;
|
docver.DocVersionConfig.SelectedSlave = _UnitIndex;
|
||||||
DocReplace = new Dictionary<int, byte[]>();
|
|
||||||
FormClosed += OnClose;
|
foreach (ItemInfo proc in docver.Procedures)
|
||||||
Text = $"{mode} Electronic Procedure ({_AnnotationType.Name}) Dialog for {docVersionInfo.Name} of {docVersionInfo.MyFolder.Name}";
|
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<int, byte[]>();
|
||||||
|
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);
|
_AnnotationType = AnnotationTypeInfo.Get(annotationTypeId);
|
||||||
_UnitIndex = unitIndex;
|
_UnitIndex = unitIndex;
|
||||||
@@ -49,6 +66,13 @@ namespace VEPROMS
|
|||||||
DocReplace = new Dictionary<int, byte[]>();
|
DocReplace = new Dictionary<int, byte[]>();
|
||||||
FormClosed += OnClose;
|
FormClosed += OnClose;
|
||||||
Text = $"{mode} Electronic Procedure ({_AnnotationType.Name}) Dialog for {procedureInfo.DisplayNumber}";
|
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
|
//Overridden function to handle export of EP data
|
||||||
@@ -320,8 +344,32 @@ namespace VEPROMS
|
|||||||
}
|
}
|
||||||
|
|
||||||
//clear objects to release memory
|
//clear objects to release memory
|
||||||
|
//and unset the unit (SelectedSlave)
|
||||||
private void OnClose(object sender, EventArgs e)
|
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.Clear();
|
||||||
DocReplace = null;
|
DocReplace = null;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user