RadReport

RadReport(
    self,
    title: Optional[str] = None,
    history: Optional[str] = None,
    technique: Optional[str] = None,
    comparison: Optional[str] = None,
    findings: Optional[str] = None,
    impression: Optional[str] = None,
)

A dataclass representing a radiology report

This class holds the different sections commonly found in radiology reports, including title, clinical history, technique, comparison with prior studies, findings, and impression.

Parameters

Name Type Description Default
title str The title or header section of the report None
history str The clinical history or indication section None
technique str The imaging technique or procedure details section None
comparison str The comparison with prior studies section None
findings str The radiological findings or description section None
impression str The impression or conclusion section None

Examples

>>> report = RadReport(
...     title="CT BRAIN WITHOUT CONTRAST",
...     history="25F with headache",
...     findings="Normal brain parenchyma",
...     impression="No acute intracranial abnormality"
... )
>>> report.to_dict()
{
    'title': 'CT BRAIN WITHOUT CONTRAST',
    'history': '25F with headache',
    'findings': 'Normal brain parenchyma',
    'impression': 'No acute intracranial abnormality',
    'technique': None,
    'comparison': None
}

Methods

Name Description
to_dict Convert the RadReport to a dictionary.
to_json Convert the RadReport to a JSON string.

to_dict

RadReport.to_dict(exclude_none: bool = False)

Convert the RadReport to a dictionary.

This method converts the RadReport object to a dictionary format.

Parameters

Name Type Description Default
exclude_none bool If True, excludes keys with None values from the output dictionary. If False, includes all keys (default). False

Returns

Name Type Description
Dict[str, Any] A dictionary containing the report sections as key-value pairs.

Examples

>>> report = RadReport(title="CT BRAIN", findings="Normal")
>>> report.to_dict()
{'title': 'CT BRAIN', 'history': None, 'technique': None,
 'comparison': None, 'findings': 'Normal', 'impression': None}
>>> report.to_dict(exclude_none=True)
{'title': 'CT BRAIN', 'findings': 'Normal'}

to_json

RadReport.to_json(exclude_none: bool = False, **kwargs)

Convert the RadReport to a JSON string.

Similar to pandas DataFrame.to_json(), this method converts the RadReport object to a JSON formatted string.

Parameters

Name Type Description Default
exclude_none bool If True, excludes keys with None values from the output JSON. If False, includes all keys (default). False
**kwargs dict Additional keyword arguments to pass to json.dumps(). Common options include: - indent: int, for pretty printing - sort_keys: bool, to sort keys alphabetically {}

Returns

Name Type Description
str A JSON string representation of the report.

Examples

>>> report = RadReport(title="CT BRAIN", findings="Normal")
>>> print(report.to_json(indent=2))
{
  "title": "CT BRAIN",
  "history": null,
  "technique": null,
  "comparison": null,
  "findings": "Normal",
  "impression": null
}
>>> print(report.to_json(exclude_none=True))
{"title":"CT BRAIN","findings":"Normal"}