public IHttpActionResult PutOpdRegister(int id, OpdRegister opdRegister)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != opdRegister.Id)
            {
                return(BadRequest());
            }

            db.Entry(opdRegister).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OpdRegisterExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
        public IHttpActionResult PutComplaint(int id, Complaint complaint)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != complaint.Id)
            {
                return(BadRequest());
            }

            db.Entry(complaint).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ComplaintExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#3
0
 public ActionResult Create([Bind(Include = "Id,ServiceName,DepartmentId,CashPrice, ServiceGroupId, IsIPD, IsOPD")] Service service)
 {
     service.DateAdded = DateTime.Now;
     db.Services.Add(service);
     db.SaveChanges();
     return(Redirect("Index"));
 }
示例#4
0
        public ActionResult Create([Bind(Include = "Id,TariffName,CompanyId,DateAdded")] Tariff tariff)

        {
            tariff.DateAdded = DateTime.Now;

            //if (ModelState.IsValid)
            //{

            //}

            try
            {
                db.Tariffs.Add(tariff);
                db.SaveChanges();
                return(RedirectToAction("Create"));
            }
            catch (DbEntityValidationException ex)
            {
                var errorMessages = ex.EntityValidationErrors
                                    .SelectMany(x => x.ValidationErrors)
                                    .Select(x => x.ErrorMessage);


                var fullErrorMessage = string.Join("; ", errorMessages);


                var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage);


                return(Content(exceptionMessage));
            }

            //ViewBag.CompanyId = new SelectList(db.Companies, "Id", "CompanyName", tariff.CompanyId);
            //return Json(tariff);
        }
示例#5
0
        public ActionResult AddNutritionAdultRegister(NutritionAdultRegister data)
        {
            db.NutritionAdultRegisters.Add(data);
            db.SaveChanges();


            return(View("Index"));
        }
        public ActionResult SavePatientProfile(RenalPatientProfile data)
        {
            data.UserId    = (int)Session["UserId"];
            data.BranchId  = 1;
            data.DateAdded = DateTime.Now;

            db.RenalPatientProfiles.Add(data);
            db.SaveChanges();

            return(RedirectToAction("PatientProfile", new { id = data.OPDNo }));
        }
        public ActionResult SavePediatricAdmissionData(PedriaticAdmission data)
        {
            data.UserId    = (int)Session["UserId"];
            data.DateAdded = DateTime.Now;
            data.BranchId  = 1;

            db.PedriaticAdmissions.Add(data);
            db.SaveChanges();

            return(RedirectToAction("Pedriatic"));
        }
示例#8
0
        public ActionResult Create([Bind(Include = "Id,TableName,Field,Required")] FieldMeta fieldMeta)
        {
            if (ModelState.IsValid)
            {
                db.FieldMetas.Add(fieldMeta);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(fieldMeta));
        }
示例#9
0
        public ActionResult Create(Department department)
        {
            department.DateAdded = DateTime.Now;
            if (ModelState.IsValid)
            {
                db.Departments.Add(department);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DepartmentType = new SelectList(db.DepartmentTypes, "Id", "DepartmnetType", department.DepartmentType);
            return(View(department));
        }
        public ActionResult SaveAmbulanceMaster(AmbulanceMaster data)
        {
            data.UserId   = (int)Session["UserId"];
            data.BranchId = 1;
            data.AddedOn  = DateTime.Now;
            data.Engaged  = false;


            db.AmbulanceMasters.Add(data);
            db.SaveChanges();

            return(RedirectToAction("AmbulanceMaster", new { id = data.Id }));
        }
示例#11
0
        public ActionResult Create([Bind(Include = "Id,MedicalHistoryQuestionName")] MedicalHistoryQuestion medicalHistoryQuestion)
        {
            if (ModelState.IsValid)
            {
                medicalHistoryQuestion.BranchId  = (int)Session["UserBranchId"];
                medicalHistoryQuestion.UserId    = int.Parse(Session["UserId"].ToString());
                medicalHistoryQuestion.TimeAdded = DateTime.Now;
                db.MedicalHistoryQuestions.Add(medicalHistoryQuestion);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(medicalHistoryQuestion));
        }
        // PUT: api/Patients/5
        public HttpResponseMessage PutApplicant(int id, [FromBody] HRApplicant applicant)
        {
            if (applicant == null)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, "no data sent"));
            }
            applicant.Id = id;

            db.Entry(applicant).State = EntityState.Modified;

            db.SaveChanges();

            return(Request.CreateResponse(HttpStatusCode.OK, applicant));
        }
        public ActionResult Create([Bind(Include = "Id,CategoryId,ParticularName")] SystemExamParticular systemExamParticular)
        {
            if (ModelState.IsValid)
            {
                systemExamParticular.BranchId  = (int)Session["UserBranchId"];
                systemExamParticular.UserId    = int.Parse(Session["UserId"].ToString());
                systemExamParticular.TimeAdded = DateTime.Now;
                db.SystemExamParticulars.Add(systemExamParticular);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryId = new SelectList(db.SystemExamCategories, "Id", "CategoryName", systemExamParticular.CategoryId);
            return(View(systemExamParticular));
        }
        public ActionResult Create([Bind(Include = "Id,CategoryName")] SystemExamCategory systemExamCategory)
        {
            if (ModelState.IsValid)
            {
                systemExamCategory.TimeAdded = DateTime.Now;
                systemExamCategory.UserId    = int.Parse(Session["UserId"].ToString());

                systemExamCategory.BranchId = (int)Session["UserBranchId"];
                db.SystemExamCategories.Add(systemExamCategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(systemExamCategory));
        }
示例#15
0
        public ActionResult Appointment(DoctorsSchedule doctorsSchedule)
        {
            doctorsSchedule.CreatedDate = DateTime.UtcNow.ToLocalTime();
            if (ModelState.IsValid)
            {//ToDo : select user from session
                doctorsSchedule.UserId = (int)Session["UserId"];

                db.DoctorsSchedules.Add(doctorsSchedule);
                db.SaveChanges();

                ViewBag.SucessFullySaved = true;
                return(RedirectToAction("Index"));
            }
            return(RedirectToAction("Index"));
        }
        public void setUpSettingsParameters()
        {
            //Theatre Marquee
            var marq = new KeyValuePair
            {
                Key_  = "TheatreMarquee",
                Value = "Enter Theatre Marquee",
                Owner = "Theatre"
            };

            if (db.KeyValuePairs.Where(e => e.Key_ == marq.Key_ && e.Owner == marq.Owner) == null)
            {
                db.KeyValuePairs.Add(marq);
            }

            var depId = new KeyValuePair
            {
                Key_  = "TheatreDepartmentName",
                Value = "Theatre",
                Owner = "Theatre"
            };

            if (db.KeyValuePairs.Where(e => e.Key_ == marq.Key_ && e.Owner == marq.Owner) == null)
            {
                db.KeyValuePairs.Add(depId);
            }

            int res = db.SaveChanges();
        }
        public ActionResult CreateDepartment(Department department)
        {
            if (!Request.IsAjaxRequest())
            {
                Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
                return(Content("Error" + Response.StatusCode));
            }

            try
            {
                if (!ModelState.IsValid)
                {
                    db.Departments.Add(department);
                    db.SaveChanges();
                    return(Content("Record Added Successfully"));
                }
            }
            catch (Exception ex)
            {
                Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
                return(Content("Error" + ex.Message + Response.StatusCode));
            }

            return(View());
        }
示例#18
0
        public int UpdateClaimNo(int id, string ClaimNumber)
        {
            var ClaimNo = db.PatientClaims.FirstOrDefault(e => e.OPDId == id);

            if (ClaimNo != null)
            {
                ClaimNo.ClaimNumber = ClaimNumber;
                ClaimNo.UserId      = int.Parse(Session["UserId"].ToString());
            }
            else
            {
                db.PatientClaims.Add(new PatientClaim()
                {
                    OPDId       = id,
                    ClaimNumber = ClaimNumber,
                    UserId      = int.Parse(Session["UserId"].ToString()),
                    BrunchId    = db.Users.FirstOrDefault(e => e.Id.Equals((int)Session["UserId"])).Employee.Branch.Id,
                });
            }

            int res = db.SaveChanges();

            if (res > 0)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
        // GET: TurnAroundTime
        public int insert(PatientTurnAroundTime aroundTime)
        {
            db.PatientTurnAroundTimes.Add(aroundTime);
            var res = db.SaveChanges();

            return(res);
        }
示例#20
0
        public ActionResult Category(HSWardCategory category)
        {
            category.BranchId  = (int)Session["UserBranchId"];
            category.UserId    = (int)Session["UserId"];
            category.DateAdded = DateTime.Now;

            db.HSWardCategories.Add(category);
            db.SaveChanges();
            return(RedirectToAction("Categories"));
        }
示例#21
0
        public ActionResult PostReconciliation(int ShiftId, double ActualAmountCash, double ActualAmountCheque, double MpesaActualAmount, String ChequeNumbers)
        {
            var shift = db.Shifts.Find(ShiftId);
            FinanceCashPointReconciliation entry = new FinanceCashPointReconciliation();

            entry.ShiftId            = ShiftId;
            entry.CashActualAmount   = ActualAmountCash;
            entry.ChequeActualAmount = ActualAmountCheque;
            entry.TimeAdded          = DateTime.Now;
            entry.UserId             = 1; /*int.Parse(Session["UserId"].ToString());*/
            entry.BranchId           = 1;
            entry.MpesaActualAmount  = MpesaActualAmount;
            entry.ChequeNumbers      = ChequeNumbers;
            db.FinanceCashPointReconciliations.Add(entry);
            db.SaveChanges();

            return(Json(new { Status = true }));
        }
示例#22
0
        public ActionResult Delete(int id)
        {
            var loggedInUser = db.Users.Find(1);
            var billItem     = db.BillServices.Find(id);

            if (billItem == null)
            {
                return(Json(new { Status = "success" }, JsonRequestBehavior.AllowGet));
            }

            var anyUserDeleteItems = true;

            var usersDeleteUnpaidItems = db.KeyValuePairs.FirstOrDefault(e => e.Key_.ToLower().Trim() == "users_delete_unpaid_items");

            if (usersDeleteUnpaidItems != null)
            {
                if (usersDeleteUnpaidItems.Value.Trim().ToLower() != "yes")
                {
                    anyUserDeleteItems = false;
                }
            }
            else
            {
                var keyValuePair = new KeyValuePair();
                keyValuePair.Key_  = "users_delete_unpaid_items";
                keyValuePair.Value = "NO";
                db.KeyValuePairs.Add(keyValuePair);
                db.SaveChanges();
            }
            if (billItem.IPDBillPartialPayments.Count() > 0 || billItem.Paid || billItem.Offered || billItem.Award > 0 || (billItem.WaivedAmount ?? 0) > 0)
            {
                return(Json(new { Status = "warning", Message = "Sorry. This item cannot be deleted. It has either been offered, paid for, awarded or waived." }, JsonRequestBehavior.AllowGet));
            }
            if (anyUserDeleteItems || billItem.UserId == loggedInUser.Id || loggedInUser.UserRole.RoleName.ToLower() == "sa" || loggedInUser.UserRole.RoleName.ToLower() == "admin")
            {
                db.BillServices.Remove(billItem);
                db.SaveChanges();
                return(Json(new { Status = "success" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { Status = "warning", Message = "Sorry. You are not allowed to delete this item. Only the person who added it can do so." }, JsonRequestBehavior.AllowGet));
            }
        }
示例#23
0
        public void AddKeyValue(String key, string value, string owner = null)
        {
            var k = db.KeyValuePairs.FirstOrDefault(e => e.Key_.ToLower().Trim() == key.ToLower().Trim() &&
                                                    e.Owner == owner);

            if (k == null)
            {
                var keyvalue = new KeyValuePair();
                keyvalue.Key_  = key.Trim();
                keyvalue.Value = value.Trim();
                keyvalue.Owner = owner;
                db.KeyValuePairs.Add(keyvalue);
                db.SaveChanges();
            }
        }
 public ActionResult Edit([Bind(Include = "Id,MainCategory,SubCategory,salutation,FName,MName,LName,Gender,DOB,Religion,CorporateCompany,CorporateEmployeeId,ImageURL,ThumbNailURL,StreetAddress,Country,County,SubCounty,Village,NationalId,KinInitial,KinName,KinMobile,Email,BloodGroup,MaritalStatus,RegDate,RegTime,BranchId,Timestamp,RegNumber")] Patient patient)
 {
     if (ModelState.IsValid)
     {
         db.Entry(patient).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(patient));
 }
示例#25
0
        public ActionResult AddNutritiondiet(NutritionDietchart diet)
        {
            ViewBag.OpdNo = diet.OPDIPDID;

            int uid = Convert.ToInt32(Session["UserId"]);

            diet.user_id = uid;
            //diet.date_time = DateTime.Today;

            if (ModelState.IsValid)
            {
                db.NutritionDietcharts.Add(diet);
                db.SaveChanges();

                ViewBag.success = true;
            }

            ViewBag.success = false;
            return(RedirectToAction("Index", new { OpdNo = diet.OPDIPDID }));
        }
示例#26
0
        public ActionResult SaveMorgAdmission(MorgAdmission morgAdmit)
        {
            morgAdmit.BranchId  = (int)Session["UserBranchId"];
            morgAdmit.UserId    = (int)Session["UserId"];
            morgAdmit.TimeAdded = DateTime.Now;
            db.MorgAdmissions.Add(morgAdmit);
            db.SaveChanges();
            //if deceased was IPD, empty the bed
            if (morgAdmit.PatientId.HasValue)
            {
                var pat       = db.Patients.Find(morgAdmit.PatientId);
                var lastVisit = pat.OpdRegisters.OrderByDescending(e => e.Id).FirstOrDefault();
                if (lastVisit != null)
                {
                    if (lastVisit.IsIPD)
                    {
                        lastVisit.Discharged      = true;
                        lastVisit.DischargedAlive = false;
                        lastVisit.DischargeDate   = morgAdmit.DateOfDeath;
                        db.SaveChanges();
                    }
                }
            }

            //create an opd entry for the
            return(Json(new { SerialNo = morgAdmit.Id.ToString().PadLeft(4, '0') }));
        }
示例#27
0
 public ActionResult PostCampOrganizer(BloodBankCampOrganizer CampOrganizer)
 {
     if (ModelState.IsValid)
     {
         Session["UserId"]  = CampOrganizer.Id;
         CampOrganizer.Id   = (int)Session["UserId"];
         CampOrganizer.Date = DateTime.UtcNow;
         db.BloodBankCampOrganizers.Add(CampOrganizer);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(RedirectToAction("Index"));
 }
示例#28
0
        public ActionResult Award100PercentToNHIF()
        {
            var x        = 0;
            var nhif     = db.Companies.FirstOrDefault(e => e.CompanyName.ToLower().Trim() == "nhif");
            var services = db.Services.ToList();

            if (nhif != null)
            {
                foreach (var t in nhif.Tariffs)
                {
                    db.ServicesPrices.RemoveRange(t.ServicesPrices);
                    db.SaveChanges();

                    foreach (var s in services)
                    {
                        var sp = new ServicesPrice();
                        sp.TariffId      = t.Id;
                        sp.ServiceId     = s.Id;
                        sp.Award         = 100;
                        sp.AwardUnit     = "Percent";
                        sp.DoctorFee     = 0;
                        sp.DoctorFeeUnit = "Amount";
                        sp.DateAdded     = DateTime.Now;

                        sp.BranchId = (int)Session["UserBranchId"];
                        sp.UserId   = (int)Session["UserId"];

                        db.ServicesPrices.Add(sp);
                        x++;
                    }
                    db.SaveChanges();
                }
            }

            return(Content("Updated " + x + " records"));
        }
示例#29
0
        public ActionResult SaveAmbulanceRequest(AmbulanceRequest data)
        {
            //var OpdIpd = data.OpdRegisters.OrderByDescending(e => e.Id).FirstOrDefault();
            data.UserId = (int)Session["UserId"];
            var user = db.Users.Find(data.UserId);

            data.RequestingNurse = user.Employee.FName + " " + user.Employee.OtherName + " ( " + user.Username + " ) ";
            data.BranchId        = 1;
            data.AddedOn         = DateTime.Now;
            data.Assigned        = false;

            db.AmbulanceRequests.Add(data);
            db.SaveChanges();

            return(RedirectToAction("Index", new { id = data.Id }));
        }
示例#30
0
        public string Migrate()
        {
            var data = db.OpdRegisters.ToList();

            foreach (var i in data)
            {
                var opReg     = db.OpdRegisters.Find(i.Id);
                var branchini = db.KeyValuePairs.FirstOrDefault(e => e.Key_.ToLower().Equals("branchid"))?.Value ?? "0";
                opReg.Id = branchini + "|" + i.Id;
                db.SaveChanges();

                if (opReg.AdmissionRecommendations.Count() > 0)
                {
                    var lis = db.AdmissionRecommendations.Where(e => e.OPDNo == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.AdmissionRecommendations.Find(u.Id);
                        ad.OPDNo = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.Allergies.Count() > 0)
                {
                    var lis = db.Allergies.Where(e => e.OPDno == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.Allergies.Find(u.Id);
                        ad.OPDno = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.AnaestheticRecords.Count() > 0)
                {
                    var lis = db.AnaestheticRecords.Where(e => e.IPDNo == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.AnaestheticRecords.Find(u.Id);
                        ad.IPDNo = opReg.Id;
                        db.SaveChanges();
                    }
                }

                if (opReg.AssignmentDetails.Count() > 0)
                {
                    var lis = db.AssignmentDetails.Where(e => e.OPDNo == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.AssignmentDetails.Find(u.Id);
                        ad.OPDNo = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.BedShiftLogs.Count() > 0)
                {
                    var lis = db.BedShiftLogs.Where(e => e.OPDNo == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.BedShiftLogs.Find(u.Id);
                        ad.OPDNo = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.BillPayments.Count() > 0)
                {
                    var lis = db.BillPayments.Where(e => e.OPDNo == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.BillPayments.Find(u.Id);
                        ad.OPDNo = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.BillServices.Count() > 0)
                {
                    var lis = db.BillServices.Where(e => e.OPDNo == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.BillServices.Find(u.Id);
                        ad.OPDNo = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.BloodPressureCharts.Count() > 0)
                {
                    var lis = db.BloodPressureCharts.Where(e => e.IPDNo == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.BloodPressureCharts.Find(u.Id);
                        ad.IPDNo = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.BloodSugarCharts.Count() > 0)
                {
                    var lis = db.BloodSugarCharts.Where(e => e.IPDNo == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.BloodSugarCharts.Find(u.Id);
                        ad.IPDNo = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.Complaints.Count() > 0)
                {
                    var lis = db.Complaints.Where(e => e.OpdIpdNumber == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.Complaints.Find(u.Id);
                        ad.OpdIpdNumber = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.CorneaClinicEntries.Count() > 0)
                {
                    var lis = db.CorneaClinicEntries.Where(e => e.OPDNo == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.CorneaClinicEntries.Find(u.Id);
                        ad.OPDNo = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.CSSDIssueToPatients.Count() > 0)
                {
                    var lis = db.CSSDIssueToPatients.Where(e => e.OPDNo == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.CSSDIssueToPatients.Find(u.Id);
                        ad.OPDNo = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.DeathCertificates.Count() > 0)
                {
                    var lis = db.DeathCertificates.Where(e => e.OPDno == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.DeathCertificates.Find(u.Id);
                        ad.OPDno = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.Deformities.Count() > 0)
                {
                    var lis = db.Deformities.Where(e => e.OPDno == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.Deformities.Find(u.Id);
                        ad.OPDno = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.DischargeRecommendations.Count() > 0)
                {
                    var lis = db.DischargeRecommendations.Where(e => e.IpdNo == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.DischargeRecommendations.Find(u.Id);
                        ad.IpdNo = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.DoctorNotes.Count() > 0)
                {
                    var lis = db.DoctorNotes.Where(e => e.IpdOpdNo == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.DoctorNotes.Find(u.Id);
                        ad.IpdOpdNo = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.FamilyHealthOverviews.Count() > 0)
                {
                    var lis = db.FamilyHealthOverviews.Where(e => e.OPDNo == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.FamilyHealthOverviews.Find(u.Id);
                        ad.OPDNo = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.FamilyMedicalHistoryResponses.Count() > 0)
                {
                    var lis = db.FamilyMedicalHistoryResponses.Where(e => e.OPDNo == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.FamilyMedicalHistoryResponses.Find(u.Id);
                        ad.OPDNo = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.Fibromyalgias.Count() > 0)
                {
                    var lis = db.Fibromyalgias.Where(e => e.OPDno == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.Fibromyalgias.Find(u.Id);
                        ad.OPDno = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.FitnessCertificates.Count() > 0)
                {
                    var lis = db.FitnessCertificates.Where(e => e.OPDno == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.FitnessCertificates.Find(u.Id);
                        ad.OPDno = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.GlucomaPerfomaEntries.Count() > 0)
                {
                    var lis = db.GlucomaPerfomaEntries.Where(e => e.OPDNo == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.GlucomaPerfomaEntries.Find(u.Id);
                        ad.OPDNo = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.HTCServiceSummaries.Count() > 0)
                {
                    var lis = db.HTCServiceSummaries.Where(e => e.OPDNo == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.HTCServiceSummaries.Find(u.Id);
                        ad.OPDNo = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.Hypermobilities.Count() > 0)
                {
                    var lis = db.Hypermobilities.Where(e => e.OPDno == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.Hypermobilities.Find(u.Id);
                        ad.OPDno = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.ImmunizationAdmins.Count() > 0)
                {
                    var lis = db.ImmunizationAdmins.Where(e => e.OPDNo == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.ImmunizationAdmins.Find(u.Id);
                        ad.OPDNo = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.InformedConsents.Count() > 0)
                {
                    var lis = db.InformedConsents.Where(e => e.OPDno == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.InformedConsents.Find(u.Id);
                        ad.OPDno = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.InfusionTherapies.Count() > 0)
                {
                    var lis = db.InfusionTherapies.Where(e => e.OPDNo == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.InfusionTherapies.Find(u.Id);
                        ad.OPDNo = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.InsuranceCards.Count() > 0)
                {
                    var lis = db.InsuranceCards.Where(e => e.OPDNo == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.InsuranceCards.Find(u.Id);
                        ad.OPDNo = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.InsuranceInvoices.Count() > 0)
                {
                    var lis = db.InsuranceInvoices.Where(e => e.OpdId == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.InsuranceInvoices.Find(u.Id);
                        ad.OpdId = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.IntakeInputOutputs.Count() > 0)
                {
                    var lis = db.IntakeInputOutputs.Where(e => e.OpdNo == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.IntakeInputOutputs.Find(u.Id);
                        ad.OpdNo = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.JPayAutoPayments.Count() > 0)
                {
                    var lis = db.JPayAutoPayments.Where(e => e.OPDNo == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.JPayAutoPayments.Find(u.Id);
                        ad.OPDNo = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.JPayments.Count() > 0)
                {
                    var lis = db.JPayments.Where(e => e.OPDNo == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.JPayments.Find(u.Id);
                        ad.OPDNo = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.LasikClinicEntries.Count() > 0)
                {
                    var lis = db.LasikClinicEntries.Where(e => e.OPDNo == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.LasikClinicEntries.Find(u.Id);
                        ad.OPDNo = opReg.Id;
                        db.SaveChanges();
                    }
                }
                if (opReg.LeaveLetters.Count() > 0)
                {
                    var lis = db.LeaveLetters.Where(e => e.OPDno == i.Id).ToList();
                    foreach (var u in lis)
                    {
                        var ad = db.LeaveLetters.Find(u.Id);
                        ad.OPDno = opReg.Id;
                        db.SaveChanges();
                    }
                }
            }
            return("");
        }