{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.pdkexport.cz/docs/specs/pdk-conversion-delivery-note.schema.json",
  "title": "pdkexport.cz Conversion Input — Supplier Delivery Note",
  "version": "1.3.260226",
  "lastUpdated": "2026-02-26",
  "currency": "CZK",
  "contact": {
    "email": "podpora@pdkexport.cz",
    "homepage": "https://www.pdkexport.cz/"
  },
  "description": "Single delivery note that a supplier sends to pdkexport.cz. The service converts it into the Czech PDK format required by the recipient. Accepted wire formats: JSON and XML — a sample payload (and an XML XSD for the XML form) live next to this schema.",
  "type": "object",
  "required": [
    "supplier",
    "recipient",
    "deliveryNoteNumber",
    "dateOfIssue",
    "totalPriceWithoutTax",
    "totalPriceWithTax",
    "items"
  ],
  "properties": {

    "supplier": {
      "type": "object",
      "title": "Dodavatel",
      "requirement": "required",
      "description": "Party issuing the delivery note.",
      "required": ["code"],
      "properties": {
        "code": {
          "type": "string",
          "title": "Identifikator dodavatele",
          "requirement": "required",
          "description": "Supplier identifier — for Czech suppliers their IC (same semantics as `recipient.nationalCode`); otherwise an identifier agreed beforehand.",
          "minLength": 1,
          "maxLength": 16,
          "pattern": "^[\\x21-\\x7E]{1,16}$",
          "examples": ["12345678"]
        }
      }
    },

    "recipient": {
      "type": "object",
      "title": "Odberatel",
      "requirement": "required",
      "description": "Receiving party — referenced by `internalId`, the supplier's own stable handle for this customer.",
      "required": ["internalId", "nationalCode", "name", "email"],
      "properties": {
        "internalId": {
          "type": "string",
          "title": "Interni ID odberatele",
          "requirement": "required",
          "description": "Supplier-chosen identifier of the recipient, stable across deliveries.",
          "minLength": 1,
          "maxLength": 32,
          "pattern": "^[A-Za-z0-9_.\\-]{1,32}$",
          "examples": ["FN-BULOVKA-PAV-K", "EUC-PHARM-01"]
        },
        "nationalCode": {
          "type": "string",
          "title": "IC odberatele",
          "requirement": "required",
          "description": "Czech national company ID (IC), exactly 8 digits, leading zeros preserved.",
          "pattern": "^[0-9]{8}$",
          "examples": ["00064211"]
        },
        "name": {
          "type": "string",
          "title": "Nazev odberatele",
          "requirement": "required",
          "description": "Recipient's legal or commercial name.",
          "minLength": 1,
          "maxLength": 30,
          "pattern": "^[^|\\r\\n\\t]+$",
          "examples": ["Nemocnice Ceske Budejovice, a.s."]
        },
        "email": {
          "type": "string",
          "title": "E-mail odberatele",
          "requirement": "required",
          "description": "Used for delivery notifications.",
          "format": "email",
          "maxLength": 150,
          "examples": ["pharmacy@hospital.example"]
        }
      }
    },

    "deliveryNoteNumber": {
      "type": "string",
      "title": "Cislo dodaciho listu",
      "requirement": "required",
      "description": "Identifier of this delivery note within the supplier's namespace.",
      "minLength": 1,
      "maxLength": 12,
      "pattern": "^[A-Za-z0-9._\\-]{1,12}$",
      "examples": ["DL2026-0042"]
    },

    "orderNumber": {
      "type": "string",
      "title": "Cislo objednavky",
      "requirement": "optional",
      "description": "Recipient's purchase-order number fulfilled by this delivery.",
      "maxLength": 36,
      "pattern": "^[A-Za-z0-9._\\-]{1,36}$",
      "examples": ["PO-2026-09887"]
    },

    "dateOfIssue": {
      "type": "string",
      "title": "Datum vystaveni",
      "requirement": "required",
      "description": "Date on which the supplier issued the delivery note.",
      "format": "date",
      "pattern": "^20[0-9]{2}-[0-9]{2}-[0-9]{2}$",
      "examples": ["2026-05-14"]
    },

    "dateOfDelivery": {
      "type": "string",
      "title": "Datum dodani",
      "requirement": "optional",
      "description": "Date the goods reach the recipient. Provide only if it differs from `dateOfIssue`.",
      "format": "date",
      "pattern": "^20[0-9]{2}-[0-9]{2}-[0-9]{2}$",
      "examples": ["2026-05-16"]
    },

    "deliveryPlace": {
      "type": "string",
      "title": "Misto doruceni",
      "requirement": "optional",
      "description": "Delivery-point code at the recipient (department, ward, pavilion) taken from the order. Provide when the recipient distinguishes sub-locations.",
      "minLength": 1,
      "maxLength": 20,
      "pattern": "^[A-Za-z0-9._\\-]{1,20}$",
      "examples": ["234103", "PHARM-PAV-K"]
    },

    "totalPriceWithoutTax": {
      "$ref": "#/$defs/price",
      "title": "Celkova cena bez DPH",
      "requirement": "required",
      "description": "Document total across all items, excluding VAT."
    },

    "totalPriceWithTax": {
      "$ref": "#/$defs/price",
      "title": "Celkova cena s DPH",
      "requirement": "required",
      "description": "Document total across all items, including VAT."
    },

    "items": {
      "type": "array",
      "title": "Polozky",
      "requirement": "required",
      "description": "Line items on the delivery note. Each item is self-contained — no separate product master is needed.",
      "minItems": 1,
      "items": { "$ref": "#/$defs/item" }
    }
  },

  "$defs": {

    "price": {
      "type": "number",
      "description": "Monetary amount.",
      "minimum": 0,
      "multipleOf": 0.01,
      "examples": [1234.56]
    },

    "vatRate": {
      "type": "number",
      "description": "VAT rate in percent.",
      "minimum": 0,
      "maximum": 99.9,
      "multipleOf": 0.1,
      "examples": [21.0, 12.0, 0.0]
    },

    "item": {
      "type": "object",
      "required": [
        "pdkCode",
        "quantity",
        "unitPriceWithoutTax",
        "unitPriceWithTax",
        "vatRate"
      ],
      "properties": {
        "pdkCode": {
          "type": "string",
          "title": "PDK kod",
          "requirement": "required",
          "description": "Primary product identifier. Either the official PDK code assigned by PharmData s.r.o., or any supplier-chosen identifier (typically the catalog number) the recipient agrees to use. Must be stable per product variant.",
          "minLength": 1,
          "maxLength": 16,
          "pattern": "^[A-Za-z0-9._\\-]{1,16}$",
          "examples": ["THU-OR-1234", "0123456789"]
        },
        "name": {
          "type": "string",
          "title": "Nazev polozky",
          "requirement": "optional",
          "description": "Product name.",
          "maxLength": 50,
          "pattern": "^[^|\\r\\n\\t]+$",
          "examples": ["Orteza kolenni stabilizacni vel. M"]
        },
        "quantity": {
          "type": "number",
          "title": "Pocet kusu",
          "requirement": "required",
          "description": "Quantity delivered.",
          "exclusiveMinimum": 0,
          "multipleOf": 0.01,
          "examples": [1, 5, 0.5]
        },
        "unitPriceWithoutTax": {
          "$ref": "#/$defs/price",
          "title": "Jednotkova cena bez DPH",
          "requirement": "required",
          "description": "Unit price excluding VAT."
        },
        "unitPriceWithTax": {
          "$ref": "#/$defs/price",
          "title": "Jednotkova cena s DPH",
          "requirement": "required",
          "description": "Unit price including VAT."
        },
        "vatRate": {
          "$ref": "#/$defs/vatRate",
          "title": "Sazba DPH radku",
          "requirement": "required",
          "description": "VAT rate applied to this item."
        },
        "batchCode": {
          "type": "string",
          "title": "Sarze",
          "requirement": "conditional",
          "description": "Required when the recipient tracks batches for this product category.",
          "minLength": 1,
          "maxLength": 20,
          "pattern": "^[A-Za-z0-9._\\-]{1,20}$",
          "examples": ["LOT-2026-04-A"]
        },
        "expirationDate": {
          "type": "string",
          "title": "Expirace",
          "requirement": "conditional",
          "description": "Required when the recipient tracks expiration for this product category. Day-precision; if only the month is known, use the last calendar day of that month.",
          "format": "date",
          "pattern": "^20[0-9]{2}-[0-9]{2}-[0-9]{2}$",
          "examples": ["2028-12-31"]
        },
        "barcode": {
          "type": "string",
          "title": "EAN / GTIN",
          "requirement": "optional",
          "description": "Product barcode. Numeric only (EAN-8, EAN-13, GTIN-14).",
          "minLength": 8,
          "maxLength": 16,
          "pattern": "^[0-9]{8,16}$",
          "examples": ["8594000123456"]
        },
        "udiCode": {
          "type": "string",
          "title": "UDI kod",
          "requirement": "conditional",
          "description": "Required for medical devices under EU MDR UDI obligation. Provide GS1 AI notation with parentheses, or the equivalent encoded form composed of the GS1 AI Character Set 82. FNC1 (0x1D) is not accepted.",
          "maxLength": 256,
          "pattern": "^[\\x20-\\x22\\x25-\\x3F\\x41-\\x5A\\x5F\\x61-\\x7A]{1,256}$",
          "examples": ["(01)08594000123456(17)281231(10)LOT2026A"]
        }
      }
    }
  }
}
