device_manager.api.exam_requests#

Handler for protocol requests.

This module defines functions to interact with the protocol manager service, including fetching tasks, sequences, and results. It provides a way to create and update acquisition tasks and results, ensuring that the data is properly formatted and authenticated.

Copyright (C) 2023, BRAIN-LINK UG (haftungsbeschränkt). All Rights Reserved. SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-ScanHub-Commercial

Attributes#

Functions#

get_task(→ scanhub_libraries.models.AcquisitionTaskOut)

Fetch acquisition task by ID from the protocol manager service.

set_task(→ scanhub_libraries.models.AcquisitionTaskOut)

Update an acquisition task on the task service with the provided payload.

get_sequence(→ scanhub_libraries.models.MRISequenceOut)

Fetch MRI sequence by ID from the protocol manager service.

create_blank_result(→ scanhub_libraries.models.ResultOut)

Create a blank result in the protocol manager service.

delete_blank_result(→ None)

Delete a blank result in the protocol manager service.

set_result(→ scanhub_libraries.models.ResultOut)

Update a result in the protocol manager service.

update_task_status(...)

Update only the status field of a task.

get_result(→ scanhub_libraries.models.ResultOut)

Fetch result by ID from the protocol manager service.

Module Contents#

device_manager.api.exam_requests.TASK_URI = 'http://protocol-manager:8000/api/v1/protocol/task'#
device_manager.api.exam_requests.RESULT_URI = 'http://protocol-manager:8000/api/v1/protocol/result'#
device_manager.api.exam_requests.SEQUENCE_URI = 'http://protocol-manager:8000/api/v1/protocol/sequence'#
device_manager.api.exam_requests.get_task(task_id: str, user_access_token: str) → scanhub_libraries.models.AcquisitionTaskOut#

Fetch acquisition task by ID from the protocol manager service.

Parameters:
Returns:

AcquisitionTaskOut | None

Return type:

The acquisition task object if found and valid.

Raises:

HTTPException – If the task is not found (404) or is not an acquisition task (400).:

device_manager.api.exam_requests.set_task(task_id: str, payload: scanhub_libraries.models.AcquisitionTaskOut, user_access_token: str) → scanhub_libraries.models.AcquisitionTaskOut#

Update an acquisition task on the task service with the provided payload.

Parameters:
  • task_id (str) – The unique identifier of the task to update.

  • payload (AcquisitionTaskOut) – The updated task data to send to the task service.

  • user_access_token (str) – The access token used for authorization with the task service.

Returns:

The updated task object returned from the task service.

Return type:

AcquisitionTaskOut

Raises:

HTTPException – If the task update fails (e.g. non-200 response from the task service).

device_manager.api.exam_requests.get_sequence(sequence_id: str, user_access_token: str) → scanhub_libraries.models.MRISequenceOut#

Fetch MRI sequence by ID from the protocol manager service.

Parameters:
Returns:

dict

Return type:

The MRI sequence object if found.

Raises:

HTTPException – If the sequence is not found (404).:

device_manager.api.exam_requests.create_blank_result(task_id: str, user_access_token: str) → scanhub_libraries.models.ResultOut#

Create a blank result in the protocol manager service.

Returns:

ResultOut

Return type:

The created blank result object.

Raises:

HTTPException – If the result creation fails (status code not 201).:

device_manager.api.exam_requests.delete_blank_result(result_id: str, user_access_token: str) → None#

Delete a blank result in the protocol manager service.

Parameters:
Return type:

None

Raises:

HTTPException – If the result deletion fails (status code not 204).:

device_manager.api.exam_requests.set_result(result_id: str, payload: scanhub_libraries.models.SetResult, user_access_token: str) → scanhub_libraries.models.ResultOut#

Update a result in the protocol manager service.

Parameters:
Returns:

ResultOut

Return type:

The updated result object.

Raises:

HTTPException – If the result update fails (status code not 200).:

device_manager.api.exam_requests.update_task_status(task_id: str, status: str, user_access_token: str) → scanhub_libraries.models.AcquisitionTaskOut#

Update only the status field of a task.

device_manager.api.exam_requests.get_result(result_id: str, user_access_token: str) → scanhub_libraries.models.ResultOut#

Fetch result by ID from the protocol manager service.

Parameters:
Returns:

ResultOut | None

Return type:

The result object if found and valid.

Raises:

HTTPException – If the result is not found (404).: