FHIR Release 3 (STU)

This page is part of the FHIR Specification (v3.0.2: STU 3). 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

Explanationofbenefit.shex

Financial Management Work GroupMaturity Level: N/ABallot Status: InformativeCompartments: Encounter, Patient, Practitioner, RelatedPerson

Raw ShEx

ShEx statement for explanationofbenefit

PREFIX fhir: <http://hl7.org/fhir/> 
PREFIX fhirvs: <http://hl7.org/fhir/ValueSet/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 
BASE <http://hl7.org/fhir/shape/>

start=@<ExplanationOfBenefit> AND {fhir:nodeRole [fhir:treeRoot]}


# Explanation of Benefit resource
<ExplanationOfBenefit> CLOSED {
    a [fhir:ExplanationOfBenefit];
    fhir:nodeRole [fhir:treeRoot]?;
    fhir:Resource.id @<id>?;                # Logical id of this artifact
    fhir:Resource.meta @<Meta>?;            # Metadata about the resource
    fhir:Resource.implicitRules @<uri>?;    # A set of rules under which this 
                                            # content was created 
    fhir:Resource.language @<code>?;        # Language of the resource content
    fhir:DomainResource.text @<Narrative>?;  # Text summary of the resource, for 
                                            # human interpretation 
    fhir:DomainResource.contained @<Resource>*;  # Contained, inline Resources
    fhir:DomainResource.extension @<Extension>*;  # Additional Content defined by 
                                            # implementations 
    fhir:DomainResource.modifierExtension @<Extension>*;  # Extensions that cannot be ignored
    fhir:ExplanationOfBenefit.identifier @<Identifier>*;  # Business Identifier
    fhir:ExplanationOfBenefit.status @<code> AND
    	{fhir:value @fhirvs:explanationofbenefit-status}?;  # active | cancelled | draft | 
                                            # entered-in-error 
    fhir:ExplanationOfBenefit.type @<CodeableConcept>?;  # Type or discipline
    fhir:ExplanationOfBenefit.subType @<CodeableConcept>*;  # Finer grained claim type 
                                            # information 
    fhir:ExplanationOfBenefit.patient @<Reference>?;  # The subject of the Products and 
                                            # Services 
    fhir:ExplanationOfBenefit.billablePeriod @<Period>?;  # Period for charge submission
    fhir:ExplanationOfBenefit.created @<dateTime>?;  # Creation date
    fhir:ExplanationOfBenefit.enterer @<Reference>?;  # Author
    fhir:ExplanationOfBenefit.insurer @<Reference>?;  # Insurer responsible for the EOB
    fhir:ExplanationOfBenefit.provider @<Reference>?;  # Responsible provider for the claim
    fhir:ExplanationOfBenefit.organization @<Reference>?;  # Responsible organization for the 
                                            # claim 
    fhir:ExplanationOfBenefit.referral @<Reference>?;  # Treatment Referral
    fhir:ExplanationOfBenefit.facility @<Reference>?;  # Servicing Facility
    fhir:ExplanationOfBenefit.claim @<Reference>?;  # Claim reference
    fhir:ExplanationOfBenefit.claimResponse @<Reference>?;  # Claim response reference
    fhir:ExplanationOfBenefit.outcome @<CodeableConcept>?;  # complete | error | partial
    fhir:ExplanationOfBenefit.disposition @<string>?;  # Disposition Message
    fhir:ExplanationOfBenefit.related @<ExplanationOfBenefit.related>*;  # Related Claims which may be 
                                            # revelant to processing this claim 
    fhir:ExplanationOfBenefit.prescription  # Prescription authorizing services 
                                            # or products 
    (   @<MedicationRequestReference> OR
        @<VisionPrescriptionReference>
    )?;
    fhir:ExplanationOfBenefit.originalPrescription @<Reference>?;  # Original prescription if 
                                            # superceded by fulfiller 
    fhir:ExplanationOfBenefit.payee @<ExplanationOfBenefit.payee>?;  # Party to be paid any benefits 
                                            # payable 
    fhir:ExplanationOfBenefit.information @<ExplanationOfBenefit.information>*;  # Exceptions, special 
                                            # considerations, the condition, 
                                            # situation, prior or concurrent 
                                            # issues 
    fhir:ExplanationOfBenefit.careTeam @<ExplanationOfBenefit.careTeam>*;  # Care Team members
    fhir:ExplanationOfBenefit.diagnosis @<ExplanationOfBenefit.diagnosis>*;  # List of Diagnosis
    fhir:ExplanationOfBenefit.procedure @<ExplanationOfBenefit.procedure>*;  # Procedures performed
    fhir:ExplanationOfBenefit.precedence @<positiveInt>?;  # Precedence (primary, secondary, 
                                            # etc.) 
    fhir:ExplanationOfBenefit.insurance @<ExplanationOfBenefit.insurance>?;  # Insurance or medical plan
    fhir:ExplanationOfBenefit.accident @<ExplanationOfBenefit.accident>?;  # Details of an accident
    fhir:ExplanationOfBenefit.employmentImpacted @<Period>?;  # Period unable to work
    fhir:ExplanationOfBenefit.hospitalization @<Period>?;  # Period in hospital
    fhir:ExplanationOfBenefit.item @<ExplanationOfBenefit.item>*;  # Goods and Services
    fhir:ExplanationOfBenefit.addItem @<ExplanationOfBenefit.addItem>*;  # Insurer added line items
    fhir:ExplanationOfBenefit.totalCost @<Money>?;  # Total Cost of service from the 
                                            # Claim 
    fhir:ExplanationOfBenefit.unallocDeductable @<Money>?;  # Unallocated deductable
    fhir:ExplanationOfBenefit.totalBenefit @<Money>?;  # Total benefit payable for the Claim
    fhir:ExplanationOfBenefit.payment @<ExplanationOfBenefit.payment>?;  # Payment (if paid)
    fhir:ExplanationOfBenefit.form @<CodeableConcept>?;  # Printed Form Identifier
    fhir:ExplanationOfBenefit.processNote @<ExplanationOfBenefit.processNote>*;  # Processing notes
    fhir:ExplanationOfBenefit.benefitBalance @<ExplanationOfBenefit.benefitBalance>*;  # Balance by Benefit Category
    fhir:index xsd:integer?                 # Relative position in a list
}

# Exceptions, special considerations, the condition, situation, prior or concurrent issues
<ExplanationOfBenefit.information> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:BackboneElement.modifierExtension @<Extension>*;  # Extensions that cannot be ignored
    fhir:ExplanationOfBenefit.information.sequence @<positiveInt>;  # Information instance identifier
    fhir:ExplanationOfBenefit.information.category @<CodeableConcept>;  # General class of information
    fhir:ExplanationOfBenefit.information.code @<CodeableConcept>?;  # Type of information
    (                                       # When it occurred
        fhir:ExplanationOfBenefit.information.timingDate @<date>  |
        fhir:ExplanationOfBenefit.information.timingPeriod @<Period> 
    )?;
    (                                       # Additional Data or supporting 
                                            # information 
        fhir:ExplanationOfBenefit.information.valueString @<string>  |
        fhir:ExplanationOfBenefit.information.valueQuantity @<Quantity>  |
        fhir:ExplanationOfBenefit.information.valueAttachment @<Attachment>  |
        fhir:ExplanationOfBenefit.information.valueReference @<Reference> 
    )?;
    fhir:ExplanationOfBenefit.information.reason @<Coding>?;  # Reason associated with the 
                                            # information 
    fhir:index xsd:integer?                 # Relative position in a list
}

# Balance by Benefit Category
<ExplanationOfBenefit.benefitBalance> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:BackboneElement.modifierExtension @<Extension>*;  # Extensions that cannot be ignored
    fhir:ExplanationOfBenefit.benefitBalance.category @<CodeableConcept>;  # Type of services covered
    fhir:ExplanationOfBenefit.benefitBalance.subCategory @<CodeableConcept>?;  # Detailed services covered within 
                                            # the type 
    fhir:ExplanationOfBenefit.benefitBalance.excluded @<boolean>?;  # Excluded from the plan
    fhir:ExplanationOfBenefit.benefitBalance.name @<string>?;  # Short name for the benefit
    fhir:ExplanationOfBenefit.benefitBalance.description @<string>?;  # Description of the benefit or 
                                            # services covered 
    fhir:ExplanationOfBenefit.benefitBalance.network @<CodeableConcept>?;  # In or out of network
    fhir:ExplanationOfBenefit.benefitBalance.unit @<CodeableConcept>?;  # Individual or family
    fhir:ExplanationOfBenefit.benefitBalance.term @<CodeableConcept>?;  # Annual or lifetime
    fhir:ExplanationOfBenefit.benefitBalance.financial @<ExplanationOfBenefit.benefitBalance.financial>*;  # Benefit Summary
    fhir:index xsd:integer?                 # Relative position in a list
}

# Care Team members
<ExplanationOfBenefit.careTeam> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:BackboneElement.modifierExtension @<Extension>*;  # Extensions that cannot be ignored
    fhir:ExplanationOfBenefit.careTeam.sequence @<positiveInt>;  # Number to covey order of careteam
    fhir:ExplanationOfBenefit.careTeam.provider  # Member of the Care Team
    (   @<PractitionerReference> OR
        @<OrganizationReference>
    );
    fhir:ExplanationOfBenefit.careTeam.responsible @<boolean>?;  # Billing practitioner
    fhir:ExplanationOfBenefit.careTeam.role @<CodeableConcept>?;  # Role on the team
    fhir:ExplanationOfBenefit.careTeam.qualification @<CodeableConcept>?;  # Type, classification or 
                                            # Specialization 
    fhir:index xsd:integer?                 # Relative position in a list
}

# Insurance or medical plan
<ExplanationOfBenefit.insurance> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:BackboneElement.modifierExtension @<Extension>*;  # Extensions that cannot be ignored
    fhir:ExplanationOfBenefit.insurance.coverage @<Reference>?;  # Insurance information
    fhir:ExplanationOfBenefit.insurance.preAuthRef @<string>*;  # Pre-Authorization/Determination 
                                            # Reference 
    fhir:index xsd:integer?                 # Relative position in a list
}

# Processing notes
<ExplanationOfBenefit.processNote> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:BackboneElement.modifierExtension @<Extension>*;  # Extensions that cannot be ignored
    fhir:ExplanationOfBenefit.processNote.number @<positiveInt>?;  # Sequence number for this note
    fhir:ExplanationOfBenefit.processNote.type @<CodeableConcept>?;  # display | print | printoper
    fhir:ExplanationOfBenefit.processNote.text @<string>?;  # Note explanitory text
    fhir:ExplanationOfBenefit.processNote.language @<CodeableConcept>?;  # Language if different from the 
                                            # resource 
    fhir:index xsd:integer?                 # Relative position in a list
}

# Payment (if paid)
<ExplanationOfBenefit.payment> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:BackboneElement.modifierExtension @<Extension>*;  # Extensions that cannot be ignored
    fhir:ExplanationOfBenefit.payment.type @<CodeableConcept>?;  # Partial or Complete
    fhir:ExplanationOfBenefit.payment.adjustment @<Money>?;  # Payment adjustment for non-Claim 
                                            # issues 
    fhir:ExplanationOfBenefit.payment.adjustmentReason @<CodeableConcept>?;  # Explanation for the non-claim 
                                            # adjustment 
    fhir:ExplanationOfBenefit.payment.date @<date>?;  # Expected date of Payment
    fhir:ExplanationOfBenefit.payment.amount @<Money>?;  # Payable amount after adjustment
    fhir:ExplanationOfBenefit.payment.identifier @<Identifier>?;  # Identifier of the payment 
                                            # instrument 
    fhir:index xsd:integer?                 # Relative position in a list
}

# Procedures performed
<ExplanationOfBenefit.procedure> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:BackboneElement.modifierExtension @<Extension>*;  # Extensions that cannot be ignored
    fhir:ExplanationOfBenefit.procedure.sequence @<positiveInt>;  # Procedure sequence for reference
    fhir:ExplanationOfBenefit.procedure.date @<dateTime>?;  # When the procedure was performed
    (                                       # Patient's list of procedures 
                                            # performed 
        fhir:ExplanationOfBenefit.procedure.procedureCodeableConcept @<CodeableConcept>  |
        fhir:ExplanationOfBenefit.procedure.procedureReference @<Reference> 
    );
    fhir:index xsd:integer?                 # Relative position in a list
}

# List of Diagnosis
<ExplanationOfBenefit.diagnosis> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:BackboneElement.modifierExtension @<Extension>*;  # Extensions that cannot be ignored
    fhir:ExplanationOfBenefit.diagnosis.sequence @<positiveInt>;  # Number to covey order of diagnosis
    (                                       # Patient's diagnosis
        fhir:ExplanationOfBenefit.diagnosis.diagnosisCodeableConcept @<CodeableConcept>  |
        fhir:ExplanationOfBenefit.diagnosis.diagnosisReference @<Reference> 
    );
    fhir:ExplanationOfBenefit.diagnosis.type @<CodeableConcept>*;  # Timing or nature of the diagnosis
    fhir:ExplanationOfBenefit.diagnosis.packageCode @<CodeableConcept>?;  # Package billing code
    fhir:index xsd:integer?                 # Relative position in a list
}

# Party to be paid any benefits payable
<ExplanationOfBenefit.payee> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:BackboneElement.modifierExtension @<Extension>*;  # Extensions that cannot be ignored
    fhir:ExplanationOfBenefit.payee.type @<CodeableConcept>?;  # Type of party: Subscriber, 
                                            # Provider, other 
    fhir:ExplanationOfBenefit.payee.resourceType @<CodeableConcept>?;  # organization | patient | 
                                            # practitioner | relatedperson 
    fhir:ExplanationOfBenefit.payee.party   # Party to receive the payable
    (   @<PractitionerReference> OR
        @<OrganizationReference> OR
        @<PatientReference> OR
        @<RelatedPersonReference>
    )?;
    fhir:index xsd:integer?                 # Relative position in a list
}

# Details of an accident
<ExplanationOfBenefit.accident> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:BackboneElement.modifierExtension @<Extension>*;  # Extensions that cannot be ignored
    fhir:ExplanationOfBenefit.accident.date @<date>?;  # When the accident occurred
    fhir:ExplanationOfBenefit.accident.type @<CodeableConcept>?;  # The nature of the accident
    (                                       # Accident Place
        fhir:ExplanationOfBenefit.accident.locationAddress @<Address>  |
        fhir:ExplanationOfBenefit.accident.locationReference @<Reference> 
    )?;
    fhir:index xsd:integer?                 # Relative position in a list
}

# Insurer added line items
<ExplanationOfBenefit.addItem> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:BackboneElement.modifierExtension @<Extension>*;  # Extensions that cannot be ignored
    fhir:ExplanationOfBenefit.addItem.sequenceLinkId @<positiveInt>*;  # Service instances
    fhir:ExplanationOfBenefit.addItem.revenue @<CodeableConcept>?;  # Revenue or cost center code
    fhir:ExplanationOfBenefit.addItem.category @<CodeableConcept>?;  # Type of service or product
    fhir:ExplanationOfBenefit.addItem.service @<CodeableConcept>?;  # Billing Code
    fhir:ExplanationOfBenefit.addItem.modifier @<CodeableConcept>*;  # Service/Product billing modifiers
    fhir:ExplanationOfBenefit.addItem.fee @<Money>?;  # Professional fee or Product charge
    fhir:ExplanationOfBenefit.addItem.noteNumber @<positiveInt>*;  # List of note numbers which apply
    fhir:ExplanationOfBenefit.addItem.adjudication @<ExplanationOfBenefit.item.adjudication>*;  # Added items adjudication
    fhir:ExplanationOfBenefit.addItem.detail @<ExplanationOfBenefit.addItem.detail>*;  # Added items details
    fhir:index xsd:integer?                 # Relative position in a list
}

# Related Claims which may be revelant to processing this claim
<ExplanationOfBenefit.related> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:BackboneElement.modifierExtension @<Extension>*;  # Extensions that cannot be ignored
    fhir:ExplanationOfBenefit.related.claim @<Reference>?;  # Reference to the related claim
    fhir:ExplanationOfBenefit.related.relationship @<CodeableConcept>?;  # How the reference claim is related
    fhir:ExplanationOfBenefit.related.reference @<Identifier>?;  # Related file or case reference
    fhir:index xsd:integer?                 # Relative position in a list
}

# Goods and Services
<ExplanationOfBenefit.item> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:BackboneElement.modifierExtension @<Extension>*;  # Extensions that cannot be ignored
    fhir:ExplanationOfBenefit.item.sequence @<positiveInt>;  # Service instance
    fhir:ExplanationOfBenefit.item.careTeamLinkId @<positiveInt>*;  # Applicable careteam members
    fhir:ExplanationOfBenefit.item.diagnosisLinkId @<positiveInt>*;  # Applicable diagnoses
    fhir:ExplanationOfBenefit.item.procedureLinkId @<positiveInt>*;  # Applicable procedures
    fhir:ExplanationOfBenefit.item.informationLinkId @<positiveInt>*;  # Applicable exception and 
                                            # supporting information 
    fhir:ExplanationOfBenefit.item.revenue @<CodeableConcept>?;  # Revenue or cost center code
    fhir:ExplanationOfBenefit.item.category @<CodeableConcept>?;  # Type of service or product
    fhir:ExplanationOfBenefit.item.service @<CodeableConcept>?;  # Billing Code
    fhir:ExplanationOfBenefit.item.modifier @<CodeableConcept>*;  # Service/Product billing modifiers
    fhir:ExplanationOfBenefit.item.programCode @<CodeableConcept>*;  # Program specific reason for item 
                                            # inclusion 
    (                                       # Date or dates of Service
        fhir:ExplanationOfBenefit.item.servicedDate @<date>  |
        fhir:ExplanationOfBenefit.item.servicedPeriod @<Period> 
    )?;
    (                                       # Place of service
        fhir:ExplanationOfBenefit.item.locationCodeableConcept @<CodeableConcept>  |
        fhir:ExplanationOfBenefit.item.locationAddress @<Address>  |
        fhir:ExplanationOfBenefit.item.locationReference @<Reference> 
    )?;
    fhir:ExplanationOfBenefit.item.quantity @<SimpleQuantity>?;  # Count of Products or Services
    fhir:ExplanationOfBenefit.item.unitPrice @<Money>?;  # Fee, charge or cost per point
    fhir:ExplanationOfBenefit.item.factor @<decimal>?;  # Price scaling factor
    fhir:ExplanationOfBenefit.item.net @<Money>?;  # Total item cost
    fhir:ExplanationOfBenefit.item.udi @<Reference>*;  # Unique Device Identifier
    fhir:ExplanationOfBenefit.item.bodySite @<CodeableConcept>?;  # Service Location
    fhir:ExplanationOfBenefit.item.subSite @<CodeableConcept>*;  # Service Sub-location
    fhir:ExplanationOfBenefit.item.encounter @<Reference>*;  # Encounters related to this billed 
                                            # item 
    fhir:ExplanationOfBenefit.item.noteNumber @<positiveInt>*;  # List of note numbers which apply
    fhir:ExplanationOfBenefit.item.adjudication @<ExplanationOfBenefit.item.adjudication>*;  # Adjudication details
    fhir:ExplanationOfBenefit.item.detail @<ExplanationOfBenefit.item.detail>*;  # Additional items
    fhir:index xsd:integer?                 # Relative position in a list
}

# Benefit Summary
<ExplanationOfBenefit.benefitBalance.financial> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:BackboneElement.modifierExtension @<Extension>*;  # Extensions that cannot be ignored
    fhir:ExplanationOfBenefit.benefitBalance.financial.type @<CodeableConcept>;  # Deductable, visits, benefit amount
    (                                       # Benefits allowed
        fhir:ExplanationOfBenefit.benefitBalance.financial.allowedUnsignedInt @<unsignedInt>  |
        fhir:ExplanationOfBenefit.benefitBalance.financial.allowedString @<string>  |
        fhir:ExplanationOfBenefit.benefitBalance.financial.allowedMoney @<Money> 
    )?;
    (                                       # Benefits used
        fhir:ExplanationOfBenefit.benefitBalance.financial.usedUnsignedInt @<unsignedInt>  |
        fhir:ExplanationOfBenefit.benefitBalance.financial.usedMoney @<Money> 
    )?;
    fhir:index xsd:integer?                 # Relative position in a list
}

# Additional items
<ExplanationOfBenefit.item.detail> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:BackboneElement.modifierExtension @<Extension>*;  # Extensions that cannot be ignored
    fhir:ExplanationOfBenefit.item.detail.sequence @<positiveInt>;  # Service instance
    fhir:ExplanationOfBenefit.item.detail.type @<CodeableConcept>;  # Group or type of product or service
    fhir:ExplanationOfBenefit.item.detail.revenue @<CodeableConcept>?;  # Revenue or cost center code
    fhir:ExplanationOfBenefit.item.detail.category @<CodeableConcept>?;  # Type of service or product
    fhir:ExplanationOfBenefit.item.detail.service @<CodeableConcept>?;  # Billing Code
    fhir:ExplanationOfBenefit.item.detail.modifier @<CodeableConcept>*;  # Service/Product billing modifiers
    fhir:ExplanationOfBenefit.item.detail.programCode @<CodeableConcept>*;  # Program specific reason for item 
                                            # inclusion 
    fhir:ExplanationOfBenefit.item.detail.quantity @<SimpleQuantity>?;  # Count of Products or Services
    fhir:ExplanationOfBenefit.item.detail.unitPrice @<Money>?;  # Fee, charge or cost per point
    fhir:ExplanationOfBenefit.item.detail.factor @<decimal>?;  # Price scaling factor
    fhir:ExplanationOfBenefit.item.detail.net @<Money>?;  # Total additional item cost
    fhir:ExplanationOfBenefit.item.detail.udi @<Reference>*;  # Unique Device Identifier
    fhir:ExplanationOfBenefit.item.detail.noteNumber @<positiveInt>*;  # List of note numbers which apply
    fhir:ExplanationOfBenefit.item.detail.adjudication @<ExplanationOfBenefit.item.adjudication>*;  # Detail level adjudication details
    fhir:ExplanationOfBenefit.item.detail.subDetail @<ExplanationOfBenefit.item.detail.subDetail>*;  # Additional items
    fhir:index xsd:integer?                 # Relative position in a list
}

# Adjudication details
<ExplanationOfBenefit.item.adjudication> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:BackboneElement.modifierExtension @<Extension>*;  # Extensions that cannot be ignored
    fhir:ExplanationOfBenefit.item.adjudication.category @<CodeableConcept>;  # Adjudication category such as 
                                            # co-pay, eligible, benefit, etc. 
    fhir:ExplanationOfBenefit.item.adjudication.reason @<CodeableConcept>?;  # Explanation of Adjudication outcome
    fhir:ExplanationOfBenefit.item.adjudication.amount @<Money>?;  # Monetary amount
    fhir:ExplanationOfBenefit.item.adjudication.value @<decimal>?;  # Non-monitory value
    fhir:index xsd:integer?                 # Relative position in a list
}

# Added items details
<ExplanationOfBenefit.addItem.detail> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:BackboneElement.modifierExtension @<Extension>*;  # Extensions that cannot be ignored
    fhir:ExplanationOfBenefit.addItem.detail.revenue @<CodeableConcept>?;  # Revenue or cost center code
    fhir:ExplanationOfBenefit.addItem.detail.category @<CodeableConcept>?;  # Type of service or product
    fhir:ExplanationOfBenefit.addItem.detail.service @<CodeableConcept>?;  # Billing Code
    fhir:ExplanationOfBenefit.addItem.detail.modifier @<CodeableConcept>*;  # Service/Product billing modifiers
    fhir:ExplanationOfBenefit.addItem.detail.fee @<Money>?;  # Professional fee or Product charge
    fhir:ExplanationOfBenefit.addItem.detail.noteNumber @<positiveInt>*;  # List of note numbers which apply
    fhir:ExplanationOfBenefit.addItem.detail.adjudication @<ExplanationOfBenefit.item.adjudication>*;  # Added items detail adjudication
    fhir:index xsd:integer?                 # Relative position in a list
}

# Additional items
<ExplanationOfBenefit.item.detail.subDetail> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:BackboneElement.modifierExtension @<Extension>*;  # Extensions that cannot be ignored
    fhir:ExplanationOfBenefit.item.detail.subDetail.sequence @<positiveInt>;  # Service instance
    fhir:ExplanationOfBenefit.item.detail.subDetail.type @<CodeableConcept>;  # Type of product or service
    fhir:ExplanationOfBenefit.item.detail.subDetail.revenue @<CodeableConcept>?;  # Revenue or cost center code
    fhir:ExplanationOfBenefit.item.detail.subDetail.category @<CodeableConcept>?;  # Type of service or product
    fhir:ExplanationOfBenefit.item.detail.subDetail.service @<CodeableConcept>?;  # Billing Code
    fhir:ExplanationOfBenefit.item.detail.subDetail.modifier @<CodeableConcept>*;  # Service/Product billing modifiers
    fhir:ExplanationOfBenefit.item.detail.subDetail.programCode @<CodeableConcept>*;  # Program specific reason for item 
                                            # inclusion 
    fhir:ExplanationOfBenefit.item.detail.subDetail.quantity @<SimpleQuantity>?;  # Count of Products or Services
    fhir:ExplanationOfBenefit.item.detail.subDetail.unitPrice @<Money>?;  # Fee, charge or cost per point
    fhir:ExplanationOfBenefit.item.detail.subDetail.factor @<decimal>?;  # Price scaling factor
    fhir:ExplanationOfBenefit.item.detail.subDetail.net @<Money>?;  # Net additional item cost
    fhir:ExplanationOfBenefit.item.detail.subDetail.udi @<Reference>*;  # Unique Device Identifier
    fhir:ExplanationOfBenefit.item.detail.subDetail.noteNumber @<positiveInt>*;  # List of note numbers which apply
    fhir:ExplanationOfBenefit.item.detail.subDetail.adjudication @<ExplanationOfBenefit.item.adjudication>*;  # Language if different from the 
                                            # resource 
    fhir:index xsd:integer?                 # Relative position in a list
}

#---------------------- Data Types -------------------

# Primitive Type dateTime
<dateTime> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:value xsd:gYear OR xsd:gYearMonth OR xsd:date OR xsd:dateTime?;  # Primitive value for dateTime
    fhir:index xsd:integer?                 # Relative position in a list
}

# Primitive Type date
<date> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:value xsd:gYear OR xsd:gYearMonth OR xsd:date?;  # Primitive value for date
    fhir:index xsd:integer?                 # Relative position in a list
}

# Metadata about a resource
<Meta> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:Meta.versionId @<id>?;             # Version specific identifier
    fhir:Meta.lastUpdated @<instant>?;      # When the resource version last 
                                            # changed 
    fhir:Meta.profile @<uri>*;              # Profiles this resource claims to 
                                            # conform to 
    fhir:Meta.security @<Coding>*;          # Security Labels applied to this 
                                            # resource 
    fhir:Meta.tag @<Coding>*;               # Tags applied to this resource
    fhir:index xsd:integer?                 # Relative position in a list
}

# Primitive Type code
<code> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:value xsd:string?;                 # Primitive value for code
    fhir:index xsd:integer?                 # Relative position in a list
}

# Primitive Type string
<string> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:value xsd:string MAXLENGTH 1048576?;  # Primitive value for string
    fhir:index xsd:integer?                 # Relative position in a list
}

# An address expressed using postal conventions (as opposed to GPS or other location definition formats)
<Address> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:Address.use @<code> AND
    	{fhir:value @fhirvs:address-use}?;  # home | work | temp | old - purpose 
                                            # of this address 
    fhir:Address.type @<code> AND
    	{fhir:value @fhirvs:address-type}?;  # postal | physical | both
    fhir:Address.text @<string>?;           # Text representation of the address
    fhir:Address.line @<string>*;           # Street name, number, direction & 
                                            # P.O. Box etc. 
    fhir:Address.city @<string>?;           # Name of city, town etc.
    fhir:Address.district @<string>?;       # District name (aka county)
    fhir:Address.state @<string>?;          # Sub-unit of country (abbreviations 
                                            # ok) 
    fhir:Address.postalCode @<string>?;     # Postal code for area
    fhir:Address.country @<string>?;        # Country (e.g. can be ISO 3166 2 or 
                                            # 3 letter code) 
    fhir:Address.period @<Period>?;         # Time period when address was/is in 
                                            # use 
    fhir:index xsd:integer?                 # Relative position in a list
}

# Content in a format defined elsewhere
<Attachment> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:Attachment.contentType @<code>?;   # Mime type of the content, with 
                                            # charset etc. 
    fhir:Attachment.language @<code>?;      # Human language of the content 
                                            # (BCP-47) 
    fhir:Attachment.data @<base64Binary>?;  # Data inline, base64ed
    fhir:Attachment.url @<uri>?;            # Uri where the data can be found
    fhir:Attachment.size @<unsignedInt>?;   # Number of bytes of content (if url 
                                            # provided) 
    fhir:Attachment.hash @<base64Binary>?;  # Hash of the data (sha-1, base64ed)
    fhir:Attachment.title @<string>?;       # Label to display in place of the 
                                            # data 
    fhir:Attachment.creation @<dateTime>?;  # Date attachment was first created
    fhir:index xsd:integer?                 # Relative position in a list
}

# An amount of economic utility in some recognized currency
<Money> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:Quantity.value @<decimal>?;        # Numerical value (with implicit 
                                            # precision) 
    fhir:Quantity.comparator @<code> AND
    	{fhir:value @fhirvs:quantity-comparator}?;  # < | <= | >= | > - how to 
                                            # understand the value 
    fhir:Quantity.unit @<string>?;          # Unit representation
    fhir:Quantity.system @<uri>?;           # System that defines coded unit form
    fhir:Quantity.code @<code>?;            # Coded form of the unit
    fhir:index xsd:integer?                 # Relative position in a list
}

# An identifier intended for computation
<Identifier> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:Identifier.use @<code> AND
    	{fhir:value @fhirvs:identifier-use}?;  # usual | official | temp | 
                                            # secondary (If known) 
    fhir:Identifier.type @<CodeableConcept>?;  # Description of identifier
    fhir:Identifier.system @<uri>?;         # The namespace for the identifier 
                                            # value 
    fhir:Identifier.value @<string>?;       # The value that is unique
    fhir:Identifier.period @<Period>?;      # Time period when id is/was valid 
                                            # for use 
    fhir:Identifier.assigner @<Reference>?;  # Organization that issued id (may 
                                            # be just text) 
    fhir:index xsd:integer?                 # Relative position in a list
}

# A human-readable formatted text, including images
<Narrative> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:Narrative.status @<code> AND
    	{fhir:value @fhirvs:narrative-status};  # generated | extensions | 
                                            # additional | empty 
    fhir:Narrative.div xsd:string;          # Limited xhtml content
    fhir:index xsd:integer?                 # Relative position in a list
}

# A reference to a code defined by a terminology system
<Coding> CLOSED {
    a NONLITERAL?;
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:Coding.system @<uri>?;             # Identity of the terminology system
    fhir:Coding.version @<string>?;         # Version of the system - if relevant
    fhir:Coding.code @<code>?;              # Symbol in syntax defined by the 
                                            # system 
    fhir:Coding.display @<string>?;         # Representation defined by the 
                                            # system 
    fhir:Coding.userSelected @<boolean>?;   # If this coding was chosen directly 
                                            # by the user 
    fhir:index xsd:integer?                 # Relative position in a list
}

# Primitive Type id
<id> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:value xsd:string?;                 # Primitive value for id
    fhir:index xsd:integer?                 # Relative position in a list
}

# Primitive Type positiveInt
<positiveInt> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:value xsd:positiveInteger?;        # Primitive value for positiveInt
    fhir:index xsd:integer?                 # Relative position in a list
}

# A reference from one resource to another
<Reference> CLOSED {
    fhir:link IRI?;
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:Reference.reference @<string>?;    # Literal reference, Relative, 
                                            # internal or absolute URL 
    fhir:Reference.identifier @<Identifier>?;  # Logical reference, when literal 
                                            # reference is not known 
    fhir:Reference.display @<string>?;      # Text alternative for the resource
    fhir:index xsd:integer?                 # Relative position in a list
}

# Base Resource
<Resource> {a .+;
    fhir:Resource.id @<id>?;                # Logical id of this artifact
    fhir:Resource.meta @<Meta>?;            # Metadata about the resource
    fhir:Resource.implicitRules @<uri>?;    # A set of rules under which this 
                                            # content was created 
    fhir:Resource.language @<code>?;        # Language of the resource content
    fhir:index xsd:integer?
}

# A fixed quantity (no comparator)
<SimpleQuantity> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:Quantity.value @<decimal>?;        # Numerical value (with implicit 
                                            # precision) 
    fhir:Quantity.unit @<string>?;          # Unit representation
    fhir:Quantity.system @<uri>?;           # System that defines coded unit form
    fhir:Quantity.code @<code>?;            # Coded form of the unit
    fhir:index xsd:integer?                 # Relative position in a list
}

# Time range defined by start and end date/time
<Period> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:Period.start @<dateTime>?;         # Starting time with inclusive 
                                            # boundary 
    fhir:Period.end @<dateTime>?;           # End time with inclusive boundary, 
                                            # if not ongoing 
    fhir:index xsd:integer?                 # Relative position in a list
}

# A measured or measurable amount
<Quantity> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:Quantity.value @<decimal>?;        # Numerical value (with implicit 
                                            # precision) 
    fhir:Quantity.comparator @<code> AND
    	{fhir:value @fhirvs:quantity-comparator}?;  # < | <= | >= | > - how to 
                                            # understand the value 
    fhir:Quantity.unit @<string>?;          # Unit representation
    fhir:Quantity.system @<uri>?;           # System that defines coded unit form
    fhir:Quantity.code @<code>?;            # Coded form of the unit
    fhir:index xsd:integer?                 # Relative position in a list
}

# Primitive Type uri
<uri> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:value xsd:string?;                 # Primitive value for uri
    fhir:index xsd:integer?                 # Relative position in a list
}

# Optional Extensions Element
<Extension> CLOSED {
    fhir:Element.id @<string>?; 
    fhir:Element.extension @<Extension>*; 
    fhir:Extension.url @<uri>; 
    ( 
        fhir:Extension.valueBase64Binary @<base64Binary>  |
        fhir:Extension.valueBoolean @<boolean>  |
        fhir:Extension.valueCode @<code>  |
        fhir:Extension.valueDate @<date>  |
        fhir:Extension.valueDateTime @<dateTime>  |
        fhir:Extension.valueDecimal @<decimal>  |
        fhir:Extension.valueId @<id>  |
        fhir:Extension.valueInstant @<instant>  |
        fhir:Extension.valueInteger @<integer>  |
        fhir:Extension.valueMarkdown @<markdown>  |
        fhir:Extension.valueOid @<oid>  |
        fhir:Extension.valuePositiveInt @<positiveInt>  |
        fhir:Extension.valueString @<string>  |
        fhir:Extension.valueTime @<time>  |
        fhir:Extension.valueUnsignedInt @<unsignedInt>  |
        fhir:Extension.valueUri @<uri>  |
        fhir:Extension.valueAddress @<Address>  |
        fhir:Extension.valueAge @<Age>  |
        fhir:Extension.valueAnnotation @<Annotation>  |
        fhir:Extension.valueAttachment @<Attachment>  |
        fhir:Extension.valueCodeableConcept @<CodeableConcept>  |
        fhir:Extension.valueCoding @<Coding>  |
        fhir:Extension.valueContactPoint @<ContactPoint>  |
        fhir:Extension.valueCount @<Count>  |
        fhir:Extension.valueDistance @<Distance>  |
        fhir:Extension.valueDuration @<Duration>  |
        fhir:Extension.valueHumanName @<HumanName>  |
        fhir:Extension.valueIdentifier @<Identifier>  |
        fhir:Extension.valueMoney @<Money>  |
        fhir:Extension.valuePeriod @<Period>  |
        fhir:Extension.valueQuantity @<Quantity>  |
        fhir:Extension.valueRange @<Range>  |
        fhir:Extension.valueRatio @<Ratio>  |
        fhir:Extension.valueReference @<Reference>  |
        fhir:Extension.valueSampledData @<SampledData>  |
        fhir:Extension.valueSignature @<Signature>  |
        fhir:Extension.valueTiming @<Timing>  |
        fhir:Extension.valueMeta @<Meta> 
    )?;
    fhir:index xsd:integer?                 # Relative position in a list
}

# Primitive Type boolean
<boolean> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:value xsd:boolean?;                # Primitive value for boolean
    fhir:index xsd:integer?                 # Relative position in a list
}

# Primitive Type unsignedInt
<unsignedInt> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:value xsd:nonNegativeInteger?;     # Primitive value for unsignedInt
    fhir:index xsd:integer?                 # Relative position in a list
}

# Primitive Type decimal
<decimal> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:value xsd:decimal?;                # Primitive value for decimal
    fhir:index xsd:integer?                 # Relative position in a list
}

# Concept - reference to a terminology or just  text
<CodeableConcept> CLOSED {
    a NONLITERAL*;
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:CodeableConcept.coding @<Coding>*;  # Code defined by a terminology 
                                            # system 
    fhir:CodeableConcept.text @<string>?;   # Plain text representation of the 
                                            # concept 
    fhir:index xsd:integer?                 # Relative position in a list
}

# Primitive Type integer
<integer> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:value xsd:integer MININCLUSIVE "-2147483648"^^xsd:integer MAXINCLUSIVE "2147483647"^^xsd:integer?;  # Primitive value for integer
    fhir:index xsd:integer?                 # Relative position in a list
}

# Primitive Type oid
<oid> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:value xsd:string?;                 # Primitive value for oid
    fhir:index xsd:integer?                 # Relative position in a list
}

# A measured or measurable amount
<Count> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:Quantity.value @<decimal>?;        # Numerical value (with implicit 
                                            # precision) 
    fhir:Quantity.comparator @<code> AND
    	{fhir:value @fhirvs:quantity-comparator}?;  # < | <= | >= | > - how to 
                                            # understand the value 
    fhir:Quantity.unit @<string>?;          # Unit representation
    fhir:Quantity.system @<uri>?;           # System that defines coded unit form
    fhir:Quantity.code @<code>?;            # Coded form of the unit
    fhir:index xsd:integer?                 # Relative position in a list
}

# Primitive Type instant
<instant> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:value xsd:dateTime?;               # Primitive value for instant
    fhir:index xsd:integer?                 # Relative position in a list
}

# Details of a Technology mediated contact point (phone, fax, email, etc.)
<ContactPoint> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:ContactPoint.system @<code> AND
    	{fhir:value @fhirvs:contact-point-system}?;  # phone | fax | email | pager | url 
                                            # | sms | other 
    fhir:ContactPoint.value @<string>?;     # The actual contact point details
    fhir:ContactPoint.use @<code> AND
    	{fhir:value @fhirvs:contact-point-use}?;  # home | work | temp | old | mobile 
                                            # - purpose of this contact point 
    fhir:ContactPoint.rank @<positiveInt>?;  # Specify preferred order of use (1 
                                            # = highest) 
    fhir:ContactPoint.period @<Period>?;    # Time period when the contact point 
                                            # was/is in use 
    fhir:index xsd:integer?                 # Relative position in a list
}

# Name of a human - parts and usage
<HumanName> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:HumanName.use @<code> AND
    	{fhir:value @fhirvs:name-use}?;  # usual | official | temp | nickname 
                                            # | anonymous | old | maiden 
    fhir:HumanName.text @<string>?;         # Text representation of the full 
                                            # name 
    fhir:HumanName.family @<string>?;       # Family name (often called 
                                            # 'Surname') 
    fhir:HumanName.given @<string>*;        # Given names (not always 'first'). 
                                            # Includes middle names 
    fhir:HumanName.prefix @<string>*;       # Parts that come before the name
    fhir:HumanName.suffix @<string>*;       # Parts that come after the name
    fhir:HumanName.period @<Period>?;       # Time period when name was/is in use
    fhir:index xsd:integer?                 # Relative position in a list
}

# Primitive Type markdown
<markdown> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:value xsd:string?;                 # Primitive value for markdown
    fhir:index xsd:integer?                 # Relative position in a list
}

# A series of measurements taken by a device
<SampledData> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:SampledData.origin @<SimpleQuantity>;  # Zero value and units
    fhir:SampledData.period @<decimal>;     # Number of milliseconds between 
                                            # samples 
    fhir:SampledData.factor @<decimal>?;    # Multiply data by this before 
                                            # adding to origin 
    fhir:SampledData.lowerLimit @<decimal>?;  # Lower limit of detection
    fhir:SampledData.upperLimit @<decimal>?;  # Upper limit of detection
    fhir:SampledData.dimensions @<positiveInt>;  # Number of sample points at each 
                                            # time point 
    fhir:SampledData.data @<string>;        # Decimal values with spaces, or "E" 
                                            # | "U" | "L" 
    fhir:index xsd:integer?                 # Relative position in a list
}

# A ratio of two Quantity values - a numerator and a denominator
<Ratio> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:Ratio.numerator @<Quantity>?;      # Numerator value
    fhir:Ratio.denominator @<Quantity>?;    # Denominator value
    fhir:index xsd:integer?                 # Relative position in a list
}

# A duration of time during which an organism (or a process) has existed
<Age> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:Quantity.value @<decimal>?;        # Numerical value (with implicit 
                                            # precision) 
    fhir:Quantity.comparator @<code> AND
    	{fhir:value @fhirvs:quantity-comparator}?;  # < | <= | >= | > - how to 
                                            # understand the value 
    fhir:Quantity.unit @<string>?;          # Unit representation
    fhir:Quantity.system @<uri>?;           # System that defines coded unit form
    fhir:Quantity.code @<code>?;            # Coded form of the unit
    fhir:index xsd:integer?                 # Relative position in a list
}

# A length - a value with a unit that is a physical distance
<Distance> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:Quantity.value @<decimal>?;        # Numerical value (with implicit 
                                            # precision) 
    fhir:Quantity.comparator @<code> AND
    	{fhir:value @fhirvs:quantity-comparator}?;  # < | <= | >= | > - how to 
                                            # understand the value 
    fhir:Quantity.unit @<string>?;          # Unit representation
    fhir:Quantity.system @<uri>?;           # System that defines coded unit form
    fhir:Quantity.code @<code>?;            # Coded form of the unit
    fhir:index xsd:integer?                 # Relative position in a list
}

# A length of time
<Duration> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:Quantity.value @<decimal>?;        # Numerical value (with implicit 
                                            # precision) 
    fhir:Quantity.comparator @<code> AND
    	{fhir:value @fhirvs:quantity-comparator}?;  # < | <= | >= | > - how to 
                                            # understand the value 
    fhir:Quantity.unit @<string>?;          # Unit representation
    fhir:Quantity.system @<uri>?;           # System that defines coded unit form
    fhir:Quantity.code @<code>?;            # Coded form of the unit
    fhir:index xsd:integer?                 # Relative position in a list
}

# Set of values bounded by low and high
<Range> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:Range.low @<SimpleQuantity>?;      # Low limit
    fhir:Range.high @<SimpleQuantity>?;     # High limit
    fhir:index xsd:integer?                 # Relative position in a list
}

# Text node with attribution
<Annotation> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    (                                       # Individual responsible for the 
                                            # annotation 
        fhir:Annotation.authorReference @<Reference>  |
        fhir:Annotation.authorReference @<Reference>  |
        fhir:Annotation.authorReference @<Reference>  |
        fhir:Annotation.authorString @<string> 
    )?;
    fhir:Annotation.time @<dateTime>?;      # When the annotation was made
    fhir:Annotation.text @<string>;         # The annotation  - text content
    fhir:index xsd:integer?                 # Relative position in a list
}

# Primitive Type base64Binary
<base64Binary> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:value xsd:base64Binary?;           # Primitive value for base64Binary
    fhir:index xsd:integer?                 # Relative position in a list
}

# A digital Signature - XML DigSig, JWT, Graphical image of signature, etc.
<Signature> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:Signature.type @<Coding>+;         # Indication of the reason the 
                                            # entity signed the object(s) 
    fhir:Signature.when @<instant>;         # When the signature was created
    (                                       # Who signed
        fhir:Signature.whoUri @<uri>  |
        fhir:Signature.whoReference @<Reference>  |
        fhir:Signature.whoReference @<Reference>  |
        fhir:Signature.whoReference @<Reference>  |
        fhir:Signature.whoReference @<Reference>  |
        fhir:Signature.whoReference @<Reference> 
    );
    (                                       # The party represented
        fhir:Signature.onBehalfOfUri @<uri>  |
        fhir:Signature.onBehalfOfReference @<Reference>  |
        fhir:Signature.onBehalfOfReference @<Reference>  |
        fhir:Signature.onBehalfOfReference @<Reference>  |
        fhir:Signature.onBehalfOfReference @<Reference>  |
        fhir:Signature.onBehalfOfReference @<Reference> 
    )?;
    fhir:Signature.contentType @<code>?;    # The technical format of the 
                                            # signature 
    fhir:Signature.blob @<base64Binary>?;   # The actual signature content (XML 
                                            # DigSig. JWT, picture, etc.) 
    fhir:index xsd:integer?                 # Relative position in a list
}

# Primitive Type time
<time> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:value xsd:time?;                   # Primitive value for time
    fhir:index xsd:integer?                 # Relative position in a list
}

# A timing schedule that specifies an event that may occur multiple times
<Timing> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    fhir:Timing.event @<dateTime>*;         # When the event occurs
    fhir:Timing.repeat @<Timing.repeat>?;   # When the event is to occur
    fhir:Timing.code @<CodeableConcept>?;   # BID | TID | QID | AM | PM | QD | 
                                            # QOD | Q4H | Q6H + 
    fhir:index xsd:integer?                 # Relative position in a list
}

# When the event is to occur
<Timing.repeat> CLOSED {
    fhir:Element.id @<string>?;             # xml:id (or equivalent in JSON)
    fhir:Element.extension @<Extension>*;   # Additional Content defined by 
                                            # implementations 
    (                                       # Length/Range of lengths, or (Start 
                                            # and/or end) limits 
        fhir:Timing.repeat.boundsDuration @<Duration>  |
        fhir:Timing.repeat.boundsRange @<Range>  |
        fhir:Timing.repeat.boundsPeriod @<Period> 
    )?;
    fhir:Timing.repeat.count @<integer>?;   # Number of times to repeat
    fhir:Timing.repeat.countMax @<integer>?;  # Maximum number of times to repeat
    fhir:Timing.repeat.duration @<decimal>?;  # How long when it happens
    fhir:Timing.repeat.durationMax @<decimal>?;  # How long when it happens (Max)
    fhir:Timing.repeat.durationUnit @<code> AND
    	{fhir:value @fhirvs:units-of-time}?;  # s | min | h | d | wk | mo | a - 
                                            # unit of time (UCUM) 
    fhir:Timing.repeat.frequency @<integer>?;  # Event occurs frequency times per 
                                            # period 
    fhir:Timing.repeat.frequencyMax @<integer>?;  # Event occurs up to frequencyMax 
                                            # times per period 
    fhir:Timing.repeat.period @<decimal>?;  # Event occurs frequency times per 
                                            # period 
    fhir:Timing.repeat.periodMax @<decimal>?;  # Upper limit of period (3-4 hours)
    fhir:Timing.repeat.periodUnit @<code> AND
    	{fhir:value @fhirvs:units-of-time}?;  # s | min | h | d | wk | mo | a - 
                                            # unit of time (UCUM) 
    fhir:Timing.repeat.dayOfWeek @<code> AND
    	{fhir:value @fhirvs:days-of-week}*;  # mon | tue | wed | thu | fri | sat 
                                            # | sun 
    fhir:Timing.repeat.timeOfDay @<time>*;  # Time of day for action
    fhir:Timing.repeat.when @<code> AND
    	{fhir:value @fhirvs:event-timing}*;  # Regular life events the event is 
                                            # tied to 
    fhir:Timing.repeat.offset @<unsignedInt>?;  # Minutes from event (before or 
                                            # after) 
    fhir:index xsd:integer?                 # Relative position in a list
}

#---------------------- Reference Types -------------------

<PractitionerReference> CLOSED {
    fhir:Element.id @<id>?;
    fhir:Element.extension @<Extension>*;
    fhir:link @<Practitioner> OR CLOSED {a [fhir:Practitioner]}?;
    fhir:Reference.reference @<string>?;
    fhir:Reference.display @<string>?;
    fhir:index xsd:integer?
}

<Practitioner> {
    a [fhir:Practitioner];
    fhir:nodeRole [fhir:treeRoot]?
}

<MedicationRequestReference> CLOSED {
    fhir:Element.id @<id>?;
    fhir:Element.extension @<Extension>*;
    fhir:link @<MedicationRequest> OR CLOSED {a [fhir:MedicationRequest]}?;
    fhir:Reference.reference @<string>?;
    fhir:Reference.display @<string>?;
    fhir:index xsd:integer?
}

<MedicationRequest> {
    a [fhir:MedicationRequest];
    fhir:nodeRole [fhir:treeRoot]?
}

<OrganizationReference> CLOSED {
    fhir:Element.id @<id>?;
    fhir:Element.extension @<Extension>*;
    fhir:link @<Organization> OR CLOSED {a [fhir:Organization]}?;
    fhir:Reference.reference @<string>?;
    fhir:Reference.display @<string>?;
    fhir:index xsd:integer?
}

<Organization> {
    a [fhir:Organization];
    fhir:nodeRole [fhir:treeRoot]?
}

<VisionPrescriptionReference> CLOSED {
    fhir:Element.id @<id>?;
    fhir:Element.extension @<Extension>*;
    fhir:link @<VisionPrescription> OR CLOSED {a [fhir:VisionPrescription]}?;
    fhir:Reference.reference @<string>?;
    fhir:Reference.display @<string>?;
    fhir:index xsd:integer?
}

<VisionPrescription> {
    a [fhir:VisionPrescription];
    fhir:nodeRole [fhir:treeRoot]?
}

<PatientReference> CLOSED {
    fhir:Element.id @<id>?;
    fhir:Element.extension @<Extension>*;
    fhir:link @<Patient> OR CLOSED {a [fhir:Patient]}?;
    fhir:Reference.reference @<string>?;
    fhir:Reference.display @<string>?;
    fhir:index xsd:integer?
}

<Patient> {
    a [fhir:Patient];
    fhir:nodeRole [fhir:treeRoot]?
}

<RelatedPersonReference> CLOSED {
    fhir:Element.id @<id>?;
    fhir:Element.extension @<Extension>*;
    fhir:link @<RelatedPerson> OR CLOSED {a [fhir:RelatedPerson]}?;
    fhir:Reference.reference @<string>?;
    fhir:Reference.display @<string>?;
    fhir:index xsd:integer?
}

<RelatedPerson> {
    a [fhir:RelatedPerson];
    fhir:nodeRole [fhir:treeRoot]?
}

#---------------------- Value Sets ------------------------

# The type of an address (physical / postal)
fhirvs:address-type ["postal" "physical" "both"]

# The status of a resource narrative
fhirvs:narrative-status ["generated" "extensions" "additional" "empty"]

# Use of contact point
fhirvs:contact-point-use ["home" "work" "temp" "old" "mobile"]

# Real world event relating to the schedule.
fhirvs:event-timing ["MORN" "AFT" "EVE" "NIGHT" "PHS" "HS" "WAKE" "C" "CM" "CD" "CV" "AC" "ACM" "ACD" "ACV" "PC" "PCM" "PCD" "PCV"]

# The days of the week.
fhirvs:days-of-week ["mon" "tue" "wed" "thu" "fri" "sat" "sun"]

# Identifies the purpose for this identifier, if known .
fhirvs:identifier-use ["usual" "official" "temp" "secondary"]

# A code specifying the state of the resource instance.
fhirvs:explanationofbenefit-status ["active" "cancelled" "draft" "entered-in-error"]

# A unit of time (units from UCUM).
fhirvs:units-of-time ["s" "min" "h" "d" "wk" "mo" "a"]

# The use of an address
fhirvs:address-use ["home" "work" "temp" "old"]

# The use of a human name
fhirvs:name-use ["usual" "official" "temp" "nickname" "anonymous" "old" "maiden"]

# How the Quantity should be understood and represented.
fhirvs:quantity-comparator ["<" "<=" ">=" ">"]

# Telecommunications form for contact point
fhirvs:contact-point-system ["phone" "fax" "email" "pager" "url" "sms" "other"]

Usage note: every effort has been made to ensure that the ShEx files are correct and useful, but they are not a normative part of the specification.