Skip to content
This repository has been archived by the owner on Jun 30, 2023. It is now read-only.

Pre release v3.0.0 beta.4 #10

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
189e9b8
Updates version
ashleybot May 18, 2022
49d3e7e
Add value 9 check to the subjectfamilyhistory form
mlan225 May 24, 2022
c71df98
Merge in D1 details view
mlan225 Jun 3, 2022
121498a
Apply an additional validation check to primaryDx value of 999
mlan225 Jun 17, 2022
e8b0892
Fixes conditional logic and validation for sub-questions in section 3…
ashleybot Jul 20, 2022
e25ad8a
Fixes validation for C2 question 12
ashleybot Jul 20, 2022
851e069
update question 11 "unknown" value from 5 to 99
mlan225 Jul 20, 2022
adb2ca8
Clearly delineates section 3 behavior for normal vs impaired cognitiv…
ashleybot Jul 22, 2022
c7b2933
Fixes bug with validation on question 6k and specification details
ashleybot Jul 26, 2022
65cad04
Updates to NACC variables and adjusts spelling
esoteric-acolyte Jul 27, 2022
19ee893
Add logic for null check for property on a3
mlan225 Jul 27, 2022
1e2fe81
Fixes validation
ashleybot Jul 27, 2022
e4b3326
Fixes validaiton
ashleybot Jul 27, 2022
7bb6a94
Includes custom data annotations and fixes bug in D1 Section 3 valida…
ashleybot Jul 28, 2022
1cf8434
Adds cascading disable for A1 and A2 forms
esoteric-acolyte Aug 3, 2022
bfb0061
Update standard global cdr to be required, also auto-calculates cdr
esoteric-acolyte Aug 3, 2022
837f7b7
Add additional conditions to b8 and fix front end bug
mlan225 Aug 3, 2022
a11563c
Create custom attribute and add additional attributes to props
mlan225 Aug 4, 2022
51f3c2b
Add radio options and additional previous value check
mlan225 Aug 4, 2022
f2d27be
Add option for unknown for number of siblings and additional validation
mlan225 Aug 4, 2022
496a67e
Add range validation to a3 and include b8 adjustments
mlan225 Aug 9, 2022
757695b
Updates the A5 QuitSmoking field to include 110
esoteric-acolyte Aug 9, 2022
41790a0
Adjust the range of PredominantSymptoms to include 0
mlan225 Aug 9, 2022
82ae49f
Fixes A1 and A2 radio disables for race, and adds valid classes and f…
esoteric-acolyte Aug 15, 2022
c370ec2
Remove duplicated code in b8 check
mlan225 Aug 19, 2022
8bfd162
Adjust previous value logic on b9
mlan225 Aug 19, 2022
2113133
Adds trail making test score validation
esoteric-acolyte Aug 22, 2022
61bc5b2
Add c2 delayed recall validation
mlan225 Aug 24, 2022
fac928c
Auto calculate B6 geriatric depression score
esoteric-acolyte Sep 12, 2022
5df9713
Update the b8 form to allow No (0) input in subquestions
mlan225 Nov 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions src/UDS.Net.Data/DataAnnotations/CurrentYearRangeAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace UDS.Net.Data.DataAnnotations
{
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class CurrentYearRangeAttribute : ValidationAttribute
{
private string PropertyName { get; set; }
private int YearMin;
private int YearMax;
private int YearUnknown;

/// <summary>
/// Property when condition asserts true.
/// </summary>
/// <param name="propertyName"></param>
/// <param name="assertion"></param>
public CurrentYearRangeAttribute(string propertyName, int yearMin, int yearUnknown)
{
PropertyName = propertyName;
YearMin = yearMin;
YearMax = DateTime.Now.Year;
YearUnknown = yearUnknown;
}

public CurrentYearRangeAttribute(string ErrorMessage)
{
this.ErrorMessage = ErrorMessage;
}

protected override ValidationResult IsValid(object propertyValue, ValidationContext propertyToValidate)
{
var instance = propertyToValidate.ObjectInstance;
var instanceType = instance.GetType();
if(propertyValue is null)
{
return ValidationResult.Success;
}

int? value = (int)propertyValue;


var formStatus = instanceType.GetProperty("FormStatus");
if (formStatus != null)
{
var formStatusValue = formStatus.GetValue(instance, null);
if (formStatusValue.ToString() != "Complete")
{
return ValidationResult.Success;
}
}

if (value >= 0)
{
if(value >= YearMin && value <= YearMax) return ValidationResult.Success;

if(value == YearUnknown) return ValidationResult.Success;

} else {
//the value was null, but the a3 form must allow null valid date inputs
return ValidationResult.Success;
}

//Year was not matched with conditions and is not valid
return new ValidationResult(ErrorMessage);
}
}
}

68 changes: 68 additions & 0 deletions src/UDS.Net.Data/DataAnnotations/InvalidRangeAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace UDS.Net.Data.DataAnnotations
{
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class InvalidRangeAttribute : ValidationAttribute
{
private string PropertyName { get; set; }
private int InvalidRangeMin;
private int InvalidRangeMax;

/// <summary>
/// Property when condition asserts true.
/// </summary>
/// <param name="propertyName"></param>
/// <param name="assertion"></param>
public InvalidRangeAttribute(string propertyName, int invalidRangeMin, int invalidRangeMax, string errorMessage = "")
{
PropertyName = propertyName;
InvalidRangeMax = invalidRangeMax;
InvalidRangeMin = invalidRangeMin;
}

public InvalidRangeAttribute(string ErrorMessage)
{
this.ErrorMessage = ErrorMessage;
}

protected override ValidationResult IsValid(object value, ValidationContext context)
{
var instance = context.ObjectInstance;
var type = instance.GetType();

var propertyValue = type.GetProperty(PropertyName).GetValue(instance);

var formStatus = type.GetProperty("FormStatus");
if (formStatus != null)
{
var formStatusValue = formStatus.GetValue(instance, null);
if (formStatusValue.ToString() != "Complete")
{
return ValidationResult.Success; // if the annotation is on a form and it is not being completed, don't run validation
}
}

var invalidMinValue = InvalidRangeMin;
var invalidMaxValue = InvalidRangeMax;

if (propertyValue != null) // we're allowing nulls in some cases, so the watched property won't always have a value
{
while (invalidMinValue <= invalidMaxValue)
{
if (propertyValue.ToString() == invalidMinValue.ToString() || value == null)
{
return new ValidationResult(ErrorMessage);
}

invalidMinValue++;
}
}

return ValidationResult.Success;
}
}
}

60 changes: 60 additions & 0 deletions src/UDS.Net.Data/DataAnnotations/RequiredIfAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace UDS.Net.Data.DataAnnotations
{
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class RequiredIfAttribute : ValidationAttribute
{
private string PropertyName { get; set; }
private object AssertionValue { get; set; }

/// <summary>
/// Property when condition asserts true.
/// </summary>
/// <param name="propertyName"></param>
/// <param name="assertion"></param>
public RequiredIfAttribute(string propertyName, object assertion, string errorMessage = "")
{
PropertyName = propertyName;
AssertionValue = assertion;
ErrorMessage = errorMessage;
}

public RequiredIfAttribute(string ErrorMessage)
{
this.ErrorMessage = ErrorMessage;
}

protected override ValidationResult IsValid(object value, ValidationContext context)
{
var instance = context.ObjectInstance;
var type = instance.GetType();

var propertyValue = type.GetProperty(PropertyName).GetValue(instance, null);

var formStatus = type.GetProperty("FormStatus");
if (formStatus != null)
{
var formStatusValue = formStatus.GetValue(instance, null);
if (formStatusValue.ToString() != "Complete")
{
return ValidationResult.Success; // if the annotation is on a form and it is not being completed, don't run validation
}
}

if (propertyValue != null) // we're allowing nulls in some cases, so the watched property won't always have a value
{
if (propertyValue.ToString() == AssertionValue.ToString() && value == null)
{
return new ValidationResult(ErrorMessage);
}
}

return ValidationResult.Success;
}

}
}

77 changes: 77 additions & 0 deletions src/UDS.Net.Data/DataAnnotations/RequiredIfImpairedAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace UDS.Net.Data.DataAnnotations
{
/// <summary>
/// This annotation was made specifically for handling special cases in
/// ClinicianDiagnosis.
/// </summary>
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class RequiredIfImpairedAttribute : ValidationAttribute
{
private string PropertyName { get; set; }
private object AssertionValue { get; set; }

/// <summary>
/// Property when condition asserts true.
/// </summary>
/// <param name="propertyName"></param>
/// <param name="assertion"></param>
public RequiredIfImpairedAttribute(string propertyName, object assertion, string errorMessage = "")
{
PropertyName = propertyName;
AssertionValue = assertion;
ErrorMessage = errorMessage;
}

public RequiredIfImpairedAttribute(string ErrorMessage)
{
this.ErrorMessage = ErrorMessage;
}

protected override ValidationResult IsValid(object value, ValidationContext context)
{
var instance = context.ObjectInstance;
var type = instance.GetType();

var propertyValue = type.GetProperty(PropertyName).GetValue(instance, null);

var formStatus = type.GetProperty("FormStatus");
var hasNormalCognition = type.GetProperty("HasNormalCognition");
if (formStatus != null && hasNormalCognition != null)
{
var formStatusValue = formStatus.GetValue(instance, null);
var hasNormalCognitionValue = hasNormalCognition.GetValue(instance, null);
if (formStatusValue.ToString() != "Complete")
{
return ValidationResult.Success; // if the annotation is on a form and it is not being completed, don't run validation
}
else
{
// form status is complete
string test = hasNormalCognitionValue.ToString();
if (hasNormalCognitionValue.ToString() == "True")
{
// cognition is normal (not impaired), so don't require
return ValidationResult.Success;
}
}
}

if (propertyValue != null) // we're allowing nulls in some cases, so the watched property won't always have a value
{
if (propertyValue.ToString() == AssertionValue.ToString() && value == null)
{
return new ValidationResult(ErrorMessage);
}
}

return ValidationResult.Success;
}

}
}


70 changes: 70 additions & 0 deletions src/UDS.Net.Data/DataAnnotations/RequiredIfRangeAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace UDS.Net.Data.DataAnnotations
{
[AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
public class RequiredIfRangeAttribute : ValidationAttribute
{
private string PropertyName { get; set; }
private int StartAssertionValue;
private int EndAssertionValue;

/// <summary>
/// Property when condition asserts true.
/// </summary>
/// <param name="propertyName"></param>
/// <param name="assertion"></param>
public RequiredIfRangeAttribute(string propertyName, int startAssertionValue, int endAssertionValue, string errorMessage = "")
{
PropertyName = propertyName;
StartAssertionValue = startAssertionValue;
EndAssertionValue = endAssertionValue;
ErrorMessage = errorMessage;
}

public RequiredIfRangeAttribute(string ErrorMessage)
{
this.ErrorMessage = ErrorMessage;
}

protected override ValidationResult IsValid(object value, ValidationContext context)
{
var instance = context.ObjectInstance;
var type = instance.GetType();

var propertyValue = type.GetProperty(PropertyName).GetValue(instance, null);

var formStatus = type.GetProperty("FormStatus");
if (formStatus != null)
{
var formStatusValue = formStatus.GetValue(instance, null);
if (formStatusValue.ToString() != "Complete")
{
return ValidationResult.Success; // if the annotation is on a form and it is not being completed, don't run validation
}
}

var startValue = StartAssertionValue;
var endValue = EndAssertionValue;

if (propertyValue != null) // we're allowing nulls in some cases, so the watched property won't always have a value
{
while (startValue <= endValue)
{
if (propertyValue.ToString() == startValue.ToString() && value == null)
{
return new ValidationResult(ErrorMessage);
}

startValue++;
}
}

return ValidationResult.Success;
}

}
}

10 changes: 10 additions & 0 deletions src/UDS.Net.Data/Dtos/PreviousValueDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;

namespace UDS.Net.Data.Dtos
{
public class PreviousValueDto
{
public string Name { get; set; }
public string Text { get; set; }
}
}
2 changes: 1 addition & 1 deletion src/UDS.Net.Data/Entities/A1_ParticipantDemographics.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using COA.Components.Web.DataAnnotations;
using UDS.Net.Data.DataAnnotations;
using Microsoft.EntityFrameworkCore;
using UDS.Net.Data.Enums;

Expand Down
2 changes: 1 addition & 1 deletion src/UDS.Net.Data/Entities/A2_CoParticipantDemographics.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using COA.Components.Web.DataAnnotations;
using UDS.Net.Data.DataAnnotations;
using Microsoft.EntityFrameworkCore;
using UDS.Net.Data.Enums;

Expand Down
Loading