Steve Lener
Steve Lener

Reputation: 1

xsl NativeDicomModel Patient Name Tag Maintain Carets dcm4che

Good Evening!

I wrote a xsl to obtain Dicom Attributes from a DCM file, and have been able to map everything correctly except for the Patient Name. The value comes over, but the carets aren't there; it combines the LastName and FirstName. I wanted the carets to separate the LastName^FirstName^MiddleInitial^Suffix. I cannot for the life of me am able to code this value correctly.

Below is my code....

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
        <xsl:apply-templates select="NativeDicomModel"/>
    </xsl:template>
    <xsl:template match="NativeDicomModel|Item">
        <xsl:param name="level"></xsl:param>
        <xsl:value-of select="$level"/>

        <NativeDicomModel xml:space="preserve">
        <DicomAttribute keyword="PatientID" tag="00100020" vr="LO"><Value number="1"><xsl:value-of select="DicomAttribute[@tag='00100020']/Value"/></Value></DicomAttribute>
        <DicomAttribute keyword="PatientName" tag="00100010" vr="PN"><PersonName number="1"><Alphabetic><xsl:value-of select="DicomAttribute[@tag='00100010']"/></Alphabetic></PersonName></DicomAttribute>
        <DicomAttribute keyword="PatientBirthDate" tag="00100030" vr="DA"><Value number="1"><xsl:value-of select="DicomAttribute[@tag='00100030']/Value"/></Value></DicomAttribute>
        <DicomAttribute keyword="PatientSex" tag="00100040" vr="CS"><Value number="1"><xsl:value-of select="DicomAttribute[@tag='00100040']/Value"/></Value></DicomAttribute>
        <DicomAttribute keyword="StudyDate" tag="00080020" vr="DA"><Value number="1"><xsl:value-of select="DicomAttribute[@tag='00080020']/Value"/></Value></DicomAttribute>
        <DicomAttribute keyword="StudyTime" tag="00080030" vr="TM"><Value number="1">0000.000</Value></DicomAttribute>
        <DicomAttribute keyword="SeriesDate" tag="00080021" vr="DA"><Value number="1"><xsl:value-of select="DicomAttribute[@tag='00080020']/Value"/></Value></DicomAttribute>
        <DicomAttribute keyword="SeriesTime" tag="00080031" vr="TM"><Value number="1">0000.000</Value></DicomAttribute>
        <DicomAttribute keyword="ReferringPhysicianName" tag="00080090" vr="PN"><Value number="1"><xsl:value-of select="DicomAttribute[@tag='00080090']/Value"/></Value></DicomAttribute>
        <DicomAttribute keyword="StudyID" tag="00200010" vr="SH"><Value number="1"><xsl:value-of select="DicomAttribute[@tag='00200010']/Value"/></Value></DicomAttribute>
        <DicomAttribute keyword="AccessionNumber" tag="00080050" vr="SH"><Value number="1"><xsl:value-of select="DicomAttribute[@tag='00080050']/Value"/></Value></DicomAttribute>
        <DicomAttribute keyword="Modality" tag="00080060" vr="CS"><Value number="1">NM</Value></DicomAttribute>
        <DicomAttribute keyword="StudyDescription" tag="00081030" vr="LO"><Value number="1">DOCUMENTS</Value></DicomAttribute>
        <DicomAttribute keyword="SeriesDescription" tag="0008103E" vr="LO"><Value number="1">DOCUMENTS</Value></DicomAttribute>
        <DicomAttribute keyword="SeriesNumber" tag="00200011" vr="IS"><Value number="1">1</Value></DicomAttribute>
        <DicomAttribute keyword="Manufacturer" tag="00080070" vr="LO"><Value number="1"></Value></DicomAttribute>
        <DicomAttribute keyword="ConversionType" tag="00080064" vr="CS"><Value number="1">SD</Value></DicomAttribute>
        <DicomAttribute keyword="InstanceNumber" tag="00200013" vr="IS"><Value number="1">1</Value></DicomAttribute>
        <DicomAttribute keyword="BurnedInAnnotation" tag="00280301" vr="CS"><Value number="1">YES</Value></DicomAttribute>
        </NativeDicomModel>
    </xsl:template>
</xsl:stylesheet>

This is the line in question:

<DicomAttribute keyword="PatientName" tag="00100010" vr="PN"><PersonName number="1"><Alphabetic><xsl:value-of select="DicomAttribute[@tag='00100010']"/></Alphabetic></PersonName></DicomAttribute>

The Patient Name in the DCM is formatted as LastName^FirstName^MiddleInitial^Suffix. When I run the stylesheet, it combines those values into one name: LastNameFirstNameMiddleInitialSuffix

This code comes from the dcm4che version 5 toolset, and I am using the dcm2xml command to convert the DCM file into a XML so I can then further parse the values out.

Upvotes: -2

Views: 407

Answers (1)

Steve Lener
Steve Lener

Reputation: 1

I guess I needed to sleep it off.. I was able to figure this out.

For DicomAttribute[@tag='00100010'], there is four parts to it: The First Name, Middle Name, Last Name, and Suffix. If you just simply state the tag, it combines all four values. if you separate it out like this:

"DicomAttribute[@tag='00100010']/PersonName/Alphabetic/FamilyName"
"DicomAttribute[@tag='00100010']/PersonName/Alphabetic/GivenName"
"DicomAttribute[@tag='00100010']/PersonName/Alphabetic/MiddleName"
"DicomAttribute[@tag='00100010']/PersonName/Alphabetic/NamePrefix"

Instead of just saying

"DicomAttribute[@tag='00100010']/PersonName"

-or-

"DicomAttribute[@tag='00100010']"

-or-

"DicomAttribute[@tag='00100010']/Value"

It will parse it out correctly in the XML.

I found my answer by looking at line 25 on:

https://github.com/dcm4che/dcm4chee-arc-light/blob/master/dcm4chee-arc-conf-data/src/main/resources/dsr2text.xsl

Once I saw this line, then it made sense to create additional lines using the Dicom Convention when it comes to an Alphabetic Name.

I wanted to provide my research and solution for others so they don't have to go through the time that I did!

  • Steve :)

        <NativeDicomModel xml:space="preserve">
    
        <DicomAttribute keyword="PatientID" tag="00100020" vr="LO"><Value number="1"><xsl:value-of select="DicomAttribute[@tag='00100020']/Value"/></Value></DicomAttribute>
        <DicomAttribute keyword="PatientName" tag="00100010" vr="PN"><PersonName number="1"><Alphabetic>
        <FamilyName><xsl:value-of select="DicomAttribute[@tag='00100010']/PersonName/Alphabetic/FamilyName"/></FamilyName>
        <GivenName><xsl:value-of select="DicomAttribute[@tag='00100010']/PersonName/Alphabetic/GivenName"/></GivenName>
        <MiddleName><xsl:value-of select="DicomAttribute[@tag='00100010']/PersonName/Alphabetic/MiddleName"/></MiddleName>
        <NamePrefix><xsl:value-of select="DicomAttribute[@tag='00100010']/PersonName/Alphabetic/NamePrefix"/></NamePrefix>
        </Alphabetic>
        </PersonName>
        </DicomAttribute>
        <DicomAttribute keyword="PatientBirthDate" tag="00100030" vr="DA"><Value number="1"><xsl:value-of select="DicomAttribute[@tag='00100030']/Value"/></Value></DicomAttribute>
        <DicomAttribute keyword="PatientSex" tag="00100040" vr="CS"><Value number="1"><xsl:value-of select="DicomAttribute[@tag='00100040']/Value"/></Value></DicomAttribute>
        <DicomAttribute keyword="StudyDate" tag="00080020" vr="DA"><Value number="1"><xsl:value-of select="DicomAttribute[@tag='00080020']/Value"/></Value></DicomAttribute>
        <DicomAttribute keyword="StudyTime" tag="00080030" vr="TM"><Value number="1">0000.000</Value></DicomAttribute>
        <DicomAttribute keyword="SeriesDate" tag="00080021" vr="DA"><Value number="1"><xsl:value-of select="DicomAttribute[@tag='00080020']/Value"/></Value></DicomAttribute>
        <DicomAttribute keyword="SeriesTime" tag="00080031" vr="TM"><Value number="1">0000.000</Value></DicomAttribute>
        <DicomAttribute keyword="ReferringPhysicianName" tag="00080090" vr="PN"><Value number="1"><xsl:value-of select="DicomAttribute[@tag='00080090']/Value"/></Value></DicomAttribute>
        <DicomAttribute keyword="StudyID" tag="00200010" vr="SH"><Value number="1"><xsl:value-of select="DicomAttribute[@tag='00200010']/Value"/></Value></DicomAttribute>
        <DicomAttribute keyword="AccessionNumber" tag="00080050" vr="SH"><Value number="1"><xsl:value-of select="DicomAttribute[@tag='00080050']/Value"/></Value></DicomAttribute>
        <DicomAttribute keyword="Modality" tag="00080060" vr="CS"><Value number="1">NM</Value></DicomAttribute>
        <DicomAttribute keyword="StudyDescription" tag="00081030" vr="LO"><Value number="1">DOCUMENTS</Value></DicomAttribute>
        <DicomAttribute keyword="SeriesDescription" tag="0008103E" vr="LO"><Value number="1">DOCUMENTS</Value></DicomAttribute>
        <DicomAttribute keyword="SeriesNumber" tag="00200011" vr="IS"><Value number="1">1</Value></DicomAttribute>
        <DicomAttribute keyword="Manufacturer" tag="00080070" vr="LO"><Value number="1"></Value></DicomAttribute>
        <DicomAttribute keyword="ConversionType" tag="00080064" vr="CS"><Value number="1">SD</Value></DicomAttribute>
        <DicomAttribute keyword="InstanceNumber" tag="00200013" vr="IS"><Value number="1">1</Value></DicomAttribute>
        <DicomAttribute keyword="BurnedInAnnotation" tag="00280301" vr="CS"><Value number="1">YES</Value></DicomAttribute>
        </NativeDicomModel>
    </xsl:template>
    

Upvotes: 0

Related Questions