Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '12.x'
node-version: '14.x'
- run: npm install
- run: npm run lint
- run: npm run prettier
Expand All @@ -22,7 +22,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [12]
node-version: [14]

steps:
- uses: actions/checkout@v1
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ COVERAGE/
logs/
node_modules/
dist/
.idea/
.idea/
.DS_Store
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
"url": "git+ssh://git@bitbucket.org/asymmetrik/carejourney-cds.git"
},
"jest": {
"moduleNameMapper": {
"axios": "axios/dist/node/axios.cjs"
},
"preset": "ts-jest",
"testEnvironment": "node",
"transform": {
Expand All @@ -51,10 +54,12 @@
"dependencies": {
"@projecttacoma/node-fhir-server-core": "^2.2.8",
"@types/fhir": "^0.0.35",
"axios": "^1.2.1",
"body-parser": "^1.19.0",
"conventional-changelog-cli": "^2.0.34",
"cors": "^2.8.5",
"express": "^4.17.1",
"fhirpath": "^3.2.0",
"lodash": "^4.17.19",
"moment": "^2.24.0",
"moment-timezone": "^0.5.40",
Expand All @@ -77,11 +82,13 @@
"@types/uuid": "^9.0.0",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"axios-mock-adapter": "^1.21.2",
"eslint": "^8.28.0",
"eslint-config-prettier": "^6.10.1",
"jest": "^27.4.5",
"jest-extended": "^1.2.0",
"json-diff": "^0.9.0",
"nock": "^13.2.9",
"nodemon": "^2.0.20",
"prettier": "^2.0.5",
"ts-jest": "^27.1.2",
Expand Down
16 changes: 10 additions & 6 deletions src/fhir/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Globals } from '../globals';
import * as path from 'path';
import * as fs from 'fs';
import * as process from 'process';
import crypto from 'crypto';

const re = /(?:\.([^.]+))?$/;

Expand Down Expand Up @@ -43,7 +44,7 @@ export class FhirUtilities {
let id = '';
if (!resource.id) {
// If no resource ID was provided, generate one.
id = uuidv1();
id = crypto.randomUUID();
} else {
id = resource.id;
}
Expand Down Expand Up @@ -77,6 +78,7 @@ export class FhirUtilities {
}

const Resource = resolveSchema(baseVersion, resource.resourceType);

const fhirResource = new Resource(resource);

// Create the resource's metadata
Expand All @@ -87,7 +89,7 @@ export class FhirUtilities {
});

if (collectionString === '') {
return reject(' Unsupported FHIR Resource Type');
reject(' Unsupported FHIR Resource Type');
}
const collection = db.collection(collectionString);

Expand All @@ -104,7 +106,8 @@ export class FhirUtilities {
collection.insert(doc, (err: any) => {
if (err) {
console.log(' Error with %s.create: ', resource.resourceType, err.message);
return reject(err);
reject(err);
return;
} else {
console.log(' Successfully added ' + resource.resourceType + ' -- ' + id);
}
Expand All @@ -113,12 +116,13 @@ export class FhirUtilities {
const history_collection = db.collection(historyCollectionString);

// Insert our patient record to history but don't assign _id
return history_collection.insert(history_doc, (err2: any) => {
history_collection.insert(history_doc, (err2: any) => {
if (err2) {
console.log(' Error with %sHistory.create: ', resource.resourceType, err2.message);
return reject(err2);
reject(err2);
return;
}
return resolve({ id: doc.id, resource_version: doc.meta.versionId });
resolve({ id: doc.id, resource_version: doc.meta.versionId });
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/TingoDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ export class TingoDatabase extends Database {
const tingo = new tingodb();
this.database = new tingo.Db(this.location, {});
this.client = '';
return resolve(this.database);
resolve(this.database);
});
}
59 changes: 59 additions & 0 deletions src/lib/__tests__/fixtures/library.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"resourceType": "Library",
"id": "HomeBloodGlucoseMonitorFaceToFace-prepopulation",
"url": "http://hl7.org/fhir/us/davinci-dtr/Library/HomeBloodGlucoseMonitorFaceToFace-prepopulation",
"name": "HomeBloodGlucoseMonitorFaceToFace-prepopulation",
"version": "0.0.1",
"title": "Blood Glucose Monitor Face To Face Prepopulation",
"status": "draft",
"type": {
"coding": [
{
"code": "logic-library"
}
]
},
"relatedArtifact": [
{
"type": "depends-on",
"resource": "Library/FHIRHelpers-4.0.0"
},
{
"type": "depends-on",
"resource": "Library/CDS_Connect_Commons_for_FHIRv400"
},
{
"type": "depends-on",
"resource": "Library/DTRHelpers"
}
],
"dataRequirement": [
{
"type": "Condition",
"codeFilter": [
{
"path": "code",
"valueSet": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1219.35"
}
]
},
{
"type": "MedicationValueSet",
"codeFilter": [
{
"path": "code",
"valueSet": "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1219.85"
}
]
},
{
"type": "MedicationStatement"
}
],
"content": [
{
"contentType": "application/elm+json",
"url": "files/HomeBloodGlucoseMonitor/r4/HomeBloodGlucoseMonitorFaceToFacePrepopulation-0.0.1.cql"
}
]
}
Loading