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
11 changes: 9 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
{
"extends": [
"prettier"
"prettier",
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"plugins": [
"@typescript-eslint"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
"semi": ["error", "always"],
"semi": ["off"],
"@typescript-eslint/semi": ["error", "always"],
"quotes": ["error", "single", { "avoidEscape": true }],

}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ package-lock.json
COVERAGE/
logs/
node_modules/
dist/
.idea/
6 changes: 6 additions & 0 deletions nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"watch": ["src"],
"ext": ".ts,.js",
"ignore": [],
"exec": "ts-node ./src/main.ts"
}
34 changes: 25 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,25 @@
"doc": "doc"
},
"scripts": {
"develop": "node src/scripts/nodemon.js",
"start": "node src/scripts/serve.js",
"develop": "node dist/scripts/develop.js",
"start": "ts-node-dev src/scripts/serve.ts",
"test": "jest --maxWorkers=4 --coverage --detectOpenHandles",
"lint": "eslint \"**/*.{js,ts}\"",
"lint:fix": "eslint \"**/*.{js,ts}\" --quiet --fix",
"prettier": "prettier --check \"**/*.{js,ts}\"",
"prettier:fix": "prettier --write \"**/*.{js,ts}\"",
"changelog": "conventional-changelog -p angular -s -i CHANGELOG.md"
"prettier:fix": "prettier --write \"**/*.{js,ts}\""
},
"repository": {
"type": "git",
"url": "git+ssh://git@bitbucket.org/asymmetrik/carejourney-cds.git"
},
"jest": {
"preset":"ts-jest",
"testEnvironment": "node",
"transform": {
"^.+\\.ts?$": "ts-jest"
},
"transformIgnorePatterns": ["<rootDir>/node_modules/"],
"testPathIgnorePatterns": [
"<rootDir>/src/config/env/test.js"
],
Expand All @@ -42,26 +47,37 @@
]
},
"dependencies": {
"@types/fhir": "^0.0.35",
"body-parser": "^1.19.0",
"conventional-changelog-cli": "^2.0.34",
"cors": "^2.8.5",
"express": "^4.17.1",
"lodash": "^4.17.19",
"moment": "^2.24.0",
"morgan": "^1.9.1",
"nodemon": "^1.19.4",
"winston": "^3.2.1",
"winston-daily-rotate-file": "^4.2.1"
},
"devDependencies": {
"prettier": "^2.0.5",
"eslint": "^8.5.0",
"@types/cors": "^2.8.12",
"@types/express": "^4.17.14",
"@types/jest": "^27.5.2",
"@types/lodash": "^4.14.188",
"@types/morgan": "^1.9.3",
"@types/node": "^18.11.9",
"@types/nodemon": "^1.19.2",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"eslint": "^8.28.0",
"eslint-config-prettier": "^6.10.1",
"jest": "^27.4.5",
"jest-extended": "^1.2.0",
"json-diff": "^0.9.0",
"nodemon": "^2.0.20",
"prettier": "^2.0.5",
"ts-jest": "^27.1.2",
"ts-node": "^9.1.1",
"typescript": "^4.8.4"
"ts-node": "^10.9.1",
"ts-node-dev": "^2.0.0",
"typescript": "^4.9.3"
}
}
76 changes: 76 additions & 0 deletions src/cards/Card.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { Resource } from 'fhir/r4';

interface Source {
label: string;
url: URL;
icon?: URL;
}
interface Action {
type: string;
description: string;
resource?: Resource | string;
}
interface Suggestion {
label: string;
uuid?: string;
actions: Action[];
}
export interface Link {
label: string;
url: URL;
type: linkType;
appContext?: string;
}
type linkType = 'absolute' | 'smart';
type indicatorType = 'info' | 'warning' | 'critical';
export default class Card {
summary: string;
detail?: string;
indicator: indicatorType;
source: Source;
suggestions?: Suggestion[];
selectionBehavior?: string;
links?: Link[];

constructor(summary: string, detail: string, source: Source, indicator: indicatorType = 'info') {
this.summary = summary;
this.detail = detail;
this.source = source;
this.indicator = indicator;
}

get card() {
return this;
}
addSuggestions(suggestions: Suggestion[]) {
if (this.suggestions) {
this.suggestions = this.suggestions.concat(suggestions);
} else {
this.suggestions = suggestions;
}
}
addSuggestion(suggestion: Suggestion) {
if (this.suggestions) {
this.suggestions?.push(suggestion);
} else {
this.suggestions = [suggestion];
}
}
addLinks(links: Link[]) {
if (this.links) {
this.links = this.links.concat(links);
} else {
this.links = links;
}
}
addLink(link: Link) {
if (this.links) {
this.links?.push(link);
} else {
this.links = [link];
}
}
generateCard() {
return this;
}
}
6 changes: 4 additions & 2 deletions src/config.js → src/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
module.exports = {
export default {
server: {
port: 8090,
discoveryEndpoint: '/cds-services'
},

smart: {
endpoint: 'http://localhost:3005/launch'
},
logging: {
level: 'info'
}
Expand Down
9 changes: 9 additions & 0 deletions src/hooks/Hook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import ServicePrefetch from './Prefetch/ServicePrefetch';

export default interface Hook {
id: string;
hook: string;
name: string;
description: string;
prefetch: ServicePrefetch;
}
23 changes: 23 additions & 0 deletions src/hooks/OrderSign.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import Hook from './Hook';
import OrderSignPrefetch from './Prefetch/OrderSignPrefetch';

export default class OrderSign implements Hook {
id: string;
hook: string;
name: string;
description: string;
prefetch: OrderSignPrefetch;
constructor(
id: string,
hook: string,
name: string,
description: string,
prefetch: OrderSignPrefetch
) {
this.id = id;
this.hook = hook;
this.name = name;
this.description = description;
this.prefetch = prefetch;
}
}
26 changes: 26 additions & 0 deletions src/hooks/OrderSignRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Bundle } from 'fhir/r4';
import { Url } from 'url';
import OrderSignRequestPrefetch from './Prefetch/OrderSignRequestPrefetch';
// https://cds-hooks.hl7.org/1.0/#fhir-resource-access
interface FhirAuthorization {
token_type: string;
expires_in: number;
scope: string;
subject: string;
}
// https://cds-hooks.org/hooks/order-sign/#context
interface OrderSignContext {
userId: string;
patientId: string;
encounterId?: string;
draftOrders: Bundle;
}
// https://cds-hooks.hl7.org/1.0/#calling-a-cds-service
export default interface OrderSignRequest {
hook: string;
hookInstance: string;
fhirServer: Url;
fhirAuthorization: FhirAuthorization;
context: OrderSignContext;
prefetch: OrderSignRequestPrefetch;
}
5 changes: 5 additions & 0 deletions src/hooks/Prefetch/OrderSignPrefetch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default interface OrderSignPrefetch {
patient?: string;
request?: string;
practitioner?: string;
}
7 changes: 7 additions & 0 deletions src/hooks/Prefetch/OrderSignRequestPrefetch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { MedicationRequest, Patient, Practitioner } from 'fhir/r4';
import RequestPrefetch from './RequestPrefetch';
export default interface OrderSignRequestPrefetch extends RequestPrefetch {
patient: Patient;
request: MedicationRequest;
practitioner: Practitioner;
}
5 changes: 5 additions & 0 deletions src/hooks/Prefetch/RequestPrefetch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Resource } from 'fhir/r4';

export default interface RequestPrefetch {
[key: string]: Resource;
}
3 changes: 3 additions & 0 deletions src/hooks/Prefetch/ServicePrefetch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default interface ServicePrefetch {
patient?: string;
}
98 changes: 0 additions & 98 deletions src/hooks/rems.hook.js

This file was deleted.

Loading