Skip to content

Commit

Permalink
Merge pull request #8 from standardhealth/ignoreFn
Browse files Browse the repository at this point in the history
Add ignoreFn to syntheaToV09 and rework utils
  • Loading branch information
rdingwell authored Sep 4, 2019
2 parents 33049e2 + 1485c7b commit 1a17187
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 16 deletions.
6 changes: 3 additions & 3 deletions dist/app.bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/app.bundle.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/app.node.bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/app.node.bundle.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/mapping/mappers/cerner.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const {
buildMappers
} = require('../mapper');
const utils = require('../../utils/common');
const mcodeUtils09 = require('../../utils/mcodeUtils09');
const utils = require('../../utils');
const syntheaToV09 = require('./syntheaToV09');
const mcodeUtils09 = utils.mcodeUtils09;

let vars = {
pStageCodes: [ 'AJCCV8 MAG-PRO P Stage', 'AJCCV8 BRE-INV P Stage'],
Expand Down
2 changes: 1 addition & 1 deletion src/mapping/mappers/syntheaToV05.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { buildMappers } = require('../mapper');
const {applyProfile} = require('../../utils/common');
const {applyProfile} = require('../../utils');

const DEFAULT_PROFILE = {
'Patient': 'http://hl7.org/fhir/us/fhirURL/StructureDefinition/shr-entity-Patient',
Expand Down
35 changes: 32 additions & 3 deletions src/mapping/mappers/syntheaToV09.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const { buildMappers } = require('../mapper');
const { applyProfile, applyProfileFunction } = require('../../utils/common');
const mcodeUtils09 = require('../../utils/mcodeUtils09');

const { applyProfile, applyProfileFunction, hasProfileFromList, mcodeUtils09 } = require('../../utils');

const defaultProfile = (resourceType) => {
switch (resourceType) {
Expand All @@ -28,6 +26,36 @@ const defaultProfile = (resourceType) => {
}
};

const allRelevantProfiles = [
'http://hl7.org/fhir/us/shr/DSTU2/StructureDefinition/shr-core-AllergyIntolerance',
'http://hl7.org/fhir/us/shr/DSTU2/StructureDefinition/shr-core-Condition',
'http://hl7.org/fhir/us/shr/DSTU2/StructureDefinition/shr-core-DiagnosticReport',
'http://hl7.org/fhir/us/shr/DSTU2/StructureDefinition/shr-core-Encounter',
'http://hl7.org/fhir/us/shr/DSTU2/StructureDefinition/shr-core-MedicationAdministration',
'http://hl7.org/fhir/us/shr/DSTU2/StructureDefinition/shr-core-MedicationRequest',
'http://hl7.org/fhir/us/shr/DSTU2/StructureDefinition/shr-core-Observation',
'http://hl7.org/fhir/us/shr/DSTU2/StructureDefinition/shr-core-Organization',
'http://hl7.org/fhir/us/shr/DSTU2/StructureDefinition/shr-core-Patient',
'http://hl7.org/fhir/us/shr/DSTU2/StructureDefinition/shr-core-Practitioner',
'http://hl7.org/fhir/us/shr/DSTU2/StructureDefinition/shr-core-Procedure',
'http://hl7.org/fhir/us/shr/StructureDefinition/shr-core-BloodPressure',
'http://hl7.org/fhir/us/shr/StructureDefinition/shr-core-BodyHeight',
'http://hl7.org/fhir/us/shr/StructureDefinition/shr-core-BodyWeight',
'http://hl7.org/fhir/us/shr/StructureDefinition/onco-core-CancerDiseaseStatus',
'http://hl7.org/fhir/us/shr/StructureDefinition/onco-core-CancerRelatedRadiationProcedure',
'http://hl7.org/fhir/us/shr/StructureDefinition/onco-core-CancerRelatedSurgicalProcedure',
'http://hl7.org/fhir/us/shr/StructureDefinition/onco-core-PrimaryCancerCondition',
'http://hl7.org/fhir/us/shr/StructureDefinition/onco-core-SecondaryCancerCondition',
'http://hl7.org/fhir/us/shr/StructureDefinition/onco-core-TNMClinicalDistantMetastasesCategory',
'http://hl7.org/fhir/us/shr/StructureDefinition/onco-core-TNMClinicalPrimaryTumorCategory',
'http://hl7.org/fhir/us/shr/StructureDefinition/onco-core-TNMClinicalRegionalNodesCategory',
'http://hl7.org/fhir/us/shr/StructureDefinition/onco-core-TNMClinicalStageGroup',
'http://hl7.org/fhir/us/shr/StructureDefinition/onco-core-TNMPathologicDistantMetastasesCategory',
'http://hl7.org/fhir/us/shr/StructureDefinition/onco-core-TNMPathologicPrimaryTumorCategory',
'http://hl7.org/fhir/us/shr/StructureDefinition/onco-core-TNMPathologicRegionalNodesCategory',
'http://hl7.org/fhir/us/shr/StructureDefinition/onco-core-TNMPathologicStageGroup',
'http://hl7.org/fhir/us/shr/StructureDefinition/onco-core-TumorMarkerTest'
];

const nthWord = (string, index) => {
return string.split(' ')[index];
Expand All @@ -46,6 +74,7 @@ const stripParens = (string) => {

const resourceMapping = {
filter: () => true,
ignore: (resource) => hasProfileFromList(resource, allRelevantProfiles),
default: (resource, _context) => applyProfile(resource, defaultProfile(resource.resourceType)),
mappers: [
{
Expand Down
11 changes: 10 additions & 1 deletion src/utils/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ const addExtension = (resource, newExtension) => {
resource.extension.push(newExtension);
};

const hasProfileFromList = (resource, profiles) => {
// ignore resources that already have mCODE profiles. we will assume they are profiled correctly
if (!resource || !resource.meta || !resource.meta.profile) {
return false; // i.e., do not ignore this since it has no profiles
}
// check if any of the profiles are mcode. returns null (falsy) if none found or the profile itself (truthy)
return resource.meta.profile.find(p => profiles.includes(p));
}

const applyProfileFunction = (profile) => {
// return an anonymous function wrapper to apply this specific profile to given resources
return (resource, _context) => applyProfile(resource, profile);
Expand Down Expand Up @@ -65,4 +74,4 @@ const find = (context, path, options = {}) => {
return results[0];
};

module.exports = {find, applyProfile, addExtension, applyProfileFunction, isTrue, addRelated};
module.exports = {find, applyProfile, addExtension, hasProfileFromList, applyProfileFunction, isTrue, addRelated};
2 changes: 1 addition & 1 deletion src/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const common = require('./common');
const mcodeUtils09 = require('./mcodeUtils09');
module.exports = {common, mcodeUtils09};
module.exports = {...common, mcodeUtils09};

0 comments on commit 1a17187

Please sign in to comment.