コード例 #1
0
        public override List <MIDAS.GBX.BusinessObjects.BusinessValidation> Validate <T>(T entity)
        {
            BO.CompanyCaseConsentApproval companyCaseConsentApproval = (BO.CompanyCaseConsentApproval)(object) entity;
            var result = companyCaseConsentApproval.Validate(companyCaseConsentApproval);

            return(result);
        }
コード例 #2
0
        public override object ConsentSave(int caseid, int companyid, List <System.Net.Http.HttpContent> streamContent, string uploadpath, bool signed)
        {
            List <BO.Document> docInfo     = new List <BO.Document>();
            StringBuilder      storagePath = new StringBuilder();
            string             SPECIALITY  = "SPECIALITY_";
            string             COMPANY     = "/COMPANY_";
            string             CASE        = "/CASE_";
            string             VISIT       = "/VISIT_";

            storagePath.Append(COMPANY)
            .Append(companyid)
            .Append(CASE)
            .Append(caseid)
            .Append("/consent");

            if (signed)
            {
                string consentPdf = GenerateConsentDocument(caseid, companyid, uploadpath, true);
                FileUpload.FileUploadManager fileUploadManager = new FileUpload.FileUploadManager(_context);
                docInfo = (List <BO.Document>)fileUploadManager.UploadSignedConsent(caseid, "consent_" + companyid, consentPdf);

                if (docInfo.ToList().FirstOrDefault <BO.Document>().Status.ToUpper().Equals("SUCCESS"))
                {
                    BO.CompanyCaseConsentApproval companyCaseConsentApprovalBO = new BO.CompanyCaseConsentApproval();
                    companyCaseConsentApprovalBO.CaseId             = caseid;
                    companyCaseConsentApprovalBO.CompanyId          = companyid;
                    companyCaseConsentApprovalBO.ConsentGivenTypeId = 3;
                    var result = this.Save(companyCaseConsentApprovalBO);
                    if (result is BO.ErrorObject)
                    {
                        return(result);
                    }
                }

                return(docInfo);
            }
            else
            {
                FileUpload.FileUploadManager fileUploadManager = new FileUpload.FileUploadManager(_context);

                docInfo = (List <BO.Document>)fileUploadManager.Upload(streamContent, storagePath.ToString(), caseid, "consent_" + companyid, uploadpath);

                if (docInfo.ToList().FirstOrDefault <BO.Document>().Status.ToUpper().Equals("SUCCESS"))
                {
                    BO.CompanyCaseConsentApproval companyCaseConsentApprovalBO = new BO.CompanyCaseConsentApproval();
                    companyCaseConsentApprovalBO.CaseId             = caseid;
                    companyCaseConsentApprovalBO.CompanyId          = companyid;
                    companyCaseConsentApprovalBO.ConsentGivenTypeId = 1;
                    var result = this.Save(companyCaseConsentApprovalBO);
                    if (result is BO.ErrorObject)
                    {
                        return(result);
                    }
                }

                return(docInfo);
            }
        }
コード例 #3
0
        public override T Convert <T, U>(U entity)
        {
            CompanyCaseConsentApproval companyCaseConsentApproval = entity as CompanyCaseConsentApproval;

            if (companyCaseConsentApproval == null)
            {
                return(default(T));
            }

            BO.CompanyCaseConsentApproval companyCaseConsentApprovalBO = new BO.CompanyCaseConsentApproval();

            companyCaseConsentApprovalBO.ID                 = companyCaseConsentApproval.Id;
            companyCaseConsentApprovalBO.CompanyId          = companyCaseConsentApproval.CompanyId;
            companyCaseConsentApprovalBO.CaseId             = companyCaseConsentApproval.CaseId;
            companyCaseConsentApprovalBO.ConsentGivenTypeId = companyCaseConsentApproval.ConsentGivenTypeId;
            companyCaseConsentApprovalBO.IsDeleted          = companyCaseConsentApproval.IsDeleted;
            companyCaseConsentApprovalBO.CreateByUserID     = companyCaseConsentApproval.CreateByUserID;
            companyCaseConsentApprovalBO.UpdateByUserID     = companyCaseConsentApproval.UpdateByUserID;

            //if (companyCaseConsentApproval.Case != null)
            //{
            //    BO.Case boCase = new BO.Case();
            //    using (CaseRepository cmp = new CaseRepository(_context))
            //    {
            //        boCase = cmp.Convert<BO.Case, Case>(companyCaseConsentApproval.Case);
            //        companyCaseConsentApprovalBO.Case = boCase;
            //    }
            //}

            BO.ConsentGivenType boConsentGivenType = new BO.ConsentGivenType();
            if (companyCaseConsentApproval.ConsentGivenType != null)
            {
                boConsentGivenType.ID              = companyCaseConsentApproval.ConsentGivenType.Id;
                boConsentGivenType.TypeText        = companyCaseConsentApproval.ConsentGivenType.TypeText;
                boConsentGivenType.TypeDescription = companyCaseConsentApproval.ConsentGivenType.TypeDescription;

                companyCaseConsentApprovalBO.ConsentGivenType = boConsentGivenType;
            }

            companyCaseConsentApprovalBO.Company      = new BO.Company();
            companyCaseConsentApprovalBO.Company.ID   = (companyCaseConsentApproval.Company != null) ? companyCaseConsentApproval.Company.id : 0;
            companyCaseConsentApprovalBO.Company.Name = (companyCaseConsentApproval.Company != null) ? companyCaseConsentApproval.Company.Name : "";

            return((T)(object)companyCaseConsentApprovalBO);
        }
コード例 #4
0
        //public override object SaveDoctor<T>(T entity)
        //{
        //    BO.DoctorCaseConsentApproval doctorCaseConsentApprovalBO = (BO.DoctorCaseConsentApproval)(object)entity;
        //    DoctorCaseConsentApproval doctorCaseConsentApprovalDB = new DoctorCaseConsentApproval();

        //    if (doctorCaseConsentApprovalBO != null)
        //    {
        //        doctorCaseConsentApprovalDB = _context.DoctorCaseConsentApprovals.Where(p => p.Id == doctorCaseConsentApprovalBO.ID
        //                                                                         && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false)))
        //                                                                         .FirstOrDefault();
        //        bool Add_doctorCaseConsentApproval = false;

        //        if (doctorCaseConsentApprovalBO.DoctorId <= 0 || doctorCaseConsentApprovalBO.Patientid <= 0)
        //        {
        //            return new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid Doctor, Case and Consent data.", ErrorLevel = ErrorLevel.Error };
        //        }

        //        if (doctorCaseConsentApprovalDB == null && doctorCaseConsentApprovalBO.ID > 0)
        //        {
        //            return new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid Doctor, Case and Consent data.", ErrorLevel = ErrorLevel.Error };
        //        }
        //        else if (doctorCaseConsentApprovalDB == null && doctorCaseConsentApprovalBO.ID <= 0)
        //        {
        //            doctorCaseConsentApprovalDB = new DoctorCaseConsentApproval();
        //            Add_doctorCaseConsentApproval = true;
        //        }

        //        if (Add_doctorCaseConsentApproval == true)
        //        {
        //            if (_context.DoctorCaseConsentApprovals.Any(p => p.DoctorId == doctorCaseConsentApprovalBO.DoctorId && p.Patientid == doctorCaseConsentApprovalBO.Patientid
        //                                                    && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))))
        //            {
        //                return new BO.ErrorObject { errorObject = "", ErrorMessage = "Doctor, Case and Consent data already exists.", ErrorLevel = ErrorLevel.Error };
        //            }
        //        }
        //        else
        //        {
        //            if (_context.DoctorCaseConsentApprovals.Any(p => p.DoctorId == doctorCaseConsentApprovalBO.DoctorId && p.Patientid == doctorCaseConsentApprovalBO.Patientid
        //                                                               && p.Id != doctorCaseConsentApprovalBO.ID
        //                                                               && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))))
        //            {
        //                return new BO.ErrorObject { errorObject = "", ErrorMessage = "Doctor, Case and Consent data already exists.", ErrorLevel = ErrorLevel.Error };
        //            }
        //        }

        //        doctorCaseConsentApprovalDB.DoctorId = doctorCaseConsentApprovalBO.DoctorId;
        //        doctorCaseConsentApprovalDB.Patientid = doctorCaseConsentApprovalBO.Patientid;
        //        doctorCaseConsentApprovalDB.FileName = doctorCaseConsentApprovalBO.FileName;

        //        if (Add_doctorCaseConsentApproval == true)
        //        {
        //            doctorCaseConsentApprovalDB = _context.DoctorCaseConsentApprovals.Add(doctorCaseConsentApprovalDB);
        //        }
        //        _context.SaveChanges();

        //    }

        //    else
        //    {
        //        return new BO.ErrorObject { errorObject = "", ErrorMessage = "Please pass valid details.", ErrorLevel = ErrorLevel.Error };
        //    }

        //    _context.SaveChanges();

        //    doctorCaseConsentApprovalDB = _context.DoctorCaseConsentApprovals.Where(p => p.Id == doctorCaseConsentApprovalDB.Id
        //                                                                      && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false)))
        //                                                                      .FirstOrDefault<DoctorCaseConsentApproval>();

        //    var res = Convert<BO.DoctorCaseConsentApproval, DoctorCaseConsentApproval>(doctorCaseConsentApprovalDB);
        //    return (object)res;
        //}
        #endregion

        #region Get By ID
        public override object Get(int id)
        {
            var acc = _context.CompanyCaseConsentApprovals.Include("Case")
                      .Include("Company")
                      .Include("ConsentGivenType")
                      .Where(p => p.Id == id &&
                             (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false)))
                      .FirstOrDefault <CompanyCaseConsentApproval>();

            BO.CompanyCaseConsentApproval acc_ = Convert <BO.CompanyCaseConsentApproval, CompanyCaseConsentApproval>(acc);
            if (acc_ == null)
            {
                return(new BO.ErrorObject {
                    ErrorMessage = "No record found.", errorObject = "", ErrorLevel = ErrorLevel.Error
                });
            }
            return((object)acc_);
        }
コード例 #5
0
        public override object Save <T>(T entity)
        {
            BO.CompanyCaseConsentApproval companyCaseConsentApprovalBO = (BO.CompanyCaseConsentApproval)(object) entity;
            CompanyCaseConsentApproval    companyCaseConsentApprovalDB = new CompanyCaseConsentApproval();

            //using (var dbContextTransaction = _context.Database.BeginTransaction())
            //{
            if (companyCaseConsentApprovalBO != null)
            {
                int         patient     = _context.Cases.Where(p => p.Id == companyCaseConsentApprovalBO.CaseId && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).Select(p => p.PatientId).FirstOrDefault();
                UserCompany userCompany = _context.UserCompanies.Where(p => p.UserID == patient && p.CompanyID == companyCaseConsentApprovalBO.CompanyId && p.IsAccepted == true && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).FirstOrDefault();
                if (userCompany == null)
                {
                    userCompany            = new UserCompany();
                    userCompany.CompanyID  = companyCaseConsentApprovalBO.CompanyId;
                    userCompany.UserID     = patient;
                    userCompany.IsAccepted = true;
                    userCompany            = _context.UserCompanies.Add(userCompany);
                    _context.SaveChanges();
                }

                CaseCompanyMapping caseCompanyMapping = _context.CaseCompanyMappings.Where(p => p.CaseId == companyCaseConsentApprovalBO.CaseId && p.CompanyId == companyCaseConsentApprovalBO.CompanyId && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).FirstOrDefault();
                if (caseCompanyMapping == null)
                {
                    caseCompanyMapping = new CaseCompanyMapping();
                    var referredBy = _context.Referrals.Where(p => p.CaseId == companyCaseConsentApprovalBO.CaseId.Value &&
                                                              p.ToCompanyId == companyCaseConsentApprovalBO.CompanyId &&
                                                              (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false)))
                                     .Select(p2 => p2.FromCompanyId).FirstOrDefault();


                    caseCompanyMapping.CaseId    = companyCaseConsentApprovalBO.CaseId.Value;
                    caseCompanyMapping.CompanyId = companyCaseConsentApprovalBO.CompanyId;

                    caseCompanyMapping.IsOriginator     = false; // companyCaseConsentApprovalBO.IsOriginator;
                    caseCompanyMapping.AddedByCompanyId = referredBy != 0 ? referredBy : companyCaseConsentApprovalBO.CompanyId;

                    caseCompanyMapping = _context.CaseCompanyMappings.Add(caseCompanyMapping);
                    _context.SaveChanges();
                }

                companyCaseConsentApprovalDB = _context.CompanyCaseConsentApprovals.Where(p => p.CaseId == companyCaseConsentApprovalBO.CaseId &&
                                                                                          p.CompanyId == companyCaseConsentApprovalBO.CompanyId &&
                                                                                          (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false)))
                                               .FirstOrDefault();

                bool Add_companyCaseConsentApproval = false;

                if (companyCaseConsentApprovalDB == null)
                {
                    Add_companyCaseConsentApproval = true;
                    companyCaseConsentApprovalDB   = new CompanyCaseConsentApproval();
                }
                else
                {
                    return(new BO.ErrorObject {
                        errorObject = "", ErrorMessage = "Company, Case and Consent data already exists.", ErrorLevel = ErrorLevel.Error
                    });
                }

                companyCaseConsentApprovalDB.CompanyId = companyCaseConsentApprovalBO.CompanyId;
                companyCaseConsentApprovalDB.CaseId    = (int)companyCaseConsentApprovalBO.CaseId;
                if (companyCaseConsentApprovalDB.ConsentGivenTypeId <= 0)
                {
                    companyCaseConsentApprovalDB.ConsentGivenTypeId = 1;
                }

                if (Add_companyCaseConsentApproval == true)
                {
                    companyCaseConsentApprovalDB.CreateByUserID = 0;
                    companyCaseConsentApprovalDB.CreateDate     = DateTime.UtcNow;

                    companyCaseConsentApprovalDB = _context.CompanyCaseConsentApprovals.Add(companyCaseConsentApprovalDB);
                }
                else
                {
                    companyCaseConsentApprovalDB.UpdateByUserID = 0;
                    companyCaseConsentApprovalDB.UpdateDate     = DateTime.UtcNow;
                }

                _context.SaveChanges();
            }

            else
            {
                return(new BO.ErrorObject {
                    errorObject = "", ErrorMessage = "Please pass valid details.", ErrorLevel = ErrorLevel.Error
                });
            }

            //dbContextTransaction.Commit();
            companyCaseConsentApprovalDB = _context.CompanyCaseConsentApprovals.Include("Case")
                                           .Include("Company")
                                           .Include("ConsentGivenType")
                                           .Where(p => p.Id == companyCaseConsentApprovalDB.Id &&
                                                  (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false)))
                                           .FirstOrDefault <CompanyCaseConsentApproval>();
            //}
            var res = Convert <BO.CompanyCaseConsentApproval, CompanyCaseConsentApproval>(companyCaseConsentApprovalDB);

            return((object)res);
        }
コード例 #6
0
        public override Object UploadSignedConsent(int id, string type, string uploadpath)
        {
            BO.Document docInfo   = new BO.Document();
            int         companyid = 0;

            string errMessage = string.Empty;
            string filename   = string.Empty;

            using (var dbContextTransaction = _context.Database.BeginTransaction())
            {
                try
                {
                    if (type.ToUpper().Contains(EN.Constants.ConsentType))
                    {
                        companyid = System.Convert.ToInt16(type.Split('_')[1]);
                        if (_context.MidasDocuments.Any(cc => cc.ObjectId == id &&
                                                        cc.ObjectType == EN.Constants.ConsentType + "_" + companyid &&
                                                        (cc.IsDeleted.HasValue == false || (cc.IsDeleted.HasValue == true && cc.IsDeleted.Value == false))))
                        {
                            //throw new Exception("Company, Case and Consent data already exists.");
                            dbContextTransaction.Rollback();
                            return(new BO.ErrorObject {
                                errorObject = "", ErrorMessage = "Company, Case and Consent data already exists.", ErrorLevel = ErrorLevel.Error
                            });
                        }
                    }

                    MidasDocument midasdoc = _context.MidasDocuments.Add(new MidasDocument()
                    {
                        ObjectType   = type,
                        ObjectId     = id,
                        DocumentName = Path.GetFileName(uploadpath),
                        DocumentPath = uploadpath.Replace(ConfigurationManager.AppSettings.Get("LOCAL_UPLOAD_PATH"), ConfigurationManager.AppSettings.Get("BLOB_SERVER")),
                        CreateDate   = DateTime.UtcNow
                    });
                    _context.Entry(midasdoc).State = System.Data.Entity.EntityState.Added;
                    _context.SaveChanges();

                    if (type.ToUpper().Contains(EN.Constants.ConsentType))
                    {
                        type = EN.Constants.ConsentType;
                    }

                    CaseCompanyConsentDocument caseCompanyConsentDocument = _context.CaseCompanyConsentDocuments.Add(new CaseCompanyConsentDocument()
                    {
                        MidasDocumentId = midasdoc.Id,
                        CaseId          = id,
                        CompanyId       = companyid,
                        DocumentName    = Path.GetFileName(uploadpath),
                        CreateDate      = DateTime.UtcNow
                    });
                    _context.Entry(caseCompanyConsentDocument).State = System.Data.Entity.EntityState.Added;
                    _context.SaveChanges();
                    filename = caseCompanyConsentDocument.DocumentName;

                    docInfo.Status       = errMessage.Equals(string.Empty) ? "Success" : "Failed";
                    docInfo.Message      = errMessage;
                    docInfo.DocumentId   = midasdoc.Id;
                    docInfo.DocumentPath = errMessage.Equals(string.Empty) ? midasdoc.DocumentPath : midasdoc.DocumentName;
                    docInfo.DocumentName = midasdoc.DocumentName;
                    docInfo.id           = id;


                    if (docInfo.Status.ToUpper().Equals("SUCCESS"))
                    {
                        CompanyCaseConsentApprovalRepository CompanyCaseConsentApprovalRepository = new CompanyCaseConsentApprovalRepository(_context);
                        BO.CompanyCaseConsentApproval        companyCaseConsentApprovalBO         = new BO.CompanyCaseConsentApproval();
                        companyCaseConsentApprovalBO.CaseId             = id;
                        companyCaseConsentApprovalBO.CompanyId          = companyid;
                        companyCaseConsentApprovalBO.ConsentGivenTypeId = 3;
                        var result = CompanyCaseConsentApprovalRepository.Save(companyCaseConsentApprovalBO);
                        if (result is BO.ErrorObject)
                        {
                            return(new BO.ErrorObject {
                                errorObject = "", ErrorMessage = "Company, Case and Consent data already exists.", ErrorLevel = ErrorLevel.Error
                            });
                        }
                    }


                    dbContextTransaction.Commit();
                }
                catch (Exception err)
                {
                    dbContextTransaction.Rollback();
                    return(new BO.ErrorObject {
                        errorObject = "", ErrorMessage = "Error while saving consent", ErrorLevel = ErrorLevel.Error
                    });
                }
            }

            return((object)docInfo);
        }
コード例 #7
0
        public override Object SaveAsBlob(int objectId, int companyId, string objectType, string documentType, string uploadpath)
        {
            BO.Document docInfo    = new BO.Document();
            string      errMessage = string.Empty;
            string      errDesc    = string.Empty;

            using (var dbContextTransaction = _context.Database.BeginTransaction())
            {
                MidasDocument midasdoc = _context.MidasDocuments.Add(new MidasDocument()
                {
                    ObjectType   = documentType.ToUpper().Equals(EN.Constants.ConsentType) ? string.Concat(EN.Constants.ConsentType, "_" + companyId) : objectType,
                    ObjectId     = objectId,
                    DocumentType = documentType,
                    DocumentName = Path.GetFileName(uploadpath),//streamContent.Headers.ContentDisposition.FileName.Replace("\"", string.Empty),
                    DocumentPath = uploadpath,
                    CreateDate   = DateTime.UtcNow
                });
                _context.Entry(midasdoc).State = System.Data.Entity.EntityState.Added;
                _context.SaveChanges();

                if (documentType.ToUpper().Equals(EN.Constants.ConsentType))
                {
                    CaseCompanyConsentDocument caseCompConsentDoc = _context.CaseCompanyConsentDocuments.Add(new CaseCompanyConsentDocument()
                    {
                        MidasDocumentId = midasdoc.Id,
                        CaseId          = objectId,
                        DocumentType    = documentType,
                        CompanyId       = companyId,
                        DocumentName    = Path.GetFileName(uploadpath),//streamContent.Headers.ContentDisposition.FileName.Replace("\"", string.Empty),
                        CreateDate      = DateTime.UtcNow
                    });
                    _context.Entry(caseCompConsentDoc).State = System.Data.Entity.EntityState.Added;
                    _context.SaveChanges();

                    BO.CompanyCaseConsentApproval        companyCaseConsentApprovalBO         = new BO.CompanyCaseConsentApproval();
                    CompanyCaseConsentApprovalRepository CompanyCaseConsentApprovalRepository = new CompanyCaseConsentApprovalRepository(_context);
                    companyCaseConsentApprovalBO.CaseId    = objectId;
                    companyCaseConsentApprovalBO.CompanyId = companyId;
                    var result = CompanyCaseConsentApprovalRepository.Save(companyCaseConsentApprovalBO);
                    if (result is BO.ErrorObject)
                    {
                        errMessage = "Failed";
                        errDesc    = ((BO.ErrorObject)result).ErrorMessage;
                        dbContextTransaction.Rollback();
                    }
                    else
                    {
                        dbContextTransaction.Commit();
                    }
                }
                else
                {
                    CaseDocument caseDoc = _context.CaseDocuments.Add(new CaseDocument()
                    {
                        MidasDocumentId = midasdoc.Id,
                        CaseId          = objectId,
                        DocumentType    = documentType,
                        DocumentName    = Path.GetFileName(uploadpath),//streamContent.Headers.ContentDisposition.FileName.Replace("\"", string.Empty),
                        CreateDate      = DateTime.UtcNow
                    });
                    _context.Entry(caseDoc).State = System.Data.Entity.EntityState.Added;
                    _context.SaveChanges();
                    dbContextTransaction.Commit();
                }

                docInfo.Status       = errMessage.Equals(string.Empty) ? "Success" : "Failed";
                docInfo.Message      = errDesc;
                docInfo.DocumentId   = midasdoc.Id;
                docInfo.DocumentPath = errMessage.Equals(string.Empty) ? midasdoc.DocumentPath : midasdoc.DocumentName;
                docInfo.DocumentName = midasdoc.DocumentName;
                docInfo.DocumentType = errMessage.Equals(string.Empty) ? midasdoc.DocumentType : string.Empty;
                docInfo.id           = objectId;
            }

            return((Object)docInfo);
        }