Skip to content

Report¤

Report dataclass ¤

Report(
    id: str,
    entered_by: str,
    report_issue_date: date,
    measurement_start_date: date,
    measurement_stop_date: date,
    issuing_laboratory: IssuingLaboratory = IssuingLaboratory(),
    technical_procedure: str = "",
    checked_by: str = "",
    checked_date: date | None = None,
    conditions: Conditions = Conditions(),
    acceptance_criteria: AcceptanceCriteria = AcceptanceCriteria(),
    cvd_equations: tuple[CVDEquation, ...] = (),
    equations: tuple[Equation, ...] = (),
    files: tuple[File, ...] = (),
    deserialised: tuple[Deserialised, ...] = (),
    tables: tuple[Table, ...] = (),
)

Represents the report element in an equipment register.

Parameters:

Name Type Description Default
id str

The report identification number.

required
entered_by str

The name of the person who initially entered the <report> element in the register.

required
report_issue_date date

The date that the report was issued.

required
measurement_start_date date

The date that the calibration measurement started.

required
measurement_stop_date date

The date that the calibration measurement stopped.

required
issuing_laboratory IssuingLaboratory

Information about the laboratory that issued the calibration report.

IssuingLaboratory()
technical_procedure str

The technical procedure(s) that was(were) followed to perform the calibration.

''
checked_by str

The name of the person who checked the information in the <report> element.

''
checked_date date | None

The date that the information in the <report> element was last checked.

None
conditions Conditions

The conditions under which the report is valid.

Conditions()
acceptance_criteria AcceptanceCriteria

Acceptance criteria for the calibration report.

AcceptanceCriteria()
cvd_equations tuple[CVDEquation, ...]

Calibration data is expressed as coefficients for the Callendar-Van Dusen equation.

()
equations tuple[Equation, ...]

Calibration data is expressed as an equation.

()
files tuple[File, ...]

Calibration data is stored in another file (not in the equipment register).

()
deserialised tuple[Deserialised, ...]

Calibration data is stored in a serialised format and deserialised.

()
tables tuple[Table, ...]

Calibration data is expressed as a CSV table in the equipment register.

()

acceptance_criteria class-attribute instance-attribute ¤

acceptance_criteria: AcceptanceCriteria = field(
    default_factory=AcceptanceCriteria
)

Acceptance criteria for the calibration report.

checked_by class-attribute instance-attribute ¤

checked_by: str = ''

The name of the person who checked the information in the <report> element.

checked_date class-attribute instance-attribute ¤

checked_date: date | None = None

The date that the information in the <report> element was last checked.

conditions class-attribute instance-attribute ¤

conditions: Conditions = field(default_factory=Conditions)

The conditions under which the report is valid.

cvd_equations class-attribute instance-attribute ¤

cvd_equations: tuple[CVDEquation, ...] = ()

Calibration data is expressed as coefficients for the Callendar-Van Dusen equation.

deserialised class-attribute instance-attribute ¤

deserialised: tuple[Deserialised, ...] = ()

Calibration data is stored in a serialised format and deserialised.

entered_by instance-attribute ¤

entered_by: str

The name of the person who initially entered the <report> element in the register.

equations class-attribute instance-attribute ¤

equations: tuple[Equation, ...] = ()

Calibration data is expressed as an equation.

files class-attribute instance-attribute ¤

files: tuple[File, ...] = ()

Calibration data is stored in another file (not in the equipment register).

id instance-attribute ¤

id: str

The report identification number.

issuing_laboratory class-attribute instance-attribute ¤

issuing_laboratory: IssuingLaboratory = field(
    default_factory=IssuingLaboratory
)

Information about the laboratory that issued the calibration report.

measurement_start_date instance-attribute ¤

measurement_start_date: date

The date that the calibration measurement started.

measurement_stop_date instance-attribute ¤

measurement_stop_date: date

The date that the calibration measurement stopped.

report_issue_date instance-attribute ¤

report_issue_date: date

The date that the report was issued.

tables class-attribute instance-attribute ¤

tables: tuple[Table, ...] = ()

Calibration data is expressed as a CSV table in the equipment register.

technical_procedure class-attribute instance-attribute ¤

technical_procedure: str = ''

The technical procedure(s) that was(were) followed to perform the calibration.

from_xml classmethod ¤

from_xml(element: Element[str]) -> Report

Convert an XML element into a Report instance.

Parameters:

Name Type Description Default
element Element[str]

A report XML element from an equipment register.

required

Returns:

Type Description
Report

The Report instance.

Source code in src/msl/equipment/schema.py
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
@classmethod
def from_xml(cls, element: Element[str]) -> Report:
    """Convert an XML element into a [Report][msl.equipment.schema.Report] instance.

    Args:
        element: A [report][type_report] XML element from an equipment register.

    Returns:
        The [Report][msl.equipment.schema.Report] instance.
    """
    # Schema forces order until `acceptanceCriteria` and then uses xsd:choice, which
    # allows sub-elements to appear (or not appear) in any order, for the data elements.
    # Using str.endswith() allows for ignoring XML namespaces that may be associated with each tag
    cvd_equations: list[CVDEquation] = []
    equations: list[Equation] = []
    files: list[File] = []
    deserialised: list[Deserialised] = []
    tables: list[Table] = []
    for child in element[7:]:
        tag = child.tag
        if tag.endswith("equation"):
            equations.append(Equation.from_xml(child))
        elif tag.endswith("table"):
            tables.append(Table.from_xml(child))
        elif tag.endswith("cvdCoefficients"):
            cvd_equations.append(CVDEquation.from_xml(child))
        elif tag.endswith("file"):
            files.append(File.from_xml(child))
        else:
            deserialised.append(Deserialised.from_xml(child))

    a = element.attrib
    return cls(
        id=a["id"] or "",
        entered_by=a["enteredBy"] or "",
        checked_by=a.get("checkedBy", ""),
        checked_date=None if not a.get("checkedDate") else _date.fromisoformat(a["checkedDate"]),
        report_issue_date=_date.fromisoformat(element[0].text or ""),
        measurement_start_date=_date.fromisoformat(element[1].text or ""),
        measurement_stop_date=_date.fromisoformat(element[2].text or ""),
        issuing_laboratory=IssuingLaboratory.from_xml(element[3]),
        technical_procedure=element[4].text or "",
        conditions=Conditions.from_xml(element[5]),
        acceptance_criteria=AcceptanceCriteria.from_xml(element[6]),
        cvd_equations=tuple(cvd_equations),
        equations=tuple(equations),
        files=tuple(files),
        deserialised=tuple(deserialised),
        tables=tuple(tables),
    )

to_xml ¤

to_xml() -> Element[str]

Convert the Report class into an XML element.

Returns:

Type Description
Element[str]

The Report as an XML element.

Source code in src/msl/equipment/schema.py
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
def to_xml(self) -> Element[str]:
    """Convert the [Report][msl.equipment.schema.Report] class into an XML element.

    Returns:
        The [Report][msl.equipment.schema.Report] as an XML element.
    """
    a = {"id": self.id, "enteredBy": self.entered_by}
    if self.checked_by:
        a["checkedBy"] = self.checked_by
    if self.checked_date is not None:
        a["checkedDate"] = self.checked_date.isoformat()

    e = Element("report", attrib=a)

    rid = SubElement(e, "reportIssueDate")
    rid.text = self.report_issue_date.isoformat()

    start = SubElement(e, "measurementStartDate")
    start.text = self.measurement_start_date.isoformat()

    stop = SubElement(e, "measurementStopDate")
    stop.text = self.measurement_stop_date.isoformat()

    e.append(self.issuing_laboratory.to_xml())

    tp = SubElement(e, "technicalProcedure")
    tp.text = self.technical_procedure

    e.append(self.conditions)
    e.append(self.acceptance_criteria)
    e.extend(equation.to_xml() for equation in self.equations)
    e.extend(table.to_xml() for table in self.tables)
    e.extend(cvd.to_xml() for cvd in self.cvd_equations)
    e.extend(file.to_xml() for file in self.files)
    e.extend(deserialised.to_xml() for deserialised in self.deserialised)
    return e

IssuingLaboratory dataclass ¤

IssuingLaboratory(lab: str = '', person: str = '')

Information about the laboratory that issued a calibration report.

Parameters:

Name Type Description Default
lab str

The name of the laboratory that issued the calibration report.

''
person str

The name of a person at the laboratory that authorised the report.

''

lab class-attribute instance-attribute ¤

lab: str = ''

The name of the laboratory that issued the calibration report.

person class-attribute instance-attribute ¤

person: str = ''

The name of a person at the laboratory that authorised the report.

from_xml classmethod ¤

from_xml(element: Element[str]) -> IssuingLaboratory

Convert an XML element into a IssuingLaboratory instance.

Parameters:

Name Type Description Default
element Element[str]

An <issuingLaboratory> element from a report element in an equipment register.

required

Returns:

Type Description
IssuingLaboratory

The IssuingLaboratory instance.

Source code in src/msl/equipment/schema.py
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
@classmethod
def from_xml(cls, element: Element[str]) -> IssuingLaboratory:
    """Convert an XML element into a [IssuingLaboratory][msl.equipment.schema.IssuingLaboratory] instance.

    Args:
        element: An `<issuingLaboratory>` element from a [report][type_report] element
            in an equipment register.

    Returns:
        The [IssuingLaboratory][msl.equipment.schema.IssuingLaboratory] instance.
    """
    return cls(
        lab=element.text or "",
        person=element.attrib.get("person", ""),
    )

to_xml ¤

to_xml() -> Element[str]

Convert the IssuingLaboratory class into an XML element.

Returns:

Type Description
Element[str]

The IssuingLaboratory as an XML element.

Source code in src/msl/equipment/schema.py
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
def to_xml(self) -> Element[str]:
    """Convert the [IssuingLaboratory][msl.equipment.schema.IssuingLaboratory] class into an XML element.

    Returns:
        The [IssuingLaboratory][msl.equipment.schema.IssuingLaboratory] as an XML element.
    """
    a = {"person": self.person} if self.person else {}
    e = Element("issuingLaboratory", attrib=a)
    e.text = self.lab
    return e