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

Query for chained parameters to the same Resource #117

Open
lukeaduncan opened this issue Jan 15, 2018 · 1 comment
Open

Query for chained parameters to the same Resource #117

lukeaduncan opened this issue Jan 15, 2018 · 1 comment

Comments

@lukeaduncan
Copy link
Contributor

Resources like Location and Organization have a partOf field that is a Reference to the same type of resource. I don't see how to pass that information in the genChainedParamQuery function.

For example, for Organization you can use partof.identifier for a chained query. But I don't know what to put for the chainedModule instance since it refers to itself which hasn't finished loading yet. I tried "this" and "module" with no luck. I also tried doing it the same as the others by requiring itself and creating an instance.

So what can you put for HERE:

queryUtils.genChainedParamQuery(queryObject['partof.identifier'][constants.NO_MODIFER], 'partof.reference', 'identifier', HERE, (err, clause) => { })

Or does this just have to be done in some completely separate way. I could duplicate the resource module without the chained parameters and the use that, but that seems excessive and then requires two files to be updated when other parameters are changed so it doesn't seem ideal.

Thanks!

@rcrichton
Copy link
Member

Hey @lduncan-intrah, this is an interesting problem. One we haven't encountered before.

I'd suggest perhaps in your FHIR resource module rather than returning an object directly with all the functions attahced to it, you can give it a name and then return that and use it in for the genChainedParamQuery function.

I.e. instead of...

return {
  searchparams: () => { ... }
}

rather do

const self = {
  searchparams: () => {
    ...
    queryUtils.genChainedParamQuery(queryObject['partof.identifier'][constants.NO_MODIFER], 'partof.reference', 'identifier', self, (err, clause) => { })
    ...
  }
}

return self

I believe something like this should work.

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