CQDefine Examples

The following examples demonstrate how to use CQDefine to create reusable libraries of logic. Each example includes a TypeScript file that defines the library, and an interactive UI that allows you to choose different patients and enter in data for parameterized functions.

Each function has documentation that is auto-generated by using TypeScript decorators. The decorators are the symbols prefix with the @ such as @Documentation.

The decorators also allow for explicit configuration of function parameters and return types.

Re-usable Knowledge

Using these building blocks, it is possible to build re-usable knowledge libraries that can be exposed through many different interfaces throughout an application stack. As we have seen before, this approach can be used to execute CQFlow logic nodes. But these libraries can also be exposed in many other ways, for instance directly through a REST API or through other orchestration approaches such as decision tables or state machines.

Possibly the most important design features of CQDefine are testability and debugability. The knowledge layer should have extensive unit tests that take into account as many possible inputs and data model nuances as possible. MockData should be generated for each test case, and tests should be written to cover edge cases. This approach can drastically improve the reliability of production code.

Basic Retrieve

First we look at a few data retrieval examples. We return either a Ternary operator or a custom data structure.

Parameterized Retrieve

Then we look at an example of how an input to a function can be parameterized allowing for more flexible code re-use.