Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Oddvocado committed Sep 20, 2023
2 parents 8c6d02c + 6c899d7 commit 31bb74b
Show file tree
Hide file tree
Showing 32 changed files with 406 additions and 119 deletions.
2 changes: 1 addition & 1 deletion src/UDS.Net.Forms.Tests/UDS.Net.Forms.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<ReleaseVersion>1.0.3</ReleaseVersion>
<ReleaseVersion>1.0.4</ReleaseVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

namespace UDS.Net.Forms.DataAnnotations
{
public class SpecialCharacterAttribute : ValidationAttribute, IClientModelValidator
public class ProhibitedCharactersAttribute : ValidationAttribute, IClientModelValidator
{
public void AddValidation(ClientModelValidationContext context)
{
MergeAttribute(context.Attributes, "data-val", "true");
MergeAttribute(context.Attributes, "data-val-specialcharacter", GetErrorMessage());
MergeAttribute(context.Attributes, "data-val-prohibitedcharacters", GetErrorMessage());
}
public static string GetErrorMessage()
{
Expand All @@ -23,9 +23,9 @@ public static string GetErrorMessage()

protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
if (value is string allowableCode)
if (value is string userInput)
{
if (allowableCode.Contains("'") || allowableCode.Contains("\"") || allowableCode.Contains("&") || allowableCode.Contains("%"))
if (userInput.Contains("'") || userInput.Contains("\"") || userInput.Contains("&") || userInput.Contains("%"))
{
return new ValidationResult(GetErrorMessage());
}
Expand Down
1 change: 1 addition & 0 deletions src/UDS.Net.Forms/Extensions/DomainToViewModelMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ public static A2 ToVM(this A2FormFields fields, int formId)
INBIRMO = fields.INBIRMO,
INBIRYR = fields.INBIRYR,
INSEX = fields.INSEX,
NEWINF = fields.NEWINF,
INHISP = fields.INHISP,
INHISPOR = fields.INHISPOR,
INHISPOX = fields.INHISPOX,
Expand Down
1 change: 1 addition & 0 deletions src/UDS.Net.Forms/Extensions/ViewModelToDomainMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public static Form ToEntity(this A2 vm)
INBIRMO = vm.INBIRMO,
INBIRYR = vm.INBIRYR,
INSEX = vm.INSEX,
NEWINF = vm.NEWINF,
INHISP = vm.INHISP,
INHISPOR = vm.INHISPOR,
INHISPOX = vm.INHISPOX,
Expand Down
6 changes: 3 additions & 3 deletions src/UDS.Net.Forms/Models/FormModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,19 @@ public virtual IEnumerable<ValidationResult> Validate(ValidationContext validati
{
yield return new ValidationResult(
$"Form kind is required",
new[] { nameof(ReasonCodeNotIncluded) });
new[] { nameof(Kind) });
}
if (string.IsNullOrWhiteSpace(Version.Trim()))
{
yield return new ValidationResult(
$"Form version is required",
new[] { nameof(ReasonCodeNotIncluded) });
new[] { nameof(Version) });
}
if (string.IsNullOrWhiteSpace(CreatedBy.Trim()))
{
yield return new ValidationResult(
$"Created by is required",
new[] { nameof(ReasonCodeNotIncluded) });
new[] { nameof(CreatedBy) });
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/UDS.Net.Forms/Models/PageModels/FormPageModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using UDS.Net.Forms.Models;
using UDS.Net.Forms.Models.UDS3;
using UDS.Net.Forms.Pages.UDS3;
using UDS.Net.Services.Enums;
using UDS.Net.Services;

namespace UDS.Net.Forms.Models.PageModels
Expand Down Expand Up @@ -67,7 +68,7 @@ protected async Task<IActionResult> OnPostAsync(int id)
{
var visit = Visit.ToEntity();

if (BaseForm.Status == Services.Enums.FormStatus.Complete)
if (BaseForm.Status == FormStatus.Complete || BaseForm.Status == FormStatus.NotIncluded)
{
/*
* ValidationContext describes any member on which validation is performed. It also enables
Expand Down
10 changes: 5 additions & 5 deletions src/UDS.Net.Forms/Models/UDS3/A1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public class A1 : FormModel
[Display(Name = "Other (specify)", Prompt = "Other origin")]
[MaxLength(60)]
[RequiredIf(nameof(HISPOR), "50", ErrorMessage = "Indicate other origin.")]
[SpecialCharacter]
[ProhibitedCharacters]
public string? HISPORX { get; set; }

/// <summary>
Expand All @@ -118,7 +118,7 @@ public class A1 : FormModel
[Display(Name = "Other (specify)", Prompt = "Other race")]
[MaxLength(60)]
[RequiredIf(nameof(RACE), "50", ErrorMessage = "Indicate other race.")]
[SpecialCharacter]
[ProhibitedCharacters]
public string? RACEX { get; set; }

/// <summary>
Expand All @@ -131,7 +131,7 @@ public class A1 : FormModel
[Display(Name = "Other (specify)", Prompt = "Other additional race")]
[MaxLength(60)]
[RequiredIf(nameof(RACESEC), "50", ErrorMessage = "Indicate other additional race.")]
[SpecialCharacter]
[ProhibitedCharacters]
public string? RACESECX { get; set; }

/// <summary>
Expand All @@ -144,7 +144,7 @@ public class A1 : FormModel
[Display(Name = "Other (specify)", Prompt = "Other additional race")]
[MaxLength(60)]
[RequiredIf(nameof(RACETER), "50", ErrorMessage = "Indicate other additional race.")]
[SpecialCharacter]
[ProhibitedCharacters]
public string? RACETERX { get; set; }

/// <summary>
Expand All @@ -157,7 +157,7 @@ public class A1 : FormModel
[Display(Name = "Other (specify)", Prompt = "Other primary language")]
[MaxLength(60)]
[RequiredIf(nameof(PRIMLANG), "50", ErrorMessage = "Indicate other language.")]
[SpecialCharacter]
[ProhibitedCharacters]
public string? PRIMLANX { get; set; }

/// <summary>
Expand Down
51 changes: 44 additions & 7 deletions src/UDS.Net.Forms/Models/UDS3/A2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Xml.Linq;
using UDS.Net.Forms.DataAnnotations;
using UDS.Net.Forms.TagHelpers;
using UDS.Net.Services.Enums;

namespace UDS.Net.Forms.Models.UDS3
{
Expand All @@ -22,71 +23,107 @@ public class A2 : FormModel
public int? INBIRYR { get; set; }

[Display(Name = "Co-participant's sex")]
[RequiredOnComplete(ErrorMessage = "Response required")]
public int? INSEX { get; set; }

[Display(Name = "Is this a new co-participant - i.e., one who was not a co-participant at any past UDS visit?")]
public int? NEWINF { get; set; }

[Display(Name = "Does the co-participant report being of Hispanic/Latino ethnicity  (i.e., having origins from a mainly Spanish-speaking Latin American country), regardless of race?")]
[RequiredIf(nameof(NEWINF), "1", ErrorMessage = "Does the co-participant report being of Hispanic/Latino ethnicity?")]
public int? INHISP { get; set; }

[Display(Name = "If yes, what are the co-participant's reported origins?")]
[RequiredIf(nameof(INHISP), "2", ErrorMessage = "What are the co-participant's reported origins?")]
public int? INHISPOR { get; set; }

[Display(Name = "Other (SPECIFY)")]
[MaxLength(60)]
[SpecialCharacter]
[ProhibitedCharacters]
[RequiredIf(nameof(INHISPOR), "50", ErrorMessage = "Indicate other additional origin")]
public string? INHISPOX { get; set; }

[Display(Name = "What does the co-participant report as his or her race?")]
[RequiredIf(nameof(NEWINF), "1", ErrorMessage = "Indicate co-participants race")]
public int? INRACE { get; set; }

[Display(Name = "Other (SPECIFY)")]
[MaxLength(60)]
[SpecialCharacter]
[RequiredIf(nameof(INRACE), "50", ErrorMessage = "Indicate other additional race")]
[ProhibitedCharacters]
public string? INRACEX { get; set; }

[Display(Name = "What additional race does the co-participant report?")]
[RequiredIf(nameof(NEWINF), "1", ErrorMessage = "Indicate additional race")]
public int? INRASEC { get; set; }

[Display(Name = "Other (SPECIFY)")]
[MaxLength(60)]
[SpecialCharacter]
[RequiredIf(nameof(INRASEC), "50", ErrorMessage = "Indicate other additional race")]
[ProhibitedCharacters]
public string? INRASECX { get; set; }

[Display(Name = "What additional race, beyond those reported in Questions 4 and 5, does the co-participant report?")]
[RequiredIf(nameof(NEWINF), "1", ErrorMessage = "Indicate additional race")]
public int? INRATER { get; set; }

[Display(Name = "Other (SPECIFY)")]
[MaxLength(60)]
[SpecialCharacter]
[RequiredIf(nameof(INRATER), "50", ErrorMessage = "Indicate other additional race")]
[ProhibitedCharacters]
public string? INRATERX { get; set; }

[Display(Name = "Co-participant's years of education — use the codes below to report the level achieved; if an attempted level is not completed, enter the number of years completed")]
[Range(0, 99, ErrorMessage = "Co-participants years of education must be within 0 and 99")]
[Display(Name = "Co-participant's years of education — use the codes below to report the level achieved; if an attempted level is not completed, enter the number of years completed" +
"<br /><br /> 12 = high school or GED<br /> 16 = bachelor's degree<br /> 18 = master's degree<br /> 20 = doctorate<br /> 99 = unknown")]
[RegularExpression(@"^(99|[0-9]|[1-2][0-9]|3[0-6])$", ErrorMessage = "Co-participants years of education must be within 0 and 36 or 99.")]
[RequiredIf(nameof(NEWINF), "1", ErrorMessage = "Indicate years of education")]
public int? INEDUC { get; set; }

[Display(Name = "What is the co-participant's relationship to the participant?")]
[RequiredOnComplete(ErrorMessage = "Response required")]
public int? INRELTO { get; set; }

[Display(Name = "How long has the co-participant known the participant?")]
[Range(0, 999, ErrorMessage = "Years known must be within 0 and 999")]
[RegularExpression(@"^(0|[1-9]\d?|120|999)$", ErrorMessage = "Years known must be within 0-120 or 999")]
[RequiredOnComplete(ErrorMessage = "Response required")]
public int? INKNOWN { get; set; }

[Display(Name = "Does the co-participant live with the subject?")]
[RequiredOnComplete(ErrorMessage = "Response required")]
public int? INLIVWTH { get; set; }

[Display(Name = "If no, approximate frequency of in-person visits?")]
[RequiredIf(nameof(INLIVWTH), "0", ErrorMessage = "Indicate frequency of visits")]
public int? INVISITS { get; set; }

[Display(Name = "If no, approximate frequency of telephone contact?")]
[RequiredIf(nameof(INLIVWTH), "0", ErrorMessage = "Indicate frequency of telephone calls")]
public int? INCALLS { get; set; }

[Display(Name = "Is there a question about the co-participant's reliability?")]
[RequiredOnComplete(ErrorMessage = "Response required")]
public int? INRELY { get; set; }

public override IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{

if (Status == FormStatus.Complete)
{
var visitValue = validationContext.Items.FirstOrDefault(v => v.Key.ToString() == "Visit").Value;
if (visitValue is VisitModel)
{
VisitModel visit = (VisitModel)visitValue;

if (visit != null)
{
if (visit.Kind == VisitKind.FVP || visit.Kind == VisitKind.TFP)
{
if (!NEWINF.HasValue)
yield return new ValidationResult("Response required", new[] { nameof(NEWINF) });
}
}
}
}
foreach (var result in base.Validate(validationContext))
{
yield return result;
Expand Down
12 changes: 6 additions & 6 deletions src/UDS.Net.Forms/Models/UDS3/A3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class A3 : FormModel
[Display(Name = "If Yes, Other (specify)")]
[MaxLength(60)]
[RequiredIf(nameof(FADMUT), "8", ErrorMessage = "Other predominant AD mutation must be specified.")]
[SpecialCharacter]
[ProhibitedCharacters]
public string? FADMUTX { get; set; }

[Display(Name = "Source of evidence for AD mutation")]
Expand All @@ -38,7 +38,7 @@ public class A3 : FormModel
[Display(Name = "If other, (specify)")]
[MaxLength(60)]
[RequiredIf(nameof(FADMUSO), "8", ErrorMessage = "Other source of evidence for AD mutation must be specified.")]
[SpecialCharacter]
[ProhibitedCharacters]
public string? FADMUSOX { get; set; }

[Display(Name = "In this family, is there evidence for an FTLD mutation? If Yes, select predominant mutation")]
Expand All @@ -48,7 +48,7 @@ public class A3 : FormModel
[Display(Name = "If Yes, Other (specify)")]
[MaxLength(60)]
[RequiredIf(nameof(FFTDMUT), "8", ErrorMessage = "Other predominant FTLD mutation must be specified.")]
[SpecialCharacter]
[ProhibitedCharacters]
public string? FFTDMUTX { get; set; }

[Display(Name = "Source of evidence for FTLD mutation")]
Expand All @@ -59,7 +59,7 @@ public class A3 : FormModel
[Display(Name = "If other, (specify)")]
[MaxLength(60)]
[RequiredIf(nameof(FFTDMUSO), "8", ErrorMessage = "Other source of evidence for FTLD mutation must be specified.")]
[SpecialCharacter]
[ProhibitedCharacters]
public string? FFTDMUSX { get; set; }

[Display(Name = "In this family, is there evidence for a mutation other than an AD or FTLD mutation?")]
Expand All @@ -69,7 +69,7 @@ public class A3 : FormModel
[Display(Name = "If Yes, specify")]
[MaxLength(60)]
[RequiredIf(nameof(FFTDMUSO), "1", ErrorMessage = "Specify other evidence for a mutation other than an AD or FTLD mutation.")]
[SpecialCharacter]
[ProhibitedCharacters]
public string? FOTHMUTX { get; set; }

[Display(Name = "Source of evidence for other mutation")]
Expand All @@ -79,7 +79,7 @@ public class A3 : FormModel
[Display(Name = "If other, specify")]
[MaxLength(60)]
[RequiredIf(nameof(FOTHMUSO), "8", ErrorMessage = "Other source of evidence required.")]
[SpecialCharacter]
[ProhibitedCharacters]
public string? FOTHMUSX { get; set; }

/// <summary>
Expand Down
10 changes: 5 additions & 5 deletions src/UDS.Net.Forms/Models/UDS3/A5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class A5 : FormModel
[MaxLength(60)]
[RequiredIf(nameof(CVOTHR), "1", ErrorMessage = "Specify cardiovascular disease")]
[RequiredIf(nameof(CVOTHR), "2", ErrorMessage = "Specify cardiovascular disease")]
[SpecialCharacter]
[ProhibitedCharacters]
public string? CVOTHRX { get; set; }

[Display(Name = "Stroke – by history, not exam (imaging is not required)")]
Expand Down Expand Up @@ -152,7 +152,7 @@ public class A5 : FormModel
[Display(Name = "Other (specify)")]
[RequiredIf(nameof(ARTHTYPE), "3", ErrorMessage = "Specify sleep disorder")]
[MaxLength(60)]
[SpecialCharacter]
[ProhibitedCharacters]
public string? ARTHTYPX { get; set; }

[Display(Name = "Upper extremity")]
Expand Down Expand Up @@ -190,7 +190,7 @@ public class A5 : FormModel
[MaxLength(60)]
[RequiredIf(nameof(OTHSLEEP), "1", ErrorMessage = "Specify sleep disorder")]
[RequiredIf(nameof(OTHSLEEP), "2", ErrorMessage = "Specify sleep disorder")]
[SpecialCharacter]
[ProhibitedCharacters]
public string? OTHSLEEX { get; set; }

[Display(Name = "Alcohol abuse: Clinically significant impairment occuring over a 12-month period manifested in one of the following areas: work, driving, legal, or social")]
Expand All @@ -204,7 +204,7 @@ public class A5 : FormModel
[MaxLength(60)]
[RequiredIf(nameof(ABUSOTHR), "1", ErrorMessage = "Specify abused substance")]
[RequiredIf(nameof(ABUSOTHR), "2", ErrorMessage = "Specify abused substance")]
[SpecialCharacter]
[ProhibitedCharacters]
public string? ABUSX { get; set; }

[Display(Name = "Post-traumatic stress disorder (PTSD)")]
Expand Down Expand Up @@ -239,7 +239,7 @@ public class A5 : FormModel
[MaxLength(60)]
[RequiredIf(nameof(PSYCDIS), "1", ErrorMessage = "Specify disorder")]
[RequiredIf(nameof(PSYCDIS), "2", ErrorMessage = "Specify disorder")]
[SpecialCharacter]
[ProhibitedCharacters]
public string? PSYCDISX { get; set; }

public override IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
Expand Down
2 changes: 1 addition & 1 deletion src/UDS.Net.Forms/Models/UDS3/B1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace UDS.Net.Forms.Models.UDS3
public class B1 : FormModel
{
[Display(Name = "Participant height (inches)")]
[RegularExpression("^(3[6-9].\\d|[4-7][0-9].\\d|8[0-7].\\d|88.8)$", ErrorMessage = "(36.0-87.9, 88.8 = not assessed)")]
[RegularExpression("^(3[6-9](.[0-9])?|[4-7][0-9](.[0-9])?|8[0-7](.[0-9])?|88.8)$", ErrorMessage = "(36.0-87.9, 88.8 = not assessed)")]
[RequiredOnComplete]
public double? HEIGHT { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion src/UDS.Net.Forms/Models/UDS3/B5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class B5 : FormModel
[Display(Name = "Other (specify)")]
[MaxLength(60)]
[RequiredIf(nameof(NPIQINF), "3", ErrorMessage = "Specify other co-participant")]
[SpecialCharacter]
[ProhibitedCharacters]
public string? NPIQINFX { get; set; }

[Display(Name = "Delusions - Does the patient have false beliefs, such as thinking that others are stealing from him/her or planning to harm him/her in some way?")]
Expand Down
2 changes: 1 addition & 1 deletion src/UDS.Net.Forms/Models/UDS3/B8.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public class B8 : FormModel
[Display(Name = "Yes (specify)")]
[MaxLength(60)]
[RequiredIf(nameof(OTHNEUR), "1", ErrorMessage = "Specify other findings")]
[SpecialCharacter]
[ProhibitedCharacters]
public string? OTHNEURX { get; set; }

public override IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
Expand Down
Loading

0 comments on commit 31bb74b

Please sign in to comment.