openapi: 3.0.3

info:
  title: MyndAuth API
  description: Prior Authorization Automation
  version: 0.0.2

servers:
  - url: https://myndshft-sandbox.apigee.net/myndauth
    description: Sandbox Endpoint
  - url: https://myndshft-prod.apigee.net/myndauth
    description: Production Endpoint

tags:
  - name: Determination
    description: Review of prior authorization requests
  - name: Authorization
    description: Adjudication of prior authorization requests

paths:
  /v1/determinations:
    post:
      tags:
        - Determination
      operationId: postDetermination

      summary: Requests a review of a prior authorization request
      description:
        "Myndshft will use its internal logic to determine if the prior authorization request is likely
        to be approved or declined.
        <br><br>
        Note: This is Myndshft's best estimate and may not reflect the actual outcome of an authorization."

      parameters:
        - $ref: '#/components/parameters/xMyndshftClientId'

      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Bundle'

      responses:
        '200':
          description: OK
          headers:
            X-Myndshft-Client-ID:
              $ref: '#/components/headers/xMyndshftClientId'

            X-Myndshft-Determinations-Status:
              $ref: '#/components/headers/xMyndshftDeterminationsStatus'

            X-Myndshft-Determinations-ID:
              $ref: '#/components/headers/xMyndshftDeterminationsID'

          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Bundle'

        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Bundle'

  /v1/determinations/{id}:
    get:
      tags:
        - Determination
      operationId: getDetermination

      summary: Retrieves the results of prior authorization review request

      parameters:
        - $ref: '#/components/parameters/xMyndshftClientId'

        - name: id
          in: path
          description: The reference number of a previous request returned in the `X-Myndshft-Request-RefNum`
            header
          required: true
          schema:
            type: string

      responses:
        '200':
          description: OK
          headers:
            X-Myndshft-Client-ID:
              $ref: '#/components/headers/xMyndshftClientId'

            X-Myndshft-Determinations-Status:
              $ref: '#/components/headers/xMyndshftDeterminationsStatus'

            X-Myndshft-Determinations-ID:
              $ref: '#/components/headers/xMyndshftDeterminationsID'

          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Bundle'

        '404':
          description: Not Found

  /v1/authorizations:
    post:
      tags:
        - Authorization
      operationId: postAuthorization

      summary: Requests a prior authorization for the given FHIR bundle
      description:
        The FHIR bundle in the body of this request will be submitted to the Payor for a prior authorization.

      parameters:
        - $ref: '#/components/parameters/xMyndshftClientId'

      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Bundle'

      responses:
        '202':
          description: Accepted
          headers:
            Content-Location:
              description: The URL to fetch the result of this prior authorization request. Please poll this url
                no more than once every 120 seconds.
              schema:
                type: string

            X-Myndshft-Client-ID:
              $ref: '#/components/headers/xMyndshftClientId'

            X-Myndshft-PA-Authorizations-ID:
              $ref: '#/components/headers/xMyndshftPAAuthorizationsID'

  /v1/authorizations/{id}:
    get:
      tags:
        - Authorization
      summary: Retrieve the result of a previous adjudication
      operationId: getAuditRecord

      parameters:
        - $ref: '#/components/parameters/xMyndshftClientId'

        - name: id
          in: path
          description: The reference number of a previous request returned in the `X-Myndshft-Request-RefNum`
            header
          required: true
          schema:
            type: string

      responses:
        '202':
          description: The authorization has been submitted and is currently being processed.
          headers:
            X-Myndshft-Client-ID:
              $ref: '#/components/headers/xMyndshftClientId'

            X-Myndshft-PA-Authorizations-Status:
              $ref: '#/components/headers/xMyndshftPAAuthorizationsStatus'

            X-Myndshft-PA-Authorizations-ID:
              $ref: '#/components/headers/xMyndshftPAAuthorizationsID'

        '200':
          description: The authorization has been processed and can be found in the body
          headers:
            X-Myndshft-Client-ID:
              $ref: '#/components/headers/xMyndshftClientId'

            X-Myndshft-PA-Authorizations-Status:
              $ref: '#/components/headers/xMyndshftPAAuthorizationsStatus'

            X-Myndshft-PA-Authorizations-ID:
              $ref: '#/components/headers/xMyndshftPAAuthorizationsID'

          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Bundle'

        '404':
          description: Not Found


components:
  headers:
    xMyndshftClientId:
      description: The client ID provided to you by Myndshft
      schema:
        type: string

    xMyndshftDeterminationsStatus:
      description: The result of this adjudication review request
      schema:
        type: string
        enum: [Approved, Denied]

    xMyndshftDeterminationsID:
      description: The reference number for this adjudication review request
      schema:
        type: string

    xMyndshftPAAuthorizationsStatus:
      description: The result of this adjudication request
      schema:
        type: string
        enum: [Queued, Complete, Error]

    xMyndshftPAAuthorizationsID:
      description: The reference number for this request
      schema:
        type: string

  parameters:
    xMyndshftClientId:
      name: X-Myndshft-Client-ID
      in: header
      description: The client ID provided to you by Myndshft
      required: true
      schema:
        type: string

    pageToken:
      name: pageToken
      in: query
      description: Used to request a specific page of the list results
      required: false
      schema:
        type: string

    pageSize:
      name: pageSize
      in: query
      description:
        "Specifiy the maximum number of results to be returned. Note that the results may be
        further constrained."
      required: false
      schema:
        type: number

  schemas:
    Bundle:
      type: object
      description:
        "A JSON FHIR Resource Bundle (https://www.hl7.org/fhir/bundle.html). Note this schema is to complex to
        represent in OpenAPI. Please refer to hl7 for the schema."
