/*修改病历*/
 public CaseInfo ModifyCase(CaseInfo newCase) {
     if (newCase == null) {
         CaseInfo newCaseInfo = new CaseInfo();
         newCaseInfo.ErrorMessage = "Empty Case Info! @Service";
         return newCaseInfo;
     }
     else {
         newCase.ErrorMessage = null;
         CaseInfoEntity caseInfoEntity = new CaseInfoEntity();
         TranslateCaseInfoToCaseInfoEntityContractData(newCase, caseInfoEntity);
         if (caseInfoEntity.ErrorMessage != null) {
             newCase.ErrorMessage = caseInfoEntity.ErrorMessage;
         }
         else {
             CaseInfoEntity newCaseInfoEntity = doctorLogic.ModifyCase(caseInfoEntity);
             newCase = new CaseInfo();
             TranslateCaseInfoEntityToCaseInfoContractData(newCaseInfoEntity, newCase);
         }
         return newCase;
     }
 }
        /*获取指定病历的信息*/
        public CaseInfo GetCaseInfo(string sCaseID, bool showICD) {
            CaseInfo    caseInfo =  new CaseInfo();
            Guid        gCaseID;
            try {
                gCaseID = new Guid(sCaseID);
            }
            catch {
                caseInfo.ErrorMessage = "Invalid ID! @Service";
                return caseInfo;
            }

            CaseInfoEntity  caseInfoEntity = doctorLogic.GetCaseInfo(gCaseID, showICD);
            TranslateCaseInfoEntityToCaseInfoContractData(caseInfoEntity, caseInfo);
            return caseInfo;
        }
 /*将CaseInfo对应的Entity翻译为数据契约*/
 private void TranslateCaseInfoEntityToCaseInfoContractData(
     CaseInfoEntity caseInfoEntity,
     CaseInfo caseInfo) {
     caseInfo.ErrorMessage       = caseInfoEntity.ErrorMessage;
     if (caseInfoEntity.CaseID != null) {
         caseInfo.CaseID = caseInfoEntity.CaseID.ToString();
     }
     if (caseInfoEntity.ExaminationID != null) {
         caseInfo.ExaminationID = caseInfoEntity.ExaminationID.ToString();
     }
     if (caseInfoEntity.PrescriptionID != null) {
         caseInfo.PrescriptionID = caseInfoEntity.PrescriptionID.ToString();
     }
     caseInfo.UserID             = caseInfoEntity.UserID;
     caseInfo.DoctorID           = caseInfoEntity.DoctorID;
     caseInfo.SectionID          = caseInfoEntity.SectionID;
     caseInfo.Date               = caseInfoEntity.Date;
     caseInfo.ChiefComplaint     = caseInfoEntity.ChiefComplaint;
     caseInfo.TentativeDiagnosis = caseInfoEntity.TentativeDiagnosis;
     caseInfo.DifferentialDiagnosis = caseInfoEntity.DifferentialDiagnosis;
     caseInfo.TreatmentPlan      = caseInfoEntity.TreatmentPlan;
     caseInfo.CountercheckDate   = caseInfoEntity.CountercheckDate;
     caseInfo.IsDraft            = caseInfoEntity.IsDraft;
 }
 /*将CaseInfo对应的数据契约翻译为Entity*/
 private void TranslateCaseInfoToCaseInfoEntityContractData(
     CaseInfo        caseInfo,
     CaseInfoEntity  caseInfoEntity) {
     caseInfoEntity.ErrorMessage         = caseInfo.ErrorMessage;
     if (caseInfo.CaseID != null) {
         try {
             caseInfoEntity.CaseID = new Guid(caseInfo.CaseID);
         }
         catch {
             caseInfoEntity.ErrorMessage = "Invalid CaseID! @Service";
         }
     }
     if (caseInfo.ExaminationID != null) {
          try {
              caseInfoEntity.ExaminationID = new Guid(caseInfo.ExaminationID);
         }
         catch {
             caseInfoEntity.ErrorMessage = "Invalid ExaminationID! @Service";
         }
     }
     if (caseInfo.PrescriptionID != null) {
         try {
             caseInfoEntity.PrescriptionID = new Guid(caseInfo.PrescriptionID);
         }
         catch {
             caseInfoEntity.ErrorMessage = "Invalid PrescriptionID! @Service";
         }
     }
     caseInfoEntity.UserID               = caseInfo.UserID;
     caseInfoEntity.DoctorID             = caseInfo.DoctorID;
     caseInfoEntity.SectionID            = caseInfo.SectionID;
     caseInfoEntity.Date                 = caseInfo.Date;
     caseInfoEntity.ChiefComplaint       = caseInfo.ChiefComplaint;
     caseInfoEntity.TentativeDiagnosis   = caseInfo.TentativeDiagnosis;
     caseInfoEntity.DifferentialDiagnosis = caseInfo.DifferentialDiagnosis;
     caseInfoEntity.TreatmentPlan        = caseInfo.TreatmentPlan;
     caseInfoEntity.CountercheckDate     = caseInfo.CountercheckDate;
     caseInfoEntity.IsDraft              = caseInfo.IsDraft;
 }
 /*创建病历并针对复查日期创建message*/
 public CaseInfo CreateCase(CaseInfo caseInfo) {
     if (caseInfo == null) {
         CaseInfo newCaseInfo = new CaseInfo();
         newCaseInfo.ErrorMessage = "Empty Case Info! @Service";
         return newCaseInfo;
     }
     else {
         caseInfo.ErrorMessage = null;
         CaseInfoEntity caseInfoEntity = new CaseInfoEntity();
         TranslateCaseInfoToCaseInfoEntityContractData(caseInfo, caseInfoEntity);
         if (caseInfoEntity.ErrorMessage != null) {
             caseInfo.ErrorMessage = caseInfoEntity.ErrorMessage;
         }
         else {
             CaseInfoEntity newCaseInfoEntity = doctorLogic.CreateCase(caseInfoEntity);
             caseInfo = new CaseInfo();
             TranslateCaseInfoEntityToCaseInfoContractData(newCaseInfoEntity, caseInfo);
         }
         return caseInfo;
     }
 }
 /*获取最近一次病历*/
 public CaseInfo GetLastCaseInfo(string userID, string password) {
     UserService userService = new UserService();
     UserInfo userInfo = userService.Login(userID, password);
     if (userInfo.ErrorMessage == null) {
         /*不显示ICD-10编码*/
         return userService.GetLastCaseInfo(false);
     }
     else {
         CaseInfo    caseInfo =  new CaseInfo();
         caseInfo.ErrorMessage = userInfo.ErrorMessage;
         return caseInfo;
     }
 }
 /*获取最近一次病历*/
 public CaseInfo GetLastCaseInfo(bool showICD) {
     CaseInfoEntity  caseInfoEntity = userLogic.GetLastCaseInfo(showICD); 
     CaseInfo        caseInfo =  new CaseInfo();
     TranslateCaseInfoEntityToCaseInfoContractData(caseInfoEntity, caseInfo);
     return caseInfo;
 }