import 'package:fis_jsonrpc/rpc.dart';
import 'package:fis_ui/index.dart';
import 'package:flyinsono/views/desktop/real_time_consultation/widgets/simple_Info.dart';
import 'package:fis_common/index.dart';
import 'package:fis_common/logger/logger.dart';
import 'package:fis_i18n/i18n.dart';
import 'package:universal_html/html.dart' as html;
import 'package:fis_ui/base_define/page.dart';
import 'package:fis_common/event/event_type.dart';
import 'package:fis_theme/theme.dart';
import 'package:fis_ui/index.dart';
import 'package:fis_jsonrpc/rpc.dart';
import 'package:fis_common/helpers/encrypt.dart';
import 'entities/patient_Info.dart';
import 'entities/process_arg.dart';

abstract class IRemedicalManager {
  final processChange = FEventHandler<ProcessArg>();

  ///查找病人列表
  Future<PageResult<ClientPatientInfoBaseDTO>> findPatients({
    int pageIndex = 1,
    int pageSize = 20,
    String keyWord = '',
    DateTime? startDateTime,
    DateTime? endDateTime,
    PatientValidStatusEnum isValid = PatientValidStatusEnum.All,
  });

  ///实体转换为可提交至接口的病人信息
  List<DataItemDTO>? convertPatientInfoToPatientDatas(PatientInfo? patientInfo);

  /// 根据后端接口的key值取到对应的value
  ///
  /// [patientData] 后端数据
  ///
  /// [keys] 对应的Key值
  String getKeyValue(
    List<DataItemDTO> patientData,
    List<String> keys,
  );

  ///创建病人
  Future<bool> createPatientByUnregisteredAsync(String patientName,
      {String? code});

  ///查找病人列表
  Future<List<SimpleInfoItem>> findSimpleInfoPatients({
    int pageIndex = 1,
    int pageSize = 20,
    String keyWord = '',
    DateTime? startDateTime,
    DateTime? endDateTime,
    PatientValidStatusEnum isValid = PatientValidStatusEnum.All,
    bool isCounsultationPatient = false,
  });

  ///病人信息DTO转实体类
  PatientInfo dtoConvertToPatientInfo(ClientPatientInfoDTO dto);

  ///查找病人详情
  Future<ClientPatientInfoDTO> findPatientByCode(
    String patientCode,
  );

  ///未登记关联创建病人（返回病人code）
  Future<String> createUnregisteredPatient(String patientName, {String? code});

  /// 获取检查部位
  Future<List<FSelectModel>> findScanPositions();

  ///查找测量图像
  Future<List<RemedicalMeasuredInfoDTO>> findRemedicalMeasuredInfoAsync(
      String recordCode,
      {BusinessTypeEnum businessType = BusinessTypeEnum.RemoteDiagnosis});

  ///查找AI图像
  Future<List<RemedicalAISelectedInfoDTO>> findAIImages(
      String recordCode, String patientId);

  ///打开图像测量页面
  void openImageMeasurePage(
    String imageUrl,
    int imageindex,
    String remedicalCode,
    String recordCode,
    String? remedicalAISelectedInfoCode,
    String patientCode,
  );

  ///查找检查报告
  Future<List<ReportDTO>> findExamReports(String recordCode);

  Future<QueryRecordResult?> queryRecordInfoAsync(String recordCode);

  ///检查是否有颈动脉图像
  bool checkCarotidList(
      RemedicalItemList remedicalItem, CarotidScanTypeEnum scanTypeEnum);

  ///查找检查记录页面
  Future<PageResult<SimpleRecordInfoDTO>> findRecordPages({
    List<String>? organizationCodes,
    List<String>? deviceCodes,
    RecordQueryStateEnum recordQueryState = RecordQueryStateEnum.All,
    RecordProcessStateEnum recordProcessState = RecordProcessStateEnum.All,
    String? keyWord,
    DateTime? startTime,
    DateTime? endTime,
    String patientCode,
    int pageIndex = 1,
    int pageSize = 20,
  });

  Future<RemedicalInfoDTO> findRemedicalByCode(String remedicalCode);
}
