UKRDC-XSData
XSData models for the UKRDC.
Installation
pip install ukrdc-xsdata
Basic usage
Creating UKRDC XML
import datetime
from xsdata.models.datatype import XmlDate
from ukrdc_xsdata.ukrdc import PatientRecord, Patient, types
record = PatientRecord(
sending_facility = "RFBAK",
sending_extract = "PV",
patient = Patient(
birth_time = XmlDate.from_datetime(datetime.datetime(year=1950, month=10, day=1)),
gender = types.gender.Gender.VALUE_9,
names = Patient.Names(
name = [
types.Name(
use="L",
family="A TEST PATIENT",
given="TESTING"
)
]
),
addresses = Patient.Addresses(
address = [
types.Address(
street="1 TEST STREET",
town="TEST TOWN",
county="TEST COUNTY",
postcode="DK1 3GG",
country=types.Address.Country(
coding_standard="ISO3166-1",
code="GB",
description="United Kingdom"
)
)
]
),
patient_numbers = types.PatientNumbers(
patient_number = [
types.PatientNumber(
number="1111111111",
organization=types.PatientNumberOrganization.CHI,
number_type=types.PatientNumberNumberType.NI,
),
types.PatientNumber(
number="U0000000",
organization=types.PatientNumberOrganization.LOCALHOSP,
number_type=types.PatientNumberNumberType.MRN,
)
]
)
)
)
from xsdata.formats.dataclass.serializers.xml import XmlSerializer
print(XmlSerializer().render(record))
will render
<?xml version="1.0" encoding="UTF-8"?>
<ns0:PatientRecord xmlns:ns0="http://www.rixg.org.uk/">
<SendingFacility>RFBAK</SendingFacility>
<SendingExtract>PV</SendingExtract>
<Patient>
<PatientNumbers>
<PatientNumber>
<Number>1111111111</Number>
<Organization>CHI</Organization>
<NumberType>NI</NumberType>
</PatientNumber>
<PatientNumber>
<Number>U0000000</Number>
<Organization>LOCALHOSP</Organization>
<NumberType>MRN</NumberType>
</PatientNumber>
</PatientNumbers>
<Names>
<Name use="L">
<Family>A TEST PATIENT</Family>
<Given>TESTING</Given>
</Name>
</Names>
<BirthTime>1950-10-01T00:00:00</BirthTime>
<Gender>9</Gender>
<Addresses>
<Address>
<Street>1 TEST STREET</Street>
<Town>TEST TOWN</Town>
<County>TEST COUNTY</County>
<Postcode>DK1 3GG</Postcode>
<Country>
<CodingStandard>ISO3166-1</CodingStandard>
<Code>GB</Code>
<Description>United Kingdom</Description>
</Country>
</Address>
</Addresses>
</Patient>
</ns0:PatientRecord>
Reading UKRDC XML
in_xml = """
<?xml version="1.0" encoding="UTF-8"?>
<ns0:PatientRecord xmlns:ns0="http://www.rixg.org.uk/">
<SendingFacility>RFBAK</SendingFacility>
<SendingExtract>PV</SendingExtract>
<Patient>
<PatientNumbers>
<PatientNumber>
<Number>1111111111</Number>
<Organization>CHI</Organization>
<NumberType>NI</NumberType>
</PatientNumber>
<PatientNumber>
<Number>U0000000</Number>
<Organization>LOCALHOSP</Organization>
<NumberType>MRN</NumberType>
</PatientNumber>
</PatientNumbers>
<Names>
<Name use="L">
<Family>A TEST PATIENT</Family>
<Given>TESTING</Given>
</Name>
</Names>
<BirthTime>1950-10-01T00:00:00</BirthTime>
<Gender>9</Gender>
<Addresses>
<Address>
<Street>1 TEST STREET</Street>
<Town>TEST TOWN</Town>
<County>TEST COUNTY</County>
<Postcode>DK1 3GG</Postcode>
<Country>
<CodingStandard>ISO3166-1</CodingStandard>
<Code>GB</Code>
<Description>United Kingdom</Description>
</Country>
</Address>
</Addresses>
</Patient>
</ns0:PatientRecord>
"""
from ukrdc_xsdata.ukrdc import PatientRecord
from xsdata.formats.dataclass.parsers import XmlParser
obj = XmlParser().from_string(in_xml, PatientRecord)
The object obj can then be used to access the data as a standard Python dataclass instance.
E.g. obj.sending_facility or obj.patient.names.name.
Metadata
Release files for ukrdc-xsdata 4.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ukrdc_xsdata-4.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Release files / ukrdc_xsdata-4.3.0-py3-none-any.whl
| Download URL | ukrdc_xsdata-4.3.0-py3-none-any.whl |
|---|---|
| Size | 87.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3a95e156c2459c30dd338ee8bc6ad840777f17ee7ec3fb412c44b84c5e871496
|
|
BLAKE2b-256 checksum How to use checksums |
7448255d171b0c8f021f3aecb5344ffb34036a2a0e45e8cc5143c3785917359a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for ukrdc-xsdata 4.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.