Exemplo n.º 1
0
        public void CopyTo(Appointment appointment)
        {
            appointment.AppointmentDay = AppointmentDay
                                         .AddHours(AppointmentTime.Hour)
                                         .AddMinutes(AppointmentTime.Minute);

            appointment.CustomerName        = CustomerName;
            appointment.CustomerEmail       = CustomerEmail;
            appointment.CustomerPhoneNumber = CustomerPhoneNumber;
            appointment.IsConfirmed         = IsConfirmed;
        }
Exemplo n.º 2
0
        public string Get(string department,
                          string reqType,
                          int providerId,
                          int patientId,
                          DateTime requestDate,
                          string status,
                          int membershipTypeId)
        {
            AppointmentDbContext        dbContextAppointment = new AppointmentDbContext(connString);
            DanpheHTTPResponse <object> responseData         = new DanpheHTTPResponse <object>();

            //RbacUser currentUser = HttpContext.Session.Get<RbacUser>("currentuser");
            //if (currentUser == null || !RBAC.UserHasPermission(currentUser.UserId, "APT", "appointment-read"))
            //{
            //    HttpResponseMessage message = new HttpResponseMessage(System.Net.HttpStatusCode.NotFound);
            //    responseData.Status = "Failed";
            //    responseData.ErrorMessage = "Unauthorized access.";
            //    return DanpheJSONConvert.SerializeObject(responseData);
            //}

            #region get request example
            //for reference
            //if (!string.IsNullOrEmpty(fName) || !string.IsNullOrEmpty(doctor) || appointmentId != 0)
            //{
            //    //If nothing is passed during search->Condition in LHS is TRUE and neglects the condition in the RHS
            //    //If some value is passed during search -> LHS will be false and checks if RHS is TRUE
            //    //If both the LHS and RHS in any one of the 3 conditions is false then query returns nothing.
            //    result = (from app in dbContextSearch.Appointments
            //              where (appointmentId == 0 || appointmentId == app.AppointmentId)
            //             && (string.IsNullOrEmpty(fName) || app.FirstName.ToLower().Contains(fName.ToLower()))
            //             && (string.IsNullOrEmpty(doctor) || app.ProviderName.ToLower().Contains(doctor.ToLower()))
            //              select app).ToList();
            //    return JsonConvert.SerializeObject(result);
            //}
            #endregion
            try
            {
                //gets the doctorschedule from appointment table
                if (reqType == "doctorschedule")
                {
                    //.ToList()is done two times,since we can't use requestDate.Date inside IQueryable
                    List <AppointmentModel> apptList = (from d in dbContextAppointment.Appointments
                                                        where d.ProviderId == providerId
                                                        select d).ToList().Where(a => a.AppointmentDate.Date == requestDate.Date).ToList();
                    AppointmentDay apptDay = AppointmentDay.FormatData(apptList);
                    responseData.Status  = "OK";
                    responseData.Results = apptDay;
                }
                //loads appointments with requested status
                else if (reqType == "getAppointments")
                {
                    var date = DateTime.Today;
                    List <AppointmentModel> appointmentList = (from app in dbContextAppointment.Appointments
                                                               select app
                                                               ).OrderByDescending(x => x.AppointmentId).ToList();
                    responseData.Status  = "OK";
                    responseData.Results = appointmentList;
                }
                //get the patient's today's or future's appointments
                else if (reqType == "checkForClashingAppointment")
                {
                    List <AppointmentModel> patAppointmentList = (from app in dbContextAppointment.Appointments
                                                                  where app.PatientId == patientId &&
                                                                  app.AppointmentDate >= DbFunctions.TruncateTime(requestDate.Date) &&
                                                                  app.ProviderId == providerId
                                                                  select app).ToList();

                    VisitDbContext dbContext = new VisitDbContext(base.connString);

                    List <VisitModel> patientvisitList = (from visit in dbContext.Visits
                                                          where visit.PatientId == patientId &&
                                                          DbFunctions.TruncateTime(visit.VisitDate) == DbFunctions.TruncateTime(requestDate.Date) &&
                                                          visit.ProviderId == providerId
                                                          select visit).ToList();

                    if ((patAppointmentList != null && patAppointmentList.Count != 0) || (patientvisitList != null && patientvisitList.Count != 0))
                    {
                        responseData.Status  = "OK";
                        responseData.Results = true;
                    }
                    else
                    {
                        responseData.Status  = "OK";
                        responseData.Results = false;
                    }
                }
                //get the discoutnpercantage using membershipTypeid
                else if (reqType == "GetMembershipDeatils")
                {
                    PatientDbContext patientDbContext = new PatientDbContext(connString);
                    var membershipDeatils             = (from mem in patientDbContext.MembershipTypes
                                                         where mem.MembershipTypeId == membershipTypeId
                                                         select new
                    {
                        MembershipTypeId = mem.MembershipTypeId,
                        DiscountPercent = mem.DiscountPercent,
                        MembershipTypeName = mem.MembershipTypeName
                    }).FirstOrDefault();

                    responseData.Status  = "OK";
                    responseData.Results = membershipDeatils;
                }
                //get the TotalAmount using providerId
                else if (reqType == "GetTotalAmountByProviderId")
                {
                    BillingDbContext billingDbContext = new BillingDbContext(connString);

                    ServiceDepartmentModel srvDept = billingDbContext.ServiceDepartment.Where(s => s.ServiceDepartmentName == "OPD").FirstOrDefault();

                    if (srvDept != null)
                    {
                        ///remove tolist from below query-- one doc will have only one opd-tkt price.. <sudrshan:14jul2017>
                        var billingItemPrice = (from bill in billingDbContext.BillItemPrice
                                                where bill.ServiceDepartmentId == srvDept.ServiceDepartmentId && bill.ItemId == providerId
                                                select bill.Price).ToList();

                        responseData.Status  = "OK";
                        responseData.Results = billingItemPrice;
                    }
                    else
                    {
                        responseData.Status       = "Failed";
                        responseData.ErrorMessage = "Failed to get OPD-Ticket Price";
                    }
                }   //getting appointment list of selected ProvideId
                else if (reqType == "get-appointment-list")
                {
                    ////.ToList()is done two times,since we can't use requestDate.Date inside IQueryable
                    //List<AppointmentModel> apptList = (from d in dbContextAppointment.Appointments
                    //                                   where d.ProviderId == providerId
                    //                                   select d).ToList();
                    //AppointmentDay apptDay = AppointmentDay.FormatData(apptList);

                    ////responseData.Status = "OK";
                    //responseData.Results = apptDay;

                    var apptList = (from apt in dbContextAppointment.Appointments
                                    where apt.ProviderId == providerId && apt.AppointmentDate == requestDate
                                    select new
                    {
                        PatientName = apt.FirstName + " " + (string.IsNullOrEmpty(apt.MiddleName) ? "" : apt.MiddleName + " ") + apt.LastName,
                        Time = apt.AppointmentTime,
                        Date = apt.AppointmentDate,
                    }).ToList();
                    if (apptList != null)
                    {
                        responseData.Status  = "OK";
                        responseData.Results = apptList;
                    }
                    else
                    {
                        responseData.Status = "Failed";
                    }
                }
            }
            catch (Exception ex)
            {
                responseData.Status       = "Failed";
                responseData.ErrorMessage = ex.Message + " exception details:" + ex.ToString();
            }
            return(DanpheJSONConvert.SerializeObject(responseData, true));
        }