示例#1
0
        public void CreatePatient_ValidPhoneNo_ReturnsPatient()
        {
            // Arrange
            var validPhoneNo = "07034678899";
            var firstname    = "Olusayo";
            var lastname     = "Babalola";
            var email        = "*****@*****.**";

            // Act
            var patient = _patientService.CreatePatient(validPhoneNo, firstname, lastname, "SYSTEM", email);

            // Assert
            Assert.IsInstanceOfType(patient, typeof(PatientDto));
            Assert.AreEqual(validPhoneNo, patient.PhoneNo);
        }
        private void button4_Click(object sender, EventArgs e)
        {
            int      n  = Convert.ToInt32(this.tbPatients.Text);
            DateTime dt = DateTime.Now;

            for (int i = 0; i < n; i++)
            {
                PASATCore.XMLParameter x = new XMLParameter("patient");
                x.AddParameter("id", "P008");
                x.AddParameter("firstname", "Felix");
                x.AddParameter("lastname", "Jiang");
                x.AddParameter("middlename", "J");
                x.AddParameter("birthDate", "restore");
                x.AddParameter("prefix", "Mr");
                x.AddParameter("suffix", "None");

                x.AddParameter("sex", "M");
                x.AddParameter("pregnancy", "No");

                PatientService ps = new PatientService();
                XMLResult      cc = ps.CreatePatient(x);

                this.pb.Value = (int)(i * 100 / n);
                this.Update();
            }

            System.TimeSpan t = DateTime.Now - dt;
            this.label1.Text = t.Seconds.ToString();
        }
示例#3
0
        public void CreatePatient_NullObject_NullReferenceException()
        {
            // Arrange
            var(unitOfWork, patientRepo, dbCollection) = GetMocks();
            var service = new PatientService(unitOfWork.Object);

            // Act + Assert
            Assert.ThrowsAsync <NullReferenceException>(async() => await service.CreatePatient(null));
        }
        public HttpResponseMessage PostPatient([FromBody] Patient patient)
        {
            //var oPatient = JsonConvert.DeserializeObject<Patient>(patient.ToString());
            bool status = patientService.CreatePatient(patient);

            if (status)
            {
                return(Request.CreateResponse(System.Net.HttpStatusCode.Created, patient));
            }
            return(Request.CreateResponse(System.Net.HttpStatusCode.BadRequest));
        }
示例#5
0
 public ActionResult Create(PatientDto patient)
 {
     try {
         //var staffID = HttpContext.User.Identity.Name;
         _patientService.CreatePatient(patient.PhoneNo, patient.Firstname, patient.Lastname, "SYSTEM", patient.Email);
         return(RedirectToAction("Index"));
     }
     catch {
         return(View());
     }
 }
示例#6
0
        public async Task <ActionResult> CreatePatient([FromBody] Patient patient)
        {
            if (string.IsNullOrEmpty(patient.Username))
            {
                return(BadRequest());
            }

            var result = await patientService.CreatePatient(patient);

            return(CreatedAtAction(nameof(GetPatient), new { result.Id }, result));
        }
示例#7
0
 public void CreatePatient(string username, string name, string surname,
                           DateTime dateOfBirth, string phoneNumber, string email, string parentsName,
                           string gender, string jmbg, bool isGuest, BloodType blood, string lbo)
 {
     patientService.CreatePatient(username, name, surname,
                                  dateOfBirth, phoneNumber, email, parentsName,
                                  gender, jmbg, isGuest, blood, lbo);
     AccountController.GetInstance().AddNewAccount(new Account(username, "pass", new Patient(username, name, surname,
                                                                                             dateOfBirth, phoneNumber, email, parentsName,
                                                                                             gender, jmbg, isGuest, blood, lbo)));
 }
示例#8
0
        public static void Method()
        {
            Patient patient = new Patient();

            patient.Name        = "Alvaro Dias";
            patient.Age         = 10;
            patient.ColorsIssue = ColorIssueStatus.No;

            PatientRepository patientRepository = new PatientRepository();
            PatientService    patientService    = new PatientService(patientRepository);

            patientService.CreatePatient(patient);
        }
        public ActionResult Create(PatientCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var service = new PatientService();

            if (service.CreatePatient(model))
            {
                TempData["SaveResult"] = "New Patient created.";
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Patient could not be created.");
            return(View(model));
        }
示例#10
0
        public async Task CreatePatient_FullInfo_Success()
        {
            // Arrange
            var(unitOfWork, patientRepo, dbCollection) = GetMocks();
            var service = new PatientService(unitOfWork.Object);
            var patient = new Patient
            {
                Id       = 28,
                FullName = "New Name"
            };

            // Act
            await service.CreatePatient(patient);

            // Assert
            Assert.IsTrue(dbCollection.ContainsKey(patient.Id));
        }
示例#11
0
        static void Main(string[] args)
        {
            XpoDefault.DataLayer = XpoDefault.GetDataLayer(ConfigurationManager.ConnectionStrings["XPODemo"].ConnectionString, AutoCreateOption.DatabaseAndSchema);

            using (var uow = new UnitOfWork())
            {
                var user = uow.FindObject <User>(1);

                if (user == null)
                {
                    user = new User(uow)
                    {
                        LastName = "Admin", FirstName = "Admin"
                    };
                    uow.CommitChanges();
                }

                AppHelper.CurrentUserOid = user.Oid;
            }

            var patientService = new PatientService();

            Console.WriteLine("Create New Patient:");
            Console.Write("Enter Patient's MRN: ");
            string mrn = Console.ReadLine();

            Console.Write("Enter Patient's Last Name: ");
            string lastName = Console.ReadLine();

            Console.Write("Enter Patient's First Name: ");
            string firstName = Console.ReadLine();

            Console.Write("Enter Patient's Date of Birth: ");
            string dateOfBirth = Console.ReadLine();

            var patientPOCO = new PatientPOCO()
            {
                MRN = mrn, LastName = lastName, FirstName = firstName, DOB = Convert.ToDateTime(dateOfBirth)
            };

            int oid = patientService.CreatePatient(patientPOCO);

            Console.WriteLine($"Oid of this patient is {oid}.");
        }
示例#12
0
        public async Task <ActionResult <PatientDto> > Post(PatientDto model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var existing = await _patientServices.GetPatientByNameAsync(model.Name);

                    if (existing != null)
                    {
                        return(BadRequest("The patient is already exists!"));
                    }

                    var location = _linkGenerator.GetPathByAction(HttpContext,
                                                                  "Get", "Patients",
                                                                  new { name = model.Name });

                    if (string.IsNullOrWhiteSpace(location))
                    {
                        return(BadRequest("Could not use current name"));
                    }

                    var patient = _mapper.Map <Patient>(model);

                    if (await _patientServices.CreatePatient(patient))
                    {
                        return(Created(location, patient));
                    }

                    return(BadRequest("Something bad happened!"));
                }
                else
                {
                    return(BadRequest(ModelState));
                }
            }
            catch (Exception e)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Database Failure: {e}"));
            }
        }
示例#13
0
 public bool CreatePatient([FromBody] Patient patient)
 {
     return(_patientService.CreatePatient(patient));
 }
示例#14
0
 public ActionResult <Patient> Post(Patient patient)
 {
     patientService.CreatePatient(patient);
     return(CreatedAtRoute("GetPatient", new { id = patient.Id.ToString() }, patient));
 }
示例#15
0
        private void button4_Click(object sender, EventArgs e)
        {
            int n=Convert.ToInt32 (this.tbPatients .Text );
            DateTime dt = DateTime.Now;
            for (int i = 0; i < n; i++)
            {
                PASATCore.XMLParameter x = new XMLParameter("patient");
                x.AddParameter("id", "P008");
                x.AddParameter("firstname", "Felix");
                x.AddParameter("lastname", "Jiang");
                x.AddParameter("middlename", "J");
                x.AddParameter("birthDate", "restore");
                x.AddParameter("prefix", "Mr");
                x.AddParameter("suffix", "None");

                x.AddParameter("sex", "M");
                x.AddParameter("pregnancy", "No");

                PatientService ps = new PatientService();
                XMLResult cc = ps.CreatePatient(x);

                this.pb.Value = (int)(i * 100 / n);
                this.Update();
            }

            System.TimeSpan t = DateTime.Now - dt;
            this.label1.Text = t.Seconds.ToString();
        }
示例#16
0
        private void getPatientInfo()
        {
            //tabc_main.SelectedTab = tabp_cam;
            String phonenumber = txt_phone.Text;

            if (phonenumber == null || phonenumber == "")
            {
                return;
            }

            // try loading the patient data from db
            label5.Text = "尝试与CRM通信";
            Patient p = null;

            try
            {
                p = PatientService.GetPatientByPhone(phonenumber);
            }
            catch (MySqlException mse)
            {
                label5.Text = "CRM通信失败";
                return;
            }

            // if loading failed, add a new one with full info
            if (p == null)
            {
                label5.Text = "病人信息不存在";
                // todo: show confirmation dialog

                DialogResult result = MessageBox.Show("病人信息不存在,添加病人信息吗?", "确认", MessageBoxButtons.YesNo);

                if (result == DialogResult.Yes)
                {
                    String name   = txt_name.Text;
                    String gender = txt_gender.Text;

                    if (name == "")
                    {
                        MessageBox.Show("请填写病人姓名", "确认", MessageBoxButtons.OK);
                        txt_name.Focus();
                        return;
                    }

                    if (gender == "")
                    {
                        MessageBox.Show("请选择病人性别", "确认", MessageBoxButtons.OK);
                        txt_gender.Focus();
                        return;
                    }

                    p = new Patient(-1, name, phonenumber, gender);

                    try
                    {
                        PatientService.CreatePatient(p);
                        label5.Text           = "病人信息已保存";
                        tabc_main.SelectedTab = tabp_cam;
                    }
                    catch (MySqlException mse)
                    {
                        label5.Text = "病人信息保存失败";
                        return;
                    }
                }
            }
            else
            {
                label5.Text = "病人信息已获取";
                // fill in patient information
                txt_name.Text   = p.name;
                txt_gender.Text = p.gender;

                // go to second tab
                tabc_main.SelectedTab = tabp_cam;
            }

            GlobalSettings.SetCurrentPatient(p);
        }