cqframework / vscode-cql

VS Code Clinical Quality Language Extension
Apache License 2.0
8 stars 5 forks source link

Can this be used in a standalone Monaco editor instance? #7

Closed alsoicode closed 2 years ago

alsoicode commented 2 years ago

Hello,

At Labcorp, we are building a FHIR resource editor for our CDS rules engine.

I'm looking for a way to validate CQL syntax before calling our translation service to convert the CQL to ELM.

Would it be possible to use parts of this project in Monaco itself?

Thanks, Brandon

JPercival commented 2 years ago

Hi Brandon,

Parts of this extension could be used in a Monaco environment, specifically the syntax highlighting. The error highlighting and syntax validation is actually done by a locally hosted (i.e. on the same machine as the Vs Code instance) "language server" that's written in Java. That's set up automatically behind the scenes by the plugin. To support a JS-based environment (e.g. a web browser) in the same way you'd have to create a shared "language service" that could be hosted separately. That doesn't yet exist anywhere for CQL AFAIK, but shouldn't be too difficult of a lift if you're using the CQL language server that's here.

Another alternative is to use a container-based approach and something like GitHub Codespaces. That allows each user to have their own private VM and all the features of the vscode-cql plugin work automatically. There's an example of that here. Check out the Readme for details of how it's set up.

Let me know if you have further questions.

alsoicode commented 2 years ago

Thank you very much for the information! The container-based approach looks very interesting. I'm not sure that would work for us from a privacy standpoint, but I've never used something like that before.

What would be really cool, I think, would be to do the syntax and error handling via WebAssembly. This would save us considerable bandwidth on large resources like Libraries.

The main thing I'm trying to do is not call the translation service unless the CQL for a Library is valid.

Also, sorry for posting here instead of Stack Overflow. I was hoping to hear from an author directly, and sincerely appreciate your reply.

JPercival commented 2 years ago

The only existing CQL syntax validation that I’m aware of is written in Java. You may be able to generate such a thing for WebAssembly from the original ANTLR grammar definitions, or by cross-compiling Java to JS. I’ve not tried either of those things.