FHIR Cross-Version Mapping Pack
0.1.0 - Ballot for Release 5.1.0 International flag

FHIR Cross-Version Mapping Pack, published by HL7 International / FHIR Infrastructure. This guide is not an authorized publication; it is the continuous build for version 0.1.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/HL7/fhir-cross-version/ and changes regularly. See the Directory of published versions

StructureMap: Questionnaire Transforms: R2 to R3

Official URL: http://hl7.org/fhir/StructureMap/Questionnaire2to3 Version: 0.1.0
Standards status: Draft Maturity Level: 1 Computable Name: Questionnaire2to3

QuestionnaireTransformsR2toR3

/// url = 'http://hl7.org/fhir/StructureMap/Questionnaire2to3'
/// name = 'Questionnaire2to3'
/// title = 'Questionnaire Transforms: R2 to R3'
/// status = 'active'

uses "http://hl7.org/fhir/1.0/Questionnaire" alias QuestionnaireR2 as source
uses "http://hl7.org/fhir/3.0/Questionnaire" alias Questionnaire as target

imports "http://hl7.org/fhir/StructureMap/*2to3"

group Questionnaire(source src : QuestionnaireR2, target tgt : Questionnaire) extends DomainResource <<type+>> {
  src.identifier -> tgt.identifier "Questionnaire-identifier";
  src.version -> tgt.version "Questionnaire-version";
  src.status as v -> tgt.status = translate(v, 'http://hl7.org/fhir/ConceptMap/Questionnaire.status-R2toR3', 'code') "Questionnaire-status";
  src.date -> tgt.date "Questionnaire-date";
  src.publisher -> tgt.publisher "Questionnaire-publisher";
  src.telecom as v ->  tgt.contact as d,  d.telecom as v "Questionnaire-telecom";
  src.subjectType -> tgt.subjectType "Questionnaire-subjectType";
  src.group as vs0 -> tgt.item as vt0 then qstGroup(vs0, vt0) "Questionnaire-group";
}

group qstGroup(source src, target tgt) extends BackboneElement {
  src -> tgt.type = 'group' "group-type";
  src.linkId -> tgt.linkId "group-linkId";
  src.title -> tgt.text "group-title";
  src.concept -> tgt.code "group-concept";
  src.text as t where src.title.exists() and src.linkId.exists() ->  tgt.item as i,  i.linkId = (src.linkId + '-' + 'display'),  i.text = t "group-text";
  src.text where src.title.empty() -> tgt.text "group-text";
  src.required -> tgt.required "group-required";
  src.repeats -> tgt.repeats "group-repeats";
  src.group as vs0 -> tgt.item as vt0 then qstGroup(vs0, vt0) "group-group";
  src.question as vs0 -> tgt.item as vt0 then qstQuestion(vs0, vt0) "group-question";
}

group qstQuestion(source src, target tgt) extends BackboneElement {
  src.type -> tgt.type "question-type";
  src.linkId -> tgt.linkId "question-linkId";
  src.concept -> tgt.code "question-concept";
  src.text -> tgt.text "question-text";
  src.required -> tgt.required "question-required";
  src.repeats -> tgt.repeats "question-repeats";
  src.options -> tgt.options "question-options";
  src.option as v ->  tgt.option as o,  o.value as v "question-option";
  src.group as vs0 -> tgt.item as vt0 then qstGroup(vs0, vt0) "question-group";
}