Exemplo n.º 1
0
        public override object GetByDocumentId(int documentId)
        {
            BO.Document docInfo   = new BO.Document();
            var         midasDocs = _context.MidasDocuments.Where(p => p.Id == documentId && (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false))).FirstOrDefault();

            return(midasDocs.DocumentPath);
        }
Exemplo n.º 2
0
        public override object SaveAsBlob(int ObjectId, int CompanyId, string DocumentObject, string DocumentType, string uploadpath)
        {
            BO.Document docInfo = new BO.Document();

            switch (DocumentObject.ToUpper())
            {
            case EN.Constants.CaseType:
                CaseDocumentRepository CaseDocumentRepository = new CaseDocumentRepository(_context);

                docInfo = (BO.Document)CaseDocumentRepository.SaveAsBlob(ObjectId, CompanyId, DocumentObject, DocumentType, uploadpath);
                break;

            case EN.Constants.VisitType:
                VisitDocumentRepository VisitDocumentRepository = new VisitDocumentRepository(_context);
                docInfo = (BO.Document)VisitDocumentRepository.SaveAsBlob(ObjectId, CompanyId, DocumentObject, DocumentType, uploadpath);
                break;

            case EN.Constants.PatientType:
                PatientDocumentRepository PatientDocumentRepository = new PatientDocumentRepository(_context);
                docInfo = (BO.Document)PatientDocumentRepository.SaveAsBlob(ObjectId, CompanyId, DocumentObject, DocumentType, uploadpath);
                break;
            }

            return(docInfo);
        }
Exemplo n.º 3
0
        public override object Save <T>(T entity)
        {
            BO.Common.UploadInfo uploadInfo = (BO.Common.UploadInfo)(object) entity;
            BO.Document          docInfo    = new BO.Document();

            switch (uploadInfo.ObjectType.ToUpper())
            {
            case EN.Constants.CaseType:
                //case EN.Constants.ConsentType:
                CaseDocumentRepository CaseDocumentRepository = new CaseDocumentRepository(_context);
                docInfo = (BO.Document)CaseDocumentRepository.SaveAsBlob(uploadInfo.ObjectId, uploadInfo.CompanyId, uploadInfo.ObjectType, uploadInfo.DocumentType, uploadInfo.BlobPath);
                break;

            case EN.Constants.VisitType:
                VisitDocumentRepository VisitDocumentRepository = new VisitDocumentRepository(_context);
                docInfo = (BO.Document)VisitDocumentRepository.SaveAsBlob(uploadInfo.ObjectId, uploadInfo.CompanyId, uploadInfo.ObjectType, uploadInfo.DocumentType, uploadInfo.BlobPath);
                break;

            case EN.Constants.PatientType:
                PatientDocumentRepository PatientDocumentRepository = new PatientDocumentRepository(_context);
                docInfo = (BO.Document)PatientDocumentRepository.SaveAsBlob(uploadInfo.ObjectId, uploadInfo.CompanyId, uploadInfo.ObjectType, uploadInfo.DocumentType, uploadInfo.BlobPath);
                break;
            }

            return(docInfo);
        }
Exemplo n.º 4
0
        public override List <MIDAS.GBX.BusinessObjects.BusinessValidation> Validate <T>(T entity)
        {
            var result = new List <BO.BusinessValidation>();

            if (typeof(T) == typeof(BO.Document))
            {
                BO.Document docInfo = (BO.Document)(object) entity;
                result = docInfo.Validate(docInfo);
            }
            else if (typeof(T) == typeof(BO.Common.UploadInfo))
            {
                List <BO.BusinessValidation> validations = new List <BO.BusinessValidation>();
                result = validations;
            }
            return(result);
        }
        public override Object SaveAsBlob(int objectId, int companyId, string objectType, string documentType, string uploadpath)
        {
            BO.Document docInfo    = new BO.Document();
            string      errMessage = string.Empty;

            MidasDocument midasdoc = _context.MidasDocuments.Add(new MidasDocument()
            {
                ObjectType   = 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();

            VisitDocument visitDoc = _context.VisitDocuments.Add(new VisitDocument()
            {
                MidasDocumentId = midasdoc.Id,
                DocumentType    = documentType,
                PatientVisitId  = objectId,
                DocumentName    = Path.GetFileName(uploadpath),//streamContent.Headers.ContentDisposition.FileName.Replace("\"", string.Empty),
                CreateDate      = DateTime.UtcNow
            });

            _context.Entry(visitDoc).State = System.Data.Entity.EntityState.Added;
            _context.SaveChanges();

            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.DocumentType = errMessage.Equals(string.Empty) ? midasdoc.DocumentType : string.Empty;
            docInfo.id           = objectId;

            return((Object)docInfo);
        }
Exemplo n.º 6
0
        public override object Save <T>(T entity)
        {
            BO.Common.UploadInfo uploadInfo = (BO.Common.UploadInfo)(object) entity;
            BO.Document          docInfo    = new BO.Document();

            switch (uploadInfo.ObjectType.ToUpper())
            {
            case EN.Constants.CaseType:
            case EN.Constants.ConsentType:
                CaseDocumentRepository CaseDocumentRepository = new CaseDocumentRepository(_context);
                docInfo = (BO.Document)CaseDocumentRepository.SaveAsBlob(uploadInfo.ObjectId, uploadInfo.CompanyId, uploadInfo.ObjectType, uploadInfo.DocumentType, uploadInfo.BlobPath);
                break;

            case EN.Constants.VisitType:
                VisitDocumentRepository VisitDocumentRepository = new VisitDocumentRepository(_context);
                docInfo = (BO.Document)VisitDocumentRepository.SaveAsBlob(uploadInfo.ObjectId, uploadInfo.CompanyId, uploadInfo.ObjectType, uploadInfo.DocumentType, uploadInfo.BlobPath);
                break;
            }
            //docInfo = (BO.Document)fileUploadManager.SaveBlob(streamContent, ObjectId, DocumentObject, uploadpath);

            return(docInfo);
        }
Exemplo n.º 7
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);
        }
        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())
            {
                if (documentType.ToLower() == "profile")
                {
                    var patientProfileDocumemnts = _context.MidasDocuments.Where(mid => mid.ObjectId == objectId &&
                                                                                 mid.DocumentType == documentType &&
                                                                                 (mid.IsDeleted.HasValue == false || (mid.IsDeleted.HasValue == true && mid.IsDeleted.Value == false)));
                    patientProfileDocumemnts.ToList().ForEach(ppd => ppd.IsDeleted = true);
                    _context.SaveChanges();
                }

                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();


                PatientDocument patientDoc = _context.PatientDocuments.Add(new PatientDocument()
                {
                    MidasDocumentId = midasdoc.Id,
                    PatientId       = objectId,
                    DocumentType    = documentType,
                    DocumentName    = Path.GetFileName(uploadpath),//streamContent.Headers.ContentDisposition.FileName.Replace("\"", string.Empty),
                    CreateDate      = DateTime.UtcNow
                });
                _context.Entry(patientDoc).State = System.Data.Entity.EntityState.Added;
                _context.SaveChanges();

                //Code to update User Info with ImageLink from midasdoc.DocumentPath
                if (patientDoc.DocumentType.ToLower() == "profile".ToLower())
                {
                    int    PatientId = midasdoc.ObjectId;
                    string ImageLink = midasdoc.DocumentPath;

                    var patientUser = _context.Users.Where(p => p.id == PatientId &&
                                                           (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false)))
                                      .FirstOrDefault();

                    if (patientUser != null)
                    {
                        patientUser.ImageLink = ImageLink;
                        _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);
        }
Exemplo n.º 9
0
        public override object DeleteFile(int caseId, int id)
        {
            BO.Document docInfo = new BO.Document();
            try
            {
                var casedocument = _context.CaseDocuments.Where(p => p.CaseId == caseId && p.MidasDocumentId == id &&
                                                                (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false)))
                                   .FirstOrDefault <CaseDocument>();

                var casecompanyconsentdocument = _context.CaseCompanyConsentDocuments.Where(p => p.CaseId == caseId && p.MidasDocumentId == id &&
                                                                                            (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false)))
                                                 .FirstOrDefault <CaseCompanyConsentDocument>();

                var referraldocument = _context.ReferralDocuments.Where(p => p.ReferralId == caseId && p.MidasDocumentId == id &&
                                                                        (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false)))
                                       .FirstOrDefault <ReferralDocument>();

                var acc = _context.MidasDocuments.Where(p => p.Id == id &&
                                                        (p.IsDeleted.HasValue == false || (p.IsDeleted.HasValue == true && p.IsDeleted.Value == false)))
                          .FirstOrDefault <MidasDocument>();
                string newFile = string.Concat(Path.GetFileNameWithoutExtension(acc.DocumentName), DateTime.Now.ToString("yyyyMMddHHmm"), Path.GetExtension(acc.DocumentName));
                string oldfile = acc.DocumentName;

                if (casedocument != null)
                {
                    casedocument.IsDeleted    = true;
                    casedocument.DocumentName = newFile;
                    _context.SaveChanges();
                }
                if (casecompanyconsentdocument != null)
                {
                    casecompanyconsentdocument.IsDeleted    = true;
                    casecompanyconsentdocument.DocumentName = newFile;
                    _context.SaveChanges();
                }
                if (referraldocument != null)
                {
                    referraldocument.IsDeleted    = true;
                    referraldocument.DocumentName = newFile;
                    _context.SaveChanges();
                }

                if (acc != null)
                {
                    acc.IsDeleted    = true;
                    acc.DocumentName = newFile;
                    _context.SaveChanges();
                }
                else if (acc == null)
                {
                    return(new BO.ErrorObject {
                        ErrorMessage = "No record found.", errorObject = "", ErrorLevel = ErrorLevel.Error
                    });
                }

                File.Copy(acc.DocumentPath.Replace(ConfigurationManager.AppSettings.Get("BLOB_PATH"), ConfigurationManager.AppSettings.Get("LOCAL_PATH")) + "\\" + oldfile, acc.DocumentPath.Replace(ConfigurationManager.AppSettings.Get("BLOB_PATH"), ConfigurationManager.AppSettings.Get("LOCAL_PATH")) + "\\" + newFile);
                File.Delete(acc.DocumentPath.Replace(ConfigurationManager.AppSettings.Get("BLOB_PATH"), ConfigurationManager.AppSettings.Get("LOCAL_PATH")) + "\\" + oldfile);

                docInfo.id           = caseId;
                docInfo.DocumentId   = acc.Id;
                docInfo.DocumentName = newFile;
                docInfo.DocumentPath = acc.DocumentPath;
                docInfo.IsDeleted    = acc.IsDeleted;
            }
            catch (Exception err)
            { return(new BO.ErrorObject {
                    ErrorMessage = "System error.", errorObject = err.Message.ToString(), ErrorLevel = ErrorLevel.Error
                }); }
            return((object)docInfo);
        }
Exemplo n.º 10
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);
        }