Skip to content

Commit

Permalink
feat: refactored the evaluation logic into the auc module.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carl Anderson committed Nov 20, 2019
1 parent ea357e7 commit 902b947
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 100 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ V3 TODO
- [x] Make a CDS Hook Service to *always* launch a SMART card for draft orders
- [x] Refactor the AUC logic into a module, enabling use in the hook too.
- [x] Write a new CDS Hook server to be run with npm
- [ ] Complete the App
- [x] Complete the App
- [x] Enable the EHR to close the form with a `ui.done` message
- [x] Enable the form to read the draft order from the fhir client on load
- [x] Enable writes to the form to update the draft order in the EHR
Expand Down
12 changes: 11 additions & 1 deletion auc.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ class Criterion {
}
};

function evaluate(order, reasons) {
if (order) {
const criterion = criteria[order];
if (criterion && reasons.length) {
return criterion.getRating(new Set(reasons));
}
}
return 'no-guidelines-apply';
}

const criteria = {
'no-procedures-for': new Criterion([[SNOMED.TOOTHACHE]], []),
[CPT.CT_HEAD_NO_CONTRAST]: new Criterion([[SNOMED.HEADACHE, SNOMED.OPTIC_DISC_EDEMA]], []),
Expand All @@ -55,5 +65,5 @@ const criteria = {
};

module.exports = {
CPT, SNOMED, criteria, getRating: Criterion.prototype.getRating,
CPT, SNOMED, criteria, evaluate, getRating: Criterion.prototype.getRating,
};
13 changes: 2 additions & 11 deletions cds-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,6 @@ function getReasons(serviceRequest) {
.map(coding => coding.code).flat();
}

function getRating(orders, reasons) {
if (orders.length) {
const criterion = auc.criteria[orders[0]];
if (criterion && reasons.length) {
return criterion.getRating(new Set(reasons));
}
}
return 'no-guidelines-apply';
}

app.post('/cds-services/demo-auc-app', function(request, response) {
const draftOrder = request.body.context.draftOrders.entry[0];
const serviceRequest = draftOrder.resource;
Expand All @@ -63,7 +53,8 @@ app.post('/cds-services/demo-auc-app', function(request, response) {
return;
}

const card = cardDetails[getRating(orders, indications)];
const rating = auc.evaluate(orders.slice().pop(), reasons);
const card = cardDetails[rating];
const label = 'Click to view the source presentation.';
const sourceUrl = 'https://docs.google.com/presentation/d/1QT6HWPW1Kix656s8hZzCMY7fgkTEEck0_aApBASc7rk/edit?usp=sharing';
const cards = [{
Expand Down
8 changes: 1 addition & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,7 @@
function getRating() {
const order = document.getElementById('orders').value;
const reasons = document.getElementById('indications').value;
if (order) {
const criterion = criteria[order];
if (criterion && reasons) {
return criterion.getRating(new Set([reasons]));
}
}
return 'no-guidelines-apply';
return evaluate(order, [reasons]);
}

function showRating() {
Expand Down
29 changes: 0 additions & 29 deletions index.js

This file was deleted.

45 changes: 0 additions & 45 deletions package-lock.json

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

10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"name": "smart-auc-demo",
"version": "2.0.0",
"description": "A demo AUC consultation app.",
"main": "index.js",
"version": "3.0.0",
"description": "A demo AUC guideline consultation app.",
"main": "index.html",
"scripts": {
"all": "concurrently --kill-others \"npm:cds-services\" \"npm:launch\" \"npm:demo\"",
"all": "concurrently --kill-others \"npm:cds-services\" \"npm:launch\"",
"cds-services": "nodemon ./cds-services.js",
"demo": "nodemon ./index.js",
"launch": "http-server -p 8899 -c-1",
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand All @@ -25,7 +24,6 @@
"concurrently": "^5.0.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"express-session": "^1.17.0",
"fhirclient": "^2.1.0",
"http-server": "^0.11.1",
"jquery": "^3.4.1"
Expand Down

0 comments on commit 902b947

Please sign in to comment.