123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530 |
- import 'dart:async';
- import 'package:fis_jsonrpc/rpc.dart';
- import 'package:flutter/foundation.dart';
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import 'package:vitalapp/architecture/defines.dart';
- import 'package:vitalapp/architecture/network_connectivity.dart';
- import 'package:vitalapp/architecture/utils/prompt_box.dart';
- import 'package:vitalapp/components/appbar.dart';
- import 'package:vitalapp/global.dart';
- import 'package:vitalapp/helper/goto_helper.dart';
- import 'package:vitalapp/managers/interfaces/account.dart';
- import 'package:vitalapp/managers/interfaces/patient.dart';
- import 'package:vitalapp/pages/controllers/home_nav_mixin.dart';
- import 'package:vitalapp/pages/home/models/menu.dart';
- import 'package:vitalapp/pages/medical/widgets/twelve_ecg.dart';
- import 'package:vitalapp/store/store.dart';
- import 'package:vnote_device_plugin/consts/types.dart';
- import 'state.dart';
- class HomeController extends FControllerBase with HomeNavMixin {
- /// 仅支持在线模式的菜单路由
- static final _onlineOnlyMenuRouteNames = <String>[
- "/contract/package_list",
- "/check/form",
- ];
- static Widget _buildImgIcon(String assetName) {
- return ClipRect(
- child: SizedBox(
- height: 34,
- child: Image.asset(
- "assets/images/home/$assetName",
- width: 46,
- height: 46,
- fit: BoxFit.fitWidth,
- ),
- ),
- );
- }
- final _patientManager = Get.find<IPatientManager>();
- final state = HomeState();
- /// 当前选中路由
- int currentIndex = -1;
- List<HomeMenuItem> homeMenuItems = [
- HomeMenuItem(
- key: 'ZY',
- title: "主页",
- routeName: "/dashboard",
- iconData: Icons.home_outlined,
- ),
- HomeMenuItem(
- key: 'XJDA',
- title: "新建档案",
- routeName: "/patient/create",
- // TODO: 图addHealthRecord.png 不太合适,先层叠这样显示
- iconWidget: _PatientAddIconProxyWidget(
- baseIcon: _buildImgIcon('healthRecord.png'),
- ),
- ),
- HomeMenuItem(
- key: 'JKDA',
- title: "健康档案",
- routeName: "/patient/detail",
- iconWidget: _buildImgIcon('healthRecord.png'),
- ),
- HomeMenuItem(
- key: 'JMLB',
- title: "居民列表",
- routeName: "/patient/list",
- iconWidget: _buildImgIcon('patientList.png'),
- ),
- HomeMenuItem(
- key: 'YSQY',
- title: "医生签约",
- routeName: "/contract/package_list",
- iconWidget: _buildImgIcon('doctorSigning.png'),
- ),
- HomeMenuItem(
- key: 'JKTJ',
- title: "健康体检",
- routeName: "/check/form",
- iconWidget: _buildImgIcon('healthCheckup.png'),
- ),
- HomeMenuItem(
- key: 'RQSF',
- title: "人群随访",
- routeName: "/check/follow_up",
- iconWidget: _buildImgIcon('populationFollowUp.png'),
- ),
- HomeMenuItem(
- key: 'JKJC',
- title: "健康检测",
- routeName: "/medical",
- iconWidget: _buildImgIcon('diagnosisDisplay.png'),
- isSelected: true,
- ),
- HomeMenuItem(
- title: "中医体质",
- routeName: "/TraditionalChineseMedicineConstitution",
- key: "ZYTZ",
- iconWidget: _buildImgIcon("medicineConstitution.png"),
- isSelected: true,
- ),
- HomeMenuItem(
- key: 'TJDJ',
- title: "体检列表",
- routeName: "/registrationList",
- iconWidget: _PatientAddIconProxyWidget(
- baseIcon: _buildImgIcon('healthRecord.png'),
- ),
- ),
- HomeMenuItem(
- key: 'TJYY',
- title: "预约管理",
- routeName: "/appointment",
- iconWidget: _PatientAddIconProxyWidget(
- baseIcon: _buildImgIcon('diagnosisDisplay.png'),
- ),
- ),
- HomeMenuItem(
- key: 'TJJCJC',
- title: "基础检查",
- routeName: "/basicCheck",
- iconWidget: _PatientAddIconProxyWidget(
- baseIcon: _buildImgIcon('patientList.png'),
- ),
- ),
- HomeMenuItem(
- key: 'TJXD',
- title: "心电",
- routeName: "/electrocardiogram",
- iconWidget: _PatientAddIconProxyWidget(
- baseIcon: _buildImgIcon('populationFollowUp.png'),
- ),
- ),
- HomeMenuItem(
- key: 'TJNY',
- title: "尿常规",
- routeName: "/ncg",
- iconWidget: _PatientAddIconProxyWidget(
- baseIcon: _buildImgIcon('populationFollowUp.png'),
- ),
- ),
- HomeMenuItem(
- key: 'TJXCG',
- title: "血常规",
- routeName: "/bloodTest",
- iconWidget: _PatientAddIconProxyWidget(
- baseIcon: _buildImgIcon('populationFollowUp.png'),
- ),
- ),
- HomeMenuItem(
- key: 'TJSH',
- title: "生化",
- routeName: "/biochemistryTest",
- iconWidget: _PatientAddIconProxyWidget(
- baseIcon: _buildImgIcon('populationFollowUp.png'),
- ),
- ),
- // HomeMenuItem(
- // key: 'SZZX',
- // title: "设置中心",
- // routeName: "/settings",
- // iconData: Icons.settings,
- // ),
- HomeMenuItem(
- key: 'TJCS',
- routeName: '/remedicalRecordView',
- title: '超声',
- iconWidget: _PatientAddIconProxyWidget(
- baseIcon: _buildImgIcon('populationFollowUp.png'),
- ),
- ),
- // HomeMenuItem(
- // key: 'YCBG',
- // routeName: '/remedicalRecordView',
- // title: '异常报告',
- // iconWidget: _PatientAddIconProxyWidget(
- // baseIcon: _buildImgIcon('populationFollowUp.png'),
- // ),
- // ),
- ];
- /// 登出
- Future<void> logOut() async {
- final result = await Get.find<IAccountManager>().logout();
- if (result) {
- Get.offAllNamed("/login");
- }
- }
- // Future<void> changeMedical() async {
- // try {
- // Get.offAllNamed("/medical", id: 1001);
- // } catch (e) {}
- // }
- void onlineChanged(_, bool isOnline) {
- state.isOnline = isOnline;
- }
- @override
- void onInit() {
- initMenus();
- super.onInit();
- }
- initAddListener() {
- netChecker.onlineChangedEvent.addListener(onlineChanged);
- }
- netCheckerRemoveListener() {
- netChecker.onlineChangedEvent.removeListener(onlineChanged);
- }
- /// 切换活动菜单
- void switchActiveMenu(HomeMenuItem data) async {
- if (!kIsOnline) {
- // 无网络时,根据仅在线支持的菜单名单判断,进行阻断和提示
- if (_onlineOnlyMenuRouteNames.contains(data.routeName)) {
- PromptBox.toast("请检查网络连接");
- return;
- }
- }
- if (state.currentSelectMenu != data.routeName) {
- switchNavByName(data.routeName);
- }
- }
- void switchNavByName(String name, [Map? patientInfo]) {
- state.currentSelectMenu = name;
- NavGotoHelper.goto(name, patientInfo);
- }
- void initMenus() {
- if (Store.user.menuPermissionList?.isNotEmpty ?? false) {
- List<HomeMenuItem> menuItems = [];
- Store.user.menuPermissionList?.forEach((element) {
- for (var item in homeMenuItems) {
- if (item.key == element.code) {
- menuItems.add(item);
- }
- }
- });
- if (!menuItems.any((element) => element.key == "JKJC")) {
- state.currentSelectMenu = menuItems.first.routeName;
- }
- state.menuItems = menuItems;
- } else {
- // state.menuItems = homeMenuItems;
- state.menuItems = [
- HomeMenuItem(
- key: 'XJDA',
- title: "新建档案",
- routeName: "/patient/create",
- // TODO: 图addHealthRecord.png 不太合适,先层叠这样显示
- iconWidget: _PatientAddIconProxyWidget(
- baseIcon: _buildImgIcon('healthRecord.png'),
- ),
- ),
- HomeMenuItem(
- key: 'JMLB',
- title: "居民列表",
- routeName: "/patient/list",
- iconWidget: _buildImgIcon('patientList.png'),
- ),
- HomeMenuItem(
- key: 'JKDA',
- title: "健康档案",
- routeName: "/patient/detail",
- iconWidget: _buildImgIcon('healthRecord.png'),
- ),
- HomeMenuItem(
- key: 'JKJC',
- title: "健康检测",
- routeName: "/medical",
- iconWidget: _buildImgIcon('diagnosisDisplay.png'),
- ),
- // HomeMenuItem(
- // key: 'SZZX',
- // title: "设置中心",
- // routeName: "/settings",
- // iconData: Icons.settings,
- // ),
- ];
- }
- }
- void updateMenus() {
- if (Store.user.menuPermissionList?.isNotEmpty ?? false) {
- List<HomeMenuItem> menuItems = [];
- Store.user.menuPermissionList?.forEach((element) {
- for (var item in homeMenuItems) {
- if (item.key == element.code) {
- menuItems.add(item);
- }
- }
- });
- // if (kDebugMode && !menuItems.any((element) => element.key == 'FSZD')) {
- // menuItems.add(
- // HomeMenuItem(
- // key: 'FSZD',
- // routeName: '/remedicalRecordView',
- // title: '分时诊断',
- // iconWidget: _PatientAddIconProxyWidget(
- // baseIcon: _buildImgIcon('healthRecord.png'),
- // ),
- // ),
- // );
- // }
- // menuItems.add(homeMenuItems.firstWhere((x) => x.key == "ZYTZ"));
- state.menuItems = menuItems;
- } else {
- // state.menuItems = homeMenuItems;
- state.menuItems = [
- HomeMenuItem(
- key: 'XJDA',
- title: "新建档案",
- routeName: "/patient/create",
- // TODO: 图addHealthRecord.png 不太合适,先层叠这样显示
- iconWidget: _PatientAddIconProxyWidget(
- baseIcon: _buildImgIcon('healthRecord.png'),
- ),
- ),
- HomeMenuItem(
- key: 'JMLB',
- title: "居民列表",
- routeName: "/patient/list",
- iconWidget: _buildImgIcon('patientList.png'),
- ),
- HomeMenuItem(
- key: 'JKDA',
- title: "健康档案",
- routeName: "/patient/detail",
- iconWidget: _buildImgIcon('healthRecord.png'),
- ),
- HomeMenuItem(
- key: 'JKJC',
- title: "健康检测",
- routeName: "/medical",
- iconWidget: _buildImgIcon('diagnosisDisplay.png'),
- ),
- // HomeMenuItem(
- // key: 'SZZX',
- // title: "设置中心",
- // routeName: "/settings",
- // iconData: Icons.settings,
- // ),
- ];
- }
- }
- void onScanData(String code) async {
- print('$code');
- RegisterPersonInfoDTO? registerPersonInfo =
- await _patientManager.getRegisterPersonInfoByPhysicalExamNumberAsync(
- physicalExamNumber: code,
- );
- PatientDTO? patientInfo = PatientDTO();
- if (registerPersonInfo != null &&
- registerPersonInfo.physicalExamNumber != null) {
- patientInfo.code = registerPersonInfo.code;
- patientInfo.patientName = registerPersonInfo.name;
- Store.user.currentSelectRegisterPersonInfo = registerPersonInfo;
- Store.user.currentSelectPatientInfo = patientInfo;
- }
- Get.back();
- onScanSwitchPage(state.currentSelectMenu);
- print(state.currentSelectMenu);
- }
- void onScanSwitchPage(String routeName) {
- switch (routeName) {
- case "/electrocardiogram":
- Get.dialog(_buildMedical());
- return;
- }
- }
- Widget _buildMedical() {
- return Scaffold(
- appBar: VAppBar(
- titleText: "体检心电",
- ),
- body: Container(
- color: Colors.white,
- child: Stack(
- children: [
- Row(
- children: [
- _buildDeviceImage(DeviceTypes.TWELVEHEART),
- _buildMedicalInput(DeviceTypes.TWELVEHEART),
- ],
- ),
- Positioned(
- right: 16,
- bottom: 16,
- child: _buildSaveButton(),
- ),
- ],
- ),
- ),
- );
- }
- Widget _buildMedicalInput(String? currentTab) {
- return Expanded(
- flex: currentTab == DeviceTypes.TWELVEHEART ? 18 : 11,
- child: Stack(
- children: [
- Container(
- padding: const EdgeInsets.all(16),
- child: Column(
- children: [
- _buildContent(),
- ],
- ),
- ),
- ],
- ),
- );
- }
- String _deviceImageUrl(String? currentTab) {
- switch (currentTab) {
- case DeviceTypes.TEMP:
- return 'assets/images/healthCheck/temp.png';
- case DeviceTypes.SUGAR:
- return 'assets/images/healthCheck/sugar.png';
- case DeviceTypes.NIBP:
- return 'assets/images/healthCheck/nibp.png';
- case DeviceTypes.SPO2:
- return 'assets/images/healthCheck/spo2.png';
- case DeviceTypes.WEIGHT:
- return 'assets/images/healthCheck/bmi.png';
- case DeviceTypes.URINE:
- return 'assets/images/healthCheck/urine.png';
- case DeviceTypes.WAIST:
- return 'assets/images/healthCheck/whb.png';
- default:
- return 'assets/images/exam/normalMeasurementChart.png';
- }
- }
- Widget _buildDeviceImage(String? currentTab) {
- if (currentTab == DeviceTypes.TWELVEHEART) {
- return const SizedBox();
- }
- return Expanded(
- flex: 7,
- child: Container(
- alignment: Alignment.topCenter,
- margin: const EdgeInsets.all(16).copyWith(top: 10),
- child: SizedBox(),
- ),
- );
- }
- Widget _buildSaveButton() {
- return Obx(() {
- if (Store.user.currentSelectRegisterPersonInfo == null) {
- return const SizedBox();
- }
- return FloatingActionButton.extended(
- // backgroundColor: Theme.of(context).primaryColor,
- onPressed: () {
- // advanceDebounce(
- // () => controller.createHeart(
- // Store.user.currentSelectRegisterPersonInfo?.physicalExamNumber ??
- // '',
- // 'HEIECG',
- // ),
- // "createCheckup",
- // 1500,
- // );
- },
- label: const SizedBox(
- width: 240,
- height: 60,
- child: Center(
- child: Text(
- '提交',
- style: TextStyle(
- fontSize: 26,
- color: Colors.white,
- ),
- ),
- ),
- ),
- );
- });
- }
- Widget _buildContent() {
- return const TwelveHeartRate();
- }
- }
- class _PatientAddIconProxyWidget extends StatelessWidget {
- final Widget baseIcon;
- const _PatientAddIconProxyWidget({
- Key? key,
- required this.baseIcon,
- }) : super(key: key);
- @override
- Widget build(BuildContext context) {
- return Stack(
- children: [
- baseIcon,
- const Positioned(
- right: 0,
- top: 0,
- child: Icon(
- Icons.add,
- size: 16,
- color: Colors.white,
- ),
- )
- ],
- );
- }
- }
|