Skip to content

Commit cd7ccae

Browse files
Merge pull request #1863 from icanbwell/nn-ignt-70
IGNT-70 Add _includeHidden support
2 parents 4c55276 + 659d920 commit cd7ccae

15 files changed

+4562
-53
lines changed

src/constants.js

+4
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ module.exports = {
204204
SYSTEM: 'http://terminology.hl7.org/CodeSystem/v3-Confidentiality',
205205
CODE: 'R'
206206
},
207+
RESOURCE_HIDDEN_TAG: {
208+
SYSTEM: 'https://fhir.icanbwell.com/4_0_0/CodeSystem/server-behavior',
209+
CODE: 'hidden'
210+
},
207211
CONSENT_OF_LINKED_PERSON_INDEX: 'consent_of_linked_person',
208212
EXTERNAL_REQUEST_RETRY_COUNT: 3,
209213
DEFAULT_CACHE_MAX_COUNT: 25,

src/operations/everything/everythingHelper.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,8 @@ class EverythingHelper {
500500

501501
const baseArgs = {
502502
base_version: base_version,
503-
_debug: debug || explain
503+
_debug: debug || explain,
504+
_includeHidden: parsedArgs._includeHidden
504505
};
505506

506507
// if explain query, don't break in chunks as will be limit to single resource later
@@ -831,12 +832,16 @@ class EverythingHelper {
831832
const relatedResourceParsedArgs = this.parseQueryStringIntoArgs(
832833
{
833834
resourceType: relatedResourceType,
834-
queryString: reverseFilterWithParentIds
835+
queryString: reverseFilterWithParentIds,
836+
commonArgs: {
837+
_includeHidden: parsedArgs._includeHidden
838+
}
835839
}
836840
);
837841

838842
const args = {};
839843
args.base_version = base_version;
844+
840845
/**
841846
* @type {boolean}
842847
*/
@@ -1141,10 +1146,12 @@ class EverythingHelper {
11411146
* converts a query string into an args array
11421147
* @param {string} resourceType
11431148
* @param {string} queryString
1149+
* @param {object} commonArgs
11441150
* @return {ParsedArgs}
11451151
*/
1146-
parseQueryStringIntoArgs({ resourceType, queryString }) {
1147-
const args = Object.fromEntries(new URLSearchParams(queryString));
1152+
parseQueryStringIntoArgs({ resourceType, queryString, commonArgs = {} }) {
1153+
const args = {};
1154+
Object.assign(args, commonArgs, Object.fromEntries(new URLSearchParams(queryString)));
11481155
args.base_version = VERSIONS['4_0_0'];
11491156
return this.r4ArgsParser.parseArgs(
11501157
{

src/operations/graph/graphHelpers.js

+21-6
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ class GraphHelper {
268268
* @param {string} property
269269
* @param {string | null} filterProperty (Optional) filter the sublist by this property
270270
* @param {*|null} filterValue (Optional) match filterProperty to this value
271+
* @param {ParsedArgs} parseArgs
271272
* @param {boolean} [explain]
272273
* @param {boolean} [debug]
273274
* @param {boolean} supportLegacyId
@@ -281,6 +282,7 @@ class GraphHelper {
281282
property,
282283
filterProperty,
283284
filterValue,
285+
parsedArgs,
284286
explain,
285287
debug,
286288
supportLegacyId = true,
@@ -332,7 +334,9 @@ class GraphHelper {
332334
*/
333335
const useAccessIndex = this.configManager.useAccessIndex;
334336

335-
const args = Object.assign({ base_version }, { id: relatedReferenceIds.join(',') });
337+
const args = Object.assign({
338+
base_version, _includeHidden: parsedArgs._includeHidden
339+
}, { id: relatedReferenceIds.join(',') });
336340
const childParseArgs = this.r4ArgsParser.parseArgs(
337341
{
338342
resourceType,
@@ -486,10 +490,12 @@ class GraphHelper {
486490
* converts a query string into an args array
487491
* @param {string} resourceType
488492
* @param {string} queryString
493+
* @param {object} commonArgs
489494
* @return {ParsedArgs}
490495
*/
491-
parseQueryStringIntoArgs ({ resourceType, queryString }) {
492-
const args = Object.fromEntries(new URLSearchParams(queryString));
496+
parseQueryStringIntoArgs ({ resourceType, queryString, commonArgs = {}}) {
497+
const args = {};
498+
Object.assign(args, commonArgs, Object.fromEntries(new URLSearchParams(queryString)));
493499
args.base_version = VERSIONS['4_0_0'];
494500
return this.r4ArgsParser.parseArgs(
495501
{
@@ -513,6 +519,7 @@ class GraphHelper {
513519
* @param {boolean} [debug]
514520
* @param {boolean} supportLegacyId
515521
* @param {string[]} proxyPatientIds
522+
* @param {ParsedArgs} parseArgs
516523
* @param {ResourceEntityAndContained[]} proxyPatientResources
517524
* @returns {QueryItem}
518525
*/
@@ -527,6 +534,7 @@ class GraphHelper {
527534
reverse_filter,
528535
explain,
529536
debug,
537+
parsedArgs,
530538
supportLegacyId = true,
531539
proxyPatientIds = [],
532540
proxyPatientResources = [],
@@ -595,11 +603,15 @@ class GraphHelper {
595603
const relatedResourceParsedArgs = this.parseQueryStringIntoArgs(
596604
{
597605
resourceType: relatedResourceType,
598-
queryString: reverseFilterWithParentIds
606+
queryString: reverseFilterWithParentIds,
607+
commonArgs: {
608+
_includeHidden: parsedArgs._includeHidden
609+
}
599610
}
600611
);
601612
const args = {};
602613
args.base_version = base_version;
614+
603615
const searchParameterName = reverse_filter.split('=')[0];
604616
/**
605617
* @type {boolean}
@@ -986,7 +998,8 @@ class GraphHelper {
986998
explain,
987999
debug,
9881000
supportLegacyId,
989-
getRaw
1001+
getRaw,
1002+
parsedArgs
9901003
}
9911004
);
9921005
if (queryItem) {
@@ -1048,6 +1061,7 @@ class GraphHelper {
10481061
supportLegacyId,
10491062
proxyPatientIds,
10501063
proxyPatientResources,
1064+
parsedArgs,
10511065
getRaw
10521066
}
10531067
);
@@ -1394,7 +1408,8 @@ class GraphHelper {
13941408
const args = {
13951409
base_version: base_version,
13961410
id: Array.from(ids).join(','),
1397-
_debug: debug
1411+
_debug: debug,
1412+
_includeHidden: parsedArgs._includeHidden
13981413
};
13991414
if (explain) {
14001415
args['_count'] = 1;

src/operations/query/r4.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const { OPERATIONS: { DELETE }, RESOURCE_HIDDEN_TAG } = require('../../constants');
12
const { fhirFilterTypes } = require('./customQueries');
23
const { FilterByString } = require('./filters/string');
34
const { FilterByUri } = require('./filters/uri');
@@ -21,7 +22,6 @@ const { MongoQuerySimplifier } = require('../../utils/mongoQuerySimplifier');
2122
const { FilterParameters } = require('./filters/filterParameters');
2223
const { UrlParser } = require('../../utils/urlParser');
2324
const { FilterByQuantity } = require('./filters/quantity');
24-
const { OPERATIONS: { DELETE } } = require('../../constants');
2525
const { isTrue } = require('../../utils/isTrue');
2626
const { FilterByOfType } = require('./filters/ofType');
2727
const { FilterByNumber } = require('./filters/number');
@@ -156,7 +156,7 @@ class R4SearchQueryCreator {
156156
// Handling case of 'hidden' tag in meta
157157
if (
158158
!parsedArgs.id &&
159-
(isUser || !isTrue(parsedArgs._includeHidden)) &&
159+
!isTrue(parsedArgs._includeHidden) &&
160160
operation !== DELETE &&
161161
!useHistoryTable &&
162162
resourceType !== 'AuditEvent'
@@ -166,8 +166,8 @@ class R4SearchQueryCreator {
166166
'meta.tag': {
167167
$not: {
168168
$elemMatch: {
169-
system: 'https://fhir.icanbwell.com/4_0_0/CodeSystem/server-behavior',
170-
code: 'hidden'
169+
system: RESOURCE_HIDDEN_TAG.SYSTEM,
170+
code: RESOURCE_HIDDEN_TAG.CODE
171171
}
172172
}
173173
}

0 commit comments

Comments
 (0)