JHE ships a Bruno API collection for exercising the Admin and FHIR APIs by hand. Every request uses environment variables, so there are no hardcoded IDs.
| What | Where (in the JHE repo) |
|---|---|
| Collection (Admin + FHIR requests) | opencollection/JHE/ |
| Token-minting command | core/management/commands/create_bruno_app.py |
| Test that keeps the collection true | tests/backend/test_bruno_collection.py |
Setup¶
Install Bruno.
Seed the database and mint an access token:
python manage.py seed python manage.py create_bruno_app --email admin@example.comcreate_bruno_appcreates a public OAuth app, generates a 1-year access token, and makes the user a manager of every organization. Copy the printed token.In Bruno, choose Open Collection and select
opencollection/JHE/.Create an environment and set the variables below. Get real IDs from the Web UI or your seeded data.
Variable Meaning BASE_URLServer root, e.g. http://localhost:8000ACCESS_TOKENToken printed by create_bruno_appORG_IDAn organization id PATIENT_IDA patient id STUDY_IDA study id USER_IDA user id DATA_SOURCE_IDA data source id CLIENT_APP_IDAn OAuth client (JheClient) id Select the environment, then send any request.
The token expires after one year. Re-run create_bruno_app to mint a new one.
Collection structure¶
| Folder | Covers |
|---|---|
| Admin | Organizations, Patients, Studies, Users, Practitioners, Data Sources, Clients, Settings, Observations |
| FHIR | FHIR R5 Patient, Observation (filtered search + _summary=count), and QuestionnaireResponse endpoints |
Keeping it in sync¶
test_bruno_collection.py parses every request and fires it against the API, so any request that drifts from the real endpoints fails the backend test suite. Run it with the normal backend tests.