public static VisitModel GetVisitItemsMapped(int patientId, string visitType, int providerId, DateTime visitDate, int userID, string connString)
        {
            var visit = new VisitModel();

            visit.PatientId            = patientId;
            visit.VisitType            = visitType;
            visit.ProviderId           = providerId;
            visit.BillingStatus        = "unpaid";
            visit.VisitStatus          = "initiated";
            visit.CreatedOn            = visitDate;
            visit.AppointmentType      = "New";
            visit.CreatedBy            = userID;
            visit.VisitDate            = visitDate;
            visit.VisitTime            = visitDate.TimeOfDay;
            visit.ProviderName         = VisitBL.GetProviderName(visit.ProviderId, connString);
            visit.VisitCode            = VisitBL.CreateNewPatientVisitCode(visit.VisitType, connString);
            visit.IsVisitContinued     = false;
            visit.IsSignedVisitSummary = false;
            visit.IsActive             = true;
            return(visit);
        }
Beispiel #2
0
        public string Put()
        {
            DanpheHTTPResponse <object> responseData = new DanpheHTTPResponse <object>();

            try
            {
                VisitDbContext dbContext = new VisitDbContext(base.connString);
                string         str       = this.ReadPostData();
                string         reqType   = this.ReadQueryStringData("reqType");
                //string billingStatus = this.ReadQueryStringData("billingStatus");
                //int patientVisitId = ToInt(this.ReadQueryStringData("billingStatus"));
                bool continuedVisitStatus = ToBool(this.ReadQueryStringData("continuedVisitStatus"));

                if (reqType == "reassignProvider")
                {
                    VisitModel visitData = DanpheJSONConvert.DeserializeObject <VisitModel>(str);
                    visitData.ModifiedOn   = System.DateTime.Now;
                    visitData.ProviderName = GetProviderName(visitData.ProviderId);

                    BillingDbContext billingDbContext = new BillingDbContext(base.connString);

                    Boolean Flag = false;
                    Flag = VisitBL.ReAssignProviderTxn(dbContext, visitData, billingDbContext);
                    if (Flag)
                    {
                        responseData.Status = "OK";
                    }
                    else
                    {
                        responseData.Status = "Failed";
                    }
                }
                else if (reqType == "changeProvider")
                {
                    VisitModel data  = DanpheJSONConvert.DeserializeObject <VisitModel>(str);
                    var        visit = dbContext.Visits.Where(v => v.PatientVisitId == data.PatientVisitId).Select(p => p).FirstOrDefault();
                    visit.ModifiedBy   = data.ModifiedBy;
                    visit.ModifiedOn   = System.DateTime.Now;
                    visit.ProviderName = GetProviderName(data.ProviderId);
                    visit.ProviderId   = data.ProviderId;
                    visit.Remarks      = string.IsNullOrEmpty(visit.Remarks) ? data.Remarks : (visit.Remarks + data.Remarks);

                    dbContext.Visits.Attach(visit);
                    dbContext.Entry(visit).Property(a => a.ModifiedBy).IsModified   = true;
                    dbContext.Entry(visit).Property(a => a.ModifiedOn).IsModified   = true;
                    dbContext.Entry(visit).Property(a => a.ProviderName).IsModified = true;
                    dbContext.Entry(visit).Property(a => a.ProviderId).IsModified   = true;
                    dbContext.Entry(visit).Property(a => a.Remarks).IsModified      = true;

                    dbContext.SaveChanges();


                    responseData.Status  = "OK";
                    responseData.Results = visit.ProviderName;
                }
            }
            catch (Exception ex)
            {
                responseData.Status       = "Failed";
                responseData.ErrorMessage = ex.Message + " exception details:" + ex.ToString();
            }
            return(DanpheJSONConvert.SerializeObject(responseData, true));
        }