subscription TicketsUpdated {
  ticketsUpdated {
    count
  }
}

query GetTicketStateMeta($state: TicketValidationState!) {
  ticketStateMeta(state: $state) {
    count
    approvalUnknownCount
    approvalRequiredCount
    tdNotCompanyCount
    approvalNotCompanyCount
  }
}

query SearchTickets($query: String!) {
  searchTickets(query: $query) {
    id
    currentState
    approvalState
    errors
    notes
    isUrgent
    urgency
    documentInfo {
      tdLocation
      approval {
        isNeeded
        whoRequested
        answeredFrom
        location
      }
    }
    createdAt
    tours {
      id
      done
      direction
      carName
      operationId
      driverName
      codriverName
      patientName
      patientSurname
      patientStreet
      patientZip
      patientCity
      healthInsurance
      category
      transportType
      ordinanceType
      startStreet
      startZip
      startCity
      targetStreet
      targetZip
      targetCity
      startDate
      check
      occupiedKm
      totalKm
      type
      rangeEndDate
      startBegin
      startEnd
      target
      targetBegin
      empty
      billDate
      billNumber
      consumptionCosts
      revenue
      revenueDispoLive
      startInstitution
      targetInstitution
      ticketId
    }
  }
}

query GetTickets($state: TicketValidationState!, $filters: TicketFilterArgs, $cursor: String, $take: Int) {
  tickets(state: $state, filters: $filters, cursor: $cursor, take: $take) {
    prevCursor
    endCursor
    hasNextPage
    totalCount
    nodes {
      id
      currentState
      approvalState
      errors
      notes
      isUrgent
      urgency
      documentInfo {
        tdLocation
        approval {
          isNeeded
          whoRequested
          answeredFrom
          location
        }
      }
      createdAt
      tours {
        id
        done
        direction
        carName
        operationId
        driverName
        codriverName
        patientName
        patientSurname
        patientStreet
        patientZip
        patientCity
        healthInsurance
        category
        transportType
        ordinanceType
        startStreet
        startZip
        startCity
        targetStreet
        targetZip
        targetCity
        startDate
        check
        occupiedKm
        totalKm
        type
        rangeEndDate
        startBegin
        startEnd
        target
        targetBegin
        empty
        billDate
        billNumber
        consumptionCosts
        revenue
        revenueDispoLive
        startInstitution
        targetInstitution
        ticketId
        ticket {
          currentState
        }
      }
    }
  }
}

mutation SetDocumentInfo(
  $ticketId: String!
  $approval: ApprovalInfoArgs
  $tdLocation: String
) {
  setDocumentInfo(
    ticketId: $ticketId
    approval: $approval
    tdLocation: $tdLocation
  ) {
    id
    currentState
    approvalState
    errors
    notes
    isUrgent
    urgency
    documentInfo {
      tdLocation
      approval {
        isNeeded
        whoRequested
        answeredFrom
        location
      }
    }
    createdAt
    tours {
      id
      done
      direction
      carName
      operationId
      driverName
      codriverName
      patientName
      patientSurname
      patientStreet
      patientZip
      patientCity
      healthInsurance
      category
      transportType
      ordinanceType
      startStreet
      startZip
      startCity
      targetStreet
      targetZip
      targetCity
      startDate
      check
      occupiedKm
      totalKm
      type
      rangeEndDate
      startBegin
      startEnd
      target
      targetBegin
      empty
    }
  }
}
