-
Notifications
You must be signed in to change notification settings - Fork 34
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
Added Support for the ExpandValueset operator #332
base: master
Are you sure you want to change the base?
Conversation
…er, AdvancedCodeService and ExpandValueSet expression
…pand method to valueset for the ExpandValueset operator
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #332 +/- ##
==========================================
+ Coverage 87.04% 87.11% +0.07%
==========================================
Files 52 52
Lines 4517 4534 +17
Branches 1273 1277 +4
==========================================
+ Hits 3932 3950 +18
Misses 377 377
+ Partials 208 207 -1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this contribution, @sorliog! This looks pretty good to me. I left a few comments regarding small things to change -- but all the important parts seems to be working well!
We like to have more than one review of each PR, so I'm also going to ask another colleague to review this.
Thanks again! We love receiving contributions!
src/cql-code-service.ts
Outdated
// class AdvancedCodeService implements AdvancedTerminologyProvider { | ||
// valueSets: ValueSetObject; | ||
// | ||
// constructor(valueSetsJson: ValueSetDictionary = {}) { | ||
// this.valueSets = {}; | ||
// for (const oid in valueSetsJson) { | ||
// this.valueSets[oid] = {}; | ||
// for (const version in valueSetsJson[oid]) { | ||
// const codes = valueSetsJson[oid][version].map( | ||
// (code: any) => new Code(code.code, code.system, code.version) | ||
// ); | ||
// this.valueSets[oid][version] = new ValueSet(oid, version, codes); | ||
// } | ||
// } | ||
// } | ||
// | ||
// findValueSetsByOid(oid: string): ValueSet[] { | ||
// return this.valueSets[oid] ? Object.values(this.valueSets[oid]) : []; | ||
// } | ||
// | ||
// findValueSet(oid: string, version?: string): ValueSet | null { | ||
// if (version != null) { | ||
// return this.valueSets[oid] != null ? this.valueSets[oid][version] : null; | ||
// } else { | ||
// const results = this.findValueSetsByOid(oid); | ||
// if (results.length === 0) { | ||
// return null; | ||
// } else { | ||
// return results.reduce((a: any, b: any) => { | ||
// if (a.version > b.version) { | ||
// return a; | ||
// } else { | ||
// return b; | ||
// } | ||
// }); | ||
// } | ||
// } | ||
// } | ||
// | ||
// | ||
// expandValueSet(oid: string, version?: string): Code[] { | ||
// const results: Code[] = []; | ||
// const valueSet: ValueSet | null = this.findValueSet(oid, version); | ||
// if (valueSet == null) { | ||
// return []; | ||
// } | ||
// valueSet.codes.forEach(code => { | ||
// if (!results.find(result => { | ||
// result === code; | ||
// })) { | ||
// results.push(code); | ||
// | ||
// } | ||
// }); | ||
// return results; | ||
// } | ||
// | ||
// | ||
// inValueSet(code: Code | Code[], oid: string, version?: string): boolean { | ||
// const valueSet: ValueSet | null = this.findValueSet(oid, version); | ||
// if (valueSet == null) { | ||
// return false; | ||
// } | ||
// | ||
// const codeList: Code[] = Array.isArray(code) ? code : [code]; | ||
// | ||
// return codeList.every(singleCode => { | ||
// valueSet.hasMatch(singleCode); | ||
// }); | ||
// } | ||
// | ||
// anyInValueSet(code: Code | Code[], oid: string, version?: string): boolean { | ||
// const valueSet: ValueSet | null = this.findValueSet(oid, version); | ||
// if (valueSet == null) { | ||
// return false; | ||
// } | ||
// | ||
// const codeList: Code[] = Array.isArray(code) ? code : [code]; | ||
// | ||
// return codeList.some(singleCode => { | ||
// valueSet.hasMatch(singleCode); | ||
// }); | ||
// } | ||
// | ||
// | ||
// expandCodeSystem(codeSystem: CodeSystem): Code[] { | ||
// throw new Error('This function is not implemented.'); | ||
// } | ||
// | ||
// | ||
// inCodeSystem(code: Code | Code[], codeSystem: CodeSystem): boolean { | ||
// throw new Error('This function is not implemented.'); | ||
// } | ||
// | ||
// subsumes(subsuming: Code | Concept, subsumed: Code | Concept): boolean { | ||
// throw new Error('This function is not implemented.'); | ||
// } | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally speaking, we try to avoid having large blocks of commented out code. If this code is not needed, I'd prefer that we delete it.
src/cql-code-service.ts
Outdated
@@ -1,7 +1,7 @@ | |||
import { Code, ValueSet } from './datatypes/datatypes'; | |||
import { TerminologyProvider, ValueSetDictionary, ValueSetObject } from './types'; | |||
|
|||
export class CodeService implements TerminologyProvider { | |||
class CodeService implements TerminologyProvider { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to remain consistent with the rest of the code base, I think it's best to export the class declaration here (as it was before).
src/cql-code-service.ts
Outdated
// } | ||
// } | ||
|
||
export { CodeService }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As noted above, in order to remain consistent with the rest of the code base, we should export as part of the class declaration.
// TODO Add advanced valueset operations here | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can delete this.
// | ||
// /** | ||
// * Interface extending TerminologyProvider to include advanced terminology operations such as expanding valuesets and codesystems | ||
// */ | ||
// | ||
// export interface AdvancedTerminologyProvider extends TerminologyProvider { | ||
// inValueSet: (code: Code | Code[], oid: string, version?: string) => boolean | Promise<boolean>; | ||
// anyInValueSet: (code: Code | Code[], oid: string, version?: string) => boolean | Promise<boolean>; | ||
// expandValueSet: ( oid: string, version?: string) => Code[] | Promise<Code[]>; | ||
// inCodeSystem: (code: Code | Code[], codeSystem: CodeSystem) => boolean | Promise<boolean>; | ||
// // expandCodeSystem: (codeSystem: CodeSystem) => Code[] | Promise<Code[]>; | ||
// // subsumes: (subsuming: Code | Concept, subsumed: Code | Concept) => boolean | Promise<boolean>; | ||
// | ||
// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be deleted as well.
I've also just realized that while you added datatype tests, there are no tests for the ELM ExpandValueSet expression. Could you add some cql tests in There is one current gotcha. When you run |
Understood, @cmoesel. I made the requested changes. Let me know if I missed anything. |
Description
Added support for the ExpandValueset operator by adding the expand method in the Valueset class. The expand method is invoked in ExpandValueSet.exec() expression.
Submitter:
npm run test:plus
to run tests, lint, and prettier)cql4browsers.js
built withnpm run build:browserify
if source changed.Reviewer:
Name: