From 9c08610b069a8764242ca7cba389f1ede86cd1ee Mon Sep 17 00:00:00 2001 From: Stephen Nielson Date: Mon, 27 Jun 2022 13:01:12 -0600 Subject: [PATCH] Fixes #5563 ccda provenance timezones (#5564) * Fixes #5563 ccda provenance timezones Fix the timezone offset to handle locale settings. Fix the lab results provenance timestamp to have timezone settings. * Handle missing doc type, tighten up addresses Tightened up the addresses on the display, don't show episodic care elements when missing doc type (IE default to ccd). --- .../oe-blue-button-generate/lib/translate.js | 6 +++- ccdaservice/serveccda.js | 37 ++++++++++++++++++++-- .../Model/CcdaServiceRequestModelGenerator.php | 1 + interface/modules/zend_modules/public/xsl/cda.xsl | 5 +-- 4 files changed, 41 insertions(+), 8 deletions(-) diff --git a/ccdaservice/oe-blue-button-generate/lib/translate.js b/ccdaservice/oe-blue-button-generate/lib/translate.js index 886f43ed2..bba3cb3e9 100644 --- a/ccdaservice/oe-blue-button-generate/lib/translate.js +++ b/ccdaservice/oe-blue-button-generate/lib/translate.js @@ -83,7 +83,11 @@ exports.time = function (input) { let formatSpec = precisionToFormat[input.precision]; if (input.precision === 'tz') { formatSpec = precisionToFormat['tz']; - result = m.utcOffset('-0400').format(formatSpec); + if (input.timezoneOffset) { + result = m.utcOffset(input.timezoneOffset).format(formatSpec); + } else { + result = m.format(formatSpec); + } return result; } result = m.format(formatSpec); diff --git a/ccdaservice/serveccda.js b/ccdaservice/serveccda.js index 249806f93..9ed3f1a71 100644 --- a/ccdaservice/serveccda.js +++ b/ccdaservice/serveccda.js @@ -39,6 +39,28 @@ function cleanText(s) { return s; } +// do a recursive descent transformation of the node object populating the timezone offset value if we have +// a precision property (inside a date) with the value of timezone. +function populateTimezones(node, tzOffset, depthCheck) { + if (!node || typeof node !== 'object') { + return node; + } + // we should NEVER go farther than 25 recursive loops down in our heirarchy, if we do it means we have an infinite loop + if (depthCheck > 25) { + console.error("Max depth traversal reached. Potential infinite loop. Breaking out of loop") + return node; + } + + if (node.hasOwnProperty('precision') && node.precision == 'tz' && !node.hasOwnProperty('timezoneOffset')) { + node.timezoneOffset = tzOffset; + } else { + for (const [key, value] of Object.entries(node)) { + node[key] = populateTimezones(value, tzOffset, depthCheck + 1); + } + } + return node; +} + function fDate(str, lim8 = false) { str = String(str); if (lim8) { @@ -1201,8 +1223,8 @@ function getResultSet(results) { { "date_time": { "point": { - "date": fDate(tResult.date_ordered), - "precision": getPrecision(fDate(tResult.date_ordered)) + "date": fDate(authorDateTime), + "precision": "tz" } }, "identifiers": [ @@ -2362,12 +2384,16 @@ function populateParticipant(participant) { function populateHeader(pd) { // default doc type ToC CCD let name = "Summarization of Episode Note"; + let isEpisodicDocumentType = false; let docCode = "34133-9"; let docOid = "2.16.840.1.113883.10.20.22.1.2"; if (pd.doc_type == 'referral') { name = "Referral Note"; docCode = "57133-1"; docOid = "2.16.840.1.113883.10.20.22.1.14"; + isEpisodicDocumentType = true; + } else if (pd.doc_type == 'careplan') { + isEpisodicDocumentType = true; } const head = { @@ -2527,7 +2553,8 @@ function populateHeader(pd) { } - if (isOne(all.encounter_list.encounter) === 1) { + if (isEpisodicDocumentType + && isOne(all.encounter_list.encounter) === 1) { head.component_of = { "identifiers": [ { @@ -3021,6 +3048,10 @@ function genCcda(pd) { meta.ccda_header = Object.assign(header); doc.meta = Object.assign(meta); + + if (pd.timezone_local_offset) { + populateTimezones(doc, pd.timezone_local_offset, 0); + } // build to cda let xml = bbg.generateCCD(doc); diff --git a/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Model/CcdaServiceRequestModelGenerator.php b/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Model/CcdaServiceRequestModelGenerator.php index e47fa654a..8aecc8886 100644 --- a/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Model/CcdaServiceRequestModelGenerator.php +++ b/interface/modules/zend_modules/module/Carecoordination/src/Carecoordination/Model/CcdaServiceRequestModelGenerator.php @@ -139,6 +139,7 @@ class CcdaServiceRequestModelGenerator $this->data .= ""; $this->data .= "" . date('YmdHis') . ""; $this->data .= "" . date('YmdHisO') . ""; + $this->data .= "" . date('O') . ""; $this->data .= "" . htmlspecialchars($send, ENT_QUOTES) . ""; $this->data .= "" . $document_type . ""; $this->data .= " diff --git a/interface/modules/zend_modules/public/xsl/cda.xsl b/interface/modules/zend_modules/public/xsl/cda.xsl index 02d456c8c..d304bfde1 100644 --- a/interface/modules/zend_modules/public/xsl/cda.xsl +++ b/interface/modules/zend_modules/public/xsl/cda.xsl @@ -2005,8 +2005,6 @@ limitations under the License. -

-

@@ -2014,10 +2012,9 @@ limitations under the License. -

-

+ -- 2.11.4.GIT