{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/google-cloud-healthcare/json-schema/google-cloud-healthcare-message-schema.json",
  "title": "Message",
  "description": "A complete HL7v2 message. See [Introduction to HL7 Standards] (https://www.hl7.org/implement/standards/index.cfm?ref=common) for details on the standard.",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/google-cloud-healthcare-projects-api-openapi.yml#/components/schemas/Message",
  "properties": {
    "schematizedData": {
      "$ref": "#/$defs/SchematizedData",
      "description": "Output only. The parsed version of the raw message data schematized according to this store's schemas and type definitions."
    },
    "data": {
      "format": "byte",
      "type": "string",
      "description": "Required. Raw message bytes."
    },
    "patientIds": {
      "items": {
        "$ref": "#/$defs/PatientId"
      },
      "type": "array",
      "description": "Output only. All patient IDs listed in the PID-2, PID-3, and PID-4 segments of this message.",
      "readOnly": true
    },
    "messageType": {
      "description": "Output only. The message type for this message. MSH-9.1.",
      "readOnly": true,
      "type": "string"
    },
    "labels": {
      "additionalProperties": {
        "type": "string"
      },
      "type": "object",
      "description": "User-supplied key-value pairs used to organize HL7v2 stores. Label keys must be between 1 and 63 characters long, have a UTF-8 encoding of maximum 128 bytes, and must conform to the following PCRE regular expression: \\p{Ll}\\p{Lo}{0,62} Label values are optional, must be between 1 and 63 characters long, have a UTF-8 encoding of maximum 128 bytes, and must conform to the following PCRE regular expression: [\\p{Ll}\\p{Lo}\\p{N}_-]{0,63} No more than 64 labels can be associated with a given store."
    },
    "name": {
      "readOnly": true,
      "type": "string",
      "description": "Output only. Resource name of the Message, of the form `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}/hl7V2Stores/{hl7_v2_store_id}/messages/{message_id}`."
    },
    "sendFacility": {
      "type": "string",
      "description": "Output only. The hospital that this message came from. MSH-4.",
      "readOnly": true
    },
    "parsedData": {
      "$ref": "#/$defs/ParsedData",
      "description": "Output only. The parsed version of the raw message data."
    },
    "createTime": {
      "description": "Output only. The datetime when the message was created. Set by the server.",
      "readOnly": true,
      "type": "string",
      "format": "google-datetime"
    },
    "sendTime": {
      "description": "Output only. The datetime the sending application sent this message. MSH-7.",
      "readOnly": true,
      "format": "google-datetime",
      "type": "string"
    }
  },
  "type": "object",
  "$defs": {
    "ParsedData": {
      "description": "The content of a HL7v2 message in a structured format.",
      "properties": {
        "segments": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Segment"
          }
        }
      },
      "type": "object"
    },
    "PatientId": {
      "properties": {
        "type": {
          "type": "string",
          "description": "ID type. For example, MRN or NHS."
        },
        "value": {
          "description": "The patient's unique identifier.",
          "type": "string"
        }
      },
      "description": "A patient identifier and associated type.",
      "type": "object"
    },
    "SchematizedData": {
      "type": "object",
      "description": "The content of an HL7v2 message in a structured format as specified by a schema.",
      "properties": {
        "data": {
          "description": "JSON output of the parser.",
          "type": "string"
        },
        "error": {
          "description": "The error output of the parser.",
          "type": "string"
        }
      }
    },
    "Segment": {
      "properties": {
        "setId": {
          "description": "Set ID for segments that can be in a set. This can be empty if it's missing or isn't applicable.",
          "type": "string"
        },
        "segmentId": {
          "type": "string",
          "description": "A string that indicates the type of segment. For example, EVN or PID."
        },
        "fields": {
          "additionalProperties": {
            "type": "string"
          },
          "type": "object",
          "description": "A mapping from the positional location to the value. The key string uses zero-based indexes separated by dots to identify Fields, components and sub-components. A bracket notation is also used to identify different instances of a repeated field. Regex for key: (\\d+)(\\[\\d+\\])?(.\\d+)?(.\\d+)? Examples of (key, value) pairs: * (0.1, \"hemoglobin\") denotes that the first component of Field 0 has the value \"hemoglobin\". * (1.1.2, \"CBC\") denotes that the second sub-component of the first component of Field 1 has the value \"CBC\". * (1[0].1, \"HbA1c\") denotes that the first component of the first Instance of Field 1, which is repeated, has the value \"HbA1c\"."
        }
      },
      "type": "object",
      "description": "A segment in a structured format."
    }
  }
}