CDR Tickets

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
Description

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).

Comment entered 2018-10-05 18:49:04 by Englisch, Volker (NIH/NCI) [C]

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.

Comment entered 2018-10-18 14:16:36 by Kline, Bob (NIH/NCI) [C]

Look at the code with Bob.

Comment entered 2018-10-18 14:46:55 by Kline, Bob (NIH/NCI) [C]
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]
Comment entered 2019-06-17 15:32:20 by Englisch, Volker (NIH/NCI) [C]

This change has been implemented on DEV and is ready for review.

Local branch: [cdr4528-valid-zip 7177e8d]

Comment entered 2019-06-18 14:53:55 by Osei-Poku, William (NIH/NCI) [C]

Verified on DEV. Thank you!

Comment entered 2019-06-18 17:49:56 by Englisch, Volker (NIH/NCI) [C]

The changes have been merged into our Joule branch.
https://github.com/NCIOCPL/cdr-lib/commit/7177e8d

Comment entered 2019-08-05 14:25:23 by Osei-Poku, William (NIH/NCI) [C]

Verified on QA. Thanks!

Comment entered 2019-09-06 21:39:42 by Osei-Poku, William (NIH/NCI) [C]

Verified on PROD. Thanks!

Elapsed: 0:00:00.001415