Skip to content

Commit

Permalink
Merge pull request #11 from projkov/7-change-result
Browse files Browse the repository at this point in the history
7 change result
  • Loading branch information
projkov authored Jul 17, 2024
2 parents 1ff099c + c30adfe commit 7304955
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 27 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"antd": "^5.19.2",
"axios": "^1.7.2",
"dotenv": "^16.4.5",
"fhirpath": "^3.14.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-ga4": "^2.1.0",
Expand Down
9 changes: 2 additions & 7 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Modal } from './components/Modal';
import logo from './assets/logo.png';
import { ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
import { ResultOutput } from './components/ResultOutput';

const App: React.FC = () => {
const { url, handleUrlChange, handleFetch,
Expand Down Expand Up @@ -52,13 +53,7 @@ const App: React.FC = () => {
<div className='editorWrapper'>
<Editor defaultLanguage="ruby" value={expression} onChange={(value) => setExpression(value as string)} options={{ formatOnPaste: true, formatOnType: true }} />
</div>
<div className='editorWrapper'>
<Editor defaultLanguage="json" value={result} options={{
formatOnPaste: true,
formatOnType: true,
readOnly: true,
}} />
</div>
<ResultOutput resultItems={result} />
</Allotment>
</div>
</Allotment>
Expand Down
28 changes: 28 additions & 0 deletions src/components/ResultOutput/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { List } from "antd";
import './styles.css';

interface ResultOutputProps {
resultItems: any[];
}

export function ResultOutput(props: ResultOutputProps) {
const { resultItems } = props;

if (resultItems.length === 0) {
return null;
}

return (
<div className="resultOutputContainer">
<List
size="small"
dataSource={resultItems}
renderItem={(item) => (
<List.Item>
<pre>{JSON.stringify(item, null, 2)}</pre>
</List.Item>
)}
/>
</div>
)
}
5 changes: 5 additions & 0 deletions src/components/ResultOutput/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.resultOutputContainer {
width: 100%;
height: 100%;
overflow: auto;
}
20 changes: 6 additions & 14 deletions src/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import axios from "axios";
import { useEffect, useState } from "react";
import { EvaluateResponse } from "./interfaces";
import { toast } from 'react-toastify';
import { reqWrapper } from "./utils/requests";
import { config } from './config'

const fhirpath = require('fhirpath');
const fhirpath_r4_model = require('fhirpath/fhir-context/r4');

export function useFHIRPathUI() {
const fhirPathServiceURL = config.fhirpathApi || 'http://localhost:5000';
const evaluateURL = fhirPathServiceURL + '/evaluate';
const [url, setUrl] = useState<string>('');
const [resource, setResource] = useState<string>('');
const [expression, setExpression] = useState<string>('');
const [result, setResult] = useState<string>('');
const [result, setResult] = useState<any[]>([]);
const [shareLink, setShareLink] = useState<string>('');
const [isLoading, setIsLoading] = useState<boolean>(false);
const [initialRun, setInitialRun] = useState<boolean>(true); // Track initial run
Expand All @@ -34,15 +33,7 @@ export function useFHIRPathUI() {

const handleExecute = async (executeResource: string, executeExpression: string) => {
setIsLoading(true);
const result = await reqWrapper(axios.post<EvaluateResponse>(evaluateURL, {
resource: JSON.parse(executeResource),
expression: executeExpression,
}))
if(result.status === 'success'){
setResult(JSON.stringify(result.data, null, 2));
} else {
showError(result.error);
}
setResult(fhirpath.evaluate(JSON.parse(executeResource), executeExpression, null, fhirpath_r4_model));
setIsLoading(false);
};

Expand Down Expand Up @@ -77,6 +68,7 @@ export function useFHIRPathUI() {

handleFetch(decodedUrl);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(() => {
Expand Down
3 changes: 0 additions & 3 deletions src/interfaces.ts

This file was deleted.

121 changes: 118 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1688,6 +1688,22 @@
resolved "https://registry.npmjs.org/@leichtgewicht/ip-codec/-/ip-codec-2.0.5.tgz"
integrity sha512-Vo+PSpZG2/fmgmiNzYK9qWRh8h/CHrwD0mo1h1DzL4yzHNSfWYujGTYsWGreD000gcgmZ7K4Ys6Tx9TxtsKdDw==

"@lhncbc/ucum-lhc@^5.0.0":
version "5.0.4"
resolved "https://registry.yarnpkg.com/@lhncbc/ucum-lhc/-/ucum-lhc-5.0.4.tgz#1357a039954e03154f89ce51f2d90c93b9c1a1f3"
integrity sha512-khuV9GV51DF80b0wJmhZTR5Bf23fhS6SSIWnyGT9X+Uvn0FsHFl2LKViQ2TTOuvwagUOUSq8/0SyoE2ZDGwrAA==
dependencies:
coffeescript "^2.7.0"
csv-parse "^4.4.6"
csv-stringify "^1.0.4"
escape-html "^1.0.3"
is-integer "^1.0.6"
jsonfile "^2.2.3"
stream "0.0.2"
stream-transform "^0.1.1"
string-to-stream "^1.1.0"
xmldoc "^0.4.0"

"@monaco-editor/loader@^1.4.0":
version "1.4.0"
resolved "https://registry.npmjs.org/@monaco-editor/loader/-/loader-1.4.0.tgz"
Expand Down Expand Up @@ -2863,6 +2879,11 @@ antd@^5.19.2:
scroll-into-view-if-needed "^3.1.0"
throttle-debounce "^5.0.0"

antlr4@~4.9.3:
version "4.9.3"
resolved "https://registry.yarnpkg.com/antlr4/-/antlr4-4.9.3.tgz#268b844ff8ce97d022399a05d4b37aa6ab4047b2"
integrity sha512-qNy2odgsa0skmNMCuxzXhM4M8J1YDaPv3TI+vCdnOAanu0N982wBrSqziDKRDctEZLZy9VffqIZXc0UGjjSP/g==

any-promise@^1.0.0:
version "1.3.0"
resolved "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz"
Expand Down Expand Up @@ -3583,6 +3604,11 @@ coa@^2.0.2:
chalk "^2.4.1"
q "^1.1.2"

coffeescript@^2.7.0:
version "2.7.0"
resolved "https://registry.yarnpkg.com/coffeescript/-/coffeescript-2.7.0.tgz#a43ec03be6885d6d1454850ea70b9409c391279c"
integrity sha512-hzWp6TUE2d/jCcN67LrW1eh5b/rSDKQK6oD6VMLlggYVUUFexgTH9z3dNYihzX4RMhze5FTUsUmOXViJKFQR/A==

collect-v8-coverage@^1.0.0:
version "1.0.2"
resolved "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz"
Expand Down Expand Up @@ -3629,7 +3655,7 @@ combined-stream@^1.0.8:
dependencies:
delayed-stream "~1.0.0"

commander@^2.20.0:
commander@^2.18.0, commander@^2.20.0:
version "2.20.3"
resolved "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz"
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
Expand Down Expand Up @@ -3996,6 +4022,18 @@ csstype@^3.0.2, csstype@^3.1.3:
resolved "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz"
integrity sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==

csv-parse@^4.4.6:
version "4.16.3"
resolved "https://registry.yarnpkg.com/csv-parse/-/csv-parse-4.16.3.tgz#7ca624d517212ebc520a36873c3478fa66efbaf7"
integrity sha512-cO1I/zmz4w2dcKHVvpCr7JVRu8/FymG5OEpmvsZYlccYolPBLoVGKUHgNoc4ZGkFeFlWGEDmMyBM+TTqRdW/wg==

csv-stringify@^1.0.4:
version "1.1.2"
resolved "https://registry.yarnpkg.com/csv-stringify/-/csv-stringify-1.1.2.tgz#77a41526581bce3380f12b00d7c5bbac70c82b58"
integrity sha512-3NmNhhd+AkYs5YtM1GEh01VR6PKj6qch2ayfQaltx5xpcAdThjnbbI5eT8CzRVpXfGKAxnmrSYLsNl/4f3eWiw==
dependencies:
lodash.get "~4.4.2"

damerau-levenshtein@^1.0.8:
version "1.0.8"
resolved "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz"
Expand Down Expand Up @@ -4037,6 +4075,11 @@ data-view-byte-offset@^1.0.0:
es-errors "^1.3.0"
is-data-view "^1.0.1"

date-fns@^1.30.1:
version "1.30.1"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-1.30.1.tgz#2e71bf0b119153dbb4cc4e88d9ea5acfb50dc05c"
integrity sha512-hBSVCvSmWC+QypYObzwGOd9wqdDpOt+0wl0KbU+R+uuZBS1jN8VsD1ss3irQDknRj5NvxiTF6oj/nDRnN/UQNw==

dayjs@^1.11.11:
version "1.11.11"
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.11.tgz#dfe0e9d54c5f8b68ccf8ca5f72ac603e7e5ed59e"
Expand Down Expand Up @@ -4343,6 +4386,11 @@ electron-to-chromium@^1.4.796:
resolved "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.812.tgz"
integrity sha512-7L8fC2Ey/b6SePDFKR2zHAy4mbdp1/38Yk5TsARO66W3hC5KEaeKMMHoxwtuH+jcu2AYLSn9QX04i95t6Fl1Hg==

emitter-component@^1.1.1:
version "1.1.2"
resolved "https://registry.yarnpkg.com/emitter-component/-/emitter-component-1.1.2.tgz#d65af5833dc7c682fd0ade35f902d16bc4bad772"
integrity sha512-QdXO3nXOzZB4pAjM0n6ZE+R9/+kPpECA/XSELIcc54NeYVnBqIk+4DFiBgK+8QbV3mdvTG6nedl7dTYgO+5wDw==

emittery@^0.10.2:
version "0.10.2"
resolved "https://registry.npmjs.org/emittery/-/emittery-0.10.2.tgz"
Expand Down Expand Up @@ -4546,7 +4594,7 @@ escalade@^3.1.1, escalade@^3.1.2:
resolved "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz"
integrity sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==

escape-html@~1.0.3:
escape-html@^1.0.3, escape-html@~1.0.3:
version "1.0.3"
resolved "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz"
integrity sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==
Expand Down Expand Up @@ -4996,6 +5044,17 @@ fb-watchman@^2.0.0:
dependencies:
bser "2.1.1"

fhirpath@^3.14.1:
version "3.14.1"
resolved "https://registry.yarnpkg.com/fhirpath/-/fhirpath-3.14.1.tgz#5b9f6604138653940a827088ab3fd70a6744fe5f"
integrity sha512-i3VVHMW7jSnMxQYiM2o4fPiMybBy+nsP1FhYCA0ydgKT5TBL/CXT1fmt20dZkF2fWwBnML9zjX4SCZRCUZGDMg==
dependencies:
"@lhncbc/ucum-lhc" "^5.0.0"
antlr4 "~4.9.3"
commander "^2.18.0"
date-fns "^1.30.1"
js-yaml "^3.13.1"

file-entry-cache@^6.0.1:
version "6.0.1"
resolved "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz"
Expand Down Expand Up @@ -5777,6 +5836,11 @@ is-finalizationregistry@^1.0.2:
dependencies:
call-bind "^1.0.2"

is-finite@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.1.0.tgz#904135c77fb42c0641d6aa1bcdbc4daa8da082f3"
integrity sha512-cdyMtqX/BOqqNBBiKlIVkytNHm49MtMlYyn1zxzvJKWmFMlGzm+ry5BBfYyeY9YmNKbRSo/o7OX9w9ale0wg3w==

is-fullwidth-code-point@^3.0.0:
version "3.0.0"
resolved "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz"
Expand All @@ -5801,6 +5865,13 @@ is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3, is-glob@~4.0.1:
dependencies:
is-extglob "^2.1.1"

is-integer@^1.0.6:
version "1.0.7"
resolved "https://registry.yarnpkg.com/is-integer/-/is-integer-1.0.7.tgz#6bde81aacddf78b659b6629d629cadc51a886d5c"
integrity sha512-RPQc/s9yBHSvpi+hs9dYiJ2cuFeU6x3TyyIp8O2H6SKEltIvJOzRj9ToyvcStDvPR/pS4rxgr1oBFajQjZ2Szg==
dependencies:
is-finite "^1.0.0"

is-map@^2.0.2, is-map@^2.0.3:
version "2.0.3"
resolved "https://registry.npmjs.org/is-map/-/is-map-2.0.3.tgz"
Expand Down Expand Up @@ -6627,6 +6698,13 @@ json5@^2.1.2, json5@^2.2.0, json5@^2.2.3:
resolved "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz"
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==

jsonfile@^2.2.3:
version "2.4.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8"
integrity sha512-PKllAqbgLgxHaj8TElYymKCAgrASebJrWpTnEkOaTowt23VKXXN0sUeriJ+eh7y6ufb/CC5ap11pz71/cM0hUw==
optionalDependencies:
graceful-fs "^4.1.6"

jsonfile@^6.0.1:
version "6.1.0"
resolved "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz"
Expand Down Expand Up @@ -6789,6 +6867,11 @@ lodash.debounce@^4.0.0, lodash.debounce@^4.0.8:
resolved "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz"
integrity sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==

lodash.get@~4.4.2:
version "4.4.2"
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
integrity sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==

lodash.isequal@^4.5.0:
version "4.5.0"
resolved "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz"
Expand Down Expand Up @@ -8722,7 +8805,7 @@ read-cache@^1.0.0:
dependencies:
pify "^2.3.0"

readable-stream@^2.0.1:
readable-stream@^2.0.1, readable-stream@^2.1.0:
version "2.3.8"
resolved "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz"
integrity sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==
Expand Down Expand Up @@ -9032,6 +9115,11 @@ sass-loader@^12.3.0:
klona "^2.0.4"
neo-async "^2.6.2"

sax@~1.1.1:
version "1.1.6"
resolved "https://registry.yarnpkg.com/sax/-/sax-1.1.6.tgz#5d616be8a5e607d54e114afae55b7eaf2fcc3240"
integrity sha512-8zci48uUQyfqynGDSkUMD7FCJB96hwLnlZOXlgs1l3TX+LW27t3psSWKUxC0fxVgA86i8tL4NwGcY1h/6t3ESg==

sax@~1.2.4:
version "1.2.4"
resolved "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz"
Expand Down Expand Up @@ -9421,6 +9509,18 @@ stop-iteration-iterator@^1.0.0:
dependencies:
internal-slot "^1.0.4"

stream-transform@^0.1.1:
version "0.1.2"
resolved "https://registry.yarnpkg.com/stream-transform/-/stream-transform-0.1.2.tgz#7d8e6b4e03ac4781778f8c79517501bfb0762a9f"
integrity sha512-3HXId/0W8sktQnQM6rOZf2LuDDMbakMgAjpViLk758/h0br+iGqZFFfUxxJSqEvGvT742PyFr4v/TBXUtowdCg==

[email protected]:
version "0.0.2"
resolved "https://registry.yarnpkg.com/stream/-/stream-0.0.2.tgz#7f5363f057f6592c5595f00bc80a27f5cec1f0ef"
integrity sha512-gCq3NDI2P35B2n6t76YJuOp7d6cN/C7Rt0577l91wllh0sY9ZBuw9KaSGqH/b0hzn3CWWJbpbW0W0WvQ1H/Q7g==
dependencies:
emitter-component "^1.1.1"

string-convert@^0.2.0:
version "0.2.1"
resolved "https://registry.yarnpkg.com/string-convert/-/string-convert-0.2.1.tgz#6982cc3049fbb4cd85f8b24568b9d9bf39eeff97"
Expand All @@ -9447,6 +9547,14 @@ string-natural-compare@^3.0.1:
resolved "https://registry.npmjs.org/string-natural-compare/-/string-natural-compare-3.0.1.tgz"
integrity sha512-n3sPwynL1nwKi3WJ6AIsClwBMa0zTi54fn2oLU6ndfTSIO05xaznjSf15PcBZU6FNWbmN5Q6cxT4V5hGvB4taw==

string-to-stream@^1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/string-to-stream/-/string-to-stream-1.1.1.tgz#aba78f73e70661b130ee3e1c0192be4fef6cb599"
integrity sha512-QySF2+3Rwq0SdO3s7BAp4x+c3qsClpPQ6abAmb0DGViiSBAkT5kL6JT2iyzEVP+T1SmzHrQD1TwlP9QAHCc+Sw==
dependencies:
inherits "^2.0.1"
readable-stream "^2.1.0"

"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz"
Expand Down Expand Up @@ -10702,6 +10810,13 @@ xmlchars@^2.2.0:
resolved "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz"
integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==

xmldoc@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/xmldoc/-/xmldoc-0.4.0.tgz#d257224be8393eaacbf837ef227fd8ec25b36888"
integrity sha512-rJ/+/UzYCSlFNuAzGuRyYgkH2G5agdX1UQn4+5siYw9pkNC3Hu/grYNDx/dqYLreeSjnY5oKg74CMBKxJHSg6Q==
dependencies:
sax "~1.1.1"

y18n@^5.0.5:
version "5.0.8"
resolved "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz"
Expand Down

0 comments on commit 7304955

Please sign in to comment.