Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Personal/rogrdon/create common validation logic #152

Merged
merged 7 commits into from
Dec 20, 2021

Conversation

rogordon01
Copy link
Contributor

This Pr creates a new package which will hold logic that validates IotConnector template files. In addition it allows sample device data to be executed against template files in order to capture errors/warnings.

@rogordon01 rogordon01 requested a review from a team as a code owner December 17, 2021 20:28
src/lib/Microsoft.Health.Fhir.Ingest.Validation/IResult.cs Outdated Show resolved Hide resolved
{
if (string.IsNullOrWhiteSpace(deviceMappingContent) && string.IsNullOrWhiteSpace(fhirMappingContent))
{
throw new ArgumentException($"At least one of [{nameof(deviceMappingContent)}] or [{nameof(fhirMappingContent)}] must be provided");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just return a ValidationResult here? I think It would be useful if this interface could be relied on to always return a Validation result so the consumer wouldn't need to wrap this in a Try/Catch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had debated about that. I leaned towards this not actually being a validation error, but an actual error with the use of the class and its arguments. We are still verifying arguments here so validation hasn't really begun. It felt strange to add such an error inside of the ValidationResult.

That's just my opinion though. I can merge what I have and change it in a subsequent PR if need be.

IContentTemplate contentTemplate = null;
ILookupTemplate<IFhirTemplate> fhirTemplate = null;

if (!string.IsNullOrEmpty(deviceMappingContent))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check and the one below are redundant based on the check above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above check ensures that at least one of the mapping templates are provided. It's still acceptable to provide a single template and leave the other null. For example, if a user is creating a new IotConnector they most likely start with the Device Template. In that case they won't have a FhirTemplate to validate. So we need the checks here to determine which ones are provided.

var fhirTemplateValues = new List<FhirValueType>();
fhirTemplateValues.Add(matchingFhirTemplate.Value);

if (matchingFhirTemplate.Components != null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that matchingFhirTemplate.Components and matchingFhirTemplate.Value are mutually exclusive. An example of this would be blood pressure. We would have the 2 components for diastolic and systolic, but there would be no value at the root.

@rogordon01 rogordon01 merged commit 64d7be5 into master Dec 20, 2021
@rogordon01 rogordon01 deleted the personal/rogrdon/createCommonValidationLogic branch December 20, 2021 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants