Index: ccr2ccd-xslt/trunk/make/Nancy-ccr_qrda-M1.xsl
===================================================================
--- ccr2ccd-xslt/trunk/make/Nancy-ccr_qrda-M1.xsl	(revision 991)
+++ ccr2ccd-xslt/trunk/make/Nancy-ccr_qrda-M1.xsl	(revision 992)
@@ -515,4 +515,118 @@
                   </section>
                 </component>
+                    <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:Problems">
+                        <component>
+                            <section>
+                                <templateId root="2.16.840.1.113883.3.88.11.83.103" assigningAuthorityName="HITSP/C83"/>
+                                <templateId root="1.3.6.1.4.1.19376.1.5.3.1.3.6" assigningAuthorityName="IHE PCC"/>
+                                <templateId root="2.16.840.1.113883.10.20.1.11" assigningAuthorityName="HL7 CCD"/>
+                                <code code="11450-4" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="Problem list"/>
+                                <title>Problems</title>
+                                <text>
+                                    <table>
+                                        <tbody>
+                                            <tr>
+                                                <th>Type</th>
+                                                <th>Date</th>
+                                                <th>Code</th>
+                                                <th>Description</th>
+                                                <th>Status</th>
+                                                <th>Source</th>
+                                            </tr>
+                                            <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Problems/a:Problem">
+                                                <tr>
+                                                    <td>
+                                                        <xsl:value-of select="a:Type/a:Text"/>
+                                                    </td>
+                                                    <td>
+                                                        <table>
+                                                            <tbody>
+                                                                <xsl:apply-templates select="a:DateTime"/>
+                                                            </tbody>
+                                                        </table>
+                                                    </td>
+                                                    <td>
+                                                        <xsl:apply-templates select="a:Description/a:Code"/>
+                                                    </td>
+                                                    <td>
+														<xsl:attribute name="ID">
+															<xsl:value-of select="a:CCRDataObjectID"></xsl:value-of>
+														</xsl:attribute>
+                                                        <xsl:value-of select="a:Description/a:Text"/>
+                                                    </td>
+                                                    <td>
+                                                        <xsl:value-of select="a:Status/a:Text"/>
+                                                    </td>
+                                                    <td>
+                                                        <xsl:call-template name="actorName">
+                                                            <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
+                                                        </xsl:call-template>
+                                                    </td>
+                                                </tr>
+                                            </xsl:for-each>
+                                        </tbody>
+                                    </table>
+                                </text>
+                                <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Problems/a:Problem">
+                                    <entry typeCode="DRIV">
+                                        <act classCode="ACT" moodCode="EVN">
+                                            <templateId root="2.16.840.1.113883.10.20.1.27"/>
+                                            <!-- Problem act template -->
+
+                                            <!-- <id> -->
+                                            <xsl:call-template name="ccdID">
+                                                <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
+                                            </xsl:call-template>
+
+                                            <code nullFlavor="NA"/>
+
+                                            <xsl:call-template name="ccdPerformer">
+                                                <xsl:with-param name="ccrActorReference" select="a:Source/a:Actor"/>
+                                            </xsl:call-template>
+
+                                            <entryRelationship typeCode="SUBJ">
+                                                <observation classCode="OBS" moodCode="EVN">
+                                                    <templateId root="2.16.840.1.113883.10.20.1.28" assigningAuthorityName="CCD"/>
+                                                    <!--Problem observation template-->
+
+                                                    <!-- <id> -->
+                                                    <xsl:call-template name="ccdID">
+                                                        <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
+                                                        <xsl:with-param name="suffix"></xsl:with-param>
+                                                    </xsl:call-template>
+
+                                                    <code code="55607006" displayName="Problem" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED-CT"/>
+
+                                                    <text>
+                                                        <reference>
+                                                            <xsl:attribute name="value">
+                                                                <xsl:text>#</xsl:text>
+                                                                <xsl:value-of select="a:CCRDataObjectID"/>
+                                                            </xsl:attribute>
+                                                        </reference>
+                                                    </text>
+
+                                                    <statusCode code="completed"/>
+
+                                                    <xsl:call-template name="ccdDateTime">
+                                                        <xsl:with-param name="dt" select="a:DateTime"/>
+                                                    </xsl:call-template>
+
+                                                    <xsl:call-template name="ccdCodedValue">
+                                                        <xsl:with-param name="ccrCodedDescription" select="a:Description"/>
+                                                    </xsl:call-template>
+
+                                                    <xsl:call-template name="ccdStatus">
+                                                        <xsl:with-param name="ccrStatus" select="a:Status"/>
+                                                    </xsl:call-template>
+                                                </observation>
+                                            </entryRelationship>
+
+                                        </act>
+                                    </entry>
+                                </xsl:for-each>
+                            </section>
+                        </component>
+                    </xsl:if>
                     <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:Procedures">
                         <component>
@@ -730,4 +844,128 @@
 </section>
 </component>
+                    <xsl:if test="a:ContinuityOfCareRecord/a:Body/a:Results/a:Result">
+                        <component>
+                            <section>
+                                <templateId root="2.16.840.1.113883.10.20.1.14"/>
+                                <code code="30954-2" codeSystem="2.16.840.1.113883.6.1"/>
+                                <title>Results</title>
+                                <text>
+                                    <table>
+                                        <tbody>
+                                            <tr>
+                                                <th>Test</th>
+                                                <th>Date</th>
+                                                <th>Result</th>
+                                                <th>Source</th>
+                                            </tr>
+                                            <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Results/a:Result">
+                                                <tr>
+                                                    <xsl:attribute name="id">
+                                                        <xsl:value-of select="a:CCRDataObjectID"/>
+                                                    </xsl:attribute>
+                                                    <td>
+                                                        <xsl:value-of select="a:Description/a:Text"/>
+                                                    </td>
+                                                    <td>
+                                                        <xsl:call-template name="date:format-date">
+                                                            <xsl:with-param name="date-time" select="a:DateTime/a:ExactDateTime"/>
+                                                        </xsl:call-template>
+                                                    </td>
+                                                    <td>
+                                                        <xsl:for-each select="a:Test[a:TestResult/a:Value!='']">
+                                                            <div>
+                                                                <xsl:attribute name="id">
+                                                                    <xsl:value-of select="a:CCRDataObjectID"/>
+                                                                </xsl:attribute>
+
+                                                                <xsl:value-of select="a:Description/a:Text"/>
+                                                                <xsl:text xml:space="preserve"> </xsl:text>
+                                                                <xsl:value-of select="a:TestResult/a:Value"/>
+                                                                <xsl:text xml:space="preserve"> </xsl:text>
+                                                                <xsl:value-of select="a:TestResult/a:Units/a:Unit"/>
+                                                                <xsl:text xml:space="preserve"> </xsl:text>
+                                                                <xsl:value-of select="a:Flag/a:Text"/>
+                                                                <br/>
+                                                            </div>
+                                                        </xsl:for-each>
+                                                        <xsl:for-each select="a:Test[a:TestResult/a:Description/a:Text!='']">
+                                                            <div>
+                                                                <xsl:attribute name="id">
+                                                                    <xsl:value-of select="a:CCRDataObjectID"/>
+                                                                </xsl:attribute>
+
+                                                                <xsl:value-of select="a:Description/a:Text"/>
+                                                                <xsl:text xml:space="preserve"> </xsl:text>
+                                                                <xsl:value-of select="a:TestResult/a:Description/a:Text" disable-output-escaping="yes"/>
+                                                                <xsl:text xml:space="preserve"> </xsl:text>
+                                                                <xsl:value-of select="a:Flag/a:Text"/>
+                                                                <br/>
+                                                            </div>
+                                                        </xsl:for-each>
+                                                    </td>
+                                                    <td>
+                                                        <xsl:call-template name="actorName">
+                                                            <xsl:with-param name="objID" select="a:Source/a:Actor/a:ActorID"/>
+                                                        </xsl:call-template>
+                                                    </td>
+                                                </tr>
+                                            </xsl:for-each>
+                                        </tbody>
+                                    </table>
+                                </text>
+                                <xsl:for-each select="/a:ContinuityOfCareRecord/a:Body/a:Results/a:Result">
+                                    <entry typeCode="DRIV">
+                                        <xsl:variable name="testDate" select="a:DateTime"/>
+
+                                        <xsl:choose>
+                                            <xsl:when test="count(a:Test)>1">
+                                                <organizer classCode="BATTERY" moodCode="EVN">
+                                                    <templateId root="2.16.840.1.113883.10.20.1.32"/>
+                                                    <!--Result organizer template -->
+
+                                                    <!-- <id> -->
+                                                    <xsl:call-template name="ccdID">
+                                                        <xsl:with-param name="ccrObjectID" select="a:CCRDataObjectID"/>
+                                                    </xsl:call-template>
+
+                                                    <!-- <code> -->
+                                                    <xsl:call-template name="ccdCodedValue">
+                                                        <xsl:with-param name="ccrCodedDescription" select="a:Description"/>
+                                                        <xsl:with-param name="nodeName" select="'code'"/>
+                                                    </xsl:call-template>
+
+                                                    <statusCode code="completed"/>
+
+                                                    <!-- <effectiveTime> -->
+                                                    <xsl:call-template name="ccdDateTime">
+                                                        <xsl:with-param name="dt" select="$testDate"/>
+                                                    </xsl:call-template>
+
+                                                    <xsl:call-template name="ccdPerformer">
+                                                        <xsl:with-param name="ccrActorReference" select="a:Source/a:Actor"/>
+                                                    </xsl:call-template>
+
+                                                    <xsl:for-each select="a:Test">
+                                                        <xsl:call-template name="ccdObservation">
+                                                            <xsl:with-param name="ccrTestNode" select="."/>
+                                                            <xsl:with-param name="testDate" select="$testDate"/>
+                                                        </xsl:call-template>
+                                                    </xsl:for-each>
+
+                                                </organizer>
+
+                                            </xsl:when>
+                                            <xsl:otherwise>
+                                                <xsl:call-template name="ccdObservation">
+                                                    <xsl:with-param name="ccrTestNode" select="a:Test[1]"/>
+                                                    <xsl:with-param name="testDate" select="$testDate"/>
+                                                </xsl:call-template>
+                                            </xsl:otherwise>
+                                        </xsl:choose>
+                                    </entry>
+                                </xsl:for-each>
+                            </section>
+                        </component>
+                    </xsl:if>
 </section>
 </component>
