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

add measure-set column #3

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ Both the `ig-summary create` and `ig-summary diff` commands support settings fil
# If the primary audience for the IG summary are clinical SMEs, including all the fixed codes
# may be unnecessarily noisy.
suppressedFixedCodes: false

# List of specific elements to be excluded while generating summary
excludeElement: [
'DeviceRequest.modifierExtension',
'DeviceRequest.modifierExtension:doNotPerform',
'Task.output.value[x]']
```

- Annotated settings file example for the `ig-summary diff` command:
Expand Down
12 changes: 12 additions & 0 deletions data_dictionary_settings.example.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
codeSystems:
'http://snomed.info/sct': SNOMED CT
'http://hl7.org/fhir/sid/icd-10-cm': ICD-10 CM

excludeElement: [
'DeviceRequest.modifierExtension',
'DeviceRequest.modifierExtension:doNotPerform',
'Task.output.value[x]',
'Encounter.reasonReference',
'Claim.extension:encounter']

extensionColumn: [
'used-by-measure',
'associated-with-valueset'
]
4 changes: 3 additions & 1 deletion src/DataDictionarySettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export type DataDictionarySettings = {
codeSystems?: { [key: string]: string };
informationTabContent?: { [key: string]: string };
touchUpHumanizedElementNames?: { [key: string]: string };
suppressFixedCodes?: boolean
suppressFixedCodes?: boolean;
extensionColumn?: string[];
excludeElement?: string[]
};

export function loadSettingsFromYaml(settingsPath: string): DataDictionarySettings {
Expand Down
58 changes: 48 additions & 10 deletions src/data-dictionary/IgSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {logger} from '../util/logger';
import {ProfileGroupExtractor, ProfileGroups} from '../profile_groups';
import {
DataElementInformation,
DataElementInformationForSpreadsheet
DataElementInformationForSpreadsheet,
SpreadsheetColNames
} from '../elements/ProfileElement';
import {ProfileElementFactory} from '../elements/Factory';
import {
Expand Down Expand Up @@ -92,7 +93,6 @@ export class IgSummary {
}
this.outputDir = outputDir;


if (logLevel === 'debug' || logLevel === 'warn' || logLevel === 'error') {
logger.level = logLevel; // ig-data-dictionary logger
fshutils.logger.level = logLevel; // SUSHI logger
Expand Down Expand Up @@ -252,20 +252,36 @@ export class IgSummary {
public async generateSpreadsheet() {
// Get external dependencies
await this.getExternalDefs();

// Store data for CSV here
let profileElements: Array<DataElementInformationForSpreadsheet> = [];

// Iterate through StructureDefinitions
// Note that SUSHI creates duplicate objects for each Profile because it wants to index by URL, ID, and name.
// `_.uniqBy()` cleans this up.
if (this.defs.allProfiles().length == 0) {
logger.error(`No profiles found in ${this.fhirDefFolder}.`);
return;
}

let extensionFlgMap = new Map<string, string>();

for (const sd of _.uniqBy(this.defs.allProfiles(), 'id')) {
const snapshot = sd.snapshot;

for (const elemJson of snapshot.element.slice(1)) {
elemJson.extension?.forEach((ext: any) => {
this.settings.extensionColumn?.forEach((col:string) => {
console.log(sd.title+elemJson.id+col);
jhlee-mitre marked this conversation as resolved.
Show resolved Hide resolved
if (ext.url.includes('/StructureDefinition/' + col)) extensionFlgMap.set(sd.title+elemJson.id+col, 'true');
})
})
}
}

for (const sd of _.uniqBy(this.defs.allProfiles(), 'id')) {
const snapshot = sd.snapshot;

// Skip abstract profiles
if (sd.abstract === true) {
continue;
Expand All @@ -278,6 +294,11 @@ export class IgSummary {
// The `slice(1)` skips the first item in the array, which is information about the StructureDefinition
// that isn't needed.
for (const elemJson of snapshot.element.slice(1)) {
if (this.settings.excludeElement?.includes(elemJson.id)) {
logger.warn(`${elemJson.id} wasn't included in the output summary report`);
continue;
}

if (
this.settings.mode == DataDictionaryMode.MustSupport &&
!(
Expand All @@ -303,7 +324,7 @@ export class IgSummary {
[this.defs, this.externalDefs],
this.settings
);

const elemToJson = elem.toJSON();
// Filter down to unique elements -- there may be duplicates because extension ProfileElement objects
// automatically add sub-elements.
Expand All @@ -324,6 +345,7 @@ export class IgSummary {

if (deduplicatedElemToJson) profileElements = profileElements.concat(deduplicatedElemToJson);
}

}

// Get list of profiles, extensions, and value sets
Expand Down Expand Up @@ -413,8 +435,10 @@ export class IgSummary {
bold: true,
size: 16
};

[
['', 'IG name', this.sushiConfig.title],
['', 'IG name', this.sushiConfig.name],
karlnaden marked this conversation as resolved.
Show resolved Hide resolved
['', 'IG title', this.sushiConfig.title],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include both name and title

['', 'IG URL', this.sushiConfig.url],
['', 'IG version', this.sushiConfig.version],
['', 'IG status', this.sushiConfig.status],
Expand All @@ -425,6 +449,8 @@ export class IgSummary {
['', '# Value Sets', allValueSets.length],
['', '# Code Systems', allCodeSystems.length],
[''],
['', 'Extension type used for Extension? column', this.settings.extensionColumn],
[''],
['', 'Data dictionary generated date', new Date().toLocaleString('en-US')]
].forEach(line => {
indexWorksheet.addRow(line);
Expand Down Expand Up @@ -510,7 +536,22 @@ export class IgSummary {

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Add extension columns dynamically
const profileElementsWorksheet = workbook.addWorksheet('Data elements');
let col = Object.keys(profileElements[0]).map(k => {
return { name: k, key: k, filterButton: true };
});

this.settings.extensionColumn?.forEach ((ec: string) => {
col.push({ name: ec, key: ec, filterButton: true });
})

profileElements.forEach(pe => {
this.settings.extensionColumn?.forEach ((ec: string) => {
pe[ec] = extensionFlgMap.get(pe[SpreadsheetColNames.ProfileTitle]+pe[SpreadsheetColNames.FHIRElement]+ec);
})
});

// Add table
profileElementsWorksheet.addTable({
name: 'profile_data_elements',
Expand All @@ -521,9 +562,7 @@ export class IgSummary {
theme: 'TableStyleMedium2',
showRowStripes: true
},
columns: Object.keys(profileElements[0]).map(k => {
return {name: k, key: k, filterButton: true};
}),
columns: col,
rows: profileElements.map(k => {
return Object.values(k);
})
Expand Down Expand Up @@ -712,5 +751,4 @@ export class IgSummary {
differ.logSummary();
}
}

}
2 changes: 1 addition & 1 deletion src/elements/ProfileElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export enum SpreadsheetColNames {
ValueSetBinding = 'Value Set Binding',
FHIRElement = 'FHIR Element (R4)',
SourceProfileURI = 'Source Profile URI',
ElementStructureDefinitionURI = 'Element StructureDefinition URI',
ElementStructureDefinitionURI = 'Element StructureDefinition URI'
}

// Non-optional version of DataElementInformation, with proper row names
Expand Down