From 07d104bc0e3c8eedcb04da16f90b9c67c777facb Mon Sep 17 00:00:00 2001 From: Vladimir Ignatov Date: Wed, 19 Jun 2019 07:09:32 -0400 Subject: [PATCH] Changes for R4 #4 --- .eslintrc => .eslintrc.js | 6 +- build/config/r4.json5 | 1048 +++++++++++++++++++++++ config-genrator/generate_config.js | 35 +- src/components/Fhir/ConditionList.js | 6 +- src/components/Fhir/ImmunizationList.js | 4 +- src/components/Fhir/ResourceList.js | 8 +- src/components/PatientDetail/index.js | 8 +- src/config.default.js | 18 +- src/lib/index.js | 25 + 9 files changed, 1120 insertions(+), 38 deletions(-) rename .eslintrc => .eslintrc.js (98%) create mode 100644 build/config/r4.json5 diff --git a/.eslintrc b/.eslintrc.js similarity index 98% rename from .eslintrc rename to .eslintrc.js index 056d18f..7b448f9 100644 --- a/.eslintrc +++ b/.eslintrc.js @@ -1,11 +1,15 @@ -{ +module.exports = { "extends": [ "eslint:recommended", "plugin:react/recommended" ], "parser": "babel-eslint", + "ecmaFeatures": { + "modules": true + }, "parserOptions": { "jsx": true, + "sourceType": "module", "experimentalObjectRestSpread": true }, "env": { diff --git a/build/config/r4.json5 b/build/config/r4.json5 new file mode 100644 index 0000000..aa610b9 --- /dev/null +++ b/build/config/r4.json5 @@ -0,0 +1,1048 @@ +{ + server: { + type: "R4", + url: "https://r4.smarthealthit.org", + tags: [ + { + key: "synthea-5-2019", + label: "Synthea sample patients 5/2019" + } + ], + conditions: { + "5602001": { + description: "Opioid abuse (disorder)", + codes: { + "SNOMED-CT": [ + "5602001" + ] + } + }, + "6072007": { + description: "Bleeding from anus", + codes: { + "SNOMED-CT": [ + "6072007" + ] + } + }, + "7200002": { + description: "Alcoholism", + codes: { + "SNOMED-CT": [ + "7200002" + ] + } + }, + "10509002": { + description: "Acute bronchitis (disorder)", + codes: { + "SNOMED-CT": [ + "10509002" + ] + } + }, + "15777000": { + description: "Prediabetes", + codes: { + "SNOMED-CT": [ + "15777000" + ] + } + }, + "16114001": { + description: "Fracture of ankle", + codes: { + "SNOMED-CT": [ + "16114001" + ] + } + }, + "19169002": { + description: "Miscarriage in first trimester", + codes: { + "SNOMED-CT": [ + "19169002" + ] + } + }, + "22298006": { + description: "Myocardial Infarction", + codes: { + "SNOMED-CT": [ + "22298006" + ] + } + }, + "24079001": { + description: "Atopic dermatitis", + codes: { + "SNOMED-CT": [ + "24079001" + ] + } + }, + "26929004": { + description: "Alzheimer's disease (disorder)", + codes: { + "SNOMED-CT": [ + "26929004" + ] + } + }, + "30832001": { + description: "Rupture of patellar tendon", + codes: { + "SNOMED-CT": [ + "30832001" + ] + } + }, + "33737001": { + description: "Fracture of rib", + codes: { + "SNOMED-CT": [ + "33737001" + ] + } + }, + "35999006": { + description: "Blighted ovum", + codes: { + "SNOMED-CT": [ + "35999006" + ] + } + }, + "36971009": { + description: "Sinusitis (disorder)", + codes: { + "SNOMED-CT": [ + "36971009" + ] + } + }, + "38341003": { + description: "Hypertension", + codes: { + "SNOMED-CT": [ + "38341003" + ] + } + }, + "38822007": { + description: "Cystitis", + codes: { + "SNOMED-CT": [ + "38822007" + ] + } + }, + "39848009": { + description: "Whiplash injury to neck", + codes: { + "SNOMED-CT": [ + "39848009" + ] + } + }, + "40055000": { + description: "Chronic sinusitis (disorder)", + codes: { + "SNOMED-CT": [ + "40055000" + ] + } + }, + "40275004": { + description: "Contact dermatitis", + codes: { + "SNOMED-CT": [ + "40275004" + ] + } + }, + "43878008": { + description: "Streptococcal sore throat (disorder)", + codes: { + "SNOMED-CT": [ + "43878008" + ] + } + }, + "44054006": { + description: "Diabetes", + codes: { + "SNOMED-CT": [ + "44054006" + ] + } + }, + "44465007": { + description: "Sprain of ankle", + codes: { + "SNOMED-CT": [ + "44465007" + ] + } + }, + "47505003": { + description: "Posttraumatic stress disorder", + codes: { + "SNOMED-CT": [ + "47505003" + ] + } + }, + "47693006": { + description: "Rupture of appendix", + codes: { + "SNOMED-CT": [ + "47693006" + ] + } + }, + "48333001": { + description: "Burn injury(morphologic abnormality)", + codes: { + "SNOMED-CT": [ + "48333001" + ] + } + }, + "49436004": { + description: "Atrial Fibrillation", + codes: { + "SNOMED-CT": [ + "49436004" + ] + } + }, + "53741008": { + description: "Coronary Heart Disease", + codes: { + "SNOMED-CT": [ + "53741008" + ] + } + }, + "55680006": { + description: "Drug overdose", + codes: { + "SNOMED-CT": [ + "55680006" + ] + } + }, + "55822004": { + description: "Hyperlipidemia", + codes: { + "SNOMED-CT": [ + "55822004" + ] + } + }, + "58150001": { + description: "Fracture of clavicle", + codes: { + "SNOMED-CT": [ + "58150001" + ] + } + }, + "62106007": { + description: "Concussion with no loss of consciousness", + codes: { + "SNOMED-CT": [ + "62106007" + ] + } + }, + "62564004": { + description: "Concussion with loss of consciousness", + codes: { + "SNOMED-CT": [ + "62564004" + ] + } + }, + "64859006": { + description: "Osteoporosis (disorder)", + codes: { + "SNOMED-CT": [ + "64859006" + ] + } + }, + "65275009": { + description: "Acute Cholecystitis", + codes: { + "SNOMED-CT": [ + "65275009" + ] + } + }, + "65363002": { + description: "Otitis media", + codes: { + "SNOMED-CT": [ + "65363002" + ] + } + }, + "65966004": { + description: "Fracture of forearm", + codes: { + "SNOMED-CT": [ + "65966004" + ] + } + }, + "68496003": { + description: "Polyp of colon", + codes: { + "SNOMED-CT": [ + "68496003" + ] + } + }, + "69896004": { + description: "Rheumatoid arthritis", + codes: { + "SNOMED-CT": [ + "69896004" + ] + } + }, + "70704007": { + description: "Sprain of wrist", + codes: { + "SNOMED-CT": [ + "70704007" + ] + } + }, + "72892002": { + description: "Normal pregnancy", + codes: { + "SNOMED-CT": [ + "72892002" + ] + } + }, + "74400008": { + description: "Appendicitis", + codes: { + "SNOMED-CT": [ + "74400008" + ] + } + }, + "75498004": { + description: "Acute bacterial sinusitis (disorder)", + codes: { + "SNOMED-CT": [ + "75498004" + ] + } + }, + "79586000": { + description: "Tubal pregnancy", + codes: { + "SNOMED-CT": [ + "79586000" + ] + } + }, + "80394007": { + description: "Hyperglycemia (disorder)", + codes: { + "SNOMED-CT": [ + "80394007" + ] + } + }, + "82423001": { + description: "Chronic pain", + codes: { + "SNOMED-CT": [ + "82423001" + ] + } + }, + "83664006": { + description: "Idiopathic atrophic hypothyroidism", + codes: { + "SNOMED-CT": [ + "83664006" + ] + } + }, + "84757009": { + description: "Epilepsy", + codes: { + "SNOMED-CT": [ + "84757009" + ] + } + }, + "87433001": { + description: "Pulmonary emphysema (disorder)", + codes: { + "SNOMED-CT": [ + "87433001" + ] + } + }, + "88805009": { + description: "Chronic congestive heart failure (disorder)", + codes: { + "SNOMED-CT": [ + "88805009" + ] + } + }, + "90560007": { + description: "Gout", + codes: { + "SNOMED-CT": [ + "90560007" + ] + } + }, + "92691004": { + description: "Carcinoma in situ of prostate (disorder)", + codes: { + "SNOMED-CT": [ + "92691004" + ] + } + }, + "93761005": { + description: "Primary malignant neoplasm of colon", + codes: { + "SNOMED-CT": [ + "93761005" + ] + } + }, + "94260004": { + description: "Secondary malignant neoplasm of colon", + codes: { + "SNOMED-CT": [ + "94260004" + ] + } + }, + "95417003": { + description: "Primary fibromyalgia syndrome", + codes: { + "SNOMED-CT": [ + "95417003" + ] + } + }, + "109838007": { + description: "Overlapping malignant neoplasm of colon", + codes: { + "SNOMED-CT": [ + "109838007" + ] + } + }, + "126906006": { + description: "Neoplasm of prostate", + codes: { + "SNOMED-CT": [ + "126906006" + ] + } + }, + "127013003": { + description: "Diabetic renal disease (disorder)", + codes: { + "SNOMED-CT": [ + "127013003" + ] + } + }, + "127295002": { + description: "Traumatic brain injury (disorder)", + codes: { + "SNOMED-CT": [ + "127295002" + ] + } + }, + "128613002": { + description: "Seizure disorder", + codes: { + "SNOMED-CT": [ + "128613002" + ] + } + }, + "156073000": { + description: "Fetus with unknown complication", + codes: { + "SNOMED-CT": [ + "156073000" + ] + } + }, + "162573006": { + description: "Suspected lung cancer (situation)", + codes: { + "SNOMED-CT": [ + "162573006" + ] + } + }, + "162864005": { + description: "Body mass index 30+ - obesity (finding)", + codes: { + "SNOMED-CT": [ + "162864005" + ] + } + }, + "185086009": { + description: "Chronic obstructive bronchitis (disorder)", + codes: { + "SNOMED-CT": [ + "185086009" + ] + } + }, + "192127007": { + description: "Child attention deficit disorder", + codes: { + "SNOMED-CT": [ + "192127007" + ] + } + }, + "195662009": { + description: "Acute viral pharyngitis (disorder)", + codes: { + "SNOMED-CT": [ + "195662009" + ] + } + }, + "195967001": { + description: "Asthma", + codes: { + "SNOMED-CT": [ + "195967001" + ] + } + }, + "196416002": { + description: "Impacted molars", + codes: { + "SNOMED-CT": [ + "196416002" + ] + } + }, + "197927001": { + description: "Recurrent urinary tract infection", + codes: { + "SNOMED-CT": [ + "197927001" + ] + } + }, + "198992004": { + description: "Antepartum eclampsia", + codes: { + "SNOMED-CT": [ + "198992004" + ] + } + }, + "201834006": { + description: "Localized, primary osteoarthritis of the hand", + codes: { + "SNOMED-CT": [ + "201834006" + ] + } + }, + "230265002": { + description: "Familial Alzheimer's disease of early onset (disorder)", + codes: { + "SNOMED-CT": [ + "230265002" + ] + } + }, + "230690007": { + description: "Stroke", + codes: { + "SNOMED-CT": [ + "230690007" + ] + } + }, + "232353008": { + description: "Perennial allergic rhinitis with seasonal variation", + codes: { + "SNOMED-CT": [ + "232353008" + ] + } + }, + "233604007": { + description: "Pneumonia", + codes: { + "SNOMED-CT": [ + "233604007" + ] + } + }, + "233678006": { + description: "Childhood asthma", + codes: { + "SNOMED-CT": [ + "233678006" + ] + } + }, + "235919008": { + description: "Cholelithiasis", + codes: { + "SNOMED-CT": [ + "235919008" + ] + } + }, + "236077008": { + description: "Protracted diarrhea", + codes: { + "SNOMED-CT": [ + "236077008" + ] + } + }, + "237602007": { + description: "Metabolic syndrome X (disorder)", + codes: { + "SNOMED-CT": [ + "237602007" + ] + } + }, + "239720000": { + description: "Tear of meniscus of knee", + codes: { + "SNOMED-CT": [ + "239720000" + ] + } + }, + "239872002": { + description: "Osteoarthritis of hip", + codes: { + "SNOMED-CT": [ + "239872002" + ] + } + }, + "239873007": { + description: "Osteoarthritis of knee", + codes: { + "SNOMED-CT": [ + "239873007" + ] + } + }, + "241929008": { + description: "Acute allergic reaction", + codes: { + "SNOMED-CT": [ + "241929008" + ] + } + }, + "254632001": { + description: "Small cell carcinoma of lung (disorder)", + codes: { + "SNOMED-CT": [ + "254632001" + ] + } + }, + "254637007": { + description: "Non-small cell lung cancer (disorder)", + codes: { + "SNOMED-CT": [ + "254637007" + ] + } + }, + "262574004": { + description: "Bullet wound", + codes: { + "SNOMED-CT": [ + "262574004" + ] + } + }, + "263102004": { + description: "Fracture subluxation of wrist", + codes: { + "SNOMED-CT": [ + "263102004" + ] + } + }, + "271737000": { + description: "Anemia (disorder)", + codes: { + "SNOMED-CT": [ + "271737000" + ] + } + }, + "275272006": { + description: "Brain damage - traumatic", + codes: { + "SNOMED-CT": [ + "275272006" + ] + } + }, + "283371005": { + description: "Laceration of forearm", + codes: { + "SNOMED-CT": [ + "283371005" + ] + } + }, + "283385000": { + description: "Laceration of thigh", + codes: { + "SNOMED-CT": [ + "283385000" + ] + } + }, + "284549007": { + description: "Laceration of hand", + codes: { + "SNOMED-CT": [ + "284549007" + ] + } + }, + "284551006": { + description: "Laceration of foot", + codes: { + "SNOMED-CT": [ + "284551006" + ] + } + }, + "301011002": { + description: "Escherichia coli urinary tract infection", + codes: { + "SNOMED-CT": [ + "301011002" + ] + } + }, + "302870006": { + description: "Hypertriglyceridemia (disorder)", + codes: { + "SNOMED-CT": [ + "302870006" + ] + } + }, + "307731004": { + description: "Injury of tendon of the rotator cuff of shoulder", + codes: { + "SNOMED-CT": [ + "307731004" + ] + } + }, + "314994000": { + description: "Metastasis from malignant tumor of prostate (disorder)", + codes: { + "SNOMED-CT": [ + "314994000" + ] + } + }, + "359817006": { + description: "Closed fracture of hip", + codes: { + "SNOMED-CT": [ + "359817006" + ] + } + }, + "363406005": { + description: "Malignant tumor of colon", + codes: { + "SNOMED-CT": [ + "363406005" + ] + } + }, + "367498001": { + description: "Seasonal allergic rhinitis", + codes: { + "SNOMED-CT": [ + "367498001" + ] + } + }, + "370143000": { + description: "Major depression disorder", + codes: { + "SNOMED-CT": [ + "370143000" + ] + } + }, + "370247008": { + description: "Facial laceration", + codes: { + "SNOMED-CT": [ + "370247008" + ] + } + }, + "398254007": { + description: "Preeclampsia", + codes: { + "SNOMED-CT": [ + "398254007" + ] + } + }, + "399211009": { + description: "History of myocardial infarction (situation)", + codes: { + "SNOMED-CT": [ + "399211009" + ] + } + }, + "403190006": { + description: "First degree burn", + codes: { + "SNOMED-CT": [ + "403190006" + ] + } + }, + "403191005": { + description: "Second degree burn", + codes: { + "SNOMED-CT": [ + "403191005" + ] + } + }, + "408512008": { + description: "Body mass index 40+ - severely obese (finding)", + codes: { + "SNOMED-CT": [ + "408512008" + ] + } + }, + "410429000": { + description: "Cardiac Arrest", + codes: { + "SNOMED-CT": [ + "410429000" + ] + } + }, + "422034002": { + description: "Diabetic retinopathy associated with type II diabetes mellitus (disorder)", + codes: { + "SNOMED-CT": [ + "422034002" + ] + } + }, + "424132000": { + description: "Non-small cell carcinoma of lung, TNM stage 1 (disorder)", + codes: { + "SNOMED-CT": [ + "424132000" + ] + } + }, + "428251008": { + description: "History of appendectomy", + codes: { + "SNOMED-CT": [ + "428251008" + ] + } + }, + "429007001": { + description: "History of cardiac arrest (situation)", + codes: { + "SNOMED-CT": [ + "429007001" + ] + } + }, + "431855005": { + description: "Chronic kidney disease stage 1 (disorder)", + codes: { + "SNOMED-CT": [ + "431855005" + ] + } + }, + "431856006": { + description: "Chronic kidney disease stage 2 (disorder)", + codes: { + "SNOMED-CT": [ + "431856006" + ] + } + }, + "443165006": { + description: "Pathological fracture due to osteoporosis (disorder)", + codes: { + "SNOMED-CT": [ + "443165006" + ] + } + }, + "444448004": { + description: "Injury of medial collateral ligament of knee", + codes: { + "SNOMED-CT": [ + "444448004" + ] + } + }, + "444470001": { + description: "Injury of anterior cruciate ligament", + codes: { + "SNOMED-CT": [ + "444470001" + ] + } + }, + "444814009": { + description: "Viral sinusitis (disorder)", + codes: { + "SNOMED-CT": [ + "444814009" + ] + } + }, + "446096008": { + description: "Perennial allergic rhinitis", + codes: { + "SNOMED-CT": [ + "446096008" + ] + } + }, + "449868002": { + description: "Smokes tobacco daily", + codes: { + "SNOMED-CT": [ + "449868002" + ] + } + }, + "698754002": { + description: "Chronic paralysis due to lesion of spinal cord", + codes: { + "SNOMED-CT": [ + "698754002" + ] + } + }, + "703151001": { + description: "History of single seizure (situation)", + codes: { + "SNOMED-CT": [ + "703151001" + ] + } + }, + "713197008": { + description: "Recurrent rectal polyp", + codes: { + "SNOMED-CT": [ + "713197008" + ] + } + }, + "124171000119105": { + description: "Chronic intractable migraine without aura", + codes: { + "SNOMED-CT": [ + "124171000119105" + ] + } + }, + "368581000119106": { + description: "Neuropathy due to type 2 diabetes mellitus (disorder)", + codes: { + "SNOMED-CT": [ + "368581000119106" + ] + } + }, + "1551000119108": { + description: "Nonproliferative diabetic retinopathy due to type 2 diabetes mellitus (disorder)", + codes: { + "SNOMED-CT": [ + "1551000119108" + ] + } + }, + "90781000119102": { + description: "Microalbuminuria due to type 2 diabetes mellitus (disorder)", + codes: { + "SNOMED-CT": [ + "90781000119102" + ] + } + }, + "1501000119109": { + description: "Proliferative diabetic retinopathy due to type II diabetes mellitus (disorder)", + codes: { + "SNOMED-CT": [ + "1501000119109" + ] + } + }, + "67811000119102": { + description: "Primary small cell malignant neoplasm of lung, TNM stage 1 (disorder)", + codes: { + "SNOMED-CT": [ + "67811000119102" + ] + } + } + } + }, + patientsPerPage: 25, + timeout: 20000, + renderSelectedOnly: false, + fhirViewer: { + enabled: true, + url: "http://docs.smarthealthit.org/fhir-viewer/index.html", + param: "url" + }, + outputMode: "id-list", + submitStrategy: "manual" +} \ No newline at end of file diff --git a/config-genrator/generate_config.js b/config-genrator/generate_config.js index 926c9c9..73c4788 100644 --- a/config-genrator/generate_config.js +++ b/config-genrator/generate_config.js @@ -50,20 +50,35 @@ function requestPromise(options) { /** * Fetches the conformance statement and determines the Fhir version - * @returns {Promise} "DSTU-1", "DSTU-2" or "STU-3" + * @returns {Promise} "DSTU-0", "DSTU-1", "DSTU-2", "STU-3" or "R4" * @see http://hl7.org/fhir/directory.html * TODO: Fixme when version 4 is out */ function getFhirVersion() { return requestPromise(app.server.replace(/\/?$/, "/metadata")).then(res => { - let ver = res.body.fhirVersion.split(".").map(parseFloat); - if (ver[0] === 0) { - return ver[1] > 4 ? "DSTU-2" : "DSTU-1" - } - else if (ver[0] === 1) { - return ver[1] > 1 ? "STU-3" : "DSTU-2" - } - return "STU-3"; + return ({ + "0" : "DSTU-0", + "0.01" : "DSTU-0", + "0.05" : "DSTU-1", + "0.06" : "DSTU-1", + "0.11" : "DSTU-1", + "0.0.82" : "DSTU-1", + "0.4.0" : "DSTU-2", + "0.5.0" : "DSTU-2", + "1.0.0" : "DSTU-2", + "1.0.2" : "DSTU-2", + "1.1.0" : "STU-3", + "1.2.0" : "STU-3", + "1.4.0" : "STU-3", + "1.6.0" : "STU-3", + "1.8.0" : "STU-3", + "3.0.1" : "STU-3", + "3.2.0" : "R4", + "3.3.0" : "R4", + "3.5.0" : "R4", + "3.5a.0" : "R4", + "4.0.0" : "R4" + }[res.body.fhirVersion]) || "Unknown"; }); } @@ -182,7 +197,7 @@ getFhirVersion().then(version => { let json = generateConfig(""); if (app.file) { - let filePath = Path.resolve(__dirname, "../config/", `${app.file}.json5`); + let filePath = Path.resolve(__dirname, "../config/", `${app.file.replace(/(\.json5)?$/, ".json5")}`); if (FS.existsSync(filePath)) { mixinDeep(json, JSON5.parse(FS.readFileSync(filePath, "utf8"))); diff --git a/src/components/Fhir/ConditionList.js b/src/components/Fhir/ConditionList.js index a90eae9..f30bf00 100644 --- a/src/components/Fhir/ConditionList.js +++ b/src/components/Fhir/ConditionList.js @@ -3,7 +3,7 @@ import PropTypes from "prop-types" import { CODE_SYSTEMS } from "../../lib/constants" import Grid from "./Grid" import Date from "./Date" -import { getPath } from "../../lib" +import { getPath, getCodeOrConcept } from "../../lib" import moment from "moment" export default class ConditionList extends React.Component @@ -70,11 +70,11 @@ export default class ConditionList extends React.Component }, { label:
Clinical Status
, - render: o =>
{ o.clinicalStatus }
+ render: o =>
{ getCodeOrConcept(o.clinicalStatus) }
}, { label :
Verification Status
, - render: o =>
{ o.verificationStatus || "-" }
+ render: o =>
{ getCodeOrConcept(o.verificationStatus) }
}, { label:
Onset Date
, diff --git a/src/components/Fhir/ImmunizationList.js b/src/components/Fhir/ImmunizationList.js index 0802d66..2d4b9f0 100644 --- a/src/components/Fhir/ImmunizationList.js +++ b/src/components/Fhir/ImmunizationList.js @@ -39,7 +39,9 @@ export default class ImmunizationList extends React.Component render: o => ( o.date ? : - "-" + o.occurrenceDateTime ? + : + o.occurrenceString || "-" ) } ]} diff --git a/src/components/Fhir/ResourceList.js b/src/components/Fhir/ResourceList.js index 87ecda5..c915882 100644 --- a/src/components/Fhir/ResourceList.js +++ b/src/components/Fhir/ResourceList.js @@ -1,7 +1,7 @@ import React from "react" import PropTypes from "prop-types" import Grid from "./Grid" -import { getPath } from "../../lib" +import { getPath, getCodeOrConcept } from "../../lib" import Period from "./Period" import Date from "./Date" import moment from "moment" @@ -187,15 +187,15 @@ export default class ResourceList extends React.Component }, { label: "Status", - path: "status" + render: rec => getCodeOrConcept(rec.status) }, { label: "Clinical Status", - path: "clinicalStatus" + render: rec => getCodeOrConcept(rec.clinicalStatus) }, { label: "Verification Status", - path: "verificationStatus" + render: rec => getCodeOrConcept(rec.verificationStatus) }, { label: "Value as String", diff --git a/src/components/PatientDetail/index.js b/src/components/PatientDetail/index.js index 776593a..ab3c8d8 100644 --- a/src/components/PatientDetail/index.js +++ b/src/components/PatientDetail/index.js @@ -109,7 +109,9 @@ export class PatientDetail extends React.Component * search returns only one page. The reason for this is that we also have * these "Prev Patient" and "Next Patient" buttons that allow the user to * walk through the result one patient at a time. - * @param {Object} server.url & server.type ... + * @param {Object} server + * @param {Object} server.url + * @param {Object} server.type * @param {Number} index */ fetchPatient(server, index) @@ -143,7 +145,7 @@ export class PatientDetail extends React.Component state.patient = getPath(state, `bundle.entry.${index}.resource`); state.nextURL = getBundleURL(state.bundle, "next"); state.hasNext = !!state.nextURL || (state.patient ? index < state.bundle.entry.length - 1 : false); - return state; + return Promise.resolve(state); }) // if no patient - jump to it's index @@ -173,7 +175,7 @@ export class PatientDetail extends React.Component // Find $everything .then(state => { - return getAllPages({ url: `${server.url}/Patient/${state.patient.id}/$everything` }) + return getAllPages({ url: `${server.url}/Patient/${state.patient.id}/$everything?_count=500` }) .then(data => { let groups = {}; data.forEach(entry => { diff --git a/src/config.default.js b/src/config.default.js index 71285e1..bebc927 100644 --- a/src/config.default.js +++ b/src/config.default.js @@ -1,22 +1,8 @@ export default { server: { - type: "STU-3", // "DSTU-2" or "STU-3" + type: "STU-3", // "DSTU-2" or "STU-3" or "R4" - // HSPC - // url: "https://sb-fhir-dstu2.smarthealthit.org/api/smartdstu2/open", - url: "https://sb-fhir-stu3.smarthealthit.org/smartstu3/open", - - // HAPI - // url: "http://fhirtest.uhn.ca/baseDstu3", - // url: "http://fhirtest.uhn.ca/baseDstu2", - - // MiHIN - // url: "http://34.195.196.20:9074/smartstu3", - // url: "http://52.90.126.238:8080/fhir/baseDstu3", - - // Other - // url: "http://sqlonfhir-dstu2.azurewebsites.net/fhir", - // url: "https://stub-dstu2.smarthealthit.org/api/fhir", + url: "https://r3.smarthealthit.org", conditions: {}, diff --git a/src/lib/index.js b/src/lib/index.js index 9fa5c8f..d130596 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -364,6 +364,31 @@ export function getPatientImageUri(patient, base="") { return url; } +/** + * Return the display text for the given CodeableConcept + * @param {Object} concept CodeableConcept + * @returns {String} + */ +export function getCodeableConcept(concept, defaultValue = "-") { + return String( + getPath(concept, "coding.0.display") || + getPath(concept, "coding.0.code") || + concept.text || + defaultValue + ); +} + +/** + * Some elements are of type `code` in older FHIR versions, but have been + * converted to CodeableConcept in later versions + * @param {String|Object} data Code or CodeableConcept + * @returns {String} + */ +export function getCodeOrConcept(data, defaultValue = "-") { + if (typeof data == "string") return data || defaultValue; + return getCodeableConcept(data, defaultValue); +} + /** * Given some input string (@input) and a string to search for (@query), this * function will highlight all the occurrences by wrapping them in