{
  "resourceType": "StructureDefinition",
  "id": "nexus-core-paymentreconciliation",
  "extension": [
    {
      "url": "https://fhir.apps.health/StructureDefinition/effective-date",
      "extension": [
        {
          "url": "paths",
          "valueString": "paymentDate"
        }
      ]
    }
  ],
  "url": "https://fhir.apps.health/StructureDefinition/nexus-core-paymentreconciliation",
  "name": "NexusCorePaymentReconciliation",
  "title": "Payment Reconciliation Profile",
  "status": "draft",
  "description": "Defines the Nexus EMR FHIR profile for a payment or refund taken at the clinic against private and third-party invoices raised at the billing vendor. One reconciliation per money event: a payment split across several invoices is one reconciliation with one detail per invoice. Invoices are named by the billing vendor's invoice identifier. Amounts are always positive; the detail type says whether money came in or went back. A reversal sets status to cancelled with a reason and keeps the record.",
  "fhirVersion": "4.0.1",
  "mapping": [
    {
      "identity": "workflow",
      "uri": "http://hl7.org/fhir/workflow",
      "name": "Workflow Pattern"
    },
    {
      "identity": "w5",
      "uri": "http://hl7.org/fhir/fivews",
      "name": "FiveWs Pattern Mapping"
    },
    {
      "identity": "cdanetv4",
      "uri": "http://www.cda-adc.ca/en/services/cdanet/",
      "name": "Canadian Dental Association eclaims standard"
    },
    {
      "identity": "rim",
      "uri": "http://hl7.org/v3",
      "name": "RIM Mapping"
    }
  ],
  "kind": "resource",
  "abstract": false,
  "type": "PaymentReconciliation",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/PaymentReconciliation",
  "derivation": "constraint",
  "snapshot": {
    "element": [
      {
        "id": "PaymentReconciliation",
        "path": "PaymentReconciliation",
        "short": "Nexus EMR payment or refund against billing-vendor invoices",
        "definition": "One payment or one refund taken at the clinic, allocated across one or more invoices raised at the\nbilling vendor. The billing vendor cannot record payments, so this is the clinic's ledger of them;\nan invoice's balance is its total less the active payments allocated to it plus the active refunds\nallocated to it.",
        "comment": "R4 `PaymentReconciliation` was designed for an insurer remitting to a provider. This profile uses\nit the other way round -- money taken from a patient or a third party at the clinic -- because it\nis the R4 resource whose elements fit: a payment with a date, an amount, an issuer, a reference\nnumber and per-invoice allocations. R5 widened the resource to cover exactly this case, and the\ntwo R5 elements this profile needs (`method`, `enterer`) are carried as R5 cross-version\nextensions.",
        "min": 0,
        "max": "*",
        "base": {
          "path": "PaymentReconciliation",
          "min": 0,
          "max": "*"
        },
        "constraint": [
          {
            "key": "dom-2",
            "severity": "error",
            "human": "If the resource is contained in another resource, it SHALL NOT contain nested Resources",
            "expression": "contained.contained.empty()",
            "xpath": "not(parent::f:contained and f:contained)",
            "source": "http://hl7.org/fhir/StructureDefinition/DomainResource"
          },
          {
            "key": "dom-3",
            "severity": "error",
            "human": "If the resource is contained in another resource, it SHALL be referred to from elsewhere in the resource or SHALL refer to the containing resource",
            "expression": "contained.where((('#'+id in (%resource.descendants().reference | %resource.descendants().as(canonical) | %resource.descendants().as(uri) | %resource.descendants().as(url))) or descendants().where(reference = '#').exists() or descendants().where(as(canonical) = '#').exists() or descendants().where(as(canonical) = '#').exists()).not()).trace('unmatched', id).empty()",
            "xpath": "not(exists(for $id in f:contained/*/f:id/@value return $contained[not(parent::*/descendant::f:reference/@value=concat('#', $contained/*/id/@value) or descendant::f:reference[@value='#'])]))",
            "source": "http://hl7.org/fhir/StructureDefinition/DomainResource"
          },
          {
            "key": "dom-4",
            "severity": "error",
            "human": "If a resource is contained in another resource, it SHALL NOT have a meta.versionId or a meta.lastUpdated",
            "expression": "contained.meta.versionId.empty() and contained.meta.lastUpdated.empty()",
            "xpath": "not(exists(f:contained/*/f:meta/f:versionId)) and not(exists(f:contained/*/f:meta/f:lastUpdated))",
            "source": "http://hl7.org/fhir/StructureDefinition/DomainResource"
          },
          {
            "key": "dom-5",
            "severity": "error",
            "human": "If a resource is contained in another resource, it SHALL NOT have a security label",
            "expression": "contained.meta.security.empty()",
            "xpath": "not(exists(f:contained/*/f:meta/f:security))",
            "source": "http://hl7.org/fhir/StructureDefinition/DomainResource"
          },
          {
            "extension": [
              {
                "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bestpractice",
                "valueBoolean": true
              },
              {
                "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bestpractice-explanation",
                "valueMarkdown": "When a resource has no narrative, only systems that fully understand the data can display the resource to a human safely. Including a human readable representation in the resource makes for a much more robust eco-system and cheaper handling of resources by intermediary systems. Some ecosystems restrict distribution of resources to only those systems that do fully understand the resources, and as a consequence implementers may believe that the narrative is superfluous. However experience shows that such eco-systems often open up to new participants over time."
              }
            ],
            "key": "dom-6",
            "severity": "warning",
            "human": "A resource should have narrative for robust management",
            "expression": "text.`div`.exists()",
            "xpath": "exists(f:text/h:div)",
            "source": "http://hl7.org/fhir/StructureDefinition/DomainResource"
          },
          {
            "key": "nexus-payment-detail-names-invoice",
            "severity": "error",
            "human": "Every detail SHALL name the invoice it settles by a billing-vendor invoice identifier",
            "expression": "detail.all(request.identifier.where(system = 'https://fhir.apps.health/NamingSystem/nexus-clinicaid-invoice-uuid' and value.exists()).exists())",
            "source": "https://fhir.apps.health/StructureDefinition/nexus-core-paymentreconciliation"
          },
          {
            "key": "nexus-payment-invoices-indexed",
            "severity": "error",
            "human": "Every invoice a detail names SHALL also appear in identifier under the same system, so a search by invoice finds the reconciliation",
            "expression": "detail.request.identifier.where(system = 'https://fhir.apps.health/NamingSystem/nexus-clinicaid-invoice-uuid').value.all($this in %resource.identifier.where(system = 'https://fhir.apps.health/NamingSystem/nexus-clinicaid-invoice-uuid').value)",
            "source": "https://fhir.apps.health/StructureDefinition/nexus-core-paymentreconciliation"
          },
          {
            "key": "nexus-payment-detail-kind",
            "severity": "error",
            "human": "Every detail SHALL be typed either payment (HL7 payment-type) or refund (Nexus payment-type)",
            "expression": "detail.all(type.coding.where((system = 'http://terminology.hl7.org/CodeSystem/payment-type' and code = 'payment') or (system = 'https://fhir.apps.health/CodeSystem/nexus-payment-type' and code = 'refund')).exists())",
            "source": "https://fhir.apps.health/StructureDefinition/nexus-core-paymentreconciliation"
          },
          {
            "key": "nexus-payment-one-direction",
            "severity": "error",
            "human": "A reconciliation SHALL be all payment or all refund, never a mix",
            "expression": "detail.where(type.coding.where(system = 'https://fhir.apps.health/CodeSystem/nexus-payment-type' and code = 'refund').exists()).empty() or detail.all(type.coding.where(system = 'https://fhir.apps.health/CodeSystem/nexus-payment-type' and code = 'refund').exists())",
            "source": "https://fhir.apps.health/StructureDefinition/nexus-core-paymentreconciliation"
          },
          {
            "key": "nexus-payment-amounts-positive",
            "severity": "error",
            "human": "paymentAmount and every detail amount SHALL be greater than zero; a refund is positive and typed refund",
            "expression": "paymentAmount.value > 0 and detail.all(amount.value > 0)",
            "source": "https://fhir.apps.health/StructureDefinition/nexus-core-paymentreconciliation"
          },
          {
            "key": "nexus-payment-reversal-has-reason",
            "severity": "error",
            "human": "A cancelled (reversed) reconciliation SHALL carry the payment-reason extension",
            "expression": "status = 'cancelled' implies extension('https://fhir.apps.health/StructureDefinition/nexus-payment-reason').exists()",
            "source": "https://fhir.apps.health/StructureDefinition/nexus-core-paymentreconciliation"
          },
          {
            "key": "nexus-payment-refund-has-reason",
            "severity": "error",
            "human": "A refund SHALL carry the payment-reason extension",
            "expression": "detail.type.coding.where(system = 'https://fhir.apps.health/CodeSystem/nexus-payment-type' and code = 'refund').exists() implies extension('https://fhir.apps.health/StructureDefinition/nexus-payment-reason').exists()",
            "source": "https://fhir.apps.health/StructureDefinition/nexus-core-paymentreconciliation"
          }
        ],
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "rim",
            "map": "Entity. Role, or Act"
          },
          {
            "identity": "workflow",
            "map": "Event"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.id",
        "path": "PaymentReconciliation.id",
        "short": "Logical id of this artifact",
        "definition": "The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.",
        "comment": "The only time that a resource does not have an id is when it is being submitted to the server using a create operation.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "Resource.id",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "http://hl7.org/fhirpath/System.String",
            "extension": [
              {
                "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type",
                "valueUrl": "string"
              }
            ]
          }
        ],
        "isModifier": false,
        "isSummary": true
      },
      {
        "id": "PaymentReconciliation.meta",
        "path": "PaymentReconciliation.meta",
        "short": "Metadata about the resource",
        "definition": "The metadata about the resource. This is content that is maintained by the infrastructure. Changes to the content might not always be associated with version changes to the resource.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "Resource.meta",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "Meta"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "isModifier": false,
        "isSummary": true
      },
      {
        "id": "PaymentReconciliation.implicitRules",
        "path": "PaymentReconciliation.implicitRules",
        "short": "A set of rules under which this content was created",
        "definition": "A reference to a set of rules that were followed when the resource was constructed, and which must be understood when processing the content. Often, this is a reference to an implementation guide that defines the special rules along with other profiles etc.",
        "comment": "Asserting this rule set restricts the content to be only understood by a limited set of trading partners. This inherently limits the usefulness of the data in the long term. However, the existing health eco-system is highly fractured, and not yet ready to define, collect, and exchange data in a generally computable sense. Wherever possible, implementers and/or specification writers should avoid using this element. Often, when used, the URL is a reference to an implementation guide that defines these special rules as part of it's narrative along with other profiles, value sets, etc.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "Resource.implicitRules",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "uri"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "isModifier": true,
        "isModifierReason": "This element is labeled as a modifier because the implicit rules may provide additional knowledge about the resource that modifies it's meaning or interpretation",
        "isSummary": true
      },
      {
        "id": "PaymentReconciliation.language",
        "path": "PaymentReconciliation.language",
        "short": "Language of the resource content",
        "definition": "The base language in which the resource is written.",
        "comment": "Language is provided to support indexing and accessibility (typically, services such as text to speech use the language tag). The html language tag in the narrative applies  to the narrative. The language tag on the resource may be used to specify the language of other presentations generated from the data in the resource. Not all the content has to be in the base language. The Resource.language should not be assumed to apply to the narrative automatically. If a language is specified, it should it also be specified on the div element in the html (see rules in HTML5 for information about the relationship between xml:lang and the html lang attribute).",
        "min": 0,
        "max": "1",
        "base": {
          "path": "Resource.language",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "code"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "isModifier": false,
        "isSummary": false,
        "binding": {
          "extension": [
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-maxValueSet",
              "valueCanonical": "http://hl7.org/fhir/ValueSet/all-languages"
            },
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
              "valueString": "Language"
            },
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-isCommonBinding",
              "valueBoolean": true
            }
          ],
          "strength": "preferred",
          "description": "A human language.",
          "valueSet": "http://hl7.org/fhir/ValueSet/languages"
        }
      },
      {
        "id": "PaymentReconciliation.text",
        "path": "PaymentReconciliation.text",
        "short": "Text summary of the resource, for human interpretation",
        "definition": "A human-readable narrative that contains a summary of the resource and can be used to represent the content of the resource to a human. The narrative need not encode all the structured data, but is required to contain sufficient detail to make it \"clinically safe\" for a human to just read the narrative. Resource definitions may define what content should be represented in the narrative to ensure clinical safety.",
        "comment": "Contained resources do not have narrative. Resources that are not contained SHOULD have a narrative. In some cases, a resource may only have text with little or no additional discrete data (as long as all minOccurs=1 elements are satisfied).  This may be necessary for data from legacy systems where information is captured as a \"text blob\" or where text is additionally entered raw or narrated and encoded information is added later.",
        "alias": [
          "narrative",
          "html",
          "xhtml",
          "display"
        ],
        "min": 0,
        "max": "1",
        "base": {
          "path": "DomainResource.text",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "Narrative"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "rim",
            "map": "Act.text?"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.contained",
        "path": "PaymentReconciliation.contained",
        "short": "Contained, inline Resources",
        "definition": "These resources do not have an independent existence apart from the resource that contains them - they cannot be identified independently, and nor can they have their own independent transaction scope.",
        "comment": "This should never be done when the content can be identified properly, as once identification is lost, it is extremely difficult (and context dependent) to restore it again. Contained resources may have profiles and tags In their meta elements, but SHALL NOT have security labels.",
        "alias": [
          "inline resources",
          "anonymous resources",
          "contained resources"
        ],
        "min": 0,
        "max": "*",
        "base": {
          "path": "DomainResource.contained",
          "min": 0,
          "max": "*"
        },
        "type": [
          {
            "code": "Resource"
          }
        ],
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "rim",
            "map": "N/A"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.extension",
        "path": "PaymentReconciliation.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "ordered": false,
          "rules": "open"
        },
        "short": "Additional content defined by implementations",
        "definition": "May be used to represent additional information that is not part of the basic definition of the resource. To make the use of extensions safe and manageable, there is a strict set of governance  applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.",
        "comment": "There can be no stigma associated with the use of extensions by any application, project, or standard - regardless of the institution or jurisdiction that uses or defines the extensions.  The use of extensions is what allows the FHIR specification to retain a core level of simplicity for everyone.",
        "alias": [
          "extensions",
          "user content"
        ],
        "min": 1,
        "max": "*",
        "base": {
          "path": "DomainResource.extension",
          "min": 0,
          "max": "*"
        },
        "type": [
          {
            "code": "Extension"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          },
          {
            "key": "ext-1",
            "severity": "error",
            "human": "Must have either extensions or value[x], not both",
            "expression": "extension.exists() != value.exists()",
            "xpath": "exists(f:extension)!=exists(f:*[starts-with(local-name(.), \"value\")])",
            "source": "http://hl7.org/fhir/StructureDefinition/Extension"
          }
        ],
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "rim",
            "map": "N/A"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.extension:method",
        "path": "PaymentReconciliation.extension",
        "sliceName": "method",
        "short": "How the money was paid: cash, debit, credit card, cheque, e-transfer, insurer EFT",
        "definition": "How the money changed hands. The R5 element `PaymentReconciliation.method`, carried as its published R4 cross-version extension.",
        "comment": "There can be no stigma associated with the use of extensions by any application, project, or standard - regardless of the institution or jurisdiction that uses or defines the extensions.  The use of extensions is what allows the FHIR specification to retain a core level of simplicity for everyone.",
        "alias": [
          "extensions",
          "user content"
        ],
        "min": 1,
        "max": "1",
        "base": {
          "path": "DomainResource.extension",
          "min": 0,
          "max": "*"
        },
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://hl7.org/fhir/5.0/StructureDefinition/extension-PaymentReconciliation.method"
            ]
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          },
          {
            "key": "ext-1",
            "severity": "error",
            "human": "Must have either extensions or value[x], not both",
            "expression": "extension.exists() != value.exists()",
            "xpath": "exists(f:extension)!=exists(f:*[starts-with(local-name(.), \"value\")])",
            "source": "http://hl7.org/fhir/StructureDefinition/Extension"
          }
        ],
        "mustSupport": true,
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "rim",
            "map": "N/A"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.extension:method.id",
        "path": "PaymentReconciliation.extension.id",
        "representation": [
          "xmlAttr"
        ],
        "short": "Unique id for inter-element referencing",
        "definition": "Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "Element.id",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "http://hl7.org/fhirpath/System.String",
            "extension": [
              {
                "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type",
                "valueUrl": "string"
              }
            ]
          }
        ],
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "rim",
            "map": "n/a"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.extension:method.extension",
        "path": "PaymentReconciliation.extension.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "description": "Extensions are always sliced by (at least) url",
          "rules": "open"
        },
        "short": "Additional content defined by implementations",
        "definition": "May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and manageable, there is a strict set of governance  applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.",
        "comment": "There can be no stigma associated with the use of extensions by any application, project, or standard - regardless of the institution or jurisdiction that uses or defines the extensions.  The use of extensions is what allows the FHIR specification to retain a core level of simplicity for everyone.",
        "alias": [
          "extensions",
          "user content"
        ],
        "min": 0,
        "max": "0",
        "base": {
          "path": "Element.extension",
          "min": 0,
          "max": "*"
        },
        "type": [
          {
            "code": "Extension"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element|4.0.1"
          },
          {
            "key": "ext-1",
            "severity": "error",
            "human": "Must have either extensions or value[x], not both",
            "expression": "extension.exists() != value.exists()",
            "xpath": "exists(f:extension)!=exists(f:*[starts-with(local-name(.), \"value\")])",
            "source": "http://hl7.org/fhir/StructureDefinition/Extension|4.0.1"
          }
        ],
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "rim",
            "map": "n/a"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.extension:method.url",
        "path": "PaymentReconciliation.extension.url",
        "representation": [
          "xmlAttr"
        ],
        "short": "identifies the meaning of the extension",
        "definition": "Source of the definition for the extension code - a logical name or a URL.",
        "comment": "The definition may point directly to a computable or human-readable definition of the extensibility codes, or it may be a logical URI as declared in some other specification. The definition SHALL be a URI for the Structure Definition defining the extension.",
        "min": 1,
        "max": "1",
        "base": {
          "path": "Extension.url",
          "min": 1,
          "max": "1"
        },
        "type": [
          {
            "code": "http://hl7.org/fhirpath/System.String",
            "extension": [
              {
                "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type",
                "valueUrl": "uri"
              }
            ]
          }
        ],
        "fixedUri": "http://hl7.org/fhir/5.0/StructureDefinition/extension-PaymentReconciliation.method",
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "rim",
            "map": "N/A"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.extension:method.value[x]",
        "path": "PaymentReconciliation.extension.value[x]",
        "short": "Payment instrument",
        "definition": "The means of payment such as check, card cash, or electronic funds transfer.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "Extension.value[x]",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "CodeableConcept"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element|4.0.1"
          }
        ],
        "isModifier": false,
        "isSummary": false,
        "binding": {
          "strength": "extensible",
          "valueSet": "https://fhir.apps.health/ValueSet/nexus-payment-method"
        },
        "mapping": [
          {
            "identity": "rim",
            "map": "N/A"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.extension:enterer",
        "path": "PaymentReconciliation.extension",
        "sliceName": "enterer",
        "short": "Who keyed the payment",
        "definition": "The person who recorded the payment or refund in the clinic's system. The R5 element `PaymentReconciliation.enterer`, carried as its published R4 cross-version extension. Absent only when the signed-in user cannot be named.",
        "comment": "Not `requestor`: in R4 that element is the practitioner responsible for the services being paid for, which is a different person from whoever took the money.",
        "alias": [
          "extensions",
          "user content"
        ],
        "min": 0,
        "max": "1",
        "base": {
          "path": "DomainResource.extension",
          "min": 0,
          "max": "*"
        },
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://hl7.org/fhir/5.0/StructureDefinition/extension-PaymentReconciliation.enterer"
            ]
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          },
          {
            "key": "ext-1",
            "severity": "error",
            "human": "Must have either extensions or value[x], not both",
            "expression": "extension.exists() != value.exists()",
            "xpath": "exists(f:extension)!=exists(f:*[starts-with(local-name(.), \"value\")])",
            "source": "http://hl7.org/fhir/StructureDefinition/Extension"
          }
        ],
        "mustSupport": true,
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "rim",
            "map": "N/A"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.extension:enterer.id",
        "path": "PaymentReconciliation.extension.id",
        "representation": [
          "xmlAttr"
        ],
        "short": "Unique id for inter-element referencing",
        "definition": "Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "Element.id",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "http://hl7.org/fhirpath/System.String",
            "extension": [
              {
                "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type",
                "valueUrl": "string"
              }
            ]
          }
        ],
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "rim",
            "map": "n/a"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.extension:enterer.extension",
        "path": "PaymentReconciliation.extension.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "description": "Extensions are always sliced by (at least) url",
          "rules": "open"
        },
        "short": "Additional content defined by implementations",
        "definition": "May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and manageable, there is a strict set of governance  applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.",
        "comment": "There can be no stigma associated with the use of extensions by any application, project, or standard - regardless of the institution or jurisdiction that uses or defines the extensions.  The use of extensions is what allows the FHIR specification to retain a core level of simplicity for everyone.",
        "alias": [
          "extensions",
          "user content"
        ],
        "min": 0,
        "max": "0",
        "base": {
          "path": "Element.extension",
          "min": 0,
          "max": "*"
        },
        "type": [
          {
            "code": "Extension"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element|4.0.1"
          },
          {
            "key": "ext-1",
            "severity": "error",
            "human": "Must have either extensions or value[x], not both",
            "expression": "extension.exists() != value.exists()",
            "xpath": "exists(f:extension)!=exists(f:*[starts-with(local-name(.), \"value\")])",
            "source": "http://hl7.org/fhir/StructureDefinition/Extension|4.0.1"
          }
        ],
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "rim",
            "map": "n/a"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.extension:enterer.url",
        "path": "PaymentReconciliation.extension.url",
        "representation": [
          "xmlAttr"
        ],
        "short": "identifies the meaning of the extension",
        "definition": "Source of the definition for the extension code - a logical name or a URL.",
        "comment": "The definition may point directly to a computable or human-readable definition of the extensibility codes, or it may be a logical URI as declared in some other specification. The definition SHALL be a URI for the Structure Definition defining the extension.",
        "min": 1,
        "max": "1",
        "base": {
          "path": "Extension.url",
          "min": 1,
          "max": "1"
        },
        "type": [
          {
            "code": "http://hl7.org/fhirpath/System.String",
            "extension": [
              {
                "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type",
                "valueUrl": "uri"
              }
            ]
          }
        ],
        "fixedUri": "http://hl7.org/fhir/5.0/StructureDefinition/extension-PaymentReconciliation.enterer",
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "rim",
            "map": "N/A"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.extension:enterer.value[x]",
        "path": "PaymentReconciliation.extension.value[x]",
        "short": "Who entered the payment",
        "definition": "Payment enterer if not the actual payment issuer.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "Extension.value[x]",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.apps.health/StructureDefinition/nexus-emr-core-practitioner",
              "https://fhir.apps.health/StructureDefinition/nexus-emr-core-practitionerrole"
            ]
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element|4.0.1"
          }
        ],
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "rim",
            "map": "N/A"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.extension:reason",
        "path": "PaymentReconciliation.extension",
        "sliceName": "reason",
        "short": "Why it was reversed or refunded",
        "definition": "Why this reconciliation was reversed, or why the refund was given. Required on a cancelled reconciliation and on every refund.",
        "comment": "There can be no stigma associated with the use of extensions by any application, project, or standard - regardless of the institution or jurisdiction that uses or defines the extensions.  The use of extensions is what allows the FHIR specification to retain a core level of simplicity for everyone.",
        "alias": [
          "extensions",
          "user content"
        ],
        "min": 0,
        "max": "1",
        "base": {
          "path": "DomainResource.extension",
          "min": 0,
          "max": "*"
        },
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://fhir.apps.health/StructureDefinition/nexus-payment-reason"
            ]
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          },
          {
            "key": "ext-1",
            "severity": "error",
            "human": "Must have either extensions or value[x], not both",
            "expression": "extension.exists() != value.exists()",
            "xpath": "exists(f:extension)!=exists(f:*[starts-with(local-name(.), \"value\")])",
            "source": "http://hl7.org/fhir/StructureDefinition/Extension"
          }
        ],
        "mustSupport": true,
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "rim",
            "map": "N/A"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.modifierExtension",
        "path": "PaymentReconciliation.modifierExtension",
        "short": "Extensions that cannot be ignored",
        "definition": "May be used to represent additional information that is not part of the basic definition of the resource and that modifies the understanding of the element that contains it and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer is allowed to define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.\n\nModifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself).",
        "comment": "There can be no stigma associated with the use of extensions by any application, project, or standard - regardless of the institution or jurisdiction that uses or defines the extensions.  The use of extensions is what allows the FHIR specification to retain a core level of simplicity for everyone.",
        "requirements": "Modifier extensions allow for extensions that *cannot* be safely ignored to be clearly distinguished from the vast majority of extensions which can be safely ignored.  This promotes interoperability by eliminating the need for implementers to prohibit the presence of extensions. For further information, see the [definition of modifier extensions](extensibility.html#modifierExtension).",
        "alias": [
          "extensions",
          "user content"
        ],
        "min": 0,
        "max": "*",
        "base": {
          "path": "DomainResource.modifierExtension",
          "min": 0,
          "max": "*"
        },
        "type": [
          {
            "code": "Extension"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          },
          {
            "key": "ext-1",
            "severity": "error",
            "human": "Must have either extensions or value[x], not both",
            "expression": "extension.exists() != value.exists()",
            "xpath": "exists(f:extension)!=exists(f:*[starts-with(local-name(.), \"value\")])",
            "source": "http://hl7.org/fhir/StructureDefinition/Extension"
          }
        ],
        "isModifier": true,
        "isModifierReason": "Modifier extensions are expected to modify the meaning or interpretation of the resource that contains them",
        "isSummary": false,
        "mapping": [
          {
            "identity": "rim",
            "map": "N/A"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.identifier",
        "path": "PaymentReconciliation.identifier",
        "short": "The invoices this reconciliation touches, for search",
        "definition": "One entry per invoice the reconciliation allocates money to, under\n`https://fhir.apps.health/NamingSystem/nexus-clinicaid-invoice-uuid`, repeating the identifiers on\n`detail.request`. It is the index: every reconciliation touching an invoice is found by one token\nsearch on `identifier`, and a reader does not depend on a server supporting the `:identifier`\nmodifier on `detail.request`.",
        "comment": "This repurposes the business identifier as an index rather than naming the reconciliation itself. Where a server advertises `detail.request:identifier`, that search is the better one, and the mirror may be retired in a later version.",
        "requirements": "Allows payment reconciliations to be distinguished and referenced.",
        "min": 1,
        "max": "*",
        "base": {
          "path": "PaymentReconciliation.identifier",
          "min": 0,
          "max": "*"
        },
        "type": [
          {
            "code": "Identifier"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "mustSupport": true,
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "workflow",
            "map": "Event.identifier"
          },
          {
            "identity": "w5",
            "map": "FiveWs.identifier"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.status",
        "path": "PaymentReconciliation.status",
        "short": "active | cancelled | draft | entered-in-error",
        "definition": "`active` counts toward a balance. `cancelled` is a reversal: the record stays, carrying its reason,\nand counts toward nothing. `entered-in-error` is a record that should never have existed and also\ncounts toward nothing. The clinic does not write `draft`.",
        "comment": "This element is labeled as a modifier because the status contains codes that mark the resource as not currently valid.",
        "requirements": "Need to track the status of the resource as 'draft' resources may undergo further edits while 'active' resources are immutable and may only have their status changed to 'cancelled'.",
        "min": 1,
        "max": "1",
        "base": {
          "path": "PaymentReconciliation.status",
          "min": 1,
          "max": "1"
        },
        "type": [
          {
            "code": "code"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "mustSupport": true,
        "isModifier": true,
        "isModifierReason": "This element is labelled as a modifier because it is a status element that contains status entered-in-error which means that the resource should not be treated as valid",
        "isSummary": true,
        "binding": {
          "extension": [
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
              "valueString": "PaymentReconciliationStatus"
            }
          ],
          "strength": "required",
          "description": "A code specifying the state of the resource instance.",
          "valueSet": "http://hl7.org/fhir/ValueSet/fm-status|4.0.1"
        },
        "mapping": [
          {
            "identity": "workflow",
            "map": "Event.status"
          },
          {
            "identity": "w5",
            "map": "FiveWs.status"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.period",
        "path": "PaymentReconciliation.period",
        "short": "Period covered",
        "definition": "The period of time for which payments have been gathered into this bulk payment for settlement.",
        "requirements": "Needed to allow receivers to monitor and reconcile payment issuer schedules.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "PaymentReconciliation.period",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "Period"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "isModifier": false,
        "isSummary": true,
        "mapping": [
          {
            "identity": "w5",
            "map": "FiveWs.done[x]"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.created",
        "path": "PaymentReconciliation.created",
        "short": "When the payment was keyed",
        "definition": "The instant the payment or refund was recorded. Distinct from `paymentDate`, the day the money changed hands.",
        "requirements": "Need to record a timestamp for use by both the recipient and the issuer.",
        "min": 1,
        "max": "1",
        "base": {
          "path": "PaymentReconciliation.created",
          "min": 1,
          "max": "1"
        },
        "type": [
          {
            "code": "dateTime"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "mustSupport": true,
        "isModifier": false,
        "isSummary": true,
        "mapping": [
          {
            "identity": "workflow",
            "map": "Event.occurrence[x]"
          },
          {
            "identity": "w5",
            "map": "FiveWs.recorded"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.paymentIssuer",
        "path": "PaymentReconciliation.paymentIssuer",
        "short": "Who paid",
        "definition": "The payer -- the patient, a family member, an employer or an insurer -- as the office named them. Usually a display only: a private payer is seldom a resource the clinic holds.",
        "comment": "This party is also responsible for the reconciliation.",
        "requirements": "Need to identify the party resonsible for the payment and this resource.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "PaymentReconciliation.paymentIssuer",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/StructureDefinition/Organization"
            ]
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "mustSupport": true,
        "isModifier": false,
        "isSummary": true,
        "mapping": [
          {
            "identity": "workflow",
            "map": "Event.performer.actor"
          },
          {
            "identity": "w5",
            "map": "FiveWs.source"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.request",
        "path": "PaymentReconciliation.request",
        "short": "Reference to requesting resource",
        "definition": "Original request resource reference.",
        "requirements": "Needed to allow the response to be linked to the request.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "PaymentReconciliation.request",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/StructureDefinition/Task"
            ]
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "w5",
            "map": "FiveWs.why[x]"
          },
          {
            "identity": "cdanetv4",
            "map": "A02|G01"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.requestor",
        "path": "PaymentReconciliation.requestor",
        "short": "Responsible practitioner",
        "definition": "The practitioner who is responsible for the services rendered to the patient.",
        "comment": "Not used by this profile. In R4 this is the practitioner responsible for the services being paid for; who keyed the payment is the `enterer` extension.",
        "requirements": "Need to identify the party responsible for the request.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "PaymentReconciliation.requestor",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/StructureDefinition/Practitioner",
              "http://hl7.org/fhir/StructureDefinition/PractitionerRole",
              "http://hl7.org/fhir/StructureDefinition/Organization"
            ]
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "cdanetv4",
            "map": "B01"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.outcome",
        "path": "PaymentReconciliation.outcome",
        "short": "queued | complete | error | partial",
        "definition": "The outcome of a request for a reconciliation.",
        "comment": "The resource may be used to indicate that: the request has been held (queued) for processing; that it has been processed and errors found (error); that no errors were found and that some of the adjudication has been undertaken (partial) or that all of the adjudication has been undertaken (complete).",
        "requirements": "To advise the requestor of an overall processing outcome.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "PaymentReconciliation.outcome",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "code"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "isModifier": false,
        "isSummary": false,
        "binding": {
          "extension": [
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
              "valueString": "RemittanceOutcome"
            },
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-isCommonBinding",
              "valueBoolean": true
            }
          ],
          "strength": "required",
          "description": "The outcome of the processing.",
          "valueSet": "http://hl7.org/fhir/ValueSet/remittance-outcome|4.0.1"
        }
      },
      {
        "id": "PaymentReconciliation.disposition",
        "path": "PaymentReconciliation.disposition",
        "short": "Disposition message",
        "definition": "A human readable description of the status of the request for the reconciliation.",
        "requirements": "Provided for user display.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "PaymentReconciliation.disposition",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "string"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "workflow",
            "map": "Event.note"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.paymentDate",
        "path": "PaymentReconciliation.paymentDate",
        "short": "The day the money changed hands",
        "definition": "The day the payer paid, or the day the refund was given. This is the effective date: receipts, day-end totals and ageing read it, never `created`.",
        "requirements": "To advise the payee when payment can be expected.",
        "min": 1,
        "max": "1",
        "base": {
          "path": "PaymentReconciliation.paymentDate",
          "min": 1,
          "max": "1"
        },
        "type": [
          {
            "code": "date"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "mustSupport": true,
        "isModifier": false,
        "isSummary": true
      },
      {
        "id": "PaymentReconciliation.paymentAmount",
        "path": "PaymentReconciliation.paymentAmount",
        "short": "The whole amount, always positive",
        "definition": "The whole sum handed over or returned: equal to the sum of the detail amounts. Always positive -- a refund is told apart by its detail type, not by its sign.",
        "requirements": "Needed to provide the actual payment amount.",
        "min": 1,
        "max": "1",
        "base": {
          "path": "PaymentReconciliation.paymentAmount",
          "min": 1,
          "max": "1"
        },
        "type": [
          {
            "code": "Money"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "mustSupport": true,
        "isModifier": false,
        "isSummary": true
      },
      {
        "id": "PaymentReconciliation.paymentAmount.id",
        "path": "PaymentReconciliation.paymentAmount.id",
        "representation": [
          "xmlAttr"
        ],
        "short": "Unique id for inter-element referencing",
        "definition": "Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "Element.id",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "http://hl7.org/fhirpath/System.String",
            "extension": [
              {
                "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type",
                "valueUrl": "string"
              }
            ]
          }
        ],
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "rim",
            "map": "n/a"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.paymentAmount.extension",
        "path": "PaymentReconciliation.paymentAmount.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "description": "Extensions are always sliced by (at least) url",
          "rules": "open"
        },
        "short": "Additional content defined by implementations",
        "definition": "May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and manageable, there is a strict set of governance  applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.",
        "comment": "There can be no stigma associated with the use of extensions by any application, project, or standard - regardless of the institution or jurisdiction that uses or defines the extensions.  The use of extensions is what allows the FHIR specification to retain a core level of simplicity for everyone.",
        "alias": [
          "extensions",
          "user content"
        ],
        "min": 0,
        "max": "*",
        "base": {
          "path": "Element.extension",
          "min": 0,
          "max": "*"
        },
        "type": [
          {
            "code": "Extension"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          },
          {
            "key": "ext-1",
            "severity": "error",
            "human": "Must have either extensions or value[x], not both",
            "expression": "extension.exists() != value.exists()",
            "xpath": "exists(f:extension)!=exists(f:*[starts-with(local-name(.), \"value\")])",
            "source": "http://hl7.org/fhir/StructureDefinition/Extension"
          }
        ],
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "rim",
            "map": "n/a"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.paymentAmount.value",
        "path": "PaymentReconciliation.paymentAmount.value",
        "short": "Numerical value (with implicit precision)",
        "definition": "Numerical value (with implicit precision).",
        "comment": "Monetary values have their own rules for handling precision (refer to standard accounting text books).",
        "requirements": "The amount of the currency. The value includes an implicit precision in the presentation of the value.",
        "min": 1,
        "max": "1",
        "base": {
          "path": "Money.value",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "decimal"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "isModifier": false,
        "isSummary": true,
        "mapping": [
          {
            "identity": "v2",
            "map": "MO.Value"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.paymentAmount.currency",
        "path": "PaymentReconciliation.paymentAmount.currency",
        "short": "ISO 4217 Currency Code",
        "definition": "ISO 4217 Currency Code.",
        "requirements": "A code indicating the currency, taken from ISO 4217.",
        "min": 1,
        "max": "1",
        "base": {
          "path": "Money.currency",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "code"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "mustSupport": true,
        "isModifier": false,
        "isSummary": true,
        "binding": {
          "extension": [
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
              "valueString": "CurrencyCode"
            },
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-isCommonBinding",
              "valueBoolean": true
            }
          ],
          "strength": "required",
          "description": "A code indicating the currency, taken from ISO 4217.",
          "valueSet": "http://hl7.org/fhir/ValueSet/currencies|4.0.1"
        },
        "mapping": [
          {
            "identity": "v2",
            "map": "MO.Currency"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.paymentIdentifier",
        "path": "PaymentReconciliation.paymentIdentifier",
        "short": "Cheque number, transaction or e-transfer reference",
        "definition": "The reference the payment instrument carried, when it carried one: a cheque number, a card terminal transaction number, an e-transfer reference.",
        "comment": "For example: EFT number or check number.",
        "requirements": "Enable the receiver to reconcile when payment is received.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "PaymentReconciliation.paymentIdentifier",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "Identifier"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "mustSupport": true,
        "isModifier": false,
        "isSummary": false
      },
      {
        "id": "PaymentReconciliation.detail",
        "path": "PaymentReconciliation.detail",
        "short": "One allocation per invoice",
        "definition": "Where the money lands: one entry per invoice, with the amount allocated to it. A payment split across invoices carries one entry for each.",
        "requirements": "Needed to show how the payment amount is distributed across the payables.",
        "min": 1,
        "max": "*",
        "base": {
          "path": "PaymentReconciliation.detail",
          "min": 0,
          "max": "*"
        },
        "type": [
          {
            "code": "BackboneElement"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "mustSupport": true,
        "isModifier": false,
        "isSummary": false
      },
      {
        "id": "PaymentReconciliation.detail.id",
        "path": "PaymentReconciliation.detail.id",
        "representation": [
          "xmlAttr"
        ],
        "short": "Unique id for inter-element referencing",
        "definition": "Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "Element.id",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "http://hl7.org/fhirpath/System.String",
            "extension": [
              {
                "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type",
                "valueUrl": "string"
              }
            ]
          }
        ],
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "rim",
            "map": "n/a"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.detail.extension",
        "path": "PaymentReconciliation.detail.extension",
        "short": "Additional content defined by implementations",
        "definition": "May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and manageable, there is a strict set of governance  applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.",
        "comment": "There can be no stigma associated with the use of extensions by any application, project, or standard - regardless of the institution or jurisdiction that uses or defines the extensions.  The use of extensions is what allows the FHIR specification to retain a core level of simplicity for everyone.",
        "alias": [
          "extensions",
          "user content"
        ],
        "min": 0,
        "max": "*",
        "base": {
          "path": "Element.extension",
          "min": 0,
          "max": "*"
        },
        "type": [
          {
            "code": "Extension"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          },
          {
            "key": "ext-1",
            "severity": "error",
            "human": "Must have either extensions or value[x], not both",
            "expression": "extension.exists() != value.exists()",
            "xpath": "exists(f:extension)!=exists(f:*[starts-with(local-name(.), \"value\")])",
            "source": "http://hl7.org/fhir/StructureDefinition/Extension"
          }
        ],
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "rim",
            "map": "n/a"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.detail.modifierExtension",
        "path": "PaymentReconciliation.detail.modifierExtension",
        "short": "Extensions that cannot be ignored even if unrecognized",
        "definition": "May be used to represent additional information that is not part of the basic definition of the element and that modifies the understanding of the element in which it is contained and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.\n\nModifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself).",
        "comment": "There can be no stigma associated with the use of extensions by any application, project, or standard - regardless of the institution or jurisdiction that uses or defines the extensions.  The use of extensions is what allows the FHIR specification to retain a core level of simplicity for everyone.",
        "requirements": "Modifier extensions allow for extensions that *cannot* be safely ignored to be clearly distinguished from the vast majority of extensions which can be safely ignored.  This promotes interoperability by eliminating the need for implementers to prohibit the presence of extensions. For further information, see the [definition of modifier extensions](extensibility.html#modifierExtension).",
        "alias": [
          "extensions",
          "user content",
          "modifiers"
        ],
        "min": 0,
        "max": "*",
        "base": {
          "path": "BackboneElement.modifierExtension",
          "min": 0,
          "max": "*"
        },
        "type": [
          {
            "code": "Extension"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          },
          {
            "key": "ext-1",
            "severity": "error",
            "human": "Must have either extensions or value[x], not both",
            "expression": "extension.exists() != value.exists()",
            "xpath": "exists(f:extension)!=exists(f:*[starts-with(local-name(.), \"value\")])",
            "source": "http://hl7.org/fhir/StructureDefinition/Extension"
          }
        ],
        "isModifier": true,
        "isModifierReason": "Modifier extensions are expected to modify the meaning or interpretation of the element that contains them",
        "isSummary": true,
        "mapping": [
          {
            "identity": "rim",
            "map": "N/A"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.detail.identifier",
        "path": "PaymentReconciliation.detail.identifier",
        "short": "Business identifier of the payment detail",
        "definition": "Unique identifier for the current payment item for the referenced payable.",
        "requirements": "Needed for reconciliation of payments.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "PaymentReconciliation.detail.identifier",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "Identifier"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "isModifier": false,
        "isSummary": false
      },
      {
        "id": "PaymentReconciliation.detail.predecessor",
        "path": "PaymentReconciliation.detail.predecessor",
        "short": "Business identifier of the prior payment detail",
        "definition": "Unique identifier for the prior payment item for the referenced payable.",
        "requirements": "Needed for reconciliation of payments.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "PaymentReconciliation.detail.predecessor",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "Identifier"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "isModifier": false,
        "isSummary": false
      },
      {
        "id": "PaymentReconciliation.detail.type",
        "path": "PaymentReconciliation.detail.type",
        "short": "payment | refund",
        "definition": "Whether this allocation is money in (`http://terminology.hl7.org/CodeSystem/payment-type#payment`) or money back (`https://fhir.apps.health/CodeSystem/nexus-payment-type#refund`). Every detail in one reconciliation carries the same type.",
        "comment": "For example: payment, adjustment, funds advance, etc.",
        "requirements": "Needed to provide context for the amount.",
        "min": 1,
        "max": "1",
        "base": {
          "path": "PaymentReconciliation.detail.type",
          "min": 1,
          "max": "1"
        },
        "type": [
          {
            "code": "CodeableConcept"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "mustSupport": true,
        "isModifier": false,
        "isSummary": false,
        "binding": {
          "extension": [
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
              "valueString": "PaymentType"
            }
          ],
          "strength": "example",
          "description": "The reason for the amount: payment, adjustment, advance.",
          "valueSet": "http://hl7.org/fhir/ValueSet/payment-type"
        }
      },
      {
        "id": "PaymentReconciliation.detail.request",
        "path": "PaymentReconciliation.detail.request",
        "short": "The invoice, by its billing-vendor identifier",
        "definition": "The invoice this allocation settles, as a logical reference carrying the billing vendor's invoice identifier under `https://fhir.apps.health/NamingSystem/nexus-clinicaid-invoice-uuid`. The invoice itself is held by the vendor, not by this server.",
        "requirements": "Needed to provide a linkage  to the original request.",
        "min": 1,
        "max": "1",
        "base": {
          "path": "PaymentReconciliation.detail.request",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/StructureDefinition/Resource"
            ]
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "mustSupport": true,
        "isModifier": false,
        "isSummary": false
      },
      {
        "id": "PaymentReconciliation.detail.submitter",
        "path": "PaymentReconciliation.detail.submitter",
        "short": "Submitter of the request",
        "definition": "The party which submitted the claim or financial transaction.",
        "requirements": "Needed for audit and validation.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "PaymentReconciliation.detail.submitter",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/StructureDefinition/Practitioner",
              "http://hl7.org/fhir/StructureDefinition/PractitionerRole",
              "http://hl7.org/fhir/StructureDefinition/Organization"
            ]
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "isModifier": false,
        "isSummary": false
      },
      {
        "id": "PaymentReconciliation.detail.response",
        "path": "PaymentReconciliation.detail.response",
        "short": "Response committing to a payment",
        "definition": "A resource, such as a ClaimResponse, which contains a commitment to payment.",
        "requirements": "Needed to provide a linkage to the payment commitment.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "PaymentReconciliation.detail.response",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/StructureDefinition/Resource"
            ]
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "isModifier": false,
        "isSummary": false
      },
      {
        "id": "PaymentReconciliation.detail.date",
        "path": "PaymentReconciliation.detail.date",
        "short": "The day the money changed hands",
        "definition": "The date from the response resource containing a commitment to pay.",
        "requirements": "Needed for audit and validation.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "PaymentReconciliation.detail.date",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "date"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "mustSupport": true,
        "isModifier": false,
        "isSummary": false
      },
      {
        "id": "PaymentReconciliation.detail.responsible",
        "path": "PaymentReconciliation.detail.responsible",
        "short": "Contact for the response",
        "definition": "A reference to the individual who is responsible for inquiries regarding the response and its payment.",
        "requirements": "To provide contact information.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "PaymentReconciliation.detail.responsible",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/StructureDefinition/PractitionerRole"
            ]
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "isModifier": false,
        "isSummary": false
      },
      {
        "id": "PaymentReconciliation.detail.payee",
        "path": "PaymentReconciliation.detail.payee",
        "short": "Recipient of the payment",
        "definition": "The party which is receiving the payment.",
        "requirements": "Needed for audit and validation.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "PaymentReconciliation.detail.payee",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/StructureDefinition/Practitioner",
              "http://hl7.org/fhir/StructureDefinition/PractitionerRole",
              "http://hl7.org/fhir/StructureDefinition/Organization"
            ]
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "isModifier": false,
        "isSummary": false
      },
      {
        "id": "PaymentReconciliation.detail.amount",
        "path": "PaymentReconciliation.detail.amount",
        "short": "The amount allocated to this invoice, always positive",
        "definition": "The monetary amount allocated from the total payment to the payable.",
        "requirements": "Needed to explain the distribution of the payment to the payables.",
        "min": 1,
        "max": "1",
        "base": {
          "path": "PaymentReconciliation.detail.amount",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "Money"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "mustSupport": true,
        "isModifier": false,
        "isSummary": false
      },
      {
        "id": "PaymentReconciliation.formCode",
        "path": "PaymentReconciliation.formCode",
        "short": "Printed form identifier",
        "definition": "A code for the form to be used for printing the content.",
        "comment": "May be needed to identify specific jurisdictional forms.",
        "requirements": "Needed to specify the specific form used for producing output for this response.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "PaymentReconciliation.formCode",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "CodeableConcept"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "isModifier": false,
        "isSummary": false,
        "binding": {
          "extension": [
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
              "valueString": "Forms"
            },
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-isCommonBinding",
              "valueBoolean": true
            }
          ],
          "strength": "example",
          "description": "The forms codes.",
          "valueSet": "http://hl7.org/fhir/ValueSet/forms"
        }
      },
      {
        "id": "PaymentReconciliation.processNote",
        "path": "PaymentReconciliation.processNote",
        "short": "The office's note on the payment",
        "definition": "Free text the office recorded with the payment. This element, not an extension, is the home for a note on this resource.",
        "requirements": "Provides the specific textual explanations associated with the processing.",
        "min": 0,
        "max": "*",
        "base": {
          "path": "PaymentReconciliation.processNote",
          "min": 0,
          "max": "*"
        },
        "type": [
          {
            "code": "BackboneElement"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "mustSupport": true,
        "isModifier": false,
        "isSummary": false
      },
      {
        "id": "PaymentReconciliation.processNote.id",
        "path": "PaymentReconciliation.processNote.id",
        "representation": [
          "xmlAttr"
        ],
        "short": "Unique id for inter-element referencing",
        "definition": "Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "Element.id",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "http://hl7.org/fhirpath/System.String",
            "extension": [
              {
                "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type",
                "valueUrl": "string"
              }
            ]
          }
        ],
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "rim",
            "map": "n/a"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.processNote.extension",
        "path": "PaymentReconciliation.processNote.extension",
        "short": "Additional content defined by implementations",
        "definition": "May be used to represent additional information that is not part of the basic definition of the element. To make the use of extensions safe and manageable, there is a strict set of governance  applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension.",
        "comment": "There can be no stigma associated with the use of extensions by any application, project, or standard - regardless of the institution or jurisdiction that uses or defines the extensions.  The use of extensions is what allows the FHIR specification to retain a core level of simplicity for everyone.",
        "alias": [
          "extensions",
          "user content"
        ],
        "min": 0,
        "max": "*",
        "base": {
          "path": "Element.extension",
          "min": 0,
          "max": "*"
        },
        "type": [
          {
            "code": "Extension"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          },
          {
            "key": "ext-1",
            "severity": "error",
            "human": "Must have either extensions or value[x], not both",
            "expression": "extension.exists() != value.exists()",
            "xpath": "exists(f:extension)!=exists(f:*[starts-with(local-name(.), \"value\")])",
            "source": "http://hl7.org/fhir/StructureDefinition/Extension"
          }
        ],
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "rim",
            "map": "n/a"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.processNote.modifierExtension",
        "path": "PaymentReconciliation.processNote.modifierExtension",
        "short": "Extensions that cannot be ignored even if unrecognized",
        "definition": "May be used to represent additional information that is not part of the basic definition of the element and that modifies the understanding of the element in which it is contained and/or the understanding of the containing element's descendants. Usually modifier elements provide negation or qualification. To make the use of extensions safe and manageable, there is a strict set of governance applied to the definition and use of extensions. Though any implementer can define an extension, there is a set of requirements that SHALL be met as part of the definition of the extension. Applications processing a resource are required to check for modifier extensions.\n\nModifier extensions SHALL NOT change the meaning of any elements on Resource or DomainResource (including cannot change the meaning of modifierExtension itself).",
        "comment": "There can be no stigma associated with the use of extensions by any application, project, or standard - regardless of the institution or jurisdiction that uses or defines the extensions.  The use of extensions is what allows the FHIR specification to retain a core level of simplicity for everyone.",
        "requirements": "Modifier extensions allow for extensions that *cannot* be safely ignored to be clearly distinguished from the vast majority of extensions which can be safely ignored.  This promotes interoperability by eliminating the need for implementers to prohibit the presence of extensions. For further information, see the [definition of modifier extensions](extensibility.html#modifierExtension).",
        "alias": [
          "extensions",
          "user content",
          "modifiers"
        ],
        "min": 0,
        "max": "*",
        "base": {
          "path": "BackboneElement.modifierExtension",
          "min": 0,
          "max": "*"
        },
        "type": [
          {
            "code": "Extension"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          },
          {
            "key": "ext-1",
            "severity": "error",
            "human": "Must have either extensions or value[x], not both",
            "expression": "extension.exists() != value.exists()",
            "xpath": "exists(f:extension)!=exists(f:*[starts-with(local-name(.), \"value\")])",
            "source": "http://hl7.org/fhir/StructureDefinition/Extension"
          }
        ],
        "isModifier": true,
        "isModifierReason": "Modifier extensions are expected to modify the meaning or interpretation of the element that contains them",
        "isSummary": true,
        "mapping": [
          {
            "identity": "rim",
            "map": "N/A"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.processNote.type",
        "path": "PaymentReconciliation.processNote.type",
        "short": "display | print | printoper",
        "definition": "The business purpose of the note text.",
        "requirements": "To convey the expectation for when the text is used.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "PaymentReconciliation.processNote.type",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "code"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "isModifier": false,
        "isSummary": false,
        "binding": {
          "extension": [
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
              "valueString": "NoteType"
            },
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-isCommonBinding",
              "valueBoolean": true
            }
          ],
          "strength": "required",
          "description": "The presentation types of notes.",
          "valueSet": "http://hl7.org/fhir/ValueSet/note-type|4.0.1"
        }
      },
      {
        "id": "PaymentReconciliation.processNote.text",
        "path": "PaymentReconciliation.processNote.text",
        "short": "Note explanatory text",
        "definition": "The explanation or description associated with the processing.",
        "requirements": "Required to provide human readable explanation.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "PaymentReconciliation.processNote.text",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "string"
          }
        ],
        "constraint": [
          {
            "key": "ele-1",
            "severity": "error",
            "human": "All FHIR elements must have a @value or children",
            "expression": "hasValue() or (children().count() > id.count())",
            "xpath": "@value|f:*|h:div",
            "source": "http://hl7.org/fhir/StructureDefinition/Element"
          }
        ],
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "cdanetv4",
            "map": "G32"
          }
        ]
      }
    ]
  },
  "differential": {
    "element": [
      {
        "id": "PaymentReconciliation",
        "path": "PaymentReconciliation",
        "short": "Nexus EMR payment or refund against billing-vendor invoices",
        "definition": "One payment or one refund taken at the clinic, allocated across one or more invoices raised at the\nbilling vendor. The billing vendor cannot record payments, so this is the clinic's ledger of them;\nan invoice's balance is its total less the active payments allocated to it plus the active refunds\nallocated to it.",
        "comment": "R4 `PaymentReconciliation` was designed for an insurer remitting to a provider. This profile uses\nit the other way round -- money taken from a patient or a third party at the clinic -- because it\nis the R4 resource whose elements fit: a payment with a date, an amount, an issuer, a reference\nnumber and per-invoice allocations. R5 widened the resource to cover exactly this case, and the\ntwo R5 elements this profile needs (`method`, `enterer`) are carried as R5 cross-version\nextensions.",
        "constraint": [
          {
            "key": "nexus-payment-detail-names-invoice",
            "severity": "error",
            "human": "Every detail SHALL name the invoice it settles by a billing-vendor invoice identifier",
            "expression": "detail.all(request.identifier.where(system = 'https://fhir.apps.health/NamingSystem/nexus-clinicaid-invoice-uuid' and value.exists()).exists())",
            "source": "https://fhir.apps.health/StructureDefinition/nexus-core-paymentreconciliation"
          },
          {
            "key": "nexus-payment-invoices-indexed",
            "severity": "error",
            "human": "Every invoice a detail names SHALL also appear in identifier under the same system, so a search by invoice finds the reconciliation",
            "expression": "detail.request.identifier.where(system = 'https://fhir.apps.health/NamingSystem/nexus-clinicaid-invoice-uuid').value.all($this in %resource.identifier.where(system = 'https://fhir.apps.health/NamingSystem/nexus-clinicaid-invoice-uuid').value)",
            "source": "https://fhir.apps.health/StructureDefinition/nexus-core-paymentreconciliation"
          },
          {
            "key": "nexus-payment-detail-kind",
            "severity": "error",
            "human": "Every detail SHALL be typed either payment (HL7 payment-type) or refund (Nexus payment-type)",
            "expression": "detail.all(type.coding.where((system = 'http://terminology.hl7.org/CodeSystem/payment-type' and code = 'payment') or (system = 'https://fhir.apps.health/CodeSystem/nexus-payment-type' and code = 'refund')).exists())",
            "source": "https://fhir.apps.health/StructureDefinition/nexus-core-paymentreconciliation"
          },
          {
            "key": "nexus-payment-one-direction",
            "severity": "error",
            "human": "A reconciliation SHALL be all payment or all refund, never a mix",
            "expression": "detail.where(type.coding.where(system = 'https://fhir.apps.health/CodeSystem/nexus-payment-type' and code = 'refund').exists()).empty() or detail.all(type.coding.where(system = 'https://fhir.apps.health/CodeSystem/nexus-payment-type' and code = 'refund').exists())",
            "source": "https://fhir.apps.health/StructureDefinition/nexus-core-paymentreconciliation"
          },
          {
            "key": "nexus-payment-amounts-positive",
            "severity": "error",
            "human": "paymentAmount and every detail amount SHALL be greater than zero; a refund is positive and typed refund",
            "expression": "paymentAmount.value > 0 and detail.all(amount.value > 0)",
            "source": "https://fhir.apps.health/StructureDefinition/nexus-core-paymentreconciliation"
          },
          {
            "key": "nexus-payment-reversal-has-reason",
            "severity": "error",
            "human": "A cancelled (reversed) reconciliation SHALL carry the payment-reason extension",
            "expression": "status = 'cancelled' implies extension('https://fhir.apps.health/StructureDefinition/nexus-payment-reason').exists()",
            "source": "https://fhir.apps.health/StructureDefinition/nexus-core-paymentreconciliation"
          },
          {
            "key": "nexus-payment-refund-has-reason",
            "severity": "error",
            "human": "A refund SHALL carry the payment-reason extension",
            "expression": "detail.type.coding.where(system = 'https://fhir.apps.health/CodeSystem/nexus-payment-type' and code = 'refund').exists() implies extension('https://fhir.apps.health/StructureDefinition/nexus-payment-reason').exists()",
            "source": "https://fhir.apps.health/StructureDefinition/nexus-core-paymentreconciliation"
          }
        ]
      },
      {
        "id": "PaymentReconciliation.extension",
        "path": "PaymentReconciliation.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "ordered": false,
          "rules": "open"
        },
        "min": 1
      },
      {
        "id": "PaymentReconciliation.extension:method",
        "path": "PaymentReconciliation.extension",
        "sliceName": "method",
        "short": "How the money was paid: cash, debit, credit card, cheque, e-transfer, insurer EFT",
        "definition": "How the money changed hands. The R5 element `PaymentReconciliation.method`, carried as its published R4 cross-version extension.",
        "min": 1,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://hl7.org/fhir/5.0/StructureDefinition/extension-PaymentReconciliation.method"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "PaymentReconciliation.extension:method.extension",
        "path": "PaymentReconciliation.extension.extension",
        "max": "0"
      },
      {
        "id": "PaymentReconciliation.extension:method.value[x]",
        "path": "PaymentReconciliation.extension.value[x]",
        "binding": {
          "strength": "extensible",
          "valueSet": "https://fhir.apps.health/ValueSet/nexus-payment-method"
        }
      },
      {
        "id": "PaymentReconciliation.extension:enterer",
        "path": "PaymentReconciliation.extension",
        "sliceName": "enterer",
        "short": "Who keyed the payment",
        "definition": "The person who recorded the payment or refund in the clinic's system. The R5 element `PaymentReconciliation.enterer`, carried as its published R4 cross-version extension. Absent only when the signed-in user cannot be named.",
        "comment": "Not `requestor`: in R4 that element is the practitioner responsible for the services being paid for, which is a different person from whoever took the money.",
        "min": 0,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://hl7.org/fhir/5.0/StructureDefinition/extension-PaymentReconciliation.enterer"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "PaymentReconciliation.extension:enterer.extension",
        "path": "PaymentReconciliation.extension.extension",
        "max": "0"
      },
      {
        "id": "PaymentReconciliation.extension:enterer.value[x]",
        "path": "PaymentReconciliation.extension.value[x]",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.apps.health/StructureDefinition/nexus-emr-core-practitioner",
              "https://fhir.apps.health/StructureDefinition/nexus-emr-core-practitionerrole"
            ]
          }
        ]
      },
      {
        "id": "PaymentReconciliation.extension:reason",
        "path": "PaymentReconciliation.extension",
        "sliceName": "reason",
        "short": "Why it was reversed or refunded",
        "definition": "Why this reconciliation was reversed, or why the refund was given. Required on a cancelled reconciliation and on every refund.",
        "min": 0,
        "max": "1",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://fhir.apps.health/StructureDefinition/nexus-payment-reason"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "PaymentReconciliation.identifier",
        "path": "PaymentReconciliation.identifier",
        "short": "The invoices this reconciliation touches, for search",
        "definition": "One entry per invoice the reconciliation allocates money to, under\n`https://fhir.apps.health/NamingSystem/nexus-clinicaid-invoice-uuid`, repeating the identifiers on\n`detail.request`. It is the index: every reconciliation touching an invoice is found by one token\nsearch on `identifier`, and a reader does not depend on a server supporting the `:identifier`\nmodifier on `detail.request`.",
        "comment": "This repurposes the business identifier as an index rather than naming the reconciliation itself. Where a server advertises `detail.request:identifier`, that search is the better one, and the mirror may be retired in a later version.",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "PaymentReconciliation.status",
        "path": "PaymentReconciliation.status",
        "definition": "`active` counts toward a balance. `cancelled` is a reversal: the record stays, carrying its reason,\nand counts toward nothing. `entered-in-error` is a record that should never have existed and also\ncounts toward nothing. The clinic does not write `draft`.",
        "mustSupport": true
      },
      {
        "id": "PaymentReconciliation.created",
        "path": "PaymentReconciliation.created",
        "short": "When the payment was keyed",
        "definition": "The instant the payment or refund was recorded. Distinct from `paymentDate`, the day the money changed hands.",
        "mustSupport": true
      },
      {
        "id": "PaymentReconciliation.paymentIssuer",
        "path": "PaymentReconciliation.paymentIssuer",
        "short": "Who paid",
        "definition": "The payer -- the patient, a family member, an employer or an insurer -- as the office named them. Usually a display only: a private payer is seldom a resource the clinic holds.",
        "mustSupport": true
      },
      {
        "id": "PaymentReconciliation.requestor",
        "path": "PaymentReconciliation.requestor",
        "comment": "Not used by this profile. In R4 this is the practitioner responsible for the services being paid for; who keyed the payment is the `enterer` extension."
      },
      {
        "id": "PaymentReconciliation.paymentDate",
        "path": "PaymentReconciliation.paymentDate",
        "short": "The day the money changed hands",
        "definition": "The day the payer paid, or the day the refund was given. This is the effective date: receipts, day-end totals and ageing read it, never `created`.",
        "mustSupport": true
      },
      {
        "id": "PaymentReconciliation.paymentAmount",
        "path": "PaymentReconciliation.paymentAmount",
        "short": "The whole amount, always positive",
        "definition": "The whole sum handed over or returned: equal to the sum of the detail amounts. Always positive -- a refund is told apart by its detail type, not by its sign.",
        "mustSupport": true
      },
      {
        "id": "PaymentReconciliation.paymentAmount.value",
        "path": "PaymentReconciliation.paymentAmount.value",
        "min": 1
      },
      {
        "id": "PaymentReconciliation.paymentAmount.currency",
        "path": "PaymentReconciliation.paymentAmount.currency",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "PaymentReconciliation.paymentIdentifier",
        "path": "PaymentReconciliation.paymentIdentifier",
        "short": "Cheque number, transaction or e-transfer reference",
        "definition": "The reference the payment instrument carried, when it carried one: a cheque number, a card terminal transaction number, an e-transfer reference.",
        "mustSupport": true
      },
      {
        "id": "PaymentReconciliation.detail",
        "path": "PaymentReconciliation.detail",
        "short": "One allocation per invoice",
        "definition": "Where the money lands: one entry per invoice, with the amount allocated to it. A payment split across invoices carries one entry for each.",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "PaymentReconciliation.detail.type",
        "path": "PaymentReconciliation.detail.type",
        "short": "payment | refund",
        "definition": "Whether this allocation is money in (`http://terminology.hl7.org/CodeSystem/payment-type#payment`) or money back (`https://fhir.apps.health/CodeSystem/nexus-payment-type#refund`). Every detail in one reconciliation carries the same type.",
        "mustSupport": true
      },
      {
        "id": "PaymentReconciliation.detail.request",
        "path": "PaymentReconciliation.detail.request",
        "short": "The invoice, by its billing-vendor identifier",
        "definition": "The invoice this allocation settles, as a logical reference carrying the billing vendor's invoice identifier under `https://fhir.apps.health/NamingSystem/nexus-clinicaid-invoice-uuid`. The invoice itself is held by the vendor, not by this server.",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "PaymentReconciliation.detail.date",
        "path": "PaymentReconciliation.detail.date",
        "short": "The day the money changed hands",
        "mustSupport": true
      },
      {
        "id": "PaymentReconciliation.detail.amount",
        "path": "PaymentReconciliation.detail.amount",
        "short": "The amount allocated to this invoice, always positive",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "PaymentReconciliation.processNote",
        "path": "PaymentReconciliation.processNote",
        "short": "The office's note on the payment",
        "definition": "Free text the office recorded with the payment. This element, not an extension, is the home for a note on this resource.",
        "mustSupport": true
      }
    ]
  }
}
