FHIR Release 3 (STU) 4

This page is part of the FHIR Specification (v3.0.2: (v4.0.1: R4 - Mixed Normative and STU 3). ) in it's permanent home (it will always be available at this URL). The current version which supercedes this version is 5.0.0 . For a full list of available versions, see the Directory of published versions . Page versions: R5 R4B R4 R3 R4 R3

Patient Care Work Group Maturity Level : N/A Ballot Standards Status : Informative Security Category : Patient Compartments : Encounter , Patient , Practitioner , RelatedPerson

R2 : R3 Converson : R4 Conversion maps for CarePlan.

Functional status for this map: 10 11 tests that all execute ok. 8 fail All tests pass round-trip testing and 10 r3 resources are invalid (33 (0 errors). ( see documentation)

map "http://hl7.org/fhir/StructureMap/CarePlan2to3" = "R2 to R3 Conversions for CarePlan"

uses "http://hl7.org/fhir/DSTU2/StructureDefinition/CarePlan" alias CarePlanR2 as source
uses "http://hl7.org/fhir/StructureDefinition/CarePlan" alias CarePlan as target

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

group for type+types  CarePlan extends DomainResource
  input src : CarePlanR2 as source
  input tgt : CarePlan as target

  "CarePlan-identifier" : for src.identifier make tgt.identifier
  "CarePlan-subject" : for src.subject make tgt.subject
  "CarePlan-status" : for src.status make tgt.status
  "CarePlan-context" : for src.context make tgt.context
  "CarePlan-period" : for src.period make tgt.period
  "CarePlan-author" : for src.author make tgt.author
  "CarePlan-modified" : for src.modified as v make tgt.extension as t, t.url = 'http://hl7.org/fhir/CarePlan-r2-modified', t.value = v
  "CarePlan-category" : for src.category make tgt.category
  "CarePlan-description" : for src.description make tgt.description
  "CarePlan-addresses" : for src.addresses make tgt.addresses
  "CarePlan-support" : for src.support make tgt.supportingInfo
  // "CarePlan-relatedPlan1" : for src.relatedPlan as vs0 where vs0.code = 'includes' make tgt.basedOn = (vs0.plan) this relationship is inverted to partOf, and that's beyond the scope of the transforms to do
  "CarePlan-relatedPlan2" : for src.relatedPlan as vs0 where vs0.code = 'replaces' make tgt.basedOn = (vs0.plan)
  "CarePlan-relatedPlan3" : for src.relatedPlan as vs0 where vs0.code = 'fulfills' make tgt.replaces = (vs0.plan)
  "CarePlan-participant" : for src where src.participant.exists() make create("CareTeam") as vt0 then plnParticipant(src, vt0, tgt)
  "CarePlan-goal" : for src.goal make tgt.goal
  "CarePlan-activity" : for src.activity as vs0 make tgt.activity as vt0 then plnActivity(vs0, vt0)
  "CarePlan-note" : for src.note make tgt.note
endgroup

group plnRelated extends BackboneElement
  input src as source
  input tgt as target

  "CarePlan.relatedPlan-code" : for src.code make tgt.code
  "CarePlan.relatedPlan-plan" : for src.plan make tgt.plan
endgroup

group plnActivity extends BackboneElement
  input src as source
  input tgt as target

  "CarePlan.activity-actionResulting" : for src.actionResulting make tgt.outcomeReference
  "CarePlan.activity-progress" : for src.progress make tgt.progress
  "CarePlan.activity-reference" : for src.reference make tgt.reference
  "CarePlan.activity-detail" : for src.detail as vs0 make tgt.detail as vt0 then plnDetail(vs0, vt0)
endgroup

group plnDetail extends BackboneElement
  input src as source
  input tgt as target

map "http://hl7.org/fhir/StructureMap/CarePlan3to4" = "R3 to R4 Conversions for CarePlan"


  "CarePlan.activity.detail-category" : for src.category make tgt.category
  "CarePlan.activity.detail-code" : for src.code make tgt.code
  "CarePlan.activity.detail-reasonCode" : for src.reasonCode make tgt.reasonCode
  "CarePlan.activity.detail-reasonReference" : for src.reasonReference make tgt.reasonReference
  "CarePlan.activity.detail-goal" : for src.goal make tgt.goal
  "CarePlan.activity.detail-status" : for src.status make tgt.status
  "CarePlan.activity.detail-statusReason" : for src.statusReason make tgt.statusReason
  "CarePlan.activity.detail-prohibited" : for src.prohibited make tgt.prohibited
  "CarePlan.activity.detail-scheduled" : for src.scheduled make tgt.scheduled
  "CarePlan.activity.detail-location" : for src.location make tgt.location
  "CarePlan.activity.detail-performer" : for src.performer make tgt.performer
  "CarePlan.activity.detail-product" : for src.product make tgt.product
  "CarePlan.activity.detail-dailyAmount" : for src.dailyAmount make tgt.dailyAmount
  "CarePlan.activity.detail-quantity" : for src.quantity make tgt.quantity
  "CarePlan.activity.detail-description" : for src.description make tgt.description 
endgroup

uses "http://hl7.org/fhir/3.0/StructureDefinition/CarePlan" alias CarePlanR3 as source
uses "http://hl7.org/fhir/StructureDefinition/CarePlan" alias CarePlan as target


group plnParticipant
  input src as source
  input tgt as target
  input tgtE as target

imports "http://hl7.org/fhir/StructureMap/*3to4"


  "CarePlan.participant-link" : for src make tgtE.careTeam = reference(tgt)
  "CarePlan.participant-member" : for src.participant as vs make tgt.participant as vt then plnParticipantMember(vs, vt)
endgroup

group CarePlan(source src : CarePlanR3, target tgt : CarePlan) extends DomainResource <<type+>> {
  src.identifier -> tgt.identifier;
  src.definition -> tgt.instantiatesCanonical;
  src.basedOn -> tgt.basedOn;
  src.replaces -> tgt.replaces;
  src.partOf -> tgt.partOf;
  src.status -> tgt.status;
  src.intent -> tgt.intent;
  src.category -> tgt.category;
  src.title -> tgt.title;
  src.description -> tgt.description;
  src.subject -> tgt.subject;
  src.context -> tgt.encounter;
  src.period -> tgt.period;
  src.author -> tgt.author;
  src.contributor -> tgt.contributor;
  src.careTeam -> tgt.careTeam;
  src.addresses -> tgt.addresses;
  src.supportingInfo -> tgt.supportingInfo;
  src.goal -> tgt.goal;
  src.activity as vs -> tgt.activity as vt then activity(vs, vt);
  src.note -> tgt.note;
}


group plnParticipantMember extends BackboneElement
  input src as source
  input tgt as target

group activity(source src, target tgt) extends BackboneElement {
  src.outcomeCodeableConcept -> tgt.outcomeCodeableConcept;
  src.outcomeReference -> tgt.outcomeReference;
  src.progress -> tgt.progress;
  src.reference -> tgt.reference;
  src.detail as vs -> tgt.detail as vt then detail(vs, vt);
}


  "CarePlan.participant-role" : for src.role make tgt.role
  "CarePlan.participant-member" : for src.member make tgt.member
endgroup

group detail(source src, target tgt) extends BackboneElement {
  src.category as v ->  tgt.extension as vt,  vt.url = 'http://hl7.org/fhir/3.0/StructureDefinition/extension-CarePlan.activity.detail.category',  vt.value = v;
  src.definition -> tgt.instantiatesCanonical;
  src.code -> tgt.code;
  src.reasonCode -> tgt.reasonCode;
  src.reasonReference -> tgt.reasonReference;
  src.goal -> tgt.goal;
  src.status -> tgt.status;
  src.statusReason as s ->  tgt.statusReason as t,  t.text = s;
  src.prohibited -> tgt.doNotPerform;
  src.scheduled : Timing as s -> tgt.scheduled = create('Timing') as t then Timing(s, t);
  src.scheduled : Period as s -> tgt.scheduled = create('Period') as t then Period(s, t);
  src.scheduled : string as s -> tgt.scheduled = create('string') as t then string(s, t);
  src.location -> tgt.location;
  src.performer -> tgt.performer;
  src.product : CodeableConcept as s -> tgt.product = create('CodeableConcept') as t then CodeableConcept(s, t);
  src.product : Reference as s -> tgt.product = create('Reference') as t then Reference(s, t);
  src.dailyAmount -> tgt.dailyAmount;
  src.quantity -> tgt.quantity;
  src.description -> tgt.description;
}



map "http://hl7.org/fhir/StructureMap/CarePlan3to2" = "R3 to R2 Conversion for CarePlan"

uses "http://hl7.org/fhir/StructureDefinition/CarePlan" alias CarePlan as source
uses "http://hl7.org/fhir/DSTU2/StructureDefinition/CarePlan" alias CarePlanR2 as target

imports "http://hl7.org/fhir/StructureMap/*3to2"

group for type+types  CarePlan extends DomainResource
  input src : CarePlan as source
  input tgt : CarePlanR2 as target

  "CarePlan-identifier" : for src.identifier make tgt.identifier
  "CarePlan-subject" : for src.subject make tgt.subject
  "CarePlan-status" : for src.status make tgt.status
  "CarePlan-context" : for src.context make tgt.context
  "CarePlan-period" : for src.period make tgt.period
  "CarePlan-author" : for src.author make tgt.author
  "CarePlan-modified" : for src.extension as e where e.url = 'http://hl7.org/fhir/CarePlan-r2-modified' make tgt.modified = (e.value)
  "CarePlan-category" : for src.category make tgt.category
  "CarePlan-description" : for src.description make tgt.description
  "CarePlan-addresses" : for src.addresses make tgt.addresses
  "CarePlan-support" : for src.supportingInfo make tgt.support
  "CarePlan-relatedPlan2" : for src.basedOn as vs0 make tgt.relatedPlan as rp, rp.code = 'fulfills', rp.plan = v
  "CarePlan-relatedPlan3" : for src.replaces as vs0 make tgt.relatedPlan as rp, rp.code = 'replaces', rp.plan = v
  "CarePlan-participant" : for src.careTeam as vs where reference.resolve().exists() make (src.careTeam.reference.resolve()) as ct then plnParticipant(ct, tgt)
  "CarePlan-goal" : for src.goal make tgt.goal
  "CarePlan-activity" : for src.activity as vs0 make tgt.activity as vt0 then plnActivity(vs0, vt0)
  "CarePlan-note" : for src.note make tgt.note
endgroup

group plnActivity extends BackboneElement
  input src as source
  input tgt as target

  "CarePlan.activity-actionResulting" : for src.outcomeReference make tgt.actionResulting
  "CarePlan.activity-progress" : for src.progress make tgt.progress
  "CarePlan.activity-reference" : for src.reference make tgt.reference
  "CarePlan.activity-detail" : for src.detail as vs0 make tgt.detail as vt0 then plnDetail(vs0, vt0)
endgroup

group plnDetail extends BackboneElement
  input src as source
  input tgt as target

  "CarePlan.activity.detail-category" : for src.category make tgt.category
  "CarePlan.activity.detail-code" : for src.code make tgt.code
  "CarePlan.activity.detail-reasonCode" : for src.reasonCode make tgt.reasonCode
  "CarePlan.activity.detail-reasonReference" : for src.reasonReference make tgt.reasonReference
  "CarePlan.activity.detail-goal" : for src.goal make tgt.goal
  "CarePlan.activity.detail-status" : for src.status make tgt.status
  "CarePlan.activity.detail-statusReason" : for src.statusReason make tgt.statusReason
  "CarePlan.activity.detail-prohibited" : for src.prohibited make tgt.prohibited
  "CarePlan.activity.detail-scheduled" : for src.scheduled make tgt.scheduled
  "CarePlan.activity.detail-location" : for src.location make tgt.location
  "CarePlan.activity.detail-performer" : for src.performer make tgt.performer
  "CarePlan.activity.detail-product" : for src.product make tgt.product
  "CarePlan.activity.detail-dailyAmount" : for src.dailyAmount make tgt.dailyAmount
  "CarePlan.activity.detail-quantity" : for src.quantity make tgt.quantity
  "CarePlan.activity.detail-description" : for src.description make tgt.description 
endgroup

map "http://hl7.org/fhir/StructureMap/CarePlan4to3" = "R4 to R3 Conversion for CarePlan"


uses "http://hl7.org/fhir/StructureDefinition/CarePlan" alias CarePlan as source
uses "http://hl7.org/fhir/3.0/StructureDefinition/CarePlan" alias CarePlanR3 as target


group plnParticipant 
  input src as source
  input tgt as target

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


  "CarePlan.participant-unlink" : for src.participant as vs make tgt.participant as vt then plnParticipantMember(vs, vt)
endgroup

group CarePlan(source src : CarePlanR3, target tgt : CarePlan) extends DomainResource <<type+>> {
  src.identifier -> tgt.identifier;
  src.instantiatesCanonical -> tgt.definition;
  src.basedOn -> tgt.basedOn;
  src.replaces -> tgt.replaces;
  src.partOf -> tgt.partOf;
  src.status -> tgt.status;
  src.intent -> tgt.intent;
  src.category -> tgt.category;
  src.title -> tgt.title;
  src.description -> tgt.description;
  src.subject -> tgt.subject;
  src.encounter -> tgt.context;
  src.period -> tgt.period;
  src.author -> tgt.author;
  src.contributor -> tgt.contributor;
  src.careTeam -> tgt.careTeam;
  src.addresses -> tgt.addresses;
  src.supportingInfo -> tgt.supportingInfo;
  src.goal -> tgt.goal;
  src.activity as vs -> tgt.activity as vt then activity(vs, vt);
  src.note -> tgt.note;
}


group plnParticipantMember extends BackboneElement
  input src as source
  input tgt as target

group activity(source src, target tgt) extends BackboneElement {
  src.outcomeCodeableConcept -> tgt.outcomeCodeableConcept;
  src.outcomeReference -> tgt.outcomeReference;
  src.progress -> tgt.progress;
  src.reference -> tgt.reference;
  src.detail as vs -> tgt.detail as vt then detail(vs, vt);
}


  "CarePlan.participant-role" : for src.role make tgt.role
  "CarePlan.participant-member" : for src.member make tgt.member
endgroup

group detail(source src, target tgt) extends BackboneElement {
  src.extension as e where url = 'http://hl7.org/fhir/3.0/StructureDefinition/extension-CarePlan.activity.detail.category' then {
    e.value -> tgt.category;
  };
  src.instantiatesCanonical -> tgt.definition;
  src.code -> tgt.code;
  src.reasonCode -> tgt.reasonCode;
  src.reasonReference -> tgt.reasonReference;
  src.goal -> tgt.goal;
  src.status -> tgt.status;
  src.statusReason as s then {
    s.text -> tgt.statusReason;
  };
  src.doNotPerform -> tgt.prohibited;
  src.scheduled : Timing as s -> tgt.scheduled = create('Timing') as t then Timing(s, t);
  src.scheduled : Period as s -> tgt.scheduled = create('Period') as t then Period(s, t);
  src.scheduled : string as s -> tgt.scheduled = create('string') as t then string(s, t);
  src.location -> tgt.location;
  src.performer -> tgt.performer;
  src.product : CodeableConcept as s -> tgt.product = create('CodeableConcept') as t then CodeableConcept(s, t);
  src.product : Reference as s -> tgt.product = create('Reference') as t then Reference(s, t);
  src.dailyAmount -> tgt.dailyAmount;
  src.quantity -> tgt.quantity;
  src.description -> tgt.description;
}



example ERROR @ CarePlan: If the resource is contained in another resource, it SHALL be referred to from elsewhere in the resource [contained.where(('#'+id in %resource.descendants().reference).not()).empty()] (src = InstanceValidator) ERROR @ CarePlan: Profile http://hl7.org/fhir/StructureDefinition/CarePlan, Element 'CarePlan.intent': minimum required = 1, but only found 0 (src = InstanceValidator) ERROR @ CarePlan.contained[1]: Condition.clinicalStatus SHALL be present if verificationStatus is not entered-in-error [verificationStatus='entered-in-error' or clinicalStatus.exists()] (src = InstanceValidator) ERROR @ CarePlan.contained[3].extension: The extension http://hl7.org/fhir/StructureDefinition/goal-target is unknown, and not allowed here (src = InstanceValidator) ERROR @ CarePlan.addresses.contained: Condition.clinicalStatus SHALL be present if verificationStatus is not entered-in-error [verificationStatus='entered-in-error' or clinicalStatus.exists()] (src = InstanceValidator) ERROR @ CarePlan.goal.contained.extension: The extension http://hl7.org/fhir/StructureDefinition/goal-target is unknown, and not allowed here (src = InstanceValidator) ERROR @ CarePlan.activity.detail: Profile http://hl7.org/fhir/StructureDefinition/CarePlan, Element 'CarePlan.activity.detail.status': minimum required = 1, but only found 0 (src = InstanceValidator) gpvisit ERROR @ CarePlan: Profile http://hl7.org/fhir/StructureDefinition/CarePlan, Element 'CarePlan.intent': minimum required = 1, but only found 0 (src = InstanceValidator) ERROR @ CarePlan.contained[1]: Condition.clinicalStatus SHALL be present if verificationStatus is not entered-in-error [verificationStatus='entered-in-error' or clinicalStatus.exists()] (src = InstanceValidator) ERROR @ CarePlan.addresses.contained: Condition.clinicalStatus SHALL be present if verificationStatus is not entered-in-error [verificationStatus='entered-in-error' or clinicalStatus.exists()] (src = InstanceValidator) f001 ERROR @ CarePlan: Profile http://hl7.org/fhir/StructureDefinition/CarePlan, Element 'CarePlan.intent': minimum required = 1, but only found 0 (src = InstanceValidator) ERROR @ CarePlan.extension: The extension http://hl7.org/fhir/CarePlan-r2-modified is unknown, and not allowed here (src = InstanceValidator) f002 ERROR @ CarePlan: Profile http://hl7.org/fhir/StructureDefinition/CarePlan, Element 'CarePlan.intent': minimum required = 1, but only found 0 (src = InstanceValidator) ERROR @ CarePlan.extension: The extension http://hl7.org/fhir/CarePlan-r2-modified is unknown, and not allowed here (src = InstanceValidator) f003 ERROR @ CarePlan: Profile http://hl7.org/fhir/StructureDefinition/CarePlan, Element 'CarePlan.intent': minimum required = 1, but only found 0 (src = InstanceValidator) ERROR @ CarePlan.extension: The extension http://hl7.org/fhir/CarePlan-r2-modified is unknown, and not allowed here (src = InstanceValidator) f201 ERROR @ CarePlan: Profile http://hl7.org/fhir/StructureDefinition/CarePlan, Element 'CarePlan.intent': minimum required = 1, but only found 0 (src = InstanceValidator) ERROR @ CarePlan.extension: The extension http://hl7.org/fhir/CarePlan-r2-modified is unknown, and not allowed here (src = InstanceValidator) f202 ERROR @ CarePlan: Profile http://hl7.org/fhir/StructureDefinition/CarePlan, Element 'CarePlan.intent': minimum required = 1, but only found 0 (src = InstanceValidator) f203 ERROR @ CarePlan: Profile http://hl7.org/fhir/StructureDefinition/CarePlan, Element 'CarePlan.intent': minimum required = 1, but only found 0 (src = InstanceValidator) ERROR @ CarePlan.extension: The extension http://hl7.org/fhir/CarePlan-r2-modified is unknown, and not allowed here (src = InstanceValidator) integrate ERROR @ CarePlan: Profile http://hl7.org/fhir/StructureDefinition/CarePlan, Element 'CarePlan.intent': minimum required = 1, but only found 0 (src = InstanceValidator) ERROR @ CarePlan.contained[1]: Condition.clinicalStatus SHALL be present if verificationStatus is not entered-in-error [verificationStatus='entered-in-error' or clinicalStatus.exists()] (src = InstanceValidator) ERROR @ CarePlan.contained[2]: Condition.clinicalStatus SHALL be present if verificationStatus is not entered-in-error [verificationStatus='entered-in-error' or clinicalStatus.exists()] (src = InstanceValidator) ERROR @ CarePlan.contained[3]: Condition.clinicalStatus SHALL be present if verificationStatus is not entered-in-error [verificationStatus='entered-in-error' or clinicalStatus.exists()] (src = InstanceValidator) ERROR @ CarePlan.extension: The extension http://hl7.org/fhir/CarePlan-r2-modified is unknown, and not allowed here (src = InstanceValidator) ERROR @ CarePlan.addresses[1].contained: Condition.clinicalStatus SHALL be present if verificationStatus is not entered-in-error [verificationStatus='entered-in-error' or clinicalStatus.exists()] (src = InstanceValidator) ERROR @ CarePlan.addresses[2].contained: Condition.clinicalStatus SHALL be present if verificationStatus is not entered-in-error [verificationStatus='entered-in-error' or clinicalStatus.exists()] (src = InstanceValidator) ERROR @ CarePlan.addresses[3].contained: Condition.clinicalStatus SHALL be present if verificationStatus is not entered-in-error [verificationStatus='entered-in-error' or clinicalStatus.exists()] (src = InstanceValidator) preg ERROR @ CarePlan: If the resource is contained in another resource, it SHALL be referred to from elsewhere in the resource [contained.where(('#'+id in %resource.descendants().reference).not()).empty()] (src = InstanceValidator) ERROR @ CarePlan: Profile http://hl7.org/fhir/StructureDefinition/CarePlan, Element 'CarePlan.intent': minimum required = 1, but only found 0 (src = InstanceValidator) ERROR @ CarePlan.contained[1]: Condition.clinicalStatus SHALL be present if verificationStatus is not entered-in-error [verificationStatus='entered-in-error' or clinicalStatus.exists()] (src = InstanceValidator) ERROR @ CarePlan.addresses.contained: Condition.clinicalStatus SHALL be present if verificationStatus is not entered-in-error [verificationStatus='entered-in-error' or clinicalStatus.exists()] (src = InstanceValidator) <p>No validation errors - all conversions are clean</p>