import 'package:fis_i18n/i18n.dart';
import 'package:fis_jsonrpc/rpc.dart';
import 'package:fis_ui/index.dart';
import 'package:flutter/material.dart';
import 'package:flyinsono/architecture/define.dart';
import 'package:flyinsono/managers/interfaces/report.dart';
import 'package:flyinsono/pages/remedical/consultation/controller.dart';
import 'package:flyinsono/pages/remedical/consultation/widgets/inspection_record_card.dart';
import 'package:get/get.dart';

///最近诊断记录UI
class LastRecord extends FisView<ConsultationController> {
  final reportManager = Get.find<IReportManager>();

  @override
  FWidget build(BuildContext context) {
    return FObx(
      () {
        GetRecordsPageDTO lastRecord = controller.state.lastRecord;
        return FColumn(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            FContainer(
              color: Colors.white,
              margin: EdgeInsets.only(
                top: 15,
                left: 15,
              ),
              child: FText(
                i18nBook.remedical.recentCheck.t,
                style: TextStyle(
                  fontSize: 18,
                  fontWeight: FontWeight.bold,
                ),
              ),
            ),
            FContainer(
              child: BuildCheckRecordCard(
                time: reportManager.getTime(
                  lastRecord.createTime.toString(),
                ),
                distributionEquipment:
                    lastRecord.displayName ?? i18nBook.homePage.notYet.t,
                department: lastRecord.deptName ?? i18nBook.homePage.notYet.t,
                examiningDoctor: lastRecord.creatorName != null
                    ? lastRecord.creatorName
                    : i18nBook.homePage.notYet.t,
                reportsNum: int.parse(lastRecord.reportNum ?? ""),
                recordCode: lastRecord.recordCode ?? i18nBook.homePage.notYet.t,
                recordStatus: lastRecord.recordStatus,
                remedicalList: lastRecord.remedicalList,
                diagnosisInfos: lastRecord.diagnosisInfos,
                isReferral: lastRecord.isReferral,
                referralStatus: lastRecord.referralStatus,
                canCreateReport: lastRecord.canCreateReport,
                deviceCode: lastRecord.deviceCode,
                canStartImgCollecting: lastRecord.canCollcetImg,
                index: 0,
              ),
            ),
          ],
        );
      },
    );
  }
}
