From 2587906910d0c034d959a2e76b8c75f44b08e95c Mon Sep 17 00:00:00 2001 From: "Shahid N. Shah" Date: Wed, 25 Sep 2024 20:35:01 -0400 Subject: [PATCH] docs: simplify README to match new surveilr.com features --- lib/pattern/fhir-explorer/README.md | 102 +++++++--------------------- 1 file changed, 26 insertions(+), 76 deletions(-) diff --git a/lib/pattern/fhir-explorer/README.md b/lib/pattern/fhir-explorer/README.md index 0cbd71357..e8549e8a7 100644 --- a/lib/pattern/fhir-explorer/README.md +++ b/lib/pattern/fhir-explorer/README.md @@ -1,4 +1,4 @@ -# `surveilr` Digital Health Patterns +# `surveilr` FHIR Explorer Pattern - `stateless-fhir.surveilr.sql` script focuses on creating views that define how to extract and present specific FHIR data from the `uniform_resource.content` @@ -10,6 +10,8 @@ is ingested, the tables need to be dropped and recreated manually, and any changes in the source data will not be reflected until the tables are refreshed. +- `package.sql.ts` script is the entry point for loading typical database + objects and Web UI content. ## Try it out on any device without this repo (if you're just using the SQL scripts) @@ -27,32 +29,36 @@ $ wget https://synthetichealth.github.io/synthea-sample-data/downloads/latest/sy $ mkdir ingest && cd ingest && unzip ../synthea_sample_data_fhir_latest.zip && cd .. # download surveilr using instructions at https://docs.opsfolio.com/surveilr/how-to/installation-guide -# then run the ingestion of files downloaded above +# making sure surveilr is in your path, then run the ingestion of files downloaded above $ surveilr ingest files -r ingest/ # use SQLPage to preview content (be sure `deno` v1.40 or above is installed) -$ surveilr https://surveilr.com/pattern/fhir-explorer/pattern.sql +$ surveilr https://surveilr.com/pattern/fhir-explorer/package.sql $ surveilr web-ui --port 9000 # launch a browser and go to http://localhost:9000/fhir/index.sql ``` -Once you ingest all the JSON using `surveilr`, apply -`orchestrate-stateful-fhir.surveilr.sql` and `stateless-fhir.surveilr.sql` all -content will be accessed through views or `*.cached` tables in -`resource-surveillance.sqlite.db`. +Running `surveilr ingest` and `surveilr .../package.sql` will automatically +create `resource-surveillance.sqlite.db` in your current directory. At this +point you can rename the SQLite database file, archive it, use in reporting +tools, DBeaver, DataGrip, or any other SQLite data access tools. -At this point you can rename the SQLite database file, archive it, use in -reporting tools, DBeaver, DataGrip, or any other SQLite data access tools. +The typical `pattern/fhir-explorer/package.sql` will only create simple SQL +convenience views on top of ingested data. On fast machines the simple SQL views +will perform well. However, if performance is slow, you can apply +`orchestrate-stateful-fhir.surveilr.sql` which will add denormalized `*_cached` +tables in `resource-surveillance.sqlite.db`. ## Try it out in this repo (if you're developing SQL scripts) First prepare the directory with sample files: ```bash -$ cd pattern/fhir-explorer +$ cd lib/pattern/fhir-explorer $ wget https://synthetichealth.github.io/synthea-sample-data/downloads/latest/synthea_sample_data_fhir_latest.zip $ wget https://synthetichealth.github.io/synthea-sample-data/downloads/10k_synthea_covid19_csv.zip -$ mkdir ingest && cd ingest && unzip ../synthea_sample_data_fhir_latest.zip ../10k_synthea_covid19_csv.zip && cd .. +$ mkdir ingest && cd ingest && unzip ../synthea_sample_data_fhir_latest.zip && unzip ../10k_synthea_covid19_csv.zip && cd .. +$ rm -f synthea_sample_data_fhir_latest.zip 10k_synthea_covid19_csv.zip ``` The directory should look like this now: @@ -64,8 +70,8 @@ The directory should look like this now: │ ├── ...(many more files) │ └── Yon80_Kiehn525_54fe5c50-37cc-930b-8e3a-2c4e91bb6eec.json ├── orchestrate-stateful-fhir.surveilr.sql -├── stateless-fhir.surveilr.sql -└── synthea_sample_data_fhir_latest.zip +├── package.sql.ts +└── stateless-fhir.surveilr.sql ``` Now @@ -91,75 +97,19 @@ ignored, only `sqlite3` is required because all content is in the other dependencies. ```bash -# load the "Console" and other menu/routing utilities plus FHIR Web UI -$ deno run -A ./ux.sql.ts | sqlite3 resource-surveillance.sqlite.db +# load the "Console" and other menu/routing utilities plus FHIR Web UI (both are same, just run one) +$ deno run -A ./package.sql.ts | surveilr shell # option 1 (same as option 2) +$ surveilr shell ./package.sql.ts # option 2 (same as option 1) # if you want to start surveilr embedded SQLPage in "watch" mode to re-load files automatically -$ ../../support/bin/sqlpagectl.ts dev --watch . --watch ../core +$ ../../universal/sqlpagectl.ts dev --watch . --watch ../../std # browse http://localhost:9000/ to see web UI # if you want to start a standalone SQLPage in "watch" mode to re-load files automatically -$ ../../support/bin/sqlpagectl.ts dev --watch . --watch ../core --standalone +$ ../../universal/sqlpagectl.ts dev --watch . --watch ../../std --standalone # browse http://localhost:9000/ to see web UI -# browse http://localhost:9000/fhir/info-schema.sql to see FHIR-specific -``` - -Once you apply `orchestrate-stateful-fhir.surveilr.sql` and -`stateless-fhir.surveilr.sql` you can ignore those files and all content will be -accessed through views or `*.cached` tables in -`resource-surveillance.sqlite.db`. At this point you can rename the SQLite -database file, archive it, use in reporting tools, DBeaver, DataGrip, or any -other SQLite data access tools. - -## Installing SQLite 3.46.0 on Ubuntu - -To install SQLite 3.46.0 on Ubuntu, follow these steps: - -### Update and Install Dependencies - -Ensure your package lists are up-to-date and install the necessary tools to -build software from source: - -```bash -sudo apt update -sudo apt install -y build-essential libreadline-dev wget -``` - -### Download SQLite 3.46.0 - -Navigate to the directory where you want to download the SQLite source code and -then download it: - -```bash -cd /usr/local/src -sudo wget https://www.sqlite.org/2024/sqlite-autoconf-3460000.tar.gz -``` - -### Extract the Downloaded Tarball - -```bash -sudo tar -xzf sqlite-autoconf-3460000.tar.gz -cd sqlite-autoconf-3460000 -``` - -### Build and Install SQLite - -Configure, build, and install SQLite: - -```bash -sudo ./configure --prefix=/usr/local -sudo make -sudo make install -``` - -### Verify the Installation - -After installation, open a new terminal and verify that SQLite 3.46.0 is -installed correctly by checking its version: - -```bash -sqlite3 --version +# browse http://localhost:9000/fhir/info-schema.sql to see FHIR-specific views and tables ``` ## Automatically reloading SQL when it changes @@ -169,7 +119,7 @@ to automatically re-load the contents into SQLite regularly. Since it can be time-consuming to re-run the same command in the CLI manually each time a file changes, you can use _watch mode_ instead. -See: [`sqlpagectl.ts`](../../support/bin/sqlpagectl.ts). +See: [`sqlpagectl.ts`](../../universal/sqlpagectl.ts). ## TODO