Janus
0.1.1 - ci-build

Janus - Local Development build (v0.1.1) built by the FHIR (HL7® FHIR® Standard) Build Tools. See the Directory of published versions

StructureMap: Transforme une extraction JSON QuestionnaireResponse vers un FHIR SDC QuestionnaireResponse - XML Representation

Draft as of 2025-10-07

Raw xml | Download


<StructureMap xmlns="http://hl7.org/fhir">
  <id value="StructureMap-QuestionnaireResponse-JSON"/>
  <text>
    <status value="generated"/>
    <div xmlns="http://www.w3.org/1999/xhtml"><p class="res-header-id"><b>Narratif généré : StructureMap StructureMap-QuestionnaireResponse-JSON</b></p><a name="StructureMap-QuestionnaireResponse-JSON"> </a><a name="hcStructureMap-QuestionnaireResponse-JSON"> </a><pre class="fml">
<b>map</b><span style="color: navy"> &quot;</span>https://www.ghdc.be/StructureMap/StructureMap-QuestionnaireResponse-JSON<span style="color: navy">&quot; = &quot;</span>TransformeQuestionnaireResponseJSONEnQuestionnaireRepsonseFHIRSDC<span style="color: navy">&quot;

</span><span style="color: navy">// </span><span style="color: green">StructureMap permettant la transformation d'une extraction JSON de QuestionnaireResponse vers le standard FHIR SDC QuestionnaireResponse.</span>

<b>uses</b><span style="color: navy"> &quot;</span>https://www.ghdc.be<span style="color: navy">&quot; </span><b>alias </b>source <b>as </b><b>source</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/R4/questionnaire.html" title="Questionnaire">http://hl7.org/fhir/StructureDefinition/Questionnaire</a><span style="color: navy">&quot; </span><b>alias </b>source <b>as </b><b>source</b>
<b>uses</b><span style="color: navy"> &quot;</span><a href="http://hl7.org/fhir/uv/sdc/STU3/StructureDefinition-sdc-questionnaireresponse.html" title="SDC Questionnaire Response">http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaireresponse</a><span style="color: navy">&quot; </span><b>alias </b>target <b>as </b><b>target</b>

<b>group </b>main<span style="color: navy">(</span><b>source</b> <span style="color: maroon">source</span><span style="color: navy"> : </span>JSON, <b>source</b> <span style="color: maroon">questionnaire</span><span style="color: navy"> : </span>Questionnaire, <b>target</b> <span style="color: maroon">target</span><span style="color: navy"> : </span>QuestionnaireResponse<span style="color: navy">)</span><span style="color: navy"> {
</span>  source.reponses<span style="color: navy"> : </span>JSON<b> as </b><span style="color: maroon">reponses</span><b> then</b><span style="color: navy"> {
</span>    reponses.groupId<span style="color: navy"> : </span>json<b> as </b><span style="color: maroon">groupId</span><b> then</b><span style="color: navy"> {
</span>      target.item<b> as </b><span style="color: maroon">groupItem</span><b> where </b>$this.linkId=%groupId<b> then</b><span style="color: navy"> {
</span>        reponses.questions<span style="color: navy"> : </span>json<b> as </b><span style="color: maroon">question</span><b> then</b><span style="color: navy"> {
</span>          question.questionId<span style="color: navy"> : </span>json<b> as </b><span style="color: maroon">questionId</span><b> then</b><span style="color: navy"> {
</span>            groupItem.item<b> as </b><span style="color: maroon">questionItem</span><b> where </b>$this.linkId=%questionId<b> then</b><span style="color: navy"> {
</span>              questionnaire.item<b> as </b><span style="color: maroon">questionnaireGroupItem</span><b> where </b>$this.linkId=%groupId<b> then</b><span style="color: navy"> {
</span>                questionnaireGroupItem.item<b> as </b><span style="color: maroon">questionnaireQuestionItem</span><b> where </b>$this.linkId=%questionId<b> then</b><span style="color: navy"> {
</span>                  questionnaireQuestionItem.type<b> as </b><span style="color: maroon">questionType</span><b> then</b><span style="color: navy"> {
</span>                    question.reponse<span style="color: navy"> : </span>json<b> as </b><span style="color: maroon">reponse</span><b> then</b><span style="color: navy"> {
</span>                      questionType<b> as </b><span style="color: maroon">questionType</span><b> where </b>($this = 'choice').not() and %reponse.exists()<span style="color: navy"><b> -&gt; </b></span>questionItem.answer[0].value = <b>cast</b><span style="color: navy">(</span><span style="color: maroon">reponse</span><span style="color: navy">, </span><span style="color: maroon">questionType</span><span style="color: navy">)</span> <i>&quot;CastNoChoice&quot;</i><span style="color: navy">;</span>
                      questionType<b> as </b><span style="color: maroon">questionType</span><b> where </b>$this = 'choice' and %reponse.exists()<span style="color: navy"><b> -&gt; </b></span>questionItem.answer[0].value = <b>c</b><span style="color: navy">(</span><span style="color: blue">'http://loinc.org'</span><span style="color: navy">, </span><span style="color: maroon">reponse</span><span style="color: navy">)</span> <i>&quot;CastChoice&quot;</i><span style="color: navy">;</span>
                    <span style="color: navy">}</span> <i>&quot;FetchResponse&quot;</i><span style="color: navy">;</span>
                  <span style="color: navy">}</span> <i>&quot;FetchQuestionType&quot;</i><span style="color: navy">;</span>
                <span style="color: navy">}</span> <i>&quot;FindQuestionnaireQuestion&quot;</i><span style="color: navy">;</span>
              <span style="color: navy">}</span> <i>&quot;FindQuestionnaireGroup&quot;</i><span style="color: navy">;</span>
            <span style="color: navy">}</span> <i>&quot;FindQuestion&quot;</i><span style="color: navy">;</span>
          <span style="color: navy">}</span> <i>&quot;QuestionId&quot;</i><span style="color: navy">;</span>
        <span style="color: navy">}</span> <i>&quot;Questions&quot;</i><span style="color: navy">;</span>
      <span style="color: navy">}</span> <i>&quot;FindGroup&quot;</i><span style="color: navy">;</span>
    <span style="color: navy">}</span><span style="color: navy">;</span>
  <span style="color: navy">}</span><span style="color: navy">;</span>
<span style="color: navy">}

</span></pre></div>
  </text>
  <url
       value="https://www.ghdc.be/StructureMap/StructureMap-QuestionnaireResponse-JSON"/>
  <version value="0.1.1"/>
  <name
        value="TransformeQuestionnaireResponseJSONEnQuestionnaireRepsonseFHIRSDC"/>
  <title
         value="Transforme une extraction JSON QuestionnaireResponse vers un FHIR SDC QuestionnaireResponse"/>
  <status value="draft"/>
  <date value="2025-10-07T10:35:59+02:00"/>
  <publisher value="Fyrstain"/>
  <contact>
    <name value="Fyrstain"/>
    <telecom>
      <system value="url"/>
      <value value="http://fyrstain.com"/>
    </telecom>
  </contact>
  <description
               value="StructureMap permettant la transformation d'une extraction JSON de QuestionnaireResponse vers le standard FHIR SDC QuestionnaireResponse."/>
  <structure>
    <url value="https://www.ghdc.be"/>
    <mode value="source"/>
    <alias value="source"/>
  </structure>
  <structure>
    <url value="http://hl7.org/fhir/StructureDefinition/Questionnaire"/>
    <mode value="source"/>
    <alias value="source"/>
  </structure>
  <structure>
    <url
         value="http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaireresponse"/>
    <mode value="target"/>
    <alias value="target"/>
  </structure>
  <group>
    <name value="main"/>
    <typeMode value="none"/>
    <input>
      <name value="source"/>
      <type value="JSON"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="questionnaire"/>
      <type value="Questionnaire"/>
      <mode value="source"/>
    </input>
    <input>
      <name value="target"/>
      <type value="QuestionnaireResponse"/>
      <mode value="target"/>
    </input>
    <rule>
      <name value="reponses"/>
      <source>
        <context value="source"/>
        <type value="JSON"/>
        <element value="reponses"/>
        <variable value="reponses"/>
      </source>
      <rule>
        <name value="groupId"/>
        <source>
          <context value="reponses"/>
          <type value="json"/>
          <element value="groupId"/>
          <variable value="groupId"/>
        </source>
        <rule>
          <name value="FindGroup"/>
          <source>
            <context value="target"/>
            <element value="item"/>
            <variable value="groupItem"/>
            <condition value="$this.linkId=%groupId"/>
          </source>
          <rule>
            <name value="Questions"/>
            <source>
              <context value="reponses"/>
              <type value="json"/>
              <element value="questions"/>
              <variable value="question"/>
            </source>
            <rule>
              <name value="QuestionId"/>
              <source>
                <context value="question"/>
                <type value="json"/>
                <element value="questionId"/>
                <variable value="questionId"/>
              </source>
              <rule>
                <name value="FindQuestion"/>
                <source>
                  <context value="groupItem"/>
                  <element value="item"/>
                  <variable value="questionItem"/>
                  <condition value="$this.linkId=%questionId"/>
                </source>
                <rule>
                  <name value="FindQuestionnaireGroup"/>
                  <source>
                    <context value="questionnaire"/>
                    <element value="item"/>
                    <variable value="questionnaireGroupItem"/>
                    <condition value="$this.linkId=%groupId"/>
                  </source>
                  <rule>
                    <name value="FindQuestionnaireQuestion"/>
                    <source>
                      <context value="questionnaireGroupItem"/>
                      <element value="item"/>
                      <variable value="questionnaireQuestionItem"/>
                      <condition value="$this.linkId=%questionId"/>
                    </source>
                    <rule>
                      <name value="FetchQuestionType"/>
                      <source>
                        <context value="questionnaireQuestionItem"/>
                        <element value="type"/>
                        <variable value="questionType"/>
                      </source>
                      <rule>
                        <name value="FetchResponse"/>
                        <source>
                          <context value="question"/>
                          <type value="json"/>
                          <element value="reponse"/>
                          <variable value="reponse"/>
                        </source>
                        <rule>
                          <name value="CastNoChoice"/>
                          <source>
                            <context value="questionType"/>
                            <variable value="questionType"/>
                            <condition
                                       value="($this = 'choice').not() and %reponse.exists()"/>
                          </source>
                          <target>
                            <context value="questionItem"/>
                            <contextType value="variable"/>
                            <element value="answer[0].value"/>
                            <transform value="cast"/>
                            <parameter>
                              <valueId value="reponse"/>
                            </parameter>
                            <parameter>
                              <valueId value="questionType"/>
                            </parameter>
                          </target>
                        </rule>
                        <rule>
                          <name value="CastChoice"/>
                          <source>
                            <context value="questionType"/>
                            <variable value="questionType"/>
                            <condition
                                       value="$this = 'choice' and %reponse.exists()"/>
                          </source>
                          <target>
                            <context value="questionItem"/>
                            <contextType value="variable"/>
                            <element value="answer[0].value"/>
                            <transform value="c"/>
                            <parameter>
                              <valueString value="http://loinc.org"/>
                            </parameter>
                            <parameter>
                              <valueId value="reponse"/>
                            </parameter>
                          </target>
                        </rule>
                      </rule>
                    </rule>
                  </rule>
                </rule>
              </rule>
            </rule>
          </rule>
        </rule>
      </rule>
    </rule>
  </group>
</StructureMap>