-
Couldn't load subscription status.
- Fork 23
Closed
Labels
Component: GatewayIssue/PR that handles connections, API gatewaysIssue/PR that handles connections, API gatewaysgood first issueGood for newcomersGood for newcomershacktoberfestIssues suitable for hacktoberfestIssues suitable for hacktoberfest
Description
CDS Hook API responses currently include null values for all optional fields, making responses verbose and harder to read. This is especially noticeable in example scripts and documentation.
Example current output:
{
"cards": [{
"summary": "Sepsis Risk: 0.1",
"indicator": "info",
"source": {
"label": "ML prediction",
"url": null,
"icon": null,
"topic": null
},
"uuid": null,
"detail": "No action required.",
"suggestions": null,
"selectionBehavior": null,
"overrideReasons": null,
"links": null
}],
"systemActions": null
}Desired output:
{
"cards": [{
"summary": "Sepsis Risk: 0.1",
"indicator": "info",
"source": {
"label": "ML prediction"
},
"detail": "No action required."
}]
}Files to check:
scripts/predict_example.py(confirmed issue)- Any file calling
.model_dump()on CDS models healthchain/gateway/cds/(CDS service implementations)- Example scripts in
cookbook/
Goal:
Configure Pydantic serialization to exclude None values from API responses.
Acceptance Criteria:
- Find all locations where CDS models are serialized (search for
.model_dump()) - Add
exclude_none=Trueparameter to serialization calls - Verify responses are cleaner in examples (test manually)
- Ensure all tests still pass
- Response validation should still work correctly
Implementation:
Card(...).model_dump(exclude_none=True)Resources:
- Pydantic serialization docs
healthchain/models/responses/cdsresponse.pyfor model definitions- Test with:
python scripts/predict_example.pyand checkhttp://localhost:8000/docs
Metadata
Metadata
Assignees
Labels
Component: GatewayIssue/PR that handles connections, API gatewaysIssue/PR that handles connections, API gatewaysgood first issueGood for newcomersGood for newcomershacktoberfestIssues suitable for hacktoberfestIssues suitable for hacktoberfest
Type
Projects
Status
Done