public PatientLookup GetPatientByCccNumber(string cccNumber) { cccNumber = cccNumber.Trim(); PatientLookup patient = null; try { patient = _patientLookupmanager.GetPatientByCccNumber(cccNumber); if (patient == null) { if (cccNumber.Contains("-")) { string[] numbers = cccNumber.Split('-'); patient = _patientLookupmanager.GetPatientByCccNumber(numbers[1]); if (patient == null) { string cccAfterRemoveLeading = numbers[1].TrimStart('0'); patient = _patientLookupmanager.GetPatientByCccNumber(cccAfterRemoveLeading); if (patient == null) { string cccConcatParts = numbers[0] + numbers[1]; patient = _patientLookupmanager.GetPatientByCccNumber(cccConcatParts); if (patient == null) { patient = _patientLookupmanager.GetPatientByNormalizedCccNumber(cccConcatParts); } } } } else { int cccNumberLength = cccNumber.Length; if (cccNumberLength == 10) { string ccc = cccNumber.Substring(5, 5); patient = _patientLookupmanager.GetPatientByCccNumber(ccc); if (patient == null) { patient = _patientLookupmanager.GetPatientByCccNumber(ccc.TrimStart('0')); if (patient == null) { string withDash = cccNumber.Substring(0, 5) + "-" + cccNumber.Substring(5, 5); patient = _patientLookupmanager.GetPatientByCccNumber(withDash); } } } else { patient = _patientLookupmanager.GetPatientByCccNumber(cccNumber.TrimStart('0')); } } } } catch (Exception e) { throw new Exception(e.Message); } return(patient); }
public PatientLookup GetPatientByCccNumber(string cccNumber) { cccNumber = cccNumber.Trim(); PatientLookup patient = null; try { patient = _patientLookupmanager.GetPatientByCccNumber(cccNumber); if (patient == null) { if (cccNumber.Contains("-")) { string[] numbers = cccNumber.Split('-'); patient = _patientLookupmanager.GetPatientByCccNumber(numbers[1]); if (patient == null) { string cccAfterRemoveLeading = numbers[1].TrimStart('0'); patient = _patientLookupmanager.GetPatientByCccNumber(cccAfterRemoveLeading); if (patient == null) { string cccConcatParts = numbers[0] + numbers[1]; patient = _patientLookupmanager.GetPatientByCccNumber(cccConcatParts); if (patient == null) { patient = _patientLookupmanager.GetPatientByNormalizedCccNumber(cccConcatParts); } } } } else { int cccNumberLength = cccNumber.Length; if (cccNumberLength == 10) { string ccc = cccNumber.Substring(5, 5); patient = _patientLookupmanager.GetPatientByCccNumber(ccc); if (patient == null) { patient = _patientLookupmanager.GetPatientByCccNumber(ccc.TrimStart('0')); if (patient == null) { string withDash = cccNumber.Substring(0, 5) + "-" + cccNumber.Substring(5, 5); patient = _patientLookupmanager.GetPatientByCccNumber(withDash); } } } else { var lookupLogic = new LookupLogic(); var facility = lookupLogic.GetFacility(); if (cccNumberLength == 5) { patient = _patientLookupmanager.GetPatientByCccNumber(facility.MFLCode + cccNumber); } else if (cccNumberLength < 5) { var count = 5 - cccNumberLength; var stringPadding = ""; while (count > 0) { stringPadding += '0'; count--; } patient = _patientLookupmanager.GetPatientByCccNumber(facility.MFLCode + stringPadding + cccNumber); } else { patient = _patientLookupmanager.GetPatientByCccNumber(cccNumber.TrimStart('0')); } } } } } catch (Exception e) { throw new Exception(e.Message); } return(patient); }