From 8bd293169837df4b22f0653409c4ea88c0091729 Mon Sep 17 00:00:00 2001 From: Ally Shaban Date: Tue, 13 Oct 2020 17:59:39 +0300 Subject: [PATCH] count processed resources --- package.json | 2 +- reports.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 0794a4c..37ae724 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fhir2es", - "version": "1.2.9", + "version": "1.3.0", "description": "Reads and caches fhir data to elasticsearch", "main": "reports.js", "scripts": { diff --git a/reports.js b/reports.js index 70bfa32..6cd8dec 100644 --- a/reports.js +++ b/reports.js @@ -839,6 +839,7 @@ class CacheFhirToES { this.getImmediateLinks(orderedResources, links, () => { async.eachSeries(orderedResources, (orderedResource, nxtResourceType) => { let processedRecords = [] + this.count = 1; let url = URI(this.FHIRBaseURL) .segment(orderedResource.resource) .segment('_history') @@ -858,6 +859,7 @@ class CacheFhirToES { password: this.FHIRPassword, }, }).then(response => { + this.totalResources = response.data.total; url = false; const next = response.data.link.find( link => link.relation === 'next' @@ -902,10 +904,9 @@ class CacheFhirToES { } processResource(resourceData, orderedResource, reportDetails, processedRecords, callback) { - let count = 1 async.each(resourceData, (data, nxtResource) => { - logger.info('processing ' + count + '/' + resourceData.length + ' records of resource ' + orderedResource.resource); - count++ + logger.info('processing ' + this.count + '/' + this.totalResources + ' records of resource ' + orderedResource.resource); + this.count++ if (!data.resource || !data.resource.resourceType) { return nxtResource() }