This commit is contained in:
2025-02-26 14:49:25 +07:00
commit 1c1d9c4474
6403 changed files with 1953774 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
*** These modified files were found in JOE when it aborted on Mon Nov 20 20:00:25 2017
*** JOE was aborted because the terminal closed
*** File '(Unnamed)'
INSTALL4J_JAVA_PREFIX
44
*** File '(Unnamed)'
/etc/init.d/mcservice
/etc/init.d/mcservice
/etc/init.d/mcservice
/etc/profile
/etc/profile
/etc/profile
mcservice
/etc/apparmor.d/usr.sbin.mysqld
orm2dcm.xsl
orm2dcm.xsl
orm2dcm.xsl
*** File '* Startup Log *'
Processing '/etc/joe/joerc'...
Finished processing /etc/joe/joerc

View File

@@ -0,0 +1,229 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:include href="common.xsl"/>
<!-- root -->
<xsl:template match="/hl7">
<dataset>
<attr tag="00080005" vr="CS">ISO_IR 100</attr>
<xsl:apply-templates select="PID"/>
<xsl:apply-templates select="PV1"/>
<xsl:apply-templates select="AL1"/>
<xsl:apply-templates select="ORC[1]"/>
<xsl:apply-templates select="OBR[1]"/>
<!-- Scheduled Procedure Step Sequence -->
<attr tag="00400100" vr="SQ">
<xsl:apply-templates select="ORC" mode="sps"/>
</attr>
</dataset>
</xsl:template>
<!-- PV1 -->
<xsl:template match="PV1">
<!-- HL7:Assigned Patient Location.1 -> DICOM:Requesting Service -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00321033'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="substring(field[3]/text(),1,64)"/>
</xsl:call-template>
<!-- HL7:Referring Doctor -> DICOM:Referring Physican Name -->
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'00080090'"/>
<xsl:with-param name="cn" select="field[7]"/>
</xsl:call-template>
<!-- HL7:Ordering Provider -> DICOM Requesting Physician -->
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'00321032'"/>
<xsl:with-param name="cn" select="field[8]"/>
</xsl:call-template>
<!-- HL7:Visit Number -> DICOM:Admission ID + Issuer -->
<xsl:call-template name="cx2attrs">
<xsl:with-param name="idtag" select="'00380010'"/>
<xsl:with-param name="istag" select="'00380011'"/>
<xsl:with-param name="cx" select="field[19]"/>
</xsl:call-template>
</xsl:template>
<!-- AL1 -->
<xsl:template match="AL1">
<!-- HL7:Allergy Code/Mnemonic/Description -> Medical Alerts + Contrast Allergies -->
<xsl:variable name="al1_3" select="string(field[3]/text())"/>
<xsl:choose>
<xsl:when test="$al1_3 = '&quot;&quot;'">
<attr tag="00102000" vr="LO"/>
<attr tag="00102110" vr="LO"/>
</xsl:when>
<xsl:when test="$al1_3">
<attr tag="00102000" vr="LO">
<xsl:value-of select="substring(substring-after($al1_3,'$'),1,64)"/>
</attr>
<attr tag="00102110" vr="LO">
<xsl:value-of select="substring(substring-before($al1_3,'$'),1,64)"/>
</attr>
</xsl:when>
</xsl:choose>
</xsl:template>
<!-- ORC[1] -->
<xsl:template match="ORC[1]">
<!-- HL7:Quantity/Timing -> DICOM:Requested Procedure Priority -->
<xsl:call-template name="procedurePriority">
<xsl:with-param name="priority" select="string(field[7]/component[5]/text())"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="procedurePriority">
<xsl:param name="priority"/>
<xsl:if test="normalize-space($priority)">
<attr tag="00401003" vr="CS">
<xsl:choose>
<xsl:when test="$priority = 'S'">STAT</xsl:when>
<xsl:when test="$priority = 'A' or $priority = 'P' or $priority = 'C' ">HIGH</xsl:when>
<xsl:when test="$priority = 'R'">ROUTINE</xsl:when>
<xsl:when test="$priority = 'T'">MEDIUM</xsl:when>
</xsl:choose>
</attr>
</xsl:if>
</xsl:template>
<!-- OBR[1] -->
<xsl:template match="OBR[1]">
<xsl:variable name="ordno" select="string(field[3]/text())"/>
<!-- HL7:Filler Order Number -> DICOM:Placer Order Number -->
<attr tag="00402016" vr="LO">
<xsl:value-of select="$ordno"/>
</attr>
<!-- HL7:Filler Order Number -> DICOM:Filler Order Number -->
<attr tag="00402017" vr="LO">
<xsl:value-of select="$ordno"/>
</attr>
<!-- HL7:Filler Order Number -> DICOM:Accession Number -->
<attr tag="00080050" vr="SH">
<xsl:value-of select="$ordno"/>
</attr>
<!-- Study Instance UID -> DICOM:Scheduled Procedure Step ID -->
<attr tag="00400009" vr="SH">
<xsl:value-of select="$ordno"/>
</attr>
<!-- HL7:Danger Code -> DICOM:Patient State -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00380500'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="substring(field[12]/text(),1,64)"/>
</xsl:call-template>
<!-- HL7:Relevant Clinical Info -> DICOM:Reason for the Requested Procedure + Admitting Diagnoses Description -->
<xsl:variable name="obr13" select="normalize-space(field[13])"/>
<xsl:choose>
<xsl:when test="$obr13 = '&quot;&quot;'">
<attr tag="00081080" vr="LO"/>
<attr tag="00401002" vr="LO"/>
</xsl:when>
<xsl:when test="$obr13">
<attr tag="00081080" vr="LO">
<xsl:value-of select="substring(substring-after(substring-after(substring-after($obr13,'$'),'$'),'$'),1,64)"/>
</attr>
<attr tag="00401002" vr="LO">
<xsl:value-of select="substring(substring-before(substring-after($obr13,'$'),'$'),1,64)"/>
</attr>
</xsl:when>
</xsl:choose>
<!-- HL7:Transportation Mode -> DICOM:Patient Transport Arrangements -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00401004'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="substring(field[30]/text(),1,64)"/>
</xsl:call-template>
</xsl:template>
<!-- ORC - sps -->
<xsl:template match="ORC" mode="sps">
<item>
<xsl:apply-templates select="following-sibling::OBR[1]" mode="sps"/>
</item>
</xsl:template>
<!-- OBR - sps -->
<xsl:template match="OBR" mode="sps">
<!-- HL7:Results Rpt/Status Chng - Date/Time -> DICOM:Scheduled Procedure Step Start Date/Time -->
<xsl:variable name="obr36" select="normalize-space(field[36]/text())"/>
<xsl:variable name="dt">
<xsl:choose>
<xsl:when test="$obr36">
<xsl:value-of select="$obr36"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="normalize-space(field[22]/text())"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="string-length($dt) >= 8">
<xsl:call-template name="attrDATM">
<xsl:with-param name="datag" select="'00400002'"/>
<xsl:with-param name="tmtag" select="'00400003'"/>
<xsl:with-param name="val">
<xsl:value-of select="$dt"/>
<xsl:if test="string-length($dt) &lt; 10">00</xsl:if>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
<!-- HL7:Filler Order Number -> DICOM:Study Instance UID -->
<xsl:variable name="accnr" select="string(field[3]/text())"/>
<attr tag="0020000D" vr="UI">
<xsl:value-of select="'1.2.40.0.13.0.11.257300.4.1'"/>
<xsl:value-of select="$accnr"/>
<xsl:value-of select="'.54321.'"/>
<xsl:value-of select="$obr36"/>
<xsl:value-of select="'00'"/>
</attr>
<!-- HL7:Entering Device -> DICOM:Scheduled Station Name -->
<xsl:call-template name="attr">
<xsl:with-param name="tag">00400010</xsl:with-param>
<xsl:with-param name="vr">SH</xsl:with-param>
<xsl:with-param name="val" select="substring(field[19]/text(),1,16)"/>
</xsl:call-template>
<!-- HL7:Entering Device -> DICOM:Modality -->
<xsl:call-template name="attr">
<xsl:with-param name="tag">00080060</xsl:with-param>
<xsl:with-param name="vr">CS</xsl:with-param>
<xsl:with-param name="val" select="substring(field[19]/component/text(),1,16)"/>
</xsl:call-template>
<!-- Study Instance UID -> DICOM:Requested Procedure -->
<!-- Study Instance UID -> DICOM:Scheduled Procedure Step ID -->
<attr tag="00400009" vr="SH">
<xsl:value-of select="$accnr"/>
</attr>
<attr tag="00401001" vr="SH">
<xsl:value-of select="$accnr"/>
</attr>
<!-- HL7:Universal Service Identifier.2 -> DICOM:Requested Procedure Description -->
<xsl:variable name="desc" select="substring(field[4]/component/text(),1,64)"/>
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00321060'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="$desc"/>
</xsl:call-template>
<!-- HL7:Universal Service Identifier -> DICOM:Requested Procedure Code -->
<xsl:call-template name="codeItem">
<xsl:with-param name="sqtag" select="'00321064'"/>
<xsl:with-param name="code" select="string(field[4]/text())"/>
<xsl:with-param name="scheme" select="'77BOSS'"/>
<xsl:with-param name="meaning" select="$desc"/>
</xsl:call-template>
<!-- HL7:Universal Service Identifier.2 -> DICOM:Scheduled Procedure Step Description -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00400007'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="$desc"/>
</xsl:call-template>
<!-- HL7:Universal Service Identifier -> DICOM:Scheduled Protocol Code -->
<xsl:call-template name="codeItem">
<xsl:with-param name="sqtag" select="'00400008'"/>
<xsl:with-param name="code" select="string(field[4]/text())"/>
<xsl:with-param name="scheme" select="'77BOSS'"/>
<xsl:with-param name="meaning" select="$desc"/>
</xsl:call-template>
<!-- HL7:Technician -> Scheduled Performing Physican Name -->
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'00400006'"/>
<xsl:with-param name="cn" select="field[34]"/>
<xsl:with-param name="cn26" select="field[34]/subcomponent"/>
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,240 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:variable name="ssn-issuer">SSN</xsl:variable>
<xsl:template name="attr">
<xsl:param name="tag"/>
<xsl:param name="vr"/>
<xsl:param name="val"/>
<xsl:if test="normalize-space($val)">
<attr tag="{$tag}" vr="{$vr}">
<xsl:call-template name="maskQuotes">
<xsl:with-param name="str" select="$val"/>
</xsl:call-template>
</attr>
</xsl:if>
</xsl:template>
<xsl:template name="maskQuotes">
<xsl:param name="str"/>
<xsl:if test="$str != '&quot;&quot;'">
<xsl:value-of select="$str"/>
</xsl:if>
</xsl:template>
<xsl:template name="cx2attrs">
<xsl:param name="idtag"/>
<xsl:param name="istag"/>
<xsl:param name="cx"/>
<attr tag="{$idtag}" vr="LO">
<xsl:value-of select="string($cx/text())"/>
</attr>
<attr tag="{$istag}" vr="LO">
<xsl:value-of select="string($cx/component[3]/text())"/>
<xsl:if test="$cx/component[3]/subcomponent[1]" >
<xsl:text>&amp;</xsl:text><xsl:value-of select="$cx/component[3]/subcomponent[1]"/>
<xsl:text>&amp;</xsl:text><xsl:value-of select="$cx/component[3]/subcomponent[2]"/>
</xsl:if>
</attr>
</xsl:template>
<xsl:template name="ei2attr">
<xsl:param name="tag"/>
<xsl:param name="ei"/>
<attr tag="{$tag}" vr="LO">
<xsl:value-of select="string($ei/text())"/>
<xsl:text>^</xsl:text>
<xsl:value-of select="string($ei/component[1]/text())"/>
</attr>
</xsl:template>
<xsl:template name="attrDA">
<xsl:param name="tag"/>
<xsl:param name="val"/>
<xsl:variable name="str" select="normalize-space($val)"/>
<xsl:if test="$str">
<attr tag="{$tag}" vr="DA">
<xsl:if test="$str != '&quot;&quot;'">
<xsl:value-of select="substring($str,1,8)"/>
</xsl:if>
</attr>
</xsl:if>
</xsl:template>
<xsl:template name="attrDATM">
<xsl:param name="datag"/>
<xsl:param name="tmtag"/>
<xsl:param name="val"/>
<xsl:variable name="str" select="normalize-space($val)"/>
<xsl:if test="$str">
<attr tag="{$datag}" vr="DA">
<xsl:if test="$str != '&quot;&quot;'">
<xsl:value-of select="substring($str,1,8)"/>
</xsl:if>
</attr>
<attr tag="{$tmtag}" vr="TM">
<xsl:if test="$str != '&quot;&quot;'">
<xsl:variable name="tm" select="substring($str,9)"/>
<!-- Skip Time Zone -->
<xsl:variable name="tm_plus" select="substring-before($tm,'+')"/>
<xsl:variable name="tm_minus" select="substring-before($tm,'-')"/>
<xsl:choose>
<xsl:when test="$tm_plus">
<xsl:value-of select="$tm_plus"/>
</xsl:when>
<xsl:when test="$tm_minus">
<xsl:value-of select="$tm_minus"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$tm"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</attr>
</xsl:if>
</xsl:template>
<xsl:template name="xpn2pnAttr">
<xsl:param name="tag"/>
<xsl:param name="xpn"/>
<xsl:param name="xpn25" select="$xpn/component"/>
<xsl:call-template name="pnAttr">
<xsl:with-param name="tag" select="$tag"/>
<xsl:with-param name="val" select="string($xpn/text())"/>
<xsl:with-param name="fn" select="string($xpn/text())"/>
<xsl:with-param name="gn" select="string($xpn25[1]/text())"/>
<xsl:with-param name="mn" select="string($xpn25[2]/text())"/>
<xsl:with-param name="ns" select="string($xpn25[3]/text())"/>
<xsl:with-param name="np" select="string($xpn25[4]/text())"/>
<xsl:with-param name="deg" select="string($xpn25[5]/text())"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="cn2pnAttr">
<xsl:param name="tag"/>
<xsl:param name="cn"/>
<xsl:param name="cn26" select="$cn/component"/>
<xsl:call-template name="pnAttr">
<xsl:with-param name="tag" select="$tag"/>
<xsl:with-param name="val" select="string($cn/text())"/>
<xsl:with-param name="fn" select="string($cn26[1]/text())"/>
<xsl:with-param name="gn" select="string($cn26[2]/text())"/>
<xsl:with-param name="mn" select="string($cn26[3]/text())"/>
<xsl:with-param name="ns" select="string($cn26[4]/text())"/>
<xsl:with-param name="np" select="string($cn26[5]/text())"/>
<xsl:with-param name="deg" select="string($cn26[6]/text())"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="pnAttr">
<xsl:param name="tag"/>
<xsl:param name="val"/>
<xsl:param name="fn"/>
<xsl:param name="gn"/>
<xsl:param name="mn"/>
<xsl:param name="np"/>
<xsl:param name="ns"/>
<xsl:param name="deg"/>
<xsl:if test="$val">
<attr tag="{$tag}" vr="PN">
<xsl:if test="$val != '&quot;&quot;'">
<xsl:call-template name="maskQuotes">
<xsl:with-param name="str" select="$fn"/>
</xsl:call-template>
<xsl:text>^</xsl:text>
<xsl:call-template name="maskQuotes">
<xsl:with-param name="str" select="$gn"/>
</xsl:call-template>
<xsl:text>^</xsl:text>
<xsl:call-template name="maskQuotes">
<xsl:with-param name="str" select="$mn"/>
</xsl:call-template>
<xsl:text>^</xsl:text>
<xsl:call-template name="maskQuotes">
<xsl:with-param name="str" select="$np"/>
</xsl:call-template>
<xsl:text>^</xsl:text>
<xsl:choose>
<xsl:when test="$ns and $ns != '&quot;&quot;'">
<xsl:value-of select="$ns"/>
<xsl:if test="$deg and $deg != '&quot;&quot;'">
<xsl:text> </xsl:text><xsl:value-of select="$deg"/>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="maskQuotes">
<xsl:with-param name="str" select="$deg"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</attr>
</xsl:if>
</xsl:template>
<xsl:template name="codeItem">
<xsl:param name="sqtag"/>
<xsl:param name="code"/>
<xsl:param name="scheme"/>
<xsl:param name="meaning"/>
<xsl:if test="normalize-space($code)">
<attr tag="{$sqtag}" vr="SQ">
<item>
<!-- Code Value -->
<attr tag="00080100" vr="SH">
<xsl:value-of select="$code"/>
</attr>
<!-- Coding Scheme Designator -->
<attr tag="00080102" vr="SH">
<xsl:value-of select="$scheme"/>
</attr>
<!-- Code Meaning -->
<attr tag="00080104" vr="LO">
<xsl:value-of select="$meaning"/>
</attr>
</item>
</attr>
</xsl:if>
</xsl:template>
<xsl:template match="PID">
<!-- Patient Name -->
<xsl:call-template name="xpn2pnAttr">
<xsl:with-param name="tag" select="'00100010'"/>
<xsl:with-param name="xpn" select="field[5]"/>
</xsl:call-template>
<!-- Patient ID -->
<xsl:call-template name="cx2attrs">
<xsl:with-param name="idtag" select="'00100020'"/>
<xsl:with-param name="istag" select="'00100021'"/>
<xsl:with-param name="cx" select="field[3]"/>
</xsl:call-template>
<!-- Patient Birth Date -->
<xsl:call-template name="attrDA">
<xsl:with-param name="tag" select="'00100030'"/>
<xsl:with-param name="val" select="string(field[7]/text())"/>
</xsl:call-template>
<!-- Patient Sex -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00100040'"/>
<xsl:with-param name="vr" select="'CS'"/>
<xsl:with-param name="val" select="string(field[8]/text())"/>
</xsl:call-template>
<!-- Other Patient Names -->
<!-- TODO: extend for multiple Other Patient Names -->
<xsl:call-template name="xpn2pnAttr">
<xsl:with-param name="tag" select="'00101001'"/>
<xsl:with-param name="xpn" select="field[9]"/>
</xsl:call-template>
<!-- Patient's Mother's Birth Name -->
<xsl:call-template name="xpn2pnAttr">
<xsl:with-param name="tag" select="'00101060'"/>
<xsl:with-param name="xpn" select="field[6]"/>
</xsl:call-template>
<!-- Map SSN Number to Other Patient ID Sequence Item -->
<xsl:variable name="ssn" select="field[19]"/>
<xsl:if test="normalize-space($ssn)">
<attr tag="00101002" vr="SQ">
<item>
<!-- Patient ID -->
<attr tag="00100020" vr="LO">
<xsl:value-of select="$ssn"/>
</attr>
<!-- Issuer Of Patient ID -->
<attr tag="00100021" vr="LO">
<xsl:value-of select="$ssn-issuer"/>
</attr>
</item>
</attr>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,198 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" encoding="ISO-8859-1" />
<xsl:param name="messageControlID"></xsl:param>
<xsl:param name="messageDateTime"></xsl:param>
<xsl:param name="receivingApplication"></xsl:param>
<xsl:param name="receivingFacility"></xsl:param>
<xsl:param name="sendingApplication"></xsl:param>
<xsl:param name="sendingFacility"></xsl:param>
<xsl:template name="MSH">
<xsl:param name="msgType"/>
<xsl:text>MSH|^~\&amp;|</xsl:text>
<xsl:value-of select="$sendingApplication"/><xsl:text>|</xsl:text>
<xsl:value-of select="$sendingFacility"/><xsl:text>|</xsl:text>
<xsl:value-of select="$receivingApplication"/><xsl:text>|</xsl:text>
<xsl:value-of select="$receivingFacility"/><xsl:text>|</xsl:text>
<xsl:value-of select="$messageDateTime"/><xsl:text>||</xsl:text>
<xsl:value-of select="$msgType"/><xsl:text>|</xsl:text>
<xsl:value-of select="$messageControlID"/><xsl:text>|P|2.3|||AL</xsl:text>
<xsl:text>&#xd;</xsl:text>
</xsl:template>
<xsl:template match="dataset" mode="dcm2PID">
<xsl:text>PID|||</xsl:text>
<xsl:value-of select="attr[@tag='00100020']" /> <!-- PatientID -->
<xsl:if test="attr[@tag='00100021']">
<xsl:text>^^^</xsl:text><xsl:value-of select="attr[@tag='00100021']" /> <!-- Issuer of patient ID -->
</xsl:if>
<xsl:text>||</xsl:text>
<xsl:value-of select="attr[@tag='00100010']" /> <!-- PatientName (is already in format fn^gn^mn^suffix^prefix^deg -->
<xsl:text>|</xsl:text>
<xsl:value-of select="attr[@tag='00101060']" /> <!-- Mothers Birth Name -->
<xsl:text>|</xsl:text>
<xsl:value-of select="attr[@tag='00100030']" /> <!-- Patient Birth Date -->
<xsl:text>|</xsl:text>
<xsl:value-of select="attr[@tag='00100040']" /> <!-- Patient Sex -->
<xsl:text>|||||||||||||||||||||</xsl:text>
<xsl:text>&#xd;</xsl:text>
</xsl:template>
<xsl:template match="dataset" mode="dcm2PV1">
<xsl:param name="patientClass" select="'I'"/> <!--required! one of B (OBSTETRICS), E (EMERGENCY), I (INPATIENT), O (OUTPATIENT), P(PREADMIT), R (RECURRING) -->
<xsl:param name="ambulatoryStatus" select="''"/> <!-- Default is empty -->
<xsl:param name="admitDateTime" select="''"/> <!-- Default is empty -->
<xsl:text>PV1||</xsl:text>
<xsl:value-of select="$patientClass" />
<xsl:text>||||||</xsl:text> <!-- 3-7 -->
<xsl:if test="attr[@tag='00080090']">
<xsl:text>^</xsl:text><xsl:value-of select="attr[@tag='00080090']" /> <!-- Referring Doctor = Referring Physican Name ; CN (id^fn^gn^..)-->
</xsl:if>
<xsl:text>||</xsl:text>
<xsl:value-of select="attr[@tag='00080060']" /> <!-- Hospital Service = Modality -->
<xsl:text>|||||</xsl:text> <!-- 11-14 -->
<xsl:value-of select="$ambulatoryStatus" />
<xsl:text>||||</xsl:text> <!-- 16-18 -->
<xsl:if test="attr[@tag='00380010']">
<xsl:value-of select="attr[@tag='00380010']"/>
<xsl:if test="attr[@tag='00380011']">
<xsl:text>^^^</xsl:text><xsl:value-of select="attr[@tag='00380011']"/> <!-- Visit Number =Admission ID, Issuer -->
</xsl:if>
</xsl:if>
<xsl:text>|||||||||||||||||||||||||</xsl:text> <!-- 20-43 -->
<xsl:value-of select="$admitDateTime" />
<xsl:text>|||||||</xsl:text> <!-- 46-50 -->
<xsl:text>&#xd;</xsl:text>
</xsl:template>
<xsl:template match="dataset" mode="dcm2ORC">
<xsl:param name="orderControl" select="'XO'"/> <!-- Default: XO .. Change Order Request -->
<xsl:param name="orderStatus" />
<xsl:param name="quantity_timing" />
<xsl:param name="transactionDT" />
<xsl:param name="orderingProvider" />
<xsl:param name="orderEffectiveDT" />
<xsl:param name="orderControlCodeReason" />
<xsl:param name="enteringOrganisation" />
<xsl:param name="enteringDevice" />
<xsl:param name="actionBy" />
<xsl:text>ORC|</xsl:text>
<xsl:value-of select="$orderControl" />
<xsl:text>|</xsl:text>
<xsl:value-of select="normalize-space(attr[@tag='00402016'])" /> <!-- Placer Order Number -->
<xsl:text>|</xsl:text>
<xsl:value-of select="normalize-space(attr[@tag='00402017'])" /> <!-- Filler Order Number -->
<xsl:text>||</xsl:text> <!-- 4 placer group number-->
<xsl:value-of select="$orderStatus" />
<xsl:text>||</xsl:text> <!-- 6 response Flag -->
<xsl:value-of select="$quantity_timing" />
<xsl:text>||</xsl:text> <!-- 8 Parent -->
<xsl:value-of select="$transactionDT" />
<xsl:text>|||</xsl:text> <!-- 10-11 -->
<xsl:value-of select="$orderingProvider" />
<xsl:text>|||</xsl:text> <!-- 13-14 -->
<xsl:value-of select="$orderEffectiveDT" />
<xsl:text>|</xsl:text>
<xsl:value-of select="$orderControlCodeReason" />
<xsl:text>|</xsl:text>
<xsl:value-of select="$enteringOrganisation" />
<xsl:text>|</xsl:text>
<xsl:value-of select="$enteringDevice" />
<xsl:text>|</xsl:text>
<xsl:value-of select="$actionBy" />
<xsl:text>&#xd;</xsl:text>
</xsl:template>
<xsl:template match="dataset" mode="dcm2OBR">
<xsl:param name="universalServiceId" />
<xsl:param name="priority" />
<xsl:param name="observationDT" />
<xsl:param name="observationEndDT" />
<xsl:param name="dangerCode" />
<xsl:param name="clinicalInfo" />
<xsl:param name="orderingProvider" />
<xsl:param name="placerField1" />
<xsl:param name="placerField2" />
<xsl:param name="fillerField1" />
<xsl:param name="fillerField2" />
<xsl:param name="statusChgDT" />
<xsl:param name="diagnService" />
<xsl:param name="transportationMode" />
<xsl:param name="technician" />
<xsl:param name="requestedProcedureCode" />
<xsl:text>OBR||</xsl:text>
<xsl:value-of select="normalize-space(attr[@tag='00402016'])" /> <!-- Placer Order Number -->
<xsl:text>|</xsl:text>
<xsl:value-of select="normalize-space(attr[@tag='00402017'])" /> <!-- Filler Order Number -->
<xsl:text>|</xsl:text>
<xsl:value-of select="$universalServiceId" />
<xsl:text>|</xsl:text>
<xsl:value-of select="$priority" />
<xsl:text>||</xsl:text> <!-- 6 Requested Date/Time (not used) -->
<xsl:value-of select="$observationDT" />
<xsl:text>|</xsl:text>
<xsl:value-of select="$observationEndDT" />
<xsl:text>||||</xsl:text> <!-- 9-11 -->
<xsl:value-of select="$dangerCode" />
<xsl:text>|</xsl:text>
<xsl:value-of select="$clinicalInfo" />
<xsl:text>|||</xsl:text> <!-- 14-15 -->
<xsl:value-of select="$orderingProvider" />
<xsl:text>||</xsl:text> <!-- 17 -->
<xsl:value-of select="normalize-space($placerField1)" />
<xsl:text>|</xsl:text>
<xsl:value-of select="normalize-space($placerField2)" />
<xsl:text>|</xsl:text>
<xsl:value-of select="normalize-space($fillerField1)" />
<xsl:text>|</xsl:text>
<xsl:value-of select="normalize-space($fillerField2)" />
<xsl:text>|</xsl:text>
<xsl:value-of select="$statusChgDT" />
<xsl:text>||</xsl:text> <!-- 23 -->
<xsl:value-of select="$diagnService" />
<xsl:text>||||||</xsl:text> <!-- 25-29 -->
<xsl:value-of select="$transportationMode" />
<xsl:text>||||</xsl:text> <!-- 31-33 -->
<xsl:value-of select="$technician" />
<xsl:text>||||||</xsl:text> <!-- 35-39 -->
<xsl:value-of select="$requestedProcedureCode" />
<xsl:text>&#xd;</xsl:text>
</xsl:template>
<xsl:template match="dataset" mode="dcm2ZDS">
<xsl:param name="applicationId"/>
<xsl:text>ZDS|</xsl:text>
<xsl:value-of select="attr[@tag='0020000D']" /> <!-- Study Instance UID -->
<xsl:text>^</xsl:text>
<xsl:value-of select="$applicationId" />
<xsl:text>^Application^DICOM</xsl:text>
</xsl:template>
<xsl:template name="attrs2cx">
<xsl:param name="id"/>
<xsl:param name="issuer"/>
<xsl:value-of select="$id"/>
<xsl:if test="$issuer">
<xsl:text>^^^</xsl:text><xsl:value-of select="$issuer"/>
</xsl:if>
</xsl:template>
<xsl:template name="codeOrDescr">
<xsl:param name="descrTag"/>
<xsl:param name="codeTag"/>
<xsl:choose>
<xsl:when test="$codeTag">
<xsl:value-of select="$codeTag/item/attr[@tag='00080100']"/><xsl:text>^</xsl:text>
<xsl:value-of select="$codeTag/item//attr[@tag='00080104']"/><xsl:text>^</xsl:text>
<xsl:value-of select="$codeTag/item/attr[@tag='00080102']"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$descrTag"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:variable name="configured_issuer">MYISSUER</xsl:variable>
<xsl:variable name="hl7_pid_assig_auth">
<xsl:value-of select="string(/hl7/PID/field[3]/component[3]/text())"/>
</xsl:variable>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/hl7/PID/field[3]/component[3]">
<xsl:choose>
<xsl:when test="string-length($hl7_pid_assig_auth) > 0">
<component>
<xsl:value-of select="$hl7_pid_assig_auth"/>
</component>
</xsl:when>
<xsl:otherwise>
<component>
<xsl:value-of select="$configured_issuer"/>
</component>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,36 @@
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="no"/>
<!-- !!! WARNING !!!
Erroneous transformations may result in unintended
changes of original data, including wrong patient
assignments.
-->
<!--
$Revision: 985 $
$Date: 2012-04-16 17:14:59 +0200 (Mon, 16 Apr 2012) $
$Author: awpek $
$LastChangedBy: awpek $
$LastChangedDate: 2012-04-16 17:14:59 +0200 (Mon, 16 Apr 2012) $
-->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/hl7/MSH/field[7]">
<field>ADT<component>A06</component></field>
</xsl:template>
<xsl:template match="/hl7/PID/field[3]">
<field><xsl:value-of select="text()" /><component/>
<component/>
<component><subcomponent>1.2.40.0.13.1.1.1.0.111.1.0.1</subcomponent>
<subcomponent>ISO</subcomponent>
</component>
</field>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text"/>
<xsl:template match="/hl7">
<xsl:choose>
<xsl:when test="PID">
<xsl:text>hl7cmd </xsl:text>
<xsl:value-of select="PID/field[3]/text()"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>NONE</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:include href="common.xsl"/>
<xsl:template match="/hl7">
<dataset>
<attr tag="00080005" vr="CS">ISO_IR 100</attr>
<attr tag="00080052" vr="CS">SERIES</attr>
<!-- Patient ID -->
<xsl:call-template name="cx2attrs">
<xsl:with-param name="idtag" select="'00100020'"/>
<xsl:with-param name="istag" select="'00100021'"/>
<xsl:with-param name="cx" select="PID/field[3]"/>
</xsl:call-template>
<attr tag="0020000D" vr="UI"/>
<attr tag="0020000E" vr="UI"/>
<attr tag="00080020" vr="DA"/><!-- Study Date -->
<attr tag="00080030" vr="TM"/><!-- Study Time -->
<attr tag="00080021" vr="DA"/><!-- Series Date -->
<attr tag="00080031" vr="TM"/><!-- Series Time -->
<attr tag="00080060" vr="CS"/><!-- Modality -->
</dataset>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text"/>
<xsl:param name="maxlen">64</xsl:param>
<xsl:template match="/hl7">
<xsl:apply-templates select="*"/>
</xsl:template>
<xsl:template match="*">
<xsl:apply-templates select="field">
<xsl:with-param name="seg" select="name()"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="field">
<xsl:param name="seg"/>
<xsl:if test="node()">
<xsl:text>
</xsl:text>
<xsl:value-of select="$seg"/>
<xsl:text>-</xsl:text>
<xsl:choose>
<xsl:when test="$seg = 'MSH'">
<xsl:value-of select="position()+2"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="position()"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>:</xsl:text>
<xsl:call-template name="prompt">
<xsl:with-param name="value" select="text()"/>
</xsl:call-template>
<xsl:apply-templates select="subcomponent"/>
<xsl:apply-templates select="component"/>
<xsl:apply-templates select="repeat"/>
</xsl:if>
</xsl:template>
<xsl:template match="repeat">
<xsl:text>~</xsl:text>
<xsl:call-template name="prompt">
<xsl:with-param name="value" select="text()"/>
</xsl:call-template>
<xsl:apply-templates select="subcomponent"/>
<xsl:apply-templates select="component"/>
</xsl:template>
<xsl:template match="component">
<xsl:text>^</xsl:text>
<xsl:call-template name="prompt">
<xsl:with-param name="value" select="text()"/>
</xsl:call-template>
<xsl:apply-templates select="subcomponent"/>
</xsl:template>
<xsl:template match="subcomponent">
<xsl:text>&amp;</xsl:text>
<xsl:call-template name="prompt">
<xsl:with-param name="value" select="text()"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="prompt">
<xsl:param name="value"/>
<xsl:value-of select="substring($value,1,$maxlen)"/>
<xsl:if test="string-length($value)&gt;$maxlen">
<xsl:text>[..]</xsl:text>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,396 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output indent="yes" method="xml" />
<xsl:template match="/hl7">
<dataset>
<xsl:call-template name="common-attrs" />
<xsl:apply-templates select="PID" />
<xsl:apply-templates select="OBR" />
<xsl:apply-templates select="TXA" />
<xsl:apply-templates select="OBX" />
</dataset>
</xsl:template>
<xsl:template name="common-attrs">
<!--Specific Character Set-->
<attr tag="00080005" vr="CS">ISO_IR 100</attr>
<!--SOP Class UID-->
<attr tag="00080016" vr="UI">1.2.840.10008.5.1.4.1.1.104.1</attr>
<!--Study Date-->
<attr tag="00080020" vr="DA" />
<!--Study Time-->
<attr tag="00080030" vr="TM" />
<!--Accession Number-->
<attr tag="00080050" vr="SH" />
<!--Modality-->
<attr tag="00080060" vr="CS">OT</attr>
<!--Conversion Type-->
<attr tag="00080064" vr="CS">SD</attr>
<!--Manufacturer-->
<attr tag="00080070" vr="LO" />
<!--Referring Physician's Name-->
<attr tag="00080090" vr="PN" />
<!--Study ID-->
<attr tag="00200010" vr="SH" />
<!--Series Number-->
<attr tag="00200011" vr="IS">1</attr>
<!--Instance Number-->
<attr tag="00200013" vr="IS">1</attr>
<!--Burned In Annotation-->
<attr tag="00280301" vr="CS">YES</attr>
<!--MIME Type of Encapsulated Document-->
<attr tag="00420012" vr="LO">application/pdf</attr>
</xsl:template>
<xsl:template match="PID">
<!--Patient's Name-->
<attr tag="00100010" vr="PN">
<xsl:call-template name="xpn2pn">
<xsl:with-param name="xpn" select="field[5]" />
</xsl:call-template>
</attr>
<!--Patient ID-->
<attr tag="00100020" vr="LO">
<xsl:value-of select="field[3]/text()" />
</attr>
<!--Issuer of Patient ID-->
<attr tag="00100021" vr="LO">
<xsl:value-of select="field[3]/component[3]" />
</attr>
<!--Patient's Birth Date-->
<attr tag="00100030" vr="DA">
<xsl:value-of select="field[7]/text()" />
</attr>
<!--Patient's Sex-->
<attr tag="00100040" vr="CS">
<xsl:value-of select="field[8]/text()" />
</attr>
</xsl:template>
<xsl:template match="OBR">
<!-- Acquisition DateTime -->
<attr tag="0008002A" vr="DT">
<xsl:value-of select="field[7]/text()" />
</attr>
<xsl:variable name="status" select="field[25]/text()" />
<!--Completion Flag-->
<xsl:choose>
<xsl:when test="$status='P'">
<attr tag="0040A491" vr="CS">PARTIAL</attr>
</xsl:when>
<xsl:when test="$status='F'">
<attr tag="0040A491" vr="CS">COMPLETE</attr>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="TXA">
<xsl:variable name="ts">
<xsl:choose>
<!--Transcription Date/Time -->
<xsl:when test="field[7]/text()">
<xsl:value-of select="field[7]/text()" />
</xsl:when>
<!--Origination date/time -->
<xsl:otherwise>
<xsl:value-of select="field[6]/text()" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Content Date -->
<attr tag="00080023" vr="DA">
<xsl:value-of select="substring($ts,1,8)" />
</attr>
<!-- Content Time -->
<attr tag="00080033" vr="TM">
<xsl:value-of select="substring($ts,9)" />
</attr>
<xsl:variable name="iuid" select="field[12]/text()" />
<!--SOP Instance UID-->
<attr tag="00080018" vr="UI">
<xsl:value-of select="$iuid" />
</attr>
<!--Series Instance UID-->
<attr tag="0020000E" vr="UI">
<xsl:value-of select="concat($iuid,'.1')" />
</attr>
<xsl:variable name="parent_iuid" select="field[13]/text()" />
<xsl:if test="$parent_iuid">
<!-- Predecessor Documents Sequence-->
<attr tag="0040A360" vr="SQ">
<item>
<!-- Referenced Series Sequence -->
<attr tag="00081115" vr="SQ">
<item>
<!-- Referenced SOP Sequence -->
<attr tag="00081199" vr="SQ">
<item>
<!-- Referenced SOP Class UID -->
<attr tag="00081150" vr="UI">1.2.840.10008.5.1.4.1.1.104.1</attr>
<!-- Referenced SOP Instance UID -->
<attr tag="00081155" vr="UI">
<xsl:value-of select="$parent_iuid" />
</attr>
</item>
</attr>
<!--Series Instance UID-->
<attr tag="0020000E" vr="UI">
<xsl:value-of select="concat($parent_iuid,'.1')" />
</attr>
</item>
</attr>
<!--Study Instance UID-->
<attr tag="0020000D" vr="UI">
<xsl:value-of select="../OBX[field[2]='HD']/field[5]/text()" />
</attr>
</item>
</attr>
</xsl:if>
<!--Verification Flag-->
<xsl:variable name="txa17" select="field[17]/text()" />
<attr tag="0040A493" vr="CS">
<xsl:choose>
<xsl:when test="$txa17='AU' or $txa17='LA'">VERIFIED</xsl:when>
<xsl:otherwise>UNVERIFIED</xsl:otherwise>
</xsl:choose>
</attr>
<xsl:if test="field[22]/component">
<!-- Verifying Observer Sequence -->
<attr tag="0040A073" vr="SQ">
<item>
<!-- Verification DateTime -->
<attr tag="0040A030" vr="DT">
<xsl:value-of select="field[22]/component[14]" />
</attr>
<!-- Verifying Observer Name -->
<attr tag="0040A075" vr="PN">
<xsl:call-template name="ppn2pn">
<xsl:with-param name="ppn" select="field[22]" />
</xsl:call-template>
</attr>
</item>
</attr>
</xsl:if>
</xsl:template>
<xsl:template match="OBX[field[2]='HD']">
<!--Study Instance UID-->
<attr tag="0020000D" vr="UI">
<xsl:value-of select="field[5]/text()" />
</attr>
</xsl:template>
<xsl:template match="OBX[field[5]/component[2]='PDF']">
<xsl:variable name="obsid" select="field[3]" />
<xsl:variable name="obsidcode" select="$obsid/text()" />
<xsl:variable name="obsidmeaning">
<xsl:choose>
<xsl:when test="$obsid/component[1]">
<xsl:value-of select="$obsid/component[1]" />
</xsl:when>
<xsl:otherwise><!-- missing ^ prefix -->
<xsl:value-of select="$obsidcode" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="obsidscheme" select="$obsid/component[2]" />
<xsl:choose>
<xsl:when test="$obsidscheme">
<xsl:call-template name="conceptName">
<xsl:with-param name="code" select="$obsidcode" />
<xsl:with-param name="scheme" select="$obsidscheme" />
<xsl:with-param name="meaning" select="$obsidmeaning" />
</xsl:call-template>
</xsl:when>
<!-- Encode Document Title -->
<xsl:when test="$obsidmeaning='Cardiac Catheterization Report'">
<xsl:call-template name="conceptName">
<xsl:with-param name="code">18745-0</xsl:with-param>
<xsl:with-param name="scheme">LN</xsl:with-param>
<xsl:with-param name="meaning">Cardiac Catheterization Report</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$obsidmeaning='Cardiac Electrophysiology Report'">
<xsl:call-template name="conceptName">
<xsl:with-param name="code">18750-0</xsl:with-param>
<xsl:with-param name="scheme">LN</xsl:with-param>
<xsl:with-param name="meaning">Cardiac Electrophysiology Report</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$obsidmeaning='CT Abdomen Report'">
<xsl:call-template name="conceptName">
<xsl:with-param name="code">11540-2</xsl:with-param>
<xsl:with-param name="scheme">LN</xsl:with-param>
<xsl:with-param name="meaning">CT Abdomen Report</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$obsidmeaning='CT Chest Report'">
<xsl:call-template name="conceptName">
<xsl:with-param name="code">11538-6</xsl:with-param>
<xsl:with-param name="scheme">LN</xsl:with-param>
<xsl:with-param name="meaning">CT Chest Report</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$obsidmeaning='CT Head Report'">
<xsl:call-template name="conceptName">
<xsl:with-param name="code">11539-4</xsl:with-param>
<xsl:with-param name="scheme">LN</xsl:with-param>
<xsl:with-param name="meaning">CT Head Report</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$obsidmeaning='CT Report'">
<xsl:call-template name="conceptName">
<xsl:with-param name="code">18747-6</xsl:with-param>
<xsl:with-param name="scheme">LN</xsl:with-param>
<xsl:with-param name="meaning">CT Report</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$obsidmeaning='Diagnostic Imaging Report'">
<xsl:call-template name="conceptName">
<xsl:with-param name="code">18748-4</xsl:with-param>
<xsl:with-param name="scheme">LN</xsl:with-param>
<xsl:with-param name="meaning">Diagnostic Imaging Report</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$obsidmeaning='Echocardiography Report'">
<xsl:call-template name="conceptName">
<xsl:with-param name="code">11522-0</xsl:with-param>
<xsl:with-param name="scheme">LN</xsl:with-param>
<xsl:with-param name="meaning">Echocardiography Report</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$obsidmeaning='ECG Report'">
<xsl:call-template name="conceptName">
<xsl:with-param name="code">11524-0</xsl:with-param>
<xsl:with-param name="scheme">LN</xsl:with-param>
<xsl:with-param name="meaning">ECG Report</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$obsidmeaning='Exercise Stress Test Report'">
<xsl:call-template name="conceptName">
<xsl:with-param name="code">18752-6</xsl:with-param>
<xsl:with-param name="scheme">LN</xsl:with-param>
<xsl:with-param name="meaning">Exercise Stress Test Report</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$obsidmeaning='Holter Study Report'">
<xsl:call-template name="conceptName">
<xsl:with-param name="code">18754-2</xsl:with-param>
<xsl:with-param name="scheme">LN</xsl:with-param>
<xsl:with-param name="meaning">Holter Study Report</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$obsidmeaning='Ultrasound Report'">
<xsl:call-template name="conceptName">
<xsl:with-param name="code">18760-9</xsl:with-param>
<xsl:with-param name="scheme">LN</xsl:with-param>
<xsl:with-param name="meaning">Ultrasound Report</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$obsidmeaning='MRI Head Report'">
<xsl:call-template name="conceptName">
<xsl:with-param name="code">11541-0</xsl:with-param>
<xsl:with-param name="scheme">LN</xsl:with-param>
<xsl:with-param name="meaning">MRI Head Report</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$obsidmeaning='MRI Report'">
<xsl:call-template name="conceptName">
<xsl:with-param name="code">18755-9</xsl:with-param>
<xsl:with-param name="scheme">LN</xsl:with-param>
<xsl:with-param name="meaning">MRI Report</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$obsidmeaning='MRI Spine Report'">
<xsl:call-template name="conceptName">
<xsl:with-param name="code">18756-7</xsl:with-param>
<xsl:with-param name="scheme">LN</xsl:with-param>
<xsl:with-param name="meaning">MRI Spine Report</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$obsidmeaning='Nuclear Medicine Report'">
<xsl:call-template name="conceptName">
<xsl:with-param name="code">18757-5</xsl:with-param>
<xsl:with-param name="scheme">LN</xsl:with-param>
<xsl:with-param name="meaning">Nuclear Medicine Report</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$obsidmeaning='Ultrasound Obstetric and Gyn Report'">
<xsl:call-template name="conceptName">
<xsl:with-param name="code">11525-3</xsl:with-param>
<xsl:with-param name="scheme">LN</xsl:with-param>
<xsl:with-param name="meaning">Ultrasound Obstetric and Gyn Report</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$obsidmeaning='PET Scan Report'">
<xsl:call-template name="conceptName">
<xsl:with-param name="code">18758-3</xsl:with-param>
<xsl:with-param name="scheme">LN</xsl:with-param>
<xsl:with-param name="meaning">PET Scan Report</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$obsidmeaning='Radiology Report'">
<xsl:call-template name="conceptName">
<xsl:with-param name="code">11528-7</xsl:with-param>
<xsl:with-param name="scheme">LN</xsl:with-param>
<xsl:with-param name="meaning">Radiology Report</xsl:with-param>
</xsl:call-template>
</xsl:when>
<!-- fallback to general Diagnostic Imaging Report -->
<xsl:otherwise>
<xsl:call-template name="conceptName">
<xsl:with-param name="code">18748-4</xsl:with-param>
<xsl:with-param name="scheme">LN</xsl:with-param>
<xsl:with-param name="meaning">Diagnostic Imaging Report</xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<!--Document Title-->
<attr tag="00420010" vr="ST">
<xsl:value-of select="$obsidmeaning" />
</attr>
</xsl:template>
<xsl:template name="conceptName">
<xsl:param name="code" />
<xsl:param name="scheme" />
<xsl:param name="meaning" />
<!--Concept Name Code Sequence-->
<attr tag="0040A043" vr="SQ">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">
<xsl:value-of select="$code" />
</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">
<xsl:value-of select="$scheme" />
</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">
<xsl:value-of select="$meaning" />
</attr>
</item>
</attr>
</xsl:template>
<xsl:template name="xpn2pn">
<xsl:param name="xpn" />
<xsl:param name="xpn25" select="$xpn/component" />
<xsl:value-of select="$xpn/text()" />
<xsl:text>^</xsl:text>
<xsl:value-of select="$xpn25[1]" />
<xsl:text>^</xsl:text>
<xsl:value-of select="$xpn25[2]" />
<xsl:text>^</xsl:text>
<xsl:value-of select="$xpn25[4]" />
<xsl:text>^</xsl:text>
<xsl:value-of select="$xpn25[3]" />
</xsl:template>
<xsl:template name="ppn2pn">
<xsl:param name="ppn" />
<xsl:param name="ppn26" select="$ppn/component" />
<xsl:value-of select="$ppn26[1]" />
<xsl:text>^</xsl:text>
<xsl:value-of select="$ppn26[2]" />
<xsl:text>^</xsl:text>
<xsl:value-of select="$ppn26[3]" />
<xsl:text>^</xsl:text>
<xsl:value-of select="$ppn26[5]" />
<xsl:text>^</xsl:text>
<xsl:value-of select="$ppn26[4]" />
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output indent="yes" method="xml"/>
<xsl:param name="SendingApplication">SendingApplication</xsl:param>
<xsl:param name="SendingFacility">SendingFacility</xsl:param>
<xsl:param name="ReceivingApplication">ReceivingApplication</xsl:param>
<xsl:param name="ReceivingFacility">ReceivingFacility</xsl:param>
<xsl:template match="/dataset">
<hl7>
<MSH fieldDelimiter="|" componentDelimiter="^" repeatDelimiter="~" escapeDelimiter="\" subcomponentDelimiter="&amp;">
<field><xsl:value-of select="$SendingApplication"/></field>
<field><xsl:value-of select="$SendingFacility"/></field>
<field><xsl:value-of select="$ReceivingApplication"/></field>
<field><xsl:value-of select="$ReceivingFacility"/></field>
<field/> <!-- Date/time of Message -->
<field/> <!-- Security -->
<field>ORM<component>O01</component></field>
<field/> <!-- Message Control ID -->
<field>P</field>
<field>2.3</field>
<field/> <!-- Sequence Number -->
<field/> <!-- Continuation Pointer -->
<field/> <!-- Accept Acknowledgment Type -->
<field/> <!-- Application Acknowledgment Type -->
<field/> <!-- Country Code -->
<field>8859/1</field>
</MSH>
<PID>
<field/>
<field/>
<field><xsl:value-of select="normalize-space(attr[@tag='00100020'])"/>
<component/>
<component/>
<component><xsl:value-of select="normalize-space(attr[@tag='00100021'])"/></component>
</field>
<field/>
<field>
<xsl:call-template name="pn2xpn">
<xsl:with-param name="pn" select="normalize-space(attr[@tag='00100010'])"/>
</xsl:call-template>
</field>
<field/>
<field><xsl:value-of select="normalize-space(attr[@tag='00100030'])"/></field>
<field><xsl:value-of select="normalize-space(attr[@tag='00100040'])"/></field>
</PID>
<xsl:apply-templates select="attr[@tag='00400270']/item"/>
</hl7>
</xsl:template>
<xsl:template match="item">
<xsl:variable name="accno" select="normalize-space(attr[@tag='00080050'])"/>
<ORC>
<field>SC</field>
<!-- Use Accession Number as Order Placer Number -->
<field><xsl:value-of select="$accno"/></field>
<!-- Use Accession Number as Order Filler Number -->
<field><xsl:value-of select="$accno"/></field>
<field/>
<!-- Order Status -->
<field>
<xsl:call-template name="ppsstatus2orderstatus">
<xsl:with-param name="ppsstatus" select="normalize-space(../../attr[@tag='00400252'])"/>
</xsl:call-template>
</field>
</ORC>
<OBR>
<field>1</field>
<!-- Use Accession Number as Order Placer Number -->
<field><xsl:value-of select="$accno"/></field>
<!-- Use Accession Number as Order Filler Number -->
<field><xsl:value-of select="$accno"/></field>
<field>
<xsl:call-template name="code2ce">
<xsl:with-param name="code" select="../../attr[@tag='00081032']/item"/>
</xsl:call-template>
</field>
</OBR>
<ZDS>
<field><xsl:value-of select="normalize-space(attr[@tag='0020000D'])"/>
<component><xsl:value-of select="$SendingApplication"/></component>
<component>Application</component>
<component>DICOM</component>
</field>
</ZDS>
</xsl:template>
<xsl:template name="pn2xpn">
<xsl:param name="pn"/>
<xsl:variable name="fn" select="substring-before($pn,'^')"/>
<xsl:choose>
<xsl:when test="$fn">
<xsl:value-of select="$fn"/>
<component>
<xsl:variable name="wofn" select="substring-after($pn,'^')"/>
<xsl:variable name="vn" select="substring-before($wofn,'^')"/>
<xsl:choose>
<xsl:when test="$vn">
<xsl:value-of select="$vn"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$wofn"/>
</xsl:otherwise>
</xsl:choose>
</component>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$pn"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="ppsstatus2orderstatus">
<xsl:param name="ppsstatus"/>
<xsl:choose>
<xsl:when test="$ppsstatus = 'COMPLETED'">CM</xsl:when>
<xsl:when test="$ppsstatus = 'DISCONTINUED'">DC</xsl:when>
<xsl:when test="$ppsstatus = 'IN PROGRESS'">IP</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template name="code2ce">
<xsl:param name="code"/>
<xsl:value-of select="normalize-space($code/attr[@tag='00080100'])"/>
<component>
<xsl:value-of select="normalize-space($code/attr[@tag='00080104'])"/>
</component>
<component>
<xsl:value-of select="normalize-space($code/attr[@tag='00080102'])"/>
</component>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:include href="common.xsl"/>
<xsl:template match="/hl7">
<dataset>
<attr tag="00080005" vr="CS">ISO_IR 100</attr>
<xsl:apply-templates select="MRG"/>
</dataset>
</xsl:template>
<xsl:template match="MRG">
<!-- Patient Name -->
<xsl:call-template name="xpn2pnAttr">
<xsl:with-param name="tag" select="'00100010'"/>
<xsl:with-param name="xpn" select="field[7]"/>
</xsl:call-template>
<!-- Patient ID -->
<xsl:call-template name="cx2attrs">
<xsl:with-param name="idtag" select="'00100020'"/>
<xsl:with-param name="istag" select="'00100021'"/>
<xsl:with-param name="cx" select="field[1]"/>
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output indent="yes" method="xml"/>
<xsl:param name="MessageControlID">1</xsl:param>
<xsl:param name="AcknowledgementCode">AA</xsl:param>
<xsl:param name="TextMessage"/>
<xsl:template match="/hl7">
<hl7>
<MSH
fieldDelimiter="{MSH/@fieldDelimiter}"
componentDelimiter="{MSH/@componentDelimiter}"
repeatDelimiter="{MSH/@repeatDelimiter}"
escapeDelimiter="{MSH/@escapeDelimiter}"
subcomponentDelimiter="{MSH/@subcomponentDelimiter}">
<field><xsl:value-of select="MSH/field[3]"/></field>
<field><xsl:value-of select="MSH/field[4]"/></field>
<field><xsl:value-of select="MSH/field[1]"/></field>
<field><xsl:value-of select="MSH/field[2]"/></field>
<field/>
<field/>
<field>ACK</field>
<field><xsl:value-of select="$MessageControlID"/></field>
<field><xsl:value-of select="MSH/field[9]"/></field>
<field><xsl:value-of select="MSH/field[10]"/></field>
<field/>
<field/>
<field/>
<field/>
<field/>
<field><xsl:value-of select="MSH/field[16]"/></field>
</MSH>
<MSA>
<field><xsl:value-of select="$AcknowledgementCode"/></field>
<field><xsl:value-of select="MSH/field[8]"/></field>
<field><xsl:value-of select="$TextMessage"/></field>
</MSA>
</hl7>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,244 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:include href="common.xsl"/>
<!-- root -->
<xsl:template match="/hl7">
<dataset>
<attr tag="00080005" vr="CS">ISO_IR 100</attr>
<xsl:apply-templates select="PID"/>
<xsl:apply-templates select="PV1"/>
<xsl:apply-templates select="AL1"/>
<xsl:apply-templates select="ORC[1]"/>
<xsl:apply-templates select="OBR[1]"/>
<!-- Scheduled Procedure Step Sequence -->
<attr tag="00400100" vr="SQ">
<xsl:apply-templates select="ORC" mode="sps"/>
</attr>
</dataset>
</xsl:template>
<!-- PV1 -->
<xsl:template match="PV1">
<!-- HL7:Assigned Patient Location.1 -> DICOM:Requesting Service -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00321033'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="substring(field[3]/text(),1,64)"/>
</xsl:call-template>
<!-- HL7:Assigned Patient Location.4 -> DICOM Requesting Physician -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00321032'"/>
<xsl:with-param name="vr" select="'PN'"/>
<xsl:with-param name="val" select="string(field[3]/component[3]/text())"/>
</xsl:call-template>
<!-- HL7:Referring Doctor -> DICOM:Referring Physican Name
(may replace HL7:Ordering Provider -> DICOM:Referring Physican Name mapping)
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'00080090'"/>
<xsl:with-param name="cn" select="field[8]"/>
</xsl:call-template>
-->
<!-- HL7:Ambulatory Status -> DICOM:Pregnancy Status -->
<xsl:call-template name="pregnancyStatus">
<xsl:with-param name="ambulantStatus" select="string(field[15]/text())"/>
</xsl:call-template>
<!-- HL7:Visit Number -> DICOM:Admission ID + Issuer -->
<xsl:call-template name="cx2attrs">
<xsl:with-param name="idtag" select="'00380010'"/>
<xsl:with-param name="istag" select="'00380011'"/>
<xsl:with-param name="cx" select="field[19]"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="pregnancyStatus">
<xsl:param name="ambulantStatus"/>
<xsl:if test="normalize-space($ambulantStatus)">
<attr tag="001021C0" vr="US">
<xsl:if test="$ambulantStatus = 'B6'">3</xsl:if>
</attr>
</xsl:if>
</xsl:template>
<!-- AL1 -->
<xsl:template match="AL1">
<!-- HL7:Allergy Code/Mnemonic/Description -> Medical Alerts + Contrast Allergies -->
<xsl:variable name="al1_3" select="string(field[3]/text())"/>
<xsl:choose>
<xsl:when test="$al1_3 = '&quot;&quot;'">
<attr tag="00102000" vr="LO"/>
<attr tag="00102110" vr="LO"/>
</xsl:when>
<xsl:when test="$al1_3">
<attr tag="00102000" vr="LO">
<xsl:value-of select="substring(substring-after($al1_3,'$'),1,64)"/>
</attr>
<attr tag="00102110" vr="LO">
<xsl:value-of select="substring(substring-before($al1_3,'$'),1,64)"/>
</attr>
</xsl:when>
</xsl:choose>
</xsl:template>
<!-- ORC[1] -->
<xsl:template match="ORC[1]">
<!-- HL7:Ordering Provider -> DICOM Referring Physican Name -->
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'00080090'"/>
<xsl:with-param name="cn" select="field[12]"/>
</xsl:call-template>
<!-- HL7:Ordering Provider -> DICOM Requesting Physician -->
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'00321032'"/>
<xsl:with-param name="cn" select="field[12]"/>
</xsl:call-template>
<!-- HL7:Quantity/Timing -> DICOM:Requested Procedure Priority -->
<xsl:call-template name="procedurePriority">
<xsl:with-param name="priority" select="string(field[7]/component[5]/text())"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="procedurePriority">
<xsl:param name="priority"/>
<xsl:if test="normalize-space($priority)">
<attr tag="00401003" vr="CS">
<xsl:choose>
<xsl:when test="$priority = 'S'">STAT</xsl:when>
<xsl:when test="$priority = 'A' or $priority = 'P' or $priority = 'C' ">HIGH</xsl:when>
<xsl:when test="$priority = 'R'">ROUTINE</xsl:when>
<xsl:when test="$priority = 'T'">MEDIUM</xsl:when>
</xsl:choose>
</attr>
</xsl:if>
</xsl:template>
<!-- OBR[1] -->
<xsl:template match="OBR[1]">
<xsl:variable name="ordno" select="string(field[3]/text())"/>
<!-- HL7:Filler Order Number -> DICOM:Placer Order Number -->
<attr tag="00402016" vr="LO">
<xsl:value-of select="$ordno"/>
</attr>
<!-- HL7:Filler Order Number -> DICOM:Filler Order Number -->
<attr tag="00402017" vr="LO">
<xsl:value-of select="$ordno"/>
</attr>
<!-- HL7:Filler Order Number -> DICOM:Accession Number -->
<attr tag="00080050" vr="SH">
<xsl:value-of select="$ordno"/>
</attr>
<!-- HL7:Danger Code -> DICOM:Patient State -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00380500'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="substring(field[12]/text(),1,64)"/>
</xsl:call-template>
<!-- HL7:Relevant Clinical Info -> DICOM:Reason for the Requested Procedure + Admitting Diagnoses Description -->
<xsl:variable name="obr13" select="normalize-space(field[13])"/>
<xsl:choose>
<xsl:when test="$obr13 = '&quot;&quot;'">
<attr tag="00081080" vr="LO"/>
<attr tag="00401002" vr="LO"/>
</xsl:when>
<xsl:when test="$obr13">
<attr tag="00081080" vr="LO">
<xsl:value-of select="substring(substring-after(substring-after(substring-after($obr13,'$'),'$'),'$'),1,64)"/>
</attr>
<attr tag="00401002" vr="LO">
<xsl:value-of select="substring(substring-before(substring-after($obr13,'$'),'$'),1,64)"/>
</attr>
</xsl:when>
</xsl:choose>
<!-- HL7:Transportation Mode -> DICOM:Patient Transport Arrangements -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00401004'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="substring(field[30]/text(),1,64)"/>
</xsl:call-template>
</xsl:template>
<!-- ORC - sps -->
<xsl:template match="ORC" mode="sps">
<item>
<!-- HL7:Entering Device -> DICOM:Scheduled Station Name -->
<xsl:call-template name="attr">
<xsl:with-param name="tag">00400010</xsl:with-param>
<xsl:with-param name="vr">SH</xsl:with-param>
<xsl:with-param name="val" select="substring(field[18]/text(),1,16)"/>
</xsl:call-template>
<!-- HL7:Entering Device -> DICOM:Modality -->
<xsl:call-template name="attr">
<xsl:with-param name="tag">00080060</xsl:with-param>
<xsl:with-param name="vr">CS</xsl:with-param>
<xsl:with-param name="val" select="substring(field[18]/component/text(),1,16)"/>
</xsl:call-template>
<xsl:apply-templates select="following-sibling::OBR[1]" mode="sps"/>
</item>
</xsl:template>
<!-- OBR - sps -->
<xsl:template match="OBR" mode="sps">
<!-- HL7:Results Rpt/Status Chng - Date/Time -> DICOM:Scheduled Procedure Step Start Date/Time -->
<xsl:variable name="obr36" select="normalize-space(field[36]/text())"/>
<xsl:variable name="dt">
<xsl:choose>
<xsl:when test="$obr36">
<xsl:value-of select="$obr36"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="normalize-space(field[22]/text())"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="string-length($dt) >= 8">
<xsl:call-template name="attrDATM">
<xsl:with-param name="datag" select="'00400002'"/>
<xsl:with-param name="tmtag" select="'00400003'"/>
<xsl:with-param name="val">
<xsl:value-of select="$dt"/>
<xsl:if test="string-length($dt) &lt; 10">00</xsl:if>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
<!-- HL7:Filler Order Number -> DICOM:Study Instance UID -->
<xsl:variable name="suid" select="string(field[3]/component[2]/text())"/>
<attr tag="0020000D" vr="UI">
<xsl:value-of select="$suid"/>
</attr>
<!-- Study Instance UID -> DICOM:Requested Procedure -->
<xsl:variable name="id"
select="substring(substring-after(substring-after(substring-after(substring-after(substring($suid,17),'.'),'.'),'.'),'.'),1,16)"/>
<attr tag="00401001" vr="SH">
<xsl:value-of select="$id"/>
</attr>
<!-- Study Instance UID -> DICOM:Scheduled Procedure Step ID -->
<attr tag="00400009" vr="SH">
<xsl:value-of select="$id"/>
</attr>
<!-- HL7:Universal Service Identifier.2 -> DICOM:Requested Procedure Description -->
<xsl:variable name="desc" select="substring(field[4]/component[2]/text(),1,64)"/>
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00321060'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="$desc"/>
</xsl:call-template>
<!-- HL7:Universal Service Identifier -> DICOM:Requested Procedure Code -->
<xsl:call-template name="codeItem">
<xsl:with-param name="sqtag" select="'00321064'"/>
<xsl:with-param name="code" select="string(field[4]/text())"/>
<xsl:with-param name="scheme" select="'99ORBIS'"/>
<xsl:with-param name="meaning" select="$desc"/>
</xsl:call-template>
<!-- HL7:Universal Service Identifier.2 -> DICOM:Scheduled Procedure Step Description -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00400007'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="$desc"/>
</xsl:call-template>
<!-- HL7:Universal Service Identifier -> DICOM:Scheduled Protocol Code -->
<xsl:call-template name="codeItem">
<xsl:with-param name="sqtag" select="'00400008'"/>
<xsl:with-param name="code" select="string(field[4]/text())"/>
<xsl:with-param name="scheme" select="'99ORBIS'"/>
<xsl:with-param name="meaning" select="$desc"/>
</xsl:call-template>
<!-- HL7:Technician -> Scheduled Performing Physican Name -->
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'00400006'"/>
<xsl:with-param name="cn" select="field[34]"/>
<xsl:with-param name="cn26" select="field[34]/subcomponent"/>
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,603 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:include href="common.xsl"/>
<xsl:param name="VerifyingOrganization">Verifying Organization</xsl:param>
<xsl:template match="/hl7">
<dataset>
<xsl:call-template name="common-attrs"/>
<xsl:apply-templates select="PID"/>
<xsl:apply-templates select="OBR[1]"/>
<xsl:apply-templates select="ZBU"/>
<!-- Identical Documents Sequence -->
<attr tag="0040A525" vr="SQ">
<xsl:apply-templates select="OBR[position()&gt;1]" mode="identical"/>
</attr>
<!-- Referenced Request Sequence -->
<attr tag="0040A370" vr="SQ">
<xsl:apply-templates select="OBR" mode="request"/>
</attr>
<!--Content Sequence-->
<attr tag="0040A730" vr="SQ">
<xsl:apply-templates select="ZBU" mode="obsctx"/>
<xsl:apply-templates select="OBR[1]" mode="clinicalInfo"/>
<xsl:apply-templates select="OBX"/>
<xsl:apply-templates select="ZBU" mode="summary"/>
</attr>
</dataset>
</xsl:template>
<xsl:template name="common-attrs">
<!-- Specific Character Set -->
<attr tag="00080005" vr="CS">ISO_IR 100</attr>
<!--SOP Class UID = Basic Text SR -->
<attr tag="00080016" vr="UI">1.2.840.10008.5.1.4.1.1.88.11</attr>
<!--Modality-->
<attr tag="00080060" vr="CS">SR</attr>
<!--Manufacturer-->
<attr tag="00080070" vr="LO">Agfa HealthCare</attr>
<!--Referring Physician's Name-->
<attr tag="00080090" vr="PN"/>
<!--Referenced Performed Procedure Step Sequence -->
<attr tag="00081111" vr="SQ"/>
<!--Study ID-->
<attr tag="00200010" vr="SH"/>
<!--Series Number-->
<attr tag="00200011" vr="IS"/>
<!--Instance Number-->
<attr tag="00200013" vr="IS">1</attr>
<!--Value Type-->
<attr tag="0040A040" vr="CS">CONTAINER</attr>
<!--Concept Name Code Sequence-->
<attr tag="0040A043" vr="SQ">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">11528-7</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">LN</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">Radiology Report</attr>
</item>
</attr>
<!--Continuity Of Content-->
<attr tag="0040A050" vr="CS">SEPARATE</attr>
<!--Content Template Sequence-->
<attr tag="0040A504" vr="SQ">
<item>
<!--Mapping Resource-->
<attr tag="00080105" vr="CS">DCMR</attr>
<!--Template Identifier-->
<attr tag="0040DB00" vr="CS">2000</attr>
</item>
</attr>
</xsl:template>
<xsl:template match="OBR">
<xsl:variable name="ordno" select="field[3]/text()"/>
<xsl:variable name="dt" select="field[22]/text()"/>
<!--Study Date/Time -->
<xsl:if test="string-length($dt) >= 8">
<xsl:call-template name="attrDATM">
<xsl:with-param name="datag" select="'00080020'"/>
<xsl:with-param name="tmtag" select="'00080030'"/>
<xsl:with-param name="val">
<xsl:value-of select="$dt"/>
<xsl:if test="string-length($dt) &lt; 10">00</xsl:if>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
<!--Accession Number-->
<attr tag="00080050" vr="SH">
<xsl:value-of select="$ordno"/>
</attr>
<!--Study Instance UID-->
<attr tag="0020000D" vr="UI">
<xsl:value-of select="field[3]/component[2]"/>
</attr>
<!--Placer Order Number / Imaging Service Request-->
<attr tag="00402016" vr="LO">
<xsl:value-of select="$ordno"/>
</attr>
<!--Filler Order Number / Imaging Service Request-->
<attr tag="00402017" vr="LO">
<xsl:value-of select="$ordno"/>
</attr>
<xsl:variable name="resultStatus" select="normalize-space(field[25])"/>
<!--Completion Flag-->
<attr tag="0040A491" vr="CS">
<xsl:choose>
<xsl:when test="$resultStatus='P'">PARTIAL</xsl:when>
<xsl:otherwise>COMPLETE</xsl:otherwise>
</xsl:choose>
</attr>
<!--Verification Flag-->
<attr tag="0040A493" vr="CS">
<xsl:choose>
<xsl:when test="$resultStatus='P' or $resultStatus='F'">VERIFIED</xsl:when>
<xsl:otherwise>UNVERIFIED</xsl:otherwise>
</xsl:choose>
</attr>
</xsl:template>
<xsl:template match="OBR" mode="identical">
<item>
<!--Study Instance UID-->
<attr tag="0020000D" vr="UI">
<xsl:value-of select="field[3]/component[2]"/>
</attr>
</item>
</xsl:template>
<xsl:template match="OBR" mode="request">
<xsl:variable name="ordno" select="field[3]/text()"/>
<item>
<!--Accession Number-->
<attr tag="00080050" vr="SH">
<xsl:value-of select="$ordno"/>
</attr>
<!--Referenced Study Sequence-->
<attr tag="00081110" vr="SQ"/>
<!--Study Instance UID-->
<attr tag="0020000D" vr="UI">
<xsl:value-of select="field[3]/component[2]"/>
</attr>
<!--Requested Procedure Description-->
<attr tag="00321060" vr="LO"/>
<!--Requested Procedure Code Sequence-->
<attr tag="00321064" vr="SQ"/>
<!--Requested Procedure ID-->
<attr tag="00401001" vr="SH"/>
<!--Placer Order Number / Imaging Service Request-->
<attr tag="00402016" vr="LO">
<xsl:value-of select="$ordno"/>
</attr>
<!--Filler Order Number / Imaging Service Request-->
<attr tag="00402017" vr="LO">
<xsl:value-of select="$ordno"/>
</attr>
</item>
</xsl:template>
<xsl:template match="ZBU">
<xsl:variable name="dt" select="concat(field[6]/text(),field[7]/text())"/>
<!--Content Date/Time-->
<xsl:if test="string-length($dt) >= 8">
<xsl:call-template name="attrDATM">
<xsl:with-param name="datag" select="'00080023'"/>
<xsl:with-param name="tmtag" select="'00080033'"/>
<xsl:with-param name="val">
<xsl:value-of select="$dt"/>
<xsl:if test="string-length($dt) &lt; 10">00</xsl:if>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
<!-- Verifying Observer Sequence -->
<attr tag="0040A073" vr="SQ">
<item>
<!-- Verifying Organization -->
<attr tag="0040A027" vr="LO">
<xsl:value-of select="$VerifyingOrganization"/>
</attr>
<!-- Verification DateTime -->
<attr tag="0040A030" vr="DT">
<xsl:value-of select="$dt"/>
</attr>
<!-- Verifying Observer Name -->
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'0040A075'"/>
<xsl:with-param name="cn" select="field[3]"/>
</xsl:call-template>
<!-- Verifying Observer Identification Code Sequence -->
<attr tag="0040A088" vr="SQ"/>
</item>
</attr>
</xsl:template>
<xsl:template match="ZBU" mode="obsctx">
<item>
<!--Relationship Type-->
<attr tag="0040A010" vr="CS">HAS CONCEPT MOD</attr>
<!--Value Type-->
<attr tag="0040A040" vr="CS">CODE</attr>
<!--Concept Name Code Sequence-->
<attr tag="0040A043" vr="SQ">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">121049</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">DCM</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">Language of Content Item and Descendants</attr>
</item>
</attr>
<!--Concept Code Sequence-->
<attr tag="0040A168" vr="SQ">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">de</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">RFC3066</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">German</attr>
</item>
</attr>
</item>
<item>
<!--Relationship Type-->
<attr tag="0040A010" vr="CS">HAS OBS CONTEXT</attr>
<!--Value Type-->
<attr tag="0040A040" vr="CS">PNAME</attr>
<!--Concept Name Code Sequence-->
<attr tag="0040A043" vr="SQ">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">121008</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">DCM</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">Person Observer Name</attr>
</item>
</attr>
<!--Person Name-->
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'0040A123'"/>
<xsl:with-param name="cn" select="field[4]"/>
</xsl:call-template>
</item>
</xsl:template>
<xsl:template match="OBR" mode="obsctx">
<item>
<!--Relationship Type-->
<attr tag="0040A010" vr="CS">HAS OBS CONTEXT</attr>
<!--Value Type-->
<attr tag="0040A040" vr="CS">UIDREF</attr>
<!--Concept Name Code Sequence-->
<attr tag="0040A043" vr="SQ">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">121018</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">DCM</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">Procedure Study Instance UID</attr>
</item>
</attr>
<!-- UID -->
<attr tag="0040A124" vr="UI">
<xsl:value-of select="field[3]/component[2]"/>
</attr>
</item>
<item>
<!--Relationship Type-->
<attr tag="0040A010" vr="CS">HAS OBS CONTEXT</attr>
<!--Value Type-->
<attr tag="0040A040" vr="CS">CODE</attr>
<!--Concept Name Code Sequence-->
<attr tag="0040A043" vr="SQ">
<item>
<attr tag="00080100" vr="SH">121023</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">DCM</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">Procedure Code</attr>
</item>
</attr>
<!--Concept Code Sequence-->
<attr tag="0040A168" vr="SQ">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">
<xsl:value-of select="field[4]/text()"/>
</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">99ORBIS</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">
<xsl:value-of select="field[4]/component[1]"/>
</attr>
</item>
</attr>
</item>
</xsl:template>
<xsl:template match="OBR" mode="procedure">
<item>
<!--Relationship Type-->
<attr tag="0040A010" vr="CS">CONTAINS</attr>
<!--Value Type-->
<attr tag="0040A040" vr="CS">CONTAINER</attr>
<!--Concept Name Code Sequence-->
<attr tag="0040A043" vr="SQ">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">121064</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">DCM</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">Current Procedure Descriptions</attr>
</item>
</attr>
<!--Continuity Of Content-->
<attr tag="0040A050" vr="CS">SEPARATE</attr>
<!--Content Sequence-->
<attr tag="0040A730" vr="SQ">
<item>
<!--Relationship Type-->
<attr tag="0040A010" vr="CS">CONTAINS</attr>
<!--Value Type-->
<attr tag="0040A040" vr="CS">TEXT</attr>
<!--Concept Name Code Sequence-->
<attr tag="0040A043" vr="SQ">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">121065</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">DCM</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">Procedure Description</attr>
</item>
</attr>
<!--Text Value-->
<attr tag="0040A160" vr="UT">
<xsl:value-of select="field[4]/component[1]"/>
</attr>
</item>
</attr>
</item>
</xsl:template>
<xsl:template match="OBR" mode="clinicalInfo">
<xsl:variable name="clinicalInfo" select="field[13]"/>
<xsl:variable name="history" select="substring-before($clinicalInfo,'$')"/>
<xsl:variable name="reason"
select="substring-before(substring-after(substring-after($clinicalInfo,'$'),'$'),'$')"/>
<xsl:if test="$history">
<item>
<!--Relationship Type-->
<attr tag="0040A010" vr="CS">CONTAINS</attr>
<!--Value Type-->
<attr tag="0040A040" vr="CS">CONTAINER</attr>
<!--Concept Name Code Sequence-->
<attr tag="0040A043" vr="SQ">
<item off="1370">
<!--Code Value-->
<attr tag="00080100" vr="SH">121060</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">DCM</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">History</attr>
</item>
</attr>
<!--Continuity Of Content-->
<attr tag="0040A050" vr="CS">SEPARATE</attr>
<!--Content Sequence-->
<attr tag="0040A730" vr="SQ">
<item>
<!--Relationship Type-->
<attr tag="0040A010" vr="CS">CONTAINS</attr>
<!--Value Type-->
<attr tag="0040A040" vr="CS">TEXT</attr>
<!--Concept Name Code Sequence-->
<attr tag="0040A043" vr="SQ">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">121060</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">DCM</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">History</attr>
</item>
</attr>
<!--Text Value-->
<attr tag="0040A160" vr="UT">
<xsl:value-of select="$history"/>
</attr>
</item>
</attr>
</item>
</xsl:if>
<xsl:if test="$reason">
<item>
<!--Relationship Type-->
<attr tag="0040A010" vr="CS">CONTAINS</attr>
<!--Value Type-->
<attr tag="0040A040" vr="CS">CONTAINER</attr>
<!--Concept Name Code Sequence-->
<attr tag="0040A043" vr="SQ">
<item off="1370">
<!--Code Value-->
<attr tag="00080100" vr="SH">111401</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">DCM</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">Reason for procedure</attr>
</item>
</attr>
<!--Continuity Of Content-->
<attr tag="0040A050" vr="CS">SEPARATE</attr>
<!--Content Sequence-->
<attr tag="0040A730" vr="SQ">
<item>
<!--Relationship Type-->
<attr tag="0040A010" vr="CS">CONTAINS</attr>
<!--Value Type-->
<attr tag="0040A040" vr="CS">TEXT</attr>
<!--Concept Name Code Sequence-->
<attr tag="0040A043" vr="SQ">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">111401</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">DCM</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">Reason for procedure</attr>
</item>
</attr>
<!--Text Value-->
<attr tag="0040A160" vr="UT">
<xsl:value-of select="$reason"/>
</attr>
</item>
</attr>
</item>
</xsl:if>
</xsl:template>
<xsl:template match="OBX">
<xsl:apply-templates select="preceding-sibling::OBR[1]" mode="procedure"/>
<item>
<!--Relationship Type-->
<attr tag="0040A010" vr="CS">CONTAINS</attr>
<!--Value Type-->
<attr tag="0040A040" vr="CS">CONTAINER</attr>
<!--Concept Name Code Sequence-->
<attr tag="0040A043" vr="SQ">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">121076</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">DCM</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">Conclusions</attr>
</item>
</attr>
<!--Continuity Of Content-->
<attr tag="0040A050" vr="CS">SEPARATE</attr>
<!--Content Sequence-->
<attr tag="0040A730" vr="SQ">
<xsl:apply-templates select="preceding-sibling::OBR[1]" mode="obsctx"/>
<item>
<!--Relationship Type-->
<attr tag="0040A010" vr="CS">CONTAINS</attr>
<!--Value Type-->
<attr tag="0040A040" vr="CS">TEXT</attr>
<!--Concept Name Code Sequence-->
<attr tag="0040A043" vr="SQ">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">121077</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">DCM</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">Conclusion</attr>
</item>
</attr>
<!--Text Value-->
<attr tag="0040A160" vr="UT">
<xsl:apply-templates select="field[5]" mode="TEXT"/>
</attr>
</item>
</attr>
</item>
</xsl:template>
<xsl:template match="text()" mode="TEXT">
<xsl:value-of select='.'/>
</xsl:template>
<xsl:template match="escape" mode="TEXT">
<xsl:choose>
<xsl:when test="text()='.br'">
<xsl:text>&#13;&#10;</xsl:text>
</xsl:when>
<xsl:when test="text()='F'">
<xsl:text>|</xsl:text>
</xsl:when>
<xsl:when test="text()='S'">
<xsl:text>^</xsl:text>
</xsl:when>
<xsl:when test="text()='T'">
<xsl:text>&amp;</xsl:text>
</xsl:when>
<xsl:when test="text()='R'">
<xsl:text>~</xsl:text>
</xsl:when>
<xsl:when test="text()='E'">
<xsl:text>\\</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="ZBU" mode="summary">
<xsl:variable name="summary" select="field[1]/text()"/>
<xsl:if test="$summary">
<item>
<!--Relationship Type-->
<attr tag="0040A010" vr="CS">CONTAINS</attr>
<!--Value Type-->
<attr tag="0040A040" vr="CS">CONTAINER</attr>
<!--Concept Name Code Sequence-->
<attr tag="0040A043" vr="SQ">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">121111</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">DCM</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">Summary</attr>
</item>
</attr>
<!--Continuity Of Content-->
<attr tag="0040A050" vr="CS">SEPARATE</attr>
<!--Content Sequence-->
<attr tag="0040A730" vr="SQ">
<item>
<!--Relationship Type-->
<attr tag="0040A010" vr="CS">CONTAINS</attr>
<!--Value Type-->
<attr tag="0040A040" vr="CS">TEXT</attr>
<!--Concept Name Code Sequence-->
<attr tag="0040A043" vr="SQ">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">121111</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">DCM</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">Summary</attr>
</item>
</attr>
<!--Text Value-->
<attr tag="0040A160" vr="UT">
<xsl:value-of select="$summary"/>
</attr>
</item>
</attr>
</item>
</xsl:if>
<xsl:variable name="recommendation" select="field[2]/text()"/>
<xsl:if test="$recommendation">
<item>
<!--Relationship Type-->
<attr tag="0040A010" vr="CS">CONTAINS</attr>
<!--Value Type-->
<attr tag="0040A040" vr="CS">CONTAINER</attr>
<!--Concept Name Code Sequence-->
<attr tag="0040A043" vr="SQ">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">121074</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">DCM</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">Recommendations</attr>
</item>
</attr>
<!--Continuity Of Content-->
<attr tag="0040A050" vr="CS">SEPARATE</attr>
<!--Content Sequence-->
<attr tag="0040A730" vr="SQ">
<item>
<!--Relationship Type-->
<attr tag="0040A010" vr="CS">CONTAINS</attr>
<!--Value Type-->
<attr tag="0040A040" vr="CS">TEXT</attr>
<!--Concept Name Code Sequence-->
<attr tag="0040A043" vr="SQ">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">121075</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">DCM</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">Recommendation</attr>
</item>
</attr>
<!--Text Value-->
<attr tag="0040A160" vr="UT">
<xsl:value-of select="$recommendation"/>
</attr>
</item>
</attr>
</item>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,241 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:include href="common.xsl"/>
<!-- root -->
<xsl:template match="/hl7">
<dataset>
<attr tag="00080005" vr="CS">ISO_IR 100</attr>
<xsl:apply-templates select="PID"/>
<xsl:apply-templates select="PV1"/>
<xsl:apply-templates select="AL1"/>
<xsl:apply-templates select="ORC[1]"/>
<xsl:apply-templates select="OBR[1]"/>
<!-- Scheduled Procedure Step Sequence -->
<attr tag="00400100" vr="SQ">
<xsl:apply-templates select="ORC" mode="sps"/>
</attr>
</dataset>
</xsl:template>
<!-- PV1 -->
<xsl:template match="PV1">
<!-- HL7:Assigned Patient Location.1 -> DICOM:Requesting Service -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00321033'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="substring(field[3]/text(),1,64)"/>
</xsl:call-template>
<!-- HL7:Assigned Patient Location.4 -> DICOM Requesting Physician -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00321032'"/>
<xsl:with-param name="vr" select="'PN'"/>
<xsl:with-param name="val" select="string(field[3]/component[3]/text())"/>
</xsl:call-template>
<!-- HL7:Referring Doctor -> DICOM:Referring Physican Name
(may replace HL7:Ordering Provider -> DICOM:Referring Physican Name mapping)
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'00080090'"/>
<xsl:with-param name="cn" select="field[8]"/>
</xsl:call-template>
-->
<!-- HL7:Ambulatory Status -> DICOM:Pregnancy Status -->
<xsl:call-template name="pregnancyStatus">
<xsl:with-param name="ambulantStatus" select="string(field[15]/text())"/>
</xsl:call-template>
<!-- HL7:Visit Number -> DICOM:Admission ID + Issuer -->
<xsl:call-template name="cx2attrs">
<xsl:with-param name="idtag" select="'00380010'"/>
<xsl:with-param name="istag" select="'00380011'"/>
<xsl:with-param name="cx" select="field[19]"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="pregnancyStatus">
<xsl:param name="ambulantStatus"/>
<xsl:if test="normalize-space($ambulantStatus)">
<attr tag="001021C0" vr="US">
<xsl:if test="$ambulantStatus = 'B6'">3</xsl:if>
</attr>
</xsl:if>
</xsl:template>
<!-- AL1 -->
<xsl:template match="AL1">
<!-- HL7:Allergy Code/Mnemonic/Description -> Medical Alerts + Contrast Allergies -->
<xsl:variable name="al1_3" select="string(field[3]/text())"/>
<xsl:choose>
<xsl:when test="$al1_3 = '&quot;&quot;'">
<attr tag="00102000" vr="LO"/>
<attr tag="00102110" vr="LO"/>
</xsl:when>
<xsl:when test="$al1_3">
<attr tag="00102000" vr="LO">
<xsl:value-of select="substring(substring-after($al1_3,'$'),1,64)"/>
</attr>
<attr tag="00102110" vr="LO">
<xsl:value-of select="substring(substring-before($al1_3,'$'),1,64)"/>
</attr>
</xsl:when>
</xsl:choose>
</xsl:template>
<!-- ORC[1] -->
<xsl:template match="ORC[1]">
<!-- HL7:Ordering Provider -> DICOM Referring Physican Name -->
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'00080090'"/>
<xsl:with-param name="cn" select="field[12]"/>
</xsl:call-template>
<!-- HL7:Ordering Provider -> DICOM Requesting Physician -->
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'00321032'"/>
<xsl:with-param name="cn" select="field[12]"/>
</xsl:call-template>
<!-- HL7:Quantity/Timing -> DICOM:Requested Procedure Priority -->
<xsl:call-template name="procedurePriority">
<xsl:with-param name="priority" select="string(field[7]/component[5]/text())"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="procedurePriority">
<xsl:param name="priority"/>
<xsl:if test="normalize-space($priority)">
<attr tag="00401003" vr="CS">
<xsl:choose>
<xsl:when test="$priority = 'S'">STAT</xsl:when>
<xsl:when test="$priority = 'A' or $priority = 'P' or $priority = 'C' ">HIGH</xsl:when>
<xsl:when test="$priority = 'R'">ROUTINE</xsl:when>
<xsl:when test="$priority = 'T'">MEDIUM</xsl:when>
</xsl:choose>
</attr>
</xsl:if>
</xsl:template>
<!-- OBR[1] -->
<xsl:template match="OBR[1]">
<xsl:variable name="ordno" select="string(field[3]/text())"/>
<!-- HL7:Filler Order Number -> DICOM:Placer Order Number -->
<attr tag="00402016" vr="LO">
<xsl:value-of select="$ordno"/>
</attr>
<!-- HL7:Filler Order Number -> DICOM:Filler Order Number -->
<attr tag="00402017" vr="LO">
<xsl:value-of select="$ordno"/>
</attr>
<!-- HL7:Filler Order Number -> DICOM:Accession Number -->
<attr tag="00080050" vr="SH">
<xsl:value-of select="$ordno"/>
</attr>
<!-- HL7:Danger Code -> DICOM:Patient State -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00380500'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="substring(field[12]/text(),1,64)"/>
</xsl:call-template>
<!-- HL7:Relevant Clinical Info -> DICOM:Reason for the Requested Procedure + Admitting Diagnoses Description -->
<xsl:variable name="obr13" select="normalize-space(field[13])"/>
<xsl:choose>
<xsl:when test="$obr13 = '&quot;&quot;'">
<attr tag="00081080" vr="LO"/>
<attr tag="00401002" vr="LO"/>
</xsl:when>
<xsl:when test="$obr13">
<attr tag="00081080" vr="LO">
<xsl:value-of select="substring(substring-after(substring-after(substring-after($obr13,'$'),'$'),'$'),1,64)"/>
</attr>
<attr tag="00401002" vr="LO">
<xsl:value-of select="substring(substring-before(substring-after($obr13,'$'),'$'),1,64)"/>
</attr>
</xsl:when>
</xsl:choose>
<!-- HL7:Transportation Mode -> DICOM:Patient Transport Arrangements -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00401004'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="substring(field[30]/text(),1,64)"/>
</xsl:call-template>
</xsl:template>
<!-- ORC - sps -->
<xsl:template match="ORC" mode="sps">
<item>
<!-- HL7:Entering Device -> DICOM:Scheduled Station Name -->
<xsl:call-template name="attr">
<xsl:with-param name="tag">00400010</xsl:with-param>
<xsl:with-param name="vr">SH</xsl:with-param>
<xsl:with-param name="val" select="substring(field[18]/text(),1,16)"/>
</xsl:call-template>
<!-- HL7:Entering Device -> DICOM:Modality -->
<xsl:call-template name="attr">
<xsl:with-param name="tag">00080060</xsl:with-param>
<xsl:with-param name="vr">CS</xsl:with-param>
<xsl:with-param name="val" select="substring(field[18]/component/text(),1,16)"/>
</xsl:call-template>
<xsl:apply-templates select="following-sibling::OBR[1]" mode="sps"/>
</item>
</xsl:template>
<!-- OBR - sps -->
<xsl:template match="OBR" mode="sps">
<!-- HL7:Results Rpt/Status Chng - Date/Time -> DICOM:Scheduled Procedure Step Start Date/Time -->
<xsl:variable name="obr36" select="normalize-space(field[36]/text())"/>
<xsl:variable name="dt">
<xsl:choose>
<xsl:when test="$obr36">
<xsl:value-of select="$obr36"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="normalize-space(field[22]/text())"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="string-length($dt) >= 8">
<xsl:call-template name="attrDATM">
<xsl:with-param name="datag" select="'00400002'"/>
<xsl:with-param name="tmtag" select="'00400003'"/>
<xsl:with-param name="val">
<xsl:value-of select="$dt"/>
<xsl:if test="string-length($dt) &lt; 10">00</xsl:if>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
<!-- HL7:Filler Order Number -> DICOM:Study Instance UID -->
<attr tag="0020000D" vr="UI">
<xsl:value-of select="string(field[3]/component[2]/text())"/>
</attr>
<!-- Requested Procedure ID -->
<attr tag="00401001" vr="SH">
<xsl:value-of select="string(field[19]/text())"/>
</attr>
<!-- Scheduled Procedure Step ID -->
<attr tag="00400009" vr="SH">
<xsl:value-of select="string(field[20]/text())"/>
</attr>
<!-- HL7:Universal Service Identifier.2 -> DICOM:Requested Procedure Description -->
<xsl:variable name="desc" select="substring(field[4]/component[2]/text(),1,64)"/>
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00321060'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="$desc"/>
</xsl:call-template>
<!-- HL7:Universal Service Identifier -> DICOM:Requested Procedure Code -->
<xsl:call-template name="codeItem">
<xsl:with-param name="sqtag" select="'00321064'"/>
<xsl:with-param name="code" select="string(field[4]/text())"/>
<xsl:with-param name="scheme" select="'99ORBIS'"/>
<xsl:with-param name="meaning" select="$desc"/>
</xsl:call-template>
<!-- HL7:Universal Service Identifier.2 -> DICOM:Scheduled Procedure Step Description -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00400007'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="$desc"/>
</xsl:call-template>
<!-- HL7:Universal Service Identifier -> DICOM:Scheduled Protocol Code -->
<xsl:call-template name="codeItem">
<xsl:with-param name="sqtag" select="'00400008'"/>
<xsl:with-param name="code" select="string(field[4]/text())"/>
<xsl:with-param name="scheme" select="'99ORBIS'"/>
<xsl:with-param name="meaning" select="$desc"/>
</xsl:call-template>
<!-- HL7:Technician -> Scheduled Performing Physican Name -->
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'00400006'"/>
<xsl:with-param name="cn" select="field[34]"/>
<xsl:with-param name="cn26" select="field[34]/subcomponent"/>
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,219 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:include href="common.xsl"/>
<xsl:template match="/hl7">
<dataset>
<attr tag="00080005" vr="CS">ISO_IR 100</attr>
<xsl:apply-templates select="PID"/>
<xsl:apply-templates select="PV1"/>
<xsl:apply-templates select="ORC[1]"/>
<xsl:apply-templates select="OBR[1]"/>
<!-- Scheduled Procedure Step Sequence -->
<attr tag="00400100" vr="SQ">
<xsl:apply-templates select="ORC" mode="sps"/>
</attr>
<xsl:apply-templates select="ZDS"/>
</dataset>
</xsl:template>
<xsl:template match="PV1">
<!-- Referring Physican Name -->
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'00080090'"/>
<xsl:with-param name="cn" select="field[8]"/>
</xsl:call-template>
<xsl:call-template name="pregnancyStatus">
<xsl:with-param name="ambulantStatus" select="string(field[15]/text())"/>
</xsl:call-template>
<!-- Admission ID, Issuer -->
<attr tag="00380010" vr="LO">
<xsl:value-of select="string(field[19]/text())"/>
</attr>
<xsl:variable name="issuerOfAdmissionID"
select="string(field[19]/component[3]/text())" />
<xsl:if test="$issuerOfAdmissionID">
<!-- Issuer of Admission ID Sequence -->
<attr tag="00380014" vr="SQ">
<item>
<!-- Local Namespace Entity ID -->
<attr tag="00400031" vr="UT">
<xsl:value-of select="$issuerOfAdmissionID" />
</attr>
</item>
</attr>
</xsl:if>
<xsl:call-template name="cx2attrs">
<xsl:with-param name="idtag" select="'00380010'"/>
<xsl:with-param name="istag" select="'00380011'"/>
<xsl:with-param name="cx" select="field[19]"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="pregnancyStatus">
<xsl:param name="ambulantStatus"/>
<xsl:if test="normalize-space($ambulantStatus)">
<attr tag="001021C0" vr="US">
<xsl:if test="$ambulantStatus = 'B6'">3</xsl:if>
</attr>
</xsl:if>
</xsl:template>
<xsl:template match="ORC[1]">
<!-- Placer Order Number -->
<xsl:call-template name="ei2attr">
<xsl:with-param name="tag" select="'00402016'"/>
<xsl:with-param name="ei" select="field[2]"/>
</xsl:call-template>
<!-- Filler Order Number -->
<xsl:call-template name="ei2attr">
<xsl:with-param name="tag" select="'00402017'"/>
<xsl:with-param name="ei" select="field[3]"/>
</xsl:call-template>
<!-- Ordering Facility Name - Institutional Department Name -->
<xsl:call-template name="ei2attr">
<xsl:with-param name="tag" select="'00081040'"/>
<xsl:with-param name="ei" select="field[21]"/>
</xsl:call-template>
<xsl:call-template name="ei2attr">
<xsl:with-param name="tag" select="'00321033'"/>
<xsl:with-param name="ei" select="field[21]"/>
</xsl:call-template>
<xsl:call-template name="procedurePriority">
<xsl:with-param name="priority" select="string(field[7]/component[5]/text())"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="procedurePriority">
<xsl:param name="priority"/>
<xsl:if test="normalize-space($priority)">
<attr tag="00401003" vr="CS">
<xsl:choose>
<xsl:when test="$priority = 'S'">STAT</xsl:when>
<xsl:when test="$priority = 'A' or $priority = 'P' or $priority = 'C' ">HIGH</xsl:when>
<xsl:when test="$priority = 'R'">ROUTINE</xsl:when>
<xsl:when test="$priority = 'T'">MEDIUM</xsl:when>
</xsl:choose>
</attr>
</xsl:if>
</xsl:template>
<xsl:template match="OBR[1]">
<!-- Accession Number -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00080050'"/>
<xsl:with-param name="vr" select="'SH'"/>
<xsl:with-param name="val" select="string(field[18]/text())"/>
</xsl:call-template>
<!-- Medical Alerts -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00102000'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="substring(field[13]/text(),1,64)"/>
</xsl:call-template>
<!-- Requesting Physician -->
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'00321032'"/>
<xsl:with-param name="cn" select="field[16]"/>
</xsl:call-template>
<!-- Requested Procedure Description -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00321060'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="field[44]/component[1]"/>
</xsl:call-template>
<!-- Study Description -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00081030'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="field[44]/component[1]"/>
</xsl:call-template>
<!-- Requested Procedure Code Sequence -->
<xsl:call-template name="codeItem">
<xsl:with-param name="sqtag" select="'00321064'"/>
<xsl:with-param name="code" select="string(field[44]/text())"/>
<xsl:with-param name="scheme" select="string(field[44]/component[2]/text())"/>
<xsl:with-param name="meaning" select="substring(field[44]/component[1]/text(),1,64)"/>
</xsl:call-template>
<!-- Patient State -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00380500'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="substring(field[12]/text(),1,64)"/>
</xsl:call-template>
<!-- Requested Procedure ID -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00401001'"/>
<xsl:with-param name="vr" select="'SH'"/>
<xsl:with-param name="val" select="string(field[19]/text())"/>
</xsl:call-template>
<!-- Patient Transport Arrangements -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00401004'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="substring(field[30]/text(),1,64)"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="ORC" mode="sps">
<item>
<!-- Scheduled Procedure Step Start Date/Time -->
<xsl:call-template name="attrDATM">
<xsl:with-param name="datag" select="'00400002'"/>
<xsl:with-param name="tmtag" select="'00400003'"/>
<xsl:with-param name="val" select="string(field[7]/component[3]/text())"/>
</xsl:call-template>
<xsl:apply-templates select="following-sibling::OBR[1]" mode="sps"/>
<xsl:apply-templates select="following-sibling::ZDS" mode="sps"/>
</item>
</xsl:template>
<xsl:template match="OBR" mode="sps">
<!-- Modality -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00080060'"/>
<xsl:with-param name="vr" select="'CS'"/>
<xsl:with-param name="val" select="string(field[24]/text())"/>
</xsl:call-template>
<!-- Scheduled Performing Physican Name -->
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'00400006'"/>
<xsl:with-param name="cn" select="field[34]"/>
<xsl:with-param name="cn26" select="field[34]/subcomponent"/>
</xsl:call-template>
<!-- Scheduled Procedure Step Description -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00400007'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="substring(field[4]/component[4]/text(),1,64)"/>
</xsl:call-template>
<!-- Scheduled Protocol Code Sequence -->
<xsl:call-template name="codeItem">
<xsl:with-param name="sqtag" select="'00400008'"/>
<xsl:with-param name="code" select="string(field[4]/component[3]/text())"/>
<xsl:with-param name="scheme" select="string(field[4]/component[5]/text())"/>
<xsl:with-param name="meaning" select="substring(field[4]/component[4]/text(),1,64)"/>
</xsl:call-template>
<!-- Scheduled Procedure Step ID -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00400009'"/>
<xsl:with-param name="vr" select="'SH'"/>
<xsl:with-param name="val" select="string(field[20]/text())"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="ZDS">
<!-- Study Instance UID -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'0020000D'"/>
<xsl:with-param name="vr" select="'UI'"/>
<xsl:with-param name="val" select="string(field[1]/text())"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="ZDS" mode="sps">
<!-- Scheduled Station AE -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00400001'"/>
<xsl:with-param name="vr" select="'AE'"/>
<xsl:with-param name="val" select="string(field[2]/text())"/>
</xsl:call-template>
<!-- Scheduled Station Name-->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00400010'"/>
<xsl:with-param name="vr" select="'SH'"/>
<xsl:with-param name="val" select="string(field[3]/text())"/>
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,482 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:include href="common.xsl"/>
<xsl:param name="VerifyingOrganization">Verifying Organization</xsl:param>
<xsl:template match="/hl7">
<dataset>
<xsl:call-template name="const-attrs"/>
<!--SOP Instance UID-->
<attr tag="00080018" vr="UI">
<xsl:value-of
select="OBX[field[3]/component='SR Instance UID']/field[5]"/>
</attr>
<xsl:apply-templates select="PID"/>
<xsl:apply-templates select="OBR"/>
<!--Current Requested Procedure Evidence Sequence-->
<attr tag="0040A375" vr="SQ">
<xsl:apply-templates
select="OBX[field[3]/component='Study Instance UID']" mode="refstudy"
/>
</attr>
<!--Content Sequence-->
<attr tag="0040A730" vr="SQ">
<xsl:call-template name="const-obsctx"/>
<xsl:apply-templates select="OBR" mode="obsctx"/>
<xsl:apply-templates select="OBX[field[3]/component='SR Text']"
mode="txt"/>
<xsl:if test="OBX[field[3]/component='SOP Instance UID']">
<item>
<!--Relationship Type-->
<attr tag="0040A010" vr="CS">CONTAINS</attr>
<!--Value Type-->
<attr tag="0040A040" vr="CS">CONTAINER</attr>
<!--Concept Name Code Sequence-->
<attr tag="0040A043">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">121180</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">DCM</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">Key Images</attr>
</item>
</attr>
<!--Continuity Of Content-->
<attr tag="0040A050" vr="CS">SEPARATE</attr>
<!--Content Sequence-->
<attr tag="0040A730" vr="SQ">
<xsl:apply-templates
select="OBX[field[3]/component='SOP Instance UID']" mode="img"/>
</attr>
</item>
</xsl:if>
</attr>
</dataset>
</xsl:template>
<xsl:template name="const-attrs">
<!-- Specific Character Set -->
<attr tag="00080005" vr="CS">ISO_IR 100</attr>
<!--SOP Class UID-->
<attr tag="00080016" vr="UI">1.2.840.10008.5.1.4.1.1.88.11</attr>
<!--Study Date-->
<attr tag="00080020" vr="DA"/>
<!--Study Time-->
<attr tag="00080030" vr="TM"/>
<!--Accession Number-->
<attr tag="00080050" vr="SH"/>
<!--Modality-->
<attr tag="00080060" vr="CS">SR</attr>
<!--Manufacturer-->
<attr tag="00080070" vr="LO"/>
<!--Referring Physician's Name-->
<attr tag="00080090" vr="PN"/>
<!--Referenced Performed Procedure Step Sequence-->
<attr tag="00081111" vr="SQ"/>
<!--Study ID-->
<attr tag="00200010" vr="SH"/>
<!--Series Number-->
<attr tag="00200011" vr="IS"/>
<!--Instance Number-->
<attr tag="00200013" vr="IS">1</attr>
<!--Value Type-->
<attr tag="0040A040" vr="CS">CONTAINER</attr>
<!--Concept Name Code Sequence-->
<attr tag="0040A043" vr="SQ">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">11528-7</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">LN</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">Radiology Report</attr>
</item>
</attr>
<!--Continuity Of Content-->
<attr tag="0040A050" vr="CS">SEPARATE</attr>
<!--Content Template Sequence-->
<attr tag="0040A504" vr="SQ"/>
</xsl:template>
<xsl:template match="OBR">
<!--Content Date/Time-->
<xsl:call-template name="attrDATM">
<xsl:with-param name="datag">00080023</xsl:with-param>
<xsl:with-param name="tmtag">00080033</xsl:with-param>
<xsl:with-param name="val" select="field[7]"/>
</xsl:call-template>
<!-- Take Study Instance UID from first referenced Image - if available -->
<xsl:variable name="suid"
select="normalize-space(../OBX[field[3]/component='Study Instance UID'][1]/field[5])"/>
<!-- Study Instance UID -->
<attr tag="0020000D" vr="UI">
<xsl:value-of select="$suid"/>
</attr>
<!--Referenced Request Sequence-->
<attr tag="0040A370" vr="SQ">
<item>
<!--Accession Number-->
<attr tag="00080050" vr="SH"/>
<!--Referenced Study Sequence-->
<attr tag="00081110" vr="SQ"/>
<!--Study Instance UID-->
<xsl:value-of select="$suid"/>
<!--Requested Procedure Description-->
<attr tag="00321060" vr="LO">
<xsl:value-of select="field[4]/component"/>
</attr>
<!--Requested Procedure Code Sequence-->
<attr tag="00321064" vr="SQ">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">
<xsl:value-of select="field[4]"/>
</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">
<xsl:value-of select="field[4]/component[2]"/>
</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">
<xsl:value-of select="field[4]/component"/>
</attr>
</item>
</attr>
<!--Requested Procedure ID-->
<attr tag="00401001" vr="SH"/>
<!--Placer Order Number / Imaging Service Request-->
<attr tag="00402016" vr="LO">
<xsl:value-of select="field[2]"/>
</attr>
<!--Filler Order Number / Imaging Service Request-->
<attr tag="00402017" vr="LO">
<xsl:value-of select="field[3]"/>
</attr>
</item>
</attr>
<!-- Verifying Observer Sequence -->
<attr tag="0040A073" vr="SQ">
<item>
<!-- Verifying Organization -->
<attr tag="0040A027" vr="LO">
<xsl:value-of select="$VerifyingOrganization"/>
</attr>
<!-- Verification DateTime -->
<attr tag="0040A030" vr="DT">
<xsl:value-of select="field[7]"/>
</attr>
<!-- Verifying Observer Name -->
<xsl:choose>
<xsl:when test="field[32]/component">
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'0040A075'"/>
<xsl:with-param name="cn" select="field[32]"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<attr tag="0040A075" vr="PN">UNKOWN</attr>
</xsl:otherwise>
</xsl:choose>
<!-- Verifying Observer Identification Code Sequence -->
<attr tag="0040A088" vr="SQ"/>
</item>
</attr>
<xsl:variable name="resultStatus" select="normalize-space(field[25])"/>
<!--Completion Flag-->
<attr tag="0040A491" vr="CS">
<xsl:choose>
<xsl:when test="$resultStatus='P'">PARTIAL</xsl:when>
<xsl:otherwise>COMPLETE</xsl:otherwise>
</xsl:choose>
</attr>
<!--Verification Flag-->
<attr tag="0040A493" vr="CS">
<xsl:choose>
<xsl:when test="$resultStatus='P' or $resultStatus='F'">VERIFIED</xsl:when>
<xsl:otherwise>UNVERIFIED</xsl:otherwise>
</xsl:choose>
</attr>
</xsl:template>
<xsl:template name="const-obsctx">
<item>
<!--Relationship Type-->
<attr tag="0040A010" vr="CS">HAS CONCEPT MOD</attr>
<!--Value Type-->
<attr tag="0040A040" vr="CS">CODE</attr>
<!--Concept Name Code Sequence-->
<attr tag="0040A043" vr="SQ">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">121049</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">DCM</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">Language of Content Item and
Descendants</attr>
</item>
</attr>
<!--Concept Code Sequence-->
<attr tag="0040A168" vr="SQ">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">eng</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">ISO639_2</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">English</attr>
</item>
</attr>
</item>
</xsl:template>
<xsl:template match="OBR" mode="obsctx">
<xsl:if test="field[32]/component">
<item>
<!--Relationship Type-->
<attr tag="0040A010" vr="CS">HAS OBS CONTEXT</attr>
<!--Value Type-->
<attr tag="0040A040" vr="CS">PNAME</attr>
<!--Concept Name Code Sequence-->
<attr tag="0040A043" vr="SQ">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">121008</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">DCM</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">Person Observer Name</attr>
</item>
</attr>
<!--Person Name-->
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'0040A123'"/>
<xsl:with-param name="cn" select="field[32]"/>
</xsl:call-template>
</item>
</xsl:if>
<item>
<!--Relationship Type-->
<attr tag="0040A010" vr="CS">HAS OBS CONTEXT</attr>
<!--Value Type-->
<attr tag="0040A040" vr="CS">CODE</attr>
<!--Concept Name Code Sequence-->
<attr tag="0040A043" vr="SQ">
<item>
<attr tag="00080100" vr="SH">121023</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">DCM</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">Procedure Code</attr>
</item>
</attr>
<!--Concept Code Sequence-->
<attr tag="0040A168" vr="SQ">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">
<xsl:value-of select="field[4]"/>
</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">
<xsl:value-of select="field[4]/component[2]"/>
</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">
<xsl:value-of select="field[4]/component"/>
</attr>
</item>
</attr>
</item>
</xsl:template>
<xsl:template match="OBX" mode="refstudy">
<xsl:variable name="suid">
<xsl:value-of select="field[5]"/>
</xsl:variable>
<xsl:if test="not(preceding-sibling::*[field[5]=$suid])">
<item>
<!-- Study Instance UID -->
<attr tag="0020000D" vr="UI">
<xsl:value-of select="$suid"/>
</attr>
<!-- >Referenced Series Sequence (0008,1115) -->
<attr tag="00081115" vr="SQ">
<xsl:apply-templates
select="../OBX[field[5]=$suid]/following-sibling::*[1]"
mode="refseries"/>
</attr>
</item>
</xsl:if>
</xsl:template>
<xsl:template match="OBX" mode="refseries">
<xsl:variable name="suid">
<xsl:value-of select="field[5]"/>
</xsl:variable>
<xsl:if test="not(preceding-sibling::*[field[5]=$suid])">
<item>
<!-- Series Instance UID -->
<attr tag="0020000E" vr="UI">
<xsl:value-of select="$suid"/>
</attr>
<!-- Referenced SOP Sequence -->
<attr tag="00081199" vr="SQ">
<xsl:apply-templates
select="../OBX[field[5]=$suid]/following-sibling::*[1]"
mode="refsop"/>
</attr>
</item>
</xsl:if>
</xsl:template>
<xsl:template match="OBX" mode="refsop">
<item>
<!--Referenced SOP Class UID-->
<attr tag="00081150" vr="UI">
<xsl:value-of select="following-sibling::*[1]/field[5]"/>
</attr>
<!--Referenced SOP Instance UID-->
<attr tag="00081155" vr="UI">
<xsl:value-of select="field[5]"/>
</attr>
</item>
</xsl:template>
<xsl:template match="OBX" mode="img">
<item>
<!--Referenced SOP Sequence-->
<attr tag="00081199" vr="SQ">
<item>
<!--Referenced SOP Class UID-->
<attr tag="00081150" vr="UI">
<xsl:value-of select="following-sibling::*[1]/field[5]"/>
</attr>
<!--Referenced SOP Instance UID-->
<attr tag="00081155" vr="UI">
<xsl:value-of select="field[5]"/>
</attr>
</item>
</attr>
<!--Relationship Type-->
<attr tag="0040A010" vr="CS">CONTAINS</attr>
<!--Value Type-->
<attr tag="0040A040" vr="CS">IMAGE</attr>
</item>
</xsl:template>
<xsl:template match="OBX" mode="txt">
<xsl:variable name="text">
<xsl:apply-templates select="field[5]" mode="txt"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="starts-with($text, 'History')">
<xsl:call-template name="text">
<xsl:with-param name="hcode">121060</xsl:with-param>
<xsl:with-param name="hname">History</xsl:with-param>
<xsl:with-param name="ecode">121060</xsl:with-param>
<xsl:with-param name="ename">History</xsl:with-param>
<xsl:with-param name="text" select="substring($text,9)"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="starts-with($text, 'Findings')">
<xsl:call-template name="text">
<xsl:with-param name="hcode">121070</xsl:with-param>
<xsl:with-param name="hname">Findings</xsl:with-param>
<xsl:with-param name="ecode">121071</xsl:with-param>
<xsl:with-param name="ename">Finding</xsl:with-param>
<xsl:with-param name="text" select="substring($text,10)"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="starts-with($text, 'Conclusions')">
<xsl:call-template name="text">
<xsl:with-param name="hcode">121076</xsl:with-param>
<xsl:with-param name="hname">Conclusions</xsl:with-param>
<xsl:with-param name="ecode">121077</xsl:with-param>
<xsl:with-param name="ename">Conclusion</xsl:with-param>
<xsl:with-param name="text" select="substring($text,13)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="text">
<xsl:with-param name="text" select="$text"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="text()" mode="txt">
<xsl:value-of select='.'/>
</xsl:template>
<xsl:template match="escape" mode="txt">
<xsl:choose>
<xsl:when test="text()='.br'">
<xsl:text>&#13;&#10;</xsl:text>
</xsl:when>
<xsl:when test="text()='F'">
<xsl:text>|</xsl:text>
</xsl:when>
<xsl:when test="text()='S'">
<xsl:text>^</xsl:text>
</xsl:when>
<xsl:when test="text()='T'">
<xsl:text>&amp;</xsl:text>
</xsl:when>
<xsl:when test="text()='R'">
<xsl:text>~</xsl:text>
</xsl:when>
<xsl:when test="text()='E'">
<xsl:text>\\</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template name="text">
<xsl:param name="hcode">121070</xsl:param>
<xsl:param name="hname">Findings</xsl:param>
<xsl:param name="ecode">121071</xsl:param>
<xsl:param name="ename">Finding</xsl:param>
<xsl:param name="text"/>
<item>
<!--Relationship Type-->
<attr tag="0040A010" vr="CS">CONTAINS</attr>
<!--Value Type-->
<attr tag="0040A040" vr="CS">CONTAINER</attr>
<!--Concept Name Code Sequence-->
<attr tag="0040A043">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">
<xsl:value-of select="$hcode"/>
</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">DCM</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">
<xsl:value-of select="$hname"/>
</attr>
</item>
</attr>
<!--Continuity Of Content-->
<attr tag="0040A050" vr="CS">SEPARATE</attr>
<!--Content Sequence-->
<attr tag="0040A730" vr="SQ">
<item>
<!--Relationship Type-->
<attr tag="0040A010" vr="CS">CONTAINS</attr>
<!--Value Type-->
<attr tag="0040A040" vr="CS">TEXT</attr>
<!--Concept Name Code Sequence-->
<attr tag="0040A043" vr="SQ">
<item>
<!--Code Value-->
<attr tag="00080100" vr="SH">
<xsl:value-of select="$ecode"/>
</attr>
<!--Coding Scheme Designator-->
<attr tag="00080102" vr="SH">DCM</attr>
<!--Code Meaning-->
<attr tag="00080104" vr="LO">
<xsl:value-of select="$ename"/>
</attr>
</item>
</attr>
<!--Text Value-->
<attr tag="0040A160" vr="UT">
<xsl:value-of select="$text"/>
</attr>
</item>
</attr>
</item>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:include href="common.xsl"/>
<xsl:template match="/hl7">
<dataset>
<attr tag="00080005" vr="CS">ISO_IR 100</attr>
<xsl:apply-templates select="PID"/>
</dataset>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,118 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
XML Format:
<prefetch>
<hl7>
...
</hl7>
<dataset>
....
</dataset>
...
</prefetch>
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:include href="common.xsl"/>
<xsl:template match="/prefetch">
<prefetch>
<xsl:choose>
<xsl:when test="string(hl7/OBR[1]/field[44]/text())='TEST_KO'">
<xsl:apply-templates select="dataset[attr[@tag='00080060']='KO']"/>
</xsl:when>
<xsl:when test="string(hl7/OBR[1]/field[44]/text())='TEST_LAST3_CR'">
<xsl:apply-templates select="dataset[attr[@tag='00080060']='CR']">
<xsl:sort select="attr[@tag='00080020']" order="descending"/>
<xsl:sort select="attr[@tag='00080021']" order="descending"/>
<xsl:sort select="attr[@tag='00080030']" order="descending"/>
<xsl:sort select="attr[@tag='00080031']" order="descending"/>
<xsl:with-param name="max" select="5"/>
<xsl:with-param name="reason" select="'TEST_LAST3_CR'"/>
</xsl:apply-templates>
</xsl:when>
<xsl:when test="string(hl7/OBR[1]/field[44]/text())='TEST_DATERANGE'">
<xsl:apply-templates
select="dataset[attr[@tag='00080020'] &gt;20080101 and attr[@tag='00080020'] &lt; 20081212]"
/>
</xsl:when>
<xsl:when test="string(hl7/OBR[1]/field[44]/text())='MAX_WITH_KEEP_STUDY'">
<xsl:apply-templates select="dataset" mode="keep_study">
<xsl:sort select="attr[@tag='0020000D']" order="ascending"/>
<xsl:with-param name="max" select="2"/>
<xsl:with-param name="reason" select="'ALL: MAX_WITH_KEEP_STUDY'"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="dataset">
<xsl:with-param name="max" select="-1"/>
<xsl:with-param name="reason" select="'default (ALL)'"/>
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
</prefetch>
</xsl:template>
<xsl:template match="dataset">
<xsl:param name="max" select="999"/>
<xsl:param name="reason"/>
<xsl:if test="$max = -1 or position() &lt;= $max">
<xsl:call-template name="schedule">
<xsl:with-param name="seriesUID" select="attr[@tag='0020000E']"/>
<xsl:with-param name="scheduleAt" select="/prefetch/hl7/ORC[1]/field[9]"/>
<xsl:with-param name="reason" select="$reason"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template match="dataset" mode="keep_study">
<xsl:param name="max" select="999"/>
<xsl:param name="reason"/>
<xsl:if test="position() &lt;= $max">
<xsl:call-template name="schedule">
<xsl:with-param name="seriesUID" select="attr[@tag='0020000E']"/>
<xsl:with-param name="scheduleAt" select="/prefetch/hl7/ORC[1]/field[9]"/>
<xsl:with-param name="reason" select="$reason"/>
</xsl:call-template>
</xsl:if>
<xsl:if test="position() = $max">
<xsl:apply-templates select="following-sibling::dataset" mode="study_iuid">
<xsl:with-param name="study_iuid" select="attr[@tag='0020000D']"/>
<xsl:with-param name="reason" select="$reason"/>
</xsl:apply-templates>
</xsl:if>
</xsl:template>
<xsl:template match="dataset" mode="study_iuid">
<xsl:param name="study_iuid" select="xxx"/>
<xsl:param name="reason"/>
<xsl:if test="attr[@tag='0020000D'] = $study_iuid">
<xsl:call-template name="schedule">
<xsl:with-param name="seriesUID" select="attr[@tag='0020000E']"/>
<xsl:with-param name="scheduleAt" select="/prefetch/hl7/ORC[1]/field[9]"/>
<xsl:with-param name="reason" select="$reason"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="schedule">
<xsl:param name="seriesUID"/>
<xsl:param name="scheduleAt"/>
<xsl:param name="reason"/>
<schedule>
<xsl:attribute name="seriesIUID">
<xsl:value-of select="$seriesUID"/>
</xsl:attribute>
<xsl:if test="string-length(string($scheduleAt)) > 0">
<xsl:attribute name="scheduleAt">
<xsl:value-of select="$scheduleAt"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="string-length(string($reason)) > 0">
<xsl:attribute name="reason">
<xsl:value-of select="$reason"/>
</xsl:attribute>
</xsl:if>
</schedule>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,238 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:include href="common.xsl"/>
<!-- root -->
<xsl:template match="/hl7">
<dataset>
<attr tag="00080005" vr="CS">ISO_IR 100</attr>
<xsl:apply-templates select="PID"/>
<xsl:apply-templates select="PV1"/>
<xsl:apply-templates select="AL1"/>
<xsl:apply-templates select="ORC[1]"/>
<xsl:apply-templates select="OBR[1]"/>
<!-- Scheduled Procedure Step Sequence -->
<attr tag="00400100" vr="SQ">
<xsl:apply-templates select="ORC" mode="sps"/>
</attr>
</dataset>
</xsl:template>
<!-- PV1 -->
<xsl:template match="PV1">
<!-- HL7:Assigned Patient Location.1 -> DICOM:Requesting Service -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00321033'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="substring(field[3]/text(),1,64)"/>
</xsl:call-template>
<!-- HL7:Referring Doctor -> DICOM:Referring Physican Name
(may replace HL7:Ordering Provider -> DICOM:Referring Physican Name mapping)
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'00080090'"/>
<xsl:with-param name="cn" select="field[8]"/>
</xsl:call-template>
-->
<!-- HL7:Ambulatory Status -> DICOM:Pregnancy Status -->
<xsl:call-template name="pregnancyStatus">
<xsl:with-param name="ambulantStatus" select="string(field[15]/text())"/>
</xsl:call-template>
<!-- HL7:Visit Number -> DICOM:Admission ID + Issuer -->
<xsl:call-template name="cx2attrs">
<xsl:with-param name="idtag" select="'00380010'"/>
<xsl:with-param name="istag" select="'00380011'"/>
<xsl:with-param name="cx" select="field[19]"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="pregnancyStatus">
<xsl:param name="ambulantStatus"/>
<xsl:if test="normalize-space($ambulantStatus)">
<attr tag="001021C0" vr="US">
<xsl:if test="$ambulantStatus = 'B6'">3</xsl:if>
</attr>
</xsl:if>
</xsl:template>
<!-- AL1 -->
<xsl:template match="AL1">
<!-- HL7:Allergy Code/Mnemonic/Description -> Medical Alerts + Contrast Allergies -->
<xsl:variable name="al1_3" select="string(field[3]/text())"/>
<xsl:choose>
<xsl:when test="$al1_3 = '&quot;&quot;'">
<attr tag="00102000" vr="LO"/>
<attr tag="00102110" vr="LO"/>
</xsl:when>
<xsl:when test="$al1_3">
<attr tag="00102000" vr="LO">
<xsl:value-of select="substring(substring-after($al1_3,'$'),1,64)"/>
</attr>
<attr tag="00102110" vr="LO">
<xsl:value-of select="substring(substring-before($al1_3,'$'),1,64)"/>
</attr>
</xsl:when>
</xsl:choose>
</xsl:template>
<!-- ORC[1] -->
<xsl:template match="ORC[1]">
<!-- HL7:Ordering Provider -> DICOM Referring Physican Name -->
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'00080090'"/>
<xsl:with-param name="cn" select="field[12]"/>
</xsl:call-template>
<!-- HL7:Ordering Provider -> DICOM Requesting Physician -->
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'00321032'"/>
<xsl:with-param name="cn" select="field[12]"/>
</xsl:call-template>
<!-- HL7:Quantity/Timing -> DICOM:Requested Procedure Priority -->
<xsl:call-template name="procedurePriority">
<xsl:with-param name="priority" select="string(field[7]/component[5]/text())"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="procedurePriority">
<xsl:param name="priority"/>
<xsl:if test="normalize-space($priority)">
<attr tag="00401003" vr="CS">
<xsl:choose>
<xsl:when test="$priority = 'S'">STAT</xsl:when>
<xsl:when test="$priority = 'A' or $priority = 'P' or $priority = 'C' ">HIGH</xsl:when>
<xsl:when test="$priority = 'R'">ROUTINE</xsl:when>
<xsl:when test="$priority = 'T'">MEDIUM</xsl:when>
</xsl:choose>
</attr>
</xsl:if>
</xsl:template>
<!-- OBR[1] -->
<xsl:template match="OBR[1]">
<xsl:variable name="ordno" select="string(field[3]/text())"/>
<!-- HL7:Filler Order Number -> DICOM:Placer Order Number -->
<attr tag="00402016" vr="LO">
<xsl:value-of select="$ordno"/>
</attr>
<!-- HL7:Filler Order Number -> DICOM:Filler Order Number -->
<attr tag="00402017" vr="LO">
<xsl:value-of select="$ordno"/>
</attr>
<!-- HL7:Filler Order Number -> DICOM:Accession Number -->
<attr tag="00080050" vr="SH">
<xsl:value-of select="$ordno"/>
</attr>
<!-- HL7:Danger Code -> DICOM:Patient State -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00380500'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="substring(field[12]/text(),1,64)"/>
</xsl:call-template>
<!-- HL7:Relevant Clinical Info -> DICOM:Reason for the Requested Procedure + Admitting Diagnoses Description -->
<xsl:variable name="obr13" select="normalize-space(field[13])"/>
<xsl:choose>
<xsl:when test="$obr13 = '&quot;&quot;'">
<attr tag="00081080" vr="LO"/>
<attr tag="00401002" vr="LO"/>
</xsl:when>
<xsl:when test="$obr13">
<attr tag="00081080" vr="LO">
<xsl:value-of select="substring(substring-after(substring-after(substring-after($obr13,'$'),'$'),'$'),1,64)"/>
</attr>
<attr tag="00401002" vr="LO">
<xsl:value-of select="substring(substring-before(substring-after($obr13,'$'),'$'),1,64)"/>
</attr>
</xsl:when>
</xsl:choose>
<!-- HL7:Transportation Mode -> DICOM:Patient Transport Arrangements -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00401004'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="substring(field[30]/text(),1,64)"/>
</xsl:call-template>
</xsl:template>
<!-- ORC - sps -->
<xsl:template match="ORC" mode="sps">
<item>
<!-- HL7:Entering Device -> DICOM:Scheduled Station Name -->
<xsl:call-template name="attr">
<xsl:with-param name="tag">00400010</xsl:with-param>
<xsl:with-param name="vr">SH</xsl:with-param>
<xsl:with-param name="val" select="substring(field[18]/text(),1,16)"/>
</xsl:call-template>
<!-- HL7:Entering Device -> DICOM:Modality -->
<xsl:call-template name="attr">
<xsl:with-param name="tag">00080060</xsl:with-param>
<xsl:with-param name="vr">CS</xsl:with-param>
<xsl:with-param name="val" select="substring(field[18]/component/text(),1,16)"/>
</xsl:call-template>
<xsl:apply-templates select="following-sibling::OBR[1]" mode="sps"/>
</item>
</xsl:template>
<!-- OBR - sps -->
<xsl:template match="OBR" mode="sps">
<!-- HL7:Results Rpt/Status Chng - Date/Time -> DICOM:Scheduled Procedure Step Start Date/Time -->
<xsl:variable name="obr36" select="normalize-space(field[36]/text())"/>
<xsl:variable name="dt">
<xsl:choose>
<xsl:when test="$obr36">
<xsl:value-of select="$obr36"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="normalize-space(field[22]/text())"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="string-length($dt) >= 8">
<xsl:call-template name="attrDATM">
<xsl:with-param name="datag" select="'00400002'"/>
<xsl:with-param name="tmtag" select="'00400003'"/>
<xsl:with-param name="val">
<xsl:value-of select="$dt"/>
<xsl:if test="string-length($dt) &lt; 10">00</xsl:if>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
<!-- HL7:Filler Order Number -> DICOM:Study Instance UID -->
<xsl:variable name="suid" select="string(field[3]/component[2]/text())"/>
<attr tag="0020000D" vr="UI">
<xsl:value-of select="$suid"/>
</attr>
<!-- Study Instance UID -> DICOM:Requested Procedure -->
<xsl:variable name="id"
select="substring(substring-after(substring-after(substring-after(substring-after(substring($suid,17),'.'),'.'),'.'),'.'),1,16)"/>
<attr tag="00401001" vr="SH">
<xsl:value-of select="$id"/>
</attr>
<!-- Study Instance UID -> DICOM:Scheduled Procedure Step ID -->
<attr tag="00400009" vr="SH">
<xsl:value-of select="$id"/>
</attr>
<!-- HL7:Universal Service Identifier.2 -> DICOM:Requested Procedure Description -->
<xsl:variable name="desc" select="substring(field[4]/component[2]/text(),1,64)"/>
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00321060'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="$desc"/>
</xsl:call-template>
<!-- HL7:Universal Service Identifier -> DICOM:Requested Procedure Code -->
<xsl:call-template name="codeItem">
<xsl:with-param name="sqtag" select="'00321064'"/>
<xsl:with-param name="code" select="string(field[4]/text())"/>
<xsl:with-param name="scheme" select="'99ORBIS'"/>
<xsl:with-param name="meaning" select="$desc"/>
</xsl:call-template>
<!-- HL7:Universal Service Identifier.2 -> DICOM:Scheduled Procedure Step Description -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00400007'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="$desc"/>
</xsl:call-template>
<!-- HL7:Universal Service Identifier -> DICOM:Scheduled Protocol Code -->
<xsl:call-template name="codeItem">
<xsl:with-param name="sqtag" select="'00400008'"/>
<xsl:with-param name="code" select="string(field[4]/text())"/>
<xsl:with-param name="scheme" select="'99ORBIS'"/>
<xsl:with-param name="meaning" select="$desc"/>
</xsl:call-template>
<!-- HL7:Technician -> Scheduled Performing Physican Name -->
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'00400006'"/>
<xsl:with-param name="cn" select="field[34]"/>
<xsl:with-param name="cn26" select="field[34]/subcomponent"/>
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,39 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:include href="common_send.xsl"/>
<xsl:template match="/">
<xsl:apply-templates select="dataset"/>
<xsl:apply-templates select="/dicomfile/dataset"/>
</xsl:template>
<xsl:template match="dataset">
<xsl:call-template name="MSH">
<xsl:with-param name="msgType" select="'ORM^O01'"/>
</xsl:call-template>
<xsl:apply-templates select="." mode="dcm2PID" />
<xsl:apply-templates select="." mode="dcm2PV1" />
<xsl:apply-templates select="." mode="dcm2ORC" />
<xsl:variable name="reqProcCode">
<xsl:call-template name="codeOrDescr">
<xsl:with-param name="descrTag" select="attr[@tag='00321060']"/> <!-- Requested Procedure Description -->
<xsl:with-param name="codeTag" select="attr[@tag='00321064']"/> <!-- Requested Procedure Code Sequence -->
</xsl:call-template>
</xsl:variable>
<xsl:variable name="schedProtocolCode">
<xsl:call-template name="codeOrDescr">
<xsl:with-param name="descrTag" select="attr[@tag='00400100']/item/attr[@tag='00400007']"/> <!-- Scheduled Procedure Step Description -->
<xsl:with-param name="codeTag" select="attr[@tag='00400100']/item/attr[@tag='00400008']"/> <!-- Scheduled Protocol Code Sequence -->
</xsl:call-template>
</xsl:variable>
<xsl:apply-templates select="." mode="dcm2OBR" >
<xsl:with-param name="placerField1" select="attr[@tag='00080050']"/> <!-- Accession Number -->
<xsl:with-param name="placerField2" select="attr[@tag='00401001']"/> <!-- Requested Procedure ID -->
<xsl:with-param name="clinicalInfo" select="attr[@tag='00102000']"/> <!-- Medical Alerts -->
<xsl:with-param name="orderingProvider" select="attr[@tag='00321032']"/> <!-- Requesting Physician -->
<xsl:with-param name="requestedProcedureCode" select="$reqProcCode"/> <!-- Requesting Physician -->
<xsl:with-param name="transportationMode" select="attr[@tag='00401004']"/> <!-- Patient Transport Arrangements -->
<xsl:with-param name="diagnService" select="attr[@tag='00400100']/item/attr[@tag='00080060']"/> <!-- Modality -->
<xsl:with-param name="fillerField1" select="attr[@tag='00400100']/item/attr[@tag='00400009']"/> <!-- Scheduled Procedure Step ID-->
<xsl:with-param name="universalServiceId" select="$schedProtocolCode"/> <!-- Scheduled Protocol Code / Descr -->
</xsl:apply-templates>
<xsl:apply-templates select="." mode="dcm2ZDS" />
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,282 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:include href="common.xsl"/>
<xsl:variable name="suid-prefix" select="'1.2.4.0.13.1.4.2252867.'"/>
<xsl:template match="/hl7">
<dataset>
<attr tag="00080005" vr="CS">ISO_IR 100</attr>
<xsl:apply-templates select="PID"/>
<xsl:apply-templates select="PV1"/>
<xsl:apply-templates select="ORC[1]"/>
<xsl:apply-templates select="OBR[1]"/>
<!-- Scheduled Procedure Step Sequence -->
<attr tag="00400100" vr="SQ">
<xsl:apply-templates select="ORC" mode="sps"/>
</attr>
</dataset>
</xsl:template>
<xsl:template match="PV1">
<!-- Referring Physican Name
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'00080090'"/>
<xsl:with-param name="cn" select="field[8]"/>
</xsl:call-template>
-->
<xsl:call-template name="pregnancyStatus">
<xsl:with-param name="ambulantStatus" select="field[15]/text()"/>
</xsl:call-template>
<!-- Admission ID, Issuer -->
<xsl:call-template name="cx2attrs">
<xsl:with-param name="idtag" select="'00380010'"/>
<xsl:with-param name="istag" select="'00380011'"/>
<xsl:with-param name="cx" select="field[19]"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="pregnancyStatus">
<xsl:param name="ambulantStatus"/>
<xsl:if test="normalize-space($ambulantStatus)">
<attr tag="001021C0" vr="US">
<xsl:if test="$ambulantStatus = 'B6'">3</xsl:if>
</attr>
</xsl:if>
</xsl:template>
<xsl:template match="ORC[1]">
<!-- Placer Order Number -->
<xsl:call-template name="ei2attr">
<xsl:with-param name="tag" select="'00402016'"/>
<xsl:with-param name="ei" select="field[2]"/>
</xsl:call-template>
<!-- Use Placer Order Number as Filler Order Number -->
<xsl:call-template name="ei2attr">
<xsl:with-param name="tag" select="'00402017'"/>
<xsl:with-param name="ei" select="field[2]"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="procedurePriority">
<xsl:param name="priority"/>
<xsl:if test="normalize-space($priority)">
<attr tag="00401003" vr="CS">
<xsl:choose>
<xsl:when test="$priority = 'S'">STAT</xsl:when>
<xsl:when test="$priority = 'A' or $priority = 'P' or $priority = 'C' ">HIGH</xsl:when>
<xsl:when test="$priority = 'R'">ROUTINE</xsl:when>
<xsl:when test="$priority = 'T'">MEDIUM</xsl:when>
</xsl:choose>
</attr>
</xsl:if>
</xsl:template>
<xsl:template match="OBR[1]">
<!-- Use Placer Order Number as Accession Number if missing OBR-18 -->
<xsl:variable name="accno">
<xsl:choose>
<xsl:when test="field[18]/text()">
<xsl:value-of select="string(field[18]/text())"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="string(field[2]/text())"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00080050'"/>
<xsl:with-param name="vr" select="'SH'"/>
<xsl:with-param name="val" select="$accno"/>
</xsl:call-template>
<!-- Provide Requesting Physician also as Referring Physican Name -->
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'00080090'"/>
<xsl:with-param name="cn" select="field[16]"/>
</xsl:call-template>
<!-- Medical Alerts -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00102000'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="string(field[13]/text())"/>
</xsl:call-template>
<!-- Requesting Physician -->
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'00321032'"/>
<xsl:with-param name="cn" select="field[16]"/>
</xsl:call-template>
<!-- (0032,1033) Requesting Service
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00321033'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="'Requesting Service'"/>
</xsl:call-template>
-->
<!-- Patient State -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00380500'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="string(field[12]/text())"/>
</xsl:call-template>
<!-- Patient Transport Arrangements -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00401004'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="string(field[30]/text())"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="ORC" mode="sps">
<item>
<!-- Use Placer Order Number.position() as Scheduled Procedure Step ID -->
<xsl:variable name="spsid" select="concat(string(field[2]/text()),'.',position())"/>
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00400009'"/>
<xsl:with-param name="vr" select="'SH'"/>
<xsl:with-param name="val" select="$spsid"/>
</xsl:call-template>
<!-- Use SPS ID as Requested Procedure ID on SPS Level!-->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00401001'"/>
<xsl:with-param name="vr" select="'SH'"/>
<xsl:with-param name="val" select="$spsid"/>
</xsl:call-template>
<!-- Use SPS ID as Study Instance UID on SPS Level -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'0020000D'"/>
<xsl:with-param name="vr" select="'UI'"/>
<xsl:with-param name="val" select="concat($suid-prefix,$spsid)"/>
</xsl:call-template>
<!-- Insert Requested Procedure Priority on SPS Level -->
<xsl:call-template name="procedurePriority">
<xsl:with-param name="priority" select="string(field[7]/component[5]/text())"/>
</xsl:call-template>
<!-- Scheduled Procedure Step Start Date/Time -->
<xsl:call-template name="attrDATM">
<xsl:with-param name="datag" select="'00400002'"/>
<xsl:with-param name="tmtag" select="'00400003'"/>
<xsl:with-param name="val" select="string(field[7]/component[3]/text())"/>
</xsl:call-template>
<xsl:apply-templates select="following-sibling::OBR[1]" mode="sps"/>
</item>
</xsl:template>
<!-- specific device XX -->
<xsl:template match="OBR[field[24]/text()='XX']" mode="sps">
<!-- Use ORB-24 as Scheduled Station Name -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00400010'"/>
<xsl:with-param name="vr" select="'SH'"/>
<xsl:with-param name="val" select="string(field[24]/text())"/>
</xsl:call-template>
<!-- Scheduled Performing Physican Name -->
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'00400006'"/>
<xsl:with-param name="cn" select="field[34]"/>
<xsl:with-param name="cn26" select="field[34]/subcomponent"/>
</xsl:call-template>
<xsl:choose>
<!-- if OBR-4.2-4:6 are missing -->
<xsl:when test="count(field[4]/component) &lt; 5">
<!-- Use ORB-4.2 as Procedure Description as Scheduled Procedure Step -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00400007'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="string(field[4]/component[1]/text())"/>
</xsl:call-template>
<!-- Use ORB-4.1-3 as Scheduled Protocol Code -->
<xsl:call-template name="codeItem">
<xsl:with-param name="sqtag" select="'00400008'"/>
<xsl:with-param name="code" select="string(field[4]/text())"/>
<xsl:with-param name="scheme" select="string(field[4]/component[2]/text())"/>
<xsl:with-param name="meaning" select="string(field[4]/component[1]/text())"/>
</xsl:call-template>
</xsl:when>
<!-- treat according IHE -->
<xsl:otherwise>
<!-- Scheduled Procedure Step Description -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00400007'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="field[4]/component[4]"/>
</xsl:call-template>
<!-- Scheduled Protocol Code Sequence -->
<xsl:call-template name="codeItem">
<xsl:with-param name="sqtag" select="'00400008'"/>
<xsl:with-param name="code" select="string(field[4]/component[3]/text())"/>
<xsl:with-param name="scheme" select="string(field[4]/component[5]/text())"/>
<xsl:with-param name="meaning" select="string(field[4]/component[4]/text())"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<!-- Use ORB-4.2 as Requested Procedure Description on SPS Level! -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00321060'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="field[4]/component[1]"/>
</xsl:call-template>
<!-- Use ORB-4.1-3 as Requested Procedure Code Sequence on SPS Level-->
<xsl:call-template name="codeItem">
<xsl:with-param name="sqtag" select="'00321064'"/>
<xsl:with-param name="code" select="string(field[4]/text())"/>
<xsl:with-param name="scheme" select="string(field[4]/component[2]/text())"/>
<xsl:with-param name="meaning" select="string(field[4]/component[1]/text())"/>
</xsl:call-template>
</xsl:template>
<!-- other devices -->
<xsl:template match="OBR" mode="sps">
<!-- Use ORB-24 as Scheduled Station Name -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00400010'"/>
<xsl:with-param name="vr" select="'SH'"/>
<xsl:with-param name="val" select="string(field[24]/text())"/>
</xsl:call-template>
<!-- Scheduled Performing Physican Name -->
<xsl:call-template name="cn2pnAttr">
<xsl:with-param name="tag" select="'00400006'"/>
<xsl:with-param name="cn" select="field[34]"/>
<xsl:with-param name="cn26" select="field[34]/subcomponent"/>
</xsl:call-template>
<xsl:choose>
<!-- if OBR-4.2-4:6 are missing -->
<xsl:when test="count(field[4]/component) &lt; 5">
<!-- Use ORB-4.2 as Procedure Description as Scheduled Procedure Step -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00400007'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="string(field[4]/component[1]/text())"/>
</xsl:call-template>
<!-- Use ORB-4.1-3 as Scheduled Protocol Code -->
<xsl:call-template name="codeItem">
<xsl:with-param name="sqtag" select="'00400008'"/>
<xsl:with-param name="code" select="string(field[4]/text())"/>
<xsl:with-param name="scheme" select="string(field[4]/component[2]/text())"/>
<xsl:with-param name="meaning" select="string(field[4]/component[1]/text())"/>
</xsl:call-template>
</xsl:when>
<!-- treat according IHE -->
<xsl:otherwise>
<!-- Scheduled Procedure Step Description -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00400007'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="string(field[4]/component[4]/text())"/>
</xsl:call-template>
<!-- Scheduled Protocol Code Sequence -->
<xsl:call-template name="codeItem">
<xsl:with-param name="sqtag" select="'00400008'"/>
<xsl:with-param name="code" select="string(field[4]/component[3]/text())"/>
<xsl:with-param name="scheme" select="string(field[4]/component[5]/text())"/>
<xsl:with-param name="meaning" select="string(field[4]/component[4]/text())"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
<!-- Use ORB-4.2 as Requested Procedure Description on SPS Level! -->
<xsl:call-template name="attr">
<xsl:with-param name="tag" select="'00321060'"/>
<xsl:with-param name="vr" select="'LO'"/>
<xsl:with-param name="val" select="string(field[4]/component[1]/text())"/>
</xsl:call-template>
<!-- Use ORB-4.1-3 as Requested Procedure Code Sequence on SPS Level-->
<xsl:call-template name="codeItem">
<xsl:with-param name="sqtag" select="'00321064'"/>
<xsl:with-param name="code" select="string(field[4]/text())"/>
<xsl:with-param name="scheme" select="string(field[4]/component[2]/text())"/>
<xsl:with-param name="meaning" select="string(field[4]/component[1]/text())"/>
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>