PK
rf}X 3 ehealth-trhc-medwise-risk-api-medstmt-sample-1.0.0/PK
rf}X 7 ehealth-trhc-medwise-risk-api-medstmt-sample-1.0.0/lib/PK
rf}X©¯z Þ Þ f ehealth-trhc-medwise-risk-api-medstmt-sample-1.0.0/lib/ehealth-trhc-medwise-risk-api-medstmt-sample.jsrequire('isomorphic-fetch')
// authentication url
const authUrl = process.env.AUTH_URL
// create basic authentication with id and secret
const basicAuth = Buffer.from(`${process.env.MW_RISK_API_TEST_APP_CLIENTID}:${process.env.MW_RISK_API_TEST_APP_SECRET}`).toString('base64')
// get access token from authentication server
const doc = await fetch(authUrl, {
headers: {
Authorization: `Basic ${basicAuth}`,
'Content-Type': 'application/json'
},
method: 'POST'
}).then(res => res.json())
const accessToken = doc.access_token
console.log('access token', accessToken)
;
const { pluck, prop, map } = require('ramda')
const patientId = 'smart-1685497'
const patient = await fetch('https://r2.smarthealthit.org/Patient/' + patientId)
.then(res => res.json())
.then(patient => ({resource: patient}))
const medicationStatement = {
"resourceType": "MedicationStatement",
"id": "example006",
"text": {
"status": "generated",
"div": "
Generated Narrative with Details
id: example006
status: active
medication: Amoxicillin (product) (Details : {SNOMED CT code '27658006' = 'p-Hydroxyampicillin', given as 'Amoxicillin (product)'})
effective: 01/02/2014
dateAsserted: 22/02/2014
informationSource: Peter Chalmers
subject: Donald Duck
taken: n
note: Father indicates they miss the occasional dose
dosage:
"
},
"status": "active",
"medicationCodeableConcept": {
"coding": [
{
"system": "http://www.nlm.nih.gov/research/umls/rxnorm",
"code": "308194",
"display": "Amoxicillin 875 MG Oral Tablet"
}
]
},
"effectiveDateTime": "2014-02-01",
"dateAsserted": "2014-02-22",
"informationSource": {
"reference": "RelatedPerson/peter",
"display": "Peter Chalmers"
},
"subject": {
"reference": "Patient/pat1",
"display": "Donald Duck"
},
"taken": "n",
"note": [
{
"text": "Father indicates they miss the occasional dose"
}
],
"dosage": [
{
"sequence": 1,
"text": "5ml three times daily",
"asNeededBoolean": false,
"route": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "260548002",
"display": "Oral"
}
]
},
"doseQuantity": {
"value": 5,
"unit": "mL",
"system": "http://unitsofmeasure.org",
"code": "mL"
},
"maxDosePerPeriod": {
"numerator": {
"value": 3
},
"denominator": {
"value": 1,
"system": "http://unitsofmeasure.org",
"code": "d"
}
}
}
]
}
//.then(bundle => pluck('resource', prop('entry', bundle)))
//.then(pluck('medicationCodeableConcept'))
//.then(map(med => ({resource: { resourceType: 'Medication', code: med }})))
const medications = [{resource: medicationStatement }]
console.log(JSON.stringify(medications, null, 2))
;
const bundle = {
resourceType: 'Bundle',
type: 'collection',
entry: [
patient,
...medications
]
}
JSON.stringify(bundle, null, 2);
const result = await fetch(`${process.env.MEDWISE_RISK_API_URL}/profiles`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`
},
body: JSON.stringify(bundle)
}).then(res => res.json())
const profileId = result.id
result;
const score = await fetch(`${process.env.MEDWISE_RISK_API_URL}/profiles/${result.id}/riskscore`, {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`
}
})
.then(res => res.json())
score.html;
const matrix = await fetch(`${process.env.MEDWISE_RISK_API_URL}/profiles/${result.id}/matrix`, {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`
}
})
.then(res => res.json())
matrix.html;
const riskFactors = await fetch(`${process.env.MEDWISE_RISK_API_URL}/profiles/${result.id}/risk-factors`, {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`
}
})
.then(res => res.json())
riskFactors.html;
const adverseEffects = await fetch(`${process.env.MEDWISE_RISK_API_URL}/profiles/${result.id}/adverse-effects`, {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`
}
})
.then(res => res.json())
adverseEffects.html;
const scoreData = await fetch(`${process.env.MEDWISE_RISK_API_URL}/profiles/${result.id}/scoredata`, {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`
}
})
.then(res => res.json())
scoreData;
const cachedBundle = await fetch(`${process.env.MEDWISE_RISK_API_URL}/profiles/${result.id}`, {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`
}
})
.then(res => res.json())
cachedBundle;
PK
rf}X‘÷°ÊI I ? ehealth-trhc-medwise-risk-api-medstmt-sample-1.0.0/package.json{
"name": "@runkit/tripott_ehealth-trhc-medwise-risk-api-medstmt-sample",
"version": "1.0.0",
"main": "./lib/ehealth-trhc-medwise-risk-api-medstmt-sample",
"dependencies": {
"isomorphic-fetch": "2.2.1",
"ramda": "0.25.0"
},
"scripts": {
"install": "node scripts/install.js"
}
}PK
rf}X³çËtî î F ehealth-trhc-medwise-risk-api-medstmt-sample-1.0.0/npm-shrinkwrap.json{
"name": "@runkit/tripott_ehealth-trhc-medwise-risk-api-medstmt-sample",
"version": "1.0.0",
"dependencies": {
"isomorphic-fetch": {
"version": "2.2.1",
"from": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz",
"dependencies": {
"node-fetch": {
"version": "1.7.3",
"from": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz",
"dependencies": {
"encoding": {
"version": "0.1.12",
"from": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz",
"dependencies": {
"iconv-lite": {
"version": "0.4.24",
"from": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"dependencies": {
"safer-buffer": {
"version": "2.1.2",
"from": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz"
}
}
}
}
},
"is-stream": {
"version": "1.1.0",
"from": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz"
}
}
},
"whatwg-fetch": {
"version": "3.0.0",
"from": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz"
}
}
},
"ramda": {
"version": "0.25.0",
"from": "https://registry.npmjs.org/ramda/-/ramda-0.25.0.tgz"
}
}
}PK
rf}X ; ehealth-trhc-medwise-risk-api-medstmt-sample-1.0.0/scripts/PK
rf}X çšCZ Z E ehealth-trhc-medwise-risk-api-medstmt-sample-1.0.0/scripts/install.jsvar fs = require('fs');
var path = require('path');
var json = require("../package.json");
var match = json.name.match(/^@runkit\/(.*)_(.*)$/);
// check if our module name actually makes sense, otherwise abort
if (!match) throw new Error("Unknown package structure!");
// check if we're actually inside a node_modules/@runkit folder, otherwise don't create symlinks
if (path.basename(path.dirname(process.cwd())) !== "@runkit" || path.basename(path.dirname(path.dirname(process.cwd()))) !== "node_modules") {
console.log("Not installing as notebook: " + process.cwd());
return;
}
console.log("creating notebook symlinks");
var userPath = path.join("..", match[1]);
var repoPath = path.join(userPath, match[2]);
mkdir(userPath);
mkdir(repoPath);
var branchMatch = json.version.match(/^0\.0\.0\-(.*)$/);
if (branchMatch) {
var branchPath = path.join(repoPath, "branches");
mkdir(branchPath);
var versionPath = path.join(branchPath, branchMatch[1]);
var relativePath = path.join("..", "..", "..", path.basename(process.cwd()));
unlink(versionPath);
fs.symlinkSync(relativePath, versionPath);
} else {
var relativePath = path.join("..", "..", path.basename(process.cwd()));
var latestPath = path.join(repoPath, "latest");
var versionPath = path.join(repoPath, json.version);
unlink(latestPath);
fs.symlinkSync(relativePath, latestPath);
unlink(versionPath);
fs.symlinkSync(relativePath, versionPath);
}
function mkdir(p) {
try {
fs.mkdirSync(p);
} catch (e) {}
}
function unlink(p) {
try {
fs.unlinkSync(p);
} catch (e) {}
}PK
rf}X 3 ehealth-trhc-medwise-risk-api-medstmt-sample-1.0.0/PK
rf}X 7 Q ehealth-trhc-medwise-risk-api-medstmt-sample-1.0.0/lib/PK
rf}X©¯z Þ Þ f ¦ ehealth-trhc-medwise-risk-api-medstmt-sample-1.0.0/lib/ehealth-trhc-medwise-risk-api-medstmt-sample.jsPK
rf}X‘÷°ÊI I ? ehealth-trhc-medwise-risk-api-medstmt-sample-1.0.0/package.jsonPK
rf}X³çËtî î F ® ehealth-trhc-medwise-risk-api-medstmt-sample-1.0.0/npm-shrinkwrap.jsonPK
rf}X ; ehealth-trhc-medwise-risk-api-medstmt-sample-1.0.0/scripts/PK
rf}X çšCZ Z E Y ehealth-trhc-medwise-risk-api-medstmt-sample-1.0.0/scripts/install.jsPK &