Exemplo n.º 1
0
        private void SavePatientData(object parameter)
        {
            bool newlyAdd = PatientId == 0 ? true : false;

            // DoctorId = _DoctorId;
            var patient = new tPatient {
                PatientId = PatientId, FirstName = FirstName, LastName = LastName, DOB = DOB, SSN = SSN, DoctorId = DoctorId
            };

            DataLayer.DB_SERVER db = new DataLayer.DB_SERVER();

            if (newlyAdd)
            {
                db.Patient.Add(patient);
                db.SaveChanges();
                PatientId = patient.PatientId;
            }
            else
            {
                var patientInDB = db.Patient.FirstOrDefault(e => e.PatientId == PatientId);
                if (patientInDB != null)
                {
                    patientInDB.FirstName = FirstName;
                    patientInDB.LastName  = LastName;
                    patientInDB.DOB       = DOB;
                    patientInDB.SSN       = SSN;
                    patientInDB.DoctorId  = DoctorId;
                    db.SaveChanges();
                }
            }

            if (newlyAdd)
            {
                if (PatentInsertedAction != null)
                {
                    PatentInsertedAction(PatientId);
                }
            }

            var commandParameter = Convert.ToInt16(parameter);

            if (commandParameter != null && commandParameter != 0) //save and next tab
            {
                if (SaveAndNextTabAction != null)
                {
                    SaveAndNextTabAction.Invoke();
                }
            }
        }
Exemplo n.º 2
0
 private void CopyPatientProperties(tPatient patientInfo)
 {
     PatientId = patientInfo.PatientId;
     FirstName = patientInfo.FirstName;
     LastName  = patientInfo.LastName;
     SSN       = patientInfo.SSN;
     DOB       = patientInfo.PatientId == 0 ? System.DateTime.Now : patientInfo.DOB;
     DoctorId  = patientInfo.DoctorId;
     if (patientInfo.PatientId != 0)
     {
         DB_SERVER _db           = new DataLayer.DB_SERVER();
         var       patientDoctor = _db.Doctor.FirstOrDefault(e => e.DoctorId == patientInfo.DoctorId);
         DoctorId   = patientDoctor.DoctorId;
         DoctorName = patientDoctor.FirstName + " " + patientDoctor.LastName;
     }
 }
Exemplo n.º 3
0
        private void LoadPatient(int patientId)
        {
            if (patientId == 0) // newly entry
            {
                PatientInfo        = new PatientInfoViewModel(new tPatient());
                PatientAddressInfo = new PatientAddressViewModel(new tAddress());
            }
            else // Modification need to existing patient;
            {
                DB_SERVER _db = new DataLayer.DB_SERVER();

                var patientInfo    = _db.Patient.FirstOrDefault(e => e.PatientId == patientId);
                var patientAddress = _db.Address.FirstOrDefault(e => e.PatientId == patientId);

                PatientInfo                  = (patientInfo != null) ? new PatientInfoViewModel(patientInfo) : new PatientInfoViewModel(new tPatient());
                PatientAddressInfo           = (patientAddress != null) ? new PatientAddressViewModel(patientAddress) : new PatientAddressViewModel(new tAddress());
                PatientAddressInfo.PatientId = PatientInfo.PatientId;
            }
        }
Exemplo n.º 4
0
        private void LoadPatient(int patientId)
        {
            if (patientId == 0) // newly entry
            {
                PatientInfo = new PatientInfoViewModel(new tPatient());
                PatientAddressInfo = new PatientAddressViewModel(new tAddress());
            }
            else // Modification need to existing patient;
            {
                DB_SERVER _db = new DataLayer.DB_SERVER();

                var patientInfo = _db.Patient.FirstOrDefault(e => e.PatientId == patientId);
                var patientAddress = _db.Address.FirstOrDefault(e => e.PatientId == patientId);

                PatientInfo = (patientInfo != null) ? new PatientInfoViewModel(patientInfo) : new PatientInfoViewModel(new tPatient());
                PatientAddressInfo = (patientAddress != null) ? new PatientAddressViewModel(patientAddress) : new PatientAddressViewModel(new tAddress());
                PatientAddressInfo.PatientId = PatientInfo.PatientId;

            }
        }
Exemplo n.º 5
0
        private void SavePatientData(object parameter)
        {
            bool newlyAdd = PatientId == 0 ? true : false;

           // DoctorId = _DoctorId;
            var patient = new tPatient { PatientId = PatientId, FirstName = FirstName, LastName = LastName, DOB = DOB, SSN = SSN, DoctorId = DoctorId };

            DataLayer.DB_SERVER db = new DataLayer.DB_SERVER();

            if (newlyAdd)
            {
                db.Patient.Add(patient);
                db.SaveChanges();
                PatientId = patient.PatientId;
            }
            else
            {
                var patientInDB = db.Patient.FirstOrDefault(e => e.PatientId == PatientId);
                if (patientInDB != null)
                {
                    patientInDB.FirstName = FirstName;
                    patientInDB.LastName = LastName;
                    patientInDB.DOB = DOB;
                    patientInDB.SSN = SSN;
                    patientInDB.DoctorId = DoctorId;
                    db.SaveChanges();
                }
            }

            if (newlyAdd)
                if (PatentInsertedAction != null)
                    PatentInsertedAction(PatientId);

            var commandParameter = Convert.ToInt16(parameter);

            if (commandParameter != null && commandParameter != 0) //save and next tab
                if (SaveAndNextTabAction != null)
                    SaveAndNextTabAction.Invoke();
        }
Exemplo n.º 6
0
 private void CopyPatientProperties(tPatient patientInfo)
 {
     PatientId = patientInfo.PatientId;
     FirstName = patientInfo.FirstName;
     LastName = patientInfo.LastName;
     SSN = patientInfo.SSN;
     DOB = patientInfo.PatientId == 0 ? System.DateTime.Now : patientInfo.DOB;
     DoctorId = patientInfo.DoctorId;
     if (patientInfo.PatientId != 0)
     {
         DB_SERVER _db = new DataLayer.DB_SERVER();
         var patientDoctor= _db.Doctor.FirstOrDefault(e => e.DoctorId == patientInfo.DoctorId);
         DoctorId = patientDoctor.DoctorId;
         DoctorName = patientDoctor.FirstName + " " + patientDoctor.LastName;
     }
 }
Exemplo n.º 7
0
        private ObservableCollection<tDoctor> LoadDoctor()
        {
            var listDoctor = new ObservableCollection<tDoctor>();

            DB_SERVER db = new DB_SERVER();
            var listDoctorFromDB = db.Doctor;

            foreach (var item in listDoctorFromDB)
                listDoctor.Add(new tDoctor { DoctorId = item.DoctorId, FirstName = item.FirstName, LastName = item.LastName });

            return listDoctor;
        }
Exemplo n.º 8
0
 public void DB_SERVERConstructorTest()
 {
     DB_SERVER db = new DB_SERVER();
     var u =db.User.FirstOrDefault(e => e.UserId == "1");
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
Exemplo n.º 9
0
        private ObservableCollection<tPatient> LoadPatient()
        {
            var listPatient = new ObservableCollection<tPatient>();

            DB_SERVER db = new DB_SERVER();
            var listPatientFromDB = db.Patient;

            foreach (var item in listPatientFromDB)
                listPatient.Add(new tPatient { PatientId = item.PatientId, FirstName = item.FirstName, LastName = item.LastName });

            return listPatient;
        }