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

Getting error while evaluating valuesets #274

Open
nehaghub opened this issue Aug 23, 2022 · 3 comments
Open

Getting error while evaluating valuesets #274

nehaghub opened this issue Aug 23, 2022 · 3 comments

Comments

@nehaghub
Copy link

C:\Users\neha.f.goel\tt\cql-execution\lib\elm\clinical.js:35
const valueset = ctx.codeService.findValueSet(this.id, this.version) || new dt.ValueSet(this.id, this.version);
^

TypeError: Cannot read properties of undefined (reading 'findValueSet')
at ValueSetDef.exec (C:\Users\neha.f.goel\tt\cql-execution\lib\elm\clinical.js:35:42)
at ValueSetDef.execute (C:\Users\neha.f.goel\tt\cql-execution\lib\elm\expression.js:29:25)
at ValueSetRef.exec (C:\Users\neha.f.goel\tt\cql-execution\lib\elm\clinical.js:51:33)
at ValueSetRef.execute (C:\Users\neha.f.goel\tt\cql-execution\lib\elm\expression.js:29:25)
at Retrieve.exec (C:\Users\neha.f.goel\tt\cql-execution\lib\elm\external.js:22:46)
at Retrieve.execute (C:\Users\neha.f.goel\tt\cql-execution\lib\elm\expression.js:29:25)
at C:\Users\neha.f.goel\tt\cql-execution\lib\elm\expression.js:37:45
at Array.map ()
at Union.execArgs (C:\Users\neha.f.goel\tt\cql-execution\lib\elm\expression.js:37:30)
at Union.exec (C:\Users\neha.f.goel\tt\cql-execution\lib\elm\overloaded.js:83:29)

Please help me for the same.
Thanks
Neha

@cmoesel
Copy link
Member

cmoesel commented Aug 25, 2022

Hi @nehaghub. If I had to guess, it seems like you are not passing in a CodeService when you construct the cql-execution Executor. The CodeService instance is the 2nd argument in the Executor constructor. See the Overview.

If you aren't passing one in to the constructor, then you need to do so. If you're using value sets from VSAC, then you can use the cql-exec-vsac code service.

If you are passing in a code service and still getting this error, then we'll need more information:

  • What version of cql-execution are you using?
  • Based on the file paths, it looks like you are not using it as an npm dependency, but have cloned the repository and are running the code directly, is that right?
  • Can you provide any example code of how you are building and or running the executor?

@nehaghub
Copy link
Author

nehaghub commented Sep 5, 2022

Hi,

  1. I am using "version": "2.4.1".
  2. Yes, I am using this way.
  3. Below is my code
    const fs = require('fs');
    const path = require('path');

const cqlfhir = require('../lib');
const vsac = require('../../cql-exec-vsac');
const cql = require('../../cql-execution/lib/cql');

parameters = {
"Measurement Period" : new cql.Interval (
new cql.DateTime(1952,1,1,0,0,0,0),
new cql.DateTime(2021,1,1,0,0,0,0)
)
}

const elmFile = JSON.parse(fs.readFileSync('C:/Users/neha.f.goel/tt/bcs.json', 'utf8'));
const libraries = {
FHIRBase:JSON.parse(fs.readFileSync('C:/Users/neha.f.goel/tt/CCS_HEDIS_MY2022-1.1.0/CCS_HEDIS_MY2022-1.1.0/libraryElm/NCQA_FHIRBase-1.1.0.json', 'utf8')),
FHIRHelpers: JSON.parse(fs.readFileSync('C:/Users/neha.f.goel/tt/CCS_HEDIS_MY2022-1.1.0/CCS_HEDIS_MY2022-1.1.0/libraryElm/FHIRHelpers-4.0.1.json', 'utf8'))
};
)
const library = new cql.Library(elmFile, new cql.Repository(libraries));

const bundles = [];

const patientsPath = 'mcode1_0_longitudinal/longitudinal/female';
for (const fileName of fs.readdirSync(patientsPath)) {
const file = path.join(patientsPath, fileName);
if (!file.endsWith('.json')) {
continue;
}
const json = JSON.parse(fs.readFileSync(file));
bundles.push(json);
}

const patientSource = cqlfhir.PatientSource.FHIRv401(); // or .FHIRv300() or .FHIRv400()

patientSource.loadBundles(bundles);

// let valueSets = [];

// if (elmFile.library && elmFile.library.valueSets && elmFile.library.valueSets.def) {
// valueSets = elmFile.library.valueSets.def;
// }

// const codeService = new vsac.CodeService('C:/Users/neha.f.goel/tt/jim_cql/valuesets/vsac_cache/', true);

console.log("b4 execution") ;
const executor = new cql.Executor(library);

// const executor = new cql.Executor(library, codeService,parameters);
const results = executor.exec(patientSource);

console.log(JSON.stringify(results, undefined, 2));

@cmoesel
Copy link
Member

cmoesel commented Oct 18, 2022

I apologize for the long delay in getting back to you. In your code above, you have commented out the lines that initialize a code service and pass it into the Executor. As I noted in my previous response, you need to pass in a CodeService as the 2nd argument to the executor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants