Example #1
0
        public DoctorsViewModel()
        {
            DisplayName = "Doctors";
            dhDoctors objLoad = new dhDoctors();

            this.MyModuel = this.ActiveModule(MyName);
            this.loadData();
        }
        public dhAccount InsertUpdateAccount(dhDoctors ObjDoctor)
        {
            //   Boolean ObjReturn =  false;
            dhAccount ObjAccount = new dhAccount();
            dhModule  objModule  = this.db.Modules.AsNoTracking().Where(x => x.VModuleName == "Doctors").First();

            if (objModule != null)
            {
                if (db.Accounts.Count() == 0)
                {
                    ObjAccount = new dhAccount();
                    ObjAccount.IModuleFK_ID     = ObjDoctor.IDocid;
                    ObjAccount.IModuleID        = objModule.IModuleID;
                    ObjAccount.AccountName      = ObjDoctor.VfName + " " + ObjDoctor.VlName;
                    ObjAccount.VAccountDesc     = BL.MsgTextCollection.MsgsList.Where(xx => xx.Key == "M_D01DEC").FirstOrDefault().Value;
                    ObjAccount.VAccountComments = BL.MsgTextCollection.MsgsList.Where(xx => xx.Key == "M_D02DEC").FirstOrDefault().Value;
                    ObjAccount.VAccountNo       = "D-" + DateTime.Now.ToString("ddmmyy") + "-" + ObjDoctor.IDocid; // D-For DOC and  DMY  - Day month year and Doc Id
                    ObjAccount.IFinaceType      = 3;
                    ObjAccount.BNominal         = false;
                    ObjAccount.BEditable        = false;

                    // db.Accounts.Add(ObjAccount);
                    return(ObjAccount);
                }

                ObjAccount = db.Accounts.Where(x => x.IModuleID == objModule.IModuleID && x.IModuleFK_ID == ObjDoctor.IDocid).FirstOrDefault();
                if (ObjAccount == null)
                {
                    ObjAccount = new dhAccount();
                    // create the account
                    ObjAccount.IModuleFK_ID     = ObjDoctor.IDocid;
                    ObjAccount.IModuleID        = objModule.IModuleID;
                    ObjAccount.AccountName      = ObjDoctor.VfName + " " + ObjDoctor.VlName;
                    ObjAccount.VAccountDesc     = BL.MsgTextCollection.MsgsList.Where(xx => xx.Key == "M_D01DEC").FirstOrDefault().Value;
                    ObjAccount.VAccountComments = BL.MsgTextCollection.MsgsList.Where(xx => xx.Key == "M_D02DEC").FirstOrDefault().Value;
                    ObjAccount.VAccountNo       = "D-" + DateTime.Now.ToString("ddMMyy") + "-" + ObjDoctor.IDocid; // D-For DOC and  DMY  - Day month year and Doc Id
                    ObjAccount.IFinaceType      = 3;
                    ObjAccount.BNominal         = false;
                    ObjAccount.BEditable        = false;
                    return(ObjAccount);
                    //  db.Accounts.Add(ObjAccount);
                }
                else
                {
                    // update existing acccount account title if needed
                    ObjAccount.AccountName = ObjDoctor.VfName + " " + ObjDoctor.VlName;
                }
            }
            return(ObjAccount);
            //    return ObjReturn;
        }
Example #3
0
        private void SaveAppointment(object sender, RoutedEventArgs e)
        {
            try
            {
                blAppointment objBlAppointment = new blAppointment();

                dhAppointment ObjNewAppointment = (dhAppointment)this.AppointmentInfo.DataContext;
                // cehck for patient
                dhPatient ObjPatient = (dhPatient)this.PatientInformationGrid.DataContext;
                // doctor
                long      iDocId = ((dhDoctorView)this.DoctorInformationGrid.DataContext).IDocid;
                dhDoctors objDoc = MyViewModel.db.Doctors.AsNoTracking().Where(x => x.IDocid == iDocId && x.BActive == true).FirstOrDefault();
                if (objDoc == null)
                {
                    return;
                }
                if (ObjPatient.iPatid == 0 || ObjPatient.iPatid < 0)
                {
                    BlPatient objBl = new BlPatient();
                    objBl.AddNewPatient(ObjPatient);
                    // need to save the patient first
                    //MyViewModel.db.Patients.Add(ObjPatient);
                    //MyViewModel.db.SaveChanges();
                    // set for patatient id
                    ObjNewAppointment.IPatid = ObjPatient.iPatid;
                }

                // check for doctors
                if (ObjNewAppointment != null)
                {
                    Dictionary <long, string> objDic = objBlAppointment.GetNextToken(objDoc, ObjNewAppointment);
                    ObjNewAppointment.FormatedTokenNumber = objDic.First().Value;
                    ObjNewAppointment.IToken_Number       = objDic.First().Key;

                    MyViewModel.db.Appointments.Add(ObjNewAppointment);
                    MyViewModel.db.SaveChanges();
                }

                this.AppointmentInfo.DataContext = ObjNewAppointment;
                Globalized.SetMsg("AOC01", DataHolders.MsgType.Info);
                Globalized.ShowMsg(lblErrorMsg);
            }
            catch (Exception ex)
            {
                Globalized.SetMsg(ex.Message, MsgType.Error);
                Globalized.ShowMsg(lblErrorMsg);
            }
        }
        public AddDoctorsViewModel(dhDoctors objTodisplay)
        {
            // load the moduel
            this.MyModuel = this.ActiveModule(MyName);

            this.ObjNewDoctor = objTodisplay;
            this.ObjNewDoctor.Specialization    = this.db.Specialization.AsNoTracking().Where(X => X.bIsActive == true).ToObservableCollection();
            this.ObjNewDoctor.Investigations    = this.db.Investigations.AsNoTracking().Where(i => i.bIsActive == true).ToObservableCollection();
            this.ObjNewDoctor.DocInvestigations = GetActiveDocInvestigations();

            // load the DocProcedures and Procedures
            this.ObjNewDoctor.Procedures = this.db.Procedures.AsNoTracking().Where(x => x.BIsActive == true).ToObservableCollection();

            //    this.ObjNewDoctor.DocProcedures = this.db.DocProcedures.Where(x => x.BIsActive == true && x.IDocid == this.ObjNewDoctor.IDocid).ToObservableCollection();
            this.ObjNewDoctor.DocProcedures = GetDocProcedures();
            DoctorAccount = GetDocAccount();
        }
        private void DocList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (sender != null)
            {
                DataGridRow dgr = sender as DataGridRow;
                // get the obect and then Invoice ID opne the Id in readonly mode
                dhDoctors objTodisplay = new dhDoctors();
                // need to update to docview // first get view object then create new doctore obj
                dhDoctorView objtemp = ((dhDoctorView)dgr.Item);


                objTodisplay = this.MyViewModel.db.Doctors.Find(objtemp.IDocid);
                if (objTodisplay != null)
                {
                    objTodisplay.IUpdate = 1;
                    AddDoctorsViewModel ObjSetToEdit = new AddDoctorsViewModel(objTodisplay);
                    //objvm.SelectToEdit(new AddPartyViewModel(objTodisplay));
                    Globalized.LoadThisObject(ObjSetToEdit, "Edit Doctor '" + objTodisplay.VfName + " " + objTodisplay.VlName + "'", Globalized.AppModuleList.Where(xx => xx.VModuleName == "Doctors").FirstOrDefault().VShortDescription);
                }
            }
        }
        private void BtnSaveDoctor_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (objNewDoctor.IUpdate == 0 || objNewDoctor.IUpdate == null)
                {
                    if (objNewDoctor.TokenStart == "" || objNewDoctor.TokenStart == null)
                    {
                        objNewDoctor.TokenStart = objNewDoctor.VfName.Substring(0, 2).ToUpper();
                    }
                    MyViewModel.db.Doctors.Add(objNewDoctor);
                    MyViewModel.db.SaveChanges();;
                    // for investigations
                    foreach (DocInvestigations item in objNewDoctor.DocInvestigations)
                    {
                        item.IDocid    = objNewDoctor.IDocid;
                        item.BIsActive = true;
                        MyViewModel.db.DocInvestigations.Add(item);
                    }
                    // for doc procedures
                    dhAccount objAccount = MyViewModel.InsertUpdateAccount(objNewDoctor);
                    MyViewModel.db.Accounts.Add(objAccount);
                    //  need to set for doc proc
                    this.AddEditDocProcedures();
                    Globalized.SetMsg("DOC01", DataHolders.MsgType.Info);
                }
                // if update flag is set
                if (objNewDoctor.IUpdate == 1)
                {
                    // dhDoctors temp =  MyViewModel.db.Doctors.Find(objNewDoctor.IDocid);
                    objNewDoctor = (dhDoctors)this.NewDoctorGrid.DataContext;
                    if (objNewDoctor.TokenStart == "" || objNewDoctor.TokenStart == null)
                    {
                        objNewDoctor.TokenStart = objNewDoctor.VfName.Substring(0, 2).ToUpper();
                    }
                    MyViewModel.db.Doctors.Attach(objNewDoctor);
                    //.State = EntityState.Added;
                    MyViewModel.db.Entry(objNewDoctor).State = EntityState.Modified;

                    dhAccount objAccount = MyViewModel.InsertUpdateAccount(objNewDoctor);

                    //
                    MyViewModel.db.Accounts.Attach(objAccount);
                    MyViewModel.db.Entry(objAccount).State = EntityState.Modified;


                    // check existing investigation
                    ObservableCollection <DocInvestigations> crntInv = MyViewModel.db.DocInvestigations.Where(x => x.IDocid == objNewDoctor.IDocid && x.BIsActive == true).ToObservableCollection();
                    foreach (DocInvestigations item in objNewDoctor.DocInvestigations)
                    {
                        item.IDocid = objNewDoctor.IDocid;
                        // make this investigation active
                        item.BIsActive = true;
                        if (crntInv.Select(x => x.IDocInvestigationsId == item.IDocInvestigationsId).FirstOrDefault() == false)
                        {
                            MyViewModel.db.DocInvestigations.Add(item);
                        }
                        else
                        {
                            DocInvestigations tempDoinv = this.MyViewModel.db.DocInvestigations.Find(item.IDocInvestigationsId);
                            if (tempDoinv != null)
                            {
                                tempDoinv = item;
                            }
                        }
                        // if(crntInv.fi)
                    }

                    //  need to set for doc proc
                    this.AddEditDocProcedures();

                    Globalized.SetMsg("DOC02", DataHolders.MsgType.Info);
                }



                //  final save and update model
                objNewDoctor.IUpdate = 1; //  now it will ebe update object

                MyViewModel.db.SaveChanges();
                // set Doctor
                MyViewModel.ObjNewDoctor = objNewDoctor;
                MyViewModel.ObjNewDoctor.DocInvestigations = MyViewModel.GetActiveDocInvestigations();


                MyViewModel.DoctorAccount    = MyViewModel.GetDocAccount();
                this.AccountInfo.DataContext = MyViewModel.DoctorAccount;

                Globalized.ShowMsg(lblErrorMsg);
            }
            catch (Exception ex)
            {
                Globalized.SetMsg(ex.Message, MsgType.Error);
                Globalized.ShowMsg(lblErrorMsg);
            }


            //  this.DataContext
        }