|
1 | 1 | const logger = require('../../helpers/logger');
|
| 2 | +const { ifSomeArgsObj } = require('../../helpers/templateUtils'); |
2 | 3 | const { isCancerStagingSystem } = require('../../helpers/cancerStagingUtils');
|
3 | 4 | const { coding } = require('./coding');
|
4 | 5 |
|
5 |
| -function stagingMethodTemplate({ code }) { |
6 |
| - if (isCancerStagingSystem(code)) { |
7 |
| - // NOTE: our general value set lookup should probably return the associate system, since it's available at the VS level |
8 |
| - return { |
| 6 | +function methodTemplate({ code, system }) { |
| 7 | + return ifSomeArgsObj( |
| 8 | + ({ code: code_, system: system_ }) => ({ |
9 | 9 | method: {
|
10 | 10 | coding: [
|
11 | 11 | coding({
|
12 |
| - code, |
13 |
| - system: 'http://snomed.info/sct', |
| 12 | + ...(code_ && { code: code_ }), |
| 13 | + ...(system_ && { system: system_ }), |
14 | 14 | }),
|
15 | 15 | ],
|
16 | 16 | },
|
17 |
| - }; |
| 17 | + }), |
| 18 | + )({ code, system }); |
| 19 | +} |
| 20 | + |
| 21 | +function stagingMethodTemplate({ code }) { |
| 22 | + if (isCancerStagingSystem(code)) { |
| 23 | + // NOTE: our general value set lookup should probably return the associate system, since it's available at the VS level |
| 24 | + return methodTemplate({ code, system: 'http://snomed.info/sct' }); |
18 | 25 | } if (code === 'C146985') {
|
19 | 26 | // TODO: fix this HARDCODED special case as delineated by this VS's description http://hl7.org/fhir/us/mcode/ValueSet-mcode-cancer-staging-system-vs.html
|
20 | 27 | // System based on http://hl7.org/fhir/us/mcode/Observation-mCODETNMClinicalPrimaryTumorCategoryExample01.json.html
|
21 |
| - return { |
22 |
| - method: { |
23 |
| - coding: [ |
24 |
| - coding({ |
25 |
| - code, |
26 |
| - system: 'http://ncimeta.nci.nih.gov', |
27 |
| - }), |
28 |
| - ], |
29 |
| - }, |
30 |
| - }; |
| 28 | + return methodTemplate({ code, system: 'http://ncimeta.nci.nih.gov' }); |
31 | 29 | }
|
32 |
| - logger.warn(`stagingMethodTemplate received a code ${code} that is not recognized; code will not be added to the resulting FHIR resource`); |
33 |
| - return null; |
| 30 | + logger.debug(`stagingMethodTemplate received a code ${code} that is not recognized; code will not be added to the resulting FHIR resource`); |
| 31 | + return methodTemplate({ code }); |
34 | 32 | }
|
35 | 33 |
|
36 | 34 | module.exports = {
|
|
0 commit comments