public EditPatientWindow(PatientManager patientmanager)
 {
     InitializeComponent();
     DataContext = this;
     Patient = new Patient();
     IsEdit = false;
     this.PMGR = patientmanager;
 }
 public EditPatientWindow(Patient patient)
 {
     InitializeComponent();
     DataContext = this;
     Patient = patient;
     IsEdit = true;
     TxtBox_Ssn.IsEnabled = false;
     TxtBox_Gender.IsEnabled = false;
     TxtBox_DateOfBirth.IsEnabled = false;
 }
        public void UpdatePatient(Patient patientFromUI, Patient patientToDB)
        {
            if (patientFromUI != null && patientToDB != null)
            {
                patientToDB.UpdatePatient(patientFromUI);
            }
            else
            {
                patientToDB = patientFromUI;
            }

            AppManager.ApplicationDb.SaveChanges();
        }
 public void RemovePatient(Patient patient)
 {
     Patients.Remove(patient);
     AppManager.ApplicationDb.Patients.Remove(patient);
     AppManager.ApplicationDb.SaveChanges();
 }
 public void RemoveMedicalRecord(Patient patient, MedicalRecord medicalRecord)
 {
     //ha benne van, akkor szedjük ki!
     if (patient.MedicalHistory.Contains(medicalRecord))
         patient.MedicalHistory.Remove(medicalRecord);
     AppManager.ApplicationDb.SaveChanges();
 }
 public void NewPatient(Patient patient)
 {
     if (patient != null)
     {
         var duplicatedPatient = (from p in Patients
                                  where patient.Ssn.Equals(p.Ssn)
                                  select p).FirstOrDefault();
         if (duplicatedPatient == null)
         {
             Patients.Add(patient);
             AppManager.ApplicationDb.Patients.Add(patient);
         }
         else
             throw new DuplicatedPatientInDbException(String.Format("Patient identified by ssn {0} already exists in database.", patient.Ssn));
     }
     AppManager.ApplicationDb.SaveChanges();
 }
        public MedicalRecord NewMedicalRecord(Patient patient, MedicalRecord medicalRecord)
        {
            patient.MedicalHistory.Add(medicalRecord);
            AppManager.ApplicationDb.SaveChanges();

            return medicalRecord;
        }
        public Object Clone()
        {
            List<MedicalRecord> MedRecList = new List<MedicalRecord>();
            foreach (MedicalRecord mr in this.MedicalHistory)
            {
                MedRecList.Add((MedicalRecord)mr.Clone());
            }

            Patient clone = new Patient(
                this.Name,
                this.Phone,
                this.DateOfBirth,
                this.Ssn,
                this.Address,
                MedRecList,
                this.Gender);

            return (object)clone;
        }
 public void UpdatePatient(Patient newPatient)
 {
     this.Name = newPatient.Name;
     this.Phone = newPatient.Phone;
     this.DateOfBirth = newPatient.DateOfBirth;
     this.Ssn = newPatient.Ssn;
     this.Address = newPatient.Address;
     this.UpdateMedicalHistory(newPatient.MedicalHistory);
     this.Gender = newPatient.Gender;
 }
        private static void PopulatePatients(ApplicationManager appMgr)
        {
            var pats = appMgr.ApplicationDb.Patients.Select(m => m);
            appMgr.ApplicationDb.Patients.RemoveRange(pats);

            Patient kati = new Patient(
                "Kómás Kati",   //name
                "069011111",       //tel
                "1996.06.20",   //DoB
                "9991999",         //SSN
                "kamucím1",        //address
                null,           //medicalHistory
                Gender.Female   //Gender
                );
            /////
            kati.MedicalHistory.Add(new Model.PatientManagement.MedicalRecord());
            Model.PatientManagement.Procedure proc = new Model.PatientManagement.Procedure();
            //proc.Name = "Új eljárás kati";
            kati.MedicalHistory[0].NewProcedure(proc);

            Patient karesz = new Patient(
                "Kankós Karesz",   //name
                "0660222222",       //tel
                "1991.02.13",   //DoB
                "1359143",         //SSN
                 "kamucím2",        //address
                null,           //medicalHistory
                Gender.Male   //Gender
                );
            karesz.MedicalHistory.Add(new Model.PatientManagement.MedicalRecord());
            Model.PatientManagement.Procedure prockaresz = new Model.PatientManagement.Procedure();
            //prockaresz.Name = "Új eljárás karesz";
            karesz.MedicalHistory[0].NewProcedure(prockaresz);

            Patient imre = new Patient(
                "Itókás Imre",   //name
                "0670333333",       //tel
                "1978.09.06",   //DoB
                "9083825",         //SSN
                "kamucím3",        //address
                null,           //medicalHistory
                Gender.Male   //Gender
                );
            imre.MedicalHistory.Add(new Model.PatientManagement.MedicalRecord());
            Model.PatientManagement.Procedure procimre = new Model.PatientManagement.Procedure();
            //procimre.Name = "Új eljárás imre";
            imre.MedicalHistory[0].NewProcedure(procimre);

            Patient hilda = new Patient(
                "Hasmenős Hilda",   //name
                "062044444",        //tel
                "1957.11.12",       //DoB
                "1125267",            //SSN
                "kamucím3",         //address
                null,               //medicalHistory
                Gender.Female       //Gender
                );
            hilda.MedicalHistory.Add(new Model.PatientManagement.MedicalRecord());
            Model.PatientManagement.Procedure prochilda = new Model.PatientManagement.Procedure();
            //prochilda.Name = "Új eljárás hilda";
            hilda.MedicalHistory[0].NewProcedure(prochilda);

            Patient bertold = new Patient(
                "Barangoló Bertold",//name
                "064055555",        //tel
                "1985.02.16",       //DoB
                "9306484",            //SSN
                "kamucím4",         //address
                null,               //medicalHistory
                Gender.Male         //Gender
                );
            bertold.MedicalHistory.Add(new Model.PatientManagement.MedicalRecord());
            Model.PatientManagement.Procedure procbertold = new Model.PatientManagement.Procedure();
            //procbertold.Name = "Új eljárás bertold";
            bertold.MedicalHistory[0].NewProcedure(procbertold);

            //List<Patient> patList = new List<Patient>();
            //for (int i = 0; i < 81; i++)
            //{
            //    patList.Add(new Patient("Teszt" + i, "0660" + i, "1980.XX." + i,
            //        9989110 + i, i + ". utca " + 10 * i, null, (Gender)(i % 2)));
            //}

            appMgr.ApplicationDb.Patients.Add(kati);
            appMgr.ApplicationDb.Patients.Add(karesz);
            appMgr.ApplicationDb.Patients.Add(imre);
            appMgr.ApplicationDb.Patients.Add(hilda);
            appMgr.ApplicationDb.Patients.Add(bertold);

            //appMgr.ApplicationDb.Patients.AddRange(patList);

            //Console.WriteLine("kati medicalhistory timestamp: "+ kati.MedicalHistory[0].CreatedTimestamp);
            //Console.WriteLine("kati medicalhistory0_procedure0 timestamp: " + kati.MedicalHistory[0].Procedures[0].CreatedTimestamp);

            appMgr.ApplicationDb.SaveChanges();
        }