Esempio n. 1
0
        public void LoadSessionInfo()
        {
            if (SelectedSession == null)
            {
                return;
            }

            NotifyOfPropertyChange(() => CanSaveSession);
            NotifyOfPropertyChange(() => CanNewEsRecord);
            NotifyOfPropertyChange(() => CanChangeService);
            NotifyOfPropertyChange(() => CanAddDrug);
            NotifyOfPropertyChange(() => CanSaveDrugs);

            Symtoms  = SelectedSession.Symtoms;
            Diagnose = SelectedSession.Diagnose;
            if (SelectedSession.ReExamDate != null)
            {
                ReExamDate = SelectedSession.ReExamDate.Value;
            }
            SessionNote = SelectedSession.Note;

            var esRecords =
                _esClinicContext.EndoscopyRecords.Include("Type").ToList().Where(e => e.SessionId == SelectedSession.SessionId);

            EsRecords.Clear();
            foreach (var esRecord in esRecords)
            {
                EsRecords.Add(esRecord);
            }

            var services =
                _esClinicContext.Services.Include("ServiceType").ToList().Where(s => s.SessionId == SelectedSession.SessionId);

            Services.Clear();
            foreach (var service in services)
            {
                Services.Add(service);
            }

            var drugs =
                _esClinicContext.Drugs.Include("Product").ToList().Where(d => d.SessionId == SelectedSession.SessionId);

            Drugs.Clear();
            foreach (var drug in drugs)
            {
                Drugs.Add(drug);
            }
        }
Esempio n. 2
0
        public void RemoveVisitor(Visitor visitor)
        {
            if (visitor == null)
            {
                return;
            }

            _esClinicContext.Visitors.Remove(visitor);
            _esClinicContext.SaveChanges();
            RefreshVisitors();

            _currentVisitor = null;
            Sessions.Clear();
            EsRecords.Clear();
            Services.Clear();
            Drugs.Clear();
        }
Esempio n. 3
0
        public void NextVisitor(Visitor visitor)
        {
            if (_currentSession == null)
            {
                RemoveVisitor(visitor);
                return;
            }

            if (!_drugSaved)
            {
                var result = MessageBox.Show("Lưu lại toa thuốc hiện tại?", "Nhắc lưu", MessageBoxButton.YesNoCancel);
                if (result == MessageBoxResult.Yes)
                {
                    SaveDrugs();
                }
                else if (result == MessageBoxResult.Cancel)
                {
                    return;
                }
            }

            _currentSession.TotalCost   = 0;
            _currentSession.ServiceCost = 0;
            var services = _esClinicContext.Services.Include("ServiceType").ToList().Where(s => s.SessionId == _currentSession.SessionId);

            foreach (var service in services)
            {
                if (service.IsChecked)
                {
                    _currentSession.ServiceCost += service.ServiceType.Price;
                }
            }

            var surchanges = _esClinicContext.Surcharges.ToList();

            foreach (var surcharge in surchanges)
            {
                TotalCost += surcharge.Price;
            }

            _currentSession.TotalCost = TotalCost + _currentSession.ServiceCost;

            _currentSession.Stage = ClinicStage.WaitToPay;

            var newPayor = new Payor
            {
                SessionId = _currentSession.SessionId,
                Name      = _currentVisitor.Patient.Name,
                Session   = _currentSession
            };

            _esClinicContext.Payors.Add(newPayor);
            _esClinicContext.Entry(_currentVisitor).State = EntityState.Deleted;
            _esClinicContext.Entry(_currentSession).State = EntityState.Modified;
            _esClinicContext.SaveChanges();

            TotalCost = 0;
            RefreshVisitors();
            _currentVisitor = null;
            _currentSession = null;
            Sessions.Clear();
            EsRecords.Clear();
            Services.Clear();
            Drugs.Clear();
        }