public async Task <ActionResult <MedicalHistory> > PostMedicalHistory(MedicalHistoryViewModel medicalHistoryModel)
        {
            var medicalHistory = new MedicalHistory
            {
                BloodType         = medicalHistoryModel.BloodType,
                ApplicationUserId = medicalHistoryModel.ApplicationUserId
            };

            _context.MedicalHistory.Add(medicalHistory);
            await _context.SaveChangesAsync();

            foreach (var operation in medicalHistoryModel.Operations)
            {
                operation.MedicalHistoryId = medicalHistory.Id;
            }

            foreach (var disease in medicalHistoryModel.Diseases)
            {
                disease.MedicalHistoryId = medicalHistory.Id;
            }

            foreach (var sensitivity in medicalHistoryModel.Sensitivities)
            {
                sensitivity.MedicalHistoryId = medicalHistory.Id;
            }

            _context.Operations.AddRange(medicalHistoryModel.Operations);
            _context.Sensitivities.AddRange(medicalHistoryModel.Sensitivities);
            _context.Diseases.AddRange(medicalHistoryModel.Diseases);

            await _context.SaveChangesAsync();

            return(Ok());
        }
        public IActionResult Put([FromODataUri] Guid key, MedicalHistory medicalhistory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            using (var trans = context.Database.BeginTransaction())
            {
                try
                {
                    if (context.MedicalHistories.Find(key) == null)
                    {
                        return(NotFound());
                    }
                    //context = new ApplicationDbContext(context.Options);
                    var local = context.MedicalHistories.Local.FirstOrDefault(it => it.MedicalHistoryID.Equals(key));
                    if (local != null)
                    {
                        context.Entry(local).State = EntityState.Detached;
                    }


                    context.Entry(medicalhistory).State = EntityState.Modified;
                    context.SaveChanges();
                    trans.Commit();
                    return(Ok(medicalhistory));
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    return(BadRequest(ex));
                }
            }
        }
Beispiel #3
0
        public ActionResult MedicalHistory(int id)
        {
            var patient = db.Patients.Find(id);

            if (patient == null)
            {
                return(this.InvokeHttp404(HttpContext));
            }

            var history = db.MedicalHistories
                          .FirstOrDefault(mh => mh.patientID == id);

            if (history == null)
            {
                history           = new MedicalHistory();
                history.patientID = id;
                history.completed = false;
                db.MedicalHistories.Add(history);
                db.SaveChanges();
            }

            var model = new MedicalHistoryViewModel();

            model.patientID = id;
            model.Patient   = patient;
            GlobalHelpers.Transfer <MedicalHistory, MedicalHistoryViewModel>(history, model);
            model.medicalhistoryID = history.ID;
            return(View(model));
        }
        public IActionResult AddMedicalHistory([FromBody] MedicalHistoryDto medicalHistoryDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Pet pet = _repoWrapper.Pet.FindByCondition(p => p.Id == medicalHistoryDto.PetId).FirstOrDefault();

            if (pet == null)
            {
                return(BadRequest("PetId is incorrect"));
            }

            var            config         = new MapperConfiguration(cfg => cfg.CreateMap <MedicalHistoryDto, MedicalHistory>());
            var            mapper         = new Mapper(config);
            MedicalHistory medicalHistory = mapper.Map <MedicalHistoryDto, MedicalHistory>(medicalHistoryDto);

            if (medicalHistory.EndDate == null)
            {
                pet.IsSick = true;
                _repoWrapper.Pet.Update(pet);
            }

            _repoWrapper.MedicalHistory.Create(medicalHistory);
            _repoWrapper.Save();

            return(Ok(new { Success = true }));
        }
        //删除一个客户的病史表
        public void DeleteMedicalHistory(int id)
        {
            MedicalHistory medicalHistory = db.MedicalHistory.Where(p => p.CustomerID == id).ToList().First();;

            db.MedicalHistory.Remove(medicalHistory);
            db.SaveChanges();
        }
        public ActionResult DeleteConfirmed(int id)
        {
            AnimalInfo         animalInfo         = db.AnimalInfo.Find(id);
            AnimalBehavior     animalBehavior     = db.AnimalBehavior.Find(id);
            AnimalHistory      animalHistory      = db.AnimalHistory.Find(id);
            ChipIdentification chipIdentification = db.ChipIdentification.Find(id);
            AdditionalContact  additionalContact  = db.AdditionalContact.Find(id);
            AdditionalPetInfo  additionalPetInfo  = db.AdditonalPetInfo.Find(id);
            Insurance          insurance          = db.Insurance.Find(id);
            MedicalHistory     medicalHistory     = db.MedicalHistory.Find(id);
            SecondaryContact   secondaryContact   = db.SecondaryContact.Find(id);
            TrackingOperations trackingOperations = db.TrackingOperations.Find(id);

            db.AnimalInfo.Remove(animalInfo);
            db.AnimalBehavior.Remove(animalBehavior);
            db.AnimalHistory.Remove(animalHistory);
            db.ChipIdentification.Remove(chipIdentification);
            db.AdditionalContact.Remove(additionalContact);
            db.AdditonalPetInfo.Remove(additionalPetInfo);
            db.Insurance.Remove(insurance);
            db.MedicalHistory.Remove(medicalHistory);
            db.SecondaryContact.Remove(secondaryContact);
            db.TrackingOperations.Remove(trackingOperations);

            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,DiseaseDisorder,DateOfDiagnosis,AgeAtOnset,Status,DateResolved,MedicalProviderId,Comments")] MedicalHistory medicalHistory)
        {
            if (id != medicalHistory.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(medicalHistory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MedicalHistoryExists(medicalHistory.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(medicalHistory));
        }
Beispiel #8
0
        public IHttpActionResult PostPatient(Patient patient)
        {
            if (!ModelState.IsValid || db.Users.Any(x => x.Email == patient.Email))
            {
                return(BadRequest(ModelState));
            }

            var medicalHistory = new MedicalHistory()
            {
                MedicalHistoryId = patient.UserId
            };
            int UserClaimId = db.UserClaims.FirstOrDefault(x => x.ClaimValue == "Patient").Id;

            patient.UserClaimId = UserClaimId;

            patient.URLImage = Constants.DefaultPatientImage;
            try
            {
                db.Patients.Add(patient);
                db.MedicalHistorys.Add(medicalHistory);
                db.SaveChanges();
                return(CreatedAtRoute("GetPatientById", new { id = patient.UserId }, patient));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #9
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser
                {
                    UserName  = registerModel.Email,
                    Email     = registerModel.Email,
                    FirstName = registerModel.FirstName,
                    LastName  = registerModel.LastName,
                };
                var result = await _userManager.CreateAsync(user, registerModel.Password);

                var medicalHistory = new MedicalHistory();

                var path            = Path.Combine(_hostingEnvironment.WebRootPath, "images", "Default-welcomer.png");
                var imageFileStream = System.IO.File.OpenRead(path);

                byte[] imageByteArray;

                using (var memoryStream = new MemoryStream())
                {
                    imageFileStream.CopyTo(memoryStream);
                    imageByteArray = memoryStream.ToArray();
                }
                var patient = new Models.Patient
                {
                    Id             = user.Id,
                    User           = user,
                    MedicalHistory = medicalHistory,
                    Picture        = new ProfilePicture()
                    {
                        Id        = Guid.NewGuid().ToString(),
                        ImageData = imageByteArray
                    }
                };

                var pat = await _userManager.FindByIdAsync(patient.Id);

                await _userManager.AddToRoleAsync(pat, "Patient");

                context.Patient.Add(patient);
                await context.SaveChangesAsync();

                if (result.Succeeded)
                {
                    await _signInManager.SignInAsync(user, isPersistent : false);

                    return(RedirectToPage("/Patient/Edit"));
                }
                else
                {
                    foreach (var error in result.Errors)
                    {
                        ModelState.AddModelError("", error.Description);
                    }
                }
            }
            return(Page());
        }
        public void Add(MedicalHistoryDTO medicalHistory, int userId)
        {
            MedicalHistory model = _mapper.Map <MedicalHistory>(medicalHistory);

            model.CreationDate = DateTime.Now;
            model.CreatedBy    = userId;
            dbset.Add(model);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            MedicalHistory medicalHistory = db.MedicalHistory.Find(id);

            db.MedicalHistory.Remove(medicalHistory);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        //新增一个用户的的同时新建病史信息
        public void AddCustomerDetails(int CustomerID)
        {
            MedicalHistory medicalHistory = new MedicalHistory();

            medicalHistory.CustomerID = CustomerID;
            db.MedicalHistory.Add(medicalHistory);
            db.SaveChanges();
        }
Beispiel #13
0
        public void AddMedicalInfoToDB(MedicalHistory medicalHistory)
        {
            MedicalHistory newMedical = new MedicalHistory();

            newMedical = medicalHistory;
            _context.MedicalHistories.Add(newMedical);
            _context.SaveChanges();
        }
Beispiel #14
0
        public MedicalHistory GetMedicalInfoFromDB(MedicalHistory medicalHistory)
        {
            var medicalInDB = _context.MedicalHistories.Where(m => m.Age == medicalHistory.Age).Where(m => m.BloodType == medicalHistory.BloodType)
                              .Where(m => m.Ethnicity == medicalHistory.Ethnicity).Where(m => m.HasAllergies == medicalHistory.HasAllergies)
                              .Where(m => m.Height == medicalHistory.Height).Where(m => m.IsMale == medicalHistory.IsMale)
                              .Where(m => m.OnMedications == medicalHistory.OnMedications).Where(m => m.Weight == medicalHistory.Weight).FirstOrDefault();

            return(medicalInDB);
        }
        /// <summary>
        /// Creator: Daulton Schilling
        /// Created: 3/18/2020
        /// Approver: Carl Davis 4/16/2020
        /// Approver:
        ///
        /// Method to update an animals medical history
        /// </summary>
        /// <remarks>
        /// Updater:
        /// Updated:
        /// Update:
        /// </remarks>
        /// <Returns>
        /// bool
        /// </Returns>
        public int UpdateAnimalMedicalHistory(MedicalHistory old_, MedicalHistory new_)
        {
            int rows = 0;
            var conn = DBConnection.GetConnection();
            var cmd  = new SqlCommand("SP_Update_Animal_Medical_History", conn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@AnimalID", new_
                                        .AnimalID);

            cmd.Parameters.AddWithValue("@NewVaccinations",
                                        new_.Vaccinations);

            cmd.Parameters.AddWithValue("@OldVaccinations",
                                        old_.Vaccinations);


            cmd.Parameters.AddWithValue("@NewSpayedNeutered",
                                        new_.Spayed_Neutered);

            cmd.Parameters.AddWithValue("@OldSpayedNeutered",
                                        old_.Spayed_Neutered);

            cmd.Parameters.AddWithValue("@NewMostRecentVaccinationDate",
                                        new_.MostRecentVaccinationDate);

            cmd.Parameters.AddWithValue("@OldMostRecentVaccinationDate",
                                        old_.MostRecentVaccinationDate);

            cmd.Parameters.AddWithValue("@NewAdditionalNotes",
                                        new_.AdditionalNotes);

            cmd.Parameters.AddWithValue("@OldAdditionalNotes",
                                        old_.AdditionalNotes);


            try
            {
                conn.Open();
                rows = cmd.ExecuteNonQuery();
                if (rows == 0)
                {
                    throw new ApplicationException("Record not found.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return(rows);
        }
        /// <summary>
        /// Creator: Daulton Schilling
        /// Created: 3/13/2020
        /// Approver: Chuck Baxter 3/13/2020
        /// Approver:
        ///
        /// Gets an animals medical history
        /// </summary>
        /// <remarks>
        /// Updater:
        /// Updated:
        /// Update:
        /// </remarks>
        /// <param name="AnimalID"></param>
        /// <Returns>
        /// List<NewAnimalChecklist>
        /// </Returns>
        public List <MedicalHistory> GetAnimalMedicalHistoryByAnimalID(int id)
        {
            var conn = DBConnection.GetConnection();

            var cmd = new SqlCommand("sp_Select_AnimalMedicalHistory_By_AnimalID");


            List <MedicalHistory> animals = new List <MedicalHistory>();


            cmd.Connection = conn;


            cmd.CommandType = CommandType.StoredProcedure;


            cmd.Parameters.Add("@AnimalID", SqlDbType.Int);
            cmd.Parameters["@AnimalID"].Value = id;


            try
            {
                conn.Open();
                var reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        var animal = new MedicalHistory();

                        animal.AnimalID                  = reader.GetInt32(0);
                        animal.AnimalName                = reader.GetString(1);
                        animal.AnimalSpeciesID           = reader.GetString(2);
                        animal.Vaccinations              = reader.GetString(3);
                        animal.Spayed_Neutered           = reader.GetBoolean(4);
                        animal.MostRecentVaccinationDate = reader.GetDateTime(5);
                        animal.AdditionalNotes           = reader.GetString(6);



                        animals.Add(animal);
                    }
                }

                reader.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return(animals);
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            MedicalHistory medicalHistory = await db.MedicalHistories.FindAsync(id);

            db.MedicalHistories.Remove(medicalHistory);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Beispiel #18
0
        public ActionResult PostInputHistory(string doctorId, int patientId, VM_inputHistory history)
        {
            int id_history;
            var data = doctorService.scheduleDetail(doctorId, patientId);


            var historys = new MedicalHistory();

            historys.Sickness        = history.sick;
            historys.DoctorID        = data.DoctorID;
            historys.PatientID       = data.PatientID;
            historys.DescriptionInfo = history.descriptionSick;
            historys.CheckUpPrice    = history.price;
            historys.CheckUpDate     = DateTime.Now.Date;
            db.MedicalHistories.Add(historys);
            var getId = db.Schedules.Where(e => e.DoctorID == doctorId && e.BookingStatus == "Booking" && e.PatientID == data.PatientID).FirstOrDefault().ID;

            db.Schedules.Find(getId).BookingStatus = "Completed";
            db.SaveChanges();
            id_history = historys.ID;

            try
            {
                int leng = history.medicineId.Count();
                for (var i = 0; i < leng; i++)
                {
                    var     patientMedic = new PatientMedicine();
                    decimal price        = history.medicineId[i];

                    patientMedic.MedicalHistoryID = id_history;
                    patientMedic.MedicineID       = history.medicineId[i];
                    patientMedic.Quantity         = history.quantity[i];
                    patientMedic.Description      = history.describeMedic[i];
                    patientMedic.MedicalPrice     = db.Medicines.Where(e => e.ID == price).First().Price;
                    db.PatientMedicines.Add(patientMedic);
                    db.SaveChanges();
                }

                for (var j = 0; j < leng; j++)
                {
                    var medicTrans = new MedicineTransaction();
                    medicTrans.MedicineID        = history.medicineId[j];
                    medicTrans.DoctorID          = data.DoctorID;
                    medicTrans.TransactionDate   = DateTime.Now;
                    medicTrans.TransactionStatus = false;
                    medicTrans.Quantity          = history.quantity[j];
                    db.MedicineTransactions.Add(medicTrans);
                    db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                return(RedirectToAction("Index"));
            }
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Id,AnimalId,Year,Vaccination,Reason")] MedicalHistory medicalHistory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(medicalHistory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(medicalHistory));
 }
 public IActionResult Put([FromBody] MedicalHistory medicalHistory)
 {
     if (ModelState.IsValid)
     {
         _context.MedicalHistories.Update(medicalHistory);
         _context.SaveChanges();
         return(Ok(medicalHistory));
     }
     return(BadRequest());
 }
        public async Task <IActionResult> Create([Bind("Id,DiseaseDisorder,DateOfDiagnosis,AgeAtOnset,Status,DateResolved,MedicalProviderId,Comments")] MedicalHistory medicalHistory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(medicalHistory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(medicalHistory));
        }
Beispiel #22
0
 /// <summary>
 /// Creator: Daulton Schilling
 /// Created: 3/18/2020
 /// Approver: Carl Davis 4/16/2020
 /// Approver:
 ///
 /// Fake method to update an animals medical history
 /// </summary>
 /// <remarks>
 /// Updater:
 /// Updated:
 /// Update:
 /// </remarks>
 /// <Returns>
 /// int
 /// </Returns>
 public int UpdateAnimalMedicalHistory(MedicalHistory old_, MedicalHistory new_)
 {
     foreach (MedicalHistory med in MH)
     {
         if (old_ == new_)
         {
             return(1);
         }
     }
     return(0);
 }
        public ActionResult Create([Bind(Include = "Id,AnimalId,Year,Vaccination,Reason")] MedicalHistory medicalHistory)
        {
            if (ModelState.IsValid)
            {
                db.MedicalHistory.Add(medicalHistory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(medicalHistory));
        }
        public async Task <ActionResult> Edit([Bind(Include = "MedicalHistoryID,Description")] MedicalHistory medicalHistory)
        {
            if (ModelState.IsValid)
            {
                db.Entry(medicalHistory).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(medicalHistory));
        }
        public void Update(MedicalHistoryDTO medicalHistory, int userId)
        {
            MedicalHistory model = _mapper.Map <MedicalHistory>(medicalHistory);

            model.ModifiedDate = DateTime.Now;
            model.ModifiedBy   = userId;

            entities.Entry(model).State = EntityState.Modified;
            entities.Entry(model).Property(m => m.CreatedBy).IsModified    = false;
            entities.Entry(model).Property(m => m.CreationDate).IsModified = false;
        }
Beispiel #26
0
        public ActionResult Edit(Customer customer, Present present, MedicalHistory history, Family family, Menstrual menstrual, Marriage marriage)
        {
            db.Entry(customer).State  = System.Data.Entity.EntityState.Modified;
            db.Entry(present).State   = System.Data.Entity.EntityState.Modified;
            db.Entry(history).State   = System.Data.Entity.EntityState.Modified;
            db.Entry(family).State    = System.Data.Entity.EntityState.Modified;
            db.Entry(menstrual).State = System.Data.Entity.EntityState.Modified;
            db.Entry(marriage).State  = System.Data.Entity.EntityState.Modified;

            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult> Create([Bind(Include = "MedicalHistoryID,Description")] MedicalHistory medicalHistory)
        {
            if (ModelState.IsValid)
            {
                db.MedicalHistories.Add(medicalHistory);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(medicalHistory));
        }
Beispiel #28
0
 public void AddHistory(MedicalHistory medicalHistory)
 {
     try
     {
         historyDataLayer.AddMedicalHistory(medicalHistory);
     }
     catch (Exception e)
     {
         ExceptionHandler.PrintException(e, new StackTrace(true));
         throw e;
     }
 }
        /// <summary>
        /// Creator: Daulton Schilling
        /// Created: 4/6/2020
        /// Approver: Carl Davis 4/16/2020
        /// Approver:
        ///
        /// Method to update an animals medical history
        /// </summary>
        /// <remarks>
        /// Updater:
        /// Updated:
        /// Update:
        /// </remarks>
        /// <Returns>
        /// int
        /// </Returns>
        public int UpdateAnimalMedicalHistory(MedicalHistory old_, MedicalHistory new_)
        {
            int result;

            try
            {
                result = _medHistoryAccessor.UpdateAnimalMedicalHistory(old_, new_);
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Update Failed!", ex);
            }
            return(result);
        }
        // GET: MedicalHistories/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MedicalHistory medicalHistory = db.MedicalHistory.Find(id);

            if (medicalHistory == null)
            {
                return(HttpNotFound());
            }
            return(View(medicalHistory));
        }