uk_sct2cl_42.1.0_20260506000001Z.zip (~930MB)Snapshot/Terminology/ (active concepts only, one row per concept)dsp_clinic PostgreSQL)| Table | Rows | Source File |
|---|---|---|
snomed_concepts |
529,392 | sct2_Concept_Snapshot_INT_20260201.txt |
snomed_descriptions |
1,567,909 | sct2_Description_Snapshot-en_INT_20260201.txt |
snomed_relationships |
3,548,588 | sct2_Relationship_Snapshot_INT_20260201.txt |
pg_trgm (trigram) index on snomed_descriptions.term — enables fast fuzzy/partial text searchconcept_id, active, language_code, type_id, source_id, destination_idPostgreSQL COPY with tab-delimited CSV format, header-skipped:
\COPY snomed_concepts FROM '...sct2_Concept_Snapshot_...txt' WITH (FORMAT CSV, DELIMITER E'\t', HEADER true, NULL '')
managed = False)Added to clinical_data/models.py:
SnomedConcept — maps to snomed_conceptsSnomedDescription — maps to snomed_descriptionsSnomedRelationship — maps to snomed_relationshipspython manage.py import_snomed /path/to/Snapshot/Terminology/
Re-runs the import using Django ORM connections.
clinical_data/migrations/0008_add_snomed_models.py — registers the unmanaged models.
GET /clinical/api/snomed/search/?q=<term>&max=20
Response:
{
"results": [
{"term": "Chest pain", "concept_id": 139228007, "description_id": 123456},
...
],
"count": 20
}
Implementation — clinical_data/views.py:snomed_search() function. Uses ILIKE query on snomed_descriptions table, prioritising exact prefix matches.
Added PARTNER_ADMIN and PARTNER_RECEPTIONIST to the /clinical/ allowed roles in core/middleware.py.
templates/clinical_data/prescription_form.html)<datalist>concept_id in a hidden field medication_concept_idtemplates/appointments/appointment_form.html)RECEPTIONIST, PARTNER_ADMIN, PARTNER_RECEPTIONIST)| File | Change |
|---|---|
clinical_data/models.py |
Added 3 unmanaged SNOMED models |
clinical_data/views.py |
Added snomed_search() view |
clinical_data/urls.py |
Added /api/snomed/search/ route |
clinical_data/management/commands/import_snomed.py |
New: re-import management command |
core/middleware.py |
Added partner roles to /clinical/ RBAC |
templates/clinical_data/prescription_form.html |
SNOMED autocomplete for medication |
templates/appointments/appointment_form.html |
Live SNOMED search (replaces seed data) |
# 1. Extract the Snapshot Terminology files
unzip -j "SnomedCT_UK*.zip" "*/Snapshot/Terminology/sct2_Concept_Snapshot*.txt" -d /tmp/snomed/
unzip -j "SnomedCT_UK*.zip" "*/Snapshot/Terminology/sct2_Description_Snapshot-en*.txt" -d /tmp/snomed/
unzip -j "SnomedCT_UK*.zip" "*/Snapshot/Terminology/sct2_Relationship_Snapshot*.txt" -d /tmp/snomed/
# 2. Run import (from within Docker container)
python manage.py import_snomed /tmp/snomed/