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

Implement stub wrapper #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on: push

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x, 22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run-script coverage
- uses: codecov/codecov-action@v4
22 changes: 2 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
# clinical-trial-matching-service-template
# clinical-trial-matching-service-siec

Template which streamlines the process of writing a server for clinical trial matching system.

For more information on the architecture and data schemas of the clinical trial matching system, please visit the clinical-trial-matching-engine [wiki](https://github.com/mcode/clinical-trial-matching-engine/wiki).

These steps give an overview of steps you need to take to get the template into a running server that will send requests to the underlying matching service.

## Basic Steps:

1. Open `src/query.ts`. This file contains a stub implementation of the query mapper - the function that receives a FHIR Bundle of patient data and uses it to look up matching clinical trials.
- The `createClinicalTrialLookup()` function creates the underlying function used. It creates a closure over the necessary configuration information, and handles creating a new `APIQuery` object based on patient data and then calling `sendQuery()` to send the actual query.
- Edit `APIQuery` to pull any necessary information out of the patient data and its `toQuery()` function to generate an appropriate query. Learn more about the patient bundle that will be sent [in the matching engine wiki](https://github.com/mcode/clinical-trial-matching-engine/wiki/Data-Model).
- Fill out your `QueryResponse` and `QueryTrial` types to match what the service returns.
- Modify `QueryErrorResponse` and `sendQuery()` to handle errors returned by the service.
2. Open `src/researchstudy-mapping.ts`. This file contains a single function: `convertToResearchStudy` function, which handles converting individual trials as returned from the underlying service into FHIR ResearchStudy objects. While the stub is small, the bulk of additional code is likely to be in here.
3. Open `src/server.ts`. This contains the code to start the service, as well as load configuration data. The default is very simplistic, it simply loads configuration via `configFromEnv()` and passes it off to the `createClinicalTrialLookup()` function. The default implementation uses [dotenv-flow](https://github.com/kerimdzhanov/dotenv-flow) to load configuration from local `.env` files - see the dotenv-flow documentation for more details about how it decides which files and in what order to load from. It may be worth changing the environment variable used to set the environment (defaults to `NODE_ENV`) and the default environment that is used (defaults to `"development"`).

Note that the function exported from this module is used by `start.js` to start the server. While additional optional arguments will be called, the implementation of invoking it in `start.js` expects it to work when called with no arguments and to return a Promise. The Promise is used solely to catch errors - if the Promise is rejected, the error is printed using `console.error`, but nothing is done when the Promise resolves successfully as in that case the server should now be running in the background.

You may need to further tweek the code stubs provided, and there are other ways to implement a service implemenation. (For example, you could simply extend `ClinicalTrialMatchingService` and pass it a matcher that invokes a method on the generated class.) However the steps above should provide the basic stubs necessary to generate an implementation of a matching service.
This is a wrapper between the [Clinical Trial Matching App](https://github.com/mcode/clinical-trial-matching-app) and the backend [Structured Inclusion Exclusion Criteria (SIEC) Engine](https://github.com/mcode/siec-engine).

# Requirements

Expand Down
Loading
Loading