Changeset 757 for ccr2ccd-xslt


Ignore:
Timestamp:
May 18, 2010, 11:42:02 AM (14 years ago)
Author:
Richard Braman
Message:

results of merge between Ken's Code and Rich's shadow development.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ccr2ccd-xslt/trunk/ccr_ccd.xsl

    r746 r757  
    11<?xml version="1.0" encoding="utf-8"?>
    2 
    32<!--
    4 Conversion of CCR to Level 2 CCD
    5 
    6 Author:         Ken Miller
     3Conversion of CCR to Level 3 CCD
     4
     5Orginal Author:         Ken Miller
    76Solventus LLC
    87ken.miller@solventus.coms
    98
    10 Date:   2008-04-25
     9Contributors:
     10Richard Braman, EHR Doctors, Inc rbraman@ehrdoctors.com
     11George Gilly (WorldVistA glilly@glilly.net)
     12xxxx - Oroville Hospital
     13
     14Date:   2010-05-5
    1115Version:        0.1
    1216
     17License :
     18
     19        This program is free software: you can redistribute it and/or modify
     20        it under the terms of the GNU General Public License as published by
     21        the Free Software Foundation, either version 3 of the License, or
     22        (at your option) any later version.
     23
     24        This program is distributed in the hope that it will be useful,
     25        but WITHOUT ANY WARRANTY; without even the implied warranty of
     26        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     27        GNU General Public License for more details.
     28
     29        You should have received a copy of the GNU General Public License
     30        along with this program.  If not, see http://www.gnu.org/licenses.
     31
    1332-->
    14 
    15 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="urn:astm-org:CCR" xmlns:date="http://exslt.org/dates-and-times" exclude-result-prefixes="a date">
    16 
     33<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="urn:astm-org:CCR" xmlns:date="http://exslt.org/dates-and-times" exclude-result-prefixes="a date" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:str="http://exslt.org/strings" extension-element-prefixes="str" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    1734    <xsl:import href="./templates/code.xsl"/>
    18     <xsl:import href="./templates/datetime.xsl"/>
     35    <xsl:import href="./templates/ccdcodedvalue.xsl"/>
     36    <xsl:import href="./templates/ccdentity.xsl"/>
     37    <xsl:import href="./templates/ccdid.xsl"/>
     38    <xsl:import href="./templates/ccddatetime.xsl"/>
     39    <xsl:import href="./templates/ccdstatus.xsl"/>
     40    <xsl:import href="./templates/ccdmedicationfrequency.xsl"/>
    1941    <xsl:import href="./templates/actor.xsl"/>
    2042    <xsl:import href="./templates/problemDescription.xsl"/>
    21 
    22     <xsl:output method="xml" encoding="utf-8" version="1.0"/>
     43    <xsl:import href="./templates/HL7OIDLookup.xsl"/>
     44
     45    <xsl:output method="xml" encoding="utf-8" version="1.0" indent="yes"/>
    2346    <xsl:template match="/">
    24         <ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:voc="urn:hl7-org:v3/voc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    25             <typeId root="2.16.840.1.113883.1.3" extension="POCD_HD000040" />
     47        <xsl:processing-instruction name="xml-stylesheet">type="text/xsl" href="CCD.xsl"</xsl:processing-instruction>
     48        <ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:voc="urn:hl7-org:v3/voc" xmlns:sdtc="urn:hl7-org:sdtc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hl7-org:v3 http://xreg2.nist.gov:8080/hitspValidation/schema/cdar2c32/infrastructure/cda/C32_CDA.xsd" classCode="DOCCLIN" moodCode="EVN">
     49            <realmCode code="US"/>
     50            <typeId root="2.16.840.1.113883.1.3" extension="POCD_HD000040"/>
    2651            <templateId root="2.16.840.1.113883.10.20.1"/>
    27             <id root="db4"/>
    28             <code code="34133-9" codeSystem="2.16.840.1.113883.6.1" displayName="Summarization of episode note"/>
     52            <templateId root="1.3.6.1.4.1.19376.1.5.3.1.1.1"/>
     53            <templateId root="2.16.840.1.113883.10.20.3"/>
     54            <templateId root="2.16.840.1.113883.3.88.11.32.1"/>
     55
     56            <id>
     57                <xsl:attribute name="root">
     58                    <xsl:value-of select="/a:ContinuityOfCareRecord/a:CCRDocumentObjectID"></xsl:value-of>
     59                </xsl:attribute>
     60            </id>
     61            <code code="34133-9" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="Summarization of episode note"/>
    2962            <title>Continuity of Care Document</title>
    30             <xsl:element name="effectiveTime">
     63            <effectiveTime>
    3164                <xsl:attribute name="value">
    3265                    <xsl:call-template name="date:format-date">
    3366                        <xsl:with-param name="date-time">
    34                             <xsl:value-of select="a:ContinuityOfCareRecord/a:DateTime/a:ExactDateTime"/>
     67                            <xsl:value-of select="/a:ContinuityOfCareRecord/a:DateTime/a:ExactDateTime"/>
    3568                        </xsl:with-param>
    3669                        <xsl:with-param name="pattern">yyyyMMddhhmmss+0000</xsl:with-param>
    3770                    </xsl:call-template>
    3871                </xsl:attribute>
    39             </xsl:element>
     72            </effectiveTime>
    4073            <confidentialityCode code="N" codeSystem="2.16.840.1.113883.5.25"/>
    4174            <languageCode code="en-US"/>
    42             <xsl:variable name="patientID" select="a:ContinuityOfCareRecord/a:Patient[1]/a:ActorID"/>
     75            <xsl:variable name="patientID" select="/a:ContinuityOfCareRecord/a:Patient[1]/a:ActorID"/>
    4376            <recordTarget>
    4477                <xsl:for-each select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$patientID]">
    4578                    <patientRole>
    46                         <xsl:element name="id">
    47                             <xsl:attribute name="extension">
    48                                 <xsl:value-of select="a:IDs/a:ID[1]"/>
    49                             </xsl:attribute>
    50                         </xsl:element>
    51                         <patient>
    52                             <name>
    53                                 <given>
    54                                     <xsl:value-of select="a:Person/a:Name/a:CurrentName/a:Given"></xsl:value-of>
    55                                 </given>
    56                                 <family>
    57                                     <xsl:value-of select="a:Person/a:Name/a:CurrentName/a:Family"></xsl:value-of>
    58                                 </family>
    59                             </name>
    60                             <xsl:element name="administrativeGenderCode">
    61                                 <xsl:attribute name="code">
    62                                     <xsl:value-of select="a:Person/a:Gender/a:Text"></xsl:value-of>
    63                                 </xsl:attribute>
    64                             </xsl:element>
    65                             <xsl:element name="birthTime">
    66                                 <xsl:attribute name="value">
    67                                     <xsl:call-template name="date:format-date">
    68                                         <xsl:with-param name="date-time">
    69                                             <xsl:value-of select="a:Person/a:DateOfBirth/a:ExactDateTime"/>
    70                                         </xsl:with-param>
    71                                         <xsl:with-param name="pattern">yyyyMMddhhmmss</xsl:with-param>
    72                                     </xsl:call-template>
    73                                 </xsl:attribute>
    74                             </xsl:element>
    75                         </patient>
     79                        <xsl:call-template name="ccdEntity">
     80                            <xsl:with-param name="ccrActorObjectID" select="/a:ContinuityOfCareRecord/a:Patient[1]/a:ActorID"></xsl:with-param>
     81                            <xsl:with-param name="personNodeName">patient</xsl:with-param>
     82                        </xsl:call-template>
    7683                    </patientRole>
    7784                </xsl:for-each>
    7885            </recordTarget>
     86
     87            <xsl:variable name="fromID" select="/a:ContinuityOfCareRecord/a:From/a:ActorLink[1]/a:ActorID"/>
    7988            <author>
    80                 <xsl:variable name="fromID" select="a:ContinuityOfCareRecord/a:From/a:ActorLink[1]/a:ActorID"/>
    8189                <xsl:for-each select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$fromID]">
    82                     <xsl:element name="time">
     90                    <time>
    8391                        <xsl:attribute name="value">
    8492                            <xsl:call-template name="date:format-date">
     
    8997                            </xsl:call-template>
    9098                        </xsl:attribute>
    91                     </xsl:element>
    92                     <assignedAuthor>
    93                         <xsl:element name="id">
    94                             <xsl:attribute name="extension">
    95                                 <xsl:choose>
    96                                     <xsl:when test="a:IDs/a:ID[1]">
    97                                         <xsl:value-of select="a:IDs/a:ID[1]"/>
    98                                     </xsl:when>
    99                                     <xsl:otherwise>
    100                                         <xsl:value-of select="$fromID"/>
    101                                     </xsl:otherwise>
    102                                 </xsl:choose>
    103                             </xsl:attribute>
    104                         </xsl:element>
    105                         <assignedPerson>
    106                             <name>
    107                                 <prefix>
    108                                     <xsl:value-of select="a:Person/a:Name/a:CurrentName/a:Title"></xsl:value-of>
    109                                 </prefix>
    110                                 <given>
    111                                     <xsl:value-of select="a:Person/a:Name/a:CurrentName/a:Given"></xsl:value-of>
    112                                 </given>
    113                                 <family>
    114                                     <xsl:value-of select="a:Person/a:Name/a:CurrentName/a:Family"></xsl:value-of>
    115                                 </family>
    116                             </name>
    117                         </assignedPerson>
    118                     </assignedAuthor>
     99                    </time>
     100                    <xsl:call-template name="ccdEntity">
     101                        <xsl:with-param name="ccrActorObjectID" select="/a:ContinuityOfCareRecord/a:From/a:ActorLink[1]/a:ActorID"></xsl:with-param>
     102                    </xsl:call-template>
    119103                </xsl:for-each>
    120104            </author>
     105
    121106            <custodian>
    122107                <assignedCustodian>
    123108                    <representedCustodianOrganization>
    124                         <id root="2.16.840.1.113883.3.96.3.42"/>
    125                         <xsl:element name="name">
    126                             <xsl:call-template name="actorName">
    127                                 <xsl:with-param name="objID" select="a:ContinuityOfCareRecord/a:From/a:ActorLink[1]/a:ActorID"/>
    128                             </xsl:call-template>
    129                         </xsl:element>
     109                        <xsl:call-template name="ccdEntity">
     110                            <xsl:with-param name="ccrActorObjectID" select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$fromID]/a:InternalCCRLink[a:LinkRelationship='Organization']/a:LinkID"></xsl:with-param>
     111                        </xsl:call-template>
    130112                    </representedCustodianOrganization>
    131113                </assignedCustodian>
    132114            </custodian>
     115
    133116            <documentationOf>
    134117                <serviceEvent classCode="PCPR">
    135118                    <effectiveTime>
    136                         <xsl:element name="low">
     119                        <low>
    137120                            <xsl:attribute name="value">
    138121                                <xsl:call-template name="date:format-date">
    139122                                    <xsl:with-param name="date-time">
    140                                         <xsl:value-of select="a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$patientID]/a:Person/a:DateOfBirth/a:ExactDateTime"/>
     123                                        <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body//a:DateTime//a:ExactDateTime">
     124                                            <xsl:sort order="ascending"/>
     125                                            <xsl:if test="position()=1">
     126                                                <xsl:value-of select="."/>
     127                                            </xsl:if>
     128                                        </xsl:for-each>
    141129                                    </xsl:with-param>
    142130                                    <xsl:with-param name="pattern">yyyyMMdd</xsl:with-param>
    143131                                </xsl:call-template>
    144132                            </xsl:attribute>
    145                         </xsl:element>
    146                         <xsl:element name="high">
     133                        </low>
     134                        <high>
    147135                            <xsl:attribute name="value">
    148136                                <xsl:call-template name="date:format-date">
    149137                                    <xsl:with-param name="date-time">
    150                                         <xsl:value-of select="a:ContinuityOfCareRecord/a:DateTime/a:ExactDateTime"/>
     138                                        <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body//a:DateTime//a:ExactDateTime">
     139                                            <xsl:sort order="descending"/>
     140                                            <xsl:if test="position()=1">
     141                                                <xsl:value-of select="."/>
     142                                            </xsl:if>
     143                                        </xsl:for-each>
    151144                                    </xsl:with-param>
    152145                                    <xsl:with-param name="pattern">yyyyMMdd</xsl:with-param>
    153146                                </xsl:call-template>
    154147                            </xsl:attribute>
    155                         </xsl:element>
     148                        </high>
    156149                    </effectiveTime>
    157150                </serviceEvent>
     151
     152                <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:HealthCareProviders/a:Provider">
     153                    <assignedEntity>
     154                        <xsl:call-template name="ccdEntity">
     155                            <xsl:with-param name="a:ccrActorObjectID" select="a:ActorID"/>
     156                        </xsl:call-template>
     157                    </assignedEntity>
     158                </xsl:for-each>
     159
    158160            </documentationOf>
     161
    159162            <component>
    160163                <structuredBody>
     
    165168                            <title>Purpose</title>
    166169                            <text>
    167                                 <xsl:value-of select="a:ContinuityOfCareRecord/a:Purpose/a:Description/a:Text"></xsl:value-of>
     170                                <xsl:value-of select="/a:ContinuityOfCareRecord/a:Purpose/a:Description/a:Text"></xsl:value-of>
    168171                            </text>
    169172                        </section>
     
    186189                                                <th>Source</th>
    187190                                            </tr>
    188                                             <xsl:for-each select="a:ContinuityOfCareRecord/a:Body/a:Alerts/a:Alert">
     191                                            <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Alerts/a:Alert">
    189192                                                <tr>
    190193                                                    <td>
     
    239242                                                <th>Source</th>
    240243                                            </tr>
    241                                             <xsl:for-each select="a:ContinuityOfCareRecord/a:Body/a:AdvanceDirectives/a:AdvanceDirective">
     244                                            <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:AdvanceDirectives/a:AdvanceDirective">
    242245                                                <tr>
    243246                                                    <td>
     
    323326                        <component>
    324327                            <section>
    325                                 <templateId root="2.16.840.1.113883.10.20.1.11"/>
     328                                <templateId root="2.16.840.1.113883.3.88.11.83.103" assigningAuthorityName="HITSP/C83"/>
     329                                <templateId root="1.3.6.1.4.1.19376.1.5.3.1.3.6" assigningAuthorityName="IHE PCC"/>
     330                                <templateId root="2.16.840.1.113883.10.20.1.11" assigningAuthorityName="HL7 CCD"/>
    326331                                <code code="11450-4" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="Problem list"/>
    327332                                <title>Problems</title>
     
    337342                                                <th>Source</th>
    338343                                            </tr>
    339                                             <xsl:for-each select="a:ContinuityOfCareRecord/a:Body/a:Problems/a:Problem">
     344                                            <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Problems/a:Problem">
    340345                                                <tr>
     346                                                    <xsl:attribute name="id">
     347                                                        <xsl:value-of select="a:CCRDataObjectID"></xsl:value-of>
     348                                                    </xsl:attribute>
     349
    341350                                                    <td>
    342351                                                        <xsl:value-of select="a:Type/a:Text"/>
    343352                                                    </td>
    344353                                                    <td>
    345                                                         <xsl:call-template name="date:format-date">
    346                                                             <xsl:with-param name="date-time">
    347                                                                 <xsl:value-of select="a:DateTime/a:ExactDateTime"/>
    348                                                             </xsl:with-param>
    349                                                         </xsl:call-template>
     354                                                        <table>
     355                                                            <tbody>
     356                                                                <xsl:apply-templates select="a:DateTime"/>
     357                                                            </tbody>
     358                                                        </table>
    350359                                                    </td>
    351360                                                    <td>
     
    368377                                    </table>
    369378                                </text>
    370                                 <xsl:for-each select="a:ContinuityOfCareRecord/a:Body/a:Problems/a:Problem">
     379                                <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Problems/a:Problem">
    371380                                    <entry typeCode="DRIV">
    372381                                        <act classCode="ACT" moodCode="EVN">
    373382                                            <templateId root="2.16.840.1.113883.10.20.1.27"/>
    374383                                            <!-- Problem act template -->
    375                                             <id root="6a2fa88d-4174-4909-aece-db44b60a3abb"/>
     384
     385                                            <!-- <id> -->
     386                                            <xsl:call-template name="ccdID">
     387                                                <xsl:with-param name="ccrObjectID">
     388                                                    <xsl:value-of select="a:CCRDataObjectID"></xsl:value-of>
     389                                                </xsl:with-param>
     390                                            </xsl:call-template>
     391
    376392                                            <code nullFlavor="NA"/>
    377                                             <xsl:variable name="SourceActorID" select="a:Source/a:Actor/a:ActorID"/>
     393
    378394                                            <performer typeCode="PRF">
    379395                                                <assignedEntity>
    380                                                     <xsl:variable name="CCRActor" select="//a:ContinuityOfCareRecord/a:Actors[a:ActorObjectID=$SourceActorID]/a:Actor"/>
    381                                                     <xsl:if test="$CCRActor/a:Address">
    382                                                         <addr>
    383                                                             <streetAddressLine>
    384                                                                 <xsl:value-of select="$CCRActor/a:Address[0]/a:Line1"/>
    385                                                             </streetAddressLine>
    386                                                             <city>
    387                                                                 <xsl:value-of select="$CCRActor/a:Address[0]/a:City"/>
    388                                                             </city>
    389                                                             <state>
    390                                                                 <xsl:value-of select="$CCRActor/a:Address[0]/a:State"/>
    391                                                             </state>
    392                                                             <postalcode>
    393                                                                 <xsl:value-of select="$CCRActor/a:Address[0]/a:PostalCode"/>
    394                                                             </postalcode>
    395                                                         </addr>
    396                                                     </xsl:if>
    397                                                     <xsl:if test="$CCRActor/a:Telephone">
    398                                                         <xsl:element name="telecom">
    399                                                             <xsl:attribute name="extension">
    400                                                                 <xsl:value-of select="$CCRActor/a:Telephone[0]/a:Value"/>
    401                                                             </xsl:attribute>
    402                                                         </xsl:element>
    403                                                     </xsl:if>
    404                                                     <assignedPerson>
    405                                                         <name>
    406                                                             <xsl:call-template name="actorName">
    407                                                                 <xsl:with-param name="objID" select="$SourceActorID"/>
    408                                                             </xsl:call-template>
    409                                                         </name>
    410                                                     </assignedPerson>
     396                                                    <xsl:call-template name="ccdEntity">
     397                                                        <xsl:with-param name="ccrActorObjectID">
     398                                                            <xsl:value-of select="a:Source/a:Actor/a:ActorID"></xsl:value-of>
     399                                                        </xsl:with-param>
     400                                                    </xsl:call-template>
    411401                                                </assignedEntity>
    412402                                            </performer>
     403
    413404                                            <entryRelationship typeCode="SUBJ">
    414405                                                <observation classCode="OBS" moodCode="EVN">
    415406                                                    <templateId root="2.16.840.1.113883.10.20.1.28" assigningAuthorityName="CCD"/>
    416407                                                    <!--Problem observation template-->
    417                                                     <id root="d11275e7-67ae-11db-bd13-0800200c9a66"/>
     408
     409                                                    <!-- <id> -->
     410                                                    <xsl:call-template name="ccdID">
     411                                                        <xsl:with-param name="ccrObjectID">
     412                                                            <xsl:value-of select="a:CCRDataObjectID"></xsl:value-of>
     413                                                        </xsl:with-param>
     414                                                        <xsl:with-param name="suffix">.1</xsl:with-param>
     415                                                    </xsl:call-template>
     416
    418417                                                    <code code="64572001" displayName="Condition" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED-CT"/>
     418
    419419                                                    <text>
    420                                                         <xsl:element name="reference">
     420                                                        <reference>
    421421                                                            <xsl:attribute name="value">
    422                                                                 <xsl:value-of select="a:CCRObjectID"/>
     422                                                                <xsl:text>#</xsl:text>
     423                                                                <xsl:value-of select="a:CCRDataObjectID"/>
    423424                                                            </xsl:attribute>
    424                                                         </xsl:element>
     425                                                        </reference>
    425426                                                    </text>
    426                                                     <xsl:element name="statusCode">
    427                                                         <xsl:attribute name="value">
    428                                                             <xsl:value-of select="a:Status/a:Code/a:Value"/>
    429                                                         </xsl:attribute>
    430                                                     </xsl:element>
    431                                                     <xsl:element name="effectiveTime">
    432                                                         <xsl:attribute name="value">
    433                                                             <xsl:call-template name="date:format-date">
    434                                                                 <xsl:with-param name="date-time">
    435                                                                     <xsl:value-of select="a:DateTime[0]/a:ExactDateTime"/>
    436                                                                 </xsl:with-param>
    437                                                                 <xsl:with-param name="pattern">yyyyMMddhhmmss+0000</xsl:with-param>
    438                                                             </xsl:call-template>
    439                                                         </xsl:attribute>
    440                                                     </xsl:element>
    441                                                     <xsl:element name="value">
    442                                                         <xsl:attribute name="displayName">
    443                                                             <xsl:value-of select="a:Description/a:Text"/>
    444                                                         </xsl:attribute>
    445                                                         <xsl:attribute name="code">
    446                                                             <xsl:value-of select="a:Description/a:Code/a:Value"/>
    447                                                         </xsl:attribute>
    448                                                         <xsl:attribute name="codeSystemName">
    449                                                             <xsl:value-of select="a:Description/a:Code/a:CodingSystem"/>
    450                                                         </xsl:attribute>
    451                                                     </xsl:element>
     427
     428                                                    <statusCode code="completed"/>
     429
     430                                                    <xsl:call-template name="ccdDateTime">
     431                                                        <xsl:with-param name="dt" select="a:DateTime"/>
     432                                                    </xsl:call-template>
     433
     434                                                    <xsl:call-template name="ccdCodedValue">
     435                                                        <xsl:with-param name="ccrCodedDescription" select="a:Description"/>
     436                                                    </xsl:call-template>
     437
     438                                                    <xsl:call-template name="ccdStatus">
     439                                                        <xsl:with-param name="ccrStatus" select="a:Status"/>
     440                                                    </xsl:call-template>
    452441                                                </observation>
    453442                                            </entryRelationship>
     443
    454444                                        </act>
    455445                                    </entry>
     
    480470                                                <th>Source</th>
    481471                                            </tr>
    482                                             <xsl:for-each select="a:ContinuityOfCareRecord/a:Body/a:Procedures/a:Procedure">
     472                                            <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Procedures/a:Procedure">
    483473                                                <tr>
     474                                                    <xsl:attribute name="id">
     475                                                        <xsl:value-of select="a:CCRDataObjectID"></xsl:value-of>
     476                                                    </xsl:attribute>
     477
    484478                                                    <td>
    485479                                                        <xsl:value-of select="a:Type/a:Text"/>
    486480                                                    </td>
    487                                                     <td>
    488                                                         <xsl:call-template name="date:format-date">
    489                                                             <xsl:with-param name="date-time">
    490                                                                 <xsl:value-of select="a:DateTime/a:ExactDateTime"/>
    491                                                             </xsl:with-param>
    492                                                         </xsl:call-template>
    493                                                     </td>
     481                                                    <table>
     482                                                        <tbody>
     483                                                            <xsl:apply-templates select="a:DateTime"/>
     484                                                        </tbody>
     485                                                    </table>
    494486                                                    <td>
    495487                                                        <xsl:apply-templates select="a:Description/a:Code"/>
     
    543535                            </section>
    544536                        </component>
     537                        <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Procedures/a:Procedure">
     538                            <entry typeCode="DRIV">
     539                                <procedure classCode="PROC" moodCode="EVN">
     540                                    <templateId root="2.16.840.1.113883.3.88.11.83.17" assigningAuthorityName="HITSP C83"/>
     541                                    <templateId root="2.16.840.1.113883.10.20.1.29" assigningAuthorityName="CCD"/>
     542                                    <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.19" assigningAuthorityName="IHE PCC"/>
     543                                    <id>
     544                                        <xsl:attribute name="root">
     545                                            <xsl:value-of select="a:CCRDataObjectID"></xsl:value-of>
     546                                        </xsl:attribute>
     547                                    </id>
     548                                    <code>
     549                                        <xsl:attribute name="code">
     550                                            <xsl:value-of select="a:Description/a:Code/a:Value"/>
     551                                        </xsl:attribute>
     552                                        <xsl:attribute name="codeSystemName">
     553                                            <xsl:value-of select="a:Description/a:Code/a:CodingSystem"/>
     554                                        </xsl:attribute>
     555                                        <xsl:attribute name="codeSystem">
     556                                            <xsl:call-template name="HL7OIDLookup">
     557                                                <xsl:with-param name="name" select="a:Description/a:Code/a:CodingSystem"/>
     558                                            </xsl:call-template>
     559                                        </xsl:attribute>
     560                                        <xsl:attribute name="displayName">
     561                                            <xsl:value-of select="a:Description/a:Text"/>
     562                                        </xsl:attribute>
     563                                    </code>
     564                                    <text>
     565                                        <reference>
     566                                            <xsl:attribute name="value">
     567                                                <xsl:value-of select="a:CCRDataObjectID"/>
     568                                            </xsl:attribute>
     569                                        </reference>
     570                                    </text>
     571                                    <statusCode>
     572                                        <xsl:attribute name="value">
     573                                            <xsl:value-of select="a:Status/a:Text"/>
     574                                        </xsl:attribute>
     575                                    </statusCode>
     576                                    <xsl:call-template name="ccdDateTime">
     577                                        <xsl:with-param name="dt" select="a:DateTime"/>
     578                                    </xsl:call-template>
     579                                    <xsl:if test="a:Method">
     580                                        <approachSiteCode>
     581                                            <xsl:attribute name="code">
     582                                                <xsl:value-of select="a:Method/a:Code/a:Value"/>
     583                                            </xsl:attribute>
     584                                            <xsl:attribute name="codeSystemName">
     585                                                <xsl:value-of select="a:Method/a:Code/a:CodingSystem"/>
     586                                            </xsl:attribute>
     587                                            <xsl:attribute name="codeSystem">
     588                                                <xsl:call-template name="HL7OIDLookup">
     589                                                    <xsl:with-param name="name" select="a:Method/a:Code/a:CodingSystem"/>
     590                                                </xsl:call-template>
     591                                            </xsl:attribute>
     592                                            <xsl:attribute name="displayName">
     593                                                <xsl:value-of select="a:Method/a:Text"/>
     594                                            </xsl:attribute>
     595                                        </approachSiteCode>
     596                                    </xsl:if>
     597                                    <xsl:if test="a:Site">
     598                                        <targetSiteCode>
     599                                            <xsl:attribute name="code">
     600                                                <xsl:value-of select="a:Site/a:Code/a:Value"/>
     601                                            </xsl:attribute>
     602                                            <xsl:attribute name="codeSystemName">
     603                                                <xsl:value-of select="a:Site/a:Code/a:CodingSystem"/>
     604                                            </xsl:attribute>
     605                                            <xsl:attribute name="codeSystem">
     606                                                <xsl:call-template name="HL7OIDLookup">
     607                                                    <xsl:with-param name="name" select="a:Site/a:Code/a:CodingSystem"/>
     608                                                </xsl:call-template>
     609                                            </xsl:attribute>
     610                                            <xsl:attribute name="displayName">
     611                                                <xsl:value-of select="a:Site/a:Text"/>
     612                                            </xsl:attribute>
     613                                        </targetSiteCode>
     614                                    </xsl:if>
     615                                    <xsl:if test="a:Practitioners/a:Practitioner">
     616                                        <xsl:variable name="PractitionerActorID" select="a:Practitioners/a:Practitioner[0]/a:ActorID"/>
     617                                        <performer typeCode="PRF">
     618                                            <assignedEntity>
     619                                                <xsl:variable name="CCRActor" select="/a:ContinuityOfCareRecord/a:Actors[a:ActorObjectID=$PractitionerActorID]/a:Actor"/>
     620                                                <xsl:if test="$CCRActor/a:Address">
     621                                                    <addr>
     622                                                        <streetAddressLine>
     623                                                            <xsl:value-of select="$CCRActor/a:Address[0]/a:Line1"/>
     624                                                        </streetAddressLine>
     625                                                        <city>
     626                                                            <xsl:value-of select="$CCRActor/a:Address[0]/a:City"/>
     627                                                        </city>
     628                                                        <state>
     629                                                            <xsl:value-of select="$CCRActor/a:Address[0]/a:State"/>
     630                                                        </state>
     631                                                        <postalcode>
     632                                                            <xsl:value-of select="$CCRActor/a:Address[0]/a:PostalCode"/>
     633                                                        </postalcode>
     634                                                    </addr>
     635                                                </xsl:if>
     636                                                <xsl:if test="$CCRActor/a:Telephone">
     637                                                    <telecom>
     638                                                        <xsl:attribute name="extension">
     639                                                            <xsl:value-of select="$CCRActor/a:Telephone[0]/a:Value"/>
     640                                                        </xsl:attribute>
     641                                                    </telecom>
     642                                                </xsl:if>
     643                                                <assignedPerson>
     644                                                    <name>
     645                                                        <xsl:call-template name="actorName">
     646                                                            <xsl:with-param name="objID" select="$PractitionerActorID"/>
     647                                                        </xsl:call-template>
     648                                                    </name>
     649                                                </assignedPerson>
     650                                            </assignedEntity>
     651                                        </performer>
     652                                    </xsl:if>
     653                                </procedure>
     654                            </entry>
     655                        </xsl:for-each>
    545656                    </xsl:if>
    546657                    <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:Medications">
    547658                        <component>
    548659                            <section>
    549                                 <templateId root="2.16.840.1.113883.10.20.1.8"/>
    550                                 <code code="10160-0" codeSystem="2.16.840.1.113883.6.1"/>
     660                                <templateId root="2.16.840.1.113883.3.88.11.83.112" assigningAuthorityName="HITSP/C83"/>
     661                                <templateId root="1.3.6.1.4.1.19376.1.5.3.1.3.19" assigningAuthorityName="IHE PCC"/>
     662                                <templateId root="2.16.840.1.113883.10.20.1.8" assigningAuthorityName="HL7 CCD"/>
     663                                <!--Medications section template-->
     664                                <code code="10160-0" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="History of medication use"/>
    551665                                <title>Medications</title>
    552666                                <text>
     
    566680                                                <th>Source</th>
    567681                                            </tr>
    568                                             <xsl:for-each select="a:ContinuityOfCareRecord/a:Body/a:Medications/a:Medication">
     682                                            <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Medications/a:Medication">
    569683                                                <tr>
    570684                                                    <td>
    571 
    572685                                                        <xsl:value-of select="a:Product/a:ProductName/a:Text"/>
    573686                                                        <xsl:if test="a:Product/a:BrandName">
     
    662775                                    </table>
    663776                                </text>
     777                                <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Medications/a:Medication">
     778                                    <entry typeCode="DRIV">
     779                                        <substanceAdministration classCode="SBADM" moodCode="EVN">
     780                                            <templateId root="2.16.840.1.113883.10.20.1.24" assigningAuthorityName="CCD"/>
     781                                            <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.7.1" assigningAuthorityName="IHE PCC"/>
     782                                            <!--Medication activity template -->
     783                                            <id>
     784                                                <xsl:attribute name="root">
     785                                                    <xsl:value-of select="a:CCRDataObjectID"></xsl:value-of>
     786                                                </xsl:attribute>
     787                                            </id>
     788                                            <statusCode>
     789                                                <xsl:attribute name="value">
     790                                                    <xsl:value-of select="a:Status/a:Text"/>
     791                                                </xsl:attribute>
     792                                            </statusCode>
     793                                            <xsl:call-template name="ccdDateTime">
     794                                                <xsl:with-param name="dt" select="a:DateTime"/>
     795                                                <xsl:with-param name="type" select="'IVL_TS'"/>
     796                                            </xsl:call-template>
     797                                            <xsl:call-template name="ccdMedicationFrequency">
     798                                                <xsl:with-param name="frequency" select="a:Directions/a:Direction/a:Frequency"/>
     799                                            </xsl:call-template>
     800                                            <xsl:if test="a:Directions/a:Direction/a:Route">
     801                                                <routeCode>
     802                                                    <xsl:attribute name="code">
     803                                                        <xsl:value-of select="a:Directions/a:Direction/a:Route/a:Code/a:Value"></xsl:value-of>
     804                                                    </xsl:attribute>
     805                                                    <xsl:attribute name="codeSystem">
     806                                                        <xsl:call-template name="HL7OIDLookup">
     807                                                            <xsl:with-param name="name" select="a:Directions/a:Direction/a:Route/a:Code/a:CodingSystem"/>
     808                                                        </xsl:call-template>
     809                                                    </xsl:attribute>
     810                                                    <xsl:attribute name="displayName">
     811                                                        <xsl:value-of select="a:Directions/a:Direction/a:Route/a:Text"></xsl:value-of>
     812                                                    </xsl:attribute>
     813                                                </routeCode>
     814                                            </xsl:if>
     815                                            <xsl:if test="a:Directions/a:Direction/a:Dose">
     816                                                <doseQuantity>
     817                                                    <low>
     818                                                        <xsl:attribute name="value">
     819                                                            <xsl:value-of select="a:Directions/a:Direction/a:Dose/a:Value"></xsl:value-of>
     820                                                        </xsl:attribute>
     821                                                        <xsl:attribute name="unit">
     822                                                            <xsl:value-of select="a:Directions/a:Direction/a:Dose/a:Unit"></xsl:value-of>
     823                                                        </xsl:attribute>
     824                                                    </low>
     825                                                    <high>
     826                                                        <xsl:attribute name="value">
     827                                                            <xsl:value-of select="a:Directions/a:Direction/a:Dose/a:Value"></xsl:value-of>
     828                                                        </xsl:attribute>
     829                                                        <xsl:attribute name="unit">
     830                                                            <xsl:value-of select="a:Directions/a:Direction/a:Dose/a:Unit"></xsl:value-of>
     831                                                        </xsl:attribute>
     832                                                    </high>
     833                                                </doseQuantity>
     834                                            </xsl:if>
     835                                            <consumable>
     836                                                <manufacturedProduct>
     837                                                    <templateId root="2.16.840.1.113883.3.88.11.83.8.2" assigningAuthorityName="HITSP C83"/>
     838                                                    <templateId root="2.16.840.1.113883.10.20.1.53" assigningAuthorityName="CCD"/>
     839                                                    <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.7.2" assigningAuthorityName="IHE PCC"/>
     840                                                    <!-- Product template -->
     841                                                    <manufacturedMaterial>
     842                                                        <code>
     843                                                            <xsl:attribute name="code">
     844                                                                <xsl:value-of select="a:Product/a:ProductName/a:Code/a:Value"></xsl:value-of>
     845                                                            </xsl:attribute>
     846                                                            <xsl:attribute name="codeSystem">
     847                                                                <xsl:call-template name="HL7OIDLookup">
     848                                                                    <xsl:with-param name="name" select="a:Product/a:ProductName/a:Code/a:CodingSystem"/>
     849                                                                </xsl:call-template>
     850                                                            </xsl:attribute>
     851                                                            <xsl:attribute name="displayName">
     852                                                                <xsl:value-of select="a:Product/a:ProductName/a:Text"></xsl:value-of>
     853                                                            </xsl:attribute>
     854                                                        </code>
     855                                                        <name>
     856                                                            <xsl:value-of select="a:Product/a:BrandName/a:Text"></xsl:value-of>
     857                                                        </name>
     858                                                    </manufacturedMaterial>
     859                                                </manufacturedProduct>
     860                                            </consumable>
     861                                        </substanceAdministration>
     862                                    </entry>
     863                                </xsl:for-each>
    664864                            </section>
    665865                        </component>
     
    682882                                                <th>Source</th>
    683883                                            </tr>
    684                                             <xsl:for-each select="a:ContinuityOfCareRecord/a:Body/a:Immunizations/a:Immunization">
     884                                            <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Immunizations/a:Immunization">
    685885                                                <tr>
    686886                                                    <td>
     
    735935                                                <th>Source</th>
    736936                                            </tr>
    737                                             <xsl:for-each select="a:ContinuityOfCareRecord/a:Body/a:VitalSigns/a:Result">
     937                                            <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:VitalSigns/a:Result">
    738938                                                <tr>
    739939                                                    <td>
     
    791991                                                <th>Source</th>
    792992                                            </tr>
    793                                             <xsl:for-each select="a:ContinuityOfCareRecord/a:Body/a:Encounters/a:Encounter">
     993                                            <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Encounters/a:Encounter">
    794994                                                <tr>
    795995                                                    <td>
     
    8641064                                                <th>Source</th>
    8651065                                            </tr>
    866                                             <xsl:for-each select="a:ContinuityOfCareRecord/a:Body/a:SocialHistory/a:SocialHistoryElement">
     1066                                            <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:SocialHistory/a:SocialHistoryElement">
    8671067                                                <tr>
    8681068                                                    <td>
     
    9161116                                                <th>Source</th>
    9171117                                            </tr>
    918                                             <xsl:for-each select="a:ContinuityOfCareRecord/a:Body/a:FamilyHistory/a:FamilyProblemHistory">
     1118                                            <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:FamilyHistory/a:FamilyProblemHistory">
    9191119                                                <tr>
    9201120                                                    <td>
     
    9711171                                                <th>Source</th>
    9721172                                            </tr>
    973                                             <xsl:for-each select="a:ContinuityOfCareRecord/a:Body/a:Results/a:Result[a:Test/a:TestResult/a:Value!='']">
     1173                                            <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Results/a:Result[a:Test/a:TestResult/a:Value!='']">
    9741174                                                <tr>
    9751175                                                    <td>
     
    10331233                                                <th>Source</th>
    10341234                                            </tr>
    1035                                             <xsl:for-each select="a:ContinuityOfCareRecord/a:Body/a:Payers/a:Payer">
     1235                                            <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Payers/a:Payer">
    10361236                                                <tr>
    10371237                                                    <td>
     
    10921292                                                    <th>Source</th>
    10931293                                                </tr>
    1094                                                 <xsl:for-each select="a:ContinuityOfCareRecord/a:Body/a:PlanOfCare/a:Plan[a:Type/a:Text='Treatment Recommendation']">
     1294                                                <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:PlanOfCare/a:Plan[a:Type/a:Text='Treatment Recommendation']">
    10951295                                                    <tr>
    10961296                                                        <td>
     
    11361336                                                    <th>Source</th>
    11371337                                                </tr>
    1138                                                 <xsl:for-each select="a:ContinuityOfCareRecord/a:Body/a:PlanOfCare/a:Plan[a:Type/a:Text='Order']">
     1338                                                <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:PlanOfCare/a:Plan[a:Type/a:Text='Order']">
    11391339                                                    <tr>
    11401340                                                        <td>
     
    12131413                                                <th>Name</th>
    12141414                                            </tr>
    1215                                             <xsl:for-each select="a:ContinuityOfCareRecord/a:Body/a:HealthCareProviders/a:Provider">
     1415                                            <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:HealthCareProviders/a:Provider">
    12161416                                                <tr>
    12171417                                                    <td>
     
    12421442                                                <th>Name</th>
    12431443                                            </tr>
    1244                                             <xsl:for-each select="a:ContinuityOfCareRecord/a:Body/a:Support/a:SupportProvider">
     1444                                            <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Support/a:SupportProvider">
    12451445                                                <tr>
    12461446                                                    <td>
     
    12741474                                                <th>Source</th>
    12751475                                            </tr>
    1276                                             <xsl:for-each select="a:ContinuityOfCareRecord/a:References/a:Reference">
     1476                                            <xsl:for-each select="/a:ContinuityOfCareRecord/a:References/a:Reference">
    12771477                                                <tr>
    12781478                                                    <td>
     
    13221522                                                <th>Address/ E-mail</th>
    13231523                                            </tr>
    1324                                             <xsl:for-each select="a:ContinuityOfCareRecord/a:Actors/a:Actor">
     1524                                            <xsl:for-each select="/a:ContinuityOfCareRecord/a:Actors/a:Actor">
    13251525                                                <xsl:sort select="a:Person/a:Name/a:DisplayName|a:Person/a:Name/a:CurrentName/a:Family" data-type="text" order="ascending"/>
    13261526                                                <xsl:if test="a:Person">
     
    13671567                                                                </xsl:if>
    13681568                                                                <xsl:if test="a:City">
    1369                                                                     <xsl:value-of select="a:City"/>,
     1569                                                                    <xsl:value-of select="a:City"/>
     1570                                                                    <xsl:text>, </xsl:text>
    13701571                                                                </xsl:if>
    13711572                                                                <xsl:value-of select="a:State"/>
     
    13951596                                                <th>Address/ E-mail</th>
    13961597                                            </tr>
    1397                                             <xsl:for-each select="a:ContinuityOfCareRecord/a:Actors/a:Actor">
     1598                                            <xsl:for-each select="/a:ContinuityOfCareRecord/a:Actors/a:Actor">
    13981599                                                <xsl:sort select="a:Organization/a:Name" data-type="text" order="ascending"/>
    13991600                                                <xsl:if test="a:Organization">
     
    14381639                                                                </xsl:if>
    14391640                                                                <xsl:if test="a:City">
    1440                                                                     <xsl:value-of select="a:City"/>,
     1641                                                                    <xsl:value-of select="a:City"/>
     1642                                                                    <xsl:text>, </xsl:text>
    14411643                                                                </xsl:if>
    14421644                                                                <xsl:value-of select="a:State"/>
     
    14661668                                                <th>Address/ E-mail</th>
    14671669                                            </tr>
    1468                                             <xsl:for-each select="a:ContinuityOfCareRecord/a:Actors/a:Actor">
     1670                                            <xsl:for-each select="/a:ContinuityOfCareRecord/a:Actors/a:Actor">
    14691671                                                <xsl:sort select="a:InformationSystem/a:Name" data-type="text" order="ascending"/>
    14701672                                                <xsl:if test="a:InformationSystem">
     
    15091711                                                                </xsl:if>
    15101712                                                                <xsl:if test="a:City">
    1511                                                                     <xsl:value-of select="a:City"/>,
     1713                                                                    <xsl:value-of select="a:City"/>
     1714                                                                    <xsl:text>, </xsl:text>
    15121715                                                                </xsl:if>
    15131716                                                                <xsl:value-of select="a:State"/>
Note: See TracChangeset for help on using the changeset viewer.