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

1350 adds logs ihe #1772

Draft
wants to merge 12 commits into
base: develop
Choose a base branch
from
Next Next commit
fix(ihe): xcdp and xca dq
  • Loading branch information
Orta21 committed Mar 12, 2024
commit 6419b73781b616a8611fc95ceee927828e4bb57e
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var json = null, error = null;
// HTTP 400 Bad Request - by default, the server cannot or will not process the request
channelMap.put("responseCode", "400");

var baseLogMessage = "XCA DQ Bulk Interface: Transformer (Step0) - ";

// Destination is not needed
destinationSet.removeAll();
Expand All @@ -11,6 +12,7 @@ destinationSet.removeAll();
// Decode and parse incoming JSON request
json = getBase64Content(msg, 'json');

logger.info(baseLogMessage + 'response: ' + JSON.stringify(json));

// Validate request
if ('string' == typeof json) {
Expand All @@ -29,5 +31,6 @@ if ('string' == typeof json) {
// Cease processing in case of an error
if (error) {
channelMap.put('NOTE', error);
logger.error(baseLogMessage + 'err: ' + error);
throw error;
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
var totalCount = 0;

var baseLogMessage = "XCA DQ Bulk Interface: Transformer (Step1) - ";

// Loop through all request entries
if (json) {
json.forEach(function(entry) {

var entryLogMessage = baseLogMessage + 'requestId: ' + entry.id.toString() + ', cxId: ' + entry.cxId.toString() + ' - ';

totalCount++;
var errorCount = 0;

Expand All @@ -20,16 +24,17 @@ if (json) {
}

} catch(ex) {
if (globalMap.containsKey('TEST_MODE')) logger.error('XCA ITI-38 Bulk Interface: Source - ' + ex);
logger.error(entryLogMessage + 'error: ' + ex);
errorCount++;
}

// Pass to the XCPD Interface channel to process
if (0 == errorCount) {

logger.info(entryLogMessage + 'entry: ' + JSON.stringify(entry));
var result = router.routeMessageByChannelId(globalMap.get('XCAITI38INTERFACE'), JSON.stringify(entry, null, 2));

} else {
logger.error(entryLogMessage + 'error: ' + errorCount.toString() + ' error(s) is/are found in the entries');
channelMap.put("responseCode", "400");
channelMap.put('NOTE', 'ERROR - ' + errorCount.toString() + ' error(s) is/are found in the entries');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var json = null, error = null;
// HTTP 400 Bad Request - by default, the server cannot or will not process the request
channelMap.put("responseCode", "400");

var baseLogMessage = "XCA DR Bulk Interface: Transformer (Step0) - ";

// Destination is not needed
destinationSet.removeAll();
Expand All @@ -11,6 +12,8 @@ destinationSet.removeAll();
// Decode and parse incoming JSON request
json = getBase64Content(msg, 'json');

logger.info(baseLogMessage + 'response: ' + JSON.stringify(json));


// Validate request
if ('string' == typeof json) {
Expand All @@ -29,5 +32,6 @@ if ('string' == typeof json) {
// Cease processing in case of an error
if (error) {
channelMap.put('NOTE', error);
logger.error(baseLogMessage + 'err: ' + error);
throw error;
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
var totalCount = 0,
var totalCount = 0,
processedCount = 0;

var baseLogMessage = "XCA DR Bulk Interface: Transformer (Step1) - ";

// Loop through all request entries
if (json) {
json.forEach(function(entry) {

var entryLogMessage = baseLogMessage + 'requestId: ' + entry.id.toString() + ', cxId: ' + entry.cxId.toString() + ' - ';

totalCount++;
var errorCount = 0;

// Check for required parameters
try {

if (!entry.hasOwnProperty('gateway')) {
errorCount++
} else if (!entry.hasOwnProperty('samlAttributes') || 0 == entry.samlAttributes.length) {
Expand All @@ -20,16 +24,17 @@ if (json) {
}

} catch(ex) {
if (globalMap.containsKey('TEST_MODE')) logger.error('XCA ITI-39 Bulk Interface: Source - ' + ex);
logger.error(entryLogMessage + 'error: ' + ex);
errorCount++;
}

// Pass to the XCPD Interface channel to process
if (0 == errorCount) {

logger.info(entryLogMessage + 'entry: ' + JSON.stringify(entry));
var result = router.routeMessageByChannelId($g('XCAITI39Interface'), JSON.stringify(entry, null, 2));

} else {
logger.error(entryLogMessage + 'error: ' + errorCount.toString() + ' error(s) is/are found in the entries');
channelMap.put("responseCode", "400");
channelMap.put('NOTE', 'ERROR - ' + errorCount.toString() + ' error(s) is/are found in the entries');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@ var json = null, error = null;
// HTTP 400 Bad Request - by default, the server cannot or will not process the request
channelMap.put("responseCode", "400");

var baseLogMessage = "XCA Interface: Transformer (Step0) - ";

// Decode and parse incoming JSON request if sent over HTTP
if (msg.toString().startsWith('<HttpRequest>')) {
json = getBase64Content(msg, 'json');

logger.info(baseLogMessage + 'response: ' + JSON.stringify(json));
} else try {

// Parse JSON request if routed from the XCPD Bulk Interface channel
json = JSON.parse(msg.toString());

} catch(ex) {
if (globalMap.containsKey('TEST_MODE')) logger.error('XCA ITI-38 Interface: Source - ' + ex);
logger.error(baseLogMessage + 'error: ' + ex);
error = 'ERROR - ' + ex;
}

Expand All @@ -41,7 +43,7 @@ if ('string' == typeof json) {
}

} catch(ex) {
if (globalMap.containsKey('TEST_MODE')) logger.error('XCA ITI-38 Interface: Source - ' + ex);
logger.error(baseLogMessage + 'error: ' + ex);
error = 'ERROR - ' + ex;
}

Expand All @@ -51,5 +53,14 @@ router.routeMessageByChannelId($g('ITI38PROCESSOR'), JSON.stringify(json));
// Cease processing in case of an error
if (error) {
channelMap.put('NOTE', error);
logger.error(
baseLogMessage +
"requestId: " +
json.id.toString() +
"cxId: " +
json.cxId.toString() +
"err: " +
error
);
throw error;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
// Decode and parse XCA ITI-38 (Cross Gateway Query Response) message
var xml = null;

var requestId = channelMap.get('MSG_ID');
var cxId = channelMap.get('CUSTOMER_ID');

var baseLogMessage = "XCA ITI38 Processor: Response (Case0) - requestId: " + requestId.toString() + ", " + "cxId: " + cxId.toString() + " - ";

var queryResponseCode = '',
homeCommunityId = null,
soapFaultCode = null,
Expand All @@ -14,15 +19,17 @@ try {
// Store for testing
channelMap.put('RESPONSE', soap.toString());

logger.info(baseLogMessage + 'Response: ' + soap);

xml = new XML(soap.toString());

// SOAP level error
if (soap.indexOf('Fault') > 0) {

channelMap.put('QACK', 'SOAP_FAULT');
// Stop further processing
return;

} else {

xml = xml.*::Body.*::AdhocQueryResponse;
Expand All @@ -32,12 +39,12 @@ try {
// urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Failure
// urn:ihe:iti:2007:ResponseStatusType:PartialSuccess
queryResponseCode = [email protected]().split(':').pop();

channelMap.put('QACK', queryResponseCode.toString());
}

} catch(ex) {
if (globalMap.containsKey('TEST_MODE')) logger.error('XCA ITI-39 Processor: Response - ' + ex);
logger.error(baseLogMessage + 'Error: ' + ex)
channelMap.put('RESPONSE_ERROR', ex.toString());
throw ex;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
// The RegistryErrorList element may be present.
// If present will contain one or more RegistryError elements with warning severity; none with error severity

var requestId = channelMap.get('MSG_ID');
var cxId = channelMap.get('CUSTOMER_ID');

var baseLogMessage = "XCA ITI38 Processor: Response (Case1) - requestId: " + requestId.toString() + ", " + "cxId: " + cxId.toString() + " - ";

if ('Success' == queryResponseCode.toString() || 'PartialSuccess' == queryResponseCode.toString()) {

var _response = getXCA38ResponseTemplate(channelMap.get('REQUEST'), null);
Expand All @@ -20,6 +25,8 @@ if ('Success' == queryResponseCode.toString() || 'PartialSuccess' == queryRespon
var operationOutcome = processRegistryErrorList(xml.*::RegistryErrorList);
if (operationOutcome) _response.operationOutcome = operationOutcome;
}

logger.info(baseLogMessage + 'Response: ' + JSON.stringify(_response));

var result = router.routeMessageByChannelId(globalMap.get('XCADQAPPINTERFACE'), JSON.stringify(_response));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@
// which shall contain corresponding RegistryError elements.
// At least one has error severity; others may have warning severity.

var requestId = channelMap.get('MSG_ID');
var cxId = channelMap.get('CUSTOMER_ID');

var baseLogMessage = "XCA ITI38 Processor: Response (Case2) - requestId: " + requestId.toString() + ", " + "cxId: " + cxId.toString() + " - ";

if ('Failure' == queryResponseCode.toString()) {

if (xml.*::RegistryErrorList.length() > 0) {

var operationOutcome = processRegistryErrorList(xml.*::RegistryErrorList);
if (operationOutcome) {
var _response = getXCA38ResponseTemplate(channelMap.get('REQUEST'), operationOutcome);
logger.info(baseLogMessage + 'Response: ' + JSON.stringify(_response));
var result = router.routeMessageByChannelId(globalMap.get('XCADQAPPINTERFACE'), JSON.stringify(_response));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ For document searches on the NHIN, it is recommended to use the following elemen
* Document Creation Time
*/

const baseLogMessage = "XCPD ITI38 Processor - requestId: " + msg.id.toString() + ", " + "cxId: " + msg.cxId.toString() + " - ";


// XDSDocumentEntryPatientId (REQUIRED) [1..1]
// Dec 20: xcpdPatientId to gatewayPatientId
var patientEntry = getXDSDocumentEntryPatientId(
Expand Down Expand Up @@ -72,3 +75,6 @@ if (msg.hasOwnProperty("serviceDate")) {
// XDSDocumentEntryType (OPTIONAL) [0..*]
var docEntryType = getXDSDocumentEntryType();
if (docEntryType) parameterList += docEntryType;

logger.info(baseLogMessage + 'Generated query parameters: ' + parameterList.toString());

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ var http = $('responseStatusLine');
http = String(http).replace('HTTP/1.1 ', '').replace(/\D/g, '');
channelMap.put('HTTP', http.toString());

var requestId = channelMap.get('MSG_ID');
var cxId = channelMap.get('CUSTOMER_ID');

var baseLogMessage = "XCPD ITI55 Processor: Response (Case0) - requestId: " + requestId.toString() + ", " + "cxId: " + cxId.toString() + " - ";


// https://docs.nextgen.com/bundle/Mirth_User_Guide_4_4_2/page/connect/connect/topics/c_Common_Scenarios_connect_ug.html
//if (responseStatus == QUEUED && connectorMessage.getSendAttempts() >= 2) {
// responseStatus = ERROR;
Expand All @@ -12,7 +18,7 @@ channelMap.put('HTTP', http.toString());
// Decode and parse XCPD ITI-55 (Cross Gateway Patient Discovery Response) message
var xml = null;

var ack = '',
var ack = '',
queryResponseCode = '',
homeCommunityId = null,
soapFaultCode = null,
Expand All @@ -22,6 +28,8 @@ try {

var soap = msg.toString();

logger.info(baseLogMessage + 'Response: ' + soap);

// Store for testing
channelMap.put('RESPONSE', soap.toString());

Expand All @@ -32,7 +40,7 @@ try {

channelMap.put('ACK', 'SOAP_FAULT');
return;

} else {

xml = xml.*::Body.*::PRPA_IN201306UV02;
Expand All @@ -52,9 +60,9 @@ try {
queryResponseCode = xml.*::controlActProcess.*::queryAck.*::[email protected]();
channelMap.put('QACK', queryResponseCode.toString());
}

} catch(ex) {
if (globalMap.containsKey('TEST_MODE')) logger.error('XCPD ITI-55 Processor: Response - ' + ex);
logger.error(baseLogMessage + 'Error: ' + ex)
channelMap.put('RESPONSE_ERROR', ex.toString());
throw ex;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
// CASE 1: The Responding Gateway finds exactly one patient record matching the criteria sent in the query parameters
// AA (application accept) is returned in Acknowledgement.typeCode (transmission wrapper).
// OK (data found, no errors) is returned in QueryAck.queryResponseCode (control act wrapper)
// One RegistrationEvent (and the associated Patient role, subject of that event) is returned from the patient information source for the patient record found.
// OK (data found, no errors) is returned in QueryAck.queryResponseCode (control act wrapper)
// One RegistrationEvent (and the associated Patient role, subject of that event) is returned from the patient information source for the patient record found.

var requestId = channelMap.get('MSG_ID');
var cxId = channelMap.get('CUSTOMER_ID');

var baseLogMessage = "XCPD ITI55 Processor: Response (Case1) - requestId: " + requestId.toString() + ", " + "cxId: " + cxId.toString() + " - ";

if ('AA' == ack.toString() && 'OK' == queryResponseCode.toString()) try {

Expand Down Expand Up @@ -33,16 +38,18 @@ if ('AA' == ack.toString() && 'OK' == queryResponseCode.toString()) try {

var patientResource = getXCPDPatientResource(subject1.toString());
if (patientResource) _response.patientResource = patientResource;


logger.info(baseLogMessage + 'Response: ' + JSON.stringify(_response));

// Send the response back to the app
var result = router.routeMessageByChannelId(globalMap.get('XCPDAPPINTERFACE'), JSON.stringify(_response));
}

// Stop further processing
return;

} catch(ex) {
if (globalMap.containsKey('TEST_MODE')) logger.error('XCPD ITI-55 Processor: Response (Case1) - ' + ex);
logger.error(baseLogMessage + 'Error: ' + ex);
channelMap.put('RESPONSE_ERROR', ex.toString());
throw ex;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,26 @@
// OK (data found, no errors) is returned in QueryAck.queryResponseCode (control act wrapper)
// One RegistrationEvent (and the associated Patient role, subject of that event) is returned for each patient record found.

var requestId = channelMap.get('MSG_ID');
var cxId = channelMap.get('CUSTOMER_ID');

var baseLogMessage = "XCPD ITI55 Processor: Response (Case2) - requestId: " + requestId.toString() + ", " + "cxId: " + cxId.toString() + " - ";

if ('AA' == ack.toString() && 'OK' == queryResponseCode.toString()) try {

// NHIN: The response to IHE XCPD Cross Gateway Patient Discovery Transaction [ITI-55] may contain multiple entries,
// but only a single entry per assigning authority is allowed.
// The choice of allowing one or zero entries per assigning authority is a compromise between false negatives and false positives.
// Requiring only a single entry per assigning authority may force a responding community to return zero matches because no single choice is appropriate,
// thus increasing the likelihood of false negatives.

logger.info(baseLogMessage + "Multiple matches found");

// Stop further processing
responseStatus = ERROR;
return;
} catch(ex) {
if (globalMap.containsKey('TEST_MODE')) logger.error('XCPD ITI-55 Processor: Response (Case2) - ' + ex);
logger.error(baseLogMessage + 'Error: ' + ex);
channelMap.put('RESPONSE_ERROR', ex.toString());
throw ex;
}
Loading