def service_item(service, status, openapi, endpoints):
    """Function that sets the correct structure for service item
    If status=='OK' and openapi is empty then:
      * it is REST X-Road service that does not have a description;
      * endpoints array is empty.
    If status=='OK' and openapi is not empty then:
      * it is OpenAPI X-Road service with description;
      * at least one endpoint must be present in OpenAPI description.
    In other cases status must not be 'OK' to indicate problem with
    the service.
    """
    return {
        'serviceCode': service[4],
        'status': status,
        'openapi': openapi,
        'endpoints': endpoints
    }