FHIR Extensions Pack v5.1.0-cibuild (2024-04-21)

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

Financial Management Work GroupMaturity Level: N/AStandards Status: InformativeSecurity Category: N/A Compartments: N/A

Following are maps for converting between the equivalent R4B resource and this R5 resource.

Maps to ExplanationOfBenefit

FML Conversion for ExplanationOfBenefit: R5 to R4 (Ready for Use/Trial Use)

/// url = 'http://hl7.org/fhir/StructureMap/ExplanationOfBenefit5to4'
/// name = 'ExplanationOfBenefit5to4'
/// title = 'FML Conversion for ExplanationOfBenefit: R5 to R4'
/// status = 'active'

conceptmap "ClaimOutcome" {
  prefix s = "http://hl7.org/fhir/claim-outcome"
  prefix t = "http://hl7.org/fhir/4.0/remittance-outcome"

  s:queued - t:queued
  s:complete - t:complete
  s:error - t:error
  s:partial - t:partial
}

conceptmap "ExplanationOfBenefitStatus" {
  prefix s = "http://hl7.org/fhir/explanationofbenefit-status"
  prefix t = "http://hl7.org/fhir/4.0/explanationofbenefit-status"

  s:active - t:active
  s:cancelled - t:cancelled
  s:draft - t:draft
  s:"entered-in-error" - t:"entered-in-error"
}

conceptmap "Use" {
  prefix s = "http://hl7.org/fhir/claim-use"
  prefix t = "http://hl7.org/fhir/4.0/claim-use"

  s:claim - t:claim
  s:preauthorization - t:preauthorization
  s:predetermination - t:predetermination
}

uses "http://hl7.org/fhir/StructureDefinition/ExplanationOfBenefit" alias ExplanationOfBenefitR5 as source
uses "http://hl7.org/fhir/4.0/StructureDefinition/ExplanationOfBenefit" alias ExplanationOfBenefitR4 as target

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

group ExplanationOfBenefit(source src : ExplanationOfBenefitR5, target tgt : ExplanationOfBenefitR4) extends DomainResource <<type+>> {
  src.identifier -> tgt.identifier;
  src.status as v -> tgt.status = translate(v, '#ExplanationOfBenefitStatus', 'code'); // src.traceNumber -> tgt.traceNumber;
  src.type -> tgt.type;
  src.subType -> tgt.subType;
  src.use as v -> tgt.use = translate(v, '#Use', 'code');
  src.patient -> tgt.patient;
  src.billablePeriod -> tgt.billablePeriod;
  src.created -> tgt.created;
  src.enterer -> tgt.enterer;
  src.insurer -> tgt.insurer;
  src.provider -> tgt.provider;
  src.priority -> tgt.priority;
  src.fundsReserveRequested -> tgt.fundsReserveRequested;
  src.fundsReserve -> tgt.fundsReserve;
  src.related as s -> tgt.related as t then ExplanationOfBenefitRelated(s, t);
  src.prescription -> tgt.prescription;
  src.originalPrescription -> tgt.originalPrescription;
  src.payee as s -> tgt.payee as t then ExplanationOfBenefitPayee(s, t); // src.event as s -> tgt.event as t then ExplanationOfBenefitEvent(s,t);
  src.referral -> tgt.referral;
  src.facility -> tgt.facility; // src.encounter -> tgt.encounter;
  src.claim -> tgt.claim;
  src.claimResponse -> tgt.claimResponse;
  src.outcome as v -> tgt.outcome = translate(v, '#ClaimOutcome', 'code');
  src.disposition -> tgt.disposition; // src.decision -> tgt.decision;
  src.preAuthRef -> tgt.preAuthRef;
  src.preAuthRefPeriod -> tgt.preAuthRefPeriod;
  src.careTeam as s -> tgt.careTeam as t then ExplanationOfBenefitCareTeam(s, t); // src.diagnosisRelatedGroup -> tgt.diagnosisRelatedGroup;
  src.supportingInfo as s -> tgt.supportingInfo as t then ExplanationOfBenefitSupportingInfo(s, t);
  src.diagnosis as s -> tgt.diagnosis as t then ExplanationOfBenefitDiagnosis(s, t);
  src.procedure as s -> tgt.procedure as t then ExplanationOfBenefitProcedure(s, t);
  src.precedence -> tgt.precedence;
  src.insurance as s -> tgt.insurance as t then ExplanationOfBenefitInsurance(s, t);
  src.accident as s -> tgt.accident as t then ExplanationOfBenefitAccident(s, t);
  src.item as s -> tgt.item as t then ExplanationOfBenefitItem(s, t); // src.patientPaid -> tgt.patientPaid;
  src.addItem as s -> tgt.addItem as t then ExplanationOfBenefitAddItem(s, t);
  src.total as s -> tgt.total as t then ExplanationOfBenefitTotal(s, t);
  src.payment as s -> tgt.payment as t then ExplanationOfBenefitPayment(s, t);
  src.formCode -> tgt.formCode;
  src.form -> tgt.form;
  src.processNote as s -> tgt.processNote as t then ExplanationOfBenefitProcessNote(s, t);
  src.benefitPeriod -> tgt.benefitPeriod;
  src.benefitBalance as s -> tgt.benefitBalance as t then ExplanationOfBenefitBenefitBalance(s, t);
}

group ExplanationOfBenefitRelated(source src, target tgt) extends BackboneElement {
  src.claim -> tgt.claim;
  src.relationship -> tgt.relationship;
  src.reference -> tgt.reference;
}

// group ExplanationOfBenefitEvent(source src, target tgt) extends BackboneElement {
// src.type -> tgt.type;
// src.when : dateTime -> tgt.when;
// src.when : Period -> tgt.when;
// }
group ExplanationOfBenefitPayee(source src, target tgt) extends BackboneElement {
  src.type -> tgt.type;
  src.party -> tgt.party;
}

group ExplanationOfBenefitCareTeam(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.provider -> tgt.provider;
  src.responsible -> tgt.responsible;
  src.role -> tgt.role;
  src.specialty -> tgt.qualification;
}

group ExplanationOfBenefitSupportingInfo(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.category -> tgt.category;
  src.code -> tgt.code;
  src.timing : date -> tgt.timing;
  src.timing : Period -> tgt.timing;
  src.value : boolean -> tgt.value;
  src.value : string -> tgt.value;
  src.value : Quantity -> tgt.value;
  src.value : Attachment -> tgt.value;
  src.value : Reference -> tgt.value;
  src.reason -> tgt.reason; // src.value : Identifier -> tgt.value;
}

group ExplanationOfBenefitDiagnosis(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.diagnosis : CodeableConcept -> tgt.diagnosis;
  src.diagnosis : Reference -> tgt.diagnosis;
  src.type -> tgt.type;
  src.onAdmission -> tgt.onAdmission;
}

group ExplanationOfBenefitProcedure(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.type -> tgt.type;
  src.date -> tgt.date;
  src.procedure : CodeableConcept -> tgt.procedure;
  src.procedure : Reference -> tgt.procedure;
  src.udi -> tgt.udi;
}

group ExplanationOfBenefitInsurance(source src, target tgt) extends BackboneElement {
  src.focal -> tgt.focal;
  src.coverage -> tgt.coverage;
  src.preAuthRef -> tgt.preAuthRef;
}

group ExplanationOfBenefitAccident(source src, target tgt) extends BackboneElement {
  src.date -> tgt.date;
  src.type -> tgt.type;
  src.location : Address -> tgt.location;
  src.location : Reference -> tgt.location;
}

group ExplanationOfBenefitItem(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.careTeamSequence -> tgt.careTeamSequence;
  src.diagnosisSequence -> tgt.diagnosisSequence;
  src.procedureSequence -> tgt.procedureSequence;
  src.informationSequence -> tgt.informationSequence;
  src.revenue -> tgt.revenue; // src.traceNumber -> tgt.traceNumber;
  src.category -> tgt.category;
  src.productOrService -> tgt.productOrService;
  src.modifier -> tgt.modifier; // src.productOrServiceEnd -> tgt.productOrServiceEnd;
  src.programCode -> tgt.programCode;
  src.serviced : date -> tgt.serviced;
  src.serviced : Period -> tgt.serviced;
  src.location : CodeableConcept -> tgt.location;
  src.location : Address -> tgt.location;
  src.location : Reference -> tgt.location;
  src.quantity -> tgt.quantity; // src.patientPaid -> tgt.patientPaid;
  src.unitPrice -> tgt.unitPrice;
  src.factor -> tgt.factor;
  src.net -> tgt.net; // src.tax -> tgt.tax;
  src.udi -> tgt.udi;
  src.bodySite as s ->  tgt.bodySite as t,  t = s.site;
  src.bodySite as s ->  tgt.subSite as t,  t = s.subSite;
  src.encounter -> tgt.encounter;
  src.noteNumber -> tgt.noteNumber;
  src.adjudication as s -> tgt.adjudication as t then ExplanationOfBenefitItemAdjudication(s, t); // src.reviewOutcome as s -> tgt.reviewOutcome as t then ExplanationOfBenefitItemReviewOutcome(s,t);
  src.detail as s -> tgt.detail as t then ExplanationOfBenefitItemDetail(s, t);
}

// group ExplanationOfBenefitItemBodySite(source src, target tgt) extends BackboneElement {
// src.site -> tgt.site;
// src.subSite -> tgt.subSite;
// }
// group ExplanationOfBenefitItemReviewOutcome(source src, target tgt) extends BackboneElement {
// src.decision -> tgt.decision;
// src.reason -> tgt.reason;
// src.preAuthRef -> tgt.preAuthRef;
// src.preAuthPeriod -> tgt.preAuthPeriod;
// }
group ExplanationOfBenefitItemAdjudication(source src, target tgt) extends BackboneElement {
  src.category -> tgt.category;
  src.reason -> tgt.reason;
  src.amount -> tgt.amount;
  src.quantity as s -> tgt then {
    s.value -> tgt.value;
  };
}

group ExplanationOfBenefitItemDetail(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.revenue -> tgt.revenue; // src.traceNumber -> tgt.traceNumber;
  src.category -> tgt.category;
  src.productOrService -> tgt.productOrService;
  src.modifier -> tgt.modifier; // src.productOrServiceEnd -> tgt.productOrServiceEnd;
  src.programCode -> tgt.programCode;
  src.quantity -> tgt.quantity; // src.patientPaid -> tgt.patientPaid;
  src.unitPrice -> tgt.unitPrice;
  src.factor -> tgt.factor;
  src.net -> tgt.net; // src.tax -> tgt.tax;
  src.udi -> tgt.udi;
  src.noteNumber -> tgt.noteNumber;
  src.subDetail as s -> tgt.subDetail as t then ExplanationOfBenefitItemDetailSubDetail(s, t);
}

group ExplanationOfBenefitItemDetailSubDetail(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.revenue -> tgt.revenue; // src.traceNumber -> tgt.traceNumber;
  src.category -> tgt.category;
  src.productOrService -> tgt.productOrService;
  src.modifier -> tgt.modifier; // src.productOrServiceEnd -> tgt.productOrServiceEnd;
  src.programCode -> tgt.programCode;
  src.quantity -> tgt.quantity; // src.patientPaid -> tgt.patientPaid;
  src.unitPrice -> tgt.unitPrice;
  src.factor -> tgt.factor;
  src.net -> tgt.net; // src.tax -> tgt.tax;
  src.udi -> tgt.udi;
  src.noteNumber -> tgt.noteNumber;
}

group ExplanationOfBenefitAddItem(source src, target tgt) extends BackboneElement {
  src.itemSequence -> tgt.itemSequence;
  src.detailSequence -> tgt.detailSequence;
  src.subDetailSequence -> tgt.subDetailSequence;
  src.provider -> tgt.provider; // src.traceNumber -> tgt.traceNumber;
  src.productOrService -> tgt.productOrService; // src.revenue -> tgt.revenue;
  src.modifier -> tgt.modifier; // src.productOrServiceEnd -> tgt.productOrServiceEnd;
  src.programCode -> tgt.programCode;
  src.serviced : date -> tgt.serviced;
  src.serviced : Period -> tgt.serviced;
  src.location : CodeableConcept -> tgt.location;
  src.location : Address -> tgt.location;
  src.location : Reference -> tgt.location;
  src.quantity -> tgt.quantity; // src.patientPaid -> tgt.patientPaid;
  src.unitPrice -> tgt.unitPrice;
  src.factor -> tgt.factor;
  src.net -> tgt.net; // src.tax -> tgt.tax;
  src.bodySite as s ->  tgt.bodySite as t,  t = s.site;
  src.bodySite as s ->  tgt.subSite as t,  t = s.subSite;
  src.noteNumber -> tgt.noteNumber;
  src.detail as s -> tgt.detail as t then ExplanationOfBenefitAddItemDetail(s, t);
}

// group ExplanationOfBenefitAddItemBodySite(source src, target tgt) extends BackboneElement {
// src.site -> tgt.site;
// src.subSite -> tgt.subSite;
// }
group ExplanationOfBenefitAddItemDetail(source src, target tgt) extends BackboneElement {
  src.productOrService -> tgt.productOrService; // src.traceNumber -> tgt.traceNumber;
  src.modifier -> tgt.modifier; // src.productOrServiceEnd -> tgt.productOrServiceEnd;
  src.quantity -> tgt.quantity; // src.patientPaid -> tgt.patientPaid;
  src.unitPrice -> tgt.unitPrice;
  src.factor -> tgt.factor;
  src.net -> tgt.net; // src.tax -> tgt.tax;
  src.noteNumber -> tgt.noteNumber;
  src.subDetail as s -> tgt.subDetail as t then ExplanationOfBenefitAddItemDetailSubDetail(s, t);
}

group ExplanationOfBenefitAddItemDetailSubDetail(source src, target tgt) extends BackboneElement {
  src.productOrService -> tgt.productOrService; // src.traceNumber -> tgt.traceNumber;
  src.modifier -> tgt.modifier; // src.productOrServiceEnd -> tgt.productOrServiceEnd;
  src.quantity -> tgt.quantity; // src.patientPaid -> tgt.patientPaid;
  src.unitPrice -> tgt.unitPrice;
  src.factor -> tgt.factor;
  src.net -> tgt.net; // src.tax -> tgt.tax;
  src.noteNumber -> tgt.noteNumber;
}

group ExplanationOfBenefitTotal(source src, target tgt) extends BackboneElement {
  src.category -> tgt.category;
  src.amount -> tgt.amount;
}

group ExplanationOfBenefitPayment(source src, target tgt) extends BackboneElement {
  src.type -> tgt.type;
  src.adjustment -> tgt.adjustment;
  src.adjustmentReason -> tgt.adjustmentReason;
  src.date -> tgt.date;
  src.amount -> tgt.amount;
  src.identifier -> tgt.identifier;
}

group ExplanationOfBenefitProcessNote(source src, target tgt) extends BackboneElement {
  src.number -> tgt.number;
  src.type as s -> tgt then {
    s.coding as s -> tgt then {
      s.code -> tgt.type;
    };
  };
  src.text -> tgt.text;
  src.language -> tgt.language;
}

group ExplanationOfBenefitBenefitBalance(source src, target tgt) extends BackboneElement {
  src.category -> tgt.category;
  src.excluded -> tgt.excluded;
  src.name -> tgt.name;
  src.description -> tgt.description;
  src.network -> tgt.network;
  src.unit -> tgt.unit;
  src.term -> tgt.term;
  src.financial as s -> tgt.financial as t then ExplanationOfBenefitBenefitBalanceFinancial(s, t);
}

group ExplanationOfBenefitBenefitBalanceFinancial(source src, target tgt) extends BackboneElement {
  src.type -> tgt.type;
  src.allowed : unsignedInt -> tgt.allowed;
  src.allowed : string -> tgt.allowed;
  src.allowed : Money -> tgt.allowed;
  src.used : unsignedInt -> tgt.used;
  src.used : Money -> tgt.used;
}

FML Conversion for ExplanationOfBenefit: R5 to R4B (Ready for Use/Trial Use)

/// url = 'http://hl7.org/fhir/StructureMap/ExplanationOfBenefit5to4B'
/// name = 'ExplanationOfBenefit5to4B'
/// title = 'FML Conversion for ExplanationOfBenefit: R5 to R4B'
/// status = 'active'

conceptmap "ClaimOutcome" {
  prefix s = "http://hl7.org/fhir/claim-outcome"
  prefix t = "http://hl7.org/fhir/4.3/remittance-outcome"

  s:queued - t:queued
  s:complete - t:complete
  s:error - t:error
  s:partial - t:partial
}

conceptmap "ExplanationOfBenefitStatus" {
  prefix s = "http://hl7.org/fhir/explanationofbenefit-status"
  prefix t = "http://hl7.org/fhir/4.3/explanationofbenefit-status"

  s:active - t:active
  s:cancelled - t:cancelled
  s:draft - t:draft
  s:"entered-in-error" - t:"entered-in-error"
}

conceptmap "Use" {
  prefix s = "http://hl7.org/fhir/claim-use"
  prefix t = "http://hl7.org/fhir/4.3/claim-use"

  s:claim - t:claim
  s:preauthorization - t:preauthorization
  s:predetermination - t:predetermination
}

uses "http://hl7.org/fhir/StructureDefinition/ExplanationOfBenefit" alias ExplanationOfBenefitR5 as source
uses "http://hl7.org/fhir/4.3/StructureDefinition/ExplanationOfBenefit" alias ExplanationOfBenefitR4B as target

imports "http://hl7.org/fhir/StructureMap/*5to4B"

group ExplanationOfBenefit(source src : ExplanationOfBenefitR5, target tgt : ExplanationOfBenefitR4B) extends DomainResource <<type+>> {
  src.identifier -> tgt.identifier;
  src.status as v -> tgt.status = translate(v, '#ExplanationOfBenefitStatus', 'code'); // src.traceNumber -> tgt.traceNumber;
  src.type -> tgt.type;
  src.subType -> tgt.subType;
  src.use as v -> tgt.use = translate(v, '#Use', 'code');
  src.patient -> tgt.patient;
  src.billablePeriod -> tgt.billablePeriod;
  src.created -> tgt.created;
  src.enterer -> tgt.enterer;
  src.insurer -> tgt.insurer;
  src.provider -> tgt.provider;
  src.priority -> tgt.priority;
  src.fundsReserveRequested -> tgt.fundsReserveRequested;
  src.fundsReserve -> tgt.fundsReserve;
  src.related as s -> tgt.related as t then ExplanationOfBenefitRelated(s, t);
  src.prescription -> tgt.prescription;
  src.originalPrescription -> tgt.originalPrescription;
  src.payee as s -> tgt.payee as t then ExplanationOfBenefitPayee(s, t); // src.event as s -> tgt.event as t then ExplanationOfBenefitEvent(s,t);
  src.referral -> tgt.referral;
  src.facility -> tgt.facility; // src.encounter -> tgt.encounter;
  src.claim -> tgt.claim;
  src.claimResponse -> tgt.claimResponse;
  src.outcome as v -> tgt.outcome = translate(v, '#ClaimOutcome', 'code');
  src.disposition -> tgt.disposition; // src.decision -> tgt.decision;
  src.preAuthRef -> tgt.preAuthRef;
  src.preAuthRefPeriod -> tgt.preAuthRefPeriod;
  src.careTeam as s -> tgt.careTeam as t then ExplanationOfBenefitCareTeam(s, t); // src.diagnosisRelatedGroup -> tgt.diagnosisRelatedGroup;
  src.supportingInfo as s -> tgt.supportingInfo as t then ExplanationOfBenefitSupportingInfo(s, t);
  src.diagnosis as s -> tgt.diagnosis as t then ExplanationOfBenefitDiagnosis(s, t);
  src.procedure as s -> tgt.procedure as t then ExplanationOfBenefitProcedure(s, t);
  src.precedence -> tgt.precedence;
  src.insurance as s -> tgt.insurance as t then ExplanationOfBenefitInsurance(s, t);
  src.accident as s -> tgt.accident as t then ExplanationOfBenefitAccident(s, t);
  src.item as s -> tgt.item as t then ExplanationOfBenefitItem(s, t); // src.patientPaid -> tgt.patientPaid;
  src.addItem as s -> tgt.addItem as t then ExplanationOfBenefitAddItem(s, t);
  src.total as s -> tgt.total as t then ExplanationOfBenefitTotal(s, t);
  src.payment as s -> tgt.payment as t then ExplanationOfBenefitPayment(s, t);
  src.formCode -> tgt.formCode;
  src.form -> tgt.form;
  src.processNote as s -> tgt.processNote as t then ExplanationOfBenefitProcessNote(s, t);
  src.benefitPeriod -> tgt.benefitPeriod;
  src.benefitBalance as s -> tgt.benefitBalance as t then ExplanationOfBenefitBenefitBalance(s, t);
}

group ExplanationOfBenefitRelated(source src, target tgt) extends BackboneElement {
  src.claim -> tgt.claim;
  src.relationship -> tgt.relationship;
  src.reference -> tgt.reference;
}

// group ExplanationOfBenefitEvent(source src, target tgt) extends BackboneElement {
// src.type -> tgt.type;
// src.when : dateTime -> tgt.when;
// src.when : Period -> tgt.when;
// }
group ExplanationOfBenefitPayee(source src, target tgt) extends BackboneElement {
  src.type -> tgt.type;
  src.party -> tgt.party;
}

group ExplanationOfBenefitCareTeam(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.provider -> tgt.provider;
  src.responsible -> tgt.responsible;
  src.role -> tgt.role;
  src.specialty -> tgt.qualification;
}

group ExplanationOfBenefitSupportingInfo(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.category -> tgt.category;
  src.code -> tgt.code;
  src.timing : date -> tgt.timing;
  src.timing : Period -> tgt.timing;
  src.value : boolean -> tgt.value;
  src.value : string -> tgt.value;
  src.value : Quantity -> tgt.value;
  src.value : Attachment -> tgt.value;
  src.value : Reference -> tgt.value;
  src.reason -> tgt.reason; // src.value : Identifier -> tgt.value;
}

group ExplanationOfBenefitDiagnosis(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.diagnosis : CodeableConcept -> tgt.diagnosis;
  src.diagnosis : Reference -> tgt.diagnosis;
  src.type -> tgt.type;
  src.onAdmission -> tgt.onAdmission;
}

group ExplanationOfBenefitProcedure(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.type -> tgt.type;
  src.date -> tgt.date;
  src.procedure : CodeableConcept -> tgt.procedure;
  src.procedure : Reference -> tgt.procedure;
  src.udi -> tgt.udi;
}

group ExplanationOfBenefitInsurance(source src, target tgt) extends BackboneElement {
  src.focal -> tgt.focal;
  src.coverage -> tgt.coverage;
  src.preAuthRef -> tgt.preAuthRef;
}

group ExplanationOfBenefitAccident(source src, target tgt) extends BackboneElement {
  src.date -> tgt.date;
  src.type -> tgt.type;
  src.location : Address -> tgt.location;
  src.location : Reference -> tgt.location;
}

group ExplanationOfBenefitItem(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.careTeamSequence -> tgt.careTeamSequence;
  src.diagnosisSequence -> tgt.diagnosisSequence;
  src.procedureSequence -> tgt.procedureSequence;
  src.informationSequence -> tgt.informationSequence;
  src.revenue -> tgt.revenue; // src.traceNumber -> tgt.traceNumber;
  src.category -> tgt.category;
  src.productOrService -> tgt.productOrService;
  src.modifier -> tgt.modifier; // src.productOrServiceEnd -> tgt.productOrServiceEnd;
  src.programCode -> tgt.programCode;
  src.serviced : date -> tgt.serviced;
  src.serviced : Period -> tgt.serviced;
  src.location : CodeableConcept -> tgt.location;
  src.location : Address -> tgt.location;
  src.location : Reference -> tgt.location;
  src.quantity -> tgt.quantity; // src.patientPaid -> tgt.patientPaid;
  src.unitPrice -> tgt.unitPrice;
  src.factor -> tgt.factor;
  src.net -> tgt.net; // src.tax -> tgt.tax;
  src.udi -> tgt.udi;
  src.bodySite as s ->  tgt.bodySite as t,  t = s.site;
  src.bodySite as s ->  tgt.subSite as t,  t = s.subSite;
  src.encounter -> tgt.encounter;
  src.noteNumber -> tgt.noteNumber;
  src.adjudication as s -> tgt.adjudication as t then ExplanationOfBenefitItemAdjudication(s, t); // src.reviewOutcome as s -> tgt.reviewOutcome as t then ExplanationOfBenefitItemReviewOutcome(s,t);
  src.detail as s -> tgt.detail as t then ExplanationOfBenefitItemDetail(s, t);
}

// group ExplanationOfBenefitItemBodySite(source src, target tgt) extends BackboneElement {
// src.site -> tgt.site;
// src.subSite -> tgt.subSite;
// }
// group ExplanationOfBenefitItemReviewOutcome(source src, target tgt) extends BackboneElement {
// src.decision -> tgt.decision;
// src.reason -> tgt.reason;
// src.preAuthRef -> tgt.preAuthRef;
// src.preAuthPeriod -> tgt.preAuthPeriod;
// }
group ExplanationOfBenefitItemAdjudication(source src, target tgt) extends BackboneElement {
  src.category -> tgt.category;
  src.reason -> tgt.reason;
  src.amount -> tgt.amount;
  src.quantity as s -> tgt then {
    s.value -> tgt.value;
  };
}

group ExplanationOfBenefitItemDetail(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.revenue -> tgt.revenue; // src.traceNumber -> tgt.traceNumber;
  src.category -> tgt.category;
  src.productOrService -> tgt.productOrService;
  src.modifier -> tgt.modifier; // src.productOrServiceEnd -> tgt.productOrServiceEnd;
  src.programCode -> tgt.programCode;
  src.quantity -> tgt.quantity; // src.patientPaid -> tgt.patientPaid;
  src.unitPrice -> tgt.unitPrice;
  src.factor -> tgt.factor;
  src.net -> tgt.net; // src.tax -> tgt.tax;
  src.udi -> tgt.udi;
  src.noteNumber -> tgt.noteNumber;
  src.subDetail as s -> tgt.subDetail as t then ExplanationOfBenefitItemDetailSubDetail(s, t);
}

group ExplanationOfBenefitItemDetailSubDetail(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.revenue -> tgt.revenue; // src.traceNumber -> tgt.traceNumber;
  src.category -> tgt.category;
  src.productOrService -> tgt.productOrService;
  src.modifier -> tgt.modifier; // src.productOrServiceEnd -> tgt.productOrServiceEnd;
  src.programCode -> tgt.programCode;
  src.quantity -> tgt.quantity; // src.patientPaid -> tgt.patientPaid;
  src.unitPrice -> tgt.unitPrice;
  src.factor -> tgt.factor;
  src.net -> tgt.net; // src.tax -> tgt.tax;
  src.udi -> tgt.udi;
  src.noteNumber -> tgt.noteNumber;
}

group ExplanationOfBenefitAddItem(source src, target tgt) extends BackboneElement {
  src.itemSequence -> tgt.itemSequence;
  src.detailSequence -> tgt.detailSequence;
  src.subDetailSequence -> tgt.subDetailSequence;
  src.provider -> tgt.provider; // src.traceNumber -> tgt.traceNumber;
  src.productOrService -> tgt.productOrService; // src.revenue -> tgt.revenue;
  src.modifier -> tgt.modifier; // src.productOrServiceEnd -> tgt.productOrServiceEnd;
  src.programCode -> tgt.programCode;
  src.serviced : date -> tgt.serviced;
  src.serviced : Period -> tgt.serviced;
  src.location : CodeableConcept -> tgt.location;
  src.location : Address -> tgt.location;
  src.location : Reference -> tgt.location;
  src.quantity -> tgt.quantity; // src.patientPaid -> tgt.patientPaid;
  src.unitPrice -> tgt.unitPrice;
  src.factor -> tgt.factor;
  src.net -> tgt.net; // src.tax -> tgt.tax;
  src.bodySite as s ->  tgt.bodySite as t,  t = s.site;
  src.bodySite as s ->  tgt.subSite as t,  t = s.subSite;
  src.noteNumber -> tgt.noteNumber;
  src.detail as s -> tgt.detail as t then ExplanationOfBenefitAddItemDetail(s, t);
}

// group ExplanationOfBenefitAddItemBodySite(source src, target tgt) extends BackboneElement {
// src.site -> tgt.site;
// src.subSite -> tgt.subSite;
// }
group ExplanationOfBenefitAddItemDetail(source src, target tgt) extends BackboneElement {
  src.productOrService -> tgt.productOrService; // src.traceNumber -> tgt.traceNumber;
  src.modifier -> tgt.modifier; // src.productOrServiceEnd -> tgt.productOrServiceEnd;
  src.quantity -> tgt.quantity; // src.patientPaid -> tgt.patientPaid;
  src.unitPrice -> tgt.unitPrice;
  src.factor -> tgt.factor;
  src.net -> tgt.net; // src.tax -> tgt.tax;
  src.noteNumber -> tgt.noteNumber;
  src.subDetail as s -> tgt.subDetail as t then ExplanationOfBenefitAddItemDetailSubDetail(s, t);
}

group ExplanationOfBenefitAddItemDetailSubDetail(source src, target tgt) extends BackboneElement {
  src.productOrService -> tgt.productOrService; // src.traceNumber -> tgt.traceNumber;
  src.modifier -> tgt.modifier; // src.productOrServiceEnd -> tgt.productOrServiceEnd;
  src.quantity -> tgt.quantity; // src.patientPaid -> tgt.patientPaid;
  src.unitPrice -> tgt.unitPrice;
  src.factor -> tgt.factor;
  src.net -> tgt.net; // src.tax -> tgt.tax;
  src.noteNumber -> tgt.noteNumber;
}

group ExplanationOfBenefitTotal(source src, target tgt) extends BackboneElement {
  src.category -> tgt.category;
  src.amount -> tgt.amount;
}

group ExplanationOfBenefitPayment(source src, target tgt) extends BackboneElement {
  src.type -> tgt.type;
  src.adjustment -> tgt.adjustment;
  src.adjustmentReason -> tgt.adjustmentReason;
  src.date -> tgt.date;
  src.amount -> tgt.amount;
  src.identifier -> tgt.identifier;
}

group ExplanationOfBenefitProcessNote(source src, target tgt) extends BackboneElement {
  src.number -> tgt.number;
  src.type as s -> tgt then {
    s.coding as s -> tgt then {
      s.code -> tgt.type;
    };
  };
  src.text -> tgt.text;
  src.language -> tgt.language;
}

group ExplanationOfBenefitBenefitBalance(source src, target tgt) extends BackboneElement {
  src.category -> tgt.category;
  src.excluded -> tgt.excluded;
  src.name -> tgt.name;
  src.description -> tgt.description;
  src.network -> tgt.network;
  src.unit -> tgt.unit;
  src.term -> tgt.term;
  src.financial as s -> tgt.financial as t then ExplanationOfBenefitBenefitBalanceFinancial(s, t);
}

group ExplanationOfBenefitBenefitBalanceFinancial(source src, target tgt) extends BackboneElement {
  src.type -> tgt.type;
  src.allowed : unsignedInt -> tgt.allowed;
  src.allowed : string -> tgt.allowed;
  src.allowed : Money -> tgt.allowed;
  src.used : unsignedInt -> tgt.used;
  src.used : Money -> tgt.used;
}

Maps from ExplanationOfBenefit

FML Conversion for ExplanationOfBenefit: R4B to R5 (Ready for Use/Trial Use)

/// url = 'http://hl7.org/fhir/StructureMap/ExplanationOfBenefit4Bto5'
/// name = 'ExplanationOfBenefit4Bto5'
/// title = 'FML Conversion for ExplanationOfBenefit: R4B to R5'
/// status = 'active'

conceptmap "ClaimOutcome" {
  prefix s = "http://hl7.org/fhir/4.3/remittance-outcome"
  prefix t = "http://hl7.org/fhir/claim-outcome"

  s:queued - t:queued
  s:complete - t:complete
  s:error - t:error
  s:partial - t:partial
}

conceptmap "ExplanationOfBenefitStatus" {
  prefix s = "http://hl7.org/fhir/4.3/explanationofbenefit-status"
  prefix t = "http://hl7.org/fhir/explanationofbenefit-status"

  s:active - t:active
  s:cancelled - t:cancelled
  s:draft - t:draft
  s:"entered-in-error" - t:"entered-in-error"
}

conceptmap "Use" {
  prefix s = "http://hl7.org/fhir/4.3/claim-use"
  prefix t = "http://hl7.org/fhir/claim-use"

  s:claim - t:claim
  s:preauthorization - t:preauthorization
  s:predetermination - t:predetermination
}

uses "http://hl7.org/fhir/4.3/StructureDefinition/ExplanationOfBenefit" alias ExplanationOfBenefitR4B as source
uses "http://hl7.org/fhir/StructureDefinition/ExplanationOfBenefit" alias ExplanationOfBenefitR5 as target

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

group ExplanationOfBenefit(source src : ExplanationOfBenefitR4B, target tgt : ExplanationOfBenefitR5) extends DomainResource <<type+>> {
  src.identifier -> tgt.identifier;
  src.status as v -> tgt.status = translate(v, '#ExplanationOfBenefitStatus', 'code'); // src.traceNumber -> tgt.traceNumber;
  src.type -> tgt.type;
  src.subType -> tgt.subType;
  src.use as v -> tgt.use = translate(v, '#Use', 'code');
  src.patient -> tgt.patient;
  src.billablePeriod -> tgt.billablePeriod;
  src.created -> tgt.created;
  src.enterer -> tgt.enterer;
  src.insurer -> tgt.insurer;
  src.provider -> tgt.provider;
  src.priority -> tgt.priority;
  src.fundsReserveRequested -> tgt.fundsReserveRequested;
  src.fundsReserve -> tgt.fundsReserve;
  src.related as s -> tgt.related as t then ExplanationOfBenefitRelated(s, t);
  src.prescription -> tgt.prescription;
  src.originalPrescription -> tgt.originalPrescription;
  src.payee as s -> tgt.payee as t then ExplanationOfBenefitPayee(s, t); // src.event as s -> tgt.event as t then ExplanationOfBenefitEvent(s,t);
  src.referral -> tgt.referral;
  src.facility -> tgt.facility; // src.encounter -> tgt.encounter;
  src.claim -> tgt.claim;
  src.claimResponse -> tgt.claimResponse;
  src.outcome as v -> tgt.outcome = translate(v, '#ClaimOutcome', 'code');
  src.disposition -> tgt.disposition; // src.decision -> tgt.decision;
  src.preAuthRef -> tgt.preAuthRef;
  src.preAuthRefPeriod -> tgt.preAuthRefPeriod;
  src.careTeam as s -> tgt.careTeam as t then ExplanationOfBenefitCareTeam(s, t); // src.diagnosisRelatedGroup -> tgt.diagnosisRelatedGroup;
  src.supportingInfo as s -> tgt.supportingInfo as t then ExplanationOfBenefitSupportingInfo(s, t);
  src.diagnosis as s -> tgt.diagnosis as t then ExplanationOfBenefitDiagnosis(s, t);
  src.procedure as s -> tgt.procedure as t then ExplanationOfBenefitProcedure(s, t);
  src.precedence -> tgt.precedence;
  src.insurance as s -> tgt.insurance as t then ExplanationOfBenefitInsurance(s, t);
  src.accident as s -> tgt.accident as t then ExplanationOfBenefitAccident(s, t);
  src.item as s -> tgt.item as t then ExplanationOfBenefitItem(s, t); // src.patientPaid -> tgt.patientPaid;
  src.addItem as s -> tgt.addItem as t then ExplanationOfBenefitAddItem(s, t);
  src.total as s -> tgt.total as t then ExplanationOfBenefitTotal(s, t);
  src.payment as s -> tgt.payment as t then ExplanationOfBenefitPayment(s, t);
  src.formCode -> tgt.formCode;
  src.form -> tgt.form;
  src.processNote as s -> tgt.processNote as t then ExplanationOfBenefitProcessNote(s, t);
  src.benefitPeriod -> tgt.benefitPeriod;
  src.benefitBalance as s -> tgt.benefitBalance as t then ExplanationOfBenefitBenefitBalance(s, t);
}

group ExplanationOfBenefitRelated(source src, target tgt) extends BackboneElement {
  src.claim -> tgt.claim;
  src.relationship -> tgt.relationship;
  src.reference -> tgt.reference;
}

// group ExplanationOfBenefitEvent(source src, target tgt) extends BackboneElement {
// src.type -> tgt.type;
// src.when : dateTime -> tgt.when;
// src.when : Period -> tgt.when;
// }
group ExplanationOfBenefitPayee(source src, target tgt) extends BackboneElement {
  src.type -> tgt.type;
  src.party -> tgt.party;
}

group ExplanationOfBenefitCareTeam(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.provider -> tgt.provider;
  src.responsible -> tgt.responsible;
  src.role -> tgt.role;
  src.qualification -> tgt.specialty;
}

group ExplanationOfBenefitSupportingInfo(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.category -> tgt.category;
  src.code -> tgt.code;
  src.timing : date -> tgt.timing;
  src.timing : Period -> tgt.timing;
  src.value : boolean -> tgt.value;
  src.value : string -> tgt.value;
  src.value : Quantity -> tgt.value;
  src.value : Attachment -> tgt.value;
  src.value : Reference -> tgt.value;
  src.reason -> tgt.reason; // src.value : Identifier -> tgt.value;
}

group ExplanationOfBenefitDiagnosis(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.diagnosis : CodeableConcept -> tgt.diagnosis;
  src.diagnosis : Reference -> tgt.diagnosis;
  src.type -> tgt.type;
  src.onAdmission -> tgt.onAdmission;
}

group ExplanationOfBenefitProcedure(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.type -> tgt.type;
  src.date -> tgt.date;
  src.procedure : CodeableConcept -> tgt.procedure;
  src.procedure : Reference -> tgt.procedure;
  src.udi -> tgt.udi;
}

group ExplanationOfBenefitInsurance(source src, target tgt) extends BackboneElement {
  src.focal -> tgt.focal;
  src.coverage -> tgt.coverage;
  src.preAuthRef -> tgt.preAuthRef;
}

group ExplanationOfBenefitAccident(source src, target tgt) extends BackboneElement {
  src.date -> tgt.date;
  src.type -> tgt.type;
  src.location : Address -> tgt.location;
  src.location : Reference -> tgt.location;
}

group ExplanationOfBenefitItem(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.careTeamSequence -> tgt.careTeamSequence;
  src.diagnosisSequence -> tgt.diagnosisSequence;
  src.procedureSequence -> tgt.procedureSequence;
  src.informationSequence -> tgt.informationSequence;
  src.revenue -> tgt.revenue; // src.traceNumber -> tgt.traceNumber;
  src.category -> tgt.category;
  src.productOrService -> tgt.productOrService;
  src.modifier -> tgt.modifier; // src.productOrServiceEnd -> tgt.productOrServiceEnd;
  src.programCode -> tgt.programCode;
  src.serviced : date -> tgt.serviced;
  src.serviced : Period -> tgt.serviced;
  src.location : CodeableConcept -> tgt.location;
  src.location : Address -> tgt.location;
  src.location : Reference -> tgt.location;
  src.quantity -> tgt.quantity; // src.patientPaid -> tgt.patientPaid;
  src.unitPrice -> tgt.unitPrice;
  src.factor -> tgt.factor;
  src.net -> tgt.net; // src.tax -> tgt.tax;
  src.udi -> tgt.udi;
  src.bodySite as s ->  tgt.bodySite as t,  t.site = s;
  src.subSite as s ->  tgt.bodySite as t,  t.subSite = s;
  src.encounter -> tgt.encounter;
  src.noteNumber -> tgt.noteNumber;
  src.adjudication as s -> tgt.adjudication as t then ExplanationOfBenefitItemAdjudication(s, t); // src.reviewOutcome as s -> tgt.reviewOutcome as t then ExplanationOfBenefitItemReviewOutcome(s,t);
  src.detail as s -> tgt.detail as t then ExplanationOfBenefitItemDetail(s, t);
}

// group ExplanationOfBenefitItemBodySite(source src, target tgt) extends BackboneElement {
// src.site -> tgt.site;
// src.subSite -> tgt.subSite;
// }
// group ExplanationOfBenefitItemReviewOutcome(source src, target tgt) extends BackboneElement {
// src.decision -> tgt.decision;
// src.reason -> tgt.reason;
// src.preAuthRef -> tgt.preAuthRef;
// src.preAuthPeriod -> tgt.preAuthPeriod;
// }
group ExplanationOfBenefitItemAdjudication(source src, target tgt) extends BackboneElement {
  src.category -> tgt.category;
  src.reason -> tgt.reason;
  src.amount -> tgt.amount;
  src.value as s ->  tgt.quantity = create('Quantity') as t,  t.value = s;
}

group ExplanationOfBenefitItemDetail(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.revenue -> tgt.revenue; // src.traceNumber -> tgt.traceNumber;
  src.category -> tgt.category;
  src.productOrService -> tgt.productOrService;
  src.modifier -> tgt.modifier; // src.productOrServiceEnd -> tgt.productOrServiceEnd;
  src.programCode -> tgt.programCode;
  src.quantity -> tgt.quantity; // src.patientPaid -> tgt.patientPaid;
  src.unitPrice -> tgt.unitPrice;
  src.factor -> tgt.factor;
  src.net -> tgt.net; // src.tax -> tgt.tax;
  src.udi -> tgt.udi;
  src.noteNumber -> tgt.noteNumber;
  src.subDetail as s -> tgt.subDetail as t then ExplanationOfBenefitItemDetailSubDetail(s, t);
}

group ExplanationOfBenefitItemDetailSubDetail(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.revenue -> tgt.revenue; // src.traceNumber -> tgt.traceNumber;
  src.category -> tgt.category;
  src.productOrService -> tgt.productOrService;
  src.modifier -> tgt.modifier; // src.productOrServiceEnd -> tgt.productOrServiceEnd;
  src.programCode -> tgt.programCode;
  src.quantity -> tgt.quantity; // src.patientPaid -> tgt.patientPaid;
  src.unitPrice -> tgt.unitPrice;
  src.factor -> tgt.factor;
  src.net -> tgt.net; // src.tax -> tgt.tax;
  src.udi -> tgt.udi;
  src.noteNumber -> tgt.noteNumber;
}

group ExplanationOfBenefitAddItem(source src, target tgt) extends BackboneElement {
  src.itemSequence -> tgt.itemSequence;
  src.detailSequence -> tgt.detailSequence;
  src.subDetailSequence -> tgt.subDetailSequence;
  src.provider -> tgt.provider; // src.traceNumber -> tgt.traceNumber;
  src.productOrService -> tgt.productOrService; // src.revenue -> tgt.revenue;
  src.modifier -> tgt.modifier; // src.productOrServiceEnd -> tgt.productOrServiceEnd;
  src.programCode -> tgt.programCode;
  src.serviced : date -> tgt.serviced;
  src.serviced : Period -> tgt.serviced;
  src.location : CodeableConcept -> tgt.location;
  src.location : Address -> tgt.location;
  src.location : Reference -> tgt.location;
  src.quantity -> tgt.quantity; // src.patientPaid -> tgt.patientPaid;
  src.unitPrice -> tgt.unitPrice;
  src.factor -> tgt.factor;
  src.net -> tgt.net; // src.tax -> tgt.tax;
  src.bodySite as s ->  tgt.bodySite as t,  t.site = s;
  src.subSite as s ->  tgt.bodySite as t,  t.subSite = s;
  src.noteNumber -> tgt.noteNumber;
  src.detail as s -> tgt.detail as t then ExplanationOfBenefitAddItemDetail(s, t);
}

// group ExplanationOfBenefitAddItemBodySite(source src, target tgt) extends BackboneElement {
// src.site -> tgt.site;
// src.subSite -> tgt.subSite;
// }
group ExplanationOfBenefitAddItemDetail(source src, target tgt) extends BackboneElement {
  src.productOrService -> tgt.productOrService; // src.traceNumber -> tgt.traceNumber;
  src.modifier -> tgt.modifier; // src.productOrServiceEnd -> tgt.productOrServiceEnd;
  src.quantity -> tgt.quantity; // src.patientPaid -> tgt.patientPaid;
  src.unitPrice -> tgt.unitPrice;
  src.factor -> tgt.factor;
  src.net -> tgt.net; // src.tax -> tgt.tax;
  src.noteNumber -> tgt.noteNumber;
  src.subDetail as s -> tgt.subDetail as t then ExplanationOfBenefitAddItemDetailSubDetail(s, t);
}

group ExplanationOfBenefitAddItemDetailSubDetail(source src, target tgt) extends BackboneElement {
  src.productOrService -> tgt.productOrService; // src.traceNumber -> tgt.traceNumber;
  src.modifier -> tgt.modifier; // src.productOrServiceEnd -> tgt.productOrServiceEnd;
  src.quantity -> tgt.quantity; // src.patientPaid -> tgt.patientPaid;
  src.unitPrice -> tgt.unitPrice;
  src.factor -> tgt.factor;
  src.net -> tgt.net; // src.tax -> tgt.tax;
  src.noteNumber -> tgt.noteNumber;
}

group ExplanationOfBenefitTotal(source src, target tgt) extends BackboneElement {
  src.category -> tgt.category;
  src.amount -> tgt.amount;
}

group ExplanationOfBenefitPayment(source src, target tgt) extends BackboneElement {
  src.type -> tgt.type;
  src.adjustment -> tgt.adjustment;
  src.adjustmentReason -> tgt.adjustmentReason;
  src.date -> tgt.date;
  src.amount -> tgt.amount;
  src.identifier -> tgt.identifier;
}

group ExplanationOfBenefitProcessNote(source src, target tgt) extends BackboneElement {
  src.number -> tgt.number;
  src.type as s where code = 'display' ->  tgt.type = create('CodeableConcept') as tc,  tc.coding = create('Coding') as tcc,  tcc.system = 'http://hl7.org/fhir/note-type',  tcc.code = 'display',  tcc.display = 'display';
  src.type as s where code = 'print' ->  tgt.type = create('CodeableConcept') as tc,  tc.coding = create('Coding') as tcc,  tcc.system = 'http://hl7.org/fhir/note-type',  tcc.code = 'print',  tcc.display = 'Print (Form)';
  src.type as s where code = 'printoper' ->  tgt.type = create('CodeableConcept') as tc,  tc.coding = create('Coding') as tcc,  tcc.system = 'http://hl7.org/fhir/note-type',  tcc.code = 'printoper',  tcc.display = 'Print (Operator)';
  src.text -> tgt.text;
  src.language -> tgt.language;
}

group ExplanationOfBenefitBenefitBalance(source src, target tgt) extends BackboneElement {
  src.category -> tgt.category;
  src.excluded -> tgt.excluded;
  src.name -> tgt.name;
  src.description -> tgt.description;
  src.network -> tgt.network;
  src.unit -> tgt.unit;
  src.term -> tgt.term;
  src.financial as s -> tgt.financial as t then ExplanationOfBenefitBenefitBalanceFinancial(s, t);
}

group ExplanationOfBenefitBenefitBalanceFinancial(source src, target tgt) extends BackboneElement {
  src.type -> tgt.type;
  src.allowed : unsignedInt -> tgt.allowed;
  src.allowed : string -> tgt.allowed;
  src.allowed : Money -> tgt.allowed;
  src.used : unsignedInt -> tgt.used;
  src.used : Money -> tgt.used;
}

FML Conversion for ExplanationOfBenefit: R4 to R5 (Ready for Use/Trial Use)

/// url = 'http://hl7.org/fhir/StructureMap/ExplanationOfBenefit4to5'
/// name = 'ExplanationOfBenefit4to5'
/// title = 'FML Conversion for ExplanationOfBenefit: R4 to R5'
/// status = 'active'

conceptmap "ClaimOutcome" {
  prefix s = "http://hl7.org/fhir/4.0/remittance-outcome"
  prefix t = "http://hl7.org/fhir/claim-outcome"

  s:queued - t:queued
  s:complete - t:complete
  s:error - t:error
  s:partial - t:partial
}

conceptmap "ExplanationOfBenefitStatus" {
  prefix s = "http://hl7.org/fhir/4.0/explanationofbenefit-status"
  prefix t = "http://hl7.org/fhir/explanationofbenefit-status"

  s:active - t:active
  s:cancelled - t:cancelled
  s:draft - t:draft
  s:"entered-in-error" - t:"entered-in-error"
}

conceptmap "Use" {
  prefix s = "http://hl7.org/fhir/4.0/claim-use"
  prefix t = "http://hl7.org/fhir/claim-use"

  s:claim - t:claim
  s:preauthorization - t:preauthorization
  s:predetermination - t:predetermination
}

uses "http://hl7.org/fhir/4.0/StructureDefinition/ExplanationOfBenefit" alias ExplanationOfBenefitR4 as source
uses "http://hl7.org/fhir/StructureDefinition/ExplanationOfBenefit" alias ExplanationOfBenefitR5 as target

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

group ExplanationOfBenefit(source src : ExplanationOfBenefitR4, target tgt : ExplanationOfBenefitR5) extends DomainResource <<type+>> {
  src.identifier -> tgt.identifier;
  src.status as v -> tgt.status = translate(v, '#ExplanationOfBenefitStatus', 'code'); // src.traceNumber -> tgt.traceNumber;
  src.type -> tgt.type;
  src.subType -> tgt.subType;
  src.use as v -> tgt.use = translate(v, '#Use', 'code');
  src.patient -> tgt.patient;
  src.billablePeriod -> tgt.billablePeriod;
  src.created -> tgt.created;
  src.enterer -> tgt.enterer;
  src.insurer -> tgt.insurer;
  src.provider -> tgt.provider;
  src.priority -> tgt.priority;
  src.fundsReserveRequested -> tgt.fundsReserveRequested;
  src.fundsReserve -> tgt.fundsReserve;
  src.related as s -> tgt.related as t then ExplanationOfBenefitRelated(s, t);
  src.prescription -> tgt.prescription;
  src.originalPrescription -> tgt.originalPrescription;
  src.payee as s -> tgt.payee as t then ExplanationOfBenefitPayee(s, t); // src.event as s -> tgt.event as t then ExplanationOfBenefitEvent(s,t);
  src.referral -> tgt.referral;
  src.facility -> tgt.facility; // src.encounter -> tgt.encounter;
  src.claim -> tgt.claim;
  src.claimResponse -> tgt.claimResponse;
  src.outcome as v -> tgt.outcome = translate(v, '#ClaimOutcome', 'code');
  src.disposition -> tgt.disposition; // src.decision -> tgt.decision;
  src.preAuthRef -> tgt.preAuthRef;
  src.preAuthRefPeriod -> tgt.preAuthRefPeriod;
  src.careTeam as s -> tgt.careTeam as t then ExplanationOfBenefitCareTeam(s, t); // src.diagnosisRelatedGroup -> tgt.diagnosisRelatedGroup;
  src.supportingInfo as s -> tgt.supportingInfo as t then ExplanationOfBenefitSupportingInfo(s, t);
  src.diagnosis as s -> tgt.diagnosis as t then ExplanationOfBenefitDiagnosis(s, t);
  src.procedure as s -> tgt.procedure as t then ExplanationOfBenefitProcedure(s, t);
  src.precedence -> tgt.precedence;
  src.insurance as s -> tgt.insurance as t then ExplanationOfBenefitInsurance(s, t);
  src.accident as s -> tgt.accident as t then ExplanationOfBenefitAccident(s, t);
  src.item as s -> tgt.item as t then ExplanationOfBenefitItem(s, t); // src.patientPaid -> tgt.patientPaid;
  src.addItem as s -> tgt.addItem as t then ExplanationOfBenefitAddItem(s, t);
  src.total as s -> tgt.total as t then ExplanationOfBenefitTotal(s, t);
  src.payment as s -> tgt.payment as t then ExplanationOfBenefitPayment(s, t);
  src.formCode -> tgt.formCode;
  src.form -> tgt.form;
  src.processNote as s -> tgt.processNote as t then ExplanationOfBenefitProcessNote(s, t);
  src.benefitPeriod -> tgt.benefitPeriod;
  src.benefitBalance as s -> tgt.benefitBalance as t then ExplanationOfBenefitBenefitBalance(s, t);
}

group ExplanationOfBenefitRelated(source src, target tgt) extends BackboneElement {
  src.claim -> tgt.claim;
  src.relationship -> tgt.relationship;
  src.reference -> tgt.reference;
}

// group ExplanationOfBenefitEvent(source src, target tgt) extends BackboneElement {
// src.type -> tgt.type;
// src.when : dateTime -> tgt.when;
// src.when : Period -> tgt.when;
// }
group ExplanationOfBenefitPayee(source src, target tgt) extends BackboneElement {
  src.type -> tgt.type;
  src.party -> tgt.party;
}

group ExplanationOfBenefitCareTeam(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.provider -> tgt.provider;
  src.responsible -> tgt.responsible;
  src.role -> tgt.role;
  src.qualification -> tgt.specialty;
}

group ExplanationOfBenefitSupportingInfo(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.category -> tgt.category;
  src.code -> tgt.code;
  src.timing : date -> tgt.timing;
  src.timing : Period -> tgt.timing;
  src.value : boolean -> tgt.value;
  src.value : string -> tgt.value;
  src.value : Quantity -> tgt.value;
  src.value : Attachment -> tgt.value;
  src.value : Reference -> tgt.value;
  src.reason -> tgt.reason; // src.value : Identifier -> tgt.value;
}

group ExplanationOfBenefitDiagnosis(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.diagnosis : CodeableConcept -> tgt.diagnosis;
  src.diagnosis : Reference -> tgt.diagnosis;
  src.type -> tgt.type;
  src.onAdmission -> tgt.onAdmission;
}

group ExplanationOfBenefitProcedure(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.type -> tgt.type;
  src.date -> tgt.date;
  src.procedure : CodeableConcept -> tgt.procedure;
  src.procedure : Reference -> tgt.procedure;
  src.udi -> tgt.udi;
}

group ExplanationOfBenefitInsurance(source src, target tgt) extends BackboneElement {
  src.focal -> tgt.focal;
  src.coverage -> tgt.coverage;
  src.preAuthRef -> tgt.preAuthRef;
}

group ExplanationOfBenefitAccident(source src, target tgt) extends BackboneElement {
  src.date -> tgt.date;
  src.type -> tgt.type;
  src.location : Address -> tgt.location;
  src.location : Reference -> tgt.location;
}

group ExplanationOfBenefitItem(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.careTeamSequence -> tgt.careTeamSequence;
  src.diagnosisSequence -> tgt.diagnosisSequence;
  src.procedureSequence -> tgt.procedureSequence;
  src.informationSequence -> tgt.informationSequence;
  src.revenue -> tgt.revenue; // src.traceNumber -> tgt.traceNumber;
  src.category -> tgt.category;
  src.productOrService -> tgt.productOrService;
  src.modifier -> tgt.modifier; // src.productOrServiceEnd -> tgt.productOrServiceEnd;
  src.programCode -> tgt.programCode;
  src.serviced : date -> tgt.serviced;
  src.serviced : Period -> tgt.serviced;
  src.location : CodeableConcept -> tgt.location;
  src.location : Address -> tgt.location;
  src.location : Reference -> tgt.location;
  src.quantity -> tgt.quantity; // src.patientPaid -> tgt.patientPaid;
  src.unitPrice -> tgt.unitPrice;
  src.factor -> tgt.factor;
  src.net -> tgt.net; // src.tax -> tgt.tax;
  src.udi -> tgt.udi;
  src.bodySite as s ->  tgt.bodySite as t,  t.site = s;
  src.subSite as s ->  tgt.bodySite as t,  t.subSite = s;
  src.encounter -> tgt.encounter;
  src.noteNumber -> tgt.noteNumber;
  src.adjudication as s -> tgt.adjudication as t then ExplanationOfBenefitItemAdjudication(s, t); // src.reviewOutcome as s -> tgt.reviewOutcome as t then ExplanationOfBenefitItemReviewOutcome(s,t);
  src.detail as s -> tgt.detail as t then ExplanationOfBenefitItemDetail(s, t);
}

// group ExplanationOfBenefitItemBodySite(source src, target tgt) extends BackboneElement {
// src.site -> tgt.site;
// src.subSite -> tgt.subSite;
// }
// group ExplanationOfBenefitItemReviewOutcome(source src, target tgt) extends BackboneElement {
// src.decision -> tgt.decision;
// src.reason -> tgt.reason;
// src.preAuthRef -> tgt.preAuthRef;
// src.preAuthPeriod -> tgt.preAuthPeriod;
// }
group ExplanationOfBenefitItemAdjudication(source src, target tgt) extends BackboneElement {
  src.category -> tgt.category;
  src.reason -> tgt.reason;
  src.amount -> tgt.amount;
  src.value as s ->  tgt.quantity = create('Quantity') as t,  t.value = s;
}

group ExplanationOfBenefitItemDetail(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.revenue -> tgt.revenue; // src.traceNumber -> tgt.traceNumber;
  src.category -> tgt.category;
  src.productOrService -> tgt.productOrService;
  src.modifier -> tgt.modifier; // src.productOrServiceEnd -> tgt.productOrServiceEnd;
  src.programCode -> tgt.programCode;
  src.quantity -> tgt.quantity; // src.patientPaid -> tgt.patientPaid;
  src.unitPrice -> tgt.unitPrice;
  src.factor -> tgt.factor;
  src.net -> tgt.net; // src.tax -> tgt.tax;
  src.udi -> tgt.udi;
  src.noteNumber -> tgt.noteNumber;
  src.subDetail as s -> tgt.subDetail as t then ExplanationOfBenefitItemDetailSubDetail(s, t);
}

group ExplanationOfBenefitItemDetailSubDetail(source src, target tgt) extends BackboneElement {
  src.sequence -> tgt.sequence;
  src.revenue -> tgt.revenue; // src.traceNumber -> tgt.traceNumber;
  src.category -> tgt.category;
  src.productOrService -> tgt.productOrService;
  src.modifier -> tgt.modifier; // src.productOrServiceEnd -> tgt.productOrServiceEnd;
  src.programCode -> tgt.programCode;
  src.quantity -> tgt.quantity; // src.patientPaid -> tgt.patientPaid;
  src.unitPrice -> tgt.unitPrice;
  src.factor -> tgt.factor;
  src.net -> tgt.net; // src.tax -> tgt.tax;
  src.udi -> tgt.udi;
  src.noteNumber -> tgt.noteNumber;
}

group ExplanationOfBenefitAddItem(source src, target tgt) extends BackboneElement {
  src.itemSequence -> tgt.itemSequence;
  src.detailSequence -> tgt.detailSequence;
  src.subDetailSequence -> tgt.subDetailSequence;
  src.provider -> tgt.provider; // src.traceNumber -> tgt.traceNumber;
  src.productOrService -> tgt.productOrService; // src.revenue -> tgt.revenue;
  src.modifier -> tgt.modifier; // src.productOrServiceEnd -> tgt.productOrServiceEnd;
  src.programCode -> tgt.programCode;
  src.serviced : date -> tgt.serviced;
  src.serviced : Period -> tgt.serviced;
  src.location : CodeableConcept -> tgt.location;
  src.location : Address -> tgt.location;
  src.location : Reference -> tgt.location;
  src.quantity -> tgt.quantity; // src.patientPaid -> tgt.patientPaid;
  src.unitPrice -> tgt.unitPrice;
  src.factor -> tgt.factor;
  src.net -> tgt.net; // src.tax -> tgt.tax;
  src.bodySite as s ->  tgt.bodySite as t,  t.site = s;
  src.subSite as s ->  tgt.bodySite as t,  t.subSite = s;
  src.noteNumber -> tgt.noteNumber;
  src.detail as s -> tgt.detail as t then ExplanationOfBenefitAddItemDetail(s, t);
}

// group ExplanationOfBenefitAddItemBodySite(source src, target tgt) extends BackboneElement {
// src.site -> tgt.site;
// src.subSite -> tgt.subSite;
// }
group ExplanationOfBenefitAddItemDetail(source src, target tgt) extends BackboneElement {
  src.productOrService -> tgt.productOrService; // src.traceNumber -> tgt.traceNumber;
  src.modifier -> tgt.modifier; // src.productOrServiceEnd -> tgt.productOrServiceEnd;
  src.quantity -> tgt.quantity; // src.patientPaid -> tgt.patientPaid;
  src.unitPrice -> tgt.unitPrice;
  src.factor -> tgt.factor;
  src.net -> tgt.net; // src.tax -> tgt.tax;
  src.noteNumber -> tgt.noteNumber;
  src.subDetail as s -> tgt.subDetail as t then ExplanationOfBenefitAddItemDetailSubDetail(s, t);
}

group ExplanationOfBenefitAddItemDetailSubDetail(source src, target tgt) extends BackboneElement {
  src.productOrService -> tgt.productOrService; // src.traceNumber -> tgt.traceNumber;
  src.modifier -> tgt.modifier; // src.productOrServiceEnd -> tgt.productOrServiceEnd;
  src.quantity -> tgt.quantity; // src.patientPaid -> tgt.patientPaid;
  src.unitPrice -> tgt.unitPrice;
  src.factor -> tgt.factor;
  src.net -> tgt.net; // src.tax -> tgt.tax;
  src.noteNumber -> tgt.noteNumber;
}

group ExplanationOfBenefitTotal(source src, target tgt) extends BackboneElement {
  src.category -> tgt.category;
  src.amount -> tgt.amount;
}

group ExplanationOfBenefitPayment(source src, target tgt) extends BackboneElement {
  src.type -> tgt.type;
  src.adjustment -> tgt.adjustment;
  src.adjustmentReason -> tgt.adjustmentReason;
  src.date -> tgt.date;
  src.amount -> tgt.amount;
  src.identifier -> tgt.identifier;
}

group ExplanationOfBenefitProcessNote(source src, target tgt) extends BackboneElement {
  src.number -> tgt.number;
  src.type as s where code = 'display' ->  tgt.type = create('CodeableConcept') as tc,  tc.coding = create('Coding') as tcc,  tcc.system = 'http://hl7.org/fhir/note-type',  tcc.code = 'display',  tcc.display = 'display';
  src.type as s where code = 'print' ->  tgt.type = create('CodeableConcept') as tc,  tc.coding = create('Coding') as tcc,  tcc.system = 'http://hl7.org/fhir/note-type',  tcc.code = 'print',  tcc.display = 'Print (Form)';
  src.type as s where code = 'printoper' ->  tgt.type = create('CodeableConcept') as tc,  tc.coding = create('Coding') as tcc,  tcc.system = 'http://hl7.org/fhir/note-type',  tcc.code = 'printoper',  tcc.display = 'Print (Operator)';
  src.text -> tgt.text;
  src.language -> tgt.language;
}

group ExplanationOfBenefitBenefitBalance(source src, target tgt) extends BackboneElement {
  src.category -> tgt.category;
  src.excluded -> tgt.excluded;
  src.name -> tgt.name;
  src.description -> tgt.description;
  src.network -> tgt.network;
  src.unit -> tgt.unit;
  src.term -> tgt.term;
  src.financial as s -> tgt.financial as t then ExplanationOfBenefitBenefitBalanceFinancial(s, t);
}

group ExplanationOfBenefitBenefitBalanceFinancial(source src, target tgt) extends BackboneElement {
  src.type -> tgt.type;
  src.allowed : unsignedInt -> tgt.allowed;
  src.allowed : string -> tgt.allowed;
  src.allowed : Money -> tgt.allowed;
  src.used : unsignedInt -> tgt.used;
  src.used : Money -> tgt.used;
}