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

feat: return only complete codesystem concepts #63

Merged
merged 3 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ yarn-error.log*

# Local dot-base checkout for running the stack
dot-base/

# local npm cache
.npm
20 changes: 20 additions & 0 deletions src/model/icd10CodeSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@ class ICD10gm {
elem.property ? ICD10gm.isTypeICDCode(elem.property) : false
);

const incompleteConcepts = processedCodesystem.concept.filter(
(concept) => !ICD10gm.isComplete(concept)
);
if (incompleteConcepts.length > 0) {
const incompleteConceptsList = incompleteConcepts
.map((concept) => `{code: ${concept.code}, display: ${concept.display}}`)
.join(", ");
logger.warn(
`WARNING: The ICD10 codesystem contains ${incompleteConcepts.length} incomplete concept(s) missing either code or display. The affected concepts are: ${incompleteConceptsList}.`
);
}

processedCodesystem.concept = processedCodesystem.concept.filter((concept) =>
ICD10gm.isComplete(concept)
);

processedCodesystem.concept = ICD10gm.trimAndCopySearchFields(processedCodesystem.concept);

return processedCodesystem;
Expand All @@ -58,6 +74,10 @@ class ICD10gm {
);
}

private static isComplete(concept: R4.ICodeSystem_Concept) {
return concept.code && concept.display;
}

private static trimAndCopySearchFields(
concept: R4.ICodeSystem_Concept[]
): R4.ICodeSystem_Concept[] {
Expand Down