Parcourir la source

新增报告模板的选择

loki.wu il y a 9 mois
Parent
commit
bbc5fcfcdb

+ 2 - 0
lib/managers/interfaces/report_template.dart

@@ -9,6 +9,8 @@ abstract class IReportTemplateManager {
     int pageIndex = 1,
     int pageSize = 100,
     String? keyword,
+    ReportTemplateBusinessTypeEnum businessType =
+        ReportTemplateBusinessTypeEnum.HEIUltrasonic,
   });
 
   ///获取机构报告模板

+ 5 - 1
lib/managers/report_template_manager.dart

@@ -24,15 +24,19 @@ class ReportTemplateManager extends BaseManager
     int pageIndex = 1,
     int pageSize = 100,
     String? keyword,
+    ReportTemplateBusinessTypeEnum businessType =
+        ReportTemplateBusinessTypeEnum.HEIUltrasonic,
+    String languageCode = "zh-CN",
   }) async {
     try {
       var result = await rpc.ultrasoundReport.vitalGetReportTemplatePageAsync(
         FindReportTemplatePagesRequest(
           token: token,
-          languageCode: i18nBook.locale.toCodeString('-'),
+          languageCode: languageCode,
           reportTemplateName: keyword,
           pageIndex: pageIndex,
           pageSize: pageSize,
+          businessType: businessType,
         ),
       );
       return result;

+ 105 - 16
lib/pages/ecg/ecg_result_view.dart

@@ -15,6 +15,7 @@ import 'package:vitalapp/components/dropdown_button.dart';
 import 'package:vitalapp/components/no_data_view.dart';
 import 'package:vitalapp/components/select.dart';
 import 'package:vitalapp/managers/interfaces/exam.dart';
+import 'package:vitalapp/managers/interfaces/report_template.dart';
 import 'package:vitalapp/pages/medical/controller.dart';
 import 'package:vitalapp/pages/medical/models/worker.dart';
 import 'package:vitalapp/pages/medical/widgets/device_status_position.dart';
@@ -52,8 +53,10 @@ class EcgResultViewState extends State<EcgResultView> {
   final _tAxisController = TextEditingController();
   final _pDurController = TextEditingController();
   final _tDurController = TextEditingController();
-  double paperSpeed = 25.0;
-  int gain = 5;
+  double _paperSpeed = 25.0;
+  int _gain = 5;
+  List<ReportTemplateDTO> _templates = [];
+  ReportTemplateDTO _currentSelectedTemplate = ReportTemplateDTO();
 
   /// 初始时的心电初始数据
   List<int> _initEcgDatas = [];
@@ -62,6 +65,17 @@ class EcgResultViewState extends State<EcgResultView> {
   void initState() {
     String examData = widget.recordInfo.examData ?? '';
     if (examData.isNotEmpty) {
+      Get.find<IReportTemplateManager>()
+          .getReportTemplatePage(
+              businessType: ReportTemplateBusinessTypeEnum.HEIECG)
+          .then((result) {
+        setState(() {
+          _templates = result.pageData ?? [];
+          if (_templates.isNotEmpty) {
+            _currentSelectedTemplate = _templates.first;
+          }
+        });
+      });
       Map<String, dynamic> examDatas = jsonDecode(examData);
       if (examDatas.containsKey("ECG_POINT12")) {
         String exgPoint12Url = examDatas["ECG_POINT12"].toString();
@@ -204,21 +218,21 @@ class EcgResultViewState extends State<EcgResultView> {
                                   id: "twelve_ecg_view",
                                   builder: (_) {
                                     return FullScreenEcgDataDialog(
-                                      height: kIsWeb ? 560 : 655,
+                                      height: kIsWeb ? 560 : 610,
                                       showHeader: false,
                                       widthScale: 1,
                                       hintFontSize: 14,
                                     );
                                   }),
                               Positioned(
-                                top: 90,
-                                left: 40,
+                                top: 70,
+                                left: 20,
                                 child: Row(
                                   children: [
                                     SizedBox(width: 25),
                                     _buildKeyValue(
                                       "",
-                                      "1.6-2.0 Hz",
+                                      "1.6Hz",
                                       fontSize: 14,
                                     ),
                                     SizedBox(width: 15),
@@ -273,7 +287,6 @@ class EcgResultViewState extends State<EcgResultView> {
         _hrController.text = heartRate12;
       }
     }
-    final gapHeight = 5.0;
     return Row(
       mainAxisAlignment: MainAxisAlignment.spaceBetween,
       children: [
@@ -281,7 +294,6 @@ class EcgResultViewState extends State<EcgResultView> {
           child: Column(
             crossAxisAlignment: CrossAxisAlignment.start,
             children: [
-              SizedBox(height: gapHeight),
               Row(
                 children: [
                   SizedBox(width: 10),
@@ -296,11 +308,11 @@ class EcgResultViewState extends State<EcgResultView> {
                         itemToString: (v) {
                           return v.toString();
                         },
-                        initialValue: paperSpeed,
+                        initialValue: _paperSpeed,
                         onChanged: (value) {
-                          paperSpeed = value;
+                          _paperSpeed = value;
                           Get.find<TwelveEcgViewController>()
-                              .changeHorizontalRatio(paperSpeed / 25);
+                              .changeHorizontalRatio(_paperSpeed / 25);
                         },
                       ),
                       Text(
@@ -322,10 +334,10 @@ class EcgResultViewState extends State<EcgResultView> {
                         itemToString: (v) {
                           return v.toString();
                         },
-                        initialValue: gain,
+                        initialValue: _gain,
                         onChanged: (value) {
-                          gain = value;
-                          int radio = gain ~/ 5;
+                          _gain = value;
+                          int radio = _gain ~/ 5;
                           List<int> tempDatas = [];
                           for (int p in _initEcgDatas) {
                             tempDatas.add(p * radio);
@@ -350,6 +362,47 @@ class EcgResultViewState extends State<EcgResultView> {
                   SizedBox(width: 10),
                 ],
               ),
+              Row(
+                children: [
+                  SizedBox(width: 10),
+                  _buildKeyValue("姓名:", widget.recordInfo.patientName ?? ''),
+                  SizedBox(width: 10),
+                  _buildKeyValue("性别:",
+                      patientGenderConvertAge(widget.recordInfo.patientGender)),
+                  SizedBox(width: 10),
+                  _buildKeyValue(
+                      "年龄:", birthDayConvertAge(widget.recordInfo.birthday)),
+                  SizedBox(width: 10),
+                  if (_templates.isNotEmpty) ...[
+                    Text(
+                      "模板:",
+                      style: TextStyle(fontSize: 20),
+                    ),
+                    GenericDropdownButton<ReportTemplateDTO>(
+                      items: _templates,
+                      initialValue: _currentSelectedTemplate,
+                      itemToString: (t) {
+                        return t.reportTemplateName ?? '';
+                      },
+                      onChanged: (v) {
+                        _currentSelectedTemplate = v;
+                      },
+                    ),
+                  ],
+                  SizedBox(
+                    width: 40,
+                  ),
+                  SizedBox(
+                    child: Text(
+                      "若需要更改图像截取范围,请滑动下方的滑动条",
+                      style: TextStyle(
+                        fontSize: 15,
+                      ),
+                    ),
+                  ),
+                ],
+              ),
+              //SizedBox(height: 5,)
             ],
           ),
         ),
@@ -358,15 +411,51 @@ class EcgResultViewState extends State<EcgResultView> {
           children: [
             Text(
               "诊断提示:",
-              style: TextStyle(fontSize: 20),
+              style: TextStyle(fontSize: 16),
             ),
-            Expanded(child: SizedBox()),
           ],
         ),
       ],
     );
   }
 
+  String patientGenderConvertAge(GenderEnum patientGender) {
+    switch (patientGender) {
+      case GenderEnum.Male:
+        return "男";
+      case GenderEnum.Female:
+        return "女";
+      default:
+        return "";
+    }
+  }
+
+  String birthDayConvertAge(DateTime? birthday) {
+    if (birthday == null) {
+      return "";
+    }
+    // 获取当前日期
+    DateTime now = DateTime.now();
+
+    // 计算年龄
+    int age = calculateAge(birthday, now);
+
+    return age.toString();
+  }
+
+  int calculateAge(DateTime birthDate, DateTime now) {
+    // 计算年份差
+    int age = now.year - birthDate.year;
+
+    // 检查生日是否已经过了当前年份
+    if (now.month < birthDate.month ||
+        (now.month == birthDate.month && now.day < birthDate.day)) {
+      age--;
+    }
+
+    return age;
+  }
+
   Widget _buildKeyValue(
     String key,
     String value, {

+ 7 - 5
lib/pages/medical/widgets/twelve_ecg_view/widgets/full_screen_ecg_data_dialog.dart

@@ -38,11 +38,13 @@ class FullScreenEcgDataDialog extends GetView<TwelveEcgViewController> {
         clipBehavior: Clip.antiAlias,
         child: Column(
           children: [
-            if (showHeader) _buildHead(),
-            Text(
-              "当前默认截取心电图像的最后5s作为报告图像,若需要更改图像截取范围,请滑动下方的滑动条,来修改截取范围。",
-              style: TextStyle(fontSize: hintFontSize),
-            ),
+            if (showHeader) ...[
+              _buildHead(),
+              Text(
+                "当前默认截取心电图像的最后5s作为报告图像,若需要更改图像截取范围,请滑动下方的滑动条,来修改截取范围。",
+                style: TextStyle(fontSize: hintFontSize),
+              ),
+            ],
             Row(
               children: [
                 SizedBox(