示例#1
0
        private ProcessResult VerifyPrescription(Prescription newPrescription)
        {
            ProcessResult    result  = new ProcessResult();
            DiagnosisManager manager = new DiagnosisManager();

            if (newPrescription.Examination.DiagnosisId < 1 ||
                newPrescription.Examination.DiagnosisId == manager.GetDefaultDiagnosis().Id)
            {
                result.Errors.Add("Reçeteli kapatmalarda teşhis belirtilmelidir.");
            }
            if (newPrescription.PrescriptionItems.Count == 0)
            {
                result.Errors.Add("Reçeteli kapatmalarda enaz bir ilaç eklenmelidir");
            }
            if (newPrescription.PrescriptionItems.Any(p => p.MedicamentId < 1))
            {
                result.Errors.Add("İlacı belirtilmemiş reçete satırı olamaz.");
            }

            if (newPrescription.DoctorNote != null)
            {
                if (newPrescription.DoctorNote.Length > 500)
                {
                    result.Errors.Add(string.Format("Doktor notu 500 karakteri geçemez. Not uzunluğu: {0}",
                                                    newPrescription.DoctorNote.Length));
                }
            }

            result.Result = !result.Errors.Any()
                ? Extensions.BLLResult.Verified
                : Extensions.BLLResult.NotVerified;

            return(result);
        }
        public bool Update(Examination newInfoExamination)
        {
            if (newInfoExamination.DiagnosisId > 0)
            {
                return(_examinationDal.Update(newInfoExamination));
            }

            DiagnosisManager manager = new DiagnosisManager();

            newInfoExamination.DiagnosisId = manager.GetDefaultDiagnosis().Id;
            return(_examinationDal.Update(newInfoExamination));
        }
        public bool Insert(Examination newExamination)
        {
            if (newExamination.DiagnosisId > 0)
            {
                return(_examinationDal.Insert(newExamination));
            }

            DiagnosisManager manager = new DiagnosisManager();

            newExamination.DiagnosisId = manager.GetDefaultDiagnosis().Id;
            return(_examinationDal.Insert(newExamination));
        }
        public ProcessResult Insert(Rendezvous newRendezvous, bool toExamination)
        {
            newRendezvous.IsActive = !toExamination;
            newRendezvous.Date     = toExamination ? DateTime.Today : newRendezvous.Date;

            ProcessResult result = Verifyrendezvous(newRendezvous);

            if (result.Result != Extensions.BLLResult.Verified)
            {
                return(result);
            }

            result = IsHoliday(newRendezvous.Date);
            if (result.Result != Extensions.BLLResult.Success)
            {
                return(result);
            }

            result = IsExistOtherRendezvous(newRendezvous);
            if (result.Result == Extensions.BLLResult.AlreadyFound)
            {
                return(result);
            }

            DAL.Extensions.DataBaseResult baseResult = _rendezvousDal.Insert(ref newRendezvous);

            switch (baseResult)
            {
            case DAL.Extensions.DataBaseResult.Error:
                result.Errors.Add(Extensions.InnerException);
                result.Result = Extensions.BLLResult.InnerException;
                break;

            case DAL.Extensions.DataBaseResult.ServerDisable:
                result.Result = Extensions.BLLResult.ServerDisable;
                result.Errors.Add(Extensions.ServerDisable);
                break;

            case DAL.Extensions.DataBaseResult.Success:
                break;

            case DAL.Extensions.DataBaseResult.AlreadyFound:
                break;

            case DAL.Extensions.DataBaseResult.Referanced:
                break;

            case DAL.Extensions.DataBaseResult.NotFound:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (toExamination)
            {
                DiagnosisManager   diagnosisManager = new DiagnosisManager();
                Diagnosis          diagnosis        = diagnosisManager.GetDefaultDiagnosis();
                ExaminationManager manager          = new ExaminationManager();
                manager.Insert(new Examination
                {
                    CanSendMessage = false, PatientId = newRendezvous.PatientId, DoctorId = newRendezvous.DoctorId, Time = newRendezvous.Date, RendezvousId = newRendezvous.Id, IsActive = true, DiagnosisId = diagnosis.Id
                });
            }

            result.Errors.Add(Extensions.SuccessProcess);
            result.Errors.Add(String.Format("Kayıt numarası: {0}", newRendezvous.Id));
            result.Result = Extensions.BLLResult.Success;
            return(result);
        }