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

Support for validating resources before saving to local db #2853

Open
LZRS opened this issue Nov 8, 2023 · 8 comments · May be fixed by #2874
Open

Support for validating resources before saving to local db #2853

LZRS opened this issue Nov 8, 2023 · 8 comments · May be fixed by #2874
Assignees

Comments

@LZRS
Copy link
Contributor

LZRS commented Nov 8, 2023

Describe the feature request.
Add support for validating FHIR resources before getting saved to local DB to ensure that no invalid resources are saved. This would also help ensure that when sync to server, requests do not fail because of resource being invalid

Additional context
If available add any other context or screenshots about the feature here.

Acceptance criteria
A check list of all things to verify once the implementation by the engineer is complete

Area path
A list of ordered steps in the app on usage of the feature to support anyone testing it e.g. Code reviewer, QA e.g.

  1. Login to the app
  2. Open Navigation bar
  3. Click on Children register
  4. Click on Child profile
  5. Click on Edit profile from menu

Implementation plan (For Engineers)
The plan for implementing the solution e.g. via a description or a check list for the various ordered tasks that will need to be completed.
i.e. Describe how you intend to solve the problem

@LZRS LZRS self-assigned this Nov 8, 2023
@dubdabasoduba
Copy link
Member

@pld I think this would be a good addition to the FHIR Core app too. We can make it configurable with an opt out capability.

@pld
Copy link
Member

pld commented Nov 8, 2023

kinda agree! but.. what happens if they are invalid? once someones trying to store a resource we wouldn't want to not persist it, I guess in theory we could redo the extraction after the config has been updated, like you could mark the QR as extraction pending or something.

But I feel like the more impactful place for effort would be on validating structuremaps to ensure they are only producing valid resources as outputs

@ndegwamartin
Copy link
Contributor

Suppose we had a variant of this that only makes this type of validation check mandatory for Debug mode. That way during development it is easier for engineers to catch such early on. This can be in place regardless of the conclusion we make for this ticket.

@dubdabasoduba
Copy link
Member

@ndegwamartin I agree this is more for the development stage and not necessary for use in production. The assumption here is that all SMs and CQL would generate correctly formatted resources by the time an app goes live

@dubdabasoduba
Copy link
Member

@LZRS how far are we with this? cc @ndegwamartin

@LZRS
Copy link
Contributor Author

LZRS commented Feb 6, 2024

@LZRS how far are we with this? cc @ndegwamartin

With this PR the validation of resources for debug, before saving to db, was added but ran into issues to do with dependency incompatibilities for the caffeine library that was causing the app to crash whenever a validation happened

Replacing the caffeine library caching with guava, using the latest engine sdk artifacts, fixes the issue but it means work on validation essentially depends on the work/merge of #2825

The validation checks that the FHIR resources conform to the defined structure, references match the expected types (that is, without checking if they refer to non-existing resources) and that code systems used are known (although, for now, marked as just warnings). Failed validations are logged to logcat, and questionnaire submission fails to succeed until all validations pass (while in debug)

Pending enhancement, would be to allow skipping to submission anyways, as some errors of validations could be treated with leniency

@pld
Copy link
Member

pld commented Feb 6, 2024

@LZRS can we show the user the failed validation directly on the screen in a way they can copy it? the users of debug will be testers on our and other teams so their workflow will be

  1. submit form
  2. get error
  3. copy error data into new issue

I think your suggestion is brings up a very good point. If the tester hits a non-critical error, we don't want them to be unable to continue testing until that non-critical error is resolved. How about we show the error in a very big clear way so the tester knows to create an issue, but we continue with the submission so that they can continue testing the workflow.

@LZRS
Copy link
Contributor Author

LZRS commented Feb 12, 2024

Yeah, makes sense. I will be looking into maybe showing the errors in a dialog just before continuing with submission. The dialog would allow the users to copy the errors and also probably have an extra button to either allow to share the errors (maybe to slack, github or email) or do background submission of the errors to sentry, email or even github

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 a pull request may close this issue.

5 participants