{
  "$schema": "https://cara.iatfglobaloversight.org/schema/ncManagementJsonSchema.json",
  "type": "object",
  "description": "NcManagement report object",
  "required": [
    "DataType",
    "uuid"
  ],
  "definitions": {
    "FileObject": {
      "type": "object",
      "description": "file object ",
      "required": [
        "Name",
        "Size",
        "Type",
        "Extension",
        "Data"
      ],
      "properties": {
        "Name": {
          "type": "string",
          "description": "Name"
        },
        "Size": {
          "type": "integer",
          "description": "Size of file in byte"
        },
        "Type": {
          "type": "string",
          "description": "file type"
        },
        "Extension": {
          "type": "string",
          "description": "file extension"
        },
        "Data": {
          "type": "string",
          "description": "file data base64 encoded including mime filetype",
          "examples": "data:application/pdf;base64,JVBER...."
        }
      }
    }
  },
  "properties": {
    "AuditData": {
      "type": "object",
      "properties": {
        "AuditDate": {
          "type": "object",
          "description": "start and end date of audit (#CARA inherited from report)",
          "required": [
            "Start",
            "End"
          ],
          "properties": {
            "Start": {
              "type": "string",
              "description": "UTC DateTime as string",
              "examples": [
                "2020-05-09T00:00:00.000Z"
              ]
            },
            "End": {
              "type": "string",
              "description": "UTC DateTime as string",
              "examples": [
                "2020-05-19T00:00:00.000Z"
              ]
            }
          }
        },
        "AuditType": {
          "type": "string",
          "description": "AuditType from (#CARA auditTypeOptions inherited from report)"
        },
        "AuditTeam": {
          "type": "array",
          "items": [
            {
              "type": "object"
            }
          ]
        }
      }
    },
    "uuid": {
      "type": "string",
      "description": "same id as report (#CARA inherited from report)"
    },
    "singleNcAction": {
      "type": "boolean",
      "description": "set if the NC is exported as single for merge identification"
    },
    "CertificationBody": {
      "type": "string",
      "description": "Id of CB as string (#CARA inherited from report)"
    },
    "Processes": {
      "type": "array",
      "description": "reduced process list (#CARA inherited from report)",
      "items": [
        {
          "type": "object",
          "properties": {
            "Id": {
              "type": [
                "number",
                "string"
              ]
            },
            "ProcessName": {
              "type": "string"
            }
          },
          "required": [
            "Id",
            "ProcessName"
          ]
        }
      ]
    },
    "changed": {
      "type": "integer",
      "description": "timestamp changed"
    },
    "exportedBy": {
      "type": "string",
      "description": "auditor adp number set on export based on auditor of application"
    },
    "DataType": {
      "type": "string",
      "const": "NcManagement"
    },
    "MajorDate20": {
      "type": "string",
      "description": "UTC DateTime as string (#CARA inherited from report used for autocomplete)"
    },
    "MajorDate60": {
      "type": "string",
      "description": "UTC DateTime as string (#CARA inherited from report used for autocomplete)"
    },
    "MinorDate60": {
      "type": "string",
      "description": "UTC DateTime as string (#CARA inherited from report used for autocomplete)"
    },
    "NcActions": {
      "type": "array",
      "items": [
        {
          "type": "object",
          "properties": {
            "Id": {
              "type": [
                "number",
                "string"
              ],
              "description": "id of nc important for merge"
            },
            "NcNo": {
              "type": "integer",
              "description": "automatically incremented"
            },
            "NcIdentificationNo": {
              "type": "string"
            },
            "Standard": {
              "type": "string",
              "enum": [
                "1",
                "2"
              ]
            },
            "Classification": {
              "type": "string",
              "enum": [
                "1",
                "2"
              ]
            },
            "DueDate20": {
              "type": "string",
              "description": "UTC DateTime as string"
            },
            "DueDate60": {
              "type": "string",
              "description": "UTC DateTime as string"
            },
            "StatementOfNonconformity": {
              "type": "string"
            },
            "CreatedBy": {
              "type": "string",
              "description": "adp number of auditor who created the NC used for merge"
            },
            "StandardClause": {
              "type": "array",
              "description": "structure based on first requirement",
              "items": [
                {
                  "type": "object",
                  "properties": {
                    "No": {
                      "type": "string",
                      "description": "number of standard chapter"
                    }
                  },
                  "required": [
                    "No"
                  ]
                }
              ]
            },
            "Requirement": {
              "type": "string"
            },
            "ObjectiveEvidence": {
              "type": "string"
            },
            "JustificationForClassification": {
              "type": "string"
            },
            "NcObserved": {
              "type": "string",
              "description": "id of selected process (#CARA will be checked against available report processes)"
            },
            "Signature": {
              "type": "object",
              "properties": {
                "AuditorName": {
                  "type": "string"
                },
                "Date": {
                  "type": "string",
                  "description": "UTC DateTime as string"
                }
              },
              "required": [
                "AuditorName",
                "Date"
              ]
            },
            "Organization": {
              "type": "object",
              "properties": {
                "CorrectionActionTiming": {
                  "type": "string",
                  "description": "Correction (Containment) action, including timing and responsible person:"
                },
                "EvidenceOfImplementation": {
                  "type": "string"
                },
                "RootCauseAnalysis": {
                  "type": "string"
                },
                "RootCauseAnalysisFiles": {
                  "type": "array",
                  "items": {
                    "$ref": "#/definitions/FileObject"
                  }
                },
                "RootCauseImpactsSimilar": {
                  "type": "string",
                  "description": "Does the root cause impact other similar processes or products?",
                  "enum": [
                    "0",
                    "1"
                  ]
                },
                "RootCauseResult": {
                  "type": "string"
                },
                "RootCauseResultFiles": {
                  "type": "array",
                  "items": {
                    "$ref": "#/definitions/FileObject"
                  }
                },
                "SystemicCorrectionActionTiming": {
                  "type": "string"
                },
                "SystemicCorrectionActionTimingFiles": {
                  "type": "array",
                  "items": {
                    "$ref": "#/definitions/FileObject"
                  }
                },
                "SystemicEvidenceOfImplementation": {
                  "type": "string"
                },
                "SystemicEvidenceOfImplementationFiles": {
                  "type": "array",
                  "items": {
                    "$ref": "#/definitions/FileObject"
                  }
                },
                "ActionTakenVerifyImplementation": {
                  "type": "string"
                },
                "ActionTakenVeryImplementationFiles": {
                  "type": "array",
                  "items": {
                    "$ref": "#/definitions/FileObject"
                  }
                },
                "Submissions": {
                  "type": "array",
                  "items": [
                    {
                      "type": "object",
                      "properties": {
                        "Representative": {
                          "type": "string"
                        },
                        "Date": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "Representative",
                        "Date"
                      ]
                    }
                  ]
                }
              },
              "PreviousOrganizationData": {
                "type": "object",
                "description": "is only used on multiple NC imports and previous versions have differences",
                "properties": {
                  "CorrectionActionTiming": {
                    "type": "string",
                    "description": "Correction (Containment) action, including timing and responsible person:"
                  },
                  "EvidenceOfImplementation": {
                    "type": "string"
                  },
                  "RootCauseAnalysis": {
                    "type": "string"
                  },
                  "RootCauseAnalysisFiles": {
                    "type": "array",
                    "items": {
                      "$ref": "#/definitions/FileObject"
                    }
                  },
                  "RootCauseImpactsSimilar": {
                    "type": "string",
                    "description": "Does the root cause impact other similar processes or products?",
                    "enum": [
                      "0",
                      "1"
                    ]
                  },
                  "RootCauseResult": {
                    "type": "string"
                  },
                  "RootCauseResultFiles": {
                    "type": "array",
                    "items": {
                      "$ref": "#/definitions/FileObject"
                    }
                  },
                  "SystemicCorrectionActionTiming": {
                    "type": "string"
                  },
                  "SystemicCorrectionActionTimingFiles": {
                    "type": "array",
                    "items": {
                      "$ref": "#/definitions/FileObject"
                    }
                  },
                  "SystemicEvidenceOfImplementation": {
                    "type": "string"
                  },
                  "SystemicEvidenceOfImplementationFiles": {
                    "type": "array",
                    "items": {
                      "$ref": "#/definitions/FileObject"
                    }
                  },
                  "ActionTakenVerifyImplementation": {
                    "type": "string"
                  },
                  "ActionTakenVeryImplementationFiles": {
                    "type": "array",
                    "items": {
                      "$ref": "#/definitions/FileObject"
                    }
                  },
                  "VersionTimestamp": {
                    "type": "integer",
                    "description": "timestamp of date from the import file"
                  }
                }
              }
            },
            "Cb": {
              "type": "object",
              "description": "part completed after nc is completed",
              "properties": {
                "DateReviewed": {
                  "type": "string",
                  "description": "UTC DateTime as string"
                },
                "ReviewerDecision": {
                  "type": "string",
                  "enum": [
                    "1",
                    "2",
                    "3"
                  ]
                },
                "ReviewerComments": {
                  "type": "string"
                },
                "ReviewerName": {
                  "type": "string"
                },
                "ResolvedSpecialAuditDate": {
                  "type": "string",
                  "description": "UTC DateTime as string",
                  "examples": [
                    "2020-05-09T00:00:00.000Z"
                  ]
                }
              }
            }
          }
        }
      ]
    }
  }
}
