{
  "resourceType": "Bundle",
  "id": "example-digidot-transaction-conditional-create",
  "meta": {
    "profile": [
      "https://novari.no/fhir/digidot/StructureDefinition/digidot-TransactionBundle-no|0.2.0"
    ],
    "tag": [
      {
        "display": "Draft alternative to linked creation: each POST uses a stable source identifier. One match reuses the existing record without updating it; multiple matches fail. The identifier policy and resource workflows must be supported by DENT."
      }
    ]
  },
  "type": "transaction",
  "entry": [
    {
      "fullUrl": "urn:uuid:11111111-1111-4111-8111-111111111111",
      "resource": {
        "resourceType": "Encounter",
        "meta": {
          "profile": [
            "https://novari.no/fhir/digidot/StructureDefinition/digidot-Encounter-no|0.6.10"
          ]
        },
        "status": "finished",
        "class": {
          "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
          "code": "AMB"
        },
        "subject": {
          "reference": "https://mpi.example.org/fhir/Patient/example-patient",
          "type": "Patient"
        },
        "participant": [
          {
            "type": [
              {
                "coding": [
                  {
                    "system": "http://terminology.hl7.org/CodeSystem/v3-ParticipationType",
                    "code": "PPRF"
                  }
                ]
              }
            ],
            "individual": {
              "reference": "https://dent.example.org/fhir/Practitioner/example-dentist",
              "type": "Practitioner"
            }
          }
        ],
        "period": {
          "start": "2026-11-19T08:00:00+00:00",
          "end": "2026-11-19T08:40:00+00:00"
        },
        "location": [
          {
            "location": {
              "reference": "https://dent.example.org/fhir/Location/example-clinic"
            }
          }
        ],
        "serviceProvider": {
          "reference": "https://dent.example.org/fhir/Organization/example-county"
        },
        "text": {
          "status": "generated",
          "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p>Synthetic completed dental contact, 19 November 2026, 09:00 to 09:40.</p></div>"
        },
        "identifier": [
          {
            "system": "https://ehr.example.org/identifiers/Encounter",
            "value": "bundle-example-encounter-001"
          }
        ]
      },
      "request": {
        "method": "POST",
        "url": "Encounter",
        "ifNoneExist": "identifier=https://ehr.example.org/identifiers/Encounter|bundle-example-encounter-001"
      }
    },
    {
      "fullUrl": "urn:uuid:22222222-2222-4222-8222-222222222222",
      "resource": {
        "resourceType": "Condition",
        "meta": {
          "profile": [
            "https://novari.no/fhir/digidot/StructureDefinition/digidot-Condition-no|0.7.0"
          ]
        },
        "identifier": [
          {
            "system": "https://ehr.example.org/identifiers/Condition",
            "value": "bundle-example-condition-001"
          }
        ],
        "clinicalStatus": {
          "coding": [
            {
              "system": "http://terminology.hl7.org/CodeSystem/condition-clinical",
              "code": "resolved"
            }
          ]
        },
        "verificationStatus": {
          "coding": [
            {
              "system": "http://terminology.hl7.org/CodeSystem/condition-ver-status",
              "code": "confirmed"
            }
          ]
        },
        "category": [
          {
            "coding": [
              {
                "system": "http://terminology.hl7.org/CodeSystem/condition-category",
                "code": "encounter-diagnosis"
              }
            ]
          }
        ],
        "code": {
          "coding": [
            {
              "id": "SCTextended",
              "system": "http://snomed.info/sct",
              "version": "http://snomed.info/sct/51000202101/version/20260715",
              "code": "80967001",
              "display": "Dental caries"
            }
          ]
        },
        "subject": {
          "reference": "https://mpi.example.org/fhir/Patient/example-patient",
          "type": "Patient"
        },
        "encounter": {
          "reference": "urn:uuid:11111111-1111-4111-8111-111111111111",
          "type": "Encounter"
        },
        "onsetDateTime": "2026-11-19",
        "abatementDateTime": "2026-11-19",
        "recorder": {
          "reference": "https://dent.example.org/fhir/Practitioner/example-dentist",
          "type": "Practitioner"
        },
        "text": {
          "status": "generated",
          "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p>Synthetic dental caries finding treated and recorded as resolved during the linked contact. This example focuses on transaction references.</p></div>"
        }
      },
      "request": {
        "method": "POST",
        "url": "Condition",
        "ifNoneExist": "identifier=https://ehr.example.org/identifiers/Condition|bundle-example-condition-001"
      }
    },
    {
      "fullUrl": "urn:uuid:33333333-3333-4333-8333-333333333333",
      "resource": {
        "resourceType": "Procedure",
        "meta": {
          "profile": [
            "https://novari.no/fhir/digidot/StructureDefinition/digidot-Procedure-no|0.6.13"
          ]
        },
        "identifier": [
          {
            "system": "https://ehr.example.org/identifiers/Procedure",
            "value": "bundle-example-procedure-001"
          }
        ],
        "status": "completed",
        "category": {
          "coding": [
            {
              "system": "https://novari.no/fhir/digidot/CodeSystem/digidot-procedure-category",
              "code": "dental-procedure"
            }
          ]
        },
        "code": {
          "coding": [
            {
              "id": "SCTextended",
              "system": "http://snomed.info/sct",
              "version": "http://snomed.info/sct/51000202101/version/20260715",
              "code": "234789004",
              "display": "Dental restoration using composite material"
            }
          ]
        },
        "subject": {
          "reference": "https://mpi.example.org/fhir/Patient/example-patient",
          "type": "Patient"
        },
        "encounter": {
          "reference": "urn:uuid:11111111-1111-4111-8111-111111111111",
          "type": "Encounter"
        },
        "reasonReference": [
          {
            "reference": "urn:uuid:22222222-2222-4222-8222-222222222222",
            "type": "Condition"
          }
        ],
        "performedDateTime": "2026-11-19T08:20:00+00:00",
        "performer": [
          {
            "actor": {
              "reference": "https://dent.example.org/fhir/Practitioner/example-dentist",
              "type": "Practitioner"
            }
          }
        ],
        "text": {
          "status": "generated",
          "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p>Synthetic composite restoration linked to its contact and caries finding. This example focuses on transaction references.</p></div>"
        }
      },
      "request": {
        "method": "POST",
        "url": "Procedure",
        "ifNoneExist": "identifier=https://ehr.example.org/identifiers/Procedure|bundle-example-procedure-001"
      }
    }
  ]
}