Example #1
0
        /// <summary>
        /// Adds the doctor patient.
        /// </summary>
        /// <returns>DoctorPatient.</returns>
        /// <param name="patient_id">Patient identifier.</param>
        /// <param name="username">Username.</param>
        public static bool addDoctorPatient(int patient_id, String username)
        {
            DoctorPatient newUser = new DoctorPatient();

            newUser.patient_id = patient_id;
            newUser.doctor     = username;
            return(Database.createDoctorPatient(newUser));
        }
        /// <summary>
        /// Adds a relationship between a doctor and a patient to the database
        /// </summary>
        /// <param name="doc">
        /// The Doctor-Patient object to be created.
        /// Must have a unique id, a patient_id and a doctor username.
        /// </param>
        /// <returns>
        /// True if the Doctor-Patient was created successully.
        /// False if the Doctor-Patient was not created.
        /// </returns>
        public static bool createDoctorPatient(DoctorPatient docpat)
        {
            if (docpat.patient_id < 0)
            {
                return(false);
            }
            if (docpat.doctor == null)
            {
                return(false);
            }
            var users = db.Table <DoctorPatient>();

            foreach (DoctorPatient x in users)
            {
                if (x.patient_id == docpat.patient_id && x.doctor == docpat.doctor)
                {
                    return(false);
                }
            }
            db.Insert(docpat);
            return(true);
        }