+ Indivo2Trig.xsl
authorEric Prud'hommeaux <eric@w3.org>
Thu, 30 Sep 2010 12:15:04 -0400
changeset 10 74371f75a6d3
parent 9 dfea1107c315
child 11 874112250113
+ Indivo2Trig.xsl
syntheticPatients/AD_PCHR_1-indivo.xml
syntheticPatients/AD_PCHR_1-tmo.trig
syntheticPatients/Indivo2Trig.xsl
syntheticPatients/Pat2Indivo2.xsl
--- a/syntheticPatients/AD_PCHR_1-indivo.xml	Sat Jul 17 20:01:55 2010 -0400
+++ b/syntheticPatients/AD_PCHR_1-indivo.xml	Thu Sep 30 12:15:04 2010 -0400
@@ -1,7 +1,7 @@
 <!-- -*- XML -*- -->
 <?xml-stylesheet type="text/xsl" href="Patrdf2html.xsl"?><Envelope xmlns="http://indivo.org/vocab/xml/documents#">
   <CurrentStatus>
-    <Contact xmlns="">
+    <Contact>
     <name>
         <fullName>George Andrew Tour</fullName>
         <givenName>George</givenName>
@@ -31,21 +31,21 @@
 </Contact>
     <PrimaryCarePhysician>
       <name>
-        <fullName xmlns="">Henry No</fullName>
-        <givenName xmlns="">Henry</givenName>
-        <familyName xmlns="">No</familyName>
+        <fullName>Henry No</fullName>
+        <givenName>Henry</givenName>
+        <familyName>No</familyName>
       </name>
       <address>
-        <streetAddress xmlns="">20 Water St.</streetAddress>
-        <postalCode xmlns="">53326</postalCode>
-        <locality xmlns="">New Hope</locality>
-        <region xmlns="">Massachusetts</region>
-        <country xmlns="">US</country>
-        <timeZone xmlns="">-5GMT</timeZone>
+        <streetAddress>20 Water St.</streetAddress>
+        <postalCode>53326</postalCode>
+        <locality>New Hope</locality>
+        <region>Massachusetts</region>
+        <country>US</country>
+        <timeZone>-5GMT</timeZone>
       </address>
-      <phoneNumber xmlns="">17891011782</phoneNumber>
+      <phoneNumber>17891011782</phoneNumber>
     </PrimaryCarePhysician>
-    <Demographics xmlns="">
+    <Demographics>
     <dateOfBirth>1934-05-15</dateOfBirth>
     <dateOfDeath>XXXX-XX-XX</dateOfDeath>
     <gender>Male</gender>
@@ -74,7 +74,7 @@
             <value>6.25</value>
             <unit type="http://indivo.org/codes/units#" value="MG"/>
           </strength>
-          <frequency xmlns="">b.i.d.</frequency>
+          <frequency>b.i.d.</frequency>
         </medication>
         <prescribedBy>
           <name>Henry No</name>
@@ -96,7 +96,7 @@
             <value>10</value>
             <unit type="http://indivo.org/codes/units#" value="MG"/>
           </strength>
-          <frequency xmlns="">q.d.</frequency>
+          <frequency>q.d.</frequency>
         </medication>
         <prescribedBy>
           <name>Henry No</name>
@@ -118,7 +118,7 @@
             <value>1.00</value>
             <unit type="http://indivo.org/codes/units#" value="MG"/>
           </strength>
-          <frequency xmlns="">q.d.</frequency>
+          <frequency>q.d.</frequency>
         </medication>
         <prescribedBy>
           <name>Henry No</name>
@@ -141,7 +141,7 @@
             <value>5.00</value>
             <unit type="http://indivo.org/codes/units#" value="MG"/>
           </strength>
-          <frequency xmlns="">q.d.</frequency>
+          <frequency>q.d.</frequency>
         </medication>
         <prescribedBy>
           <name>Henry No</name>
@@ -163,7 +163,7 @@
             <value>5.00</value>
             <unit type="http://indivo.org/codes/units#" value="MG"/>
           </strength>
-          <frequency xmlns="">q.d.</frequency>
+          <frequency>q.d.</frequency>
         </medication>
         <prescribedBy>
           <name>Henry No</name>
@@ -178,25 +178,25 @@
         <dateOnset>2009-05-15T12:00:00</dateOnset>
         <name type="http://indivo.org/codes/ICD9" value="410">hypertension</name>
         <comments>...</comments>
-        <diagnosedBy xmlns="">Henry No</diagnosedBy>
+        <diagnosedBy>Henry No</diagnosedBy>
       </Problem>
       <Problem>
         <dateOnset>2009-05-20T12:00:00</dateOnset>
         <name type="http://indivo.org/codes/ICD9" value="272">hypercholesterolaemia</name>
         <comments>...</comments>
-        <diagnosedBy xmlns="">Henry No</diagnosedBy>
+        <diagnosedBy>Henry No</diagnosedBy>
       </Problem>
       <Problem>
         <dateOnset>2009-05-20T12:00:00</dateOnset>
         <name type="http://indivo.org/codes/ICD9" value="427">atrial fibrillation</name>
         <comments>...</comments>
-        <diagnosedBy xmlns="">Henry No</diagnosedBy>
+        <diagnosedBy>Henry No</diagnosedBy>
       </Problem>
       <Problem>
         <dateOnset>2009-08-10T12:00:00</dateOnset>
         <name type="http://indivo.org/codes/ICD9" value="331">alzheimer’s disease</name>
         <comments>...</comments>
-        <diagnosedBy xmlns="">Henry No</diagnosedBy>
+        <diagnosedBy>Henry No</diagnosedBy>
       </Problem>
     </Conditions>
     <Procedures>
@@ -232,8 +232,8 @@
     </Allergies>
     <Immunizations>
       <Immunization>
-        <dateAdministered>1940-01-01T12:00:00</dateAdministered>
-        <administeredBy xmlns="">Henry No</administeredBy>
+        <dateAdministered>1940-01-01T00:00:00</dateAdministered>
+        <administeredBy>Henry No</administeredBy>
         <vaccine>
           <type>measles</type>
           <manufacturer/>
@@ -245,8 +245,8 @@
         <adverseEvent/>
       </Immunization>
       <Immunization>
-        <dateAdministered>1940-01-01T12:00:00</dateAdministered>
-        <administeredBy xmlns="">Henry No</administeredBy>
+        <dateAdministered>1940-01-01T00:00:00</dateAdministered>
+        <administeredBy>Henry No</administeredBy>
         <vaccine>
           <type>mumps</type>
           <manufacturer/>
@@ -258,8 +258,8 @@
         <adverseEvent/>
       </Immunization>
       <Immunization>
-        <dateAdministered>1949-01-01T12:00:00</dateAdministered>
-        <administeredBy xmlns="">Henry No</administeredBy>
+        <dateAdministered>1949-01-01T00:00:00</dateAdministered>
+        <administeredBy>Henry No</administeredBy>
         <vaccine>
           <type>rubella</type>
           <manufacturer/>
@@ -271,8 +271,8 @@
         <adverseEvent/>
       </Immunization>
       <Immunization>
-        <dateAdministered>2005-01-01T12:00:00</dateAdministered>
-        <administeredBy xmlns="">Henry No</administeredBy>
+        <dateAdministered>2005-01-01T00:00:00</dateAdministered>
+        <administeredBy>Henry No</administeredBy>
         <vaccine>
           <type>tetanus</type>
           <manufacturer/>
@@ -284,7 +284,7 @@
         <adverseEvent/>
       </Immunization>
     </Immunizations>
-    <lifestyle xmlns="">  
+    <lifestyle>  
        <alcoholConsumption>
            <frequency>2</frequency>
            <units>week</units>
@@ -312,7 +312,7 @@
             <date>2004-08-15</date>
        </diet>
   </lifestyle>
-    <familyHistory xmlns="">
+    <familyHistory>
       <subject id="1">
          <relation>maternalGrandmother</relation>
          <fname>Susie</fname>
@@ -375,4 +375,300 @@
       </subject>
 </familyHistory>
   </CurrentStatus>
+  <Encounter>
+    <Date>2009-05-15</Date>
+    <Contact>
+      <fullName>Henry No</fullName>
+    </Contact>
+    <MedicalBaseline>true</MedicalBaseline>
+    <MedicalTest>Annual Medical</MedicalTest>
+    <ReportedSymptoms>false</ReportedSymptoms>
+    <WorkingDiagnosis>
+      <PreliminaryDiagnosis>
+        <DiagnosisDescription>false</DiagnosisDescription>
+      </PreliminaryDiagnosis>
+    </WorkingDiagnosis>
+    <LabTests>
+      <Test>
+        <dateMeasured>2009-05-15</dateMeasured>
+        <name>Blood count; complete (CBC), automated (Hgb, Hct, RBC, WBC and platelet count) and automated differential WBC count</name>
+        <status>@@@</status>
+      </Test>
+      <Test>
+        <dateMeasured>2009-05-15</dateMeasured>
+        <name>Lipid panel</name>
+        <status>@@@</status>
+      </Test>
+      <Test>
+        <dateMeasured>2009-05-15</dateMeasured>
+        <name>Hepatic function panel</name>
+        <status>@@@</status>
+      </Test>
+      <Test>
+        <dateMeasured>2009-05-15</dateMeasured>
+        <name>Renal function panel</name>
+        <status>@@@</status>
+      </Test>
+      <Test>
+        <dateMeasured>2009-05-15</dateMeasured>
+        <name>Thyroid stimulating hormone (TSH)</name>
+        <status>@@@</status>
+      </Test>
+    </LabTests>
+  </Encounter>
+  <Encounter>
+    <Date>2009-05-17</Date>
+    <Contact>
+      <fullName>Henry No</fullName>
+    </Contact>
+    <MedicalBaseline>true</MedicalBaseline>
+    <MedicalTest>routine</MedicalTest>
+    <ReportedSymptoms>false</ReportedSymptoms>
+    <WorkingDiagnosis>
+      <PreliminaryDiagnosis>
+          <DiagnosisDescription>atrial fibrillation</DiagnosisDescription>
+          <ICD9>427</ICD9>
+          <ICD9Description>atrial fibrillation</ICD9Description>
+       </PreliminaryDiagnosis>
+      <DifferentialDiagnosis>
+          <ICD9>427</ICD9>
+          <ICD9Description>Atrial fibrillation</ICD9Description>
+       </DifferentialDiagnosis>
+    </WorkingDiagnosis>
+    <LabTests>
+      <Test>
+        <dateMeasured>2009-05-17</dateMeasured>
+        <name>Rhythm ECG</name>
+        <HCLSresult>
+          <LabTest>
+            <variant_Synonyms/>
+          </LabTest>
+        </HCLSresult>
+        <status>@@@</status>
+      </Test>
+    </LabTests>
+  </Encounter>
+  <Encounter>
+    <Date>2009-05-18</Date>
+    <Contact>
+      <fullName>Henry No</fullName>
+    </Contact>
+    <MedicalBaseline>true</MedicalBaseline>
+    <MedicalTest>true</MedicalTest>
+    <ReportedSymptoms>irregular pulse</ReportedSymptoms>
+    <WorkingDiagnosis>
+      <PreliminaryDiagnosis>
+        <DiagnosisDescription>atrial fibrillation</DiagnosisDescription>
+      </PreliminaryDiagnosis>
+    </WorkingDiagnosis>
+    <LabTests>
+      <Test>
+        <dateMeasured>2009-05-18</dateMeasured>
+        <name>Ambry test </name>
+        <SNPresult>
+          <LabTest>
+            <variant_Synonyms>VKOR; MST134; MST576; VKCFD2; EDTP308; MGC2694; FLJ00289; IMAGE345520</variant_Synonyms>
+          </LabTest>
+        </SNPresult>
+        <status>@@@</status>
+      </Test>
+      <Test>
+        <dateMeasured>2009-05-18</dateMeasured>
+        <name/>
+        <SNPresult>
+          <LabTest>
+            <variant_Synonyms> CPC9; CYP2C; CYP2C10; MGC88320; P450IIC9; MGC149605; CYP2C9 </variant_Synonyms>
+          </LabTest>
+        </SNPresult>
+        <status>@@@</status>
+      </Test>
+    </LabTests>
+  </Encounter>
+  <Encounter>
+    <Date>2009-05-20</Date>
+    <Contact>
+      <fullName>Henry No</fullName>
+    </Contact>
+    <MedicalBaseline>true</MedicalBaseline>
+    <MedicalTest>false</MedicalTest>
+    <ReportedSymptoms>none</ReportedSymptoms>
+    <WorkingDiagnosis>
+      <PreliminaryDiagnosis>
+        <DiagnosisDescription>none</DiagnosisDescription>
+      </PreliminaryDiagnosis>
+    </WorkingDiagnosis>
+    <LabTests/>
+  </Encounter>
+  <Encounter>
+    <Date>2009-06-03</Date>
+    <Contact>
+      <fullName>Henry No</fullName>
+    </Contact>
+    <MedicalBaseline>true</MedicalBaseline>
+    <MedicalTest>true</MedicalTest>
+    <ReportedSymptoms>none</ReportedSymptoms>
+    <WorkingDiagnosis>
+      <PreliminaryDiagnosis>
+        <DiagnosisDescription>none</DiagnosisDescription>
+      </PreliminaryDiagnosis>
+    </WorkingDiagnosis>
+    <LabTests>
+      <Test>
+        <dateMeasured>2009-06-03</dateMeasured>
+        <name>Lipid panel</name>
+        <status>@@@</status>
+      </Test>
+    </LabTests>
+  </Encounter>
+  <Encounter>
+    <Date>2009-07-03</Date>
+    <Contact>
+      <fullName>Henry No</fullName>
+    </Contact>
+    <MedicalBaseline>true</MedicalBaseline>
+    <MedicalTest>true</MedicalTest>
+    <ReportedSymptoms>none</ReportedSymptoms>
+    <WorkingDiagnosis>
+      <PreliminaryDiagnosis>
+        <DiagnosisDescription>none</DiagnosisDescription>
+      </PreliminaryDiagnosis>
+    </WorkingDiagnosis>
+    <LabTests>
+      <Test>
+        <dateMeasured>2009-07-03</dateMeasured>
+        <name>Lipid panel</name>
+        <status>@@@</status>
+      </Test>
+    </LabTests>
+  </Encounter>
+  <Encounter>
+    <Date>2009-07-15</Date>
+    <Date>2009-07-16</Date>
+    <Contact>
+      <fullName>Henry No</fullName>
+    </Contact>
+    <Contact>
+      <fullName>Mark Tourney</fullName>
+    </Contact>
+    <MedicalBaseline>false</MedicalBaseline>
+    <MedicalBaseline>false</MedicalBaseline>
+    <MedicalTest>false</MedicalTest>
+    <MedicalTest>true</MedicalTest>
+    <ReportedSymptoms>Confusion, Declining memory</ReportedSymptoms>
+    <ReportedSymptoms> Confusion, Declining memory </ReportedSymptoms>
+    <WorkingDiagnosis>
+      <PreliminaryDiagnosis>
+          <DiagnosisDescription>Dementia</DiagnosisDescription>
+          <ICD9>331</ICD9>
+          <ICD9Description> Other cerebral degenerations</ICD9Description>
+       </PreliminaryDiagnosis>
+      <DifferentialDiagnosis>
+       </DifferentialDiagnosis>
+    </WorkingDiagnosis>
+    <WorkingDiagnosis>
+      <PreliminaryDiagnosis>
+          <DiagnosisDescription>Dementia</DiagnosisDescription>
+          <ICD9>331</ICD9>
+          <ICD9Description> Other cerebral degenerations</ICD9Description>
+       </PreliminaryDiagnosis>
+      <DifferentialDiagnosis>
+          <ICD9>331.0</ICD9>
+          <ICD9Description>Alzheimer's disease</ICD9Description>
+       </DifferentialDiagnosis>
+    </WorkingDiagnosis>
+    <LabTests>
+      <Test>
+        <dateMeasured>2009-07-15</dateMeasured>
+        <name>Other psychologic evaluation and testing</name>
+        <HCLSresult>
+          <LabTest>
+            <variant_Synonyms/>
+          </LabTest>
+        </HCLSresult>
+        <status>@@@</status>
+      </Test>
+      <Test>
+        <dateMeasured>2009-07-15</dateMeasured>
+        <name>Magnetic resonance imaging of brain and brain</name>
+        <HCLSresult>
+          <LabTest>
+            <variant_Synonyms/>
+          </LabTest>
+        </HCLSresult>
+        <status>@@@</status>
+      </Test>
+      <Test>
+        <dateMeasured>2009-07-15</dateMeasured>
+        <name>Blood count; complete (CBC), automated (Hgb, Hct, RBC, WBC and platelet count) and automated differential WBC count</name>
+        <status>@@@</status>
+      </Test>
+      <Test>
+        <dateMeasured>2009-07-15</dateMeasured>
+        <name>ADmark Alzheimer's Evaluation</name>
+        <SNPresult>
+          <LabTest>
+            <variant_Synonyms>APOE4, NG_007084.2:g.7903T&gt;C</variant_Synonyms>
+          </LabTest>
+        </SNPresult>
+        <status>@@@</status>
+      </Test>
+    </LabTests>
+  </Encounter>
+  <Encounter>
+    <Date>2009-08-03</Date>
+    <Contact>
+      <fullName>Henry No</fullName>
+    </Contact>
+    <MedicalBaseline>true</MedicalBaseline>
+    <MedicalTest>true</MedicalTest>
+    <ReportedSymptoms>false</ReportedSymptoms>
+    <WorkingDiagnosis>
+      <PreliminaryDiagnosis>
+        <DiagnosisDescription>false</DiagnosisDescription>
+      </PreliminaryDiagnosis>
+    </WorkingDiagnosis>
+    <LabTests>
+      <Test>
+        <dateMeasured>2009-08-03</dateMeasured>
+        <name>Lipid panel</name>
+        <status>@@@</status>
+      </Test>
+    </LabTests>
+  </Encounter>
+  <Encounter>
+    <Date>2009-08-15</Date>
+    <Contact>
+      <fullName>Henry No</fullName>
+    </Contact>
+    <MedicalBaseline>false</MedicalBaseline>
+    <MedicalTest>none</MedicalTest>
+    <ReportedSymptoms>nausea</ReportedSymptoms>
+    <WorkingDiagnosis>
+      <PreliminaryDiagnosis>
+        <DiagnosisDescription>adverse event to Donepezil</DiagnosisDescription>
+      </PreliminaryDiagnosis>
+    </WorkingDiagnosis>
+    <LabTests/>
+  </Encounter>
+  <Encounter>
+    <Date>2009-11-03</Date>
+    <Contact>
+      <fullName>Henry No</fullName>
+    </Contact>
+    <MedicalBaseline>true</MedicalBaseline>
+    <MedicalTest>false</MedicalTest>
+    <ReportedSymptoms>false</ReportedSymptoms>
+    <WorkingDiagnosis>
+      <PreliminaryDiagnosis>
+        <DiagnosisDescription>false</DiagnosisDescription>
+      </PreliminaryDiagnosis>
+    </WorkingDiagnosis>
+    <LabTests>
+      <Test>
+        <dateMeasured>2009-11-03</dateMeasured>
+        <name>Lipid panel</name>
+        <status>@@@</status>
+      </Test>
+    </LabTests>
+  </Encounter>
 </Envelope>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/syntheticPatients/AD_PCHR_1-tmo.trig	Thu Sep 30 12:15:04 2010 -0400
@@ -0,0 +1,119 @@
+
+  @prefix : <tag:eric@w3.org:2009/tmo/translator#> .
+  @prefix foaf: <http://xmlns.com/foaf/0.1/> .
+  @prefix trans: <tag:eric@w3.org:2009/tmo/translator#> .  
+  @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .  
+{
+_:patient  a trans:Patient ;
+  
+    
+  foaf:name "George Andrew Tour" ;
+
+  foaf:givenName "George" ;
+
+  foaf:familyName "Tour" ;
+
+    
+  foaf:mbox <gtour@hotmail.com> ;
+
+    
+  foaf:mbox <george.tour@technology.com> ;
+
+    
+    
+    
+    
+    
+
+  . 
+_:pricare  a trans:PrimaryCarePhysician ;
+  
+      
+  foaf:name "Henry No" ;
+
+  foaf:givenName "Henry" ;
+
+  foaf:familyName "No" ;
+
+      
+      
+    
+  . 
+
+  _:patient trans:hasCondition [
+  trans:onset "2009-05-15T12:00:00"^^xsd:dateTime ;
+
+  trans:diagnosedWith "hypertension" ;
+
+  # unmatched comments
+  # unmatched diagnosedBy
+  ] .
+
+  _:patient trans:hasCondition [
+  trans:onset "2009-05-20T12:00:00"^^xsd:dateTime ;
+
+  trans:diagnosedWith "hypercholesterolaemia" ;
+
+  # unmatched comments
+  # unmatched diagnosedBy
+  ] .
+
+  _:patient trans:hasCondition [
+  trans:onset "2009-05-20T12:00:00"^^xsd:dateTime ;
+
+  trans:diagnosedWith "atrial fibrillation" ;
+
+  # unmatched comments
+  # unmatched diagnosedBy
+  ] .
+
+  _:patient trans:hasCondition [
+  trans:onset "2009-08-10T12:00:00"^^xsd:dateTime ;
+
+  trans:diagnosedWith "alzheimer’s disease" ;
+
+  # unmatched comments
+  # unmatched diagnosedBy
+  ] .
+
+  [ a :Encounter ;
+    :patient _:patient
+  ] .
+
+  [ a :Encounter ;
+    :patient _:patient
+  ] .
+
+  [ a :Encounter ;
+    :patient _:patient
+  ] .
+
+  [ a :Encounter ;
+    :patient _:patient
+  ] .
+
+  [ a :Encounter ;
+    :patient _:patient
+  ] .
+
+  [ a :Encounter ;
+    :patient _:patient
+  ] .
+
+  [ a :Encounter ;
+    :patient _:patient
+  ] .
+
+  [ a :Encounter ;
+    :patient _:patient
+  ] .
+
+  [ a :Encounter ;
+    :patient _:patient
+  ] .
+
+  [ a :Encounter ;
+    :patient _:patient
+  ] .
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/syntheticPatients/Indivo2Trig.xsl	Thu Sep 30 12:15:04 2010 -0400
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- $Id: Pat2rdf.xsl,v 1.23 2009/11/30 03:42:28 eric Exp $ -->
+<xsl:stylesheet 
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:in="http://indivo.org/vocab/xml/documents#"
+    xmlns="http://indivo.org/vocab/xml/documents#999"
+    version="1.0">
+
+<xsl:output method="text" indent='yes' encoding='utf-8'
+	    omit-xml-declaration="yes"	    
+	    media-type="text/turtle" version="1.0"/>
+
+<xsl:template match="in:Envelope">
+  @prefix : &lt;tag:eric@w3.org:2009/tmo/translator#&gt; .
+  @prefix foaf: &lt;http://xmlns.com/foaf/0.1/&gt; .
+  @prefix trans: &lt;tag:eric@w3.org:2009/tmo/translator#&gt; .  
+  @prefix xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt; .  
+{
+<xsl:apply-templates select="in:CurrentStatus"/>
+<xsl:apply-templates select="in:Encounter"/>
+}
+</xsl:template>
+
+<xsl:template match="in:CurrentStatus">
+  <xsl:apply-templates select="in:Contact"/>
+  <xsl:apply-templates select="in:PrimaryCarePhysician"/>
+  <xsl:apply-templates select="in:Conditions"/>
+</xsl:template>
+
+<xsl:template match="in:Contact">
+  <xsl:call-template name="contact">
+    <xsl:with-param name="subject" select="'_:patient'"/>
+    <xsl:with-param name="type" select="'trans:Patient'"/>
+  </xsl:call-template>
+</xsl:template>
+
+<xsl:template match="in:PrimaryCarePhysician">
+  <xsl:call-template name="contact">
+    <xsl:with-param name="subject" select="'_:pricare'"/>
+    <xsl:with-param name="type" select="'trans:PrimaryCarePhysician'"/>
+  </xsl:call-template>
+</xsl:template>
+
+<xsl:template name="contact">
+  <xsl:param name="subject"/>
+  <xsl:param name="type"/>
+  <xsl:value-of select="$subject"/>  a <xsl:value-of select="$type"/> ;
+  <xsl:apply-templates mode="contact"/>
+  . 
+</xsl:template>
+
+<xsl:template mode="contact" match="in:name">
+  <xsl:apply-templates mode="contact" select="*"/>
+</xsl:template>
+
+<xsl:template mode="contact" match="in:fullName">
+  foaf:name "<xsl:value-of select="text()"/>" ;
+</xsl:template>
+
+<xsl:template mode="contact" match="in:givenName">
+  foaf:givenName "<xsl:value-of select="text()"/>" ;
+</xsl:template>
+
+<xsl:template mode="contact" match="in:familyName">
+  foaf:familyName "<xsl:value-of select="text()"/>" ;
+</xsl:template>
+
+<xsl:template mode="contact" match="in:email">
+  foaf:mbox &lt;<xsl:value-of select="normalize-space(text())"/>&gt; ;
+</xsl:template>
+
+<xsl:template mode="contact" match="*">
+</xsl:template>
+
+<xsl:template match="in:Conditions">
+  <xsl:apply-templates select="in:Problem"/>
+</xsl:template>
+
+<xsl:template match="in:Problem">
+  _:patient trans:hasCondition [<xsl:apply-templates mode="problem" select="*"/>
+  ] .
+</xsl:template>
+
+<xsl:template mode="problem" match="in:dateOnset">
+  trans:onset "<xsl:value-of select="text()"/>"^^xsd:dateTime ;
+</xsl:template>
+
+<xsl:template mode="problem" match="in:name">
+  trans:diagnosedWith "<xsl:value-of select="text()"/>" ;
+</xsl:template>
+
+<xsl:template mode="problem" match="*">
+  # unmatched <xsl:value-of select="name()"/>
+</xsl:template>
+
+<xsl:template match="in:Encounter">
+  [ a :Encounter ;
+    :patient _:patient
+  ] .
+</xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file
--- a/syntheticPatients/Pat2Indivo2.xsl	Sat Jul 17 20:01:55 2010 -0400
+++ b/syntheticPatients/Pat2Indivo2.xsl	Thu Sep 30 12:15:04 2010 -0400
@@ -1,167 +1,299 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!-- $Id: Pat2rdf.xsl,v 1.23 2009/11/30 03:42:28 eric Exp $ -->
 <xsl:stylesheet 
-	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-	version="2.0"
-	xmlns="http://indivo.org/vocab/xml/documents">
+	version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://indivo.org/vocab/xml/documents#">
 
 <xsl:output method="xml" indent='yes' encoding='utf-8'
 omit-xml-declaration="yes"	    
 media-type="application/rdf+xml" version="1.0"/>
 
 <xsl:template match="/root">
-	<xsl:comment> -*- XML -*- </xsl:comment><xsl:processing-instruction name="xml-stylesheet"><xsl:text>type="text/xsl" href="Patrdf2html.xsl"</xsl:text></xsl:processing-instruction>
-	<Envelope>
-		<CurrentStatus>
-			<xsl:copy-of select="Contact"/>
-			<xsl:apply-templates select="Practice"/>
-			<xsl:copy-of select="Demographics"/>
-			<xsl:apply-templates select="prescriptions"/>
-			<xsl:apply-templates select="conditions"/>
-			<xsl:apply-templates select="procedures"/>
-			<xsl:apply-templates select="allergies"/>
-			<xsl:apply-templates select="immunizations"/>
-			<xsl:copy-of select="lifestyle"/>
-			<xsl:copy-of select="familyHistory"/>
-		</CurrentStatus>
-	</Envelope>
+  <xsl:comment> -*- XML -*- </xsl:comment><xsl:processing-instruction name="xml-stylesheet"><xsl:text>type="text/xsl" href="Patrdf2html.xsl"</xsl:text></xsl:processing-instruction>
+  <Envelope>
+    <CurrentStatus>
+      <xsl:copy-of select="Contact"/>
+      <xsl:apply-templates select="Practice"/>
+      <xsl:copy-of select="Demographics"/>
+      <xsl:apply-templates select="prescriptions"/>
+      <xsl:apply-templates select="conditions"/>
+      <xsl:apply-templates select="procedures"/>
+      <xsl:apply-templates select="allergies"/>
+      <xsl:apply-templates select="immunizations"/>
+      <xsl:copy-of select="lifestyle"/>
+      <xsl:copy-of select="familyHistory"/>
+    </CurrentStatus>
+    <xsl:apply-templates select="Encounter"/>
+  </Envelope>
 </xsl:template>
 
 <xsl:template match="Practice">
-	<PrimaryCarePhysician>
-		<name>
-			<xsl:copy-of select="primaryCarePhysician/fullName"/>
-			<xsl:copy-of select="primaryCarePhysician/givenName"/>
-			<xsl:copy-of select="primaryCarePhysician/familyName"/>
-		</name>
-		<address>
-			<xsl:copy-of select="practiceAddress/streetAddress"/>
-			<xsl:copy-of select="practiceAddress/postalCode"/>
-			<xsl:copy-of select="practiceAddress/locality"/>
-			<xsl:copy-of select="practiceAddress/region"/>
-			<xsl:copy-of select="practiceAddress/country"/>
-			<xsl:copy-of select="practiceAddress/timeZone"/>
-		</address>
-		<xsl:copy-of select="practiceAddress/phoneNumber"/>
-	</PrimaryCarePhysician>
+  <PrimaryCarePhysician>
+    <name>
+      <xsl:copy-of select="primaryCarePhysician/fullName"/>
+      <xsl:copy-of select="primaryCarePhysician/givenName"/>
+      <xsl:copy-of select="primaryCarePhysician/familyName"/>
+    </name>
+    <address>
+      <xsl:copy-of select="practiceAddress/streetAddress"/>
+      <xsl:copy-of select="practiceAddress/postalCode"/>
+      <xsl:copy-of select="practiceAddress/locality"/>
+      <xsl:copy-of select="practiceAddress/region"/>
+      <xsl:copy-of select="practiceAddress/country"/>
+      <xsl:copy-of select="practiceAddress/timeZone"/>
+    </address>
+    <xsl:copy-of select="practiceAddress/phoneNumber"/>
+  </PrimaryCarePhysician>
 </xsl:template>
 
 <xsl:template match="prescriptions">
-	<Prescriptions>
-		<xsl:for-each select="drug">
-			<Prescription>
-				<medication>
-					<dateStarted><xsl:value-of select="datePrescribed"/></dateStarted>
-					<xsl:if test="datePrescriptionEnded != 'false'">
-						<dateStopped><xsl:value-of select="datePrescriptionEnded"/></dateStopped>
-					</xsl:if>
-					<name>
-						<xsl:attribute name="type">http://indivo.org/codes/ndc</xsl:attribute>
-						<xsl:value-of select="NDC"/>
-					</name>
-					<brandName>
-						
-					</brandName>
-					<dose>
-						<value><xsl:value-of select="999"/></value>
-						<unit type="http://indivo.org/codes/units#">
-							<xsl:attribute name="value">
-								<xsl:value-of select="999"/>
-							</xsl:attribute>
-						</unit>
-					</dose>
-					<strength>
-						<value><xsl:value-of select="strength"/></value>
-						<unit type="http://indivo.org/codes/units#">
-							<xsl:attribute name="value">
-								<xsl:value-of select="unit"/>
-							</xsl:attribute>
-						</unit>
-					</strength>
-					<xsl:copy-of select="frequency"/>
-				</medication>
-				<prescribedBy>
-					<name><xsl:value-of select="prescribedBy"/></name>
-				</prescribedBy>
-				<dispenseAsWritten>true</dispenseAsWritten>
-				<refillInfo><xsl:value-of select="refill"/></refillInfo>
-				<instructions><xsl:value-of select="physicianNotes"/></instructions>
-			</Prescription>
-		</xsl:for-each>
-	</Prescriptions>
+  <Prescriptions>
+    <xsl:for-each select="drug">
+      <Prescription>
+	<medication>
+	  <dateStarted><xsl:value-of select="datePrescribed"/></dateStarted>
+	  <xsl:if test="datePrescriptionEnded != 'false'">
+	    <dateStopped><xsl:value-of select="datePrescriptionEnded"/></dateStopped>
+	  </xsl:if>
+	  <name>
+	    <xsl:attribute name="type">http://indivo.org/codes/ndc</xsl:attribute>
+	    <xsl:value-of select="NDC"/>
+	  </name>
+	  <brandName>
+	    
+	  </brandName>
+	  <dose>
+	    <value><xsl:value-of select="999"/></value>
+	    <unit type="http://indivo.org/codes/units#">
+	      <xsl:attribute name="value">
+		<xsl:value-of select="999"/>
+	      </xsl:attribute>
+	    </unit>
+	  </dose>
+	  <strength>
+	    <value><xsl:value-of select="strength"/></value>
+	    <unit type="http://indivo.org/codes/units#">
+	      <xsl:attribute name="value">
+		<xsl:value-of select="unit"/>
+	      </xsl:attribute>
+	    </unit>
+	  </strength>
+	  <xsl:copy-of select="frequency"/>
+	</medication>
+	<prescribedBy>
+	  <name><xsl:value-of select="prescribedBy"/></name>
+	</prescribedBy>
+	<dispenseAsWritten>true</dispenseAsWritten>
+	<refillInfo><xsl:value-of select="refill"/></refillInfo>
+	<instructions><xsl:value-of select="physicianNotes"/></instructions>
+      </Prescription>
+    </xsl:for-each>
+  </Prescriptions>
 </xsl:template>
 
 <xsl:template match="conditions">
-	<Conditions>
-		<xsl:for-each select="condition">
-			<Problem>
-				<dateOnset><xsl:value-of select="dateDiagnosed"/>T12:00:00</dateOnset> <!-- dateOnset should be different that dateDiagnosed -->
-				<!-- <dateResolution></dateResolution> -->
-				<name type="http://indivo.org/codes/ICD9">
-					<xsl:attribute name="value">
-						<xsl:value-of select="ICD9"/>
-					</xsl:attribute>
-					<xsl:value-of select="diagnosedWith"/>
-				</name>
-				<comments><xsl:value-of select="physicianNotes"/></comments>
-				<xsl:copy-of select="diagnosedBy"/>
-			</Problem>
-		</xsl:for-each>
-	</Conditions>
+  <Conditions>
+    <xsl:for-each select="condition">
+      <Problem>
+	<dateOnset><xsl:value-of select="dateDiagnosed"/>T12:00:00</dateOnset> <!-- dateOnset should be different that dateDiagnosed -->
+	<!-- <dateResolution></dateResolution> -->
+	<name type="http://indivo.org/codes/ICD9">
+	  <xsl:attribute name="value">
+	    <xsl:value-of select="ICD9"/>
+	  </xsl:attribute>
+	  <xsl:value-of select="diagnosedWith"/>
+	</name>
+	<comments><xsl:value-of select="physicianNotes"/></comments>
+	<xsl:copy-of select="diagnosedBy"/>
+      </Problem>
+    </xsl:for-each>
+  </Conditions>
 </xsl:template>
 
 <xsl:template match="procedures">
-	<Procedures>
-		<xsl:for-each select="procedure">
-			<Procedure>
-				<datePerformed><xsl:value-of select="procedureDate"/>T12:00:00</datePerformed>
-				<name type="http://indivo.org/codes/ICD9_Procedure">
-					<xsl:attribute name="value">
-						<xsl:value-of select="ICD9_Procedure"/>
-					</xsl:attribute>
-					<xsl:value-of select="procedureName"/>
-				</name>
-				<Provider>
-					<name><xsl:value-of select="referredBy"/></name>
-					<institution><xsl:value-of select="referredInstitution"/></institution>
-				</Provider>
-				<comments><xsl:value-of select="procedureNotes"/></comments>
-			</Procedure>
-		</xsl:for-each>
-	</Procedures>
+  <Procedures>
+    <xsl:for-each select="procedure">
+      <Procedure>
+	<datePerformed><xsl:value-of select="procedureDate"/>T12:00:00</datePerformed>
+	<name type="http://indivo.org/codes/ICD9_Procedure">
+	  <xsl:attribute name="value">
+	    <xsl:value-of select="ICD9_Procedure"/>
+	  </xsl:attribute>
+	  <xsl:value-of select="procedureName"/>
+	</name>
+	<Provider>
+	  <name><xsl:value-of select="referredBy"/></name>
+	  <institution><xsl:value-of select="referredInstitution"/></institution>
+	</Provider>
+	<comments><xsl:value-of select="procedureNotes"/></comments>
+      </Procedure>
+    </xsl:for-each>
+  </Procedures>
 </xsl:template>
 
 <xsl:template match="allergies">
-	<Allergies>
-		<xsl:for-each select="child::*">
-			<Allergy>
-				<allergen>
-					<type type="http://codes.indivo.org/codes/allergentypes/"><xsl:value-of select="name(.)"/></type>
-					<name type="http://codes.indivo.org/codes/allergens/"><xsl:value-of select="."/></name>
-				</allergen>
-			</Allergy>
-		</xsl:for-each>
-	</Allergies>
+  <Allergies>
+    <xsl:for-each select="child::*">
+      <Allergy>
+	<allergen>
+	  <type type="http://codes.indivo.org/codes/allergentypes/"><xsl:value-of select="name(.)"/></type>
+	  <name type="http://codes.indivo.org/codes/allergens/"><xsl:value-of select="."/></name>
+	</allergen>
+      </Allergy>
+    </xsl:for-each>
+  </Allergies>
 </xsl:template>
 
 <xsl:template match="immunizations">
-	<Immunizations>
-		<xsl:for-each select="child::*">
-			<Immunization>
-				<dateAdministered><xsl:value-of select="date"/>-01-01T12:00:00</dateAdministered>
-				<xsl:copy-of select="administeredBy"/>
-				<vaccine>
-					<type><xsl:value-of select="name(.)"/></type>
-					<manufacturer></manufacturer>
-					<lot></lot>
-					<expiration></expiration>
-				</vaccine>
-				<sequence><xsl:value-of select="stage"/></sequence>
-				<anatomicSurface><xsl:value-of select="method"/></anatomicSurface> <!-- Not exactly.. -->
-				<adverseEvent></adverseEvent>
-			</Immunization>
-		</xsl:for-each>
-	</Immunizations>
+  <Immunizations>
+    <xsl:for-each select="child::*">
+      <Immunization>
+	<dateAdministered><xsl:value-of select="date"/>-01-01T00:00:00</dateAdministered>
+	<xsl:copy-of select="administeredBy"/>
+	<vaccine>
+	  <type><xsl:value-of select="name(.)"/></type>
+	  <manufacturer></manufacturer>
+	  <lot></lot>
+	  <expiration></expiration>
+	</vaccine>
+	<sequence><xsl:value-of select="stage"/></sequence>
+	<anatomicSurface><xsl:value-of select="method"/></anatomicSurface> <!-- Not exactly.. -->
+	<adverseEvent></adverseEvent>
+      </Immunization>
+    </xsl:for-each>
+  </Immunizations>
+</xsl:template>
+
+<xsl:template match="Encounter">
+  <Encounter>
+    <xsl:apply-templates select="dateOfEncounter"/>
+    <xsl:apply-templates select="physician"/>
+    <xsl:apply-templates select="medicalBaseline"/>
+    <xsl:apply-templates select="medicalTest"/>
+    <xsl:apply-templates select="reportedSymptoms"/>
+    <xsl:apply-templates select="workingDiagnosis"/>
+    <LabTests>
+      <xsl:apply-templates select="test">
+	<xsl:with-param name="date" select="dateOfEncounter/text()"/>
+      </xsl:apply-templates>
+    </LabTests>
+
+    <!-- xsl:for-each select="child::*">
+      <Immunization>
+	<dateAdministered><xsl:value-of select="date"/>-01-01T12:00:00</dateAdministered>
+	<xsl:copy-of select="administeredBy"/>
+	<vaccine>
+	  <type><xsl:value-of select="name(.)"/></type>
+	  <manufacturer></manufacturer>
+	  <lot></lot>
+	  <expiration></expiration>
+	</vaccine>
+	<sequence><xsl:value-of select="stage"/></sequence>
+	<anatomicSurface><xsl:value-of select="method"/></anatomicSurface>
+	<adverseEvent></adverseEvent>
+      </Immunization>
+    </xsl:for-each -->
+  </Encounter>
+</xsl:template>
+
+<xsl:template match="dateOfEncounter">
+  <Date>
+    <xsl:value-of select="text()"/>
+  </Date>
+</xsl:template>
+
+<xsl:template match="physician">
+  <Contact>
+    <fullName>
+      <xsl:value-of select="text()"/>
+    </fullName>
+  </Contact>
+</xsl:template>
+
+<xsl:template match="medicalBaseline">
+  <MedicalBaseline>
+    <xsl:value-of select="text()"/>
+  </MedicalBaseline>
+</xsl:template>
+
+<xsl:template match="medicalTest">
+  <MedicalTest>
+    <xsl:value-of select="text()"/>
+  </MedicalTest>
+</xsl:template>
+
+<xsl:template match="reportedSymptoms">
+  <ReportedSymptoms>
+    <xsl:value-of select="text()"/>
+  </ReportedSymptoms>
+</xsl:template>
+
+<xsl:template match="workingDiagnosis">
+  <WorkingDiagnosis>
+    <xsl:choose>
+      <xsl:when test="preliminaryDiagnosis">
+	<PreliminaryDiagnosis>
+	  <xsl:apply-templates mode="diagnosis" select="preliminaryDiagnosis"/>
+	</PreliminaryDiagnosis>
+	<xsl:if test="differentialDiagnosis">
+	  <DifferentialDiagnosis>
+	    <xsl:apply-templates mode="diagnosis" select="differentialDiagnosis"/>
+	  </DifferentialDiagnosis>
+	</xsl:if>
+      </xsl:when>
+      <xsl:otherwise>
+	<PreliminaryDiagnosis>
+	  <DiagnosisDescription>
+	    <xsl:value-of select="text()"/>
+	  </DiagnosisDescription>
+	</PreliminaryDiagnosis>
+      </xsl:otherwise>
+    </xsl:choose>    
+  </WorkingDiagnosis>
+</xsl:template>
+
+<xsl:template mode="diagnosis" match="diagnosisDescription">
+  <DiagnosisDescription><xsl:value-of select="text()"/></DiagnosisDescription>
+</xsl:template>
+
+<xsl:template mode="diagnosis" match="ICD9">
+  <ICD9><xsl:value-of select="text()"/></ICD9>
+</xsl:template>
+
+<xsl:template mode="diagnosis" match="ICD9Description">
+  <ICD9Description><xsl:value-of select="text()"/></ICD9Description>
+</xsl:template>
+
+<xsl:template match='test'>
+  <xsl:param name="date"/>
+  <Test>
+    <dateMeasured><xsl:value-of select="$date"/></dateMeasured>
+    <name><xsl:value-of select="testName"/></name>
+    <xsl:choose>
+      <xsl:when test='@x_2="Genotyping SNPs"'>
+	<xsl:apply-templates mode="SNP" select="result"/>
+      </xsl:when>
+      <xsl:otherwise>
+	<xsl:apply-templates select="result"/>
+      </xsl:otherwise>
+    </xsl:choose>
+    <status>@@@</status>
+  </Test>
+</xsl:template>
+
+<xsl:template mode="SNP" match="result">
+  <SNPresult>
+  <LabTest>
+    <variant_Synonyms><xsl:value-of select="variant_Synonyms/text()"/></variant_Synonyms>
+  </LabTest>
+  </SNPresult>
+</xsl:template>
+
+<xsl:template match="result">
+  <HCLSresult>
+  <LabTest>
+    <variant_Synonyms><xsl:value-of select="variant_Synonyms/text()"/></variant_Synonyms>
+  </LabTest>
+  </HCLSresult>
 </xsl:template>
 
 </xsl:stylesheet>