openapi: 3.0.3
info:
  title: Prior Authorization Determination API
  version: 1.0.0
  description:
    Evaluate whether a procedure may require authorization for given patient, payer(s), and facility
    context.
  x-infinx-audience: EXTERNAL

servers:
  - url: https://ipas.infinx.com
    description: IPA production environment
  - url: https://testipa.infinx.com
    description: IPA staging environment

paths:
  /papapiinterface/ada/cases:
    post:
      summary: Evaluate prior authorization for a case
      tags:
        - Auth Determination
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/DeterminationRequest"
            example:
              caseInformation:
                accessionNumber: "ACC123456"
                dateOfServiceStr: "2024-12-15T14:30:00.000Z"
              insuranceInformation:
                - memberId: "MEMBER001"
                  payerName: "ACME INSURANCE CO"
                  payerType: "PRIMARY"
                - memberId: "MEMBER002"
                  payerName: "MEDICARE"
                  payerType: "SECONDARY"
              patientInformation:
                dob: "1985-07-12T00:00:00.000Z"
                firstName: "JOHN"
                lastName: "DOE"
              physicianInformation:
                firstName: "JANE"
                lastName: "SMITH"
                npi: "1234567890"
              procedureInformation:
                - cptCode: "72131"
              facilityInformation:
                facilityName: "SAMPLE HOSPITAL"
                facilityNPI: ""
                facilityCode: "SH"
      responses:
        "200":
          description: Authorization evaluation result
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DeterminationResponse"
              example:
                caseInformation:
                  accessionNumber: "ACC123456"
                  dateOfServiceStr: "2024-12-15T14:30:00Z"
                  caseNumber: "ACC123456-CASE789"
                decision:
                  - cptCode: "72131"
                    payerName: "ACME INSURANCE CO"
                    memberId: "MEMBER001"
                    status: "MayRequireAuthorization"
                    jobNumber: "ACC123456-72131-MEMBER001-JOB001"
                  - cptCode: "72131"
                    payerName: "MEDICARE"
                    memberId: "MEMBER002"
                    status: "NoAuthRequired"
                    jobNumber: "72131-MEMBER002-JOB002"
                insuranceInformation:
                  - payerType: "PRIMARY"
                    payerName: "ACME INSURANCE CO"
                    memberId: "MEMBER001"
                  - payerType: "SECONDARY"
                    payerName: "MEDICARE"
                    memberId: "MEMBER002"
                procedureInformation:
                  - cptCode: "72131"
        "400":
          description: Invalid request payload
        "401":
          description: Unauthorized
        "500":
          description: Server error

components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

  schemas:
    PayerType:
      type: string
      description: Type of payer relative to the case
      enum:
        - PRIMARY
        - SECONDARY

    DecisionStatus:
      type: string
      description: Outcome of payer-specific authorization evaluation
      enum:
        - AuthRequired
        - MayRequireAuthorization
        - NoAuthRequired

    CaseInformationBase:
      type: object
      additionalProperties: false
      properties:
        accessionNumber:
          type: string
          description: Accession/Case identifier in the ordering system
        dateOfServiceStr:
          type: string
          format: date-time
          description: Scheduled date/time of service (ISO-8601)
      required:
        - accessionNumber
        - dateOfServiceStr

    CaseInformation:
      allOf:
        - $ref: "#/components/schemas/CaseInformationBase"

    CaseInformationResponse:
      allOf:
        - $ref: "#/components/schemas/CaseInformationBase"
        - type: object
          additionalProperties: false
          properties:
            caseNumber:
              type: string
              description: Unique case number assigned by the authorization system
          required:
            - caseNumber

    InsuranceInfo:
      type: object
      additionalProperties: false
      properties:
        memberId:
          type: string
        payerName:
          type: string
        payerType:
          $ref: "#/components/schemas/PayerType"
      required:
        - memberId
        - payerName
        - payerType

    PatientInformation:
      type: object
      additionalProperties: false
      properties:
        dob:
          type: string
          format: date-time
        firstName:
          type: string
        lastName:
          type: string
      required:
        - dob

    PhysicianInformation:
      type: object
      additionalProperties: false
      properties:
        firstName:
          type: string
        lastName:
          type: string
        npi:
          type: string
          description: 10-digit NPI
      required:
        - firstName
        - lastName
        - npi

    ProcedureInformationItem:
      type: object
      additionalProperties: false
      properties:
        cptCode:
          type: string
          description: CPT code for the procedure
      required:
        - cptCode

    FacilityInformation:
      type: object
      additionalProperties: false
      properties:
        facilityName:
          type: string
        facilityNPI:
          type: string
          description: May be empty if not applicable
        facilityCode:
          type: string
      required:
        - facilityName
        - facilityNPI
        - facilityCode

    DecisionItem:
      type: object
      additionalProperties: false
      properties:
        cptCode:
          type: string
        payerName:
          type: string
        memberId:
          type: string
        status:
          $ref: "#/components/schemas/DecisionStatus"
        jobNumber:
          type: string
      required:
        - cptCode
        - payerName
        - memberId
        - status
        - jobNumber

    # ---------- Top-level request/response ----------
    DeterminationRequest:
      type: object
      additionalProperties: false
      properties:
        caseInformation:
          $ref: "#/components/schemas/CaseInformation"
        insuranceInformation:
          type: array
          minItems: 1
          items:
            $ref: "#/components/schemas/InsuranceInfo"
        patientInformation:
          $ref: "#/components/schemas/PatientInformation"
        physicianInformation:
          $ref: "#/components/schemas/PhysicianInformation"
        procedureInformation:
          type: array
          minItems: 1
          items:
            $ref: "#/components/schemas/ProcedureInformationItem"
        facilityInformation:
          $ref: "#/components/schemas/FacilityInformation"
      required:
        - caseInformation
        - insuranceInformation
        - patientInformation
        - procedureInformation

    DeterminationResponse:
      type: object
      additionalProperties: false
      properties:
        caseInformation:
          $ref: "#/components/schemas/CaseInformationResponse"
        decision:
          type: array
          items:
            $ref: "#/components/schemas/DecisionItem"
        insuranceInformation:
          type: array
          items:
            $ref: "#/components/schemas/InsuranceInfo"
        procedureInformation:
          type: array
          items:
            $ref: "#/components/schemas/ProcedureInformationItem"
      required:
        - caseInformation
        - decision
        - insuranceInformation
        - procedureInformation
