{
  "resourceType": "StructureDefinition",
  "id": "nexus-emr-core-provenance",
  "extension": [
    {
      "url": "https://fhir.apps.health/StructureDefinition/effective-date",
      "extension": [
        {
          "url": "paths",
          "valueString": "occurredDateTime | occurredPeriod.start | recorded"
        }
      ]
    },
    {
      "url": "https://fhir.apps.health/StructureDefinition/salient-field",
      "extension": [
        {
          "url": "key",
          "valueCode": "activity"
        },
        {
          "url": "expression",
          "valueString": "activity"
        },
        {
          "url": "type",
          "valueCode": "coded"
        }
      ]
    },
    {
      "url": "https://fhir.apps.health/StructureDefinition/salient-field",
      "extension": [
        {
          "url": "key",
          "valueCode": "date"
        },
        {
          "url": "expression",
          "valueString": "occurredDateTime | occurredPeriod.start | recorded"
        },
        {
          "url": "type",
          "valueCode": "dateTime"
        }
      ]
    },
    {
      "url": "https://fhir.apps.health/StructureDefinition/smart-exposed",
      "extension": [
        {
          "url": "read",
          "valueString": "provenance:read"
        },
        {
          "url": "write",
          "valueString": "provenance:write"
        }
      ]
    }
  ],
  "url": "https://fhir.apps.health/StructureDefinition/nexus-emr-core-provenance",
  "name": "NexusEmrCoreProvenance",
  "title": "Provenance Profile",
  "status": "draft",
  "experimental": false,
  "description": "Attribution for AI-mediated and cross-boundary writes: what was produced, when, by which agent (human or non-human), from what inputs, and -- for generated text -- which verbatim source passage each statement rests on. Used standalone against a produced resource, and contained in an AI-suggestion review Task against the suggestion contained alongside it.",
  "fhirVersion": "4.0.1",
  "mapping": [
    {
      "identity": "workflow",
      "uri": "http://hl7.org/fhir/workflow",
      "name": "Workflow Pattern"
    },
    {
      "identity": "rim",
      "uri": "http://hl7.org/v3",
      "name": "RIM Mapping"
    },
    {
      "identity": "w3c.prov",
      "uri": "http://www.w3.org/ns/prov",
      "name": "W3C PROV"
    },
    {
      "identity": "w5",
      "uri": "http://hl7.org/fhir/fivews",
      "name": "FiveWs Pattern Mapping"
    },
    {
      "identity": "fhirauditevent",
      "uri": "http://hl7.org/fhir/auditevent",
      "name": "FHIR AuditEvent Mapping"
    }
  ],
  "kind": "resource",
  "abstract": false,
  "type": "Provenance",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Provenance",
  "derivation": "constraint",
  "snapshot": {
    "element": [
      {
        "id": "Provenance",
        "path": "Provenance",
        "short": "Nexus EMR Provenance Core",
        "definition": "A record of what produced or changed a resource: the activity, when it was recorded, the\nagents responsible (which may include a non-human agent), and the inputs it derived from.\n\nPrimary intended use is AI-action attribution -- keeping an AI-produced resource traceable to\nthe agent that produced it, the human who accepted it, and the record context it was generated\nfrom. Where the product is generated text, the `attributedFact` extension carries the trail at\nstatement grain: each statement with the verbatim quote(s) backing it.",
        "comment": "Some parties may be duplicated between the target resource and its provenance.  For instance, the prescriber is usually (but not always) the author of the prescription resource. This resource is defined with close consideration for W3C Provenance.",
        "alias": [
          "History",
          "Event",
          "Activity"
        ],
        "min": 0,
        "max": "*",
        "base": {
          "path": "Provenance",
          "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": "provenance-target-required",
            "severity": "error",
            "human": "Provenance.target must name at least one resource -- a provenance with no target is unattributable",
            "expression": "target.exists()",
            "source": "https://fhir.apps.health/StructureDefinition/nexus-emr-core-provenance"
          },
          {
            "key": "provenance-ai-action-names-agent",
            "severity": "warning",
            "human": "A Provenance that carries attributed facts SHOULD name the non-human agent that generated them (agent.who typed or referenced as Device), in addition to any supervising human -- otherwise the trail cannot distinguish generated content from human-authored content",
            "expression": "extension.where(url = 'https://fhir.apps.health/StructureDefinition/nexus-attributed-fact').exists() implies agent.where(who.type = 'Device' or who.reference.startsWith('Device/')).exists()",
            "source": "https://fhir.apps.health/StructureDefinition/nexus-emr-core-provenance"
          }
        ],
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "rim",
            "map": "Entity. Role, or Act"
          },
          {
            "identity": "workflow",
            "map": "Event"
          },
          {
            "identity": "rim",
            "map": "ControlAct[isNormalAct() and subsumes(CACT, classCode) and moodCode=EVN]"
          },
          {
            "identity": "w3c.prov",
            "map": "Activity"
          }
        ]
      },
      {
        "id": "Provenance.id",
        "path": "Provenance.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": "Provenance.meta",
        "path": "Provenance.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": "Provenance.meta.id",
        "path": "Provenance.meta.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": "Provenance.meta.extension",
        "path": "Provenance.meta.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": "Provenance.meta.versionId",
        "path": "Provenance.meta.versionId",
        "short": "Version specific identifier",
        "definition": "The version specific identifier, as it appears in the version portion of the URL. This value changes when the resource is created, updated, or deleted.",
        "comment": "The server assigns this value, and ignores what the client specifies, except in the case that the server is imposing version integrity on updates/deletes.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "Meta.versionId",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "id"
          }
        ],
        "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": "Provenance.meta.lastUpdated",
        "path": "Provenance.meta.lastUpdated",
        "short": "When the resource version last changed",
        "definition": "When the resource last changed - e.g. when the version changed.",
        "comment": "This value is always populated except when the resource is first being created. The server / resource manager sets this value; what a client provides is irrelevant. This is equivalent to the HTTP Last-Modified and SHOULD have the same value on a [read](http.html#read) interaction.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "Meta.lastUpdated",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "instant"
          }
        ],
        "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": "Provenance.meta.source",
        "path": "Provenance.meta.source",
        "short": "Identifies EMR instance & pipeline version the resource came from",
        "definition": "A URI that identifies the EMR pipeline and version from which this resource originated.  This tells you which EMR instance (recommend using the instance identifier), and the version of the pipeline code/transformations.",
        "comment": "In the provenance resource, this corresponds to Provenance.entity.what[x]. The exact use of the source (and the implied Provenance.entity.role) is left to implementer discretion. Only one nominated source is allowed; for additional provenance details, a full Provenance resource should be used. \n\nThis element can be used to indicate where the current master source of a resource that has a canonical URL if the resource is no longer hosted at the canonical URL.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "Meta.source",
          "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"
          }
        ],
        "mustSupport": true,
        "isModifier": false,
        "isSummary": true
      },
      {
        "id": "Provenance.meta.profile",
        "path": "Provenance.meta.profile",
        "short": "Profiles this resource claims to conform to",
        "definition": "A list of profiles (references to [StructureDefinition](structuredefinition.html#) resources) that this resource claims to conform to. The URL is a reference to [StructureDefinition.url](structuredefinition-definitions.html#StructureDefinition.url).",
        "comment": "It is up to the server and/or other infrastructure of policy to determine whether/how these claims are verified and/or updated over time.  The list of profile URLs is a set.",
        "min": 0,
        "max": "*",
        "base": {
          "path": "Meta.profile",
          "min": 0,
          "max": "*"
        },
        "type": [
          {
            "code": "canonical",
            "targetProfile": [
              "http://hl7.org/fhir/StructureDefinition/StructureDefinition"
            ]
          }
        ],
        "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": "Provenance.meta.security",
        "path": "Provenance.meta.security",
        "short": "Security Labels applied to this resource",
        "definition": "Security labels applied to this resource. These tags connect specific resources to the overall security policy and infrastructure.",
        "comment": "The security labels can be updated without changing the stated version of the resource. The list of security labels is a set. Uniqueness is based the system/code, and version and display are ignored.",
        "min": 0,
        "max": "*",
        "base": {
          "path": "Meta.security",
          "min": 0,
          "max": "*"
        },
        "type": [
          {
            "code": "Coding"
          }
        ],
        "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,
        "binding": {
          "extension": [
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
              "valueString": "SecurityLabels"
            },
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-isCommonBinding",
              "valueBoolean": true
            }
          ],
          "strength": "extensible",
          "description": "Security Labels from the Healthcare Privacy and Security Classification System.",
          "valueSet": "http://hl7.org/fhir/ValueSet/security-labels"
        }
      },
      {
        "id": "Provenance.meta.tag",
        "path": "Provenance.meta.tag",
        "short": "Tags applied to this resource",
        "definition": "Tags applied to this resource. Tags are intended to be used to identify and relate resources to process and workflow, and applications are not required to consider the tags when interpreting the meaning of a resource.",
        "comment": "The tags can be updated without changing the stated version of the resource. The list of tags is a set. Uniqueness is based the system/code, and version and display are ignored.",
        "min": 0,
        "max": "*",
        "base": {
          "path": "Meta.tag",
          "min": 0,
          "max": "*"
        },
        "type": [
          {
            "code": "Coding"
          }
        ],
        "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,
        "binding": {
          "extension": [
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
              "valueString": "Tags"
            }
          ],
          "strength": "example",
          "description": "Codes that represent various types of tags, commonly workflow-related; e.g. \"Needs review by Dr. Jones\".",
          "valueSet": "http://hl7.org/fhir/ValueSet/common-tags"
        }
      },
      {
        "id": "Provenance.implicitRules",
        "path": "Provenance.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": "Provenance.language",
        "path": "Provenance.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": "Provenance.text",
        "path": "Provenance.text",
        "short": "Narrative",
        "definition": "A human-readable narrative summary of the NexusEmrCoreProvenance resource for human interpretation.",
        "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"
          }
        ],
        "mustSupport": true,
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "rim",
            "map": "Act.text?"
          }
        ]
      },
      {
        "id": "Provenance.contained",
        "path": "Provenance.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": "Provenance.extension",
        "path": "Provenance.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": 0,
        "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": "Provenance.extension:attributedFact",
        "path": "Provenance.extension",
        "sliceName": "attributedFact",
        "short": "Per-fact citations for AI-generated text (statement + verbatim quotes)",
        "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": "Present when the target is AI-generated text produced under the cite-every-fact contract (summaries, chiefly). Repeats in fact order; order is significant. A generated summary need not be persisted at all -- but when it or its provenance is, this is where the citation trail lives, so the trail survives the write-back at full fidelity.",
        "alias": [
          "extensions",
          "user content"
        ],
        "min": 0,
        "max": "*",
        "base": {
          "path": "DomainResource.extension",
          "min": 0,
          "max": "*"
        },
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://fhir.apps.health/StructureDefinition/nexus-attributed-fact"
            ]
          }
        ],
        "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": "Provenance.modifierExtension",
        "path": "Provenance.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": "Provenance.target",
        "path": "Provenance.target",
        "short": "The resource(s) this provenance describes",
        "definition": "The resources produced or changed by the activity. For an AI write-back this is the resource\nthe AI produced -- the drafted DocumentReference, the suggested MedicationRequest, the\nTask.\n\nMultiple targets are permitted and are the normal case for a single AI action that writes a\nbundle: one Provenance covering the set is preferable to one per resource, because the action\nwas one decision.",
        "comment": "Per the Nexus EMR logical-reference model these MAY be identifier-only. A consumer resolving provenance MUST handle a reference with no literal `reference` -- this is the single most common cause of provenance appearing 'missing' when it is present.",
        "min": 1,
        "max": "*",
        "base": {
          "path": "Provenance.target",
          "min": 1,
          "max": "*"
        },
        "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": true,
        "mapping": [
          {
            "identity": "w5",
            "map": "FiveWs.what[x]"
          },
          {
            "identity": "rim",
            "map": "./outboundRelationship[isNormalActRelationship() and typeCode=SUBJ]/target  OR  ./participation[isNormalParticipation() and typeCode=SBJ]/role  OR  ./participation[isNormalParticipation() and typeCode=SBJ]/role[isNormalRole()]/player"
          },
          {
            "identity": "fhirauditevent",
            "map": "AuditEvent.entity.reference"
          },
          {
            "identity": "w3c.prov",
            "map": "Entity Created/Updated"
          }
        ]
      },
      {
        "id": "Provenance.occurred[x]",
        "path": "Provenance.occurred[x]",
        "short": "When the activity happened",
        "definition": "The period during which the activity occurred.",
        "comment": "Preferred over `recorded` as THE date. A provenance written asynchronously (a queued write-back) has a `recorded` well after the action; dating the action to the bookkeeping timestamp misplaces it in every timeline.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "Provenance.occurred[x]",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "Period"
          },
          {
            "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": false,
        "mapping": [
          {
            "identity": "workflow",
            "map": "Event.occurred[x]"
          },
          {
            "identity": "w5",
            "map": "FiveWs.done[x]"
          },
          {
            "identity": "rim",
            "map": "./effectiveTime[type=IVL_TS]"
          },
          {
            "identity": "w3c.prov",
            "map": "Activity.startTime & Activity.endTime"
          }
        ]
      },
      {
        "id": "Provenance.recorded",
        "path": "Provenance.recorded",
        "short": "When this provenance record was created",
        "definition": "The instant of time at which the activity was recorded.",
        "comment": "This can be a little different from the time stamp on the resource if there is a delay between recording the event and updating the provenance and target resource.",
        "min": 1,
        "max": "1",
        "base": {
          "path": "Provenance.recorded",
          "min": 1,
          "max": "1"
        },
        "type": [
          {
            "code": "instant"
          }
        ],
        "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": "w5",
            "map": "FiveWs.recorded"
          },
          {
            "identity": "rim",
            "map": "unique(./participation[isNormalParticipation() and typeCode=AUT]/time[type=TS])"
          },
          {
            "identity": "fhirauditevent",
            "map": "AuditEvent.recorded"
          },
          {
            "identity": "w3c.prov",
            "map": "Activity.when"
          }
        ]
      },
      {
        "id": "Provenance.policy",
        "path": "Provenance.policy",
        "short": "Policy or plan the activity was defined by",
        "definition": "Policy or plan the activity was defined by. Typically, a single activity may have multiple applicable policy documents, such as patient consent, guarantor funding, etc.",
        "comment": "For example: Where an OAuth token authorizes, the unique identifier from the OAuth token is placed into the policy element Where a policy engine (e.g. XACML) holds policy logic, the unique policy identifier is placed into the policy element.",
        "min": 0,
        "max": "*",
        "base": {
          "path": "Provenance.policy",
          "min": 0,
          "max": "*"
        },
        "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": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "rim",
            "map": "./inboundRelationship[isNormalActRelationship() and typeCode=\"SUBJ\"]/source[isNormalAct and subsumes(POLICY, classCode) and moodCode=EVN]/text[typeCode='ED'/tel"
          },
          {
            "identity": "fhirauditevent",
            "map": "AuditEvent.agent.policy"
          }
        ]
      },
      {
        "id": "Provenance.location",
        "path": "Provenance.location",
        "short": "Where the activity occurred, if relevant",
        "definition": "Where the activity occurred, if relevant.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "Provenance.location",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/StructureDefinition/Location"
            ]
          }
        ],
        "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.location"
          },
          {
            "identity": "w5",
            "map": "FiveWs.where[x]"
          },
          {
            "identity": "rim",
            "map": "unique(./participation[isNormalParticipation() and typeCode=LOC]/role[isNormalRole() and subsumes(SDLOC, classCode)]/player[isNormalEntity and classCode=\"LOC\" and determinerCode=\"INST\"]"
          },
          {
            "identity": "fhirauditevent",
            "map": "AuditEvent.agent.location"
          },
          {
            "identity": "w3c.prov",
            "map": "Activity.location"
          }
        ]
      },
      {
        "id": "Provenance.reason",
        "path": "Provenance.reason",
        "short": "Reason the activity is occurring",
        "definition": "The reason that the activity was taking place.",
        "min": 0,
        "max": "*",
        "base": {
          "path": "Provenance.reason",
          "min": 0,
          "max": "*"
        },
        "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": "ProvenanceReason"
            }
          ],
          "strength": "extensible",
          "description": "The reason the activity took place.",
          "valueSet": "http://terminology.hl7.org/ValueSet/v3-PurposeOfUse"
        },
        "mapping": [
          {
            "identity": "workflow",
            "map": "Event.reasonCode"
          },
          {
            "identity": "w5",
            "map": "FiveWs.why[x]"
          },
          {
            "identity": "rim",
            "map": "unique(./reasonCode)"
          },
          {
            "identity": "fhirauditevent",
            "map": "AuditEvent.purposeOfEvent"
          },
          {
            "identity": "w3c.prov",
            "map": "Activity.Activity"
          }
        ]
      },
      {
        "id": "Provenance.activity",
        "path": "Provenance.activity",
        "short": "What kind of activity produced the target",
        "definition": "An activity is something that occurs over a period of time and acts upon or with entities; it may include consuming, processing, transforming, modifying, relocating, using, or generating entities.",
        "comment": "Deliberately unbound. R4's example binding (`provenance-activity-type`) does not anticipate AI-mediated authorship -- draft-generated, AI-suggested, human-accepted -- and asserting it would mis-describe the data. Treat the activity vocabulary as open and read `activity.text`, which is what the examples carry. A validator run against the base spec will warn that no code was supplied; that warning is expected here.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "Provenance.activity",
          "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"
          }
        ],
        "mustSupport": true,
        "isModifier": false,
        "isSummary": false,
        "binding": {
          "extension": [
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
              "valueString": "ProvenanceActivity"
            }
          ],
          "strength": "extensible",
          "description": "The activity that took place.",
          "valueSet": "http://hl7.org/fhir/ValueSet/provenance-activity-type"
        },
        "mapping": [
          {
            "identity": "workflow",
            "map": "Event.code"
          },
          {
            "identity": "w5",
            "map": "FiveWs.why[x]"
          },
          {
            "identity": "rim",
            "map": "Act.code"
          },
          {
            "identity": "w3c.prov",
            "map": "Activity.Activity"
          }
        ]
      },
      {
        "id": "Provenance.agent",
        "path": "Provenance.agent",
        "short": "Who took part in the action",
        "definition": "Who or what was responsible for the activity.\n\nFor an AI-mediated action there are normally TWO agents and both matter:\n  • the **non-human agent** that generated the content -- a Device, identifying the harness\n    and, where a consumer needs it, the model;\n  • the **human** who reviewed, accepted or attested to it -- a Practitioner.\n\nRecording only the human makes AI-drafted content indistinguishable from human-authored\ncontent, which is the specific outcome this profile exists to prevent. Recording only the AI\nloses accountability.",
        "comment": "Includes the AI agent and its human supervisor where content was AI-drafted.",
        "requirements": "An agent can be a person, an organization, software, device, or other entities that may be ascribed responsibility.",
        "min": 1,
        "max": "*",
        "base": {
          "path": "Provenance.agent",
          "min": 1,
          "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,
        "mapping": [
          {
            "identity": "workflow",
            "map": "Event.performer"
          },
          {
            "identity": "w5",
            "map": "FiveWs.who"
          },
          {
            "identity": "rim",
            "map": "./participation[isNormalParticipation()]  OR  ./outboundRelationship[isNormalActRelationship() and typeCode='DRIV']"
          },
          {
            "identity": "fhirauditevent",
            "map": "AuditEvent.agent"
          },
          {
            "identity": "w3c.prov",
            "map": "Agent"
          }
        ]
      },
      {
        "id": "Provenance.agent.id",
        "path": "Provenance.agent.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": "Provenance.agent.extension",
        "path": "Provenance.agent.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": "Provenance.agent.modifierExtension",
        "path": "Provenance.agent.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": "Provenance.agent.type",
        "path": "Provenance.agent.type",
        "short": "The agent's role (author, verifier, attester, ...)",
        "definition": "The role this agent played in the activity -- for example `author` for the agent that generated\nthe content, and `attester` or `verifier` for the human who reviewed and accepted it.\n\nRequired (1..1) in this profile, matching US Core. This is the element that distinguishes a\nnon-human generating agent from the human who took responsibility for its output; without it, a\nProvenance naming two agents does not say which did what.",
        "comment": "Bound extensible to `provenance-agent-type` by the base. `author` + `attester` is the expected pair for an AI-mediated write -- see the AI-drafted-note example.",
        "min": 1,
        "max": "1",
        "base": {
          "path": "Provenance.agent.type",
          "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"
          }
        ],
        "mustSupport": true,
        "isModifier": false,
        "isSummary": true,
        "binding": {
          "extension": [
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
              "valueString": "ProvenanceAgentType"
            }
          ],
          "strength": "extensible",
          "description": "The type of participation that a provenance agent played with respect to the activity.",
          "valueSet": "http://hl7.org/fhir/ValueSet/provenance-agent-type"
        },
        "mapping": [
          {
            "identity": "workflow",
            "map": "Event.performer.function"
          },
          {
            "identity": "rim",
            "map": ".role"
          },
          {
            "identity": "fhirauditevent",
            "map": "AuditEvent.agent.type"
          },
          {
            "identity": "w3c.prov",
            "map": "Agent.Attribution"
          }
        ]
      },
      {
        "id": "Provenance.agent.role",
        "path": "Provenance.agent.role",
        "short": "What the agents role was",
        "definition": "The function of the agent with respect to the activity. The security role enabling the agent with respect to the activity.",
        "comment": "For example: doctor, nurse, clerk, etc.",
        "min": 0,
        "max": "*",
        "base": {
          "path": "Provenance.agent.role",
          "min": 0,
          "max": "*"
        },
        "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": "ProvenanceAgentRole"
            }
          ],
          "strength": "example",
          "description": "The role that a provenance agent played with respect to the activity.",
          "valueSet": "http://hl7.org/fhir/ValueSet/security-role-type"
        },
        "mapping": [
          {
            "identity": "rim",
            "map": ".typecode"
          },
          {
            "identity": "fhirauditevent",
            "map": "AuditEvent.agent.role"
          }
        ]
      },
      {
        "id": "Provenance.agent.who",
        "path": "Provenance.agent.who",
        "short": "The agent itself -- Practitioner, Device (AI/system), Organization, Patient",
        "definition": "The individual, device or organization that participated in the event.",
        "comment": "Practitioner is the primary provider identity in this IG. A non-human agent is a Device, referenced logically (by identifier) where the harness graph has no stored Device instance; set `Reference.type` to `Device` so a reader can tell what kind of agent it is without resolving. Whether model identity rides on that Device instance is open -- see the token/model accounting note at the top of this file.",
        "min": 1,
        "max": "1",
        "base": {
          "path": "Provenance.agent.who",
          "min": 1,
          "max": "1"
        },
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.apps.health/StructureDefinition/nexus-emr-core-practitioner",
              "https://fhir.apps.health/StructureDefinition/nexus-emr-core-practitionerrole",
              "https://fhir.apps.health/StructureDefinition/nexus-emr-core-patient",
              "https://fhir.apps.health/StructureDefinition/nexus-emr-core-relatedperson",
              "https://fhir.apps.health/StructureDefinition/nexus-emr-core-organization",
              "https://fhir.apps.health/StructureDefinition/nexus-emr-core-appdevice",
              "https://fhir.apps.health/StructureDefinition/nexus-emr-core-emrdevice"
            ]
          }
        ],
        "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.actor"
          },
          {
            "identity": "rim",
            "map": ".id"
          }
        ]
      },
      {
        "id": "Provenance.agent.onBehalfOf",
        "path": "Provenance.agent.onBehalfOf",
        "short": "The party the agent acted for",
        "definition": "The individual, device, or organization for whom the change was made.",
        "comment": "Covers the delegation case the harness will need: an AI agent acting on behalf of the supervising practitioner, or of the clinic.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "Provenance.agent.onBehalfOf",
          "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",
              "https://fhir.apps.health/StructureDefinition/nexus-emr-core-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": false,
        "mapping": [
          {
            "identity": "rim",
            "map": "Person, Practitioner, Organization, Device :* .role [classCode = RoleClassMutualRelationship; role.code and * .scopes[Role](classCode=IDENT) and *.plays [Role.Code]"
          }
        ]
      },
      {
        "id": "Provenance.entity",
        "path": "Provenance.entity",
        "short": "The inputs the activity derived from -- for AI, the record context it was given",
        "definition": "The resources the activity used as input. For an AI action this is the record context the model\nwas given: the resources drawn from the patient compartment that informed the output.\n\nThis is what makes an AI output auditable rather than merely attributable -- \"this draft was\ngenerated from these twelve resources\" is a reviewable claim, where \"this draft came from the\nharness\" is not.",
        "comment": "Records WHICH RESOURCES the activity read, and stays at that grain deliberately: statement-level attribution -- which generated sentence rests on which passage -- rides the `attributedFact` extension instead, and a citation there MAY point back to the entity it was drawn from. For a chart-wide compartment load, listing every member may still be prohibitively large, and a summarizing convention (the compartment snapshot's own identifier rather than each member) is the expected direction for that case.",
        "min": 0,
        "max": "*",
        "base": {
          "path": "Provenance.entity",
          "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,
        "mapping": [
          {
            "identity": "rim",
            "map": "./subjectOf"
          },
          {
            "identity": "fhirauditevent",
            "map": "AuditEvent.entity"
          },
          {
            "identity": "w3c.prov",
            "map": "Entity"
          }
        ]
      },
      {
        "id": "Provenance.entity.id",
        "path": "Provenance.entity.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": "Provenance.entity.extension",
        "path": "Provenance.entity.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": "Provenance.entity.modifierExtension",
        "path": "Provenance.entity.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": "Provenance.entity.role",
        "path": "Provenance.entity.role",
        "short": "derivation | revision | quotation | source | removal",
        "definition": "How the entity was used during the activity.",
        "min": 1,
        "max": "1",
        "base": {
          "path": "Provenance.entity.role",
          "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": false,
        "isSummary": true,
        "binding": {
          "extension": [
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
              "valueString": "ProvenanceEntityRole"
            }
          ],
          "strength": "required",
          "description": "How an entity was used in an activity.",
          "valueSet": "http://hl7.org/fhir/ValueSet/provenance-entity-role|4.0.1"
        },
        "mapping": [
          {
            "identity": "rim",
            "map": "./typeCode"
          },
          {
            "identity": "fhirauditevent",
            "map": "AuditEvent.entity.lifecycle"
          },
          {
            "identity": "w3c.prov",
            "map": "Entity.role"
          }
        ]
      },
      {
        "id": "Provenance.entity.what",
        "path": "Provenance.entity.what",
        "short": "The input resource",
        "definition": "Identity of the  Entity used. May be a logical or physical uri and maybe absolute or relative.",
        "comment": "May be identifier-only per the logical-reference model.",
        "min": 1,
        "max": "1",
        "base": {
          "path": "Provenance.entity.what",
          "min": 1,
          "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": true,
        "mapping": [
          {
            "identity": "rim",
            "map": "./text/reference"
          },
          {
            "identity": "fhirauditevent",
            "map": "AuditEvent.entity.reference"
          },
          {
            "identity": "w3c.prov",
            "map": "Entity.Identity"
          }
        ]
      },
      {
        "id": "Provenance.entity.agent",
        "path": "Provenance.entity.agent",
        "short": "Entity is attributed to this agent",
        "definition": "The entity is attributed to an agent to express the agent's responsibility for that entity, possibly along with other agents. This description can be understood as shorthand for saying that the agent was responsible for the activity which generated the entity.",
        "comment": "A usecase where one Provenance.entity.agent is used where the Entity that was used in the creation/updating of the Target, is not in the context of the same custodianship as the Target, and thus the meaning of Provenance.entity.agent is to say that the entity referenced is managed elsewhere and that this Agent provided access to it.  This would be similar to where the Entity being referenced is managed outside FHIR, such as through HL7 v2, v3, or XDS. This might be where the Entity being referenced is managed in another FHIR resource server. Thus it explains the Provenance of that Entity's use in the context of this Provenance activity.",
        "min": 0,
        "max": "*",
        "base": {
          "path": "Provenance.entity.agent",
          "min": 0,
          "max": "*"
        },
        "contentReference": "#Provenance.agent",
        "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": "./author/role"
          }
        ]
      },
      {
        "id": "Provenance.signature",
        "path": "Provenance.signature",
        "short": "Signature on target",
        "definition": "A digital signature on the target Reference(s). The signer should match a Provenance.agent. The purpose of the signature is indicated.",
        "min": 0,
        "max": "*",
        "base": {
          "path": "Provenance.signature",
          "min": 0,
          "max": "*"
        },
        "type": [
          {
            "code": "Signature"
          }
        ],
        "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": "./signatureText"
          }
        ]
      }
    ]
  },
  "differential": {
    "element": [
      {
        "id": "Provenance",
        "path": "Provenance",
        "short": "Nexus EMR Provenance Core",
        "definition": "A record of what produced or changed a resource: the activity, when it was recorded, the\nagents responsible (which may include a non-human agent), and the inputs it derived from.\n\nPrimary intended use is AI-action attribution -- keeping an AI-produced resource traceable to\nthe agent that produced it, the human who accepted it, and the record context it was generated\nfrom. Where the product is generated text, the `attributedFact` extension carries the trail at\nstatement grain: each statement with the verbatim quote(s) backing it.",
        "constraint": [
          {
            "key": "provenance-target-required",
            "severity": "error",
            "human": "Provenance.target must name at least one resource -- a provenance with no target is unattributable",
            "expression": "target.exists()",
            "source": "https://fhir.apps.health/StructureDefinition/nexus-emr-core-provenance"
          },
          {
            "key": "provenance-ai-action-names-agent",
            "severity": "warning",
            "human": "A Provenance that carries attributed facts SHOULD name the non-human agent that generated them (agent.who typed or referenced as Device), in addition to any supervising human -- otherwise the trail cannot distinguish generated content from human-authored content",
            "expression": "extension.where(url = 'https://fhir.apps.health/StructureDefinition/nexus-attributed-fact').exists() implies agent.where(who.type = 'Device' or who.reference.startsWith('Device/')).exists()",
            "source": "https://fhir.apps.health/StructureDefinition/nexus-emr-core-provenance"
          }
        ]
      },
      {
        "id": "Provenance.meta.source",
        "path": "Provenance.meta.source",
        "short": "Identifies EMR instance & pipeline version the resource came from",
        "definition": "A URI that identifies the EMR pipeline and version from which this resource originated.  This tells you which EMR instance (recommend using the instance identifier), and the version of the pipeline code/transformations.",
        "mustSupport": true
      },
      {
        "id": "Provenance.text",
        "path": "Provenance.text",
        "short": "Narrative",
        "definition": "A human-readable narrative summary of the NexusEmrCoreProvenance resource for human interpretation.",
        "mustSupport": true
      },
      {
        "id": "Provenance.extension",
        "path": "Provenance.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "ordered": false,
          "rules": "open"
        }
      },
      {
        "id": "Provenance.extension:attributedFact",
        "path": "Provenance.extension",
        "sliceName": "attributedFact",
        "short": "Per-fact citations for AI-generated text (statement + verbatim quotes)",
        "comment": "Present when the target is AI-generated text produced under the cite-every-fact contract (summaries, chiefly). Repeats in fact order; order is significant. A generated summary need not be persisted at all -- but when it or its provenance is, this is where the citation trail lives, so the trail survives the write-back at full fidelity.",
        "min": 0,
        "max": "*",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "https://fhir.apps.health/StructureDefinition/nexus-attributed-fact"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Provenance.target",
        "path": "Provenance.target",
        "short": "The resource(s) this provenance describes",
        "definition": "The resources produced or changed by the activity. For an AI write-back this is the resource\nthe AI produced -- the drafted DocumentReference, the suggested MedicationRequest, the\nTask.\n\nMultiple targets are permitted and are the normal case for a single AI action that writes a\nbundle: one Provenance covering the set is preferable to one per resource, because the action\nwas one decision.",
        "comment": "Per the Nexus EMR logical-reference model these MAY be identifier-only. A consumer resolving provenance MUST handle a reference with no literal `reference` -- this is the single most common cause of provenance appearing 'missing' when it is present.",
        "mustSupport": true
      },
      {
        "id": "Provenance.occurred[x]",
        "path": "Provenance.occurred[x]",
        "short": "When the activity happened",
        "comment": "Preferred over `recorded` as THE date. A provenance written asynchronously (a queued write-back) has a `recorded` well after the action; dating the action to the bookkeeping timestamp misplaces it in every timeline.",
        "mustSupport": true
      },
      {
        "id": "Provenance.recorded",
        "path": "Provenance.recorded",
        "short": "When this provenance record was created",
        "mustSupport": true
      },
      {
        "id": "Provenance.activity",
        "path": "Provenance.activity",
        "short": "What kind of activity produced the target",
        "comment": "Deliberately unbound. R4's example binding (`provenance-activity-type`) does not anticipate AI-mediated authorship -- draft-generated, AI-suggested, human-accepted -- and asserting it would mis-describe the data. Treat the activity vocabulary as open and read `activity.text`, which is what the examples carry. A validator run against the base spec will warn that no code was supplied; that warning is expected here.",
        "mustSupport": true
      },
      {
        "id": "Provenance.agent",
        "path": "Provenance.agent",
        "short": "Who took part in the action",
        "definition": "Who or what was responsible for the activity.\n\nFor an AI-mediated action there are normally TWO agents and both matter:\n  • the **non-human agent** that generated the content -- a Device, identifying the harness\n    and, where a consumer needs it, the model;\n  • the **human** who reviewed, accepted or attested to it -- a Practitioner.\n\nRecording only the human makes AI-drafted content indistinguishable from human-authored\ncontent, which is the specific outcome this profile exists to prevent. Recording only the AI\nloses accountability.",
        "comment": "Includes the AI agent and its human supervisor where content was AI-drafted.",
        "mustSupport": true
      },
      {
        "id": "Provenance.agent.type",
        "path": "Provenance.agent.type",
        "short": "The agent's role (author, verifier, attester, ...)",
        "definition": "The role this agent played in the activity -- for example `author` for the agent that generated\nthe content, and `attester` or `verifier` for the human who reviewed and accepted it.\n\nRequired (1..1) in this profile, matching US Core. This is the element that distinguishes a\nnon-human generating agent from the human who took responsibility for its output; without it, a\nProvenance naming two agents does not say which did what.",
        "comment": "Bound extensible to `provenance-agent-type` by the base. `author` + `attester` is the expected pair for an AI-mediated write -- see the AI-drafted-note example.",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Provenance.agent.who",
        "path": "Provenance.agent.who",
        "short": "The agent itself -- Practitioner, Device (AI/system), Organization, Patient",
        "comment": "Practitioner is the primary provider identity in this IG. A non-human agent is a Device, referenced logically (by identifier) where the harness graph has no stored Device instance; set `Reference.type` to `Device` so a reader can tell what kind of agent it is without resolving. Whether model identity rides on that Device instance is open -- see the token/model accounting note at the top of this file.",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.apps.health/StructureDefinition/nexus-emr-core-practitioner",
              "https://fhir.apps.health/StructureDefinition/nexus-emr-core-practitionerrole",
              "https://fhir.apps.health/StructureDefinition/nexus-emr-core-patient",
              "https://fhir.apps.health/StructureDefinition/nexus-emr-core-relatedperson",
              "https://fhir.apps.health/StructureDefinition/nexus-emr-core-organization",
              "https://fhir.apps.health/StructureDefinition/nexus-emr-core-appdevice",
              "https://fhir.apps.health/StructureDefinition/nexus-emr-core-emrdevice"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Provenance.agent.onBehalfOf",
        "path": "Provenance.agent.onBehalfOf",
        "short": "The party the agent acted for",
        "comment": "Covers the delegation case the harness will need: an AI agent acting on behalf of the supervising practitioner, or of the clinic.",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://fhir.apps.health/StructureDefinition/nexus-emr-core-practitioner",
              "https://fhir.apps.health/StructureDefinition/nexus-emr-core-practitionerrole",
              "https://fhir.apps.health/StructureDefinition/nexus-emr-core-organization"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Provenance.entity",
        "path": "Provenance.entity",
        "short": "The inputs the activity derived from -- for AI, the record context it was given",
        "definition": "The resources the activity used as input. For an AI action this is the record context the model\nwas given: the resources drawn from the patient compartment that informed the output.\n\nThis is what makes an AI output auditable rather than merely attributable -- \"this draft was\ngenerated from these twelve resources\" is a reviewable claim, where \"this draft came from the\nharness\" is not.",
        "comment": "Records WHICH RESOURCES the activity read, and stays at that grain deliberately: statement-level attribution -- which generated sentence rests on which passage -- rides the `attributedFact` extension instead, and a citation there MAY point back to the entity it was drawn from. For a chart-wide compartment load, listing every member may still be prohibitively large, and a summarizing convention (the compartment snapshot's own identifier rather than each member) is the expected direction for that case.",
        "mustSupport": true
      },
      {
        "id": "Provenance.entity.role",
        "path": "Provenance.entity.role",
        "mustSupport": true
      },
      {
        "id": "Provenance.entity.what",
        "path": "Provenance.entity.what",
        "short": "The input resource",
        "comment": "May be identifier-only per the logical-reference model.",
        "mustSupport": true
      }
    ]
  }
}
