Skip to content

Commit

Permalink
Address initial PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lmd59 committed Jun 24, 2024
1 parent 0246397 commit f920bbc
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 21 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
20 changes: 11 additions & 9 deletions service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,31 +95,33 @@ 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 [CRMI Publishable Artifact Repository](https://hl7.org/fhir/uv/crmi/1.0.0-snapshot/artifact-repository-service.html#publishable-artifact-repository) minimum write capability _publish_
- Supports the _Publishable_ minimum write capability _publish_
- Artifact must be in active status and conform to appropriate shareable and publishable profiles
- Authoring (In Progress):
- Supports the [CRMI Authoring Artifact Repository](https://hl7.org/fhir/uv/crmi/1.0.0-snapshot/artifact-repository-service.html#authoring-artifact-repository) additional authoring capability _submit_
- 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>`
- Publishable:
- Supports the [CRMI Publishable Artifact Repository](https://hl7.org/fhir/uv/crmi/1.0.0-snapshot/artifact-repository-service.html#publishable-artifact-repository) minimum write capability _retire_
- 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 (In Progress):
- Supports the [CRMI Authoring Artifact Repository](https://hl7.org/fhir/uv/crmi/1.0.0-snapshot/artifact-repository-service.html#authoring-artifact-repository) additional authoring capability _revise_
- 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 [CRMI Publishable Artifact Repository](https://hl7.org/fhir/uv/crmi/1.0.0-snapshot/artifact-repository-service.html#publishable-artifact-repository) minimum write capability _archive_
- Supports the _Publishable_ minimum write capability _archive_
- Artifact must be in retired status
- Authoring (In Progress):
- Supports the [CRMI Authoring Artifact Repository](https://hl7.org/fhir/uv/crmi/1.0.0-snapshot/artifact-repository-service.html#authoring-artifact-repository) additional authoring capability _withdraw_
- Authoring:
- Supports the additional _Authoring_ capability _withdraw_
- Artifact must be in draft status

### Search
Expand Down
15 changes: 13 additions & 2 deletions service/scripts/dbSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ async function deleteCollections() {
/*
* Gathers necessary file path(s) for bundle(s) to upload, then uploads all measure and
* library resources found in the bundle(s).
*
* If a connectionURL is provided, then posts the resources to the server at the
* connectionURL (as a transaction bundle), otherwise, loads the resources directly to the database
*/
async function loadBundle(fileOrDirectoryPath: string, connectionURL?: string) {
const status = fs.statSync(fileOrDirectoryPath);
Expand Down Expand Up @@ -68,6 +69,9 @@ async function loadBundle(fileOrDirectoryPath: string, connectionURL?: string) {
}
}

/*
* POSTs a transaction bundle to url
*/
async function transactBundle(bundle: fhir4.Bundle, url: string) {
if (bundle.entry) {
// only upload Measures and Libraries
Expand Down Expand Up @@ -100,6 +104,9 @@ async function transactBundle(bundle: fhir4.Bundle, url: string) {
}
}

/*
* Loads all resources found in the bundle at filePath, by POSTing them to the provided url
*/
async function postBundleResources(filePath: string, url: string) {
console.log(`Loading bundle from path ${filePath}`);

Expand All @@ -118,7 +125,7 @@ async function postBundleResources(filePath: string, url: string) {
}

/*
* Loads all measure or library resources found in the bundle located at param filePath
* Loads all resources found in the bundle at filePath, directly to the database
*/
async function uploadBundleResources(filePath: string) {
console.log(`Loading bundle from path ${filePath}`);
Expand Down Expand Up @@ -171,6 +178,10 @@ async function uploadBundleResources(filePath: string) {
}
}

/*
* Convenience modification of an array of entries to create isOwned relationships and coerce to status active.
* This let's us massage existing data that may not have the appropriate properties needed for a Publishable Measure Repository
*/
function modifyEntriesForUpload(entries: fhir4.BundleEntry<fhir4.FhirResource>[]) {
// pre-process to find owned relationships
const ownedUrls: string[] = [];
Expand Down
12 changes: 6 additions & 6 deletions service/src/services/BaseService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async function uploadResourcesFromBundle(entries: DetailedEntry[]) {

// pre-process to find owned relationships and error as needed
const ownedUrls: string[] = [];
const modifedRequestsArray = scrubbedEntries.map(entry => {
const modifiedRequestsArray = scrubbedEntries.map(entry => {
if (entry.request) {
const { method } = entry.request;
if (method !== 'PUT' && method !== 'POST') {
Expand All @@ -61,7 +61,7 @@ async function uploadResourcesFromBundle(entries: DetailedEntry[]) {
}
});

const requestsArray = modifedRequestsArray.map(async entry => {
const requestsArray = modifiedRequestsArray.map(async entry => {
// add library owned extension
entry = addLibraryIsOwned(entry, ownedUrls);
return insertBundleResources(entry as DetailedEntry);
Expand All @@ -84,10 +84,10 @@ async function insertBundleResources(entry: DetailedEntry) {
}
} else {
if (entry.resource.id) {
const oldResource = (await findResourceById(
entry.resource.id,
entry.resource.resourceType
)) as fhir4.Library | null;
const oldResource = (await findResourceById(entry.resource.id, entry.resource.resourceType)) as
| fhir4.Library
| fhir4.Measure
| null;
if (oldResource) {
checkFieldsForUpdate(entry.resource, oldResource);
} else {
Expand Down
1 change: 1 addition & 0 deletions service/src/services/LibraryService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export class LibraryService implements Service<fhir4.Library> {
/**
* result of sending a PUT request to {BASE_URL}/4_0_1/Library/{id}
* updates the library with the passed in id using the passed in data
* or creates a library with passed in id if it does not exist in the database
*/
async update(args: RequestArgs, { req }: RequestCtx) {
logger.info(`PUT /Library/${args.id}`);
Expand Down
4 changes: 2 additions & 2 deletions service/src/services/MeasureService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ export class MeasureService implements Service<fhir4.Measure> {
}

/**
* result of sending a DELETE request to {BASE_URL}/4_0_1/Library/{id}
* deletes the library with the passed in id if it exists in the database
* result of sending a DELETE request to {BASE_URL}/4_0_1/measure/{id}
* deletes the measure with the passed in id if it exists in the database
*/
async remove(args: RequestArgs) {
const resource = (await findResourceById(args.id, 'Measure')) as fhir4.Measure | null;
Expand Down

0 comments on commit f920bbc

Please sign in to comment.