private string TransferOutSequence(string registryID, string noteID) { XmlNode tranferOuts = null; ThisAddIn.TransferOutTime(registryID, ref tranferOuts); if (tranferOuts == null) { return(null); } XmlNodeList emrNotes = emrDoc.DocumentElement.SelectNodes(ElementNames.EmrNote); XmlNode congeners = ThisAddIn.GetCongener0(noteID, emrNotes); if (congeners.ChildNodes.Count == 0) { return(tranferOuts.FirstChild.Attributes[AttributeNames.TransferOutSequence].Value); } string sequence = null; foreach (XmlNode tranferOut in tranferOuts.ChildNodes) { string commitT = ""; sequence = tranferOut.Attributes[AttributeNames.TransferOutSequence].Value; if (ThisAddIn.NoteExistsWithSequence(AttributeNames.TransferOutSequence, sequence, congeners, ref commitT) != null && commitT != "") { continue; } break; } return(sequence); }