Example #1
0
        public async Task <IActionResult> PregnantRefer([Bind] PregnantReferViewModel model)
        {
            var patient = await SetPatient(model.PatientId);

            var facilities = _context.Facility
                             .Where(x => x.Id != UserFacility() && x.ProvinceId == UserProvince());

            if (ModelState.IsValid)
            {
                var pregnantForm = await SetPregnantForm(model, _type.Value.REFER);

                var tracking = await PregnantTracking(pregnantForm, _type.Value.REFER);

                var activity = await PregnantActivity(tracking, _type.Value.REFER);

                await _context.AddAsync(tracking);

                await _context.AddAsync(activity);

                await _context.SaveChangesAsync();

                return(RedirectToAction("ListPatients", "ViewPatients"));
            }
            else
            {
                ModelState.AddModelError("ReferredTo", "Please select a Facility.");
                ModelState.AddModelError("Department", "Please select a Department.");
                ModelState.AddModelError("WomanMajorFindings", "This field is required.");
                ModelState.AddModelError("WomanInformationGiven", "This field is required.");
            }
            ViewBag.Patient    = patient;
            ViewBag.Facility   = _context.Facility.Find(UserId()).Name;
            ViewBag.Facilities = new SelectList(facilities, "Id", "Name");
            return(PartialView());
        }
Example #2
0
        public async Task<IActionResult> PregnantForm(string code)
        {
            var form = await _context.PregnantForm.SingleAsync(x => x.Code.Equals(code));
            Baby baby = null;

            if (form.PatientBabyId != null)
                baby = await _context.Baby.SingleOrDefaultAsync(x => x.BabyId.Equals(form.PatientBabyId));

            var pregnantForm = new PregnantViewModel(form, baby);

            var tracking = _context.Tracking.Single(x => x.Code.Equals(code));
            var activity = _context.Activity.Single(x => x.Code.Equals(code) && x.Status.Equals(_status.Value.REFERRED));

            if (!activity.Status.Equals(_status.Value.REFERRED))
                activity.Status = _status.Value.REFERRED;

            tracking.DateSeen = DateTime.Now;
            activity.DateSeen = DateTime.Now;
            _context.Update(tracking);
            _context.Update(activity);

            var seen = new Seen
            {
                FacilityId = UserFacility(),
                TrackingId = _context.Tracking.Single(x => x.Code.Equals(form.Code)).Id,
                UpdatedAt = DateTime.Now,
                CreatedAt = DateTime.Now,
                UserMd = UserId()
            };

            await _context.AddAsync(seen);
            await _context.SaveChangesAsync();
            return PartialView(pregnantForm);
        }
Example #3
0
 public void ViewReco([Bind] FeedbackViewModel model)
 {
     if (ModelState.IsValid)
     {
         var feedback = new Feedback
         {
             Code       = model.Code,
             SenderId   = model.MdId,
             RecieverId = null,
             Message    = model.Message,
             CreatedAt  = DateTime.Now,
             UpdatedAt  = DateTime.Now
         };
         _context.AddAsync(feedback);
         _context.SaveChangesAsync();
     }
 }
Example #4
0
        public async Task <IActionResult> Chat([Bind] FeedbackViewModel model)
        {
            if (ModelState.IsValid)
            {
                var chat = new Feedback
                {
                    Code       = model.Code,
                    SenderId   = model.MdId,
                    RecieverId = null,
                    Message    = model.Message,
                    UpdatedAt  = DateTime.Now,
                    CreatedAt  = DateTime.Now
                };
                await _context.AddAsync(chat);

                await _context.SaveChangesAsync();
            }
            ;

            return(View());
        }