public JsonResult DeleteAppointment(string Id)
        {
            bool Success = false;

            //DateTime sysTime = DateTime.Now;
            if (!string.IsNullOrEmpty(Id))
            {
                try
                {
                    HcDoctorAppointmentEntity obj = (HcDoctorAppointmentEntity)ExecuteDB(HCareTaks.AG_GetSingleHcDoctorAppointmentRecordById, Id);
                    obj.Id = Id;
                    //obj.Updatedby = !string.IsNullOrEmpty(Uid) ? Uid : null;
                    obj.Updatedby   = Session["UserId"].ToString();
                    obj.Updatedtime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
                    obj.Status      = "Cancelled";
                    obj.QueryFlag   = "Cancelled";
                    Success         = (bool)ExecuteDB(HCareTaks.AG_UpdateHcDoctorAppointmentInfo, obj);

                    //DateTime dbTime = DateTime.ParseExact(Dates, "dd/MM/yyyy", null);
                    //string AppDate = dbTime.ToString("dddd, dd MMMM yyyy") + " & " + Times;
                    //double tDays = (dbTime.AddDays(1) - sysTime).TotalDays;

                    //if (Status == "Pending" && tDays < 0) { DeleteAppointments(Id); Status = "Cancelled"; }
                }
                catch { }
            }
            string Message = Success ? "Process has been done successfully." : "Sorry something went wrong!";

            return(Json(new { Success = Success, Message = Message }));
        }
        public bool UpdateHcDoctorAppointmentInfo(HcDoctorAppointmentEntity hcDoctorAppointmentEntity, Database db, DbTransaction transaction)
        {
            string sql = "UPDATE HC_Doctor_Appointment SET PatientUID= @Patientuid, DoctorID= @Doctorid, Dates= @Dates, TimeID= @Timeid, Reasons= @Reasons, PayMethod= @Paymethod, Status= @Status, UpdatedBy= @Updatedby, UpdatedTime= @Updatedtime WHERE Id=@Id";

            if (hcDoctorAppointmentEntity.QueryFlag == "Cancelled")
            {
                sql = "UPDATE HC_Doctor_Appointment SET Status= @Status, UpdatedBy= @Updatedby, UpdatedTime= @Updatedtime WHERE Id=@Id";
            }

            DbCommand dbCommand = db.GetSqlStringCommand(sql);

            db.AddInParameter(dbCommand, "Id", DbType.String, hcDoctorAppointmentEntity.Id);
            db.AddInParameter(dbCommand, "Patientuid", DbType.String, hcDoctorAppointmentEntity.Patientuid);
            db.AddInParameter(dbCommand, "Doctorid", DbType.String, hcDoctorAppointmentEntity.Doctorid);
            db.AddInParameter(dbCommand, "Dates", DbType.String, hcDoctorAppointmentEntity.Dates);
            db.AddInParameter(dbCommand, "Timeid", DbType.String, hcDoctorAppointmentEntity.Timeid);
            db.AddInParameter(dbCommand, "Reasons", DbType.String, hcDoctorAppointmentEntity.Reasons);
            db.AddInParameter(dbCommand, "Paymethod", DbType.String, hcDoctorAppointmentEntity.Paymethod);
            db.AddInParameter(dbCommand, "Status", DbType.String, hcDoctorAppointmentEntity.Status);
            db.AddInParameter(dbCommand, "Updatedby", DbType.String, hcDoctorAppointmentEntity.Updatedby);
            db.AddInParameter(dbCommand, "Updatedtime", DbType.String, hcDoctorAppointmentEntity.Updatedtime);

            db.ExecuteNonQuery(dbCommand, transaction);
            return(true);
        }
        public JsonResult SaveAppointment(HcDoctorAppointmentEntity obj)
        {
            bool Success = false;

            if (!string.IsNullOrEmpty(obj.Doctorid) && !string.IsNullOrEmpty(obj.Dates) && !string.IsNullOrEmpty(obj.Timeid) && !string.IsNullOrEmpty(obj.Reasons) && !string.IsNullOrEmpty(obj.Paymethod))
            {
                try
                {
                    obj.Patientuid    =
                        obj.Createdby = Session["UserId"].ToString();
                    obj.Createdtime   = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
                    obj.Status        = "Upcoming";
                    obj.Dates         = DateFormatWebToDb(obj.Dates);
                    obj.Id            = (string)ExecuteDB(HCareTaks.AG_SaveHcDoctorAppointmentInfo, obj);
                    if (!string.IsNullOrEmpty(obj.Id))
                    {
                        Success = true;
                    }
                }
                catch { }
            }

            string Message = Success ? "Process has been done successfully." : "Sorry something went wrong!";

            return(Json(new { Success = Success, Message = Message }));
        }
        public object UpdateHcDoctorAppointmentInfo(object param)
        {
            Database db     = DatabaseFactory.CreateDatabase();
            object   retObj = null;

            using (DbConnection connection = db.CreateConnection())
            {
                connection.Open();
                DbTransaction transaction = connection.BeginTransaction();
                try
                {
                    HcDoctorAppointmentEntity hcDoctorAppointmentEntity = (HcDoctorAppointmentEntity)param;
                    HcDoctorAppointmentDAL    hcDoctorAppointmentDAL    = new HcDoctorAppointmentDAL();
                    retObj = (object)hcDoctorAppointmentDAL.UpdateHcDoctorAppointmentInfo(hcDoctorAppointmentEntity, db, transaction);
                    transaction.Commit();
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
                finally
                {
                    connection.Close();
                }
            }
            return(retObj);
        }
Beispiel #5
0
        public DataTable GetAllHcDoctorAppointmentRecord(object param)
        {
            Database db  = DatabaseFactory.CreateDatabase();
            string   sql = @"SELECT A.ID, A.PatientUID, U.FirstName+' '+U.LastName  as Username, U.Gender,
                            (SELECT FLOOR((CAST (GetDate() AS INTEGER) - CAST( cast(U.DOB as datetime) AS INTEGER)) / 365.25)) AS Age,  
                            A.DoctorID, A.Dates, A.TimeID, A.Reasons, A.PayMethod, A.Status, A.CreatedBy, A.CreatedTime, A.UpdatedBy, A.UpdatedTime 
                            , D.Name DoctorName, D.Specialist, (Select Name From HC_Doctor_Departments z Where z.ID = D.Department) DoctorDeptName, T.Times,
                            A.symtomps_image_path, A.prescription_image_path
                            FROM HC_Doctor_Appointment A 
                            Left Join HC_DoctorInfo D ON D.ID = A.DoctorID
                            Left Join HC_Users U ON U.ID = A.PatientUID
                            Left Join HC_Doctor_Times T ON T.ID = A.TimeID
                            Where 1=1";

            HcDoctorAppointmentEntity obj = new HcDoctorAppointmentEntity();

            if (param != null)
            {
                obj = (HcDoctorAppointmentEntity)param;
            }

            if (!string.IsNullOrEmpty(obj.QueryFlag) && obj.QueryFlag == "Patient")
            {
                if (!string.IsNullOrEmpty(obj.Patientuid))
                {
                    sql += " And A.PatientUID = '" + obj.Patientuid + "'";
                }
                if (!string.IsNullOrEmpty(obj.Status))
                {
                    sql += " And A.Status = '" + obj.Status + "'";
                }
            }

            else if (!string.IsNullOrEmpty(obj.QueryFlag) && obj.QueryFlag == "Doctor")
            {
                if (!string.IsNullOrEmpty(obj.Patientuid))
                {
                    sql += " And A.DoctorID = '" + obj.Patientuid + "'";
                }
            }
            if (!string.IsNullOrEmpty(obj.Id))
            {
                sql += " And A.ID = '" + obj.Id + "'";
            }

            sql += " Order By Convert(dateTime,A.CreatedTime,103) Desc";

            DbCommand dbCommand = db.GetSqlStringCommand(sql);
            DataSet   ds        = db.ExecuteDataSet(dbCommand);

            return(ds.Tables[0]);
        }
        string ManageAppointmentData()
        {
            string Upcoming  = @"<div class='appointment-list bg-info p-10 mb-20'><h4>Upcoming Appointment</h4>
                    <table class='table table-sm table-responsive table-hover'><thead>
                    <tr><th>#</th><th>Doctor</th><th>Reasons</th><th>Appointment</th><th>Created</th><th>&nabla;</th></tr></thead><tbody>",
                   Completed = @"<div class='appointment-list bg-success p-10 mb-20'><h4>Completed Appointment</h4>
                    <table class='table table-sm table-responsive'><thead>
                    <tr><th>#</th><th>Doctor</th><th>Reasons</th><th>Appointment</th><th>Created</th></tr></thead><tbody>",
                   Cancelled = @"<div class='appointment-list bg-danger p-10 mb-20'><h4>Cancelled Appointment</h4>
                    <table class='table table-sm table-responsive'><thead>
                    <tr><th>#</th><th>Doctor</th><th>Reasons</th><th>Appointment</th><th>Created</th></tr></thead><tbody>";
            HcDoctorAppointmentEntity obj = new HcDoctorAppointmentEntity();

            obj.Patientuid = Session["UserId"].ToString();
            DataTable dt = (DataTable)ExecuteDB(HCareTaks.AG_GetAllHcDoctorAppointmentRecord, obj);
            int       Up = 1, Co = 1, Ca = 1;

            foreach (DataRow dr in dt.Rows)
            {
                string Id            = dr["Id"].ToString(),
                             Status  = dr["Status"].ToString(),
                             Times   = dr["Times"].ToString(),
                             Dates   = dr["Dates"].ToString() + "<br><small>" + Times + "</small>",
                             Created = dr["CreatedTime"].ToString().Substring(0, 10),
                             Reasons = dr["Reasons"].ToString(),
                             Doctor  = dr["DoctorName"].ToString() + "<br><small>" + dr["DoctorDeptName"].ToString() + "</small>";

                if (Status == "Upcoming")
                {
                    string Action = "<i class='fa fa-times text-danger iPointer' onclick=\"DeleteAppointment('" + Id + "')\" title='Cancel This Appointment'></i>";
                    Upcoming += "<tr><td>" + Up + "</td><td>" + Doctor + "</td><td>" + Reasons + "</td><td>" + Dates + "</td><td>" + Created + "</td><td>" + Action + "</td></tr>";
                    Up++;
                }
                else if (Status == "Completed")
                {
                    Completed += "<tr><td>" + Co + "</td><td>" + Doctor + "</td><td>" + Reasons + "</td><td>" + Dates + "</td><td>" + Created + "</td></tr>";
                    Co++;
                }
                else if (Status == "Cancelled")
                {
                    Cancelled += "<tr><td>" + Ca + "</td><td>" + Doctor + "</td><td>" + Reasons + "</td><td>" + Dates + "</td><td>" + Created + "</td></tr>";
                    Ca++;
                }
            }
            return(Upcoming + "</tbody></table></div>" + Completed + "</tbody></table></div>" + Cancelled + "</tbody></table></div>");
        }
        public object SaveHcDoctorAppointmentInfo(HcDoctorAppointmentEntity hcDoctorAppointmentEntity, Database db, DbTransaction transaction)
        {
            string    sql       = "INSERT INTO HC_Doctor_Appointment ( PatientUID, DoctorID, Dates, TimeID, Reasons, PayMethod, Status, CreatedBy, CreatedTime ) output inserted.ID VALUES (  @Patientuid,  @Doctorid,  @Dates,  @Timeid,  @Reasons,  @Paymethod,  @Status,  @Createdby,  @Createdtime )";
            DbCommand dbCommand = db.GetSqlStringCommand(sql);

            db.AddInParameter(dbCommand, "Patientuid", DbType.String, hcDoctorAppointmentEntity.Patientuid);
            db.AddInParameter(dbCommand, "Doctorid", DbType.String, hcDoctorAppointmentEntity.Doctorid);
            db.AddInParameter(dbCommand, "Dates", DbType.String, hcDoctorAppointmentEntity.Dates);
            db.AddInParameter(dbCommand, "Timeid", DbType.String, hcDoctorAppointmentEntity.Timeid);
            db.AddInParameter(dbCommand, "Reasons", DbType.String, hcDoctorAppointmentEntity.Reasons);
            db.AddInParameter(dbCommand, "Paymethod", DbType.String, hcDoctorAppointmentEntity.Paymethod);
            db.AddInParameter(dbCommand, "Status", DbType.String, hcDoctorAppointmentEntity.Status);
            db.AddInParameter(dbCommand, "Createdby", DbType.String, hcDoctorAppointmentEntity.Createdby);
            db.AddInParameter(dbCommand, "Createdtime", DbType.String, hcDoctorAppointmentEntity.Createdtime);

            var id = db.ExecuteScalar(dbCommand, transaction).ToString();

            return(id);
        }
        public HcDoctorAppointmentEntity GetSingleHcDoctorAppointmentRecordById(object param)
        {
            Database  db        = DatabaseFactory.CreateDatabase();
            string    sql       = "SELECT ID, PatientUID, DoctorID, Dates, TimeID, Reasons, PayMethod, Status, CreatedBy, CreatedTime, UpdatedBy, UpdatedTime FROM HC_Doctor_Appointment WHERE Id=@Id";
            DbCommand dbCommand = db.GetSqlStringCommand(sql);

            db.AddInParameter(dbCommand, "Id", DbType.String, param);
            HcDoctorAppointmentEntity hcDoctorAppointmentEntity = null;

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    hcDoctorAppointmentEntity = new HcDoctorAppointmentEntity();
                    if (dataReader["ID"] != DBNull.Value)
                    {
                        hcDoctorAppointmentEntity.Id = dataReader["ID"].ToString();
                    }
                    if (dataReader["PatientUID"] != DBNull.Value)
                    {
                        hcDoctorAppointmentEntity.Patientuid = dataReader["PatientUID"].ToString();
                    }
                    if (dataReader["DoctorID"] != DBNull.Value)
                    {
                        hcDoctorAppointmentEntity.Doctorid = dataReader["DoctorID"].ToString();
                    }
                    if (dataReader["Dates"] != DBNull.Value)
                    {
                        hcDoctorAppointmentEntity.Dates = dataReader["Dates"].ToString();
                    }
                    if (dataReader["TimeID"] != DBNull.Value)
                    {
                        hcDoctorAppointmentEntity.Timeid = dataReader["TimeID"].ToString();
                    }
                    if (dataReader["Reasons"] != DBNull.Value)
                    {
                        hcDoctorAppointmentEntity.Reasons = dataReader["Reasons"].ToString();
                    }
                    if (dataReader["PayMethod"] != DBNull.Value)
                    {
                        hcDoctorAppointmentEntity.Paymethod = dataReader["PayMethod"].ToString();
                    }
                    if (dataReader["Status"] != DBNull.Value)
                    {
                        hcDoctorAppointmentEntity.Status = dataReader["Status"].ToString();
                    }
                    if (dataReader["CreatedBy"] != DBNull.Value)
                    {
                        hcDoctorAppointmentEntity.Createdby = dataReader["CreatedBy"].ToString();
                    }
                    if (dataReader["CreatedTime"] != DBNull.Value)
                    {
                        hcDoctorAppointmentEntity.Createdtime = dataReader["CreatedTime"].ToString();
                    }
                    if (dataReader["UpdatedBy"] != DBNull.Value)
                    {
                        hcDoctorAppointmentEntity.Updatedby = dataReader["UpdatedBy"].ToString();
                    }
                    if (dataReader["UpdatedTime"] != DBNull.Value)
                    {
                        hcDoctorAppointmentEntity.Updatedtime = dataReader["UpdatedTime"].ToString();
                    }
                }
            }
            return(hcDoctorAppointmentEntity);
        }