Sidebar

Can I rearrange the order of items in the html or human readable section of a cda.

0 votes
394 views
asked Nov 15, 2016 by brandon-w-8204 (33,270 points)
edited Nov 15, 2016 by michael-h-5027

I want to change the order of elements from: Code, Procedure Name, Date, Entry Date

to: Procedure Name, Code, Date, Entry Date

Starting with:

<ClinicalDocument>
   ...
   <component>
      <structuredBody>
         <component>
            <section>
               <code code="47519-4" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="Procedures"/>
               ...
               <text>
                  <table border="1" width="100%">
                     <thead>
                        <tr>
                           <th>Code</th>
                           <th>Procedure Name</th>

                           <th>Date</th>
                           <th>Entry Date</th>
                        </tr>
                     </thead>
                     <tbody>
                        <tr>
                           <td ID="Procedure1">CPT-93000</td>
                           <td>EKG w/ Interpretation</td>

                           <td>2009/08/28</td>
                           <td>2008/07/29</td>
                        </tr>
                        <tr>
                           <td ID="Procedure2">CPT-80061</td>
                           <td>Lipid Profile</td>

                           <td>2009/08/28</td>
                           <td>2008/07/29</td>
                        </tr>
                        ...
                     </tbody>
                  </table>
               </text>
               ...
            </section>
         </component>
      </structuredBody>
   </component>
</ClinicalDocument>

 

1 Answer

0 votes

You can reorder the html in the procedures with the following code:

 

// Use the Procedure LOINC to point to that section of the CDA
var procedureHtml = qie.parseXMLString(message.getNode('/ClinicalDocument/component/structuredBody/component/section[code/@code="47519-4"]/text/table'));

// Reorder header - By changing the name of the fields as needed
procedureHtml.setNode('/table/thead/tr/th[1]', 'Procedure Name');
procedureHtml.setNode('/table/thead/tr/th[2]', 'Code');

// Reorder data - By looping through each body element
var trCount = procedureHtml.getCount('/table/tbody/tr');
for (var i = 1; i <= trCount; i++) {
   var code = procedureHtml.getNode('/table/tbody/tr[' + i + ']/td[1]');
   var codeId = procedureHtml.getNode('/table/tbody/tr[' + i + ']/td[1]/@ID');
   var name = procedureHtml.getNode('/table/tbody/tr[' + i + ']/td[2]');
   
   procedureHtml.removeFirstNode('/table/tbody/tr[' + i + ']/td[1]/@ID');
   
   procedureHtml.setNode('/table/tbody/tr[' + i + ']/td[1]', name);
   procedureHtml.setNode('/table/tbody/tr[' + i + ']/td[2]/@ID', codeId);
   procedureHtml.setNode('/table/tbody/tr[' + i + ']/td[2]', code);
}

// Set procedure html back into
message.setNode('/ClinicalDocument/component/structuredBody/component/section[code/@code="47519-4"]/text/table', procedureHtml);

 

This can work for other sections by modifying the code above.

answered Nov 15, 2016 by brandon-w-8204 (33,270 points)
edited Nov 15, 2016 by michael-h-5027
...