{
  "$defs": {
    "__schema0": {
      "const": "1.0",
      "type": "string"
    },
    "__schema1": {
      "items": {
        "$ref": "#/$defs/__schema2"
      },
      "maxItems": 1000,
      "type": "array"
    },
    "__schema10": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "number"
        },
        {
          "type": "boolean"
        },
        {
          "type": "null"
        },
        {
          "items": {
            "$ref": "#/$defs/__schema10"
          },
          "type": "array"
        },
        {
          "additionalProperties": {
            "$ref": "#/$defs/__schema10"
          },
          "propertyNames": {
            "type": "string"
          },
          "type": "object"
        }
      ]
    },
    "__schema11": {
      "items": {
        "$ref": "#/$defs/__schema12"
      },
      "maxItems": 1000,
      "type": "array"
    },
    "__schema12": {
      "maxLength": 5000,
      "minLength": 1,
      "type": "string"
    },
    "__schema13": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema14": {
      "const": "functional_acknowledgment",
      "type": "string"
    },
    "__schema15": {
      "maxLength": 200,
      "minLength": 1,
      "type": "string"
    },
    "__schema16": {
      "enum": [
        "997",
        "999",
        "ta1"
      ],
      "type": "string"
    },
    "__schema17": {
      "description": "An ISO 8601 timestamp with a UTC offset",
      "format": "date-time",
      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$",
      "type": "string"
    },
    "__schema18": {
      "additionalProperties": false,
      "description": "A value qualified by an identifier scheme",
      "properties": {
        "agency": {
          "$ref": "#/$defs/__schema21"
        },
        "description": {
          "$ref": "#/$defs/__schema22"
        },
        "extensions": {
          "$ref": "#/$defs/__schema23"
        },
        "scheme": {
          "$ref": "#/$defs/__schema19"
        },
        "value": {
          "$ref": "#/$defs/__schema20"
        }
      },
      "required": [
        "scheme",
        "value"
      ],
      "type": "object"
    },
    "__schema19": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "__schema2": {
      "additionalProperties": false,
      "description": "A typed business reference",
      "properties": {
        "description": {
          "$ref": "#/$defs/__schema6"
        },
        "extensions": {
          "$ref": "#/$defs/__schema7"
        },
        "issuer": {
          "$ref": "#/$defs/__schema5"
        },
        "type": {
          "$ref": "#/$defs/__schema3"
        },
        "value": {
          "$ref": "#/$defs/__schema4"
        }
      },
      "required": [
        "type",
        "value"
      ],
      "type": "object"
    },
    "__schema20": {
      "maxLength": 500,
      "minLength": 1,
      "type": "string"
    },
    "__schema21": {
      "maxLength": 200,
      "minLength": 1,
      "type": "string"
    },
    "__schema22": {
      "maxLength": 500,
      "minLength": 1,
      "type": "string"
    },
    "__schema23": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema24": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "__schema25": {
      "$ref": "#/$defs/__schema17"
    },
    "__schema26": {
      "enum": [
        "accepted",
        "accepted_with_errors",
        "partially_accepted",
        "rejected"
      ],
      "type": "string"
    },
    "__schema27": {
      "items": {
        "$ref": "#/$defs/__schema28"
      },
      "maxItems": 100000,
      "type": "array"
    },
    "__schema28": {
      "additionalProperties": false,
      "description": "Acknowledgment outcome for one functional group",
      "properties": {
        "controlNumber": {
          "$ref": "#/$defs/__schema30"
        },
        "errors": {
          "$ref": "#/$defs/__schema47"
        },
        "extensions": {
          "$ref": "#/$defs/__schema48"
        },
        "functionalIdentifierCode": {
          "$ref": "#/$defs/__schema29"
        },
        "status": {
          "$ref": "#/$defs/__schema26"
        },
        "transactionSets": {
          "$ref": "#/$defs/__schema31"
        }
      },
      "required": [
        "controlNumber",
        "status"
      ],
      "type": "object"
    },
    "__schema29": {
      "maxLength": 20,
      "minLength": 1,
      "type": "string"
    },
    "__schema3": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "__schema30": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "__schema31": {
      "items": {
        "$ref": "#/$defs/__schema32"
      },
      "maxItems": 100000,
      "type": "array"
    },
    "__schema32": {
      "additionalProperties": false,
      "description": "Acknowledgment outcome for one transaction set",
      "properties": {
        "controlNumber": {
          "$ref": "#/$defs/__schema34"
        },
        "errors": {
          "$ref": "#/$defs/__schema36"
        },
        "extensions": {
          "$ref": "#/$defs/__schema46"
        },
        "implementationConventionReference": {
          "$ref": "#/$defs/__schema35"
        },
        "status": {
          "$ref": "#/$defs/__schema26"
        },
        "transactionSetCode": {
          "$ref": "#/$defs/__schema33"
        }
      },
      "required": [
        "transactionSetCode",
        "controlNumber",
        "status"
      ],
      "type": "object"
    },
    "__schema33": {
      "maxLength": 20,
      "minLength": 1,
      "type": "string"
    },
    "__schema34": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "__schema35": {
      "maxLength": 200,
      "minLength": 1,
      "type": "string"
    },
    "__schema36": {
      "items": {
        "$ref": "#/$defs/__schema37"
      },
      "maxItems": 100000,
      "type": "array"
    },
    "__schema37": {
      "additionalProperties": false,
      "description": "A structured syntax or envelope error reported by an acknowledgment",
      "properties": {
        "badData": {
          "$ref": "#/$defs/__schema44"
        },
        "code": {
          "$ref": "#/$defs/__schema39"
        },
        "elementPosition": {
          "$ref": "#/$defs/__schema43"
        },
        "extensions": {
          "$ref": "#/$defs/__schema45"
        },
        "level": {
          "$ref": "#/$defs/__schema38"
        },
        "message": {
          "$ref": "#/$defs/__schema40"
        },
        "segmentId": {
          "$ref": "#/$defs/__schema41"
        },
        "segmentPosition": {
          "$ref": "#/$defs/__schema42"
        }
      },
      "required": [
        "level",
        "code"
      ],
      "type": "object"
    },
    "__schema38": {
      "enum": [
        "interchange",
        "functional_group",
        "transaction_set",
        "segment",
        "element"
      ],
      "type": "string"
    },
    "__schema39": {
      "maxLength": 100,
      "minLength": 1,
      "type": "string"
    },
    "__schema4": {
      "maxLength": 500,
      "minLength": 1,
      "type": "string"
    },
    "__schema40": {
      "maxLength": 1000,
      "minLength": 1,
      "type": "string"
    },
    "__schema41": {
      "maxLength": 20,
      "minLength": 1,
      "type": "string"
    },
    "__schema42": {
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991,
      "type": "integer"
    },
    "__schema43": {
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991,
      "type": "integer"
    },
    "__schema44": {
      "maxLength": 1000,
      "type": "string"
    },
    "__schema45": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema46": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema47": {
      "items": {
        "$ref": "#/$defs/__schema37"
      },
      "maxItems": 100000,
      "type": "array"
    },
    "__schema48": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema49": {
      "items": {
        "$ref": "#/$defs/__schema37"
      },
      "maxItems": 100000,
      "type": "array"
    },
    "__schema5": {
      "maxLength": 200,
      "minLength": 1,
      "type": "string"
    },
    "__schema6": {
      "maxLength": 500,
      "minLength": 1,
      "type": "string"
    },
    "__schema7": {
      "$ref": "#/$defs/__schema8"
    },
    "__schema8": {
      "additionalProperties": {
        "$ref": "#/$defs/__schema10"
      },
      "description": "Namespaced, JSON-compatible extension values",
      "propertyNames": {
        "$ref": "#/$defs/__schema9"
      },
      "type": "object"
    },
    "__schema9": {
      "pattern": "^[a-z][a-z0-9]*(?:[.-][a-z0-9]+)*:[A-Za-z][A-Za-z0-9_.-]*$",
      "type": "string"
    }
  },
  "$id": "urn:loomedi:canonical:v1:functional-acknowledgment",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "A canonical X12 TA1, 997, or 999 technical acknowledgment",
  "properties": {
    "acknowledgmentNumber": {
      "$ref": "#/$defs/__schema15"
    },
    "acknowledgmentType": {
      "$ref": "#/$defs/__schema16"
    },
    "documentType": {
      "$ref": "#/$defs/__schema14"
    },
    "errors": {
      "$ref": "#/$defs/__schema49"
    },
    "extensions": {
      "$ref": "#/$defs/__schema13"
    },
    "generatedAt": {
      "$ref": "#/$defs/__schema17"
    },
    "groups": {
      "$ref": "#/$defs/__schema27"
    },
    "notes": {
      "$ref": "#/$defs/__schema11"
    },
    "receiver": {
      "$ref": "#/$defs/__schema18"
    },
    "referencedInterchangeControlNumber": {
      "$ref": "#/$defs/__schema24"
    },
    "referencedInterchangeDateTime": {
      "$ref": "#/$defs/__schema25"
    },
    "references": {
      "$ref": "#/$defs/__schema1"
    },
    "schemaVersion": {
      "$ref": "#/$defs/__schema0"
    },
    "sender": {
      "$ref": "#/$defs/__schema18"
    },
    "status": {
      "$ref": "#/$defs/__schema26"
    }
  },
  "required": [
    "schemaVersion",
    "documentType",
    "acknowledgmentNumber",
    "acknowledgmentType",
    "generatedAt",
    "sender",
    "receiver",
    "referencedInterchangeControlNumber",
    "status"
  ],
  "title": "FunctionalAcknowledgment",
  "type": "object"
}
