Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-add static measurements #13

Merged
merged 4 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The Python type signature for the schema is as follows:

Patient = TypedDict('Patient', {
'patient_id': int,
'static_measurements': List[Measurement],
'events': List[Event],
})

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "meds"
version = "0.1.1"
version = "0.1.2"
description = "A data standard for working with event stream data"
readme = "README.md"
license = {text = "Apache-2.0"}
Expand Down
3 changes: 2 additions & 1 deletion src/meds/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def patient_schema(per_event_metadata_schema=pa.null()):
patient = pa.schema(
[
("patient_id", pa.int64()),
("static_measurements", pa.list_(measurement)),
("events", pa.list_(event)), # Require ordered by time
]
)
Expand All @@ -61,7 +62,7 @@ def patient_schema(per_event_metadata_schema=pa.null()):

Event = TypedDict("Event", {"time": datetime.datetime, "measurements": List[Measurement]})

Patient = TypedDict("Patient", {"patient_id": int, "events": List[Event]})
Patient = TypedDict("Patient", {"patient_id": int, "static_measurements": List[Measurement], "events": List[Event]})

############################################################

Expand Down
7 changes: 7 additions & 0 deletions tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ def test_patient_schema():
patient_data = [
{
"patient_id": 123,
"static_measurements": [{
"code": "some_static_code",
"text_value": "example",
"numeric_value": 1.0,
"datetime_value": datetime.datetime(2019, 1, 1, 0, 0, 0),
"metadata": None,
}],
"events": [{ # Nested list for events
"time": datetime.datetime(2020, 1, 1, 12, 0, 0),
"measurements": [{ # Nested list for measurements
Expand Down
Loading