Changeset 766 for ccr2ccd-xslt


Ignore:
Timestamp:
May 19, 2010, 9:54:08 PM (14 years ago)
Author:
Richard Braman
Message:

new file

File:
1 edited

Legend:

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

    r757 r766  
    1 <?xml version="1.0" encoding="utf-8"?>
     1<?xml version="1.0" encoding="utf-8"?>
    22<!--
    33Conversion of CCR to Level 3 CCD
     
    99Contributors:
    1010Richard Braman, EHR Doctors, Inc rbraman@ehrdoctors.com
    11 George Gilly (WorldVistA glilly@glilly.net)
     11George Lilly (WorldVistA glilly@glilly.net)
    1212xxxx - Oroville Hospital
    1313
     
    3131
    3232-->
    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">
     33<xsl:stylesheet version="1.0" xmlns="urn:hl7-org:v3" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="urn:astm-org:CCR" xmlns:date="http://exslt.org/dates-and-times"
     34xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exclude-result-prefixes="a date">
     35    <xsl:import href="./templates/cdavocablookup.xsl"/>
     36    <xsl:import href="./templates/hl7oidlookup.xsl"/>
    3437    <xsl:import href="./templates/code.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"/>
    4138    <xsl:import href="./templates/actor.xsl"/>
     39    <xsl:import href="./templates/datetime.xsl"/>
    4240    <xsl:import href="./templates/problemDescription.xsl"/>
    43     <xsl:import href="./templates/HL7OIDLookup.xsl"/>
    4441
    4542    <xsl:output method="xml" encoding="utf-8" version="1.0" indent="yes"/>
    4643    <xsl:template match="/">
    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">
     44        <ClinicalDocument xmlns="urn:hl7-org:v3" xsi:schemaLocation="urn:hl7-org:v3 http://xreg2.nist.gov:8080/hitspValidation/schema/cdar2c32/infrastructure/cda/C32_CDA.xsd" classCode="DOCCLIN" moodCode="EVN">
    4945            <realmCode code="US"/>
    5046            <typeId root="2.16.840.1.113883.1.3" extension="POCD_HD000040"/>
     
    104100            </author>
    105101
    106             <custodian>
    107                 <assignedCustodian>
    108                     <representedCustodianOrganization>
    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>
    112                     </representedCustodianOrganization>
    113                 </assignedCustodian>
    114             </custodian>
     102            <xsl:if test="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$fromID]/a:InternalCCRLink[a:LinkRelationship='Organization']">
     103                <custodian>
     104                    <assignedCustodian>
     105                        <representedCustodianOrganization>
     106                            <xsl:call-template name="ccdEntity">
     107                                <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>
     108                            </xsl:call-template>
     109                        </representedCustodianOrganization>
     110                    </assignedCustodian>
     111                </custodian>
     112            </xsl:if>
    115113
    116114            <documentationOf>
     
    533531                                    </table>
    534532                                </text>
     533
     534                                <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Procedures/a:Procedure">
     535                                    <entry typeCode="DRIV">
     536                                        <procedure classCode="PROC" moodCode="EVN">
     537                                            <templateId root="2.16.840.1.113883.3.88.11.83.17" assigningAuthorityName="HITSP C83"/>
     538                                            <templateId root="2.16.840.1.113883.10.20.1.29" assigningAuthorityName="CCD"/>
     539                                            <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.19" assigningAuthorityName="IHE PCC"/>
     540
     541                                            <!-- <id> -->
     542                                            <xsl:call-template name="ccdID">
     543                                                <xsl:with-param name="ccrObjectID">
     544                                                    <xsl:value-of select="a:CCRDataObjectID"></xsl:value-of>
     545                                                </xsl:with-param>
     546                                            </xsl:call-template>
     547
     548                                            <!-- <code> -->
     549                                            <xsl:call-template name="ccdCodedValue">
     550                                                <xsl:with-param name="ccrCodedDescription" select="a:Description"/>
     551                                                <xsl:with-param name="nodeName" select="'code'"/>
     552                                            </xsl:call-template>
     553
     554                                            <text>
     555                                                <reference>
     556                                                    <xsl:attribute name="value">
     557                                                        <xsl:text>#</xsl:text>
     558                                                        <xsl:value-of select="a:CCRDataObjectID"/>
     559                                                    </xsl:attribute>
     560                                                </reference>
     561                                            </text>
     562
     563                                            <xsl:call-template name="ccdStatusProcedure">
     564                                                <xsl:with-param name="status" select="a:Status"></xsl:with-param>
     565                                            </xsl:call-template>
     566
     567                                            <xsl:call-template name="ccdDateTime">
     568                                                <xsl:with-param name="dt" select="a:DateTime"/>
     569                                            </xsl:call-template>
     570
     571                                            <xsl:if test="a:Method">
     572                                                <xsl:call-template name="ccdCodedValue">
     573                                                    <xsl:with-param name="ccrCodedDescription" select="a:Method"/>
     574                                                    <xsl:with-param name="nodeName" select="'approachSiteCode'"/>
     575                                                </xsl:call-template>
     576                                            </xsl:if>
     577
     578                                            <xsl:if test="a:Site">
     579                                                <xsl:call-template name="ccdCodedValue">
     580                                                    <xsl:with-param name="ccrCodedDescription" select="a:Site"/>
     581                                                    <xsl:with-param name="nodeName" select="'targetSiteCode'"/>
     582                                                </xsl:call-template>
     583                                            </xsl:if>
     584
     585                                            <xsl:if test="a:Practitioners/a:Practitioner">
     586                                                <performer typeCode="PRF">
     587                                                    <assignedEntity>
     588                                                        <xsl:call-template name="ccdEntity">
     589                                                            <xsl:with-param name="ccrActorObjectID" select="a:Practitioners/a:Practitioner[1]/a:ActorID"/>
     590                                                        </xsl:call-template>
     591                                                    </assignedEntity>
     592                                                </performer>
     593                                            </xsl:if>
     594                                        </procedure>
     595                                    </entry>
     596                                </xsl:for-each>
    535597                            </section>
    536598                        </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>
    656599                    </xsl:if>
    657600                    <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:Medications">
     
    780723                                            <templateId root="2.16.840.1.113883.10.20.1.24" assigningAuthorityName="CCD"/>
    781724                                            <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.7.1" assigningAuthorityName="IHE PCC"/>
     725
    782726                                            <!--Medication activity template -->
    783                                             <id>
    784                                                 <xsl:attribute name="root">
     727
     728                                            <!-- <id> -->
     729                                            <xsl:call-template name="ccdID">
     730                                                <xsl:with-param name="ccrObjectID">
    785731                                                    <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>
     732                                                </xsl:with-param>
     733                                            </xsl:call-template>
     734
     735                                            <statusCode code='completed'/>
     736
    793737                                            <xsl:call-template name="ccdDateTime">
    794738                                                <xsl:with-param name="dt" select="a:DateTime"/>
    795739                                                <xsl:with-param name="type" select="'IVL_TS'"/>
    796740                                            </xsl:call-template>
     741
    797742                                            <xsl:call-template name="ccdMedicationFrequency">
    798743                                                <xsl:with-param name="frequency" select="a:Directions/a:Direction/a:Frequency"/>
    799744                                            </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>
     745
     746                                            <xsl:call-template name="ccdCodedValue">
     747                                                <xsl:with-param name="ccrCodedDescription" select="a:Directions/a:Direction/a:Route"/>
     748                                                <xsl:with-param name="nodeName" select="'routeCode'"/>
     749                                                <xsl:with-param name="domain" select="'RouteOfAdministration'"/>
     750                                            </xsl:call-template>
     751
    815752                                            <xsl:if test="a:Directions/a:Direction/a:Dose">
    816753                                                <doseQuantity>
     
    838775                                                    <templateId root="2.16.840.1.113883.10.20.1.53" assigningAuthorityName="CCD"/>
    839776                                                    <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.7.2" assigningAuthorityName="IHE PCC"/>
     777
    840778                                                    <!-- Product template -->
     779
    841780                                                    <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>
     781                                                        <xsl:call-template name="ccdCodedValue">
     782                                                            <xsl:with-param name="ccrCodedDescription" select="a:Product/a:ProductName"/>
     783                                                            <xsl:with-param name="nodeName" select="'code'"/>
     784                                                            <xsl:with-param name="domain" select="'RouteOfAdministration'"/>
     785                                                        </xsl:call-template>
    855786                                                        <name>
    856787                                                            <xsl:value-of select="a:Product/a:BrandName/a:Text"></xsl:value-of>
     
    11711102                                                <th>Source</th>
    11721103                                            </tr>
    1173                                             <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Results/a:Result[a:Test/a:TestResult/a:Value!='']">
     1104                                            <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Results/a:Result">
    11741105                                                <tr>
     1106                                                    <xsl:attribute name="id">
     1107                                                        <xsl:value-of select="a:CCRDataObjectID"></xsl:value-of>
     1108                                                    </xsl:attribute>
    11751109                                                    <td>
    11761110                                                        <xsl:value-of select="a:Description/a:Text"/>
     
    11851119                                                    <td>
    11861120                                                        <xsl:for-each select="a:Test[a:TestResult/a:Value!='']">
    1187                                                             <xsl:value-of select="a:Description/a:Text"/>
    1188                                                             <xsl:text xml:space="preserve"> </xsl:text>
    1189                                                             <xsl:value-of select="a:TestResult/a:Value"/>
    1190                                                             <xsl:text xml:space="preserve"> </xsl:text>
    1191                                                             <xsl:value-of select="a:TestResult/a:Units/a:Unit"/>
    1192                                                             <xsl:text xml:space="preserve"> </xsl:text>
    1193                                                             <xsl:value-of select="a:Flag/a:Text"/>
    1194                                                             <br/>
     1121                                                            <div>
     1122                                                                <xsl:attribute name="id">
     1123                                                                    <xsl:value-of select="a:CCRDataObjectID"></xsl:value-of>
     1124                                                                </xsl:attribute>
     1125
     1126                                                                <xsl:value-of select="a:Description/a:Text"/>
     1127                                                                <xsl:text xml:space="preserve"> </xsl:text>
     1128                                                                <xsl:value-of select="a:TestResult/a:Value"/>
     1129                                                                <xsl:text xml:space="preserve"> </xsl:text>
     1130                                                                <xsl:value-of select="a:TestResult/a:Units/a:Unit"/>
     1131                                                                <xsl:text xml:space="preserve"> </xsl:text>
     1132                                                                <xsl:value-of select="a:Flag/a:Text"/>
     1133                                                                <br/>
     1134                                                            </div>
    11951135                                                        </xsl:for-each>
    11961136                                                        <xsl:for-each select="a:Test[a:TestResult/a:Description/a:Text!='']">
    1197                                                             <xsl:value-of select="a:Description/a:Text"/>
    1198                                                             <xsl:text xml:space="preserve"> </xsl:text>
    1199                                                             <xsl:value-of select="a:TestResult/a:Description/a:Text" disable-output-escaping="yes"/>
    1200                                                             <xsl:text xml:space="preserve"> </xsl:text>
    1201                                                             <xsl:value-of select="a:Flag/a:Text"/>
    1202                                                             <br/>
     1137                                                            <div>
     1138                                                                <xsl:attribute name="id">
     1139                                                                    <xsl:value-of select="a:CCRDataObjectID"></xsl:value-of>
     1140                                                                </xsl:attribute>
     1141
     1142                                                                <xsl:value-of select="a:Description/a:Text"/>
     1143                                                                <xsl:text xml:space="preserve"> </xsl:text>
     1144                                                                <xsl:value-of select="a:TestResult/a:Description/a:Text" disable-output-escaping="yes"/>
     1145                                                                <xsl:text xml:space="preserve"> </xsl:text>
     1146                                                                <xsl:value-of select="a:Flag/a:Text"/>
     1147                                                                <br/>
     1148                                                            </div>
    12031149                                                        </xsl:for-each>
    12041150                                                    </td>
     
    12131159                                    </table>
    12141160                                </text>
     1161                                <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Results/a:Result">
     1162                                    <entry typeCode="DRIV">
     1163                                        <xsl:variable name="testDate" select="a:DateTime"/>
     1164
     1165                                        <xsl:choose>
     1166                                            <xsl:when test="count(a:Test)>1">
     1167                                                <organizer classCode="BATTERY" moodCode="EVN">
     1168                                                    <templateId root="2.16.840.1.113883.10.20.1.32"/>
     1169                                                    <!--Result organizer template -->
     1170
     1171                                                    <!-- <id> -->
     1172                                                    <xsl:call-template name="ccdID">
     1173                                                        <xsl:with-param name="ccrObjectID">
     1174                                                            <xsl:value-of select="a:CCRDataObjectID"></xsl:value-of>
     1175                                                        </xsl:with-param>
     1176                                                    </xsl:call-template>
     1177
     1178                                                    <!-- <code> -->
     1179                                                    <xsl:call-template name="ccdCodedValue">
     1180                                                        <xsl:with-param name="ccrCodedDescription" select="a:Description"/>
     1181                                                        <xsl:with-param name="nodeName" select="'code'"/>
     1182                                                    </xsl:call-template>
     1183
     1184                                                    <statusCode code="completed"/>
     1185
     1186                                                    <!-- <effectiveTime> -->
     1187                                                    <xsl:call-template name="ccdDateTime">
     1188                                                        <xsl:with-param name="dt" select="$testDate"/>
     1189                                                    </xsl:call-template>
     1190
     1191                                                    <performer>
     1192                                                        <assignedEntity>
     1193                                                            <xsl:call-template name="ccdEntity">
     1194                                                                <xsl:with-param name="ccrActorObjectID">
     1195                                                                    <xsl:value-of select="a:Source/a:Actor/a:ActorID"></xsl:value-of>
     1196                                                                </xsl:with-param>
     1197                                                            </xsl:call-template>
     1198                                                        </assignedEntity>
     1199                                                    </performer>
     1200
     1201                                                    <xsl:for-each select="a:Test">
     1202                                                        <xsl:call-template name="labObservation">
     1203                                                            <xsl:with-param name="ccrTestNode" select="."/>
     1204                                                            <xsl:with-param name="testDate" select="$testDate"/>
     1205                                                        </xsl:call-template>
     1206                                                    </xsl:for-each>
     1207
     1208                                                </organizer>
     1209
     1210                                            </xsl:when>
     1211                                            <xsl:otherwise>
     1212                                                <xsl:call-template name="labObservation">
     1213                                                    <xsl:with-param name="ccrTestNode" select="a:Test[1]"/>
     1214                                                    <xsl:with-param name="testDate" select="$testDate"/>
     1215                                                </xsl:call-template>
     1216
     1217                                            </xsl:otherwise>
     1218                                        </xsl:choose>
     1219                                    </entry>
     1220                                </xsl:for-each>
    12151221                            </section>
    12161222                        </component>
     
    17361742        </ClinicalDocument>
    17371743    </xsl:template>
     1744
     1745    <xsl:template name="ccdEntity">
     1746        <xsl:param name="ccrActorObjectID"/>
     1747        <xsl:param name="personNodeName">assignedPerson</xsl:param>
     1748
     1749        <xsl:variable name="CCRActor" select="//a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$ccrActorObjectID]"/>
     1750
     1751        <id>
     1752            <xsl:choose>
     1753                <xsl:when test="$CCRActor/a:IDs">
     1754                    <xsl:attribute name="extension">
     1755                        <xsl:value-of select="$CCRActor/a:IDs[1]/a:ID"/>
     1756                    </xsl:attribute>
     1757                    <xsl:attribute name="root">
     1758                        <xsl:value-of select="$CCRActor/a:IDs[1]/a:Type/a:Text"/>
     1759                    </xsl:attribute>
     1760                </xsl:when>
     1761                <xsl:otherwise>
     1762                    <xsl:attribute name="extension">
     1763                        <xsl:value-of select="$CCRActor/a:ActorObjectID"/>
     1764                    </xsl:attribute>
     1765                    <xsl:attribute name="root">
     1766                        <xsl:text>CCR Actor ID</xsl:text>
     1767                    </xsl:attribute>
     1768                </xsl:otherwise>
     1769            </xsl:choose>
     1770        </id>
     1771
     1772        <xsl:if test="$CCRActor/a:Organization">
     1773            <xsl:value-of select="$CCRActor/a:Organization/a:Name"></xsl:value-of>
     1774        </xsl:if>
     1775
     1776        <addr>
     1777            <xsl:choose>
     1778                <xsl:when test="$CCRActor/a:Address">
     1779                    <xsl:attribute name="use">
     1780                        <xsl:call-template name="CDAVocabularyLookup">
     1781                            <xsl:with-param name="domain" select="'telecommunicationsAddressUse'"/>
     1782                            <xsl:with-param name="ccrDescription" select="$CCRActor/a:Address/a:Type/a:Text"/>
     1783                        </xsl:call-template>
     1784                    </xsl:attribute>
     1785                    <streetAddressLine>
     1786                        <xsl:value-of select="$CCRActor/a:Address[1]/a:Line1"/>
     1787                    </streetAddressLine>
     1788                    <city>
     1789                        <xsl:value-of select="$CCRActor/a:Address[1]/a:City"/>
     1790                    </city>
     1791                    <state>
     1792                        <xsl:value-of select="$CCRActor/a:Address[1]/a:State"/>
     1793                    </state>
     1794                    <postalcode>
     1795                        <xsl:value-of select="$CCRActor/a:Address[1]/a:PostalCode"/>
     1796                    </postalcode>
     1797                </xsl:when>
     1798                <xsl:otherwise>
     1799                    <streetAddressLine/>
     1800                </xsl:otherwise>
     1801            </xsl:choose>
     1802        </addr>
     1803
     1804        <telecom>
     1805            <xsl:if test="$CCRActor/a:Telephone">
     1806                <xsl:attribute name="use">
     1807                    <xsl:call-template name="CDAVocabularyLookup">
     1808                        <xsl:with-param name="domain" select="'telecommunicationsAddressUse'"/>
     1809                        <xsl:with-param name="ccrDescription" select="$CCRActor/a:Telephone/a:Type/a:Text"/>
     1810                    </xsl:call-template>
     1811                </xsl:attribute>
     1812                <xsl:attribute name="value">
     1813                    <xsl:text>tel:+1-</xsl:text>
     1814                    <xsl:value-of select="$CCRActor/a:Telephone[1]/a:Value"/>
     1815                </xsl:attribute>
     1816            </xsl:if>
     1817
     1818        </telecom>
     1819
     1820        <xsl:if test="$CCRActor/a:Email">
     1821            <telecom>
     1822                <xsl:choose>
     1823                    <xsl:when test="$CCRActor/a:Telephone">
     1824                        <xsl:attribute name="use">
     1825                            <xsl:call-template name="CDAVocabularyLookup">
     1826                                <xsl:with-param name="domain" select="'telecommunicationsAddressUse'"/>
     1827                                <xsl:with-param name="ccrDescription" select="$CCRActor/a:Telephone/a:Type/a:Text"/>
     1828                            </xsl:call-template>
     1829                        </xsl:attribute>
     1830                        <xsl:attribute name="value">
     1831                            <xsl:text>mailto:</xsl:text>
     1832                            <xsl:value-of select="$CCRActor/a:Email[1]/a:Value"/>
     1833                        </xsl:attribute>
     1834                    </xsl:when>
     1835                    <xsl:otherwise>
     1836                        <xsl:attribute name="value">Unknown</xsl:attribute>
     1837                    </xsl:otherwise>
     1838                </xsl:choose>
     1839            </telecom>
     1840        </xsl:if>
     1841
     1842        <xsl:if test="a:Person">
     1843            <xsl:element name="{$personNodeName}">
     1844                <name>
     1845                    <xsl:if test="a:Person/a:Name/a:CurrentName/a:Title">
     1846                        <prefix>
     1847                            <xsl:value-of select="a:Person/a:Name/a:CurrentName/a:Title"></xsl:value-of>
     1848                        </prefix>
     1849                    </xsl:if>
     1850                    <xsl:if test="a:Person/a:Name/a:CurrentName/a:Given">
     1851                        <given>
     1852                            <xsl:value-of select="a:Person/a:Name/a:CurrentName/a:Given"></xsl:value-of>
     1853                        </given>
     1854                    </xsl:if>
     1855                    <xsl:if test="a:Person/a:Name/a:CurrentName/a:Middle">
     1856                        <given>
     1857                            <xsl:value-of select="a:Person/a:Name/a:CurrentName/a:Middle"></xsl:value-of>
     1858                        </given>
     1859                    </xsl:if>
     1860                    <xsl:if test="a:Person/a:Name/a:CurrentName/a:Family">
     1861                        <family>
     1862                            <xsl:value-of select="a:Person/a:Name/a:CurrentName/a:Family"></xsl:value-of>
     1863                        </family>
     1864                    </xsl:if>
     1865                    <xsl:if test="a:Person/a:Name/a:CurrentName/a:Suffix">
     1866                        <suffix>
     1867                            <xsl:value-of select="a:Person/a:Name/a:CurrentName/a:Suffix"></xsl:value-of>
     1868                        </suffix>
     1869                    </xsl:if>
     1870                </name>
     1871
     1872                <xsl:if test="a:Person/a:Gender">
     1873
     1874                    <xsl:call-template name="ccdCodedValue">
     1875                        <xsl:with-param name="ccrCodedDescription" select="a:Person/a:Gender"/>
     1876                        <xsl:with-param name="domain" select="'AdministrativeGender'"/>
     1877                        <xsl:with-param name="nodeName" select="'administrativeGenderCode'"/>
     1878                    </xsl:call-template>
     1879                </xsl:if>
     1880
     1881                <xsl:if test="a:Person/a:DateOfBirth">
     1882                    <birthTime>
     1883                        <xsl:attribute name="value">
     1884                            <xsl:call-template name="date:format-date">
     1885                                <xsl:with-param name="date-time">
     1886                                    <xsl:value-of select="a:Person/a:DateOfBirth/a:ExactDateTime"/>
     1887                                </xsl:with-param>
     1888                                <xsl:with-param name="pattern">yyyyMMddhhmmss</xsl:with-param>
     1889                            </xsl:call-template>
     1890                        </xsl:attribute>
     1891                    </birthTime>
     1892                </xsl:if>
     1893            </xsl:element>
     1894        </xsl:if>
     1895
     1896        <xsl:if test="$ccrActorObjectID=/a:ContinuityOfCareRecord/a:Patient[1]/a:ActorID">
     1897            <xsl:if test="/a:ContinuityOfCareRecord/a:Body/a:SocialHistory/a:SocialHistoryElement[a:Type/a:Text='Marital Status']">
     1898
     1899                <xsl:call-template name="ccdCodedValue">
     1900                    <xsl:with-param name="ccrCodedDescription" select="/a:ContinuityOfCareRecord/a:Body/a:SocialHistory/a:SocialHistoryElement[a:Type/a:Text='Marital Status']/a:Description"></xsl:with-param>
     1901                    <xsl:with-param name="domain" select="'MaritalStatus'"/>
     1902                    <xsl:with-param name="nodeName" select="'maritalStatusCode'"/>
     1903                </xsl:call-template>
     1904
     1905            </xsl:if>
     1906
     1907            <xsl:if test="/a:ContinuityOfCareRecord/a:Body/a:SocialHistory/a:SocialHistoryElement[a:Type/a:Text='Language']">
     1908                <languageCommunication>
     1909                    <templateId root="2.16.840.1.113883.3.88.11.83.2" assigningAuthorityName="HITSP/C83"/>
     1910                    <templateId root="1.3.6.1.4.1.19376.1.5.3.1.2.1" assigningAuthorityName="IHE/PCC"/>
     1911
     1912                    <xsl:call-template name="ccdCodedValue">
     1913                        <xsl:with-param name="ccrCodedDescription" select="/a:ContinuityOfCareRecord/a:Body/a:SocialHistory/a:SocialHistoryElement[a:Type/a:Text='Language']/a:Description"></xsl:with-param>
     1914                        <xsl:with-param name="domain" select="'HumanLanguage'"/>
     1915                        <xsl:with-param name="nodeName" select="'languageCode'"/>
     1916                    </xsl:call-template>
     1917
     1918                </languageCommunication>
     1919            </xsl:if>
     1920        </xsl:if>
     1921
     1922        <xsl:if test="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$ccrActorObjectID]/a:InternalCCRLink[a:LinkRelationship='Organization']">
     1923            <representedOrganization>
     1924                <xsl:call-template name="ccdEntity">
     1925                    <xsl:with-param name="ccrActorObjectID" select="/a:ContinuityOfCareRecord/a:Actors/a:Actor[a:ActorObjectID=$ccrActorObjectID]/a:InternalCCRLink[a:LinkRelationship='Organization']/a:LinkID"></xsl:with-param>
     1926                </xsl:call-template>
     1927            </representedOrganization>
     1928        </xsl:if>
     1929
     1930    </xsl:template>
     1931
     1932    <xsl:template name="ccdID">
     1933        <xsl:param name="ccrObjectID"/>
     1934        <xsl:param name="suffix"></xsl:param>
     1935
     1936        <id>
     1937            <xsl:attribute name="root">
     1938                <xsl:value-of select="$ccrObjectID"></xsl:value-of>
     1939                <xsl:value-of select="$suffix"></xsl:value-of>
     1940            </xsl:attribute>
     1941            <xsl:attribute name="extension">CCR Object ID</xsl:attribute>
     1942        </id>
     1943    </xsl:template>
     1944
     1945    <xsl:template name="ccdCodedValue">
     1946        <xsl:param name="ccrCodedDescription"/>
     1947        <xsl:param name="type"/>
     1948        <xsl:param name="domain"/>
     1949        <xsl:param name="nodeName">value</xsl:param>
     1950
     1951        <xsl:element name="{$nodeName}">
     1952            <xsl:if test="$type">
     1953                <xsl:attribute name="xsi:type">
     1954                    <xsl:value-of select="$type"/>
     1955                </xsl:attribute>
     1956            </xsl:if>
     1957            <xsl:choose>
     1958                <xsl:when test="$ccrCodedDescription/a:Code">
     1959                    <xsl:attribute name="displayName">
     1960                        <xsl:value-of select="$ccrCodedDescription/a:Text"/>
     1961                    </xsl:attribute>
     1962                    <xsl:attribute name="code">
     1963                        <xsl:value-of select="$ccrCodedDescription/a:Code/a:Value"/>
     1964                    </xsl:attribute>
     1965                    <xsl:attribute name="codeSystemName">
     1966                        <xsl:value-of select="$ccrCodedDescription/a:Code/a:CodingSystem"/>
     1967                    </xsl:attribute>
     1968                    <xsl:attribute name="codeSystem">
     1969                        <xsl:call-template name="HL7OIDLookup">
     1970                            <xsl:with-param name="name" select="$ccrCodedDescription/a:Code/a:CodingSystem"/>
     1971                        </xsl:call-template>
     1972                    </xsl:attribute>
     1973                </xsl:when>
     1974                <xsl:when test="$domain">
     1975                    <xsl:variable name="cdaCode">
     1976                        <xsl:call-template name="CDAVocabularyLookup">
     1977                            <xsl:with-param name="domain" select="$domain"/>
     1978                            <xsl:with-param name="ccrtext" select="$ccrCodedDescription/a:Text"/>
     1979                        </xsl:call-template>
     1980                    </xsl:variable>
     1981                    <xsl:attribute name="displayName">
     1982                        <xsl:call-template name="CDADisplayNameLookup">
     1983                            <xsl:with-param name="domain" select="$domain"/>
     1984                            <xsl:with-param name="cdacode" select="$cdaCode"/>
     1985                        </xsl:call-template>
     1986                    </xsl:attribute>
     1987                    <xsl:attribute name="code">
     1988                        <xsl:value-of select="$cdaCode"></xsl:value-of>
     1989                    </xsl:attribute>
     1990                    <xsl:attribute name="codeSystemName">
     1991                        <xsl:call-template name="CDAVocabularyCodeSystemNameLookup">
     1992                            <xsl:with-param name="domain" select="$domain"/>
     1993                        </xsl:call-template>
     1994                    </xsl:attribute>
     1995                    <xsl:attribute name="codeSystemName">
     1996                        <xsl:call-template name="CDAVocabularyCodeSystemLookup">
     1997                            <xsl:with-param name="domain" select="$domain"/>
     1998                        </xsl:call-template>
     1999                    </xsl:attribute>
     2000                </xsl:when>
     2001                <xsl:otherwise>
     2002                    <xsl:attribute name="displayName">
     2003                        <xsl:value-of select="$ccrCodedDescription/a:Text"/>
     2004                    </xsl:attribute>
     2005                </xsl:otherwise>
     2006            </xsl:choose>
     2007        </xsl:element>
     2008
     2009    </xsl:template>
     2010
     2011    <xsl:template name="ccdDateTime">
     2012        <xsl:param name="dt"/>
     2013        <xsl:param name="type"/>
     2014        <xsl:if test="$dt">
     2015            <xsl:if test="$dt[1]/a:ExactDateTime">
     2016                <effectiveTime>
     2017                    <xsl:if test="$type">
     2018                        <xsl:attribute name="xsi:type">
     2019                            <xsl:value-of select="$type"></xsl:value-of>
     2020                        </xsl:attribute>
     2021                    </xsl:if>
     2022                    <low>
     2023                        <xsl:attribute name="value">
     2024                            <xsl:call-template name="date:format-date">
     2025                                <xsl:with-param name="date-time">
     2026                                    <xsl:value-of select="$dt[1]/a:ExactDateTime"/>
     2027                                </xsl:with-param>
     2028                                <xsl:with-param name="pattern">yyyyMMdd</xsl:with-param>
     2029                            </xsl:call-template>
     2030                        </xsl:attribute>
     2031                    </low>
     2032                    <high nullFlavor="UNK"/>
     2033                </effectiveTime>
     2034            </xsl:if>
     2035            <xsl:if test="$dt[1]/a:DateTimeRange">
     2036                <effectiveTime>
     2037                    <low>
     2038                        <xsl:attribute name="value">
     2039                            <xsl:call-template name="date:format-date">
     2040                                <xsl:with-param name="date-time">
     2041                                    <xsl:value-of select="$dt[1]/a:DateTimeRange/a:BeginRange/a:ExactDateTime"/>
     2042                                </xsl:with-param>
     2043                                <xsl:with-param name="pattern">yyyyMMdd</xsl:with-param>
     2044                            </xsl:call-template>
     2045                        </xsl:attribute>
     2046                    </low>
     2047                    <high>
     2048                        <xsl:attribute name="value">
     2049                            <xsl:call-template name="date:format-date">
     2050                                <xsl:with-param name="date-time">
     2051                                    <xsl:value-of select="$dt[1]/a:DateTimeRange/a:EndRange/a:ExactDateTime"/>
     2052                                </xsl:with-param>
     2053                                <xsl:with-param name="pattern">yyyyMMdd</xsl:with-param>
     2054                            </xsl:call-template>
     2055                        </xsl:attribute>
     2056                    </high>
     2057                </effectiveTime>
     2058            </xsl:if>
     2059        </xsl:if>
     2060    </xsl:template>
     2061
     2062    <xsl:template name="ccdMedicationFrequency">
     2063        <xsl:param name="frequency"/>
     2064        <xsl:if test="$frequency">
     2065            <xsl:choose>
     2066                <xsl:when test="$frequency/a:Value='qd'">
     2067                    <effectiveTime xsi:type="PIVL_TS" operator="A">
     2068                        <xsl:attribute name="institutionSpecified">true</xsl:attribute>
     2069                        <period>
     2070                            <xsl:attribute name="value">24</xsl:attribute>
     2071                            <xsl:attribute name="unit">h</xsl:attribute>
     2072                        </period>
     2073                    </effectiveTime>
     2074                </xsl:when>
     2075                <xsl:when test="$frequency/a:Value='bid'">
     2076                    <effectiveTime xsi:type="PIVL_TS" operator="A">
     2077                        <xsl:attribute name="institutionSpecified">true</xsl:attribute>
     2078                        <period>
     2079                            <xsl:attribute name="value">12</xsl:attribute>
     2080                            <xsl:attribute name="unit">h</xsl:attribute>
     2081                        </period>
     2082                    </effectiveTime>
     2083                </xsl:when>
     2084                <xsl:when test="$frequency/a:Value='tid'">
     2085                    <effectiveTime xsi:type="PIVL_TS" operator="A">
     2086                        <xsl:attribute name="institutionSpecified">true</xsl:attribute>
     2087                        <period>
     2088                            <xsl:attribute name="value">8</xsl:attribute>
     2089                            <xsl:attribute name="unit">h</xsl:attribute>
     2090                        </period>
     2091                    </effectiveTime>
     2092                </xsl:when>
     2093                <xsl:when test="$frequency/a:Value='qid'">
     2094                    <effectiveTime xsi:type="PIVL_TS" operator="A">
     2095                        <xsl:attribute name="institutionSpecified">true</xsl:attribute>
     2096                        <period>
     2097                            <xsl:attribute name="value">6</xsl:attribute>
     2098                            <xsl:attribute name="unit">h</xsl:attribute>
     2099                        </period>
     2100                    </effectiveTime>
     2101                </xsl:when>
     2102                <xsl:when test="$frequency/a:Value='qam'">
     2103                    <effectiveTime xsi:type='EIVL' operator='A'>
     2104                        <event code='ACM'/>
     2105                    </effectiveTime>
     2106                </xsl:when>
     2107                <xsl:when test="$frequency/a:Value='qpm'">
     2108                    <effectiveTime xsi:type='EIVL' operator='A'>
     2109                        <event code='PCV'/>
     2110                    </effectiveTime>
     2111                </xsl:when>
     2112            </xsl:choose>
     2113        </xsl:if>
     2114    </xsl:template>
     2115
     2116    <xsl:template name="ccdStatus">
     2117        <xsl:param name="ccrStatus"/>
     2118
     2119        <entryRelationship typeCode="REFR">
     2120            <observation classCode="OBS" moodCode="EVN">
     2121                <templateId root="2.16.840.1.113883.10.20.1.50"/>
     2122                <!-- Problem status observation template -->
     2123                <code code="33999-4" codeSystem="2.16.840.1.113883.6.1" displayName="Status"/>
     2124                <statusCode code="completed"/>
     2125                <xsl:call-template name="ccdCodedValue">
     2126                    <xsl:with-param name="ccrCodedDescription" select="$ccrStatus"/>
     2127                </xsl:call-template>
     2128            </observation>
     2129        </entryRelationship>
     2130    </xsl:template>
     2131
     2132    <xsl:template name="ccdStatusObservation">
     2133        <xsl:param name="status"/>
     2134        <xsl:variable name="statusText" select="$status/a:Text"></xsl:variable>
     2135        <xsl:choose>
     2136            <xsl:when test="$statusText='Active'">
     2137                <xsl:call-template name="ccdStatusElement">
     2138                    <xsl:with-param name="statusCode" select="'55561003'"></xsl:with-param>
     2139                    <xsl:with-param name="statusDisplayName" select="$statusText"></xsl:with-param>
     2140                </xsl:call-template>
     2141            </xsl:when>
     2142            <xsl:when test="$statusText='Inactive'">
     2143                <xsl:call-template name="ccdStatusElement">
     2144                    <xsl:with-param name="statusCode" select="'73425007'"></xsl:with-param>
     2145                    <xsl:with-param name="statusDisplayName" select="$statusText"></xsl:with-param>
     2146                </xsl:call-template>
     2147            </xsl:when>
     2148            <xsl:when test="$statusText='Chronic'">
     2149                <xsl:call-template name="ccdStatusElement">
     2150                    <xsl:with-param name="statusCode" select="'90734009'"></xsl:with-param>
     2151                    <xsl:with-param name="statusDisplayName" select="$statusText"></xsl:with-param>
     2152                </xsl:call-template>
     2153            </xsl:when>
     2154        </xsl:choose>
     2155    </xsl:template>
     2156
     2157    <xsl:template name="ccdStatusProcedure">
     2158        <xsl:param name="status"/>
     2159        <xsl:variable name="statusText" select="$status/a:Text"></xsl:variable>
     2160        <xsl:choose>
     2161            <xsl:when test="$statusText='Completed'">
     2162                <statusCode code="completed"/>
     2163            </xsl:when>
     2164            <xsl:when test="$statusText='Active'">
     2165                <statusCode code="active"/>
     2166            </xsl:when>
     2167            <xsl:when test="$statusText='Aborted'">
     2168                <statusCode code="aborted"/>
     2169            </xsl:when>
     2170            <xsl:when test="$statusText='Cancelled' or $statusText='Canceled'">
     2171                <statusCode code="cancelled"/>
     2172            </xsl:when>
     2173            <xsl:otherwise>
     2174                <statusCode>
     2175                    <xsl:attribute name="code">
     2176                        <xsl:value-of select="$statusText"></xsl:value-of>
     2177                    </xsl:attribute>
     2178                </statusCode>
     2179            </xsl:otherwise>
     2180        </xsl:choose>
     2181    </xsl:template>
     2182
     2183    <xsl:template name="ccdStatusElement">
     2184        <xsl:param name="statusCode"/>
     2185        <xsl:param name="statusDisplayName"/>
     2186        <value>
     2187            <xsl:attribute name="xsi:type">CE</xsl:attribute>
     2188            <xsl:attribute name="code">
     2189                <xsl:value-of select="$statusCode"></xsl:value-of>
     2190            </xsl:attribute>
     2191            <xsl:attribute name="codeSystem">2.16.840.1.113883.6.96</xsl:attribute>
     2192            <xsl:attribute name="displayName">
     2193                <xsl:value-of select="$statusDisplayName"></xsl:value-of>
     2194            </xsl:attribute>
     2195        </value>
     2196    </xsl:template>
     2197
     2198    <xsl:template name="labObservation">
     2199        <xsl:param name="ccrTestNode"/>
     2200        <xsl:param name="testDate"/>
     2201
     2202        <component>
     2203            <observation classCode="OBS" moodCode="EVN">
     2204                <templateId root="2.16.840.1.113883.3.88.11.83.15" assigningAuthorityName="HITSP C83"/>
     2205                <templateId root="2.16.840.1.113883.10.20.1.31" assigningAuthorityName="CCD"/>
     2206                <templateId root="1.3.6.1.4.1.19376.1.5.3.1.4.13" assigningAuthorityName="IHE PCC"/>
     2207                <!-- Result observation template -->
     2208
     2209                <xsl:call-template name="ccdID">
     2210                    <xsl:with-param name="ccrObjectID">
     2211                        <xsl:value-of select="$ccrTestNode/a:CCRDataObjectID"></xsl:value-of>
     2212                    </xsl:with-param>
     2213                </xsl:call-template>
     2214
     2215                <!-- <code> -->
     2216                <xsl:call-template name="ccdCodedValue">
     2217                    <xsl:with-param name="ccrCodedDescription" select="$ccrTestNode/a:Description"/>
     2218                    <xsl:with-param name="nodeName" select="'code'"/>
     2219                </xsl:call-template>
     2220
     2221                <text>
     2222                    <reference>
     2223                        <xsl:attribute name="value">
     2224                            <xsl:text>#</xsl:text>
     2225                            <xsl:value-of select="$ccrTestNode/a:CCRDataObjectID"/>
     2226                        </xsl:attribute>
     2227                    </reference>
     2228                </text>
     2229
     2230                <statusCode code="completed"/>
     2231
     2232                <!-- <effectiveTime> -->
     2233                <xsl:choose>
     2234                    <xsl:when test="$ccrTestNode/a:DateTime">
     2235                        <xsl:call-template name="ccdDateTime">
     2236                            <xsl:with-param name="dt" select="$ccrTestNode/a:DateTime"/>
     2237                        </xsl:call-template>
     2238                    </xsl:when>
     2239                    <xsl:otherwise>
     2240                        <xsl:call-template name="ccdDateTime">
     2241                            <xsl:with-param name="dt" select="$testDate"/>
     2242                        </xsl:call-template>
     2243                    </xsl:otherwise>
     2244                </xsl:choose>
     2245
     2246                <xsl:choose>
     2247                    <xsl:when test="$ccrTestNode/a:TestResult[a:Value!='']">
     2248                        <value xsi:type="PQ">
     2249                            <xsl:attribute name="value">
     2250                                <xsl:value-of select="$ccrTestNode/a:TestResult/a:Value"/>
     2251                            </xsl:attribute>
     2252                            <xsl:attribute name="unit">
     2253                                <xsl:value-of select="$ccrTestNode/a:TestResult/a:Units/a:Unit"/>
     2254                            </xsl:attribute>
     2255                        </value>
     2256                    </xsl:when>
     2257                    <xsl:when test="$ccrTestNode/a:TestResult[a:Description/a:Text!='']">
     2258                        <value xsi:type="TX">
     2259                            <xsl:attribute name="value">
     2260                                <xsl:value-of select="$ccrTestNode/a:TestResult/a:Description/a:Text"/>
     2261                            </xsl:attribute>
     2262                        </value>
     2263                    </xsl:when>
     2264                </xsl:choose>
     2265
     2266                <xsl:if test="$ccrTestNode/a:Flag">
     2267                    <xsl:call-template name="ccdCodedValue">
     2268                        <xsl:with-param name="ccrCodedDescription" select="$ccrTestNode/a:Flag"/>
     2269                        <xsl:with-param name="nodeName" select="'interpretationCode'"/>
     2270                        <xsl:with-param name="domain" select="'ObservationInterpretation'"/>
     2271                    </xsl:call-template>
     2272                </xsl:if>
     2273
     2274                <xsl:if test="$ccrTestNode/a:NormalResult">
     2275                    <referenceRange>
     2276                        <xsl:if test="$ccrTestNode/a:NormalResult/a:Normal/a:Description/a:Text">
     2277                            <observationRange>
     2278                                <text>
     2279                                    <xsl:value-of select="$ccrTestNode/a:NormalResult/a:Normal/a:Description/a:Text"/>
     2280                                </text>
     2281                            </observationRange>
     2282                        </xsl:if>
     2283                    </referenceRange>
     2284                </xsl:if>
     2285
     2286            </observation>
     2287        </component>
     2288
     2289    </xsl:template>
    17382290</xsl:stylesheet>
Note: See TracChangeset for help on using the changeset viewer.