public void Save(FluConsentSignature domain) { using (var adapter = PersistenceLayer.GetDataAccessAdapter()) { var entity = Mapper.Map <FluConsentSignature, FluConsentSignatureEntity>(domain); DeactivateAll(domain.EventCustomerId); if (!adapter.SaveEntity(entity)) { throw new PersistenceFailureException("Unable to save gift card answer and signature."); } } }
public bool SaveAnswers(FluVaccineConsentModel model, long orgRoleUserId) { var evenntCustomer = _eventCustomerRepository.GetById(model.EventCustomerId); if (evenntCustomer == null) { return(false); } var signatureLocation = _mediaRepository.GetFluVaccineConsentSignatureLocation(evenntCustomer.EventId, evenntCustomer.CustomerId); var version = _fluConsentSignatureRepository.GetLatestVersion(model.EventCustomerId); var fluConsentSignature = new FluConsentSignature { EventCustomerId = model.EventCustomerId, Version = version, IsActive = true, CreatedBy = orgRoleUserId, DateCreated = DateTime.Now }; var answers = new List <FluConsentAnswerModel>(); if (!model.CustomerAnswers.IsNullOrEmpty()) { answers.AddRange(model.CustomerAnswers); } if (!model.ClinicalAnswers.IsNullOrEmpty()) { answers.AddRange(model.ClinicalAnswers); } if (!answers.IsNullOrEmpty()) { var fluConsentAnswers = new List <FluConsentAnswer>(); var answerVersion = _fluConsentAnswerRepository.GetLatestVersion(model.EventCustomerId); foreach (var answer in answers) { var fluConsentAnswer = new FluConsentAnswer { EventCustomerId = model.EventCustomerId, QuestionId = answer.QuestionId, Answer = answer.Answer, Version = answerVersion + 1, IsActive = true, DateCreated = DateTime.Now, CreatedBy = orgRoleUserId }; fluConsentAnswers.Add(fluConsentAnswer); } _fluConsentAnswerRepository.SaveAnswer(fluConsentAnswers); } if (!string.IsNullOrWhiteSpace(model.PatientSignatureBytes)) { var fileName = "PatientSignature_" + Guid.NewGuid() + ".jpg"; var patientImageFile = SaveSignatureImage(model.PatientSignatureBytes, orgRoleUserId, signatureLocation, fileName); fluConsentSignature.SignatureFileId = patientImageFile.Id; fluConsentSignature.ConsentSignedDate = DateTime.Now; } //If Clinical Provider Signature provided before Patient Signature, we will not save the consent data. if (!string.IsNullOrWhiteSpace(model.ClinicalProviderSignatureBytes)) { var fileName = "ClinicalProviderSignature_" + Guid.NewGuid() + ".jpg"; var clinicalProviderImageFile = SaveSignatureImage(model.ClinicalProviderSignatureBytes, orgRoleUserId, signatureLocation, fileName); fluConsentSignature.ClinicalProviderSignatureFileId = clinicalProviderImageFile.Id; } _fluConsentSignatureRepository.Save(fluConsentSignature); var consentQuestion = model.CustomerAnswers.FirstOrDefault(x => x.QuestionId == ReceiveVaccinationQuestionId); if (consentQuestion != null && consentQuestion.Answer.ToLower() == Boolean.TrueString.ToLower()) { evenntCustomer.IsFluVaccineConsentSigned = true; _eventCustomerRepository.Save(evenntCustomer); } else { evenntCustomer.IsFluVaccineConsentSigned = false; _eventCustomerRepository.Save(evenntCustomer); } return(true); }
public FluVaccinationConsentViewModel GetFluVaccinationConsentViewModel(Event eventData, Customer customer, Host host, IEnumerable <FluConsentQuestion> questions, IEnumerable <FluConsentAnswer> answers, FluConsentSignature signature, IEnumerable <File> signatureFiles) { var model = new FluVaccinationConsentViewModel { Address = Mapper.Map <Address, AddressViewModel>(customer.Address), CustomerId = customer.CustomerId, CustomerName = customer.Name, DateofBirth = customer.DateOfBirth, Email = customer.Email != null?customer.Email.ToString() : "", EventAddress = Mapper.Map <Address, AddressViewModel>(host.Address), EventDate = eventData.EventDate, EventId = eventData.Id, Gender = (int)customer.Gender, Height = customer.Height != null ? (int)customer.Height.TotalInches : 0, Weight = customer.Weight != null ? (int)customer.Weight.TotalPounds : 0, PhoneNumber = customer.HomePhoneNumber.ToString(), Race = (int)customer.Race, }; var questionAnswers = new List <FluConsentQuestionAnswerEditModel>(); if (!answers.IsNullOrEmpty()) { foreach (var answer in answers) { var question = questions.First(x => x.Id == answer.QuestionId); var questionAnswer = new FluConsentQuestionAnswerEditModel { QuestionId = answer.QuestionId, Question = question.Question, Answer = answer.Answer, ControlValue = !string.IsNullOrWhiteSpace(question.ControlValues) ? question.ControlValues.Split(',') : null, Type = (CheckListQuestionType)question.TypeId, Index = question.Index, ParentId = question.ParentId }; questionAnswers.Add(questionAnswer); } model.Answers = questionAnswers; } if (!signatureFiles.IsNullOrEmpty()) { var mediaLocation = _mediaRepository.GetFluVaccineConsentSignatureLocation(eventData.Id, customer.CustomerId); var patientSignature = signatureFiles.FirstOrDefault(x => x.Id == signature.SignatureFileId); model.SignatureImageUrl = patientSignature != null ? mediaLocation.Url + patientSignature.Path : string.Empty; model.ConsentSignedDate = signature.ConsentSignedDate.ToString("MM/dd/yyyy"); var clinicalProviderSignature = signatureFiles.FirstOrDefault(x => x.Id == signature.ClinicalProviderSignatureFileId); model.ClinicalProviderSignatureImageUrl = clinicalProviderSignature != null ? mediaLocation.Url + clinicalProviderSignature.Path : string.Empty; } return(model); }