/// /// 醫師轉檔 /// /// public string SetDoctorTransfer() { List doctors = new List(); List depDoctors = new List(); string strConnString = ConfigurationManager.ConnectionStrings["CMUHWebSiteMySqlConnection"].ConnectionString; using (var conn = new MySqlConnection(strConnString)) { var query = @"SELECT CASE WHEN status = 'true' THEN 0 ELSE 1 END AS IsEnable, name AS Name, TRIM(description) AS EmpNo, title AS Title, gender AS Gender, specialty AS Introduction, content AS Img, name AS EnName, experience AS Experience, education AS Education, specialty AS Specialty FROM doctors WHERE SUBSTRING(description, 1, 1) = 'D' AND status != 'true'"; doctors = conn.Query(query).AsList(); query = @"SELECT c.depintroID AS Id, c.depID AS DepId, a.description AS LastModifyUser, b.sort AS SortId FROM doctors a, dep_doc b, dep_intro c WHERE b.docid = a.docid AND c.depID = b.groupID AND SUBSTRING( a.description, 1, 1 ) = 'D' ORDER BY a.description, b.sort, c.depintroID"; depDoctors = conn.Query(query).AsList(); } DocCurPosRepository docCurPosRepository = new DocCurPosRepository(); List docCurPosList = docCurPosRepository.All().Where(x => x.docid.Substring(0, 1) == "D").ToList(); DocExExpRepository docExExpRepository = new DocExExpRepository(); List docExExpList = docExExpRepository.All().Where(x => x.docid.Substring(0, 1) == "D" && (x.start_date.Trim() != "*" || x.title.Trim() != "*")).ToList(); List depDetails = new List(); DepDetailRepository depDetailRepository = new DepDetailRepository(); depDetails = depDetailRepository.All().ToList(); foreach (var item in doctors) { try { List doctorDeps = depDoctors.Where(x => x.LastModifyUser.Trim() == item.EmpNo.Trim()).ToList(); Dep_Doctors doctorMainDep = depDoctors.Where(x => x.LastModifyUser.Trim() == item.EmpNo.Trim()).OrderBy(x => x.SortId).FirstOrDefault(); DepDetail doctorMainDepDetail = new DepDetail(); List otherDoctorDeps = new List(); if (doctorDeps.Count > 0) { List exceptDoctorDeps = new List { doctorMainDep }; otherDoctorDeps = doctorDeps.Except(exceptDoctorDeps).ToList(); doctorMainDepDetail = depDetails.Where(x => x.TableCode.Trim() == doctorMainDep.DepId.ToString()).FirstOrDefault(); } item.ModifyOn = DateTime.Now; item.LastModifyUser = "a29463"; item.IsEnable = false; // item.SortId 棄用 int separatorIndex = Regex.Match(item.Name, @"[a-zA-Z]").Index; item.Name = separatorIndex == 0 ? item.Name.Trim() : item.Name.Substring(0, separatorIndex - 1).Trim(); item.EnName = separatorIndex == 0 ? string.Empty : item.EnName.Substring(separatorIndex, item.EnName.Length - separatorIndex).Trim(); item.Introduction = item.Introduction == null ? item.Introduction : Regex.Replace(item.Introduction, @"(
|
|
||
)", "\r\n"); item.Experience = item.Experience == null ? item.Experience : Regex.Replace(item.Experience, @"(
|
|
||
)", "\r\n"); item.Education = item.Education == null ? item.Education : Regex.Replace(item.Education, @"(
|
|
||
)", "\r\n"); item.Specialty = item.Specialty == null ? item.Specialty : Regex.Replace(item.Specialty, @"(
|
|
||
)", "\r\n"); item.Illustration = @"
  • 未滿 18 歲者,建議改掛兒科相關診。
  • 未有身分證之新生兒,請以現場或人工掛號。
  • 教學診是以教學為主,會有住院醫師或實習醫學生在旁學習看診;因為教學診,敬請看診病人須為本人親自看診。
  • 6 - 13 號為現場初診保留號。
  • 網路初診預約未就診,在三個月內若需掛號請由複診登入。
"; item.DepID = doctorMainDepDetail.Id == 0 ? 157 : doctorMainDepDetail.Id; item.TypeID = doctorMainDepDetail.ParentDepSubID == null ? 44 : doctorMainDepDetail.ParentDepSubID.Value; item.CurrentPosition = String.Join("\r\n", docCurPosList.Where(x => x.docid == item.EmpNo).OrderByDescending(x => x.start_date).Select(x => String.Format("{0} {1}", x.department, x.title)).ToArray()); item.ExExperience = String.Join("\r\n", docExExpList.Where(x => x.docid == item.EmpNo).OrderByDescending(x => x.start_date).Select(x => String.Format("{0} {1}", x.company, x.title)).ToArray()); item.OtherDep = String.Join(",", otherDoctorDeps.Join(depDetails, x => x.DepId.ToString(), y => y.TableCode.Trim(), (x, y) => new { DepId = y.Id.ToString() }).Select(x => x.DepId).ToArray()); item.OtherDep = item.OtherDep == string.Empty ? null : item.OtherDep; } catch (Exception e) { e.ToString(); continue; } } DepTypeSubRepository depTypeSubRepository = new DepTypeSubRepository(); List depTypeSubs = depTypeSubRepository.All().ToList(); List temp = doctors.Where(x => !depTypeSubs.Where(y => y.Id == x.TypeID).Any()).ToList(); DoctorsRepository doctorsRepository = new DoctorsRepository(); string result = doctorsRepository.CreateAll(doctors); return result; // return string.Empty; }