/*将CaseHistory对应的Entity翻译为数据契约*/
        private void TranslateCaseHistoryEntityToCaseHistoryContractData(
            CaseHistoryEntity caseHistoryEntity,
            CaseHistory caseHistory) {
            caseHistory.ErrorMessage = caseHistoryEntity.ErrorMessage;
            caseHistory.Count = caseHistoryEntity.Count;

            if (caseHistory.Count > 0) {
                caseHistory.caseInfo = new CaseInfo[caseHistory.Count];
                for (int i = 0; i < caseHistory.Count; i++) {
                    caseHistory.caseInfo[i] = new CaseInfo();
                    TranslateCaseInfoEntityToCaseInfoContractData(
                        caseHistoryEntity.caseInfoEntity[i],
                        caseHistory.caseInfo[i]);
                }
            }
        }
        ///*获取某医生在某区间内所有未完成的病历*/
        //public CaseHistoryEntity RetrieveMyDraft(string doctorID, DateTime? startDate, DateTime? endDate) {

        //    return null;
        //}

        #endregion

        
        #region 获取某科室全体医生撰写的病历 RetrieveSectionCase(string sectionID, DateTime? startDate, DateTime? endDate, bool isDraft, bool showICD)

        /*获取某科室在某区间内所有已完成的病历(isDraft为false时),或未完成的病历*/
        public CaseHistoryEntity RetrieveSectionCase(string sectionID, DateTime? startDate, DateTime? endDate, bool isDraft, bool showICD) {
            CaseHistoryEntity caseHistoryEntity = new CaseHistoryEntity();
            DrPEDatabaseEntities DEntities = new DrPEDatabaseEntities();

            IQueryable<CaseHistory> cases = null;

            /*根据时间和科室ID查找病历*/
            if (isDraft == false) {
                cases = from c in DEntities.CaseHistories
                        where ((c.ModifiedDate != null) && (startDate <= c.ModifiedDate) && (c.ModifiedDate <= endDate) && (c.SectionID == sectionID))
                        orderby c.ModifiedDate
                        select c;
            }
            else {
                cases = from c in DEntities.CaseHistories
                        where ((c.ModifiedDate == null) && (startDate <= c.CreatedDate) && (c.CreatedDate <= endDate) && (c.SectionID == sectionID))
                        orderby c.CreatedDate
                        select c;
            }

            /*处理无结果的情况*/
            int caseCount = cases.Count();
            if (caseCount <= 0) {
                caseHistoryEntity.ErrorMessage = String.Format("No Case Histories Created in Section {2} Modified Between {0} and {1}! @Data",
                                                                startDate, endDate, sectionID);
                return caseHistoryEntity;
            }

            /*逐条进行转录*/
            int cnt = 0;
            //caseHistoryEntity = new CaseHistoryEntity();
            caseHistoryEntity.Count = caseCount;
            caseHistoryEntity.caseInfoEntity = new CaseInfoEntity[caseCount];
            foreach (var c in cases) {
                caseHistoryEntity.caseInfoEntity[cnt] = new CaseInfoEntity();

                /*复制病历部分信息*/
                caseHistoryEntity.caseInfoEntity[cnt].CaseID = c.CaseID;
                caseHistoryEntity.caseInfoEntity[cnt].ExaminationID = c.ExaminationID;
                caseHistoryEntity.caseInfoEntity[cnt].PrescriptionID = c.PrescriptionID;
                caseHistoryEntity.caseInfoEntity[cnt].UserID = c.UserID;
                caseHistoryEntity.caseInfoEntity[cnt].DoctorID = c.DoctorID;
                caseHistoryEntity.caseInfoEntity[cnt].SectionID = c.SectionID;
                caseHistoryEntity.caseInfoEntity[cnt].CountercheckDate = c.CountercheckDate;
                caseHistoryEntity.caseInfoEntity[cnt].Date = c.ModifiedDate;

                /*针对ICD编码进行转写*/
                if (showICD == false) {
                    caseHistoryEntity.caseInfoEntity[cnt].ChiefComplaint = TranslateICD(c.ChiefComplaint);
                    caseHistoryEntity.caseInfoEntity[cnt].TentativeDiagnosis = TranslateICD(c.TentativeDiagnosis);
                    caseHistoryEntity.caseInfoEntity[cnt].DifferentialDiagnosis = TranslateICD(c.DifferentialDiagnosis);
                    caseHistoryEntity.caseInfoEntity[cnt].TreatmentPlan = TranslateICD(c.TreatmentPlan);
                }
                else {
                    caseHistoryEntity.caseInfoEntity[cnt].ChiefComplaint = c.ChiefComplaint;
                    caseHistoryEntity.caseInfoEntity[cnt].TentativeDiagnosis = c.TentativeDiagnosis;
                    caseHistoryEntity.caseInfoEntity[cnt].DifferentialDiagnosis = c.DifferentialDiagnosis;
                    caseHistoryEntity.caseInfoEntity[cnt].TreatmentPlan = c.TreatmentPlan;
                }

                cnt++;
            }

            return caseHistoryEntity;
        }
 /*获取某医生在某区间内所有已完成的病历(isDraft为false时),或未完成的病历*/
 public CaseHistoryEntity RetrieveDoctorCase(DateTime? startDate, DateTime? endDate, bool isDraft, bool showICD) {
     if (confirmed == false) {
         CaseHistoryEntity caseHistoryEntity = new CaseHistoryEntity();
         caseHistoryEntity.ErrorMessage = "尚未 Not Logged in Yet! @Logic";
         return caseHistoryEntity;
     }
     else {
         return doctorDAO.RetrieveDoctorCase(confirmedDoctorID, startDate, endDate, isDraft, showICD);
     }
 }
 /*获取某科室在某区间内所有已完成的病历(isDraft为false时),或未完成的病历*/
 public CaseHistoryEntity RetrieveSectionCase(DateTime? startDate, DateTime? endDate, bool isDraft, bool showICD) {
     if (confirmed == false) {
         CaseHistoryEntity caseHistoryEntity = new CaseHistoryEntity();
         caseHistoryEntity.ErrorMessage = "尚x未 Not Logged in Yet! @Logic";
         return caseHistoryEntity;
     }
     else {
         DoctorInfoEntity doctorInfoEntity = openAccessDAO.GetDoctorInfo(confirmedDoctorID);
         return doctorDAO.RetrieveSectionCase(doctorInfoEntity.SectionID, startDate, endDate, isDraft, showICD);
     }
 }
 /*获取指定用户在某区间内所有完成的病历*/
 public CaseHistoryEntity GetCaseHistory(string userID, DateTime? startDate, DateTime? endDate, bool showICD) {
     if (confirmed == false) {
         CaseHistoryEntity caseHistoryEntity = new CaseHistoryEntity();
         caseHistoryEntity.ErrorMessage = "有意义 Not Logged in Yet! @Logic";
         return caseHistoryEntity;
     }
     else {
         return doctorDAO.GetCaseHistory(userID, startDate, endDate, showICD);
     }
 }