Пример #1
0
        public AddPatientViewModel(PatientListViewModel patientListViewModel,
                                   PatientService patientService,
                                   PersonService personService,
                                   DiagnosisService diagnosisService,
                                   PhysicianService physicianService,
                                   EmployeeService employeeService,
                                   WardService wardService,
                                   BedService bedService,
                                   VitalRecordService vitalRecordService,
                                   ConditionService conditionService)
        {
            _patientListViewModel = patientListViewModel;
            _patientService       = patientService;
            _personService        = personService;
            _diagnosisService     = diagnosisService;
            _physicianService     = physicianService;
            _employeeService      = employeeService;
            _wardService          = wardService;
            _bedService           = bedService;
            _vitalRecordService   = vitalRecordService;
            _conditionService     = conditionService;

            ContactPersons = new ObservableCollection <Person>(_personService.GetPersons()
                                                               .Where(c => c.Discriminator == "Person"));

            SubscriberPersons = new ObservableCollection <Person>(_personService.GetPersons()
                                                                  .Where(c => c.Discriminator == "Person"));

            Nurses = new ObservableCollection <Nurse>(_employeeService.GetNurses());

            Physicians = new ObservableCollection <Physician>(_physicianService.GetPhysicians());

            Wards = new ObservableCollection <Ward>(_wardService.GetWards()
                                                    .Include(c => c.FacilityLink));

            Beds = new ObservableCollection <Bed>(_bedService.GetBeds()
                                                  .Include(c => c.WorkUnitLink));

            Conditions                   = new ObservableCollection <Condition>(_conditionService.GetConditions());
            PatientModel.BirthDate       = DateTime.Now;
            PatientModel.DateOfContact   = DateTime.Now;
            InpatientModel.DateAdmitted  = DateTime.Now;
            InpatientModel.DischargeDate = DateTime.Now;
        }
        public EditPatientViewModel(CombinedPatientViewModel originalModel,
                                    CombinedPatientViewModel duplicateModel,
                                    PatientService patientService,
                                    PersonService personService,
                                    WardService wardService,
                                    BedService bedService,
                                    VisitService visitService)
        {
            AssociatedPatientModel  = duplicateModel;
            _originalModel          = originalModel;
            OriginalPatientModel    = _originalModel.PatientModel;
            OriginalInpatientModel  = _originalModel.InpatientModel;
            OriginalOutpatientModel = _originalModel.OutpatientModel;
            _patientService         = patientService;
            _personService          = personService;
            _wardService            = wardService;
            _bedService             = bedService;
            _visitService           = visitService;
            ContactPersons          = new ObservableCollection <Person>(_personService.GetPersons()
                                                                        .Where(c => c.Discriminator == "Person").ToList());
            SubscriberPersons = new ObservableCollection <Person>(_personService.GetPersons()
                                                                  .Where(c => c.Discriminator == "Person").ToList());
            Wards = new ObservableCollection <Ward>(_wardService.GetWards()
                                                    .Include(c => c.FacilityLink));
            Beds = new ObservableCollection <Bed>(_bedService.GetBeds()
                                                  .Include(c => c.WorkUnitLink));
            if (!AssociatedPatientModel.IsOutpatient)
            {
                if (AssociatedPatientModel.InpatientModel.BedId != null)
                {
                    SelectedBed = Beds.First(c => c.BedId == AssociatedPatientModel.InpatientModel.BedId);
                    OriginalBed = SelectedBed;
                }
                if (AssociatedPatientModel.InpatientModel.ContactPersonId != null)
                {
                    SelectedContactPerson = ContactPersons.First(c =>
                                                                 c.PersonId == AssociatedPatientModel.InpatientModel.ContactPersonId);
                    OriginalContact = SelectedContactPerson;
                }
                if (AssociatedPatientModel.InpatientModel.SubscriberPersonId != null)
                {
                    SelectedSubscriber = SubscriberPersons.First(c =>
                                                                 c.PersonId == AssociatedPatientModel.InpatientModel.SubscriberPersonId);
                    OriginalSubscriber = SelectedSubscriber;
                }
                SelectedWard   = Wards.First(c => c.WardId == AssociatedPatientModel.InpatientModel.WardId);
                OriginalWard   = SelectedWard;
                PatientModel   = AssociatedPatientModel.PatientModel;
                InpatientModel = AssociatedPatientModel.InpatientModel;
            }
            else
            {
                if (AssociatedPatientModel.OutpatientModel.ContactPersonId != null)
                {
                    SelectedContactPerson = ContactPersons.First(c =>
                                                                 c.PersonId == AssociatedPatientModel.OutpatientModel.ContactPersonId);
                    OriginalContact = SelectedContactPerson;
                }

                if (AssociatedPatientModel.OutpatientModel.SubscriberPersonId != null)
                {
                    SelectedSubscriber = SubscriberPersons.First(c =>
                                                                 c.PersonId == AssociatedPatientModel.OutpatientModel.SubscriberPersonId);
                    OriginalSubscriber = SelectedSubscriber;
                }

                Visits = new ObservableCollection <Visit>(_visitService.GetVisits()
                                                          .Where(c => c.OutpatientId == AssociatedPatientModel.OutpatientModel.PersonId));
                PatientModel    = AssociatedPatientModel.PatientModel;
                OutpatientModel = AssociatedPatientModel.OutpatientModel;
            }
        }