Issue Number | 4528 |
---|---|
Summary | Zip code extension causes documents to fail schema validation |
Created | 2018-09-20 13:28:18 |
Issue Type | Bug |
Submitted By | Osei-Poku, William (NIH/NCI) [C] |
Assigned To | Englisch, Volker (NIH/NCI) [C] |
Status | Closed |
Resolved | 2019-06-17 15:32:33 |
Resolution | Fixed |
Path | /home/bkline/backups/jira/ocecdr/issue.233379 |
When a zip code has an extension, the document fails schema
validation. The document only validates after removing the extension.
This is happening on PROD and I did test on QA and got the same
results.
Sample documents:
664545
793606 (test document).
The ZIP code validation is handed over by the schema to the function
cdrutil:/valid-zip() which is part of the CDR API if I'm
following the path correctly. This function checks the ZIP code that is
passed against the DB table. If this ZIP code isn't 5 characters long,
the validation will fail.
In the old - pre API - system, the 5 character sub-string of the passed
ZIP code had been used to validate the code regardless if it was 5 or
5+4 characters.
I will discuss these findings with Bob when he comes back and identify
how to make the necessary changes.
For my information:
valid-zip() is part of cdrapi/docs.py.
Look at the code with Bob.
diff --git a/Python/cdrapi/docs.py b/Python/cdrapi/docs.py
index f01ca30..5932f16 100644--- a/Python/cdrapi/docs.py
+++ b/Python/cdrapi/docs.py
@@ -4498,7 +4498,7 @@ class Resolver(etree.Resolver):
result = etree.Element("ValidZip")
query = Query("zipcode", "zip")- query.where(query.Condition("zip", args))
+ query.where(query.Condition("zip", args[:5]))
row = query.execute(self.cursor).fetchone()
if row and row.zip: result.text = str(row.zip)[:5]
This change has been implemented on DEV and is ready for review.
Local branch: [cdr4528-valid-zip 7177e8d]
Verified on DEV. Thank you!
The changes have been merged into our Joule branch.
https://github.com/NCIOCPL/cdr-lib/commit/7177e8d
Verified on QA. Thanks!
Verified on PROD. Thanks!
Elapsed: 0:00:00.001415