registerSelfcheckAnswer method

  1. @override
Future<bool> registerSelfcheckAnswer(
  1. {required String rehabilitationId,
  2. required int version,
  3. required FormType formType,
  4. required List<String> answers}
)
override

問診の回答を登録する。

登録が成功した時、リハビリ可否の結果を返す。

Implementation

@override
Future<bool> registerSelfcheckAnswer({
  required String rehabilitationId,
  required int version,
  required FormType formType,
  required List<String> answers,
}) async {
  try {
    final addRehabilitationTakeFormRequest = AddRehabilitationTakeFormRequest(
      ((b) {
        b
          ..rehabilitationID = rehabilitationId
          ..ver = version
          ..type = formType.number
          ..answers = ListBuilder(answers);
      }),
    );

    final result = await _client.addRehabilitationTakeFormPost(
      addRehabilitationTakeFormRequest: addRehabilitationTakeFormRequest,
    );
    final resultData = result.data;

    if (resultData == null) {
      throw RepositoryException(
        RepositoryErrorType.notFound,
        RepositoryErrorType.notFound.message,
      );
    }

    return resultData.addRehabilitationTakeFormResult;
  } on RepositoryException catch (_) {
    rethrow;
  } on DioException catch (error, stackTrace) {
    throw await _dioErrorHandler.handleDioError(
      error,
      stackTrace,
      rehabilitationId,
    );
  } catch (error, stackTrace) {
    throw _repositoryErrorHandler.handleUnknownError(error, stackTrace);
  }
}