Creating an XML Schema (XSD) can be useful in a variety of situations in the real world. This is especially true when exchanging information between different systems. Standards are required this is why we need XML schema.
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="patent">
<xs:complexType>
<xs:sequence>
<xs:element name="PatientID" type="xs:int"/>
<xs:element name="FirstName" type="xs:string" maxLength="50"/>
<xs:element name="LastName" type="xs:string" maxLength="50"/>
<xs:element name="DateOfBirth" type="xs:date"/>
<xs:element name="Gender" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Here is a concrete example.
Case study: Healthcare data exchange
Sometimes Hospitals share patient medical records with insurance companies to process claims. Hospital electronic health record (EHR) systems and insurance company claims processing systems must have a standardized method for exchanging information to guarantee accurate and consistent communication.
Problem
Medical records contain complex and sensitive information, such as patient demographics. Medical history, diagnosis code, treatment details and billing information. Systems can display this information in several ways. If there is no general standard The risk of miscommunication or data loss increases. As a result, the claim approval process is complicated. and may result in delays in patient care.
Solution is XML schema
XML Schema can be designed to define the structure of patient medical records for data exchange. This plan will help ensure that hospitals and insurance companies use a consistent format for data elements and types.
Let’s suppose the hospital is storing the Patient’s information, Medical history, Diagnosis details, and Treatment details., etc. information for the patient.
Here is a step by step details:
Patient information:
- PatientID: Unique identifier for the patient (integer).
- FirstName, LastName: Patient name (string, max length 50)
- DateOfBirth: Date of birth (date format)
- Gender: Gender of the patient (Number: Male, Female, Other)
Then, we will define this information in the like below:
<xs:sequence>
<xs:element name="PatientID" type="xs:int"/>
<xs:element name="FirstName" type="xs:string" maxLength="50"/>
<xs:element name="LastName" type="xs:string" maxLength="50"/>
<xs:element name="DateOfBirth" type="xs:date"/>
<xs:element name="Gender" type="xs:string"/>
</xs:sequence>
Medical history:
- Status: Medical Condition (String)
- StartDate: Admission Date (date format)
- EndDate: condition resolved date. (date format)
<xs:sequence>
<xs:element name="Condition" type="xs:string"/>
<xs:element name="StartDate" type="xs:date"/>
<xs:element name="EndDate" type="xs:date" minOccurs="0"/>
</xs:sequence>
Diagnosis:
- DiagnosisCode: ICD-10 code for the diagnosis (string, length 7).
- Description: Description of the diagnosis (string, max length 200).
<xs:sequence>
<xs:element name="DiagnosisCode" type="xs:string" maxLength="7"/>
<xs:element name="Description" type="xs:string" maxLength="200"/>
</xs:sequence>
Treatment details:
- TreatmentCode: The code representing the treatment provided (string, max length 10).
- StartDate: Date of treatment start. (date format)
- EndDate: End date management (Date format)
<xs:sequence>
<xs:element name="TreatmentCode" type="xs:string" maxLength="10"/>
<xs:element name="StartDate" type="xs:date"/>
<xs:element name="EndDate" type="xs:date" minOccurs="0"/>
</xs:sequence>
Billing information:
- TotalAmount: Total amount billed (decimal, up to 2 decimal places)
- InsuranceCoveredAmount: Amount covered by insurance (decimal, up to 2 decimal places)
- PatientDueAmount: Amount paid by the patient (decimal, up to 2 decimal places).
<xs:sequence>
<xs:element name="TotalAmount" type="xs:decimal"/>
<xs:element name="InsuranceCoveredAmount" type="xs:decimal"/>
<xs:element name="PatientDueAmount" type="xs:decimal"/>
</xs:sequence>
Here is the FULL schema of the above properties:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="MedicalRecord">
<xs:complexType>
<xs:sequence>
<xs:element name="PatientInfo">
<xs:complexType>
<xs:sequence>
<xs:element name="PatientID" type="xs:int"/>
<xs:element name="FirstName" type="xs:string" maxLength="50"/>
<xs:element name="LastName" type="xs:string" maxLength="50"/>
<xs:element name="DateOfBirth" type="xs:date"/>
<xs:element name="Gender" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="MedicalHistory">
<xs:complexType>
<xs:sequence>
<xs:element name="Condition" type="xs:string"/>
<xs:element name="StartDate" type="xs:date"/>
<xs:element name="EndDate" type="xs:date" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Diagnosis">
<xs:complexType>
<xs:sequence>
<xs:element name="DiagnosisCode" type="xs:string" maxLength="7"/>
<xs:element name="Description" type="xs:string" maxLength="200"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Treatment">
<xs:complexType>
<xs:sequence>
<xs:element name="TreatmentCode" type="xs:string" maxLength="10"/>
<xs:element name="StartDate" type="xs:date"/>
<xs:element name="EndDate" type="xs:date" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="BillingInfo">
<xs:complexType>
<xs:sequence>
<xs:element name="TotalAmount" type="xs:decimal"/>
<xs:element name="InsuranceCoveredAmount" type="xs:decimal"/>
<xs:element name="PatientDueAmount" type="xs:decimal"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
This schema defines the structure of a medical record and ensures that all exchanged records conform to this structure, providing a robust foundation for data integrity and communication between the hospital and the insurance company.
If you want to know how to define the XML schema, see XML Schema Introduction.
Advantages of using XML schema
- Data validation: Ensure that the data exchanged between the hospital and insurance company follows the required format.
- Helps reduce errors Interoperability: Systems can easily understand and process data without custom parsing.
- Documentation: The XML schema serves as a formal contract between the two parties. It specifies the structure of the information exchanged.