# entry[].resource.text.div
Generated Narrative: StructureMap Account2to3

/// url = 'http://hl7.org/fhir/uv/xver/StructureMap/Account2to3'
/// name = 'Account2to3'
/// title = 'Account Transforms: R2 to R3'
/// status = 'active'

uses "http://hl7.org/fhir/1.0/StructureDefinition/Account" alias AccountR2 as source
uses "http://hl7.org/fhir/3.0/StructureDefinition/Account" alias Account as target

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

group Account(source src : AccountR2, target tgt : Account) extends DomainResource <<type+>> {
  src.identifier -> tgt.identifier "Accountidentifier";
  src.name -> tgt.name "Accountname";
  src.type -> tgt.type "Accounttype";
  src.status -> tgt.status "Accountstatus";
  src.activePeriod -> tgt.active "Accountactive";
  src.balance -> tgt.balance "Accountbalance";
  src.subject -> tgt.subject "Accountsubject";
  src.owner -> tgt.owner "Accountowner";
  src.description -> tgt.description "Accountdescription";
}

# entry[].resource.text.div
Generated Narrative: StructureMap Account3to2

/// url = 'http://hl7.org/fhir/uv/xver/StructureMap/Account3to2'
/// name = 'Account3to2'
/// title = 'Account Transforms: R3 to R2'
/// status = 'active'

uses "http://hl7.org/fhir/3.0/StructureDefinition/Account" alias Account as source
uses "http://hl7.org/fhir/1.0/StructureDefinition/Account" alias AccountR2 as target

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

group Account(source src : Account, target tgt : AccountR2) extends DomainResource <<type+>> {
  src.identifier -> tgt.identifier "Accountidentifier";
  src.name -> tgt.name "Accountname";
  src.type -> tgt.type "Accounttype";
  src.status -> tgt.status "Accountstatus";
  src.active -> tgt.activePeriod "AccountactivePeriod";
  src.balance -> tgt.balance "Accountbalance";
  src.subject -> tgt.subject "Accountsubject";
  src.owner -> tgt.owner "Accountowner";
  src.description -> tgt.description "Accountdescription";
}

# entry[].resource.text.div
Generated Narrative: StructureMap Account3to4

/// url = 'http://hl7.org/fhir/uv/xver/StructureMap/Account3to4'
/// name = 'Account3to4'
/// title = 'Account Transforms: R3 to R4'
/// status = 'active'

uses "http://hl7.org/fhir/3.0/StructureDefinition/Account" alias AccountR3 as source
uses "http://hl7.org/fhir/4.0/StructureDefinition/Account" alias Account as target

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

group Account(source src : AccountR3, target tgt : Account) extends DomainResource <<type+>> {
  src.identifier -> tgt.identifier;
  src.status -> tgt.status;
  src.type -> tgt.type;
  src.name -> tgt.name;
  src.subject -> tgt.subject;
  src.period -> tgt.servicePeriod;
  src.coverage as s -> tgt.coverage as t then AccountCoverage(s, t);
  src.owner -> tgt.owner;
  src.description -> tgt.description;
  src.guarantor as s -> tgt.guarantor as t then AccountGuarantor(s, t);
}

group AccountCoverage(source src, target tgt) extends BackboneElement {
  src.coverage -> tgt.coverage;
  src.priority -> tgt.priority;
}

group AccountGuarantor(source src, target tgt) extends BackboneElement {
  src.party -> tgt.party;
  src.onHold -> tgt.onHold;
  src.period -> tgt.period;
}

# entry[].resource.text.div
Generated Narrative: StructureMap Account4to3

/// url = 'http://hl7.org/fhir/uv/xver/StructureMap/Account4to3'
/// name = 'Account4to3'
/// title = 'Account Transforms: R4 to R3'
/// status = 'active'

uses "http://hl7.org/fhir/4.0/StructureDefinition/Account" alias Account as source
uses "http://hl7.org/fhir/3.0/StructureDefinition/Account" alias AccountR3 as target

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

group Account(source src : Account, target tgt : AccountR3) extends DomainResource <<type+>> {
  src.identifier -> tgt.identifier;
  src.status -> tgt.status;
  src.type -> tgt.type;
  src.name -> tgt.name;
  src.subject -> tgt.subject;
  src.servicePeriod -> tgt.period;
  src.coverage as s -> tgt.coverage as t then AccountCoverage(s, t);
  src.owner -> tgt.owner;
  src.description -> tgt.description;
  src.guarantor as s -> tgt.guarantor as t then AccountGuarantor(s, t);
}

group AccountCoverage(source src, target tgt) extends BackboneElement {
  src.coverage -> tgt.coverage;
  src.priority -> tgt.priority;
}

group AccountGuarantor(source src, target tgt) extends BackboneElement {
  src.party -> tgt.party;
  src.onHold -> tgt.onHold;
  src.period -> tgt.period;
}

# entry[].resource.text.div
Generated Narrative: StructureMap Account5to4b

/// url = 'http://hl7.org/fhir/uv/xver/StructureMap/Account5to4b'
/// name = 'Account5to4b'
/// title = 'Account Transforms: R5 to R4B'
/// status = 'active'

uses "http://hl7.org/fhir/5.0/StructureDefinition/Account" alias AccountR5 as source
uses "http://hl7.org/fhir/4.3/StructureDefinition/Account" alias AccountR4B as target

imports "http://hl7.org/fhir/uv/xver/StructureMap/*5to4b"

group Account(source src : AccountR5, target tgt : AccountR4B) extends DomainResource <<type+>> {
  src.identifier -> tgt.identifier;
  src.status as v -> tgt.status = translate(v, 'http://hl7.org/fhir/uv/xver/ConceptMap/act.status-5to4b', 'code');
  src.type -> tgt.type;
  src.name -> tgt.name;
  src.subject -> tgt.subject;
  src.servicePeriod -> tgt.servicePeriod;
  src.coverage as s -> tgt.coverage as t then AccountCoverage(s, t);
  src.owner -> tgt.owner;
  src.description -> tgt.description;
  src.guarantor as s -> tgt.guarantor as t then AccountGuarantor(s, t);
}

group AccountCoverage(source src, target tgt) extends BackboneElement {
  src.coverage -> tgt.coverage;
  src.priority -> tgt.priority;
}

group AccountGuarantor(source src, target tgt) extends BackboneElement {
  src.party -> tgt.party;
  src.onHold -> tgt.onHold;
  src.period -> tgt.period;
}

# entry[].resource.text.div
Generated Narrative: StructureMap ActivityDefinition3to4

/// url = 'http://hl7.org/fhir/uv/xver/StructureMap/ActivityDefinition3to4'
/// name = 'ActivityDefinition3to4'
/// title = 'ActivityDefinition Transforms: R3 to R4'
/// status = 'active'

uses "http://hl7.org/fhir/3.0/StructureDefinition/ActivityDefinition" alias ActivityDefinitionR3 as source
uses "http://hl7.org/fhir/4.0/StructureDefinition/ActivityDefinition" alias ActivityDefinition as target

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

group ActivityDefinition(source src : ActivityDefinitionR3, target tgt : ActivityDefinition) extends DomainResource <<type+>> {
  src.url -> tgt.url;
  src.identifier -> tgt.identifier;
  src.version -> tgt.version;
  src.name -> tgt.name;
  src.title -> tgt.title;
  src.status -> tgt.status;
  src.experimental -> tgt.experimental;
  src.date -> tgt.date;
  src.publisher -> tgt.publisher;
  src.contact -> tgt.contact;
  src.description -> tgt.description;
  src.useContext -> tgt.useContext;
  src.jurisdiction -> tgt.jurisdiction;
  src.purpose -> tgt.purpose;
  src.usage -> tgt.usage;
  src.copyright -> tgt.copyright;
  src.approvalDate -> tgt.approvalDate;
  src.lastReviewDate -> tgt.lastReviewDate;
  src.effectivePeriod -> tgt.effectivePeriod;
  src.topic -> tgt.topic;
  src.contributor as vs where (type = 'author') -> tgt.author as vt then Contributor(vs, vt);
  src.contributor as vs where (type = 'editor') -> tgt.editor as vt then Contributor(vs, vt);
  src.contributor as vs where (type = 'reviewer') -> tgt.reviewer as vt then Contributor(vs, vt);
  src.contributor as vs where (type = 'endorser') -> tgt.endorser as vt then Contributor(vs, vt);
  src.relatedArtifact -> tgt.relatedArtifact;
  src.library -> tgt.library;
  src.kind as v -> tgt.kind = translate(v, 'http://hl7.org/fhir/uv/xver/ConceptMap/resources-3to4', 'code');
  src.code -> tgt.code;
  src.timing -> tgt.timing;
  src.location -> tgt.location;
  src.participant as s -> tgt.participant as t then ActivityDefinitionParticipant(s, t);
  src.product -> tgt.product;
  src.quantity -> tgt.quantity;
  src.dosage -> tgt.dosage;
  src.bodySite -> tgt.bodySite;
  src.transform -> tgt.transform;
  src.dynamicValue as s -> tgt.dynamicValue as t then ActivityDefinitionDynamicValue(s, t);
}

group ActivityDefinitionParticipant(source src, target tgt) extends BackboneElement {
  src.type -> tgt.type;
  src.role -> tgt.role;
}

group ActivityDefinitionDynamicValue(source src, target tgt) extends BackboneElement {
  src.path -> tgt.path;
  src as vs -> tgt.expression as vt then {
    vs.description -> vt.description;
    vs.language -> vt.language;
    vs.expression -> vt.expression;
  } "expression";
}

# entry[].resource.text.div
Generated Narrative: StructureMap ActivityDefinition4to3

/// url = 'http://hl7.org/fhir/uv/xver/StructureMap/ActivityDefinition4to3'
/// name = 'ActivityDefinition4to3'
/// title = 'ActivityDefinition Transforms: R4 to R3'
/// status = 'active'

uses "http://hl7.org/fhir/4.0/StructureDefinition/ActivityDefinition" alias ActivityDefinition as source
uses "http://hl7.org/fhir/3.0/StructureDefinition/ActivityDefinition" alias ActivityDefinitionR3 as target

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

group ActivityDefinition(source src : ActivityDefinition, target tgt : ActivityDefinitionR3) extends DomainResource <<type+>> {
  src.url -> tgt.url;
  src.identifier -> tgt.identifier;
  src.version -> tgt.version;
  src.name -> tgt.name;
  src.title -> tgt.title;
  src.status -> tgt.status;
  src.experimental -> tgt.experimental;
  src.date -> tgt.date;
  src.publisher -> tgt.publisher;
  src.contact -> tgt.contact;
  src.description -> tgt.description;
  src.useContext -> tgt.useContext;
  src.jurisdiction -> tgt.jurisdiction;
  src.purpose -> tgt.purpose;
  src.usage -> tgt.usage;
  src.copyright -> tgt.copyright;
  src.approvalDate -> tgt.approvalDate;
  src.lastReviewDate -> tgt.lastReviewDate;
  src.effectivePeriod -> tgt.effectivePeriod;
  src.topic -> tgt.topic;
  src.author as vs ->  tgt.contributor as vt,  vt.type = 'author' then Contributor(vs, vt);
  src.editor as vs ->  tgt.contributor as vt,  vt.type = 'editor' then Contributor(vs, vt);
  src.reviewer as vs ->  tgt.contributor as vt,  vt.type = 'reviewer' then Contributor(vs, vt);
  src.endorser as vs ->  tgt.contributor as vt,  vt.type = 'endorser' then Contributor(vs, vt);
  src.relatedArtifact -> tgt.relatedArtifact;
  src.library -> tgt.library;
  src.kind as v -> tgt.kind = translate(v, 'http://hl7.org/fhir/uv/xver/ConceptMap/resources-4to3', 'code');
  src.code -> tgt.code;
  src.timing : Timing -> tgt.timing; // R4 also has Age and Duration in src.timing
  src.timing : dateTime -> tgt.timing;
  src.timing : Period -> tgt.timing;
  src.timing : Range -> tgt.timing;
  src.location -> tgt.location;
  src.participant as s -> tgt.participant as t then ActivityDefinitionParticipant(s, t);
  src.product -> tgt.product;
  src.quantity -> tgt.quantity;
  src.dosage -> tgt.dosage;
  src.bodySite -> tgt.bodySite;
  src.transform -> tgt.transform;
  src.dynamicValue as s -> tgt.dynamicValue as t then ActivityDefinitionDynamicValue(s, t);
}

group ActivityDefinitionParticipant(source src, target tgt) extends BackboneElement {
  src.type -> tgt.type;
  src.role -> tgt.role;
}

group ActivityDefinitionDynamicValue(source src, target tgt) extends BackboneElement {
  src.path -> tgt.path;
  src.expression as vs -> tgt as vt then {
    vs.description -> vt.description;
    vs.language -> vt.language;
    vs.expression -> vt.expression;
  };
}

# entry[].resource.group[].rule[].documentation
R4 also has Age and Duration in src.timing

# entry[].resource.text.div
Generated Narrative: StructureMap ActivityDefinition5to4b

/// url = 'http://hl7.org/fhir/uv/xver/StructureMap/ActivityDefinition5to4b'
/// name = 'ActivityDefinition5to4b'
/// title = 'ActivityDefinition Transforms: R5 to R4B'
/// status = 'active'

uses "http://hl7.org/fhir/5.0/StructureDefinition/ActivityDefinition" alias ActivityDefinitionR5 as source
uses "http://hl7.org/fhir/4.3/StructureDefinition/ActivityDefinition" alias ActivityDefinitionR4B as target

imports "http://hl7.org/fhir/uv/xver/StructureMap/*5to4b"

group ActivityDefinition(source src : ActivityDefinitionR5, target tgt : ActivityDefinitionR4B) extends DomainResource <<type+>> {
  src.url -> tgt.url;
  src.identifier -> tgt.identifier;
  src.version -> tgt.version;
  src.name -> tgt.name;
  src.title -> tgt.title;
  src.subtitle -> tgt.subtitle;
  src.status as v -> tgt.status = translate(v, 'http://hl7.org/fhir/uv/xver/ConceptMap/adf.status-5to4b', 'code');
  src.experimental -> tgt.experimental;
  src.subject as s where (coding.exists((code = 'Patient') and (system = 'http://hl7.org/fhir/fhir-types'))) ->  tgt.subject = create('CodeableConcept') as tc,  tc.coding as tcc,  tcc.system = 'http://hl7.org/fhir/resource-types',  tcc.code = 'Patient',  tcc.display = 'Patient';
  src.subject as s where (coding.exists((code = 'Practitioner') and (system = 'http://hl7.org/fhir/fhir-types'))) ->  tgt.subject = create('CodeableConcept') as tc,  tc.coding as tcc,  tcc.system = 'http://hl7.org/fhir/resource-types',  tcc.code = 'Patient',  tcc.display = 'Practitioner';
  src.subject as s where (coding.exists((code = 'Organization') and (system = 'http://hl7.org/fhir/fhir-types'))) ->  tgt.subject = create('CodeableConcept') as tc,  tc.coding as tcc,  tcc.system = 'http://hl7.org/fhir/resource-types',  tcc.code = 'Patient',  tcc.display = 'Organization';
  src.subject as s where (coding.exists((code = 'Location') and (system = 'http://hl7.org/fhir/fhir-types'))) ->  tgt.subject = create('CodeableConcept') as tc,  tc.coding as tcc,  tcc.system = 'http://hl7.org/fhir/resource-types',  tcc.code = 'Patient',  tcc.display = 'Location';
  src.subject as s where (coding.exists((code = 'Device') and (system = 'http://hl7.org/fhir/fhir-types'))) ->  tgt.subject = create('CodeableConcept') as tc,  tc.coding as tcc,  tcc.system = 'http://hl7.org/fhir/resource-types',  tcc.code = 'Patient',  tcc.display = 'Device';
  src.subject : Reference -> tgt.subject;
  src.subject : canonical -> tgt.subject;
  src.date -> tgt.date;
  src.publisher -> tgt.publisher;
  src.contact -> tgt.contact;
  src.description -> tgt.description;
  src.useContext -> tgt.useContext;
  src.jurisdiction -> tgt.jurisdiction;
  src.purpose -> tgt.purpose;
  src.usage -> tgt.usage;
  src.copyright -> tgt.copyright;
  src.approvalDate -> tgt.approvalDate;
  src.lastReviewDate -> tgt.lastReviewDate;
  src.effectivePeriod -> tgt.effectivePeriod;
  src.topic -> tgt.topic;
  src.author -> tgt.author;
  src.editor -> tgt.editor;
  src.reviewer -> tgt.reviewer;
  src.endorser -> tgt.endorser;
  src.relatedArtifact -> tgt.relatedArtifact;
  src.library -> tgt.library;
  src.kind -> tgt.kind;
  src.profile -> tgt.profile;
  src.code -> tgt.code;
  src.intent as v -> tgt.intent = translate(v, 'http://hl7.org/fhir/uv/xver/ConceptMap/adf.intent-5to4b', 'code');
  src.priority as v -> tgt.priority = translate(v, 'http://hl7.org/fhir/uv/xver/ConceptMap/adf.priority-5to4b', 'code');
  src.doNotPerform -> tgt.doNotPerform;
  src.timing : Timing -> tgt.timing;
  src.timing : Age -> tgt.timing;
  src.timing : Range -> tgt.timing;
  src.timing : Duration -> tgt.timing;
  src.location -> tgt.location;
  src.participant as s -> tgt.participant as t then ActivityDefinitionParticipant(s, t);
  src.product : Reference -> tgt.product;
  src.product : CodeableConcept -> tgt.product;
  src.quantity -> tgt.quantity;
  src.dosage -> tgt.dosage;
  src.bodySite -> tgt.bodySite;
  src.specimenRequirement -> tgt.specimenRequirement;
  src.observationRequirement -> tgt.observationRequirement;
  src.observationResultRequirement -> tgt.observationResultRequirement;
  src.transform -> tgt.transform;
  src.dynamicValue as s -> tgt.dynamicValue as t then ActivityDefinitionDynamicValue(s, t);
}

group ActivityDefinitionParticipant(source src, target tgt) extends BackboneElement {
  src.type as v -> tgt.type = translate(v, 'http://hl7.org/fhir/uv/xver/ConceptMap/adf.pa.type-5to4b', 'code');
  src.role -> tgt.role;
}

group ActivityDefinitionDynamicValue(source src, target tgt) extends BackboneElement {
  src.path -> tgt.path;
  src.expression -> tgt.expression;
}

# entry[].resource.title
ActivityDefinition Transforms: R5 to R4B

# entry[].resource.text.div
Generated Narrative: StructureMap Address2to3

/// url = 'http://hl7.org/fhir/uv/xver/StructureMap/Address2to3'
/// name = 'Address2to3'
/// title = 'Address Transforms: R2 to R3'
/// status = 'active'

uses "http://hl7.org/fhir/1.0/StructureDefinition/Address" alias AddressR2 as source
uses "http://hl7.org/fhir/3.0/StructureDefinition/Address" alias Address as target

imports "http://hl7.org/fhir/uv/xver/StructureMap/primitives2to3"
imports "http://hl7.org/fhir/uv/xver/StructureMap/Element2to3"
imports "http://hl7.org/fhir/uv/xver/StructureMap/Period2to3"

group Address(source src : AddressR2, target tgt : Address) extends Element <<type+>> {
  src.use -> tgt.use "Addressuse";
  src.type -> tgt.type "Addresstype";
  src.text -> tgt.text "Addresstext";
  src.line -> tgt.line "Addressline";
  src.city -> tgt.city "Addresscity";
  src.district -> tgt.district "Addressdistrict";
  src.state -> tgt.state "Addressstate";
  src.postalCode -> tgt.postalCode "AddresspostalCode";
  src.country -> tgt.country "Addresscountry";
  src.period -> tgt.period "Addressperiod";
}

# entry[].resource.text.div
Generated Narrative: StructureMap Address3to2

/// url = 'http://hl7.org/fhir/uv/xver/StructureMap/Address3to2'
/// name = 'Address3to2'
/// title = 'Address Transforms: R3 to R2'
/// status = 'active'

uses "http://hl7.org/fhir/3.0/StructureDefinition/Address" alias Address as source
uses "http://hl7.org/fhir/1.0/StructureDefinition/Address" alias AddressR2 as target

imports "http://hl7.org/fhir/uv/xver/StructureMap/primitives3to2"
imports "http://hl7.org/fhir/uv/xver/StructureMap/Element3to2"
imports "http://hl7.org/fhir/uv/xver/StructureMap/Period3to2"

group Address(source src : Address, target tgt : AddressR2) extends Element <<type+>> {
  src.use -> tgt.use "Addressuse";
  src.type -> tgt.type "Addresstype";
  src.text -> tgt.text "Addresstext";
  src.line -> tgt.line "Addressline";
  src.city -> tgt.city "Addresscity";
  src.district -> tgt.district "Addressdistrict";
  src.state -> tgt.state "Addressstate";
  src.postalCode -> tgt.postalCode "AddresspostalCode";
  src.country -> tgt.country "Addresscountry";
  src.period -> tgt.period "Addressperiod";
}

# entry[].resource.text.div
Generated Narrative: StructureMap Address3to4

/// url = 'http://hl7.org/fhir/uv/xver/StructureMap/Address3to4'
/// name = 'Address3to4'
/// title = 'Address Transforms: R3 to R4'
/// status = 'active'

uses "http://hl7.org/fhir/3.0/StructureDefinition/Address" alias AddressR3 as source
uses "http://hl7.org/fhir/4.0/StructureDefinition/Address" alias Address as target

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

group Address(source src : AddressR3, target tgt : Address) extends Element <<type+>> {
  src.use -> tgt.use;
  src.type -> tgt.type;
  src.text -> tgt.text;
  src.line -> tgt.line;
  src.city -> tgt.city;
  src.district -> tgt.district;
  src.state -> tgt.state;
  src.postalCode -> tgt.postalCode;
  src.country -> tgt.country;
  src.period -> tgt.period;
}

# entry[].resource.text.div
Generated Narrative: StructureMap Address4to3

/// url = 'http://hl7.org/fhir/uv/xver/StructureMap/Address4to3'
/// name = 'Address4to3'
/// title = 'Address Transforms: R4 to R3'
/// status = 'active'

uses "http://hl7.org/fhir/4.0/StructureDefinition/Address" alias Address as source
uses "http://hl7.org/fhir/3.0/StructureDefinition/Address" alias AddressR3 as target

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

group Address(source src : Address, target tgt : AddressR3) extends Element <<type+>> {
  src.use -> tgt.use;
  src.type -> tgt.type;
  src.text -> tgt.text;
  src.line -> tgt.line;
  src.city -> tgt.city;
  src.district -> tgt.district;
  src.state -> tgt.state;
  src.postalCode -> tgt.postalCode;
  src.country -> tgt.country;
  src.period -> tgt.period;
}

# entry[].resource.text.div
Generated Narrative: StructureMap Address5to4b

/// url = 'http://hl7.org/fhir/uv/xver/StructureMap/Address5to4b'
/// name = 'Address5to4b'
/// title = 'Address Transforms: R5 to R4B'
/// status = 'active'

uses "http://hl7.org/fhir/5.0/StructureDefinition/Address" alias AddressR5 as source
uses "http://hl7.org/fhir/4.3/StructureDefinition/Address" alias AddressR4B as target

imports "http://hl7.org/fhir/uv/xver/StructureMap/*5to4b"

group Address(source src : AddressR5, target tgt : AddressR4B) extends Element <<type+>> {
  src.use as v -> tgt.use = translate(v, 'http://hl7.org/fhir/uv/xver/ConceptMap/add.use-5to4b', 'code');
  src.type as v -> tgt.type = translate(v, 'http://hl7.org/fhir/uv/xver/ConceptMap/add.type-5to4b', 'code');
  src.text -> tgt.text;
  src.line -> tgt.line;
  src.city -> tgt.city;
  src.district -> tgt.district;
  src.state -> tgt.state;
  src.postalCode -> tgt.postalCode;
  src.country -> tgt.country;
  src.period -> tgt.period;
}

# entry[].resource.text.div
Generated Narrative: StructureMap AdministrableProductDefinition5to4b

/// url = 'http://hl7.org/fhir/uv/xver/StructureMap/AdministrableProductDefinition5to4b'
/// name = 'AdministrableProductDefinition5to4b'
/// title = 'AdministrableProductDefinition Transforms: R5 to R4B'
/// status = 'active'

uses "http://hl7.org/fhir/5.0/StructureDefinition/AdministrableProductDefinition" alias AdministrableProductDefinitionR5 as source
uses "http://hl7.org/fhir/4.3/StructureDefinition/AdministrableProductDefinition" alias AdministrableProductDefinitionR4B as target

imports "http://hl7.org/fhir/uv/xver/StructureMap/*5to4b"

group AdministrableProductDefinition(source src : AdministrableProductDefinitionR5, target tgt : AdministrableProductDefinitionR4B) extends DomainResource <<type+>> {
  src.identifier -> tgt.identifier;
  src.status as v -> tgt.status = translate(v, 'http://hl7.org/fhir/uv/xver/ConceptMap/apd.status-5to4b', 'code');
  src.formOf -> tgt.formOf;
  src.administrableDoseForm -> tgt.administrableDoseForm;
  src.unitOfPresentation -> tgt.unitOfPresentation;
  src.producedFrom -> tgt.producedFrom;
  src.ingredient -> tgt.ingredient;
  src.device -> tgt.device;
  src.property as s -> tgt.property as t then AdministrableProductDefinitionProperty(s, t);
  src.routeOfAdministration as s -> tgt.routeOfAdministration as t then AdministrableProductDefinitionRouteOfAdministration(s, t);
}

group AdministrableProductDefinitionProperty(source src, target tgt) extends BackboneElement {
  src.type -> tgt.type;
  src.value : CodeableConcept -> tgt.value;
  src.value : Quantity -> tgt.value;
  src.value : date -> tgt.value;
  src.value : boolean -> tgt.value;
  src.value : Attachment -> tgt.value;
  src.status as v -> tgt.status = translate(v, 'http://hl7.org/fhir/uv/xver/ConceptMap/apd.pr.status-5to4b', 'code');
}

group AdministrableProductDefinitionRouteOfAdministration(source src, target tgt) extends BackboneElement {
  src.code -> tgt.code;
  src.firstDose -> tgt.firstDose;
  src.maxSingleDose -> tgt.maxSingleDose;
  src.maxDosePerDay -> tgt.maxDosePerDay;
  src.maxDosePerTreatmentPeriod -> tgt.maxDosePerTreatmentPeriod;
  src.maxTreatmentPeriod -> tgt.maxTreatmentPeriod;
  src.targetSpecies as s -> tgt.targetSpecies as t then AdministrableProductDefinitionRouteOfAdministrationTargetSpecies(s, t);
}

group AdministrableProductDefinitionRouteOfAdministrationTargetSpecies(source src, target tgt) extends BackboneElement {
  src.code -> tgt.code;
  src.withdrawalPeriod as s -> tgt.withdrawalPeriod as t then RouteOfAdministrationTargetSpeciesWithdrawalPeriod(s, t);
}

group RouteOfAdministrationTargetSpeciesWithdrawalPeriod(source src, target tgt) extends BackboneElement {
  src.tissue -> tgt.tissue;
  src.value -> tgt.value;
  src.supportingInformation -> tgt.supportingInformation;
}

# entry[].resource.text.div
Generated Narrative: StructureMap AdverseEvent3to4

/// url = 'http://hl7.org/fhir/uv/xver/StructureMap/AdverseEvent3to4'
/// name = 'AdverseEvent3to4'
/// title = 'AdverseEvent Transforms: R3 to R4'
/// status = 'active'

uses "http://hl7.org/fhir/3.0/StructureDefinition/AdverseEvent" alias AdverseEventR3 as source
uses "http://hl7.org/fhir/4.0/StructureDefinition/AdverseEvent" alias AdverseEvent as target

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

group AdverseEvent(source src : AdverseEventR3, target tgt : AdverseEvent) extends DomainResource <<type+>> {
  src.identifier -> tgt.identifier;
  src.category as vs ->  tgt.category as vt,  vt.coding as c,  c.system = 'http://terminology.hl7.org/CodeSystem/adverse-event-category',  c.code = vs;
  src.type -> tgt.event;
  src.description as vs where (src.type.exists().not()) ->  tgt.event as vt,  vt.text = vs "DescriptionWhenNoEvent";
  src.subject -> tgt.subject; // use description in leiu of type for event
  src.date -> tgt.date;
  src.reaction -> tgt.resultingCondition;
  src.location -> tgt.location;
  src.seriousness -> tgt.seriousness;
  src.outcome -> tgt.outcome;
  src.recorder -> tgt.recorder;
  src.eventParticipant -> tgt.contributor;
  src.suspectEntity as s -> tgt.suspectEntity as t then AdverseEventSuspectEntity(s, t);
  src.subjectMedicalHistory -> tgt.subjectMedicalHistory;
  src.referenceDocument -> tgt.referenceDocument;
  src.study -> tgt.study;
}

group AdverseEventSuspectEntity(source src, target tgt) extends BackboneElement {
  src.instance -> tgt.instance;
  src.causality;
  src -> tgt.causality as t then {
    src.causalityAssessment -> t.assessment;
    src.causalityProductRelatedness -> t.productRelatedness;
    src.causalityAuthor -> t.author;
    src.causalityMethod -> t.method;
  } "CopyCausality"; // not migrated to R4
}

# entry[].resource.group[].rule[].documentation
use description in leiu of type for event

# entry[].resource.text.div
Generated Narrative: StructureMap AdverseEvent4to3

/// url = 'http://hl7.org/fhir/uv/xver/StructureMap/AdverseEvent4to3'
/// name = 'AdverseEvent4to3'
/// title = 'AdverseEvent Transforms: R4 to R3'
/// status = 'active'

uses "http://hl7.org/fhir/4.0/StructureDefinition/AdverseEvent" alias AdverseEvent as source
uses "http://hl7.org/fhir/3.0/StructureDefinition/AdverseEvent" alias AdverseEventR3 as target

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

group AdverseEvent(source src : AdverseEvent, target tgt : AdverseEventR3) extends DomainResource <<type+>> {
  src.identifier -> tgt.identifier;
  src.category as vs then {
    vs.coding as c where (system = 'http://terminology.hl7.org/CodeSystem/adverse-event-category') then {
      c.code -> tgt.category;
    };
  };
  src.event -> tgt.type;
  src.subject -> tgt.subject;
  src.date -> tgt.date;
  src.resultingCondition -> tgt.reaction;
  src.location -> tgt.location;
  src.seriousness -> tgt.seriousness;
  src.outcome -> tgt.outcome;
  src.recorder -> tgt.recorder;
  src.contributor -> tgt.eventParticipant;
  src.suspectEntity as s -> tgt.suspectEntity as t then AdverseEventSuspectEntity(s, t);
  src.subjectMedicalHistory -> tgt.subjectMedicalHistory;
  src.referenceDocument -> tgt.referenceDocument;
  src.study -> tgt.study;
}

group AdverseEventSuspectEntity(source src, target tgt) extends BackboneElement {
  src.instance -> tgt.instance;
  src.causality as s -> tgt as t then AdverseEventSuspectEntityCausality(s, t);
}

group AdverseEventSuspectEntityCausality(source src, target tgt) extends BackboneElement {
  src.assessment -> tgt.causalityAssessment;
  src.productRelatedness -> tgt.causalityProductRelatedness;
  src.author -> tgt.causalityAuthor;
  src.method -> tgt.causalityMethod;
}

# entry[].resource.text.div
Generated Narrative: StructureMap AdverseEvent5to4b

/// url = 'http://hl7.org/fhir/uv/xver/StructureMap/AdverseEvent5to4b'
/// name = 'AdverseEvent5to4b'
/// title = 'AdverseEvent Transforms: R5 to R4B'
/// status = 'active'

uses "http://hl7.org/fhir/5.0/StructureDefinition/AdverseEvent" alias AdverseEventR5 as source
uses "http://hl7.org/fhir/4.3/StructureDefinition/AdverseEvent" alias AdverseEventR4B as target

imports "http://hl7.org/fhir/uv/xver/StructureMap/*5to4b"

group AdverseEvent(source src : AdverseEventR5, target tgt : AdverseEventR4B) extends DomainResource <<type+>> {
  src.identifier -> tgt.identifier;
  src.actuality as v -> tgt.actuality = translate(v, 'http://hl7.org/fhir/uv/xver/ConceptMap/aev.actuality-5to4b', 'code');
  src.category -> tgt.category;
  src.code -> tgt.event;
  src.subject -> tgt.subject;
  src.encounter -> tgt.encounter;
  src.occurrence : dateTime -> tgt.date;
  src.occurrence : Period as v then {
    v.start -> tgt.date;
  } "periodDateTime";
  src.occurrence : Timing as v then {
    v.event -> tgt.date;
  } "timingDateTime";
  src.detected -> tgt.detected;
  src.recordedDate -> tgt.recordedDate;
  src.resultingEffect -> tgt.resultingCondition;
  src.location -> tgt.location;
  src.seriousness -> tgt.seriousness;
  src.outcome -> tgt.outcome;
  src.recorder -> tgt.recorder;
  src.participant as s then AdverseEventParticipant(s, tgt);
  src.study -> tgt.study;
  src.suspectEntity as s -> tgt.suspectEntity as t then AdverseEventSuspectEntity(s, t);
  src.contributingFactor as s then AdverseEventContributingFactor(s, tgt);
}

group AdverseEventParticipant(source src, target tgt) extends BackboneElement {
  src.actor -> tgt.contributor;
}

group AdverseEventSuspectEntity(source src, target tgt) extends BackboneElement {
  src.instance : Reference -> tgt.instance;
  src.causality as s -> tgt.causality as t then AdverseEventSuspectEntityCausality(s, t);
}

group AdverseEventSuspectEntityCausality(source src, target tgt) extends BackboneElement {
  src.assessmentMethod -> tgt.assessment;
  src.entityRelatedness -> tgt.productRelatedness;
  src.author -> tgt.author;
}

group AdverseEventContributingFactor(source src, target tgt) extends BackboneElement {
  src.item : Reference -> tgt.subjectMedicalHistory;
}

# entry[].resource.text.div
Generated Narrative: StructureMap Age3to4

/// url = 'http://hl7.org/fhir/uv/xver/StructureMap/Age3to4'
/// name = 'Age3to4'
/// title = 'Age Transforms: R3 to R4'
/// status = 'active'

uses "http://hl7.org/fhir/3.0/StructureDefinition/Age" alias AgeR3 as source
uses "http://hl7.org/fhir/4.0/StructureDefinition/Age" alias Age as target

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

group Age(source src : AgeR3, target tgt : Age) extends Quantity <<type+>> {
}

# entry[].resource.text.div
Generated Narrative: StructureMap Age4to3

/// url = 'http://hl7.org/fhir/uv/xver/StructureMap/Age4to3'
/// name = 'Age4to3'
/// title = 'Age Transforms: R4 to R3'
/// status = 'active'

uses "http://hl7.org/fhir/4.0/StructureDefinition/Age" alias Age as source
uses "http://hl7.org/fhir/3.0/StructureDefinition/Age" alias AgeR3 as target

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

group Age(source src : Age, target tgt : AgeR3) extends Quantity <<type+>> {
}

# entry[].resource.text.div
Generated Narrative: StructureMap Age5to4b

/// url = 'http://hl7.org/fhir/uv/xver/StructureMap/Age5to4b'
/// name = 'Age5to4b'
/// title = 'Age Transforms: R5 to R4B'
/// status = 'active'

uses "http://hl7.org/fhir/5.0/StructureDefinition/Age" alias AgeR5 as source
uses "http://hl7.org/fhir/4.3/StructureDefinition/Age" alias AgeR4B as target

imports "http://hl7.org/fhir/uv/xver/StructureMap/*5to4b"

group Age(source src : AgeR5, target tgt : AgeR4B) extends Quantity <<type+>> {
}