public ActionResult MessageReport(string PatientId, DateTime FromDate, DateTime ToDate)
        {
            var totalwithin          = 0;
            var totaloutside         = 0;
            IEncounterReport encrepo = new EncounterReportModel();
            IEnumerable <EncounterReport> encrepos = encrepo.GetAll().Where(e => e.PatientId == PatientId).AsEnumerable();

            IPatientMDRepository    _patients = new PatientMDRepository();
            IEnumerable <PatientMD> patient   = _patients.GetByUserId(PatientId);
            var pat = patient.FirstOrDefault();

            foreach (var er in encrepos)
            {
                DateTime date = er.Encounterdate;
                if (FromDate <= date && date <= ToDate)
                {
                    totalwithin++;
                }
                else
                {
                    totaloutside++;
                }
            }
            var            numwithin             = 0;
            var            numoutside            = 0;
            IMessageReport msgrepo               = new MessageReportModel();
            IEnumerable <MessageReport> msgrepos = msgrepo.GetAll().Where(e => e.SentTo == PatientId).AsEnumerable();

            foreach (var mr in msgrepos)
            {
                DateTime dt = mr.Messagedate;

                if (FromDate <= dt && dt <= ToDate)
                {
                    numwithin++;
                }
                else
                {
                    numoutside++;
                }
            }

            var json = new MessageReportViewModel
            {
                PatientName  = pat.PatientName,
                DOB          = pat.DateOfBirth,
                TotalOutside = totaloutside,
                TotalWithin  = totalwithin,
                Gender       = pat.Sex,
                NumWithin    = numwithin,
                NumOutside   = numoutside
            };

            return(Json(json));
        }
        public ActionResult EncounterReport(string patientid, DateTime FromDate, DateTime ToDate)
        {
            IEncounterReport encrepo = new EncounterReportModel();
            IEnumerable <EncounterReport> encrepos = encrepo.GetAll().Where(e => e.PatientId == patientid).AsEnumerable();

            IPatientMDRepository    _patients = new PatientMDRepository();
            IEnumerable <PatientMD> patient   = _patients.GetByUserId(patientid);
            var pat = patient.FirstOrDefault();
            List <EncounterReportViewModel> logs = new List <EncounterReportViewModel>();

            foreach (var er in encrepos)
            {
                DateTime date = er.Encounterdate;
                if (FromDate <= date && date <= ToDate)
                {
                    //EncounterReportViewModel log = new EncounterReportViewModel();
                    Guid           userid = new Guid(er.UpdateBy);
                    MembershipUser upuser = Membership.GetUser(userid);
                    try
                    {
                        logs.Add(new EncounterReportViewModel()
                        {
                            PatientName   = pat.PatientName,
                            Date          = date.ToString(),
                            ActionResults = er.Action,
                            UpdatedBy     = upuser.UserName
                        });
                    }
                    catch (Exception ex)
                    {
                    }
                    //logs.Add(log);
                }
            }

            return(Json(logs));
        }