Skip to content

Commit

Permalink
Publishable write (#101)
Browse files Browse the repository at this point in the history
* Publishable minimum write capabilities

* Add lost function and update for tests

* Add script and cleaner logic sharing

* Add tests and test fixes

* bundle transaction checks and capability statement

* remove TODOs

* Address initial PR comments

* transact bundles synchronously

Also add notes about potential race condition (task already exists for it)

* disable eslint rule for two lines

* handle shareable artifact required fields

* Remove directory-upload and re-use test resource base
  • Loading branch information
lmd59 authored Jun 28, 2024
1 parent 873349f commit 299f778
Show file tree
Hide file tree
Showing 19 changed files with 808 additions and 204 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,19 @@ cp app/.env.example app/.env.local
cp service/.env.example service/.env
```

Make any changes to point to the measure repository service, Mongo database, and optionally the VSAC API. `0.0.0.0` may be a more appropriate database address than `localhost` for certain environment setups.
Make any changes to point to the measure repository service, Mongo database, and optionally the VSAC API. `0.0.0.0` may be a more appropriate database address than `localhost` for certain environment setups.
Additionally, some versions of tooling may have issues with running `next dev` within workspaces. Disabling telemetry can prevent the disallowed npm command from running under the hood.
```bash
npx next telemetry disable
```


### Mongo Replica Set Setup

Use the mongodb configuration file to configure the single node replica set. For more information about the configuration file and system location, see the mongodb [configuration file documentation](https://www.mongodb.com/docs/manual/reference/configuration-options/).

1. First shutdown any currently running mongodb standalone instances: `brew services stop mongodb-community`.
2. Locate your [Mongo Configuration File](https://www.mongodb.com/docs/compass/current/settings/config-file/#:~:text=For%20macOS%20and%20Linux%2C%20the,%5Cmongodb%2Dcompass.). _System dependent but may be found at `/usr/local/etc/mongod.conf`_.
2. Locate your [Mongo Configuration File](https://www.mongodb.com/docs/manual/reference/configuration-options/). _System dependent but may be found at `/opt/homebrew/etc/mongod.conf`_.
3. Add this replication set configuration to the mongo configuration file:

```
Expand Down
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"test:service": "npm run test --workspace=service"
},
"devDependencies": {
"@types/lodash": "^4.17.4",
"concurrently": "^7.6.0"
}
}
3 changes: 2 additions & 1 deletion service/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
PORT=3000
HOST='localhost'
DATABASE_URL='mongodb://localhost:27017/measure-repository?replicaSet=rs0'
VSAC_API_KEY="<your-api-key>" # Add if you plan on using the `include-terminology` query param
VSAC_API_KEY="<your-api-key>" # Add if you plan on using the `include-terminology` query param
AUTHORING=true # Make false if this is running as a publishable repository instead
1 change: 1 addition & 0 deletions service/.env.test
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
VSAC_API_KEY="example-api-key"
AUTHORING=true
33 changes: 27 additions & 6 deletions service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,11 @@ The server supports transaction bundle uploads via the `:/base_version/` endpoin
- The request body must be a FHIR bundle of type `transaction`.
- The entries SHALL be of resource type "Measure" or "Library." An error will be thrown otherwise.

For ease of use, the `service/directory-upload.sh` script can be used to run the transaction bundle upload on an input directory. Details are as follows:
For ease of use, an upload workflow similar to `db:loadBundle` can be done by POSTing a directory of transaction bundles rather than directly uploading to the database. While the server is running (script assumes default location http://localhost:3000/4_0_1), run the following script with the desired directory path:

- The `-h` option can be used to view usage.
- A server URL must be supplied via the `-s` option.
- A directory path must be supplied via the `-d` option.
- The script can support nested directories (one level deep).
```
npm run db:postBundle <path to directory> <optional server location>
```

## Usage

Expand All @@ -95,12 +94,34 @@ When sending requests, ensure that the `"Content-type": "application/json+fhir"`

### CRUD Operations

This server can be configured as a [Publishable Measure Repository](https://build.fhir.org/ig/HL7/cqf-measures/measure-repository-service.html#publishable-measure-repository) or an [Authoring Measure Repository](https://build.fhir.org/ig/HL7/cqf-measures/measure-repository-service.html#authoring-measure-repository) using the `AUTHORING` environment variable. The minimum write capabilities for these repositories are described further in the [CRMI Publishable Artifact Repository](https://hl7.org/fhir/uv/crmi/1.0.0-snapshot/artifact-repository-service.html#publishable-artifact-repository) and [CRMI Authoring Artifact Repository](https://hl7.org/fhir/uv/crmi/1.0.0-snapshot/artifact-repository-service.html#authoring-artifact-repository) specifications, respectively. The write capabilities implemented in this server are further detailed for the create, update, and delete operations described below.

This server currently supports the following CRUD operations:

- Read by ID with `GET` to endpoint: `4_0_1/<resourceType>/<resourceId>`
- Create resource (Library or Measure) with `POST` to endpoint: `4_0_1/<resourceType>`
- Publishable:
- Supports the _Publishable_ minimum write capability _publish_
- Artifact must be in active status and conform to appropriate shareable and publishable profiles
- Authoring:
- Supports the additional _Authoring_ capability _submit_
- Artifact must be in draft status

- Update resource (Library or Measure) with `PUT` to endpoint: `4_0_1/<resourceType>/<resourceId>`
_More functionality coming soon!_
- Publishable:
- Supports the _Publishable_ minimum write capability _retire_
- Artifact must be in active status and may only change the status to retired and update the date (and other metadata appropriate to indicate retired status)
- Authoring:
- Supports the additional _Authoring_ capability _revise_
- Artifact must be in (and remain in) draft status

- Delete resource (Library or Measure) with `DELETE` to endpoint: `4_0_1/<resourceType>/<resourceId>`
- Publishable:
- Supports the _Publishable_ minimum write capability _archive_
- Artifact must be in retired status
- Authoring:
- Supports the additional _Authoring_ capability _withdraw_
- Artifact must be in draft status

### Search

Expand Down
74 changes: 0 additions & 74 deletions service/directory-upload.sh

This file was deleted.

1 change: 1 addition & 0 deletions service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"db:reset": "ts-node ./scripts/dbSetup.ts reset",
"db:setup": "ts-node ./scripts/dbSetup.ts create",
"db:loadBundle": "ts-node ./scripts/dbSetup.ts loadBundle",
"db:postBundle": "ts-node ./scripts/dbSetup.ts postBundle",
"lint": "eslint \"./src/**/*.{js,ts}\"",
"lint:fix": "eslint \"./src/**/*.{js,ts}\" --fix",
"prettier": "prettier --check \"./src/**/*.{js,ts}\"",
Expand Down
Loading

0 comments on commit 299f778

Please sign in to comment.