Esempio n. 1
0
        public void Test_CreatePatient_Success(string Identification, string FirstName, string LastName, int Age, string Email, string PhoneNumber)
        {
            SQL.Patients patient = new SQL.Patients
            {
                Identification = Identification,
                FirstName      = FirstName,
                LastName       = LastName,
                Age            = Age,
                Email          = Email,
                PhoneNumber    = PhoneNumber
            };

            _patientRepository.Insert(patient);
            _patientRepository.Save();

            Assert.IsTrue(patient.Id > 0);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a new patience
        /// </summary>
        /// <param name="model">Patient information detail</param>
        /// <returns></returns>
        public bool CreatePatient(PatientModel model)
        {
            bool isCreated = true;

            SQL.Patients ptDB = new SQL.Patients
            {
                Identification = model.Identification,
                FirstName      = model.FirstName,
                LastName       = model.LastName,
                Age            = model.Age,
                PhoneNumber    = model.PhoneNumber,
                Email          = model.Email
            };

            _patientRepository.Insert(ptDB);
            _patientRepository.Save();

            return(isCreated);
        }
Esempio n. 3
0
        /// <summary>
        /// Get patient details by a given id
        /// </summary>
        /// <param name="identification">Patient identification</param>
        /// <returns></returns>
        public Patient GetPatientByIdentification(string identification)
        {
            SQL.Patients ptDb = _patientRepository.GetPatientsByIdentification(identification);

            if (ptDb != null)
            {
                Patient pt = new Patient
                {
                    Id             = ptDb.Id,
                    Identification = ptDb.Identification,
                    FirstName      = ptDb.FirstName,
                    LastName       = ptDb.LastName,
                    Age            = ptDb.Age.GetValueOrDefault(),
                    PhoneNumber    = ptDb.PhoneNumber,
                    Email          = ptDb.Email,
                    Appointments   = Enumerable.Empty <Appointment>().ToList()
                };

                foreach (SQL.Appointments item in ptDb.Appointments)
                {
                    pt.Appointments.Add(new Appointment
                    {
                        Id                  = item.Id,
                        PatientId           = item.PatientId,
                        SpecialtyId         = item.SpecialtyId,
                        AppointmentDateTime = item.AppointmentDateTime,
                        Specialty           = new Specialty
                        {
                            Id            = item.Specialties.Id,
                            SpecialtyName = item.Specialties.SpecialtyName
                        }
                    });
                }

                return(pt);
            }
            else
            {
                return(new Patient());
            }
        }