https://github.com/beda-software/fhirsnake
A minimalistic FHIR server for resources as files
https://github.com/beda-software/fhirsnake
Last synced: 4 months ago
JSON representation
A minimalistic FHIR server for resources as files
- Host: GitHub
- URL: https://github.com/beda-software/fhirsnake
- Owner: beda-software
- Created: 2024-08-23T13:06:52.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-26T08:58:51.000Z (almost 2 years ago)
- Last Synced: 2024-10-31T09:47:27.038Z (over 1 year ago)
- Language: Python
- Size: 427 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README

# fhirsnake: turn static files to a FHIR server

## What is it?
**fhirsnake** is a minimalistic FHIR server that serve yaml and json files as FHIR resources
## How it works?
The server reads all `yaml` and `json` files from `resources` directory.
Resources directory should have subdirectories with names equal resource types:
```markdown
resources/
├── Patient/
│ ├── example.yaml
│ ├── john-doe.json
│ └── patient3.yaml
├── Questionnaire/
│ ├── questionnaire1.yaml
│ ├── questionnaire2.yaml
│ └── sudbir/
│ └── questionnaire3.yaml
```
## Environment variable substitution
To use environment variables in resources, you can use the syntax `${VAR_NAME}`.
In the case of missing environment variable, the exception will be raised.
NOTE: The syntax `$VAR` without braces is not supported because it might be used in resources.
## Supported operations
> [!IMPORTANT]
> All created and updated resources persist in runtime only. All changes are vanished after service restart
- **read**, **create** and **update** operations are supported
- **search** - limied support without any search params
- `GET /$index` operation returns a map of all resources in format `:`
## Usage
1. Organize resources in a directory
### Server
1. Option A: Run a container
```bash
docker run -p 8002:8000 -v ./resources:/app/resources bedasoftware/fhirsnake
```
2. Option B: Adjust source destination in `Dockerfile.resources` if required
2.1. Build an image using the base image
```bash
docker build -t fhirsnake-resources:latest -f Dockerfile.resources .
docker run -p 8000:8000 fhirsnake-resources
```
### Export
1. Export resources as .json (Bundle) or .ndjson or ndjson.gz
```bash
docker run -v ./resources:/app/resources -v ./output:/output bedasoftware/fhirsnake export --external-questionnaire-fce-fhir-converter-url=http://host.docker.internal:3000/to-fhir --output /output/seeds.ndjson.gz
```
### Watch
1. Watch resources for changes and send as PUT requests to external fhir server
```bash
docker run -v ./resources:/app/resources -v ./output:/output bedasoftware/fhirsnake watch --external-fhir-server-url http://host.docker.internal:8080 --external-fhir-server-header "Authorization: Token token" --external-questionnaire-fce-fhir-converter-url=http://host.docker.internal:3000/to-fhir
```
### Using external questionnaire FCE->FHIR converter
There's an image `bedasoftware/questionnaire-fce-fhir-converter:latest` available that provides `/to-fhir` endpoint that can be used along with `--external-questionnaire-fce-fhir-converter-url` args for watch and export commands.
## Contribution and feedback
Please, use [Issues](https://github.com/beda-software/fhirsnake/issues)
## Development
### Format and fix with ruff
```sh
ruff format
ruff check . --fix
```
### Issue new version - run [semantic release](https://semantic-release.gitbook.io/semantic-release/usage/installation) locally
```sh
npx semantic-release --no-ci
```
### Publish to pypi
```sh
poetry build
poetry publish
```