import 'package:fis_jsonrpc/rpc.dart';
import 'package:flyinsono/architecture/storage/file_storage.dart';
import 'package:flyinsono/managers/report_manager.dart';
import 'package:flyinsono/pages/remedical/report/report_edit/entitys/report_tag_key.dart';
import 'package:fis_common/event/event_type.dart';
import 'entities/reportEditSource.dart';
import 'entities/report_element_info.dart';
import 'package:fis_measure/process/workspace/rpc_bridge.dart';

abstract class IReportManager {
  FileStorage get fileStorage => FileStorage.createInstance("remedical/report");

  ///编辑报告点击事件
  final onEditReport = FEventHandler<String>();

  ///提交报告事件
  final onSubmitReport = FEventHandler<bool>();

  ///手机端提交报告
  final onMobileSubmitReport = FEventHandler<bool>();

  ///语音识别
  Future<String> commitASRInfoAsync(String token, String extension);

  ///下载
  Future<void> directlyDownloadPDF(String reportCode, String fileName);

  ///直接打印文档
  Future<void> directlyPrintPDF(String reportCode, String fileName);

  ///打印图像
  Future<void> directlyPrintPDFJpges(List<String>? images, String fileName);

  ///打印文件（通过下载地址）
  Future<void> directlyPrintPDFFile(String fileUrl, String fileName);

  ///下载图像格式 PDF
  Future<void> directlyDownloadPDFJpges(List<String>? images, String fileName);

  ///下载文件格式 PDF
  Future<void> directlyDownloadPDFFile(String pdfFileUrl, String fileName);

  ///报告分享
  Future<bool> openReportShareDialog(String? reportToShare);

  ///获取所有报告
  Future<List<ReportDTO>> findReportsAsync(String recordCode);

  Future<ReportDTO> findReportByCodeAsync(String reportCode);

  Future<List<ReportDTO>> getReportInfoAsync(String recordCode);

  Future<String> getReportTemplate();

  ///提交报告标签
  Future<bool> submitReportTags(String reportCode, List<String> selectedTags);

  ///初始化标签所需数据
  ///
  /// [reportType] 默认值远程诊断
  Future<Map<ReportTagKey, List<String>>> getReportTagDatas(
    String recordCode, [
    ReportTypeEnum? reportType,
  ]);

  void enterVidMeasurePage({
    String imageUrl = '',
    int imageindex = 0,
    String remedicalCode = '',
    String patientCode = '',
    String recordCode = '',
    VidImageSource source = VidImageSource.Consultation,
    String? remedicalAISelectedInfoCode = '',
    bool needRouterBack = false,
    bool reportPageEnter = false,
  });

  ///获取报告提交内容信息Json
  String getMobileReportDatasJson({
    String? patientName,
    String? patientSex,
    String? age,
    List<String>? imageInfos,
    String? des,
    String? summary,
    String? creatorName,
    String? fullName,
    String? customDoctor,
    String? customOrganzation,
    String? deviceOrganzationName,
  });

  String getTime(String time);

  /// 根据扫查记录获取转诊扫查图像详情
  Future<RemedicalListResult> queryReferralRemedicalListByRecordInfoAsync(
      String recordCode, String referralRecordCode);

  ///获取分享报告链接
  Future<String> findReportShareUrlAsync(String reportCode);

  ///手机端底部弹窗选择分享方式
  Future<bool> showBottomSheet(ReportDTO reportInfo);

  ///注册微信分享api
  void initFluwx();

  ///打开报告编辑页面
  Future<void> openReportEdit(
    String patientCode, {
    String consultationCode = '',
    String recordCode = '',
    String reportCode = '',
    int patientTab = 0,
    String referralRecordCode = '',
    ReportEditSource reportEditSource = ReportEditSource.VSono,
  });

  Future<RemedicalListResult> getRemedicalListByRecordInfoAsync(
      String recordCode);

  ///打开报告预览页面
  Future<void> openReportPreviewPage(
    String recordCode,
    String referralRecordCode, {
    String reportCode = '',
  });

  ///获取测量图像
  Future<List<RemedicalMeasuredInfoDTO>> findRemedicalMeasuredInfoAsync(
    String recordCode, {
    BusinessTypeEnum businessTypeEnum = BusinessTypeEnum.RemoteDiagnosis,
  });

  List<FReportElementInfo> convertReportData(String jsonData);
}
