swagger: '2.0'
info:
  title: ProviderServices-InboundDocuments-V2
  version: '2.0'
  description:
    <p>
    Welcome to the Documents to ACC API. This is a secondary interaction linked to a Claim. 
    This allows software vendors to have one mechanism for Providers to submit various document types.
    </p>
host: apiservicesnpe.acc.co.nz
basePath: /api/v2
schemes:
  - https
securityDefinitions:
  apiKeyHeader:
    type: apiKey
    name: apikey
    in: header
security:
  - apiKeyHeader: []
paths:
  /documents:
    post:
      tags:
        - Upload Documents
      description: 
        <p>
        Allows software vendors to create a new service with ACC; the submission of selected documents (in PDF format and up to a maximum size of 20MB) through the addition of set metadata. The documents are a secondary interaction generally linked to a Claim or resulting invoice.
        </p>
        <p> 
        Discussion with your customers will determine which documents would add value and whether they wish to submit the documents at the same time as they submit a claim / invoice or later or both.
        </p>
        <p>
        <b>The permitted contentType for a specific user group, and sample documents for each document type, 
        are specified on the Developer Resource Centre:&nbsp;https://developer.acc.co.nz/sample-inbound-documents</b>
        </p>
      operationId: uploaddocument
      summary: Upload Document
      responses:
        '202':
          description: Accepted
          schema:
            $ref: '#/definitions/SuccessResponse'
        '400':
          description: Bad request, invalid request
          schema:
            $ref: '#/definitions/BadRequestErrorResponse'
        '401':
          description: Unauthorised, authentication error
          schema:
            $ref: '#/definitions/UnauthorisedErrorResponse'
        '403':
          description: Forbidden, unauthorised error
          schema:
            $ref: '#/definitions/ForbiddenErrorResponse'
        '500':
          description: Internal server error
          schema:
            $ref: '#/definitions/InternalErrorResponse'
      consumes:
      - multipart/form-data
      parameters:
      - name: ACC-CorrelationId
        in: header
        description: >-
          Unique UUID to track the incoming requests.
        type: string
        format: uuid
        required: true
      - in: formData    
        name: document
        description: Actual document (PDF) to be uploaded.
        required: true
        type: file
      - in: formData    
        name: documentMetaData
        description: Metadata as a JSON object. This should contain the additional information about the patient and the event that caused the document to be uploaded, such as claim number, event date, reason etc.
          An example:<br /><br />
          {<br />
          &nbsp;&nbsp;&nbsp;&nbsp;"contentType":"MMEXSPECR", (<font color='red'>mandatory</font>)<br />
          &nbsp;&nbsp;&nbsp;&nbsp;"fileCreationDateTime":"2020041213113022", (yyyyMMddHHmmss)<br />
          &nbsp;&nbsp;&nbsp;&nbsp;"runId":"666666",<br />
          &nbsp;&nbsp;&nbsp;&nbsp;"claimReferenceNumber":"AC344433", (<font color='red'>mandatory</font>)<br />
          &nbsp;&nbsp;&nbsp;&nbsp;"consultingProviderName":"Provider name",<br />
          &nbsp;&nbsp;&nbsp;&nbsp;"dateOfConsult":"24-05-2020", (DD-MM-YYYY)<br />
          &nbsp;&nbsp;&nbsp;&nbsp;"metaDataForContentType":"Metadata for content type string",<br />
          &nbsp;&nbsp;&nbsp;&nbsp;"assessmentType":"Assessment type string",<br />
          &nbsp;&nbsp;&nbsp;&nbsp;"bodySite":"Body site string",<br />
          &nbsp;&nbsp;&nbsp;&nbsp;"clientNHINumber":"ABC1234",<br />
          &nbsp;&nbsp;&nbsp;&nbsp;"clientFirstName":"First name", (<font color='red'>mandatory</font>)<br />
          &nbsp;&nbsp;&nbsp;&nbsp;"clientLastName":"Last name", (<font color='red'>mandatory</font>)<br />
          &nbsp;&nbsp;&nbsp;&nbsp;"clientDOB":"12-05-1956", (DD-MM-YYYY, <font color='red'>mandatory</font>)<br />
          &nbsp;&nbsp;&nbsp;&nbsp;"fileExtension":"PDF" (<font color='red'>mandatory</font>)<br />
          }
        required: true
        type: string
                
tags: []
definitions:

  DocumentMetaData:
    type: object
    properties:
      contentType:
        type: string
        description: The content type of the file
        example: MMEXSPECR
      fileCreationDateTime:
        type: string
        description: The date and time the file was created in yyyyMMddHHmmss format
        example: 2020041213113022
      runId:
        type: string
        description: The run ID
        example: 666666
      claimReferenceNumber:
        type: string
        description: The claim reference number
        example: AC344433
      consultingProviderName:
        type: string
        description: The provider name
        example: Provider name
      dateOfConsult:
        type: string
        description: The consulation date in dd-MM-yyyy format
        example: 24-05-2020
      metaDataForContentType:
        type: string
        description: Certain content types require extra metadata
        example: Metadata for content type string
      assessmentType:
        type: string
        description: The assessment type
        example: Assessment type string
      bodySite:
        type: string
        description: The body site
        example: Body site string
      clientNHINumber:
        type: string
        description: The client's NHI number
        example: ABC1234
      clientFirstName:
        type: string
        description: The client's first name
        example: First name
      clientLastName:
        type: string
        description: The client's last name
        example: Last name
      clientDOB:
        type: string
        description: The client's date of birth in dd-MM-yyyy format
        example: 12-05-1956
      fileExtension:
        type: string
        description: The file extension
        example: PDF
 
  SuccessResponse:
    type: object
    properties:
      documentMetaData:
          $ref: '#/definitions/DocumentMetaData'
      status:
        type: string
        description: The status message
        example: Receipted
      createdAt:
        type: string
        description: The date and time the document was received in yyyy-MM-dd format
        example: 2020-06-11

  BadRequestErrorResponse:
    type: object
    properties:
      code:
        type: integer
        description: The HTTP status code of the error
        example: 400
      message:
        type: string
        description: Human-readable description of the error
        example: There is an error with the document metadata.
      metadataErrors:
        type: array
        items:
          $ref: '#/definitions/MetadataError'
          
  UnauthorisedErrorResponse:
    type: object
    properties:
      code:
        type: integer
        description: The HTTP status code of the error
        example: 401
      message:
        type: string
        description: Human-readable description of the error
        example: You are not authorised to access this service. Contact ACC Digital Operations on 0800 222 994 option 1 to arrange permission.
      metadataErrors:
        type: array
        items:
          $ref: '#/definitions/MetadataError'
        example: null
          
  ForbiddenErrorResponse:
    type: object
    properties:
      code:
        type: integer
        description: The HTTP status code of the error
        example: 403
      message:
        type: string
        description: Human-readable description of the error
        example: You are not authorised to access this service. Contact ACC Digital Operations on 0800 222 994 option 1 to arrange permission.
      metadataErrors:
        type: array
        items:
          $ref: '#/definitions/MetadataError'
        example: null
          
  InternalErrorResponse:
    type: object
    properties:
      code:
        type: integer
        description: The HTTP status code of the error
        example: 500
      message:
        type: string
        description: Human-readable description of the error
        example: An internal error has occurred.
      metadataErrors:
        type: array
        items:
          $ref: '#/definitions/MetadataError'
        example: null

  MetadataError:
    type: object
    properties:
      field:
        type: string
        description: The metadata field that has an error
        example: contentType
      message:
        type: string
        description: Human-readable description of the error
        example: Field is mandatory and must be present.