コード例 #1
0
        /// <summary>
        /// Inserts doctor data
        /// returns last inserted id
        /// </summary>
        /// <returns></returns>
        public static int InsertDoctor(int personId, int doctortypeid, string username, string password)
        {
            // perform encryption on password
            try
            {
                HealtheeEntities db = new HealtheeEntities();
                if (DEBUG)
                {
                    db.Database.Log = Console.WriteLine;
                }
                Doctor d = new Doctor
                {
                    PersonID     = personId,
                    DoctorTypeID = doctortypeid,
                    Username     = username,
                    Password     = password
                };

                db.Doctors.Add(d);
                db.SaveChanges();
                return(d.DoctorID);
            }
            catch (Exception e)
            {
                return(0);
            }
        }
コード例 #2
0
        /// <summary>
        /// Adds new appointment
        /// </summary>
        /// <returns></returns>
        public static int InsertAppointment(int doctorid, int patientid, int statusid, string date, string time, string notes)
        {
            try
            {
                HealtheeEntities db = new HealtheeEntities();
                if (DEBUG)
                {
                    db.Database.Log = Console.WriteLine;
                }
                Appointment a = new Appointment
                {
                    DoctorID        = doctorid,
                    PatientID       = patientid,
                    StatusID        = statusid,
                    AppointmentDate = date,
                    AppointmentTime = time,
                    Notes           = notes
                };

                db.Appointments.Add(a);
                db.SaveChanges();
                return(a.AppointmentID);
            }
            catch (Exception e)
            {
                return(0);
            }
        }
コード例 #3
0
        /// <summary>
        /// Inserts row do Activity table
        /// </summary>
        /// <param name="activityType"></param>
        /// <param name="doctorID"></param>
        /// <param name="statusID"></param>
        /// <param name="details"></param>
        /// <param name="data"></param>
        public static void AddDoctorActivity(int activityType, int doctorID, int statusID, string details, string data)
        {
            try
            {
                HealtheeEntities db = new HealtheeEntities();
                if (DEBUG)
                {
                    db.Database.Log = Console.WriteLine;
                }

                db.Activities.Add(new Activity()
                {
                    ActivityTypeID = activityType,
                    DoctorID       = doctorID,
                    StatusID       = statusID,
                    Details        = details,
                    Data           = data,
                    ActivityDate   = DateTime.Now
                });
                db.SaveChanges();
            }
            catch (Exception e)
            {
                // log exception
            }
        }
コード例 #4
0
        /// <summary>
        /// Updates medical record
        /// </summary>
        /// <param name="allergies"></param>
        /// <param name="medication"></param>
        /// <param name="notes"></param>
        /// <returns></returns>
        public static bool UpdateMedicalRecord(int medicalrecordid, string allergies, string medication, string notes)
        {
            try
            {
                HealtheeEntities db = new HealtheeEntities();
                if (DEBUG)
                {
                    db.Database.Log = Console.WriteLine;
                }

                var query = from med in db.MedicalRecords
                            where med.MedicalRecordID == medicalrecordid
                            select med;
                MedicalRecord medrecord = query.FirstOrDefault();
                medrecord.Allergies  = allergies;
                medrecord.Medication = medication;
                medrecord.Notes      = notes;
                db.SaveChanges();

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
コード例 #5
0
        /// <summary>
        /// Inserts a medical record
        /// </summary>
        /// <param name="allergies"></param>
        /// <param name="medication"></param>
        /// <param name="notes"></param>
        /// <returns></returns>
        public static int InsertMedicalRecord(string allergies, string medication, string notes)
        {
            try
            {
                HealtheeEntities db = new HealtheeEntities();
                if (DEBUG)
                {
                    db.Database.Log = Console.WriteLine;
                }
                MedicalRecord m = new MedicalRecord
                {
                    Allergies  = allergies,
                    Medication = medication,
                    Notes      = notes
                };

                db.MedicalRecords.Add(m);
                db.SaveChanges();
                return(m.MedicalRecordID);
            }
            catch (Exception e)
            {
                return(0);
            }
        }
コード例 #6
0
        /// <summary>
        /// Updates a person record
        /// </summary>
        /// <param name="personid"></param>
        /// <param name="firstname"></param>
        /// <param name="lastname"></param>
        /// <param name="gender"></param>
        /// <param name="dob"></param>
        /// <param name="nationalid"></param>
        /// <param name="mobilenumber"></param>
        /// <param name="homenumber"></param>
        /// <param name="worknumber"></param>
        /// <param name="address1"></param>
        /// <param name="address2"></param>
        /// <param name="city"></param>
        /// <param name="country"></param>
        /// <returns></returns>
        public static bool UpdatePerson(int personid, string firstname, string lastname, string gender, DateTime dob, string nationalid, string mobilenumber,
                                        string homenumber, string worknumber, string address1, string address2, string city, string country, string email)
        {
            try
            {
                HealtheeEntities db = new HealtheeEntities();
                if (DEBUG)
                {
                    db.Database.Log = Console.WriteLine;
                }

                var query = from p in db.People
                            where p.PersonID == personid
                            select p;
                Person person = query.FirstOrDefault();
                //if (person == null) return false;

                person.FirstName = firstname;
                person.LastName  = lastname;
                person.Gender    = gender;
                if (dob != DateTime.MinValue)
                {
                    person.DateOfBirth = dob;
                }
                person.NationalID   = nationalid;
                person.MobileNumber = mobilenumber;
                person.HomeNumber   = homenumber;
                person.Address1     = address1;
                person.Address2     = address2;
                person.City         = city;
                person.Country      = country;
                person.Email        = email;
                person.LastUpdated  = DateTime.Now;

                db.SaveChanges();

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
コード例 #7
0
        /// <summary>
        /// Inserts person data into database
        /// returns last inserted id
        /// </summary>
        /// <returns></returns>
        public static int InsertPerson(string firstname, string lastname, string gender, DateTime dob, string nationalid, string mobilenumber,
                                       string homenumber, string worknumber, string address1, string address2, string city, string country, string email)
        {
            try
            {
                HealtheeEntities db = new HealtheeEntities();
                if (DEBUG)
                {
                    db.Database.Log = Console.WriteLine;
                }
                Person p = new Person {
                    FirstName    = firstname,
                    LastName     = lastname,
                    Gender       = gender,
                    NationalID   = nationalid,
                    MobileNumber = mobilenumber,
                    HomeNumber   = homenumber,
                    WorkNumber   = worknumber,
                    Address1     = address1,
                    Address2     = address2,
                    City         = city,
                    Country      = country,
                    Email        = email
                };

                if (dob != DateTime.MinValue)
                {
                    p.DateOfBirth = dob;
                }

                db.People.Add(p);
                db.SaveChanges();
                return(p.PersonID);
            }
            catch (Exception e)
            {
                return(0);
            }
        }
コード例 #8
0
        /// <summary>
        /// Inserts a row into patient table
        /// </summary>
        /// <param name="personid"></param>
        /// <param name="medicalrecordid"></param>
        /// <returns></returns>
        public static int InsertPatient(int personid, int medicalrecordid)
        {
            try
            {
                HealtheeEntities db = new HealtheeEntities();
                if (DEBUG)
                {
                    db.Database.Log = Console.WriteLine;
                }
                Patient p = new Patient
                {
                    PersonID        = personid,
                    MedicalRecordID = medicalrecordid
                };

                db.Patients.Add(p);
                db.SaveChanges();
                return(p.PatientID);
            }
            catch (Exception e)
            {
                return(0);
            }
        }