{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://velacent.com/schemas/profile/1.0/profile.schema.json",
  "title": "Velacent Bridge interface profile 1.0",
  "description": "The machine-readable part of a Velacent Bridge interface profile: the first fenced block of a profile Markdown file, with the info string 'json profile'. No PHI and no customer-identifying data: connection details are entered when a profile is applied. See docs/DATA_PLANE.md, 'Interface Profiles & Conformance'.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "id", "name", "vendor", "product", "version", "summary", "publisher", "trust", "licence", "basis", "coverage", "conformance", "template"],
  "properties": {
    "schema": {"const": "https://velacent.com/schemas/profile/1.0/profile.schema.json"},
    "id": {"type": "string", "maxLength": 100, "pattern": "^[a-z0-9][a-z0-9-]{0,40}(\\.[a-z0-9][a-z0-9-]{0,40}){1,5}$"},
    "name": {"type": "string", "minLength": 1, "maxLength": 120, "pattern": "^[^<>]*$"},
    "vendor": {"type": "string", "minLength": 1, "maxLength": 80, "pattern": "^[^<>]*$"},
    "product": {"type": "string", "minLength": 1, "maxLength": 80, "pattern": "^[^<>]*$"},
    "version": {"type": "string", "maxLength": 40, "pattern": "^(0|[1-9]\\d{0,5})\\.(0|[1-9]\\d{0,5})\\.(0|[1-9]\\d{0,5})(-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$"},
    "summary": {"type": "string", "minLength": 1, "maxLength": 500, "pattern": "^[^<>]*$"},
    "publisher": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "org": {"type": "string", "minLength": 1, "maxLength": 120, "pattern": "^[^<>]*$"},
        "anonymous": {"type": "boolean"}
      },
      "oneOf": [
        {"required": ["org"], "properties": {"anonymous": {"const": false}}},
        {"required": ["anonymous"], "properties": {"anonymous": {"const": true}}, "not": {"required": ["org"]}}
      ]
    },
    "trust": {"enum": ["official", "velacent", "verified", "community"], "description": "official: published by Velacent. velacent: an EHR connection kit profile authored by Velacent, listed as Published by Velacent (ids velacent.ehr.*). community: published by a customer. verified: a community profile Velacent reviewed (granted by the registry review, recorded in the index)."},
    "licence": {"enum": ["Velacent-Profile-Registry-1.0", "Velacent-Private-Connector-1.0"], "description": "Velacent-Profile-Registry-1.0 for every shared profile; Velacent-Private-Connector-1.0 only with visibility private (the private connector license)."},
    "basis": {"enum": ["velacent_product", "public_specification", "customer_configuration", "vendor_statement", "learned_unverified"]},
    "regions": {"type": "array", "maxItems": 20, "uniqueItems": true, "description": "ISO 3166-1 alpha-2 country codes where the profile is released. Empty or absent: the United States market (including its territories).", "items": {"type": "string", "pattern": "^[A-Z]{2}$"}},
    "attestation": {
      "type": "object",
      "additionalProperties": false,
      "description": "The vendor's attestation on a vendor_statement profile: who attested, when, under which terms version, and the statement.",
      "required": ["by", "at", "terms_version", "statement"],
      "properties": {
        "by": {"type": "string", "minLength": 2, "maxLength": 160, "pattern": "^[^<>]*$"},
        "at": {"type": "string", "format": "date-time"},
        "terms_version": {"type": "string", "maxLength": 20},
        "statement": {"type": "string", "maxLength": 400}
      }
    },
    "sources": {
      "type": "array",
      "maxItems": 20,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["title", "url", "accessed"],
        "properties": {
          "title": {"type": "string", "minLength": 1, "maxLength": 200},
          "url": {"type": "string", "maxLength": 500, "pattern": "^https://"},
          "accessed": {"type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$"},
          "basis": {"enum": ["baseline"], "description": "baseline: accessed is the 2026-11-18 baseline date carried forward, not the date of a real read"}
        }
      }
    },
    "applies_to": {
      "type": "array",
      "maxItems": 50,
      "description": "Every product and version this profile serves when they all work with the same connector (one profile per connector, not per name).",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["product"],
        "properties": {
          "product": {"type": "string", "minLength": 1, "maxLength": 80, "pattern": "^[^<>]*$"},
          "versions": {"type": "array", "maxItems": 50, "items": {"type": "string", "minLength": 1, "maxLength": 40, "pattern": "^[^<>]*$"}}
        }
      }
    },
    "provenance": {
      "type": "object",
      "additionalProperties": false,
      "description": "How an Official profile was made: built from public documentation (basis public_specification) or, at the Unverified level, from Velacent Bridge's own understanding with no source (basis learned_unverified: only kind and notice). The notice is the label shown with the profile.",
      "required": ["kind", "notice"],
      "allOf": [
        {"if": {"required": ["kind"], "properties": {"kind": {"const": "learned_unverified"}}}, "then": {"properties": {"notice": {"pattern": "^Unverified: (based on Velacent.s general understanding of how the .+ typically behaves\\. Not built from, checked against or endorsed by .+\\.|the interface types are as listed in .+'s public catalog, https://.+; message-level details are provided by .+ to its customers and are not reflected here\\.|directory-sourced\\. This listing rests only on what the public API directory page states \\((?:dated \\d{4}-\\d{2}-\\d{2}|baseline \\d{4}-\\d{2}-\\d{2} \\(carried forward; [^)]+\\))\\), https://apis\\.io/.+; .+ did not supply or review it and its own material could not be read\\.) Confirm every detail with your .+ representative before go-live\\.$"}}}},
        {"if": {"required": ["kind"], "properties": {"kind": {"enum": ["fhir_capability", "hl7v2_spec", "gov_guide", "x12_companion", "exchange_docs"]}}}, "then": {"required": ["extraction", "retrieved", "terms_url", "terms_checked"], "properties": {"notice": {"pattern": "^Built from .+'s public specification, https://.+, (?:dated \\d{4}-\\d{2}-\\d{2}|baseline \\d{4}-\\d{2}-\\d{2} \\(carried forward; [^)]+\\)); not yet verified by .+\\.$"}}}}
      ],
      "properties": {
        "kind": {"enum": ["fhir_capability", "hl7v2_spec", "gov_guide", "x12_companion", "exchange_docs", "learned_unverified"]},
        "extraction": {"enum": ["deterministic", "ai_assisted"]},
        "method": {"enum": ["fetched", "read_in_browser"]},
        "catalog_url": {"type": "string", "maxLength": 500, "pattern": "^https://"},
        "directory_url": {"type": "string", "maxLength": 500, "pattern": "^https://apis\\.io/"},
        "directory_read": {"type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$"},
        "retrieved": {"type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$"},
        "document_version": {"type": "string", "maxLength": 80, "pattern": "^[^<>]*$"},
        "document_date": {"type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$"},
        "terms_url": {"type": "string", "maxLength": 500, "pattern": "^https://"},
        "terms_checked": {"type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$"},
        "basis": {"enum": ["baseline"], "description": "baseline: retrieved (and the sources' accessed dates, and directory_read) is the 2026-11-18 baseline date carried forward, not the date of a real read; a re-read replaces the date and removes the marker"},
        "terms_basis": {"enum": ["baseline"], "description": "baseline: terms_checked is the 2026-11-18 baseline date carried forward"},
        "notice": {"type": "string", "description": "Documented profiles: Built from <vendor>'s public specification, <url>, dated <date> (the source's own date) or baseline <date>; not yet verified by <vendor>. Unverified profiles (kind learned_unverified): Unverified: based on Velacent Bridge's general understanding of how the <product> typically behaves. Not built from, checked against or endorsed by <vendor>. Confirm every detail with your <vendor> representative before go-live."},
        "sections": {
          "type": "array",
          "maxItems": 20,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["name", "confidence"],
            "properties": {
              "name": {"type": "string", "minLength": 1, "maxLength": 60, "pattern": "^[^<>]*$"},
              "confidence": {"enum": ["high", "medium", "low"]},
              "reference": {"type": "string", "maxLength": 200, "pattern": "^[^<>]*$"}
            }
          }
        }
      }
    },
    "coverage": {
      "type": "object",
      "additionalProperties": false,
      "minProperties": 1,
      "properties": {
        "hl7v2": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["type"],
            "properties": {
              "type": {"type": "string", "pattern": "^[A-Z][A-Z0-9]{2}$"},
              "triggers": {"type": "array", "items": {"type": "string", "pattern": "^[A-Z0-9]{3}$"}},
              "versions": {"type": "array", "items": {"enum": ["2.1", "2.2", "2.3", "2.3.1", "2.4", "2.5", "2.5.1", "2.6", "2.7", "2.7.1", "2.8", "2.8.1", "2.8.2", "2.9"], "description": "HL7 v2 versions supported by the version converter (internal/hl7 Versions)."}}
            }
          }
        },
        "fhir": {
          "type": "object",
          "additionalProperties": false,
          "required": ["version", "resources"],
          "properties": {
            "version": {"enum": ["R4", "R4B", "R5"]},
            "resources": {"type": "array", "minItems": 1, "items": {"type": "string", "pattern": "^[A-Z][A-Za-z]{1,63}$"}}
          }
        },
        "x12": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["set"],
            "properties": {
              "set": {"type": "string", "pattern": "^[0-9]{3}$"},
              "versions": {"type": "array", "items": {"type": "string", "pattern": "^00[0-9]{4}(X[0-9]{3}(A[0-9])?)?$"}}
            }
          }
        },
        "dicom": {
          "type": "object",
          "additionalProperties": false,
          "required": ["objects"],
          "properties": {"objects": {"type": "array", "minItems": 1, "items": {"enum": ["SR", "CADSR", "KOS", "PDF", "CDA"]}}}
        },
        "other": {
          "type": "array",
          "items": {"type": "object", "additionalProperties": false, "required": ["format"], "properties": {"format": {"enum": ["CDA", "CSV"]}}}
        },
        "immunization": {
          "type": "object",
          "additionalProperties": false,
          "description": "How an immunization registry wants eligibility and funding reported, from the registry's own documentation. Every field is optional; an absent field means the documentation was not read for it.",
          "properties": {
            "eligibility_capture": {"enum": ["per_immunization", "per_visit", "either"], "description": "The level at which the registry takes the patient's eligibility (OBX-17 VXC40 per immunization, VXC41 per visit)."},
            "funding_stock_model": {"enum": ["two_stock", "three_stock"], "description": "two_stock: public and private funding source codes. three_stock: public VFC, public non-VFC and private."},
            "local_eligibility_codes": {"type": "array", "maxItems": 50, "uniqueItems": true, "items": {"type": "string", "pattern": "^[A-Z][A-Z0-9]{2}[0-9]{2}$"}, "description": "Locally defined eligibility codes the registry documents as accepted (a state authority code and two digits)."}
          }
        },
        "web_api": {
          "type": "array",
          "maxItems": 20,
          "description": "Web APIs: the generic REST APIs a public API directory page names (directory-sourced listings), or the API families a vendor's own public documentation describes (Documented listings built from a web API facts file).",
          "items": {"type": "object", "additionalProperties": false, "required": ["name"], "properties": {"name": {"type": "string", "minLength": 3, "maxLength": 80, "pattern": "^[^<>]*$"}, "auth": {"enum": ["oauth2", "api_key", "basic", "unstated"]}}}
        }
      }
    },
    "conformance": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "rules": {"type": "array", "maxItems": 500, "items": {"$ref": "#/$defs/rule"}}
      }
    },
    "template": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "routes": {"type": "array", "maxItems": 20, "items": {"$ref": "#/$defs/route"}}
      }
    },
    "query": {"$ref": "#/$defs/query"},
    "visibility": {"enum": ["shared", "private"], "description": "private: a connector built by Velacent Bridge for one customer organization, stored only in its tenant, id prefix private., license Velacent-Private-Connector-1.0; never in the shared registry or public pages. Absent means shared."}
  },
  "$defs": {
    "query": {
      "description": "How the system answers a FHIR read, search or write sent through Velacent Bridge partner access (internal/querycap). Absent: none.",
      "type": "object",
      "additionalProperties": false,
      "required": ["method"],
      "properties": {
        "method": {"enum": ["fhir", "hl7_query", "rest_api", "none"]},
        "resources": {"type": "array", "maxItems": 40, "items": {"$ref": "#/$defs/query_resource"}},
        "hl7": {
          "type": "object",
          "additionalProperties": false,
          "required": ["version", "queries"],
          "properties": {
            "version": {"type": "string", "pattern": "^2\\.[3-8](\\.[0-9])?$"},
            "queries": {"type": "array", "minItems": 1, "maxItems": 10, "items": {"$ref": "#/$defs/query_hl7"}}
          }
        },
        "rest": {
          "type": "object",
          "additionalProperties": false,
          "required": ["auth", "operations"],
          "properties": {
            "server": {"type": "string", "pattern": "^https://", "maxLength": 300},
            "auth": {
              "type": "object",
              "additionalProperties": false,
              "required": ["scheme"],
              "properties": {
                "scheme": {"enum": ["oauth2_client_credentials", "api_key_header", "basic", "none"]},
                "header": {"type": "string", "pattern": "^[A-Za-z0-9-]{1,64}$"},
                "token_url": {"type": "string", "pattern": "^https://", "maxLength": 300},
                "scopes": {"type": "array", "maxItems": 20, "items": {"type": "string", "minLength": 1, "maxLength": 100}}
              }
            },
            "operations": {"type": "array", "minItems": 1, "maxItems": 60, "items": {"$ref": "#/$defs/query_rest_operation"}}
          }
        },
        "note": {"type": "string", "maxLength": 300},
        "export": {
          "type": "object",
          "additionalProperties": false,
          "description": "FHIR Bulk Data Access ($export, IG v3.0.0) as the FHIR server states it; method fhir only.",
          "properties": {
            "group": {"type": "boolean"},
            "patient": {"type": "boolean"},
            "system": {"type": "boolean"},
            "patient_param": {"type": "boolean"},
            "type_filter": {"type": "boolean"}
          }
        }
      }
    },
    "query_resource": {
      "type": "object",
      "additionalProperties": false,
      "required": ["type", "interactions"],
      "properties": {
        "type": {"type": "string", "pattern": "^[A-Z][A-Za-z]{1,63}$"},
        "interactions": {"type": "array", "minItems": 1, "items": {"enum": ["read", "search", "create", "update"]}},
        "search_params": {"type": "array", "maxItems": 40, "items": {"type": "string", "pattern": "^(_id|_lastUpdated|[a-z][a-z0-9-]{0,63})(\\.[a-z][a-z0-9-]{0,63})?$"}},
        "via": {"type": "array", "items": {"type": "string", "minLength": 1, "maxLength": 120}},
        "conditional_create": {"type": "boolean", "description": "The FHIR server states conditional create (If-None-Exist) for this type; only with the create interaction."}
      }
    },
    "query_hl7": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "message", "response", "returns", "params"],
      "properties": {
        "name": {"type": "string", "minLength": 1, "maxLength": 120},
        "message": {"type": "string", "pattern": "^QBP\\^"},
        "response": {"type": "string", "pattern": "^RSP\\^"},
        "returns": {"type": "array", "minItems": 1, "maxItems": 10, "items": {"type": "string", "pattern": "^[A-Z][A-Za-z]{1,63}$"}},
        "params": {"type": "array", "minItems": 1, "maxItems": 12, "items": {"$ref": "#/$defs/query_hl7_param"}}
      }
    },
    "query_hl7_param": {
      "type": "object",
      "additionalProperties": false,
      "required": ["search", "field"],
      "properties": {
        "search": {"type": "string", "minLength": 1, "maxLength": 130},
        "field": {"type": "string", "pattern": "^QPD-([3-9]|1[0-9])(\\.[1-9][0-9]?)?$"}
      }
    },
    "query_rest_operation": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "method", "path", "resource", "interaction", "mapping"],
      "properties": {
        "id": {"type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]{0,79}$"},
        "method": {"enum": ["GET", "POST"]},
        "path": {"type": "string", "pattern": "^/", "maxLength": 300},
        "resource": {"type": "string", "pattern": "^[A-Z][A-Za-z]{1,63}$"},
        "interaction": {"enum": ["read", "search"]},
        "params": {"type": "array", "maxItems": 12, "items": {"$ref": "#/$defs/query_rest_param"}},
        "result": {"type": "string", "maxLength": 200},
        "mapping": {"type": "array", "minItems": 1, "maxItems": 80, "items": {"$ref": "#/$defs/query_field_map"}}
      }
    },
    "query_rest_param": {
      "type": "object",
      "additionalProperties": false,
      "required": ["fhir", "in", "name"],
      "properties": {
        "fhir": {"type": "string", "minLength": 1, "maxLength": 130},
        "in": {"enum": ["path", "query"]},
        "name": {"type": "string", "pattern": "^[A-Za-z0-9_.\\[\\]-]{1,64}$"}
      }
    },
    "query_field_map": {
      "type": "object",
      "additionalProperties": false,
      "required": ["from", "to", "source", "reviewed"],
      "properties": {
        "from": {"type": "string", "minLength": 1, "maxLength": 200},
        "to": {"type": "string", "minLength": 1, "maxLength": 200},
        "source": {"enum": ["heuristic", "ai", "vendor"]},
        "reviewed": {"type": "boolean"}
      }
    },
    "rule": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "format", "path", "check"],
      "properties": {
        "id": {"type": "string", "pattern": "^[a-z0-9][a-z0-9_.-]{0,63}$"},
        "format": {"enum": ["hl7v2", "fhir", "x12"]},
        "applies_to": {"type": "array", "maxItems": 50, "items": {"type": "string", "minLength": 1, "maxLength": 40}},
        "path": {"type": "string", "minLength": 1, "maxLength": 120, "description": "HL7 'PID.3.4' (every segment occurrence unless 'OBX(0).5'); FHIR 'Patient.identifier.system'; X12 'CLM01', 'NM1[85]09', 'SV101-2'."},
        "check": {"enum": ["required", "absent", "cardinality", "format", "pattern", "value_set", "identifier", "equals", "one_of"]},
        "min": {"type": "integer", "minimum": 0},
        "max": {"type": "integer", "minimum": 0},
        "value_format": {"enum": ["date", "hl7_ts", "fhir_date", "fhir_datetime", "x12_date", "numeric", "integer", "alphanumeric", "npi", "oid", "uuid"]},
        "pattern": {"type": "string", "minLength": 1, "maxLength": 200, "description": "An RE2 regular expression."},
        "value": {"type": "string", "maxLength": 100},
        "values": {"type": "array", "maxItems": 200, "items": {"type": "string", "maxLength": 100}},
        "value_set": {
          "type": "object",
          "additionalProperties": false,
          "required": ["system"],
          "properties": {
            "system": {"type": "string", "minLength": 1, "maxLength": 64, "description": "A loaded terminology (ICD-10-CM, ICD-10-PCS, HCPCS, LOINC, RxNorm, SNOMED CT, NPI), a customer code set ('code_set:<id>'), or a named table with inline codes. Never CPT codes inline."},
            "codes": {"type": "array", "maxItems": 200, "items": {"type": "string", "maxLength": 100}}
          }
        },
        "identifier": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "require_authority": {"type": "boolean"},
            "require_type": {"type": "boolean"},
            "type_codes": {"type": "array", "maxItems": 200, "items": {"type": "string", "maxLength": 100}}
          }
        },
        "when": {
          "type": "object",
          "additionalProperties": false,
          "required": ["path"],
          "properties": {
            "path": {"type": "string", "minLength": 1, "maxLength": 120},
            "equals": {"type": "string", "maxLength": 100},
            "one_of": {"type": "array", "maxItems": 200, "items": {"type": "string", "maxLength": 100}},
            "present": {"type": "boolean"}
          }
        },
        "severity": {"enum": ["error", "warning"]},
        "message": {"type": "string", "maxLength": 300, "description": "Plain-language explanation shown when the rule fails."}
      },
      "allOf": [
        {"if": {"properties": {"check": {"const": "cardinality"}}}, "then": {"anyOf": [{"required": ["min"]}, {"required": ["max"]}]}},
        {"if": {"properties": {"check": {"const": "format"}}}, "then": {"required": ["value_format"]}},
        {"if": {"properties": {"check": {"const": "pattern"}}}, "then": {"required": ["pattern"]}},
        {"if": {"properties": {"check": {"const": "value_set"}}}, "then": {"required": ["value_set"]}},
        {"if": {"properties": {"check": {"const": "identifier"}}}, "then": {"required": ["identifier"]}},
        {"if": {"properties": {"check": {"const": "equals"}}}, "then": {"required": ["value"]}},
        {"if": {"properties": {"check": {"const": "one_of"}}}, "then": {"required": ["values"]}}
      ]
    },
    "route": {
      "type": "object",
      "additionalProperties": false,
      "required": ["key", "match", "destination"],
      "properties": {
        "key": {"type": "string", "pattern": "^[a-z0-9][a-z0-9-]{0,31}$"},
        "description": {"type": "string", "maxLength": 300, "pattern": "^[^<>]*$"},
        "match": {"type": "array", "minItems": 1, "items": {"type": "string", "maxLength": 64}},
        "destination": {
          "type": "object",
          "additionalProperties": false,
          "required": ["kind"],
          "properties": {
            "kind": {"enum": ["accept", "mllp", "sftp", "webhook", "http_api", "fhir", "dicom", "database"]},
            "options": {"type": "object", "description": "Destination options of config.Destination without connection details (no address, url, host, user, password, secret, key, token, file, directory, certificate, TLS, AE title, database, project, bucket, headers, SMART or auth fields)."}
          }
        },
        "enrichment": {"type": "object", "description": "Route enrichment rules (route.enrichment); code maps, code sets and provider directories by ID; no sender names."},
        "conversion": {"type": "string", "pattern": "^([a-z0-9_]{1,32}|2[.][0-9]([.][0-9])?)$", "description": "The destination transform (output form) for http_api, webhook, fhir and dicom destinations; for mllp and hl7_https destinations, the HL7 v2 version (2.1-2.9) each message is converted to (destination hl7_version)."},
        "conversion_policy": {"enum": ["keep", "drop", "reject"], "description": "Values the target HL7 v2 version cannot carry: keep (default), drop (audited) or reject. Only with an HL7 v2 version conversion."},
        "ack": {
          "type": "object",
          "additionalProperties": false,
          "required": ["mode"],
          "properties": {
            "mode": {"enum": ["required", "none", "errors_only"]},
            "grace_seconds": {"type": "integer", "minimum": 0, "maximum": 60}
          }
        },
        "policy": {"enum": ["report", "reject"]}
      }
    }
  }
}
