-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload-codesystems.sh
More file actions
executable file
·91 lines (80 loc) · 3.59 KB
/
Copy pathupload-codesystems.sh
File metadata and controls
executable file
·91 lines (80 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env bash
# Upload the ICD-11 CodeSystems the postcoord suite needs into a running FHIR
# terminology server. One-time setup; ~155 MB on disk for the minimum set,
# takes a few minutes to index.
#
# Uses standard FHIR REST (`POST /CodeSystem` with `application/fhir+json`) so
# it works against any FHIR terminology server that accepts CodeSystem
# resources — Ontoserver, the HAPI reference server, Snowstorm, etc.
#
# Usage:
# ./upload-codesystems.sh [--server URL] [--fixtures DIR]
# [--supplements] [--include-foundation]
#
# --server URL FHIR base URL for the target terminology server
# (default: http://localhost:8080/fhir)
# --fixtures DIR Path to the ICD11toFHIR converter output directory
# (default: $HOME/code/ICD11toFHIR/target)
# --supplements Also upload the -es / -fr translation supplements
# (not needed for cluster validation; displays only)
# --include-foundation Also upload ICD11Foundation-2026-01 (~130 MB; not needed for
# the current suite — only MMS + ICF cases are exercised)
#
# Idempotent: re-running re-uploads via POST, replacing the prior version match.
set -euo pipefail
SERVER="http://localhost:8080/fhir"
FIXTURES="$HOME/code/ICD11toFHIR/target"
SUPPLEMENTS=0
INCLUDE_FOUNDATION=0
while [[ $# -gt 0 ]]; do
case "$1" in
--server) SERVER="$2"; shift 2 ;;
--fixtures) FIXTURES="$2"; shift 2 ;;
--supplements) SUPPLEMENTS=1; shift ;;
--include-foundation) INCLUDE_FOUNDATION=1; shift ;;
-h|--help) sed -n '2,22p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
*) echo "unknown arg: $1" >&2; exit 1 ;;
esac
done
if [[ ! -d "$FIXTURES" ]]; then
echo "fixtures dir not found: $FIXTURES" >&2
echo "Run the ICD11toFHIR converter first (mvn package in that repo)." >&2
exit 1
fi
upload () {
local file="$1" label="$2"
if [[ ! -f "$file" ]]; then
echo " skip $label (file missing: $file)"
return
fi
echo " uploading $label ($(du -h "$file" | cut -f1))..."
local http
http=$(curl -sS -o /tmp/upload-resp.json -w '%{http_code}' \
-X POST "$SERVER/CodeSystem" \
-H 'Content-Type: application/fhir+json' \
--data-binary @"$file")
if [[ "$http" != "201" && "$http" != "200" ]]; then
echo " HTTP $http"
head -c 500 /tmp/upload-resp.json; echo
else
echo " HTTP $http"
fi
}
echo "Target: $SERVER"
echo "Source: $FIXTURES"
# Axis lookups — small support code systems referenced by MMS subproperty groups.
upload "$FIXTURES/ICD11AxisName-2025-01.json" "AxisName lookup"
upload "$FIXTURES/ICD11AllowMultipleValues-2025-01.json" "AllowMultipleValues lookup"
# Primary linearizations.
upload "$FIXTURES/ICD11MMS-2026-01-en.json" "MMS 2026-01 (en)"
upload "$FIXTURES/ICD11ICF-2026-01-en.json" "ICF 2026-01 (en)"
if [[ $SUPPLEMENTS -eq 1 ]]; then
upload "$FIXTURES/ICD11MMS-2026-01-supplement-es.json" "MMS 2026-01 (es supplement)"
upload "$FIXTURES/ICD11MMS-2026-01-supplement-fr.json" "MMS 2026-01 (fr supplement)"
upload "$FIXTURES/ICD11ICF-2026-01-supplement-es.json" "ICF 2026-01 (es supplement)"
upload "$FIXTURES/ICD11ICF-2026-01-supplement-fr.json" "ICF 2026-01 (fr supplement)"
fi
if [[ $INCLUDE_FOUNDATION -eq 1 ]]; then
upload "$FIXTURES/ICD11Foundation-2026-01-en.json" "Foundation 2026-01 (en)"
fi
echo "Done. Indexing may continue server-side for a few minutes — check $SERVER/CodeSystem before running ./run.sh."