Skip to content

Instantly share code, notes, and snippets.

View johngrimes's full-sized avatar
🚴
coding and cycling

John Grimes johngrimes

🚴
coding and cycling
View GitHub Profile
@johngrimes
johngrimes / ViewDefinition-UsCoreBloodPressures.json
Created May 21, 2025 06:38
US Core Blood Pressure SQL on FHIR example, with Spanish translations
{
"resourceType": "ViewDefinition",
"id": "UsCoreBloodPressures",
"language": "en",
"name": "us_core_blood_pressures",
"_name": {
"extension": [
{
"extension": [
{
@johngrimes
johngrimes / sbom.py
Created May 8, 2025 06:37
Human-readable CycloneDX SBOM
#!/usr/bin/env python3
"""
Read a CycloneDX 1.4 *JSON* BOM from stdin and print one line per component:
<name>@<version> – <license1>, <license2>, …
Usage:
python3 cyclonedx-deps-json.py < bom.json
"""
@johngrimes
johngrimes / ecl_formatter.py
Created April 23, 2025 23:54
Simple ECL formatter
#!/usr/bin/env python3
"""
ECL Formatter - Formats SNOMED CT Expression Constraint Language queries
with consistent indentation and spacing.
Usage: cat ecl.txt | ./ecl_formatter.py > formatted_ecl.txt
"""
import re
import sys
@johngrimes
johngrimes / consumer.py
Last active June 1, 2025 00:27
Streaming SQL on FHIR example with Pathling and Kafka
#!/usr/bin/env python3
"""
Consumer module for processing FHIR resources from Kafka with ETL pipeline.
This module defines constants for the base directory and Spark checkpoint
directory, and implements functions to create Spark sessions, define FHIR
resource views, and start a Kafka consumer to process and persist FHIR data in
PostgreSQL.
"""
@johngrimes
johngrimes / 1.Condition.json
Last active July 9, 2024 04:28
A proof-of-concept for the flexible schema approach described in the draft "Parquet on FHIR" specification
{
"resourceType": "Condition",
"id": "1",
"clinicalStatus": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/condition-clinical",
"code": "active"
}
]
@johngrimes
johngrimes / get_token.py
Created February 27, 2024 00:06
OAuth2 client credentials test harness
import requests
def get_oauth2_token(client_id, client_secret, token_url):
"""
Obtain an OAuth2 token using client credentials grant.
:param client_id: OAuth2 Client ID
:param client_secret: OAuth2 Client Secret
:param token_url: OAuth2 Token Endpoint URL
@johngrimes
johngrimes / prostate_cancer.ipynb
Created January 16, 2024 10:35
Pathling SQL on FHIR Demo
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@johngrimes
johngrimes / checking-inactive-codes.md
Last active December 14, 2023 23:08
Method for checking for inactive codes within a set of JSON FHIR resources
@johngrimes
johngrimes / update_resources.py
Created August 8, 2022 04:23
Send any number of FHIR JSON resource files to a server as updates (in parallel)
import json
import multiprocessing as mp
import sys
from math import floor
from time import time
import requests
def update_resource(file):
@johngrimes
johngrimes / upload_bundles.py
Last active August 3, 2022 06:44
Upload FHIR JSON Bundles to a FHIR server (in parallel)
import multiprocessing as mp
import sys
from time import time
import requests
def upload_bundle(file):
with open(file) as bundle:
data = bundle.read()