public async Task <ActionResult> EditMedication(PatientMedicalHistory_MedicationRx medicationRx)
        {
            if (HelperExtensions.isAllowedforEditingorAdd(medicationRx.PatientId, CategoryCycleStatusHelper.GetPatientNewOrOldCycleByCategory(medicationRx.PatientId, BillingCodeHelper.cmmBillingCatagoryid), User.Identity.GetUserId()) == false)
            {
                return(RedirectToAction("Index", "CcmStatus", new { status = HelperExtensions.GetStatusRedirectionbyUser(User.Identity.GetUserId()), Message = "Cycle is locked." }));
            }
            var patient = _db.Patients.Find(medicationRx.PatientId);

            if (patient != null && ModelState.IsValid)
            {
                patient.UpdatedBy = User.Identity.GetUserId();
                patient.UpdatedOn = DateTime.Now;

                _db.Entry(medicationRx).State = EntityState.Modified;

                await _db.SaveChangesAsync();
            }

            ViewBag.PatientName = patient?.FirstName + " " + patient?.LastName;
            ViewBag.PatientId   = patient?.Id;
            ViewBag.CcmStatus   = patient?.CcmStatus;
            ViewBag.CurrentPage = "Medical History";

            return(RedirectToAction("Patient", "CurrentMedication", new { patientId = medicationRx.PatientId }));
        }
Example #2
0
        public async Task <ActionResult> Create(DoctorVisit visit)
        {
            if (HelperExtensions.isAllowedforEditingorAdd(visit.PatientId, CategoryCycleStatusHelper.GetPatientNewOrOldCycleByCategory(visit.PatientId, BillingCodeHelper.cmmBillingCatagoryid), User.Identity.GetUserId()) == false)
            {
                return(RedirectToAction("Index", "CcmStatus", new { status = HelperExtensions.GetStatusRedirectionbyUser(User.Identity.GetUserId()), Message = "Cycle is locked." }));
            }
            var patient = await _db.Patients.FindAsync(visit.PatientId);

            ViewBag.PatientName = patient?.FirstName + " " + patient?.LastName;

            if (patient != null)
            {
                _db.DoctorVisits.Add(visit);

                patient.UpdatedBy = User.Identity.GetUserId();
                patient.UpdatedOn = DateTime.Now;

                _db.Entry(patient).State = EntityState.Modified;
                await _db.SaveChangesAsync();

                return(RedirectToAction("ListDoctorVisits", new { patientId = visit.PatientId }));
            }

            return(View(new DoctorVisit {
                PatientId = visit.PatientId
            }));
        }
        public async Task <ActionResult> GeneralConditions(PatientMedicalHistory_GeneralCondition conditions)
        {
            if (HelperExtensions.isAllowedforEditingorAdd(conditions.PatientId, CategoryCycleStatusHelper.GetPatientNewOrOldCycleByCategory(conditions.PatientId, BillingCodeHelper.cmmBillingCatagoryid), User.Identity.GetUserId()) == false)
            {
                return(RedirectToAction("Index", "CcmStatus", new { status = HelperExtensions.GetStatusRedirectionbyUser(User.Identity.GetUserId()), Message = "Cycle is locked." }));
            }
            var patient = await _db.Patients.FindAsync(conditions.PatientId);

            if (patient != null)
            {
                patient.UpdatedBy = User.Identity.GetUserId();
                patient.UpdatedOn = DateTime.Now;
                var gconditions = _db.PatientMedicalHistory_GeneralConditions.Where(x => x.PatientId == conditions.PatientId).FirstOrDefault();
                if (gconditions == null)
                {
                    _db.PatientMedicalHistory_GeneralConditions.Add(conditions);
                }
                else
                {
                    _db.Entry(conditions).State = EntityState.Modified;
                }
                //_db.Set<PatientMedicalHistory_GeneralCondition>().AddOrUpdate(conditions);
                await _db.SaveChangesAsync();
            }

            ViewBag.PatientName = patient?.FirstName + " " + patient?.LastName;
            ViewBag.PatientId   = patient?.Id;
            ViewBag.CcmStatus   = patient?.CcmStatus;
            ViewBag.CurrentPage = "Medical History";

            return(RedirectToAction("Patient", "CurrentMedication", new { patientId = conditions.PatientId }));
        }
        public async Task <ActionResult> Create(PatientProfile_Address address)
        {
            if (HelperExtensions.isAllowedforEditingorAdd(address.PatientId, CategoryCycleStatusHelper.GetPatientNewOrOldCycleByCategory(address.PatientId, BillingCodeHelper.cmmBillingCatagoryid), User.Identity.GetUserId()) == false)
            {
                return(RedirectToAction("Index", "CcmStatus", new { status = HelperExtensions.GetStatusRedirectionbyUser(User.Identity.GetUserId()), Message = "Cycle is locked." }));
            }
            var patient = await _db.Patients.FindAsync(address.PatientId);

            if (patient != null && ModelState.IsValid)
            {
                patient.Address1            = address.Address1;
                patient.Address2            = address.Address2;
                patient.City                = address.City;
                patient.State               = address.State;
                patient.Zipcode             = address.Zip;
                patient.BuildingType        = address.BuildingType;
                patient.DeliveryPermisison  = address.DeliveryPermisison;
                patient.DeliveryInstruction = address.DeliveryInstruction;

                if (patient.AddressId != null)
                {
                    _db.Entry(address).State = EntityState.Modified;
                }

                else
                {
                    _db.PatientProfile_Addresses.Add(address);
                    await _db.SaveChangesAsync();

                    patient.AddressId = address.Id;
                }

                patient.UpdatedBy        = User.Identity.GetUserId();
                patient.UpdatedOn        = DateTime.Now;
                _db.Entry(patient).State = EntityState.Modified;
                await _db.SaveChangesAsync();

                return(RedirectToAction("Create", "PatientUrgencyContact", new { patientId = patient.Id }));
            }

            var sameAddress = new PatientProfile_Address
            {
                PatientId           = address.PatientId,
                Address1            = patient?.Address1,
                Address2            = patient?.Address2,
                City                = patient?.City,
                State               = patient?.State,
                Zip                 = patient?.Zipcode,
                BuildingType        = patient?.BuildingType,
                DeliveryPermisison  = patient?.DeliveryPermisison,
                DeliveryInstruction = patient?.DeliveryInstruction
            };

            ViewBag.PatientName = patient?.FirstName + " " + patient?.LastName;
            ViewBag.PatientId   = patient?.Id;
            ViewBag.CcmStatus   = patient?.CcmStatus;

            return(View(sameAddress));
        }
Example #5
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Icd10Codes icd10Codes = await _db.Icd10Codes.FindAsync(id);

            if (HelperExtensions.isAllowedforEditingorAdd(icd10Codes.PatientId, CategoryCycleStatusHelper.GetPatientNewOrOldCycleByCategory(icd10Codes.PatientId, BillingCodeHelper.cmmBillingCatagoryid), User.Identity.GetUserId()) == false)
            {
                return(RedirectToAction("Index", "CcmStatus", new { status = HelperExtensions.GetStatusRedirectionbyUser(User.Identity.GetUserId()), Message = "Cycle is locked." }));
            }
            _db.Icd10Codes.Remove(icd10Codes);
            await _db.SaveChangesAsync();

            return(RedirectToAction("_Index", new { patientId = icd10Codes.PatientId }));
        }
Example #6
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,Code10,Code9,PatientId,DateCreated")] Icd10Codes icd10Codes)
        {
            if (HelperExtensions.isAllowedforEditingorAdd(icd10Codes.PatientId, CategoryCycleStatusHelper.GetPatientNewOrOldCycleByCategory(icd10Codes.PatientId, BillingCodeHelper.cmmBillingCatagoryid), User.Identity.GetUserId()) == false)
            {
                return(RedirectToAction("Index", "CcmStatus", new { status = HelperExtensions.GetStatusRedirectionbyUser(User.Identity.GetUserId()), Message = "Cycle is locked." }));
            }
            if (ModelState.IsValid)
            {
                _db.Entry(icd10Codes).State = EntityState.Modified;
                await _db.SaveChangesAsync();

                return(RedirectToAction("Index", new { patientId = icd10Codes.PatientId }));
            }
            return(View(icd10Codes));
        }
Example #7
0
        public async Task <ActionResult> Create(SecondaryDoctor secondaryDoctor)
        {
            if (HelperExtensions.isAllowedforEditingorAdd(secondaryDoctor.PatientId, CategoryCycleStatusHelper.GetPatientNewOrOldCycleByCategory(secondaryDoctor.PatientId, BillingCodeHelper.cmmBillingCatagoryid), User.Identity.GetUserId()) == false)
            {
                return(RedirectToAction("Index", "CcmStatus", new { status = HelperExtensions.GetStatusRedirectionbyUser(User.Identity.GetUserId()), Message = "Cycle is locked." }));
            }
            if (ModelState.IsValid)
            {
                _db.SecondaryDoctors.Add(secondaryDoctor);
                await _db.SaveChangesAsync();

                return(RedirectToAction("Index", new { patientId = secondaryDoctor.PatientId }));
            }

            return(View(secondaryDoctor));
        }
        public async Task <ActionResult> Create(PatientProfile_Contact contact)
        {
            if (HelperExtensions.isAllowedforEditingorAdd(contact.PatientId, CategoryCycleStatusHelper.GetPatientNewOrOldCycleByCategory(contact.PatientId, BillingCodeHelper.cmmBillingCatagoryid), User.Identity.GetUserId()) == false)
            {
                return(RedirectToAction("Index", "CcmStatus", new { status = HelperExtensions.GetStatusRedirectionbyUser(User.Identity.GetUserId()), Message = "Cycle is locked." }));
            }
            var patient = await _db.Patients.FindAsync(contact.PatientId);

            if (patient != null && ModelState.IsValid)
            {
                patient.MobilePhoneNumber = contact.CellPhoneNumber;
                patient.AllowText         = contact.CellPhonePermission;
                patient.WorkPhoneNumber   = contact.WorkPhoneNumber;
                patient.HomePhoneNumber   = contact.HomePhoneNumber;
                patient.Email             = contact.Email;
                patient.AllowEmail        = contact.EmailPermission;

                if (patient.ContactId != null)
                {
                    _db.Entry(contact).State = EntityState.Modified;
                }

                else
                {
                    _db.PatientProfile_Contact.Add(contact);
                    await _db.SaveChangesAsync();

                    patient.ContactId = contact.Id;
                }

                patient.UpdatedBy        = User.Identity.GetUserId();
                patient.UpdatedOn        = DateTime.Now;
                _db.Entry(patient).State = EntityState.Modified;
                await _db.SaveChangesAsync();

                return(RedirectToAction("Create", "PatientAddress", new { patientId = patient?.Id }));
            }

            ViewBag.PatientName = patient?.FirstName + " " + patient?.LastName;
            ViewBag.PatientId   = patient?.Id;
            ViewBag.CcmStatus   = patient?.CcmStatus;

            return(View(contact));
        }
        public async Task <ActionResult> Create(PatientProfile_Insurance insurance, string MedicareIdNumber, string MedicaidIdNumber, string OtherInsuranceIdNumber)
        {
            if (HelperExtensions.isAllowedforEditingorAdd(insurance.PatientId, CategoryCycleStatusHelper.GetPatientNewOrOldCycleByCategory(insurance.PatientId, BillingCodeHelper.cmmBillingCatagoryid), User.Identity.GetUserId()) == false)
            {
                return(RedirectToAction("Index", "CcmStatus", new { status = HelperExtensions.GetStatusRedirectionbyUser(User.Identity.GetUserId()), Message = "Cycle is locked." }));
            }
            var patient = _db.Patients.Find(insurance.PatientId);

            if (patient != null && ModelState.IsValid)
            {
                if (patient.InsuranceId != null)
                {
                    _db.Entry(insurance).State = EntityState.Modified;
                }

                else
                {
                    _db.PatientProfile_Insurance.Add(insurance);
                    await _db.SaveChangesAsync();

                    patient.InsuranceId = insurance.Id;
                }
                //
                patient.MedicaidIdNumber       = MedicaidIdNumber;
                patient.MedicareIdNumber       = MedicareIdNumber;
                patient.OtherInsuranceIdNumber = OtherInsuranceIdNumber;
                //
                patient.UpdatedBy        = User.Identity.GetUserId();
                patient.UpdatedOn        = DateTime.Now;
                _db.Entry(patient).State = EntityState.Modified;
                await _db.SaveChangesAsync();


                return(RedirectToAction("Create", "PatientMedicalStatus", new { patientId = patient.Id }));
            }

            ViewBag.PatientName = patient?.FirstName + " " + patient?.LastName;
            ViewBag.PatientId   = patient?.Id;
            ViewBag.CcmStatus   = patient?.CcmStatus;

            return(View(insurance));
        }
Example #10
0
        public async Task <ActionResult> Create(CarePlan carePlan)
        {
            try
            {
                CategoryCycleStatusHelper.User = User;
                if (HelperExtensions.isAllowedforEditingorAdd(carePlan.PatientId, CategoryCycleStatusHelper.GetPatientNewOrOldCycleByCategory(carePlan.PatientId, BillingCodeHelper.cmmBillingCatagoryid), User.Identity.GetUserId()) == false)
                {
                    return(RedirectToAction("Index", "CcmStatus", new { status = HelperExtensions.GetStatusRedirectionbyUser(User.Identity.GetUserId()), Message = "Cycle is locked." }));
                }
                var patient = await _db.Patients.FirstOrDefaultAsync(p => p.Id == carePlan.PatientId);

                if (patient != null && ModelState.IsValid)
                {
                    _db.Set <CarePlan>().AddOrUpdate(carePlan);

                    patient.UpdatedBy        = User.Identity.GetUserId();
                    patient.UpdatedOn        = DateTime.Now;
                    _db.Entry(patient).State = EntityState.Modified;
                    await _db.SaveChangesAsync();
                }

                var physician = await _db.Physicians.FindAsync(patient?.PhysicianId);

                ViewBag.PhysicianName = physician?.FirstName + ' ' + physician?.LastName;
                ViewBag.PatientName   = patient?.FirstName + ' ' + patient?.LastName;
                ViewBag.PatientId     = patient?.Id;
                ViewBag.CcmStatus     = patient?.CcmStatus;

                return(View(carePlan));
            }
            catch (Exception ex)
            {
                CarePlan carePlan1 = new CarePlan();
                ViewBag.PhysicianName = "Error";
                ViewBag.PatientName   = "Error";
                ViewBag.PatientId     = 0;
                ViewBag.CcmStatus     = "Error";
                log.Error(Environment.NewLine + User.Identity.GetUserName() + "-------" + User.Identity.GetUserId() + Environment.NewLine + ex.Message + "-----" + ex.StackTrace);
                return(View(carePlan1));
                /*return ex.Message + "------------------" + ex.StackTrace;*/
            }
        }
Example #11
0
        public async Task <ActionResult> Create(PatientLifestyle_WorkAndRelationship workRelationship)
        {
            if (HelperExtensions.isAllowedforEditingorAdd(workRelationship.PatientId, CategoryCycleStatusHelper.GetPatientNewOrOldCycleByCategory(workRelationship.PatientId, BillingCodeHelper.cmmBillingCatagoryid), User.Identity.GetUserId()) == false)
            {
                return(RedirectToAction("Index", "CcmStatus", new { status = HelperExtensions.GetStatusRedirectionbyUser(User.Identity.GetUserId()), Message = "Cycle is locked." }));
            }
            var patient = _db.Patients.Find(workRelationship.PatientId);

            if (patient != null && ModelState.IsValid)
            {
                if (patient.WorkAndRelationshipId != null)
                {
                    workRelationship.Id = (int)patient.WorkAndRelationshipId;
                    _db.Entry(workRelationship).State = EntityState.Modified;
                }
                else
                {
                    _db.PatientLifestyle_WorkAndRelationships.Add(workRelationship);
                    await _db.SaveChangesAsync();

                    patient.WorkAndRelationshipId = workRelationship.Id;
                }

                patient.UpdatedBy        = User.Identity.GetUserId();
                patient.UpdatedOn        = DateTime.Now;
                _db.Entry(patient).State = EntityState.Modified;
                await _db.SaveChangesAsync();

                return(RedirectToAction("Create", "PatientLifestyle_DietAndHabit", new { patientId = patient.Id }));
            }

            ViewBag.Employment_StatusId   = new SelectList(_db.PatientLifestyle_WorkAndRelationship_EmploymentStatuses, "Id", "Type", workRelationship.Employment_StatusId);
            ViewBag.Relationship_StatusId = new SelectList(_db.PatientLifestyle_WorkAndRelationship_RelationshipStatuses, "Id", "Type", workRelationship.Relationship_StatusId);
            ViewBag.TravelRequirementId   = new SelectList(_db.PatientLifestyle_WorkAndRelationship_Travels, "Id", "Type", workRelationship.TravelRequirementId);

            ViewBag.PatientName = patient?.FirstName + " " + patient?.LastName;
            ViewBag.PatientId   = patient?.Id;
            ViewBag.CcmStatus   = patient?.CcmStatus;

            return(View(workRelationship));
        }
        public async Task <ActionResult> Create(PatientLifestyle_LifeStress lifeStress)
        {
            if (HelperExtensions.isAllowedforEditingorAdd(lifeStress.PatientId, CategoryCycleStatusHelper.GetPatientNewOrOldCycleByCategory(lifeStress.PatientId, BillingCodeHelper.cmmBillingCatagoryid), User.Identity.GetUserId()) == false)
            {
                return(RedirectToAction("Index", "CcmStatus", new { status = HelperExtensions.GetStatusRedirectionbyUser(User.Identity.GetUserId()), Message = "Cycle is locked." }));
            }
            var patient = _db.Patients.Find(lifeStress.PatientId);

            if (patient != null && ModelState.IsValid)
            {
                if (patient.LifeStressId != null)
                {
                    _db.Entry(lifeStress).State = EntityState.Modified;
                }

                else
                {
                    _db.PatientLifestyle_LifeStresses.Add(lifeStress);
                    await _db.SaveChangesAsync();

                    patient.LifeStressId = lifeStress.Id;
                }

                patient.UpdatedBy        = User.Identity.GetUserId();
                patient.UpdatedOn        = DateTime.Now;
                _db.Entry(patient).State = EntityState.Modified;
                await _db.SaveChangesAsync();

                return(RedirectToAction("Create", "PatientLifestyle_NutritionalSupplement", new { patientId = patient?.Id }));
            }

            ViewBag.Coping_StressId = new SelectList(_db.PatientLifestyle_LifeStress_CopingStresses, "Id", "Type", lifeStress.Coping_StressId);
            ViewBag.LifeStressId    = new SelectList(_db.PatientLifestyle_LifeStress_Stresses, "Id", "Type", lifeStress.LifeStressId);
            ViewBag.workStressId    = new SelectList(_db.PatientLifestyle_LifeStress_Stresses, "Id", "Type", lifeStress.workStressId);

            ViewBag.PatientName = patient?.FirstName + " " + patient?.LastName;
            ViewBag.PatientId   = patient?.Id;
            ViewBag.CcmStatus   = patient?.CcmStatus;

            return(View(lifeStress));
        }
        public async Task <ActionResult> Create(PatientLifestyle_NutritionalSupplement supplement)
        {
            if (HelperExtensions.isAllowedforEditingorAdd(supplement.PatientId, CategoryCycleStatusHelper.GetPatientNewOrOldCycleByCategory(supplement.PatientId, BillingCodeHelper.cmmBillingCatagoryid), User.Identity.GetUserId()) == false)
            {
                return(RedirectToAction("Index", "CcmStatus", new { status = HelperExtensions.GetStatusRedirectionbyUser(User.Identity.GetUserId()), Message = "Cycle is locked." }));
            }
            var patient = await _db.Patients.FindAsync(supplement.PatientId);

            if (ModelState.IsValid && patient != null)
            {
                if (patient.NutritionalSupplementId != null)
                {
                    _db.Entry(supplement).State = EntityState.Modified;
                }

                else
                {
                    _db.PatientLifestyle_NutritionalSupplements.Add(supplement);
                    await _db.SaveChangesAsync();

                    patient.NutritionalSupplementId = supplement.Id;
                }

                patient.UpdatedOn = DateTime.Now;
                patient.UpdatedBy = User.Identity.GetUserId();
                patient.CcmStatus = "Claims Submission";
                patient.CcmClaimSubmissionDate = DateTime.Now;
                _db.Entry(patient).State       = EntityState.Modified;
                await _db.SaveChangesAsync();


                return(RedirectToAction("Index", "CcmStatus", new { status = "Enrolled" }));
            }

            ViewBag.PatientName = patient?.FirstName + " " + patient?.LastName;
            ViewBag.PatientId   = patient?.Id;
            ViewBag.CcmStatus   = patient?.CcmStatus;

            return(View(supplement));
        }
        public async Task <ActionResult> Create(PatientLifestyle_DietAndHabit dietHabit)
        {
            if (HelperExtensions.isAllowedforEditingorAdd(dietHabit.PatientId, CategoryCycleStatusHelper.GetPatientNewOrOldCycleByCategory(dietHabit.PatientId, BillingCodeHelper.cmmBillingCatagoryid), User.Identity.GetUserId()) == false)
            {
                return(RedirectToAction("Index", "CcmStatus", new { status = HelperExtensions.GetStatusRedirectionbyUser(User.Identity.GetUserId()), Message = "Cycle is locked." }));
            }
            var patient = _db.Patients.Find(dietHabit.PatientId);

            if (patient != null && ModelState.IsValid)
            {
                if (patient.DietAndHabitId != null)
                {
                    _db.Entry(dietHabit).State = EntityState.Modified;
                }

                else
                {
                    _db.PatientLifestyle_DietAndHabits.Add(dietHabit);
                    await _db.SaveChangesAsync();

                    patient.DietAndHabitId = dietHabit.Id;
                }

                patient.UpdatedBy        = User.Identity.GetUserId();
                patient.UpdatedOn        = DateTime.Now;
                _db.Entry(patient).State = EntityState.Modified;
                await _db.SaveChangesAsync();

                return(RedirectToAction("Create", "PatientLifestyle_LifeStress", new { patientId = patient.Id }));
            }

            ViewBag.AlcoholId   = new SelectList(_db.PatientLifestyle_DietAndHabit_AlcoholFrequencies, "id", "Type", dietHabit.AlcoholId);
            ViewBag.PatientName = patient?.FirstName + " " + patient?.LastName;
            ViewBag.PatientId   = patient?.Id;
            ViewBag.CcmStatus   = patient?.CcmStatus;

            return(View(dietHabit));
        }
Example #15
0
        public async Task <ActionResult> Create(PatientMedicalHistory_FamilyHistory familyHistory)
        {
            if (HelperExtensions.isAllowedforEditingorAdd(familyHistory.PatientId, CategoryCycleStatusHelper.GetPatientNewOrOldCycleByCategory(familyHistory.PatientId, BillingCodeHelper.cmmBillingCatagoryid), User.Identity.GetUserId()) == false)
            {
                return(RedirectToAction("Index", "CcmStatus", new { status = HelperExtensions.GetStatusRedirectionbyUser(User.Identity.GetUserId()), Message = "Cycle is locked." }));
            }
            var patient = _db.Patients.Find(familyHistory.PatientId);

            if (patient != null && ModelState.IsValid)
            {
                if (patient.FamilyHistoryId != null)
                {
                    _db.Entry(familyHistory).State = EntityState.Modified;
                }

                else
                {
                    _db.PatientMedicalHistory_FamilyHistories.Add(familyHistory);
                    await _db.SaveChangesAsync();

                    patient.FamilyHistoryId = familyHistory.Id;
                }

                patient.UpdatedBy        = User.Identity.GetUserId();
                patient.UpdatedOn        = DateTime.Now;
                _db.Entry(patient).State = EntityState.Modified;
                await _db.SaveChangesAsync();

                return(RedirectToAction("Create", "PatientAllergy", new { patientId = patient.Id }));
            }

            ViewBag.PatientName = patient?.FirstName + " " + patient?.LastName;
            ViewBag.PatientId   = patient?.Id;
            ViewBag.CcmStatus   = patient?.CcmStatus;

            return(View(familyHistory));
        }
Example #16
0
        public async Task <ActionResult> Create([Bind(Exclude = "MedicareEligibiltySceenshot,MedicaidEligibiltySceenshot")] PatientMeidcareMedicaidEligibility patientMeidcareMedicaidEligibility, FormCollection form, string EnrollmentStatushiden, string EnrollmentSubStatushiden, string EnrollmentSubStatusReasonhiden, string EnrollmentStatusNotes)
        {
            if (HelperExtensions.isAllowedforEditingorAdd(patientMeidcareMedicaidEligibility.PatientId, CategoryCycleStatusHelper.GetPatientNewOrOldCycleByCategory(patientMeidcareMedicaidEligibility.PatientId, BillingCodeHelper.cmmBillingCatagoryid), User.Identity.GetUserId()) == false)
            {
                return(RedirectToAction("Index", "CcmStatus", new { status = HelperExtensions.GetStatusRedirectionbyUser(User.Identity.GetUserId()), Message = "Cycle is locked." }));
                //return "Cycle is locked.";
            }
            if (ModelState.IsValid)
            {
                var patient = _db.Patients.Where(x => x.Id == patientMeidcareMedicaidEligibility.PatientId).FirstOrDefault();
                patient.EnrollmentStatus    = EnrollmentStatushiden == "" ? null : EnrollmentStatushiden;
                patient.EnrollmentSubStatus = EnrollmentSubStatushiden == "" ? null : EnrollmentSubStatushiden;
                if (patient?.EnrollmentSubStatus == "In-Active Enrolled")
                {
                    patient.EnrollmentSubStatusReason = EnrollmentSubStatusReasonhiden;
                }
                else
                {
                    patient.EnrollmentSubStatusReason = "";
                }
                patient.EnrollmentStatusNotes = EnrollmentStatusNotes;
                if (patient.CCMEnrolledOn == null)
                {
                    patient.CcmStatus     = "Enrolled";
                    patient.CCMEnrolledOn = DateTime.Now;
                    patient.CCMEnrolledBy = User.Identity.GetUserId();
                    //HelperExtensions.UpdateCurrentMonthActivityfromCycleZeroToOne(patient.Id);
                    try
                    {
                        var reviewtimeccms = _db.ReviewTimeCcms.Where(x => x.PatientId == patient.Id && x.Cycle == 0).ToList().Where(x => x.StartTime.Date.Month == DateTime.Now.Month).ToList();
                        foreach (var reviewtimeccmitem in reviewtimeccms)
                        {
                            reviewtimeccmitem.Cycle            = 1;
                            _db.Entry(reviewtimeccmitem).State = EntityState.Modified;
                            _db.SaveChanges();
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
                _db.Entry(patient).State = EntityState.Modified;
                _db.SaveChanges();
                var postedImageFile  = Request.Files["MedicareEligibiltySceenshot"];
                var postedImageFile1 = Request.Files["MedicaidEligibiltySceenshot"];

                var model = _db.PatientMeidcareMedicaidEligibilities.AsNoTracking().Where(p => p.PatientId == patientMeidcareMedicaidEligibility.PatientId).FirstOrDefault();
                if (postedImageFile?.ContentLength != 0 && postedImageFile?.InputStream != null)
                {
                    using (var binary = new BinaryReader(postedImageFile.InputStream))
                    {
                        var imageData = binary.ReadBytes(postedImageFile.ContentLength);
                        if (imageData.Length > 0)
                        {
                            patientMeidcareMedicaidEligibility.MedicareEligibiltySceenshot = imageData;
                        }
                    }
                }
                if (postedImageFile1?.ContentLength != 0 && postedImageFile1?.InputStream != null)
                {
                    using (var binary = new BinaryReader(postedImageFile1.InputStream))
                    {
                        var imageData = binary.ReadBytes(postedImageFile1.ContentLength);
                        if (imageData.Length > 0)
                        {
                            patientMeidcareMedicaidEligibility.MedicaidEligibiltySceenshot = imageData;
                        }
                    }
                }
                if (model == null)
                {
                    patientMeidcareMedicaidEligibility.CreatedOn = DateTime.Now;
                    patientMeidcareMedicaidEligibility.CreatedBy = User.Identity.GetUserId();

                    _db.PatientMeidcareMedicaidEligibilities.Add(patientMeidcareMedicaidEligibility);
                    await _db.SaveChangesAsync();
                }
                else
                {
                    patientMeidcareMedicaidEligibility.MedicaidEligibiltySceenshot = patientMeidcareMedicaidEligibility.MedicaidEligibiltySceenshot == null ? model.MedicaidEligibiltySceenshot : patientMeidcareMedicaidEligibility.MedicaidEligibiltySceenshot;
                    patientMeidcareMedicaidEligibility.MedicareEligibiltySceenshot = patientMeidcareMedicaidEligibility.MedicareEligibiltySceenshot == null ? model.MedicareEligibiltySceenshot : patientMeidcareMedicaidEligibility.MedicareEligibiltySceenshot;
                    patientMeidcareMedicaidEligibility.UpdatedOn        = DateTime.Now;
                    patientMeidcareMedicaidEligibility.UpdatedBy        = User.Identity.GetUserId();
                    _db.Entry(patientMeidcareMedicaidEligibility).State = EntityState.Modified;
                    await _db.SaveChangesAsync();
                }

                //return "True";
                return(RedirectToAction("Details", "Patient", new { Id = patient.Id }));
            }

            //return "False";
            return(View(patientMeidcareMedicaidEligibility));
        }
Example #17
0
        public async Task <ActionResult> Create(PatientProfile profile)
        {
            if (HelperExtensions.isAllowedforEditingorAdd(profile.PatientId, CategoryCycleStatusHelper.GetPatientNewOrOldCycleByCategory(profile.PatientId, BillingCodeHelper.cmmBillingCatagoryid), User.Identity.GetUserId()) == false)
            {
                return(RedirectToAction("Index", "CcmStatus", new { status = HelperExtensions.GetStatusRedirectionbyUser(User.Identity.GetUserId()), Message = "Cycle is locked." }));
            }
            var patient = await _db.Patients.FindAsync(profile.PatientId);

            if (patient != null && ModelState.IsValid)
            {
                patient.Prefix            = profile.Prefix;
                patient.MiddleName        = profile.MiddleName;
                patient.Suffix            = profile.Suffix;
                patient.Gender            = profile.Gender;
                patient.PreferredLanguage = profile.PreferredLanguage;
                patient.OtherLanguage     = profile.OtherLanguage;
                patient.FirstName         = profile.FirstName;
                patient.LastName          = profile.LastName;
                patient.BirthDate         = profile.BirthDate.Value;
                patient.UpdatedBy         = User.Identity.GetUserId();
                patient.UpdatedOn         = DateTime.Now;

                if (patient.ProfileId != null)
                {
                    _db.Entry(profile).State = EntityState.Modified;
                }

                else
                {
                    _db.PatientProfiles.Add(profile);
                    await _db.SaveChangesAsync();

                    patient.ProfileId = profile.Id;
                }

                patient.UpdatedBy        = User.Identity.GetUserId();
                patient.UpdatedOn        = DateTime.Now;
                _db.Entry(patient).State = EntityState.Modified;
                await _db.SaveChangesAsync();

                return(RedirectToAction("Create", "PatientContact", new { patientId = patient.Id }));
            }


            var sameProfile = new PatientProfile
            {
                PatientId         = profile.PatientId,
                Prefix            = patient?.Prefix,
                FirstName         = patient?.FirstName,
                MiddleName        = patient?.MiddleName,
                LastName          = patient?.LastName,
                Suffix            = patient?.Suffix,
                BirthDate         = patient?.BirthDate,
                Gender            = patient?.Gender,
                OtherLanguage     = patient?.OtherLanguage,
                PreferredLanguage = patient?.PreferredLanguage
            };

            ViewBag.PatientName = patient?.FirstName + " " + patient?.LastName;
            ViewBag.PatientId   = patient?.Id;
            ViewBag.CcmStatus   = patient?.CcmStatus;
            return(View(sameProfile));
        }