Teine-meeskond: Difference between revisions
From ICO wiki
Jump to navigationJump to search
No edit summary |
|||
Line 248: | Line 248: | ||
==Style Sheet 3== | ==Style Sheet 3== | ||
<source lang="xml"> | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<!-- Very simple XSLT, print out all syptom fever and it's description --> | |||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |||
<xsl:output method="html" indent="yes"/> | |||
<xsl:template match="/"> | |||
<html> | |||
<body> | |||
<h2>Fever description</h2> | |||
<table border="1"> | |||
<tr bgcolor="#9acd32"> | |||
<th>Symptom</th> | |||
<th>Description</th> | |||
</tr> | |||
<xsl:for-each select="PatientData/Patient/MedicalHistory/Complaint[Symptom='Fever']"> | |||
<tr> | |||
<td> | |||
<xsl:value-of select="Symptom"/> | |||
</td> | |||
<td> | |||
<xsl:value-of select="Description"/> | |||
</td> | |||
</tr> | |||
</xsl:for-each> | |||
</table> | |||
</body> | |||
</html> | |||
</xsl:template> | |||
</xsl:stylesheet> | |||
</source> |
Revision as of 20:47, 6 May 2013
Võrgurakendused II: hajussüsteemide ehitamine
Kodutöö leht
Rühma liikmed:
- Nikolai Skorohodov
- Ragnar Rattas
- Rynga Bogdanov
XML
Faili kirjeldus
XML fail
<?xml version="1.0" encoding="utf-8" ?>
<!-- Simple XML datafile for holding patients data -->
<PatientData>
<Patient id="1" hasInsurance="yes">
<FirstName>Mari-Liis</FirstName>
<LastName>Männik</LastName>
<PersonalCode>47101010033</PersonalCode>
<MedicalHistory>
<Complaint id="1" isPrivate="no">
<Symptom>Fever</Symptom>
<BeginDateTime>2013-05-28T09:00:00</BeginDateTime>
<Description>I'm feeling sick and I have 38 degrees fever!</Description>
<Treatment>
<Medicine id="1" isPrescriptionDrug="no">
<Name>Aspirin</Name>
<BeginDate>2013-05-28</BeginDate>
<EndDate>2013-05-30</EndDate>
<Notes>Take one tablet three times a day.</Notes>
</Medicine>
<Medicine id="2" isPrescriptionDrug="yes">
<Name>Xanax</Name>
<BeginDate>2013-05-28</BeginDate>
<EndDate>2013-05-30</EndDate>
<Notes>Take two pills per day and enjoy your flight!</Notes>
</Medicine>
</Treatment>
</Complaint>
<Complaint id="2" isPrivate="yes">
<Symptom>Headache</Symptom>
<BeginDateTime>2013-05-28T09:00:00</BeginDateTime>
<EndDateTime>2013-05-30T09:00:00</EndDateTime>
<Description>I'm having random headaches</Description>
<Treatment>
<Medicine id="2" isPrescriptionDrug="yes">
<Name>Xanax</Name>
<BeginDate>2013-05-28</BeginDate>
<EndDate>2013-05-30</EndDate>
<Notes>Take one pill per day and enjoy!</Notes>
</Medicine>
</Treatment>
</Complaint>
</MedicalHistory>
</Patient>
<Patient id="2" hasInsurance="no">
<FirstName>Igor</FirstName>
<LastName>Žaikovski</LastName>
<PersonalCode>37101010021</PersonalCode>
<MedicalHistory>
<Complaint id="1" isPrivate="no">
<Symptom>Can't sleep</Symptom>
<BeginDateTime>2013-05-28T09:00:00</BeginDateTime>
<Description>I can't sleep.</Description>
<Treatment>
<Medicine id="3" isPrescriptionDrug="no">
<Name>Sleeping pills</Name>
<BeginDate>2013-05-28</BeginDate>
<EndDate>2013-06-30</EndDate>
<Notes>Take one pill before going to sleep.</Notes>
</Medicine>
</Treatment>
</Complaint>
</MedicalHistory>
</Patient>
</PatientData>
XML schema (XSD)
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- Start of PatientData -->
<xs:element name="PatientData">
<xs:complexType>
<xs:sequence>
<!-- Start of patinet element description -->
<xs:element name="Patient" maxOccurs="unbounded">
<!-- Start of patient child elements description -->
<xs:complexType>
<xs:sequence>
<xs:element name="FirstName" type="xs:string" />
<xs:element name="LastName" type="xs:string" />
<!-- Patients Estonian national personal code (without county code), i.e. 380xxxxxxxxx -->
<xs:element name="PersonalCode" type="xs:integer" />
<!-- Start of MedicalHistory, only one is allowed, all complaints go under this element -->
<xs:element minOccurs="0" maxOccurs="1" name="MedicalHistory">
<xs:complexType>
<xs:sequence>
<!-- Start of patient complaints -->
<xs:element name="Complaint" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<!-- Illness symptoms -->
<xs:element name="Symptom" type="xs:string" />
<!-- Start and end dateTime of symptoms -->
<xs:element name="BeginDateTime" minOccurs="0" type="xs:dateTime" />
<xs:element name="EndDateTime" minOccurs="0" type="xs:dateTime" />
<!-- Longer explanation about symptoms -->
<xs:element name="Description" type="xs:string" />
<!-- Doctors treatment for this complaint -->
<xs:element name="Treatment" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<!-- Start of medicine -->
<xs:element maxOccurs="unbounded" name="Medicine">
<!-- Medicines unique ID -->
<xs:complexType>
<xs:sequence>
<!-- Medicines name -->
<xs:element name="Name" type="xs:string" />
<!-- For how long to take the medicine -->
<xs:element name="BeginDate" minOccurs="0" type="xs:date" />
<xs:element name="EndDate" minOccurs="0" type="xs:date" />
<!-- Some notes how to take the medicine -->
<xs:element name="Notes" type="xs:string" />
</xs:sequence>
<!-- Medicines unique ID -->
<xs:attribute name="id" type="xs:integer" use="required" />
<!-- Is it prescription drug? Only allow yes/no -->
<xs:attribute name="isPrescriptionDrug" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="yes|no"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<!-- End of medicine -->
</xs:element>
</xs:sequence>
</xs:complexType>
<!-- End of treatment -->
</xs:element>
</xs:sequence>
<!-- Complaint unique ID -->
<xs:attribute name="id" type="xs:integer" use="required" />
<!-- Is this complaint very delicate issue and it should be hidden to other doctors -->
<xs:attribute name="isPrivate" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="yes|no"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<!-- End of MedicalHistory -->
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:integer" use="required" />
<!-- Is patient insured at Haigekassa? Only allow yes/no -->
<xs:attribute name="hasInsurance" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="yes|no"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<!-- Patients unique ID -->
<!-- End of Patient -->
</xs:element>
</xs:sequence>
</xs:complexType>
<!-- End of PatientData -->
</xs:element>
</xs:schema>
Style Sheet 1
<?xml version="1.0" encoding="utf-8"?>
<!-- Very simple XSLT, print out all patients -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html>
<head>
<title>List of patients</title>
</head>
<body>
<h1>List of patients</h1>
<ul>
<xsl:for-each select="PatientData/Patient">
<li>
<xsl:value-of select="FirstName"/>
<xsl:text> </xsl:text>
<xsl:value-of select="LastName"/>
<xsl:text> (</xsl:text>
<xsl:value-of select="PersonalCode"/>
<xsl:text>)</xsl:text>
</li>
</xsl:for-each>
</ul>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Style Sheet 2
<?xml version="1.0" encoding="utf-8"?>
<!-- Very simple XSLT, print out all syptoms patients have ever had -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<h2>List of symptoms</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Symptom</th>
</tr>
<xsl:for-each select="PatientData/Patient/MedicalHistory/Complaint">
<tr>
<td><xsl:value-of select="Symptom"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Style Sheet 3
<?xml version="1.0" encoding="utf-8"?>
<!-- Very simple XSLT, print out all syptom fever and it's description -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<h2>Fever description</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Symptom</th>
<th>Description</th>
</tr>
<xsl:for-each select="PatientData/Patient/MedicalHistory/Complaint[Symptom='Fever']">
<tr>
<td>
<xsl:value-of select="Symptom"/>
</td>
<td>
<xsl:value-of select="Description"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>