Пример #1
0
        public AwvPcpConsentViewModel GetAwvPcpConsentViewModel(long customerId, long eventId)
        {
            var customer  = _customerRepository.GetCustomer(customerId);
            var pcp       = _primaryCarePhysicianRepository.Get(customer.CustomerId);
            var eventData = _eventRepository.GetById(eventId);

            string   signatureUrl           = string.Empty;
            DateTime?signedDate             = null;
            var      eventCustomer          = _eventCustomerRepository.Get(eventId, customerId);
            var      mediaLocation          = _mediaRepository.GetPhysicianRecordRequestSignatureLocation(eventId, customerId);
            var      physicianRecordRequest = _physicianRecordRequestSignatureRepository.GetByEventCustomerId(eventCustomer.Id);

            if (physicianRecordRequest != null)
            {
                var signatureFile = _fileRepository.GetById(physicianRecordRequest.SignatureFileId);
                signatureUrl = mediaLocation.Url + signatureFile.Path;
                signedDate   = physicianRecordRequest.ConsentSignedDate;
            }

            return(GetAwvPcpConsentViewModel(customer, eventData, pcp, signatureUrl, signedDate));
        }
        public PhysicianRecordRequestSignatureModel GetPhysicianRecordRequestSignature(long eventCustomerId)
        {
            var physicianRecordRequest = _physicianRecordRequestSignatureRepository.GetByEventCustomerId(eventCustomerId);

            var file = physicianRecordRequest != null?_fileRepository.GetById(physicianRecordRequest.SignatureFileId) : null;

            if (file == null)
            {
                return(new PhysicianRecordRequestSignatureModel
                {
                    EventCustomerId = eventCustomerId,
                    SignatureBytes = null
                });
            }

            var eventCustomer     = _eventCustomerRepository.GetById(eventCustomerId);
            var filename          = file.Path;
            var signatureLocation = _mediaRepository.GetPhysicianRecordRequestSignatureLocation(eventCustomer.EventId, eventCustomer.CustomerId);
            var filePath          = Path.Combine(signatureLocation.PhysicalPath, filename);

            var physicianRecordRequestSignatureModel = new PhysicianRecordRequestSignatureModel
            {
                EventCustomerId = eventCustomerId
            };

            var signatureBytes = string.Empty;

            if (File.Exists(filePath))
            {
                var bytes = File.ReadAllBytes(filePath);
                signatureBytes = Convert.ToBase64String(bytes);
            }

            physicianRecordRequestSignatureModel.SignatureBytes = signatureBytes;

            return(physicianRecordRequestSignatureModel);
        }