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

Official URL: https://www.ghdc.be/StructureMap/StructureMap-QuestionnaireResponse-JSON Version: 0.1.1
Draft as of 2025-10-07 Computable Name: TransformeQuestionnaireResponseJSONEnQuestionnaireRepsonseFHIRSDC
map "https://www.ghdc.be/StructureMap/StructureMap-QuestionnaireResponse-JSON" = "TransformeQuestionnaireResponseJSONEnQuestionnaireRepsonseFHIRSDC"

// StructureMap permettant la transformation d'une extraction JSON de QuestionnaireResponse vers le standard FHIR SDC QuestionnaireResponse.

uses "https://www.ghdc.be" alias source as source
uses "http://hl7.org/fhir/StructureDefinition/Questionnaire" alias source as source
uses "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaireresponse" alias target as target

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