-
Notifications
You must be signed in to change notification settings - Fork 6
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
Refactor and restructure validation functions. #63
Open
mint-thompson
wants to merge
11
commits into
main
Choose a base branch
from
overhaul
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The current state of this branch is a work-in-progress: lots of incomplete implementations and tests. Use this branch to work towards a complete implementation of the refactored validator classes.
Fix OBOB for code count. Add tests for incorrect use of code columns. Start filling out tests for validateRow tall Adding "normalized columns" so that we can easily find the location of elements, but keep the original formatting for message purposes. Define some of the tests for validating a row in tall mode. Fields tested are description, setting, and the drug information fields. Add tests for code pairs and non-payer specific charges add tests for payer specific negotiated charge Add "other" methodology conditional Still messing around a bit with types and the structure of the validation tree. Add tests for requiring at least one charge I'm starting to feel uneasy about some of these implementations. Might try to change up how they go so I have less actual logic in the predicate functions. Change up validation types and partial function application Individual validation functions are redefined so that the arguments are listed in a useful order for binding. This means that when actually validating the row, the only values to pass in are the data object and the row index. Add tests for dollar amount requiring min and max Remove reset method, since it's really just for convenience, and it doesn't actually make things that much more convenient.
Add tests for modifier-only rows. Add tests for requiring estimated allowed amount when payer-specific percentage or algorithm, but not dollar amount, are present. Add tests for requiring drug information when NDC code type is used.
Add tests for payer specific negotiated charge conditional. Add tests for "other" methodology conditional. Add tests for requiring at least one charge.
Add tests for payer-specific dollar amount requiring a min and max. Add tests for modifier row additional information. Add tests for requiring an estimated allowed amount for a percentage or algorithm. Add tests for requiring drug information when code type is NDC.
Build row validators after rows are determined. Add list of available versions to InvalidVersionError.
Tests that depend on a specific version of the requirements are split into separate files, since the main test file was growing too large. For pre-v2.2.0 versions, there are no modifier rows. Therefore, code information is always required.
Many constants are moved around so that there's fewer total definitions in the CsvValidator file. Bind the CsvValidator instance to the data callback so that the function will have access to any other properties it needs. Fill out todo tests for JsonValidator. Make JsonValidator's schema properties public, both for testing and because it might be useful to be able to modify them in an inherited class. Delete some unused constants and types.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a large restructuring of the CSV and JSON validation logic into two new classes:
JsonValidator
andCsvValidator
. These classes replace the previously defined types in order to facilitate reuse and extension.The main change to JSON validation is the use of schemas defined in files. Previously, the schemas were defined as variables in the code. This means there are some new preparatory steps to get the subschemas out of the main schema. But, the overall implementation, where the metadata is checked last, is the same.
CSV validation is now significantly different. It still makes use of some helper functions for typical types of checks (required values, enums, etc.), but instead of an explicit function definition for validating rows, the validation checks are created by binding some variables to base validation functions, then adding those checks to a tree. This allows for sets of checks to occur conditionally based on the results of other checks or defined predicates. It also allows for the set of checks to vary depending on the version option. Errors now exist as specific error classes, which allows for easier analysis or modification by code that uses this module.
The current implementation removes the previous concept of the warning flag for validation errors. Instead, the expectation is that validation is performed against a specific version of the requirements without regard for any future requirements. This allows for easier analysis of files published before certain requirements took effect.
The jest module is now used for tests. The previous set of tests are rewritten, and there are some new tests specific to the new implementation.
While reviewing these changes, please keep in mind the organization of constants, functions, and classes. I tried to get things organized reasonably well, but I may not have moved everything to the right places.