Skip to content

Commit b849ff6

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent f990a8b commit b849ff6

File tree

6 files changed

+51
-43
lines changed

6 files changed

+51
-43
lines changed

jupyterhealth-exchange/apis.md

+13-15
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ title: Working with APIs
88
- The Patient authorization code is generated by the server and then shared out-of-band as a secret link with the user.
99
- OAuth is configured from the Django Admin page (See Getting Started above).
1010
- Endpoints and configuration details can be discovered from the OIDC metadata endpoint:
11-
`/o/.well-known/openid-configuration`
11+
`/o/.well-known/openid-configuration`
1212
- The returned Access Token should be included in the `Authorization` header for all API requests with the prefix `Bearer `.
1313
- Because the Patient authorization code is generated by the server, the PKCE code challenge and code verifier must be static values and set by the env vars (example below). The client then sends this `code_verifier` along with the authorization code to obtain tokens.
1414

@@ -123,7 +123,7 @@ code=4AWKhgaaomTSf9PfwxN4ExnXjdSEqh&grant_type=authorization_code&redirect_uri=h
123123
}
124124
]
125125
}
126-
126+
127127
```
128128

129129
- A `PATCH` request can be sent with the same payload to update an existing Consent
@@ -135,10 +135,10 @@ code=4AWKhgaaomTSf9PfwxN4ExnXjdSEqh&grant_type=authorization_code&redirect_uri=h
135135

136136
- The `FHIR Patient` endpoint returns a list of Patients as a FHIR Bundle for a given Study ID passed as query parameter`_has:Group:member:_id` or alternatively a single Patient matching the query parameter `identifier=<system>|<value>`
137137

138-
| Query Parameter | Example | Description |
139-
| ----------------------- | ------------------------------- | ------------------------------------------------------------ |
140-
| `_has:Group:member:_id` | `30001` | Filter by Patients that are in the Study with ID 30001 |
141-
| `identifier` | `http://ehr.example.com|abc123` | Filter by single Patient with Identifier System `http://ehr.example.com` and Value `abc123` |
138+
| Query Parameter | Example | Description |
139+
| ----------------------- | ------------------------ | ------------------------------------------------------ |
140+
| `_has:Group:member:_id` | `30001` | Filter by Patients that are in the Study with ID 30001 |
141+
| `identifier` | \`http://ehr.example.com | abc123\` |
142142

143143
```json
144144
// GET /fhir/r5/Patient?_has:Group:member:_id=30001
@@ -191,14 +191,12 @@ code=4AWKhgaaomTSf9PfwxN4ExnXjdSEqh&grant_type=authorization_code&redirect_uri=h
191191
- `device.reference` references a Data Source ID
192192
- `valueAttachment` is Base 64 Encoded Binary JSON
193193

194-
| Query Parameter | Example | Description |
195-
| ------------------------------- | ----------------------------------------------------- | ------------------------------------------------------------ |
196-
| `patient._has:Group:member:_id` | `30001` | Filter by Patients that are in the Study with ID 30001 |
197-
| `patient` | `40001` | Filter by single Patient with ID 40001 |
198-
| `patient.identifier` | `http://ehr.example.com|abc123` | Filter by single Patient with Identifier System `http://ehr.example.com` and Value `abc123` |
199-
| `code` | `https://w3id.org/openmhealth|omh:blood-pressure:4.0` | Filter by Type/Scope with System `https://w3id.org/openmhealth` and Code `omh:blood-pressure:4.0` |
200-
201-
194+
| Query Parameter | Example | Description |
195+
| ------------------------------- | ------------------------------ | ------------------------------------------------------ |
196+
| `patient._has:Group:member:_id` | `30001` | Filter by Patients that are in the Study with ID 30001 |
197+
| `patient` | `40001` | Filter by single Patient with ID 40001 |
198+
| `patient.identifier` | \`http://ehr.example.com | abc123\` |
199+
| `code` | \`https://w3id.org/openmhealth | omh:blood-pressure:4.0\` |
202200

203201
```json
204202
// GET /fhir/r5/Observation?patient._has:Group:member:_id=30001&patient=40001&code=https://w3id.org/openmhealth|omh:blood-pressure:4.0
@@ -286,4 +284,4 @@ code=4AWKhgaaomTSf9PfwxN4ExnXjdSEqh&grant_type=authorization_code&redirect_uri=h
286284
}
287285
},
288286
...
289-
```
287+
```

jupyterhealth-exchange/architecture.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ Django is a mature and well-supported web framework but was specifically chosen
1414
### DRF Serializers and Pydantic
1515

1616
- The Django Rest Framework uses the concept of Serializers to validate schemas, whereas the FHIR validator uses Pydantic.
17+
1718
- It is not reasonable to re-write the entire validation in the Serializer, so instead a combination of the two are used:
19+
1820
- Top-level fields (most importantly the `id` of a record) are managed by the Serializer.
1921
- Nested fields (for example `code{}.coding[].system` above) are configured as a JSON field in the Serializer (so the top level field is this example is `code`) and then Pydantic is used to validate the whole schema including nested JSON.
2022

@@ -111,7 +113,7 @@ erDiagram
111113
int study_id
112114
int user_id
113115
}
114-
116+
115117
"observations (FHIR Observation)" ||--|| "codeable_concepts (FHIR CodeableConcept)": ""
116118
"observations (FHIR Observation)" ||--|{ "observation_identifiers": ""
117119
"observations (FHIR Observation)" ||--|| "data_sources": ""
@@ -129,7 +131,7 @@ erDiagram
129131
varchar system
130132
varchar value
131133
}
132-
134+
133135
"studies (FHIR Group)" ||--|{ "study_patients": ""
134136
"codeable_concepts (FHIR CodeableConcept)" {
135137
int id
@@ -144,7 +146,7 @@ erDiagram
144146
enum scope_action
145147
int scope_code_id
146148
bool consented
147-
timestamp consented_time
149+
timestamp consented_time
148150
}
149151
"data_sources" ||--|{ "data_source_supported_scopes": ""
150152
"data_sources" ||--|{ "study_data_sources": ""

jupyterhealth-exchange/developer-setup.md

+15-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This guide provides a comprehensive walkthrough for setting up your development
66

77
## Step by Step
88

9-
1. Set up your Python environment. This project uses Django **version 5.2** which requires python **3.10, 3.11, 3.12 or 3.13**.
9+
1. Set up your Python environment. This project uses Django **version 5.2** which requires python **3.10, 3.11, 3.12 or 3.13**.
1010
```{note}
1111
If using pipenv it is recommended to run `pipenv sync` against the lock file to match package versions.
1212
```
@@ -41,18 +41,20 @@ This guide provides a comprehensive walkthrough for setting up your development
4141
import random
4242
import string
4343

44+
4445
def generate_pkce_verifier(length=44):
4546
characters = string.ascii_letters + string.digits
46-
return ''.join(random.choices(characters, k=length))
47+
return "".join(random.choices(characters, k=length))
48+
4749

4850
print(generate_pkce_verifier())
4951
```
5052
1. Use the PKCE verifier to generate the [PKCE code challenge](https://tonyxu-io.github.io/pkce-generator).
5153
1. Return to the `.env` file
52-
- Update `OIDC_CLIENT_ID` with the newly created app Client ID
53-
- Update the `OIDC_RSA_PRIVATE_KEY` with the newly created Private Key
54-
- Update `PATIENT_AUTHORIZATION_CODE_CHALLENGE` and `PATIENT_AUTHORIZATION_CODE_VERIFIER` with PKCE static values generated above
55-
- Restart the python environment and Django server
54+
- Update `OIDC_CLIENT_ID` with the newly created app Client ID
55+
- Update the `OIDC_RSA_PRIVATE_KEY` with the newly created Private Key
56+
- Update `PATIENT_AUTHORIZATION_CODE_CHALLENGE` and `PATIENT_AUTHORIZATION_CODE_VERIFIER` with PKCE static values generated above
57+
- Restart the python environment and Django server
5658
1. Browse to http://localhost:8000/ and log in with the credentials `[email protected]` `Jhe1234!`and you should be directed to the `/portal/organizations` path with some example Organizations is the dropdown.
5759

5860
```{note} Static PKCE Values
@@ -69,19 +71,21 @@ It is understood this runs against best practices; however, this is only used fo
6971
After logging in on Windows, users are redirected to the portal, but a blank screen persists. This issue seems related to the `oidc-client-ts` library but is actually due to incorrectly set environment variables on Windows.
7072

7173
#### Cause
74+
7275
On Windows systems (particularly when running Django via Visual Studio Code or Git Bash), the environment variables related to OIDC in `settings.py` may become incorrectly formatted. This causes URLs to be malformed, preventing proper authentication.
7376

7477
#### Examples of Incorrectly Set Values
75-
- `OIDC_CLIENT_REDIRECT_URI`:
78+
79+
- `OIDC_CLIENT_REDIRECT_URI`:
7680
http://localhost:8000C:/Program Files/Git/auth/callback
77-
- `OIDC_CLIENT_AUTHORITY`:
81+
- `OIDC_CLIENT_AUTHORITY`:
7882
http://localhost:8000O://
7983

8084
#### Solution
8185

8286
The solution is to explicitly hardcode the correct values to OIDC variables in your `settings.py`. This will prevent incorrect path injections and ensure proper URL formation, resolving the blank screen issue after login on Windows machines.
8387

8488
```python
85-
OIDC_CLIENT_REDIRECT_URI = 'http://localhost:8000/auth/callback'
86-
OIDC_CLIENT_AUTHORITY = 'http://localhost:8000/o/'
87-
```
89+
OIDC_CLIENT_REDIRECT_URI = "http://localhost:8000/auth/callback"
90+
OIDC_CLIENT_AUTHORITY = "http://localhost:8000/o/"
91+
```

jupyterhealth-exchange/overview.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ JupyterHealth Exchange is a Django web application that facilitates the sharing
77
In the context of JupyterHealth, data producers are typically study participants (FHIR *Patients*) using the [CommonHealth Android App](https://play.google.com/store/apps/details?id=org.thecommonsproject.android.phr) linked to personal devices (e.g., Glucose Monitors), and data consumers are typically researchers (FHIR *Practitioners*).
88

99
```{image} ../assets/images/jupyterhealth-exchange-overview.jpg
10-
:alt: Diagram of application components
11-
:width: 800px
10+
---
11+
alt: Diagram of application components
12+
width: 800px
13+
---
1214
```
1315

1416
## Features
@@ -20,4 +22,4 @@ In the context of JupyterHealth, data producers are typically study participants
2022

2123
## Status
2224

23-
This project is currently in a Proof of Concept stage. You can monitor progress in our [GitHub Project](https://github.com/orgs/the-commons-project/projects/8).
25+
This project is currently in a Proof of Concept stage. You can monitor progress in our [GitHub Project](https://github.com/orgs/the-commons-project/projects/8).

jupyterhealth-exchange/security.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,7 @@ This will allow per-user access control, registered and enforced by SMART-on-FHI
8181
## Data Flow Diagram
8282

8383
```{image} ../assets/images/CHCS-Architecture.png
84-
:alt: CHCS Architecture
85-
```
84+
---
85+
alt: CHCS Architecture
86+
---
87+
```

jupyterhealth-exchange/web-ui.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ title: Web User Interface
3838
## Use Case Example
3939

4040
1. Sign up as a new user from the web UI.
41-
2. Create a new Organization.
42-
3. Add yourself to the Organization (View Organization > Users+).
43-
4. Create a new Study for the Organization (View Organization > Studies+).
44-
5. Create a new Patient for the Organization using a different email than (1) (Patients > Add Patient).
45-
6. Add Data Sources and Scopes to the Study (View Study > Data Sources+, Scope Requests+).
46-
7. Add the Patient to the Study (Patients > check box > Add Patient(s) to Study).
47-
8. Create an Invitation Link for the Patient (View Patient > Generate Invitation Link).
48-
9. Use the code in the invitation link with the Auth API to swap it for tokens.
49-
10. Upload Observations using the FHIR API.
41+
1. Create a new Organization.
42+
1. Add yourself to the Organization (View Organization > Users+).
43+
1. Create a new Study for the Organization (View Organization > Studies+).
44+
1. Create a new Patient for the Organization using a different email than (1) (Patients > Add Patient).
45+
1. Add Data Sources and Scopes to the Study (View Study > Data Sources+, Scope Requests+).
46+
1. Add the Patient to the Study (Patients > check box > Add Patient(s) to Study).
47+
1. Create an Invitation Link for the Patient (View Patient > Generate Invitation Link).
48+
1. Use the code in the invitation link with the Auth API to swap it for tokens.
49+
1. Upload Observations using the FHIR API.

0 commit comments

Comments
 (0)