FHIR Chat · storing html code · implementers

Stream: implementers

Topic: storing html code


view this post on Zulip Naminder Soorma (Jul 06 2016 at 15:22):

Is it possible to store html code/markdown code in say description elements?

view this post on Zulip Lloyd McKenzie (Jul 06 2016 at 16:19):

There's an extension for that :> http://www.hl7.org/fhir/extension-markup.html

view this post on Zulip Lloyd McKenzie (Jul 06 2016 at 16:19):

Also, for StructureDefinition and a few other resources, some of the elements are already defined as Markdown

view this post on Zulip Naminder Soorma (Jul 07 2016 at 08:31):

edit - will this only work for StructureDefinition?

I am wanted a field in the CodeSystem resource that allows me to attached HTML from a code system description, is this achievable?

So a very rough example would be shown near the bottom of this code:

<CodeSystem xmlns="http://hl7.org/fhir">
<url value="http://fhir.nhs.net/CodeSystem/TestCodeSystem"/>
<identifier>
<system value="http://fhir.nhs.net/TestCodeSystem"/>
<value value="CodeSystemNHS"/>
</identifier>
<version value="1"/>
<name value="CodeSystemNHS"/>
<status value="active"/>
<experimental value="false"/>
<date value="2016-07-05"/>
<description value="Test CodeSystem"/>
<extension xmlns="http://hl7.org/fhir"
url="http://hl7.org/fhir/StructureDefinition/codesystem-comments" >
<valueString value="Notes at the bottom comments can be entered here"/>
</extension>
<extension xmlns="http://hl7.org/fhir"
url="http://hl7.org/fhir/StructureDefinition/markup" >
<valueString value="<html><body><p id="demo"></p>"/>
</extension>
<caseSensitive value="false"/>

view this post on Zulip Lloyd McKenzie (Jul 07 2016 at 14:01):

You'll have to escape the HTML, so <valueString value="&lt;html&gt;&lt;body&gt;..."
Also, your html would need to be valid - so close tags for every open tag. In this case you should strip the <html> and <body>. I'd expect something like <valueString value="&lt;b&gt;This is an &lt;i&gt;important&lt;/i&gt; description&lt;/b&gt;"/>

view this post on Zulip Naminder Soorma (Jul 07 2016 at 14:30):

ok, the server seems to have accepted it, but got to admit seems a very messy way to have to escape the HTML tags. Then on output would have to re-enter them...

view this post on Zulip Eric Haas (Jul 07 2016 at 14:52):

Are you asking wherther to have this in the narrative part of the resource or in the description element itself?

view this post on Zulip Lloyd McKenzie (Jul 07 2016 at 16:09):

@Naminder Soorma The HTML content is just a string. So long as you treat it as a string, your XML handler should deal with the escaping and unescaping transparently for you. (The alternative would be to base-64 encode it, which would be worse . . .)

view this post on Zulip Naminder Soorma (Jul 08 2016 at 08:20):

@Lloyd McKenzie - ok I understand now that it is simply a string, I will play with getting our data into the format needed. @Eric Haas - I am trying to have it as a description element. For example I have data held in a table and want to store the header row retaining the bold text to distinguish it from the data values

view this post on Zulip Naminder Soorma (Jul 08 2016 at 09:53):

Thanks got this sorted now, this website helped to get all the codes https://dev.w3.org/html5/html-author/charref

<extension xmlns="http://hl7.org/fhir"
 url="http://hl7.org/fhir/codeSystem/markup" >

<valueString value="&lt;table border=&quot;1&quot;&gt;&lt;tr&gt;&lt;td&gt;&lt;b&gt;Line 1 Header&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Line 2 Data&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;&lt;b&gt;This is an &lt;i&gt;important&lt;/i&gt; description&lt;/b&gt;"/>
</extension>


Last updated: Apr 12 2022 at 19:14 UTC