microsoft / FHIR-Converter

Conversion utility to translate legacy data formats into FHIR
MIT License
390 stars 172 forks source link

Invalid JSON generated (Exception) - CcdaDataParser does not escape incoming double quote character #421

Open jgriesemer-ndsc opened 1 year ago

jgriesemer-ndsc commented 1 year ago

Conversion fails and throws a PostprocessException because CcdaDataParser.cs does not escape double quote characters inside of XText nodes from the incoming xml document.

Example problematic xml:

<value xsi:type="ST">
* Adjustment of the mA and/or kV according to patient size (this  
       includes techniques or standardized protocols for targeted exams  
       where dose is matched to indication / reason for exam; i.e.  
       extremities or head ) * Use of iterative reconstruction technique"
</value>

Using Ccda Processor with DischargeSummary template. I've added a step to the parser locally to replace " -> \" and the fix works.

marcocrasso commented 1 year ago

Similar problem with: \" and Microsoft.Health.Fhir.Liquid.Converter.Tool 5.0.4.3.

<value code="&quot;text&quot;" displayName="&quot;text&quot;">
    <originalText>
        <reference value="text"/>
    </originalText>
</value>

Output:

Process failed: Invalid JSON generated: line 845:18 no viable alternative at input: ...

Preprocessing also works for me.

sowu880 commented 1 year ago

Hi, you can use string filter: 'escape' in CCDA templates which will return string with special chars escaped. e.g. "div":"\<div>{{ component.section.title.displayName| escape }}\</div>",

Thanks.

evachen96 commented 1 year ago

@jgriesemer-ndsc were you able to try out the escape string filter? Did that help with the issue?