R4 Ballot #1 #2 (Mixed Normative/Trial use)

This page is part of the FHIR Specification (v3.3.0: (v3.5.0: R4 Ballot 2). #2). 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

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

R2 : R3 : R4 Conversion maps for CarePlan.

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

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

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


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


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

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

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

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


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

group CarePlan extends DomainResource
  input src : CarePlanR3 as source
  input tgt : CarePlan as target


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

  "CarePlan.identifier": for src.identifier make tgt.identifier
  "CarePlan.instantiatesCanonical": for src.instantiatesCanonical make tgt.instantiatesCanonical
  "CarePlan.instantiatesUri": for src.instantiatesUri make tgt.instantiatesUri
  "CarePlan.basedOn": for src.basedOn make tgt.basedOn
  "CarePlan.replaces": for src.replaces make tgt.replaces
  "CarePlan.partOf": for src.partOf make tgt.partOf
  "CarePlan.status": for src.status make tgt.status
  "CarePlan.intent": for src.intent make tgt.intent
  "CarePlan.category": for src.category make tgt.category
  "CarePlan.title": for src.title make tgt.title
  "CarePlan.description": for src.description make tgt.description
  "CarePlan.subject": for src.subject make tgt.subject
  "CarePlan.context": for src.context make tgt.context
  "CarePlan.period": for src.period make tgt.period
  "CarePlan.created": for src.created make tgt.created
  "CarePlan.author": for src.author make tgt.author
  "CarePlan.contributor": for src.contributor make tgt.contributor
  "CarePlan.careTeam": for src.careTeam make tgt.careTeam
  "CarePlan.addresses": for src.addresses make tgt.addresses
  "CarePlan.supportingInfo": for src.supportingInfo make tgt.supportingInfo
  "CarePlan.goal": for src.goal make tgt.goal
  "CarePlan.activity": for src.activity as s make tgt.activity as t then CarePlanActivity(s,t)
  "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.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

group CarePlanActivity extends BackboneElement
  input src : CarePlanR3 as source
  input tgt : CarePlan 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 

  "CarePlan.activity.outcomeCodeableConcept": for src.outcomeCodeableConcept make tgt.outcomeCodeableConcept
  "CarePlan.activity.outcomeReference": for src.outcomeReference 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 s make tgt.detail as t then CarePlanActivityDetail(s,t)

endgroup

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

  "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 plnParticipantMember extends BackboneElement
  input src as source
  input tgt as target

group CarePlanActivityDetail extends BackboneElement
  input src : CarePlanR3 as source
  input tgt : CarePlan as target


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

  "CarePlan.activity.detail.kind": for src.kind make tgt.kind
  "CarePlan.activity.detail.instantiatesCanonical": for src.instantiatesCanonical make tgt.instantiatesCanonical
  "CarePlan.activity.detail.instantiatesUri": for src.instantiatesUri make tgt.instantiatesUri
  "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.doNotPerform": for src.doNotPerform make tgt.doNotPerform
  "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/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

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


  "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

uses "http://hl7.org/fhir/StructureDefinition/CarePlan" alias CarePlan as source
uses "http://hl7.org/fhir/3.0/StructureDefinition/CarePlan" alias CarePlanR3 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

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


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

group CarePlan extends DomainResource
  input src : CarePlanR3 as source
  input tgt : CarePlan 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 

  "CarePlan.identifier": for src.identifier make tgt.identifier
  "CarePlan.instantiatesCanonical": for src.instantiatesCanonical make tgt.instantiatesCanonical
  "CarePlan.instantiatesUri": for src.instantiatesUri make tgt.instantiatesUri
  "CarePlan.basedOn": for src.basedOn make tgt.basedOn
  "CarePlan.replaces": for src.replaces make tgt.replaces
  "CarePlan.partOf": for src.partOf make tgt.partOf
  "CarePlan.status": for src.status make tgt.status
  "CarePlan.intent": for src.intent make tgt.intent
  "CarePlan.category": for src.category make tgt.category
  "CarePlan.title": for src.title make tgt.title
  "CarePlan.description": for src.description make tgt.description
  "CarePlan.subject": for src.subject make tgt.subject
  "CarePlan.context": for src.context make tgt.context
  "CarePlan.period": for src.period make tgt.period
  "CarePlan.created": for src.created make tgt.created
  "CarePlan.author": for src.author make tgt.author
  "CarePlan.contributor": for src.contributor make tgt.contributor
  "CarePlan.careTeam": for src.careTeam make tgt.careTeam
  "CarePlan.addresses": for src.addresses make tgt.addresses
  "CarePlan.supportingInfo": for src.supportingInfo make tgt.supportingInfo
  "CarePlan.goal": for src.goal make tgt.goal
  "CarePlan.activity": for src.activity as s make tgt.activity as t then CarePlanActivity(s,t)
  "CarePlan.note": for src.note make tgt.note

endgroup

group CarePlanActivity extends BackboneElement
  input src : CarePlanR3 as source
  input tgt : CarePlan as target


group plnParticipant 
  input src as source
  input tgt as target

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

  "CarePlan.activity.outcomeCodeableConcept": for src.outcomeCodeableConcept make tgt.outcomeCodeableConcept
  "CarePlan.activity.outcomeReference": for src.outcomeReference 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 s make tgt.detail as t then CarePlanActivityDetail(s,t)

endgroup

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

group CarePlanActivityDetail extends BackboneElement
  input src : CarePlanR3 as source
  input tgt : CarePlan as target


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

  "CarePlan.activity.detail.kind": for src.kind make tgt.kind
  "CarePlan.activity.detail.instantiatesCanonical": for src.instantiatesCanonical make tgt.instantiatesCanonical
  "CarePlan.activity.detail.instantiatesUri": for src.instantiatesUri make tgt.instantiatesUri
  "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.doNotPerform": for src.doNotPerform make tgt.doNotPerform
  "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



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)