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
Prev Previous commit
Next Next commit
fix(ihe): add dr logs
  • Loading branch information
Orta21 committed Mar 14, 2024
commit d3fdfc71190f751969e93279540b39805a9b4fbd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ json = getBase64Content(msg, 'json');

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


// Validate request
if ('string' == typeof json) {
error = 'ERROR - ' + json;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,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 Interface: Transformer (Step0) - ";
var baseLogMessage = "XCA DQ Interface: Transformer (Step0) - ";

// Decode and parse incoming JSON request if sent over HTTP
if (msg.toString().startsWith('<HttpRequest>')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +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 DQ 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-39 Interface: Source - ' + ex);
logger.error(baseLogMessage + 'error: ' + ex);
error = 'ERROR - ' + ex;
}

Expand All @@ -40,15 +43,23 @@ if ('string' == typeof json) {
}

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

router.routeMessageByChannelId($g('ITI39PROCESSOR'), 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;
}

router.routeMessageByChannelId($g('ITI39PROCESSOR'), JSON.stringify(json));
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 = "XCA ITI39 Processor: Response (Case0) - requestId: " + requestId.toString() + ", " + "cxId: " + cxId.toString() + " - ";


// Decode and parse XCA ITI-38 (Cross Gateway Query Response) message
var xml = null;

Expand All @@ -14,19 +20,21 @@ var queryResponseCode = '',
try {

var soap = msg.toString();

// 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.*::RetrieveDocumentSetResponse;
Expand All @@ -35,12 +43,12 @@ try {
// urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success
// urn:ihe:iti:2007:ResponseStatusType:PartialSuccess
// urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Failure
queryResponseCode = xml.*::[email protected]().split(':').pop();
queryResponseCode = xml.*::[email protected]().split(':').pop();
channelMap.put('QACK', queryResponseCode.toString());
}

} catch(ex) {
if (globalMap.containsKey('TEST_MODE')) logger.error('XCA ITI-39 Processor: Response - ' + ex);
channelMap.put('RESPONSE_ERROR', ex.toString());
logger.error(baseLogMessage + 'Error: ' + ex)
channelMap.put('RESPONSE_ERROR', ex.toString());
throw ex;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
// If both successes and failures are received from Responding Gateways, the Initiating Gateway shall return both DocumentResponse and
// RegistryErrorList elements in one response and specify PartialSuccess status.

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

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

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

if (xml.*::DocumentResponse.length() > 0) try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
// 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 ITI39 Processor: Response (Case2) - requestId: " + requestId.toString() + ", " + "cxId: " + cxId.toString() + " - ";

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

if (xml.*::RegistryResponse.*::RegistryErrorList.length() > 0) try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
// Check for the documentReference list in the incoming message
if (!msg.hasOwnProperty('documentReference')) throw 'ERROR - The required documentReference is missing. The processing has been stopped.';

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

var parameterList = new XMLList();

// Generate one or more requests, each of which representing an individual document
// that the Document Consumer wants to retrieve from the Document Repository
msg.documentReference.forEach(function(entry) {
var docRequest = getXCA39DocumentRequest(entry);
if (docRequest) parameterList += docRequest;
});
});

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