protected override async Task ValidateAndSave() { if (MDRDetails.CountryId != null) { MDRDetails.Country = await _referenceDataRepository.GetCountryByIdAsync((int)MDRDetails.CountryId); } UpdateFlags(); ValidateRelatedNotificationId(); ValidationService.TrySetFormattedDate(MDRDetails, "MDRDetails", nameof(MDRDetails.MDRTreatmentStartDate), FormattedMdrTreatmentDate); MDRDetails.DatesHaveBeenSet = true; // Add additional field required for date validation MDRDetails.Dob = Notification.PatientDetails.Dob; MDRDetails.SetValidationContext(Notification); if (TryValidateModel(MDRDetails, nameof(MDRDetails))) { await Service.UpdateMDRDetailsAsync(Notification, MDRDetails); await _enhancedSurveillanceAlertsService.CreateOrDismissMdrAlert(Notification); } }
protected override async Task <IActionResult> PrepareAndDisplayPageAsync(bool isBeingSubmitted) { if (!Notification.IsMdr) { return(NotFound()); } var countries = await _referenceDataRepository.GetAllCountriesAsync(); Countries = new SelectList(countries, nameof(Country.CountryId), nameof(Country.Name)); MDRDetails = Notification.MDRDetails; FormattedMdrTreatmentDate = MDRDetails.MDRTreatmentStartDate.ConvertToFormattedDate(); await SetNotificationProperties(isBeingSubmitted, MDRDetails); if (MDRDetails.ShouldValidateFull) { TryValidateModel(MDRDetails, MDRDetails.GetType().Name); } RenderConditionalCountryFieldIds = countries .Where(c => c.IsoCode == Models.Countries.UkCode) .Select(c => c.CountryId.ToString()) .ToList(); return(Page()); }
protected override async Task ValidateAndSave() { if (MDRDetails.CountryId != null) { MDRDetails.Country = await _referenceDataRepository.GetCountryByIdAsync((int)MDRDetails.CountryId); } UpdateFlags(); ValidateRelatedNotificationId(); MDRDetails.SetValidationContext(Notification); if (TryValidateModel(MDRDetails, nameof(MDRDetails))) { await Service.UpdateMDRDetailsAsync(Notification, MDRDetails); } }
private MDRDetails ExtractMdrDetailsAsync(MigrationDbNotification rawNotification) { var mdr = new MDRDetails(); mdr.ExposureToKnownCaseStatus = Converter.GetStatusFromString(rawNotification.mdr_ExposureToKnownTbCase); mdr.RelationshipToCase = rawNotification.mdr_RelationshipToCase; // Notification.mdr_CaseInUKStatus is not used, as in NTBS it's calculated on the fly mdr.CountryId = rawNotification.mdr_CountryId; if (!string.IsNullOrEmpty(rawNotification.mdr_RelatedNotificationId)) { mdr.NotifiedToPheStatus = Status.Yes; mdr.RelatedNotificationId = int.Parse(rawNotification.mdr_RelatedNotificationId); } return(mdr); }
public async Task UpdateMDRDetailsAsync(Notification notification, MDRDetails details) { _context.SetValues(notification.MDRDetails, details); await _notificationRepository.SaveChangesAsync(); }