{
  "$id": "https://www.interoplayer.dev/schemas/claim-837p-v1.json",
  "title": "Interoplayer 837P translation request v1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "transaction",
    "submitter",
    "receiver",
    "billingProvider",
    "subscriber",
    "payer",
    "claim"
  ],
  "properties": {
    "schemaVersion": {
      "const": "1.0"
    },
    "transaction": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "controlNumber",
        "submitterTransactionIdentifier",
        "creationDate",
        "creationTime",
        "purposeCode"
      ],
      "properties": {
        "controlNumber": {
          "type": "string",
          "pattern": "^[0-9]{4,9}$"
        },
        "submitterTransactionIdentifier": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,49}$"
        },
        "creationDate": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
        },
        "creationTime": {
          "type": "string",
          "pattern": "^[0-9]{2}:[0-9]{2}(:[0-9]{2})?$"
        },
        "purposeCode": {
          "enum": [
            "00",
            "18"
          ]
        }
      }
    },
    "submitter": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "organizationName",
        "identifier",
        "contact"
      ],
      "properties": {
        "organizationName": {
          "type": "string",
          "minLength": 1,
          "maxLength": 60
        },
        "identifier": {
          "type": "string",
          "pattern": "^[A-Za-z0-9]{2,80}$"
        },
        "contact": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "name",
            "phone"
          ],
          "properties": {
            "name": {
              "type": "string",
              "minLength": 1,
              "maxLength": 60
            },
            "phone": {
              "type": "string",
              "pattern": "^[0-9]{10,15}$"
            },
            "email": {
              "type": "string",
              "minLength": 3,
              "maxLength": 80,
              "pattern": "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$"
            }
          }
        }
      }
    },
    "receiver": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "organizationName",
        "identifier"
      ],
      "properties": {
        "organizationName": {
          "type": "string",
          "minLength": 1,
          "maxLength": 60
        },
        "identifier": {
          "type": "string",
          "pattern": "^[A-Za-z0-9]{2,80}$"
        }
      }
    },
    "billingProvider": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "entityType",
            "organizationName",
            "npi",
            "taxonomyCode",
            "taxId",
            "address"
          ],
          "properties": {
            "entityType": {
              "const": "organization"
            },
            "organizationName": {
              "type": "string",
              "minLength": 1,
              "maxLength": 60
            },
            "npi": {
              "type": "string",
              "pattern": "^[0-9]{10}$"
            },
            "taxonomyCode": {
              "type": "string",
              "pattern": "^[A-Za-z0-9]{10}$"
            },
            "taxId": {
              "type": "string",
              "pattern": "^[0-9]{9}$"
            },
            "address": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "address1",
                "city",
                "state",
                "postalCode"
              ],
              "properties": {
                "address1": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 55
                },
                "address2": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 55
                },
                "city": {
                  "type": "string",
                  "minLength": 2,
                  "maxLength": 30
                },
                "state": {
                  "type": "string",
                  "pattern": "^[A-Za-z]{2}$"
                },
                "postalCode": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9 -]{1,13}[A-Za-z0-9]$"
                }
              }
            },
            "contact": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "name",
                "phone"
              ],
              "properties": {
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 60
                },
                "phone": {
                  "type": "string",
                  "pattern": "^[0-9]{10,15}$"
                }
              }
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "entityType",
            "firstName",
            "lastName",
            "npi",
            "taxonomyCode",
            "taxId",
            "address"
          ],
          "properties": {
            "entityType": {
              "const": "person"
            },
            "firstName": {
              "type": "string",
              "minLength": 1,
              "maxLength": 35
            },
            "middleName": {
              "type": "string",
              "minLength": 1,
              "maxLength": 25
            },
            "lastName": {
              "type": "string",
              "minLength": 1,
              "maxLength": 60
            },
            "npi": {
              "type": "string",
              "pattern": "^[0-9]{10}$"
            },
            "taxonomyCode": {
              "type": "string",
              "pattern": "^[A-Za-z0-9]{10}$"
            },
            "taxId": {
              "type": "string",
              "pattern": "^[0-9]{9}$"
            },
            "address": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "address1",
                "city",
                "state",
                "postalCode"
              ],
              "properties": {
                "address1": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 55
                },
                "address2": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 55
                },
                "city": {
                  "type": "string",
                  "minLength": 2,
                  "maxLength": 30
                },
                "state": {
                  "type": "string",
                  "pattern": "^[A-Za-z]{2}$"
                },
                "postalCode": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9 -]{1,13}[A-Za-z0-9]$"
                }
              }
            },
            "contact": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "name",
                "phone"
              ],
              "properties": {
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 60
                },
                "phone": {
                  "type": "string",
                  "pattern": "^[0-9]{10,15}$"
                }
              }
            }
          }
        }
      ]
    },
    "subscriber": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "firstName",
        "lastName",
        "memberId",
        "dateOfBirth",
        "gender",
        "relationshipCode",
        "address"
      ],
      "properties": {
        "firstName": {
          "type": "string",
          "minLength": 1,
          "maxLength": 35
        },
        "middleName": {
          "type": "string",
          "minLength": 1,
          "maxLength": 25
        },
        "lastName": {
          "type": "string",
          "minLength": 1,
          "maxLength": 60
        },
        "memberId": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,79}$"
        },
        "groupNumber": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,49}$"
        },
        "dateOfBirth": {
          "type": "string",
          "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
        },
        "gender": {
          "enum": [
            "F",
            "M",
            "U"
          ]
        },
        "relationshipCode": {
          "const": "18"
        },
        "address": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "address1",
            "city",
            "state",
            "postalCode"
          ],
          "properties": {
            "address1": {
              "type": "string",
              "minLength": 1,
              "maxLength": 55
            },
            "address2": {
              "type": "string",
              "minLength": 1,
              "maxLength": 55
            },
            "city": {
              "type": "string",
              "minLength": 2,
              "maxLength": 30
            },
            "state": {
              "type": "string",
              "pattern": "^[A-Za-z]{2}$"
            },
            "postalCode": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9 -]{1,13}[A-Za-z0-9]$"
            }
          }
        }
      }
    },
    "payer": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "organizationName",
        "identifier"
      ],
      "properties": {
        "organizationName": {
          "type": "string",
          "minLength": 1,
          "maxLength": 60
        },
        "identifier": {
          "type": "string",
          "pattern": "^[A-Za-z0-9]{2,80}$"
        }
      }
    },
    "claim": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "patientControlNumber",
        "totalChargeAmount",
        "placeOfServiceCode",
        "frequencyCode",
        "claimFilingIndicatorCode",
        "diagnoses",
        "serviceLines"
      ],
      "properties": {
        "patientControlNumber": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,37}$"
        },
        "totalChargeAmount": {
          "type": "string",
          "pattern": "^(0|[1-9][0-9]{0,9})(\\.[0-9]{1,2})?$"
        },
        "placeOfServiceCode": {
          "type": "string",
          "pattern": "^[0-9]{2}$"
        },
        "frequencyCode": {
          "enum": [
            "1",
            "7",
            "8"
          ]
        },
        "claimFilingIndicatorCode": {
          "enum": [
            "BL",
            "CH",
            "CI",
            "HM",
            "MA",
            "MB",
            "MC",
            "OF",
            "TV",
            "VA",
            "WC",
            "ZZ"
          ]
        },
        "payerClaimControlNumber": {
          "type": "string",
          "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,49}$"
        },
        "diagnoses": {
          "type": "array",
          "minItems": 1,
          "maxItems": 12,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9]{2,6}$"
          }
        },
        "renderingProvider": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "firstName",
            "lastName",
            "npi"
          ],
          "properties": {
            "firstName": {
              "type": "string",
              "minLength": 1,
              "maxLength": 35
            },
            "middleName": {
              "type": "string",
              "minLength": 1,
              "maxLength": 25
            },
            "lastName": {
              "type": "string",
              "minLength": 1,
              "maxLength": 60
            },
            "npi": {
              "type": "string",
              "pattern": "^[0-9]{10}$"
            },
            "taxonomyCode": {
              "type": "string",
              "pattern": "^[A-Za-z0-9]{10}$"
            }
          }
        },
        "serviceLines": {
          "type": "array",
          "minItems": 1,
          "maxItems": 50,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "procedureCode",
              "chargeAmount",
              "unitCount",
              "serviceDate",
              "diagnosisPointers"
            ],
            "properties": {
              "procedureCode": {
                "type": "string",
                "pattern": "^[A-Za-z0-9]{5}$"
              },
              "modifiers": {
                "type": "array",
                "minItems": 1,
                "maxItems": 4,
                "uniqueItems": true,
                "items": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9]{2}$"
                }
              },
              "chargeAmount": {
                "type": "string",
                "pattern": "^(0|[1-9][0-9]{0,9})(\\.[0-9]{1,2})?$"
              },
              "unitCount": {
                "type": "string",
                "pattern": "^(0|[1-9][0-9]{0,6})(\\.[0-9]{1,3})?$"
              },
              "serviceDate": {
                "type": "string",
                "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
              },
              "diagnosisPointers": {
                "type": "array",
                "minItems": 1,
                "maxItems": 4,
                "uniqueItems": true,
                "items": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 12
                }
              },
              "placeOfServiceCode": {
                "type": "string",
                "pattern": "^[0-9]{2}$"
              }
            }
          }
        }
      }
    }
  }
}
