public static string GetNextReportNo(Test.PanelSetOrderCollection panelSetOrderCollection, YellowstonePathology.Business.PanelSet.Model.PanelSet panelSet, string masterAccessionNo) { string result = null; if (panelSet.ReportNoLetter.AllowMultipleInSameAccession == false) { if (panelSetOrderCollection.Exists(panelSet.PanelSetId) == false) result = masterAccessionNo + "." + panelSet.ReportNoLetter.Letter; } else { int largestId = 0; foreach (Test.PanelSetOrder panelSetOrder in panelSetOrderCollection) { OrderIdParser orderIdParser = new OrderIdParser(panelSetOrder.ReportNo); int? reportNoNumber = orderIdParser.ReportNoNumber; if (reportNoNumber == null) { int currentId = GetIdNumber(panelSetOrder.ReportNo, panelSet.ReportNoLetter.Letter); if (currentId > largestId) largestId = currentId; } else { string reportNoLetter = orderIdParser.ReportNoLetter; if (reportNoLetter == panelSet.ReportNoLetter.Letter && reportNoNumber.Value > largestId) largestId = reportNoNumber.Value; } } result = masterAccessionNo + "." + panelSet.ReportNoLetter.Letter + (largestId + 1).ToString(); } return result; }