{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "urn:sbv:iso20022:auth.001.001.02",
  "title": "InformationRequestOpening — auth.001.001.02 (SBV profile)",
  "description": "ISO 20022 auth.001.001.02: Mở yêu cầu thông tin AML/CFT (SBV → NHTM)",
  "type": "object",
  "required": ["Document"],
  "properties": {
    "Document": {
      "type": "object",
      "required": ["InfReqOpng"],
      "properties": {
        "InfReqOpng": {
          "type": "object",
          "required": ["InvstgtnId", "LglMndtBsis", "CnfdtltySts", "DueDt", "InvstgtnPrd", "SubjMttr"],
          "properties": {

            "InvstgtnId": { "type": "string", "maxLength": 35, "description": "Investigation ID — unique per request" },

            "LglMndtBsis": {
              "type": "object",
              "description": "Cơ sở pháp lý (Luật PCRT, Nghị định 19/2023)",
              "properties": {
                "Tp":   { "type": "object", "properties": { "Cd": { "type": "string", "enum": ["LLEG","RQST","SUSP"] } } },
                "Desc": { "type": "string", "maxLength": 350 }
              }
            },

            "CnfdtltySts": {
              "type": "object",
              "description": "Mức độ bảo mật thông tin yêu cầu",
              "properties": {
                "IsConfidential": { "type": "boolean" }
              }
            },

            "DueDt": { "type": "string", "format": "date", "description": "Hạn chót phản hồi" },

            "InvstgtnPrd": {
              "type": "object",
              "required": ["FrDt", "ToDt"],
              "properties": {
                "FrDt": { "type": "string", "format": "date" },
                "ToDt": { "type": "string", "format": "date" }
              }
            },

            "SubjMttr": {
              "type": "object",
              "description": "Đối tượng điều tra (KH / giao dịch / tài khoản)",
              "properties": {
                "Cstmr": {
                  "type": "object",
                  "properties": {
                    "ClntId": { "type": "string", "maxLength": 35, "description": "Customer ID của NHTM" },
                    "IndvPrsn": {
                      "type": "object",
                      "properties": {
                        "GvnNm":  { "type": "string", "maxLength": 35 },
                        "FmlyNm": { "type": "string", "maxLength": 35 },
                        "DtAndPlcOfBirth": {
                          "type": "object",
                          "properties": {
                            "BirthDt": { "type": "string", "format": "date" },
                            "CtryOfBirth": { "type": "string", "pattern": "^[A-Z]{2}$" }
                          }
                        },
                        "Othr": {
                          "type": "object",
                          "description": "Số CCCD / Hộ chiếu",
                          "properties": {
                            "Id": { "type": "string", "maxLength": 35 },
                            "SchmeNm": { "type": "object", "properties": { "Cd": { "type": "string", "enum": ["CCCD","PASSP","DRVR"] } } }
                          }
                        }
                      }
                    },
                    "Org": {
                      "type": "object",
                      "properties": {
                        "FullLglNm": { "type": "string", "maxLength": 350 },
                        "LEI":       { "type": "string", "pattern": "^[A-Z0-9]{18}[0-9]{2}$" },
                        "TaxIdNb":   { "type": "string", "maxLength": 35 }
                      }
                    }
                  }
                },
                "Acct": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "Id":  { "type": "object", "properties": { "Othr": { "type": "object", "properties": { "Id": { "type": "string" } } } } },
                      "Ccy": { "type": "string", "pattern": "^[A-Z]{3}$" }
                    }
                  }
                },
                "Tx": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "UETR": { "type": "string" },
                      "Dt":   { "type": "string", "format": "date" },
                      "Amt":  { "type": "number" },
                      "Ccy":  { "type": "string", "pattern": "^[A-Z]{3}$" }
                    }
                  }
                }
              }
            }

          }
        }
      }
    }
  }
}
