예제 #1
0
        public JsonResult ExitingPatientChanngeinfo(DoctorNameSpeciality drobj)
        {
            HospitalManagementEntities db  = new Models.HospitalManagementEntities();
            DoctorNameSpeciality       obj = new DoctorNameSpeciality();

            string fromdate        = string.Empty;
            string todate          = string.Empty;
            string Drname          = string.Empty;
            string flagExitPatient = string.Empty;

            fromdate        = Convert.ToString(drobj.fromDate);
            todate          = Convert.ToString(drobj.toDate);
            Drname          = Convert.ToString(drobj.NameSpecialist);
            flagExitPatient = Convert.ToString(drobj.flag);



            SqlCommand cmd = new SqlCommand("[sp_getExistingPatientsByDrId]", con);

            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet        ds = new DataSet();

            da.Fill(ds);


            //Existing Patient Logic when only drname is passed
            if ((Drname != string.Empty) && (fromdate == string.Empty) && (todate == string.Empty) && flagExitPatient == "ExistingPatient")
            {
                SqlCommand cmdOnlyDrName = new SqlCommand("[sp_getExistingPatientsByDrId]", con);
                obj.NameSpecialist = Drname.ToString();
                con.Open();
                string name       = obj.NameSpecialist.Split('-')[0];
                string specialist = obj.NameSpecialist.Split('-')[1];
                obj.DrId = Convert.ToInt32(db.Doctors.Where(s => s.Name == name && s.Specialist == specialist).Select(s => s.DoctorId).FirstOrDefault());
                cmdOnlyDrName.CommandType = CommandType.StoredProcedure;
                cmdOnlyDrName.Parameters.AddWithValue("@DrId", obj.DrId);
                cmdOnlyDrName.Parameters.AddWithValue("@fromdate", obj.fromDate);
                cmdOnlyDrName.Parameters.AddWithValue("@todate", obj.toDate);
                SqlDataAdapter daOnlyDrName = new SqlDataAdapter(cmdOnlyDrName);
                DataSet        dsOnlyDrName = new DataSet();
                daOnlyDrName.Fill(dsOnlyDrName);
                int ExistingCountPatient = Convert.ToInt32(dsOnlyDrName.Tables[0].Rows[0]["CurrentPatient"]);
                TempData["CurrentPatient"] = ExistingCountPatient;
            }
            //Passed only from and todate
            else if ((Drname == string.Empty) && (fromdate != string.Empty) && (todate != string.Empty) && flagExitPatient == "ExistingPatient")
            {
                SqlCommand cmdfromToDate = new SqlCommand("[sp_getExistingPatientsByDrId]", con);
                obj.NameSpecialist = Drname.ToString();
                con.Open();
                string name       = obj.NameSpecialist.Split('-')[0];
                string specialist = obj.NameSpecialist.Split('-')[1];
                obj.DrId = Convert.ToInt32(db.Doctors.Where(s => s.Name == name && s.Specialist == specialist).Select(s => s.DoctorId).FirstOrDefault());
                cmdfromToDate.CommandType = CommandType.StoredProcedure;
                cmdfromToDate.Parameters.AddWithValue("@DrId", obj.DrId);
                cmdfromToDate.Parameters.AddWithValue("@fromdate", obj.fromDate);
                cmdfromToDate.Parameters.AddWithValue("@todate", obj.toDate);
                SqlDataAdapter dafromToDate = new SqlDataAdapter(cmd);
                DataSet        dsfromToDate = new DataSet();
                dafromToDate.Fill(dsfromToDate);
                int ExistingCountPatient = Convert.ToInt32(dsfromToDate.Tables[0].Rows[0]["CurrentPatient"]);
                TempData["CurrentPatient"] = ExistingCountPatient;
            }
            //Passed all the Values
            else if ((Drname != string.Empty) && (fromdate != string.Empty) && (todate != string.Empty) && flagExitPatient == "ExistingPatient")
            {
                SqlCommand cmdAllValues = new SqlCommand("[sp_getExistingPatientsByDrId]", con);
                obj.NameSpecialist = Drname.ToString();
                con.Open();
                string name       = obj.NameSpecialist.Split('-')[0];
                string specialist = obj.NameSpecialist.Split('-')[1];
                obj.DrId        = Convert.ToInt32(db.Doctors.Where(s => s.Name == name && s.Specialist == specialist).Select(s => s.DoctorId).FirstOrDefault());
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@DrId", obj.DrId);
                cmd.Parameters.AddWithValue("@fromdate", obj.fromDate);
                cmd.Parameters.AddWithValue("@todate", obj.toDate);
                SqlDataAdapter daAllValues = new SqlDataAdapter(cmd);
                DataSet        dsAllValues = new DataSet();
                daAllValues.Fill(dsAllValues);
                int ExistingCountPatient = Convert.ToInt32(dsAllValues.Tables[0].Rows[0]["CurrentPatient"]);
                TempData["CurrentPatient"] = ExistingCountPatient;
            }
            DashboardDetail GetDashboardCount = new DashboardDetail();

            GetDashboardCount.CountExistingPatient = (int)TempData["CurrentPatient"];
            //   ViewBag.CountExistingPatient = (int)TempData["CurrentPatient"]
            return(Json(GetDashboardCount, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public ActionResult GetAppointCount(FormCollection frm)
        {
            HospitalManagementEntities db  = new Models.HospitalManagementEntities();
            DoctorNameSpeciality       obj = new DoctorNameSpeciality();

            string fromdate           = string.Empty;
            string todate             = string.Empty;
            string Drname             = string.Empty;
            string flagExitPatient    = string.Empty;
            string flagCurrentEarning = string.Empty;

            if (frm["fromappDate"] != string.Empty)
            {
                fromdate = Convert.ToString(frm["fromappDate"]);
            }
            if (frm["toappDate"] != string.Empty)
            {
                todate = Convert.ToString(frm["toappDate"]);
            }
            if (frm["DrNameAndSpeciality"] != string.Empty)
            {
                Drname = Convert.ToString(frm["DrNameAndSpeciality"]);
            }
            if (frm["hfAppointments"] != string.Empty)
            {
                flagExitPatient = Convert.ToString(frm["hfAppointments"]);
            }
            if (frm["CurrentOPEarning"] != string.Empty)
            {
                flagCurrentEarning = Convert.ToString(frm["hfTotalAccounts"]);
            }


            //Current Appointment Details By DrName!
            if ((Drname != string.Empty) && (fromdate == string.Empty) && (todate == string.Empty) && flagExitPatient != "ExistingPatient")
            {
                SqlCommand cmd = new SqlCommand("[sp_getCurrentAppointmentByDrId]", con);
                obj.NameSpecialist = frm["DrNameAndSpeciality"].ToString();
                con.Open();
                string name       = obj.NameSpecialist.Split('-')[0];
                string specialist = obj.NameSpecialist.Split('-')[1];
                obj.DrId        = Convert.ToInt32(db.Doctors.Where(s => s.Name == name && s.Specialist == specialist).Select(s => s.DoctorId).FirstOrDefault());
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@DrId", obj.DrId);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataSet        ds = new DataSet();
                da.Fill(ds);
                int CurrentCountAppointment = Convert.ToInt32(ds.Tables[0].Rows[0]["CurrentAppointmentCount"]);
                TempData["CurrentCountAppointment"] = CurrentCountAppointment;
            }
            else if ((Drname != string.Empty) && (fromdate == string.Empty) && (todate == string.Empty) && flagExitPatient == "ExistingPatient")
            {
                SqlCommand cmdOnlyDrName = new SqlCommand("[sp_getExistingPatientsByDrId]", con);
                obj.NameSpecialist = Drname.ToString();
                con.Open();
                string name       = obj.NameSpecialist.Split('-')[0];
                string specialist = obj.NameSpecialist.Split('-')[1];
                obj.DrId = Convert.ToInt32(db.Doctors.Where(s => s.Name == name && s.Specialist == specialist).Select(s => s.DoctorId).FirstOrDefault());
                cmdOnlyDrName.CommandType = CommandType.StoredProcedure;
                cmdOnlyDrName.Parameters.AddWithValue("@DrId", obj.DrId);
                cmdOnlyDrName.Parameters.AddWithValue("@fromdate", obj.fromDate);
                cmdOnlyDrName.Parameters.AddWithValue("@todate", obj.toDate);
                SqlDataAdapter daOnlyDrName = new SqlDataAdapter(cmdOnlyDrName);
                DataSet        dsOnlyDrName = new DataSet();
                daOnlyDrName.Fill(dsOnlyDrName);
                int ExistingCountPatient = Convert.ToInt32(dsOnlyDrName.Tables[0].Rows[0]["CurrentPatient"]);
                TempData["CurrentPatient"] = ExistingCountPatient;
            }
            //Passed only from and todate
            else if ((Drname == string.Empty) && (fromdate != string.Empty) && (todate != string.Empty) && flagExitPatient == "ExistingPatient")
            {
                SqlCommand cmdfromToDate = new SqlCommand("sp_getExistingPatientsByDrId", con);

                con.Open();

                cmdfromToDate.CommandType = CommandType.StoredProcedure;
                obj.DrId = Convert.ToInt32(db.Doctors.Where(s => s.Name == "").Select(s => s.DoctorId).FirstOrDefault());


                if (obj.DrId == 0)
                {
                    obj.DrId = null;
                }
                cmdfromToDate.Parameters.AddWithValue("@DrId", obj.DrId);
                cmdfromToDate.Parameters.AddWithValue("@fromdate", Convert.ToString(fromdate));
                cmdfromToDate.Parameters.AddWithValue("@todate", Convert.ToString(todate));
                SqlDataAdapter dafromToDate = new SqlDataAdapter(cmdfromToDate);
                DataSet        dsfromToDate = new DataSet();
                dafromToDate.Fill(dsfromToDate);
                int ExistingCountPatient = Convert.ToInt32(dsfromToDate.Tables[0].Rows[0]["CurrentPatient"]);
                TempData["CurrentPatient"] = ExistingCountPatient;
            }
            //Passed all the Values
            else if ((Drname != string.Empty) && (fromdate != string.Empty) && (todate != string.Empty) && flagExitPatient == "ExistingPatient")
            {
                SqlCommand cmdAllValues = new SqlCommand("[sp_getExistingPatientsByDrId]", con);
                obj.NameSpecialist = Drname.ToString();
                con.Open();
                string name       = obj.NameSpecialist.Split('-')[0];
                string specialist = obj.NameSpecialist.Split('-')[1];
                obj.DrId = Convert.ToInt32(db.Doctors.Where(s => s.Name == name && s.Specialist == specialist).Select(s => s.DoctorId).FirstOrDefault());
                cmdAllValues.CommandType = CommandType.StoredProcedure;
                cmdAllValues.Parameters.AddWithValue("@DrId", obj.DrId);
                cmdAllValues.Parameters.AddWithValue("@fromdate", fromdate);
                cmdAllValues.Parameters.AddWithValue("@todate", todate);
                SqlDataAdapter daAllValues = new SqlDataAdapter(cmdAllValues);
                DataSet        dsAllValues = new DataSet();
                daAllValues.Fill(dsAllValues);
                int ExistingCountPatient = Convert.ToInt32(dsAllValues.Tables[0].Rows[0]["CurrentPatient"]);
                TempData["CurrentPatient"] = ExistingCountPatient;
            }
            //DashboardDetail GetDashboardCount = new DashboardDetail();
            //GetDashboardCount.CountExistingPatient = (int)TempData["CurrentPatient"];
            // Billing Information based on Doctor name for current Date

            else if ((Drname != string.Empty) && (fromdate == string.Empty) && (todate == string.Empty) && flagCurrentEarning == "CurrentOPEarning")
            {
                SqlCommand cmdOnlyDrName = new SqlCommand("[sp_getCurrentAccountDetailsByDrId]", con);
                obj.NameSpecialist = Drname.ToString();
                con.Open();
                string name       = obj.NameSpecialist.Split('-')[0];
                string specialist = obj.NameSpecialist.Split('-')[1];
                obj.DrId = Convert.ToInt32(db.Doctors.Where(s => s.Name == name && s.Specialist == specialist).Select(s => s.DoctorId).FirstOrDefault());
                cmdOnlyDrName.CommandType = CommandType.StoredProcedure;
                cmdOnlyDrName.Parameters.AddWithValue("@DrId", obj.DrId);
                cmdOnlyDrName.Parameters.AddWithValue("@fromdate", fromdate);
                cmdOnlyDrName.Parameters.AddWithValue("@todate", todate);
                SqlDataAdapter daOnlyDrName = new SqlDataAdapter(cmdOnlyDrName);
                DataSet        dsOnlyDrName = new DataSet();
                daOnlyDrName.Fill(dsOnlyDrName);
                int CurrentEarningOP = Convert.ToInt32(dsOnlyDrName.Tables[0].Rows[0]["TotalEarning"]);
                TempData["TotalEarning"] = CurrentEarningOP;
            }
            //Passed only from and todate
            else if ((Drname == string.Empty) && (fromdate != string.Empty) && (todate != string.Empty) && flagCurrentEarning == "CurrentOPEarning")
            {
                SqlCommand cmdfromToDate = new SqlCommand("sp_getCurrentAccountDetailsByDrId", con);

                con.Open();

                cmdfromToDate.CommandType = CommandType.StoredProcedure;
                obj.DrId = Convert.ToInt32(db.Doctors.Where(s => s.Name == "").Select(s => s.DoctorId).FirstOrDefault());


                if (obj.DrId == 0)
                {
                    obj.DrId = null;
                }
                cmdfromToDate.Parameters.AddWithValue("@DrId", obj.DrId);
                cmdfromToDate.Parameters.AddWithValue("@fromdate", Convert.ToString(fromdate));
                cmdfromToDate.Parameters.AddWithValue("@todate", Convert.ToString(todate));
                SqlDataAdapter dafromToDate = new SqlDataAdapter(cmdfromToDate);
                DataSet        dsfromToDate = new DataSet();
                dafromToDate.Fill(dsfromToDate);
                int CurrentEarningOP = Convert.ToInt32(dsfromToDate.Tables[0].Rows[0]["TotalEarning"]);
                TempData["TotalEarning"] = CurrentEarningOP;
            }
            //Passed all the Values
            else if ((Drname != string.Empty) && (fromdate != string.Empty) && (todate != string.Empty) && flagCurrentEarning == "CurrentOPEarning")
            {
                SqlCommand cmdAllValues = new SqlCommand("[sp_getCurrentAccountDetailsByDrId]", con);
                obj.NameSpecialist = Drname.ToString();
                con.Open();
                string name       = obj.NameSpecialist.Split('-')[0];
                string specialist = obj.NameSpecialist.Split('-')[1];
                obj.DrId = Convert.ToInt32(db.Doctors.Where(s => s.Name == name && s.Specialist == specialist).Select(s => s.DoctorId).FirstOrDefault());
                cmdAllValues.CommandType = CommandType.StoredProcedure;
                cmdAllValues.Parameters.AddWithValue("@DrId", obj.DrId);
                cmdAllValues.Parameters.AddWithValue("@fromdate", fromdate);
                cmdAllValues.Parameters.AddWithValue("@todate", todate);
                SqlDataAdapter daAllValues = new SqlDataAdapter(cmdAllValues);
                DataSet        dsAllValues = new DataSet();
                daAllValues.Fill(dsAllValues);
                int CurrentEarningOP = Convert.ToInt32(dsAllValues.Tables[0].Rows[0]["TotalEarning"]);
                TempData["TotalEarning"] = CurrentEarningOP;
            }


            return(RedirectToAction("Index"));
        }