Example #1
0
        public ActionResult CreatePatient(CreatePatientModel model)
        {
            var db_logic = new DatabaseLogic(connection);

            db_logic.PostCreatePatientData(model);

            return(RedirectToAction("AssignPatient"));
        }
Example #2
0
        /*
         * PostCreatePatientData - void
         *
         * Once the user is done entering new patient data on the CreatePatient
         * view, the information is saved to the database here. Method takes in
         * one parameter, a model from the CreatePatient view with all of the
         * user input.
         *
         */
        public void PostCreatePatientData(CreatePatientModel model)
        {
            connection.Open();

            //Finds a random 7-digit MRN (medical record number) that's not
            //already in the database assigned to another patient, assigns that
            //MRN to the new patient
            string randomizeMrn = "SELECT FLOOR(RAND() * 9000000 + 1000000) AS " +
                                  "random_num FROM ehr_patients WHERE 'mrn' NOT IN (SELECT mrn " +
                                  "FROM ehr_patients) LIMIT 1";


            MySqlCommand    cmd1       = new MySqlCommand(randomizeMrn, connection);
            MySqlDataReader dataReader = cmd1.ExecuteReader();
            int             random_mrn = 0;

            while (dataReader.Read())
            {
                random_mrn = dataReader.GetInt32(0);
            }
            model.mrn = random_mrn;

            connection.Close();


            connection.Open();

            //Generate mysql query from data stored in model
            string query = $"INSERT INTO ehr_patients (first_name, last_name, " +
                           "gender, birthdate, weight, bmi, unit, admit_date, room, " +
                           "allergies, attending, isolation, infection, code_status, " +
                           "healthcare_directives, language, mrn) VALUES " +
                           "('{model.firstName}', '{model.lastName}', '{model.gender}', " +
                           "'{model.birthDate}', '{model.weight}', '{model.bmi}', " +
                           "'{model.unit}', '{model.admitDate}', '{model.room}', " +
                           "'{model.allergies}', '{model.attending}', '{model.isolation}', " +
                           "'{model.infection}', '{model.codeStatus}', '{model.healthcareDirs}', " +
                           "'{model.language}', '{model.mrn}')";

            MySqlCommand cmd = new MySqlCommand(query, connection);

            //Run query and insert data into the database
            cmd.ExecuteNonQuery();

            //Create unique patient table for flow sheets based upon patient mrn
            string       str_mrn     = random_mrn.ToString();
            string       createTable = $"CREATE TABLE fs_" + str_mrn + " (date_time VARCHAR(20) NOT NULL, bp VARCHAR(20), pulse VARCHAR(20), temp VARCHAR(20), respirations VARCHAR(20), spo2 VARCHAR(20), rr VARCHAR(20), quality VARCHAR(50), map VARCHAR(20), iv VARCHAR(20), oral_intake VARCHAR(50), uop VARCHAR(20), PRIMARY KEY (date_time))";
            MySqlCommand cmd2        = new MySqlCommand(createTable, connection);

            cmd2.ExecuteNonQuery();

            connection.Close();
        }
        public async Task <IActionResult> CreatePatient(CreatePatientModel model)
        {
            if (ModelState.IsValid)
            {
                AppUser user = new AppUser
                {
                    UserName    = model.Name,
                    Surname     = model.Surname,
                    City        = model.City,
                    ZipCode     = model.ZipCode,
                    Email       = model.Email,
                    PhoneNumber = model.PhoneNumber,
                    ChooseRole  = model.ChooseRole
                };


                IdentityResult result = await userManager.CreateAsync(user, model.Password);



                if (result.Succeeded)
                {
                    Patient patient = new Patient()
                    {
                    };
                    repository.AddPatientToUser(patient, user.Email);
                    await repository.AddRoleToUser(user.Email, user.ChooseRole);

                    return(RedirectToAction("HomePage", "Home", null));
                }
                else
                {
                    foreach (IdentityError error in result.Errors)
                    {
                        ModelState.AddModelError("", error.Description);
                    }
                }
            }

            return(View("PatientView", model));
        }
Example #4
0
        public IActionResult CreatePatient([FromBody] CreatePatientModel model)
        {
            var id = _createPatientCommand.Execute(model);

            return(CreatedAtRoute("GetPatient", new { id }, ""));
        }
Example #5
0
 public void CreatePatient(CreatePatientModel patientModel)
 {
 }