Browse Source

肺结核随访代码提交

finlay 11 months ago
parent
commit
3fa0850ff8

BIN
assets/images/patient/肺结核健康管理.png


+ 2 - 2
lib/architecture/values/features.dart

@@ -73,6 +73,6 @@ class FeatureKeys {
   ///儿童健康管理
   static const ChildrenHealthManagement = 'ETJKGL';
 
-  ///严重精神障碍补充表
-  static const MentalDisorderAdditionalInfo = 'YZJSZABCXX';
+  ///肺结核患者管理
+  static const TuberculosisManagementRecord = 'FJHHZJKGL';
 }

+ 3 - 0
lib/managers/prescription.dart

@@ -1,3 +1,5 @@
+import 'dart:convert';
+
 import 'package:fis_common/logger/logger.dart';
 import 'package:fis_jsonrpc/rpc.dart';
 import 'package:vitalapp/managers/interfaces/prescription.dart';
@@ -22,6 +24,7 @@ class PrescriptionManager implements IPrescriptionManager {
         prescriptionData: prescriptionData,
         token: Store.user.token,
       );
+      print(jsonEncode(request.toJson()));
       String prescriptionCode =
           await rpc.vitalPrescription.createPrescriptionAsync(request);
       return prescriptionCode;

+ 12 - 11
lib/pages/check/follow_up/controller.dart

@@ -75,18 +75,19 @@ class FollowUpController extends GetxController {
     if (state.followUpPhoto?.isNotEmpty ?? false) {
       followUpPhotos = [state.followUpPhoto!];
     }
-    final result = await _followUpManager.createFollowUp(
-      CreateFollowUpRequest(
-        key: key,
-        patientCode: patientCode,
-        templateCode: templateCode,
-        followUpData: data,
-        followUpTime: state.followUpTime,
-        nextFollowUpTime: state.nextFollowUpTime,
-        followUpMode: state.followUpMode ?? FollowUpModeEnum.Outpatient,
-        followUpPhotos: followUpPhotos,
-      ),
+    var request = CreateFollowUpRequest(
+      key: key,
+      patientCode: patientCode,
+      templateCode: templateCode,
+      followUpData: data,
+      followUpTime: state.followUpTime,
+      nextFollowUpTime: state.nextFollowUpTime,
+      followUpMode: state.followUpMode ?? FollowUpModeEnum.Outpatient,
+      followUpPhotos: followUpPhotos,
     );
+    print(jsonEncode(request.toJson()));
+
+    final result = await _followUpManager.createFollowUp(request);
     if (result.isNotEmpty) {
       await createPrescription(result);
       PromptBox.toast('保存成功');

+ 12 - 1
lib/pages/check/follow_up_record/controller.dart

@@ -48,8 +48,16 @@ class FollowUpRecordController extends FControllerBase {
 
   Future<void> getFollowUpRecordList() async {
     try {
+      var keys = [followUpType];
+      if (followUpType == "FollowUpTuberculosisFirstRecord") {
+        keys = [
+          "FollowUpTuberculosisFirstRecord",
+          "FollowUpTuberculosisRecord",
+          "FollowUpTuberculosisResultRecord"
+        ];
+      }
       var result = await _followUpManager.getFollowUpRecordList(
-        [followUpType],
+        keys,
         patientCode,
       );
       List<FollowUpRecordDTO> followUpDTOList = [];
@@ -311,6 +319,9 @@ class FollowUpRecordController extends FControllerBase {
     'ET_1_2SETJKJCLB': "1~2岁儿童健康检查列表",
     'ET_1SNETJKJCLB': "1岁内儿童健康检查列表",
     'ET_FamilyVisitRecord': "新生儿访视列表",
+    'FollowUpTuberculosisFirstRecord': "肺结核患者第一次入户随访记录表",
+    'FollowUpTuberculosisRecord': "肺结核患者随访服务记录表",
+    'FollowUpTuberculosisResultRecord': "肺结核患者结论表",
   };
 
   String getFollowUpValueByKey(String key) {

+ 3 - 0
lib/pages/check/tuberculosis_management_record/controller.dart

@@ -0,0 +1,3 @@
+import 'package:vitalapp/architecture/defines.dart';
+
+class TuberculosisManagementController extends FControllerBase {}

+ 0 - 0
lib/pages/check/tuberculosis_management_record/state.dart


+ 416 - 0
lib/pages/check/tuberculosis_management_record/view.dart

@@ -0,0 +1,416 @@
+import 'package:fis_jsonrpc/rpc.dart';
+import 'package:flutter/foundation.dart';
+import 'package:flutter/material.dart';
+import 'package:get/get.dart';
+import 'package:intl/intl.dart';
+import 'package:vitalapp/components/appbar.dart';
+import 'package:vitalapp/consts/styles.dart';
+import 'package:vitalapp/database/entities/defines.dart';
+import 'package:vitalapp/pages/check/follow_up/widgets/follow_up_from.dart';
+import 'package:vitalapp/pages/check/follow_up_record/controller.dart';
+import 'package:vitalapp/pages/check/tuberculosis_management_record/controller.dart';
+import 'package:vitalapp/pages/check/tuberculosis_management_record/widget/FormSelectDialog.dart';
+import 'package:vitalapp/pages/check/widgets/configurable_card.dart';
+import 'package:vitalapp/pages/medical/controller.dart';
+import 'package:vitalapp/pages/patient/list/widgets/status.dart';
+import 'package:vitalapp/pages/widgets/record_common_item.dart';
+
+class TuberculosisManagementView extends GetView<FollowUpRecordController> {
+  const TuberculosisManagementView({
+    Key? key,
+    required this.followUpType,
+  }) : super(key: key);
+  final String followUpType;
+  @override
+  Widget build(BuildContext context) {
+    return GetBuilder(
+        init: FollowUpRecordController(
+          followUpType: followUpType,
+        ),
+        builder: (_) {
+          return Scaffold(
+            backgroundColor: const Color.fromRGBO(238, 238, 238, 1),
+            appBar: VAppBar(
+              titleWidget: Text('肺结核患者随访管理'),
+              actions: [
+                IconButton(
+                  onPressed: () {
+                    Get.dialog(FormSelectDialog(onConfirm: (type) {
+                      String key = "FollowUpTuberculosisFirstRecord";
+                      switch (type) {
+                        case 1:
+                          key = "FollowUpTuberculosisFirstRecord";
+                          break;
+                        case 2:
+                          key = "FollowUpTuberculosisRecord";
+                          break;
+                        case 3:
+                          key = "FollowUpTuberculosisResultRecord";
+                          break;
+                      }
+                      _changePage(key);
+                      Get.back();
+                    }));
+                  },
+                  icon: Icon(
+                    Icons.add,
+                    size: 48,
+                  ),
+                ),
+                SizedBox(
+                  width: 8,
+                ),
+              ],
+            ),
+            body: Stack(
+              children: [
+                Row(
+                  mainAxisAlignment: MainAxisAlignment.start,
+                  crossAxisAlignment: CrossAxisAlignment.start,
+                  children: [
+                    _buildDiagram(),
+                    _buildListView(),
+                  ],
+                ),
+              ],
+            ),
+          );
+        });
+  }
+
+  void _changePage(String key) async {
+    /// TODO BAKA 急需求 后面改掉
+    await Get.put(MedicalController());
+    controller.followUpController.state.followUpTime = DateTime.now();
+    controller.followUpController.state.nextFollowUpTime = null;
+    controller.followUpController.state.followUpMode =
+        FollowUpModeEnum.Outpatient;
+    controller.followUpController.state.followUpPhoto = '';
+    await Get.to(
+      ConfigurableCard(
+        cardKey: key,
+        callBack: (key, templateCode, data) async {
+          final result = await controller.followUpController.createFollowUp(
+            key,
+            templateCode,
+            data,
+          );
+          return result;
+        },
+        followUpWidget: FollowUpFrom(
+          cardKey: key,
+        ),
+      ),
+      transition: Transition.rightToLeft,
+    );
+    await controller.getFollowUpRecordList();
+    await Get.find<MedicalController>().initRecordDataState();
+
+    await Get.delete<MedicalController>();
+  }
+
+  Widget _buildDiagram() {
+    return Expanded(
+      flex: 1,
+      child: Padding(
+        padding: const EdgeInsets.all(16.0).copyWith(right: 0),
+        child: Container(
+          // color: Colors.white,
+          padding: const EdgeInsets.all(16),
+          decoration: BoxDecoration(
+            color: Colors.white,
+            border: Border.all(
+              color: Colors.white,
+            ),
+            borderRadius: GlobalStyles.borderRadius,
+          ),
+          child: Image.asset(
+            'assets/images/exam/normalMeasurementChart.png',
+            height: double.infinity,
+            fit: BoxFit.fitWidth,
+          ),
+        ),
+      ),
+    );
+  }
+
+  Widget _buildListView() {
+    return Expanded(
+      flex: 2,
+      child: Padding(
+        padding: const EdgeInsets.all(16),
+        child: RefreshIndicator(
+            child: Obx(
+              () {
+                final list = controller.state.followUpDTOList;
+                final children = <Widget>[];
+                for (var i = 0; i < list.length; i++) {
+                  final dto = list[i];
+                  final offlineSyncArr = controller.offlineSyncTemp[i];
+                  final records = dto.followUpRecordDatas;
+                  if (records == null) {
+                    continue;
+                  }
+                  for (var j = 0; j < records.length; j++) {
+                    final data = records[j];
+                    OfflineDataSyncState? offlineSyncState;
+                    offlineSyncState = kIsWeb ? null : offlineSyncArr[j];
+                    children.add(
+                      _followUpRecordCard(
+                        index: j,
+                        dto: dto,
+                        dataDto: data,
+                        syncState: offlineSyncState,
+                      ),
+                    );
+                  }
+                }
+
+                return list.isEmpty
+                    ? Container(
+                        margin: const EdgeInsets.only(top: 80),
+                        child: Column(
+                          children: [
+                            Center(
+                              child: Image.asset(
+                                "assets/images/no_data.png",
+                                width: 300,
+                                height: 300,
+                                fit: BoxFit.cover,
+                              ),
+                            ),
+                            const Text(
+                              "暂无数据,先看看别的吧",
+                              style: TextStyle(fontSize: 18),
+                            ),
+                          ],
+                        ),
+                      )
+                    : GridView(
+                        gridDelegate:
+                            const SliverGridDelegateWithFixedCrossAxisCount(
+                          crossAxisCount: 1,
+                          mainAxisSpacing: 16,
+                          crossAxisSpacing: 20,
+                          childAspectRatio: 900 / 180,
+                        ),
+                        children: children,
+                      );
+              },
+            ),
+            onRefresh: () async {}),
+      ),
+    );
+  }
+}
+
+// ignore: camel_case_types
+class _followUpRecordCard extends StatelessWidget {
+  final FollowUpRecordDTO dto;
+  final FollowUpRecordDataDTO dataDto;
+  final int index;
+  final OfflineDataSyncState? syncState; // TODO temp
+  _followUpRecordCard({
+    required this.dto,
+    required this.dataDto,
+    required this.index,
+    this.syncState,
+  });
+  final controller = Get.find<FollowUpRecordController>();
+  @override
+  Widget build(BuildContext context) {
+    final body = Stack(
+      children: [
+        Row(
+          children: [
+            Expanded(
+              flex: 10,
+              child: Container(
+                padding: const EdgeInsets.symmetric(
+                  horizontal: 30,
+                  vertical: 12,
+                ),
+                child: Column(
+                  crossAxisAlignment: CrossAxisAlignment.start,
+                  children: [
+                    const SizedBox(
+                      height: 8,
+                    ),
+                    LayoutBuilder(builder: (context, c) {
+                      final width = c.maxWidth - 100;
+                      return SizedBox(
+                        width: width,
+                        child: _buildBaseInfoRow(),
+                      );
+                    }),
+                    const SizedBox(
+                      height: 20,
+                    ),
+                    Wrap(
+                      alignment: WrapAlignment.start,
+                      spacing: 20,
+                      runSpacing: 8,
+                      children: [
+                        SizedBox(
+                          width: 300,
+                          child: RecordCommonItem(
+                            itemName: '姓名',
+                            itemValue: dto.patientName ?? "",
+                            fontSize: 18,
+                          ),
+                        ),
+                        RecordCommonItem(
+                          itemName: '随访类型',
+                          itemValue:
+                              controller.getFollowUpMode(dataDto.followUpMode),
+                          fontSize: 18,
+                        ),
+                      ],
+                    ),
+                    const SizedBox(
+                      height: 20,
+                    ),
+                    Wrap(
+                      alignment: WrapAlignment.start,
+                      spacing: 20,
+                      runSpacing: 8,
+                      children: [
+                        SizedBox(
+                          width: 300,
+                          child: RecordCommonItem(
+                            itemName: '随访医生',
+                            itemValue: dataDto.followUpDoctor ?? "",
+                            fontSize: 18,
+                          ),
+                        ),
+                        RecordCommonItem(
+                          itemName: '随访时间',
+                          itemValue: dataDto.followUpTime != null
+                              ? DateFormat("yyyy-MM-dd")
+                                  .format(dataDto.followUpTime!.toLocal())
+                              : "",
+                          fontSize: 18,
+                        ),
+                      ],
+                    )
+                  ],
+                ),
+              ),
+            ),
+            Expanded(
+              child: IconButton(
+                onPressed: () {
+                  controller.toCheckPage(dataDto, isCreateFromOldDto: true);
+                },
+                icon: Icon(
+                  Icons.add,
+                  size: 56,
+                  color: Colors.grey.shade400,
+                ),
+              ),
+            )
+          ],
+        ),
+        Positioned(
+          top: 16,
+          right: 0,
+          child: _FollowUpRecordSignStatusTag(
+            dataDto: dataDto,
+          ),
+        ),
+        // if(dataDto)
+        Positioned(
+          top: 16,
+          right: 100,
+          child: _OfflineSyncTag(syncState: syncState),
+        ),
+        // Positioned(
+        //   bottom: 16,
+        //   right: 12,
+        //   child: IconButton(
+        //     icon: Icon(
+        //       Icons.edit,
+        //       size: 26,
+        //       color: Theme.of(context).primaryColor,
+        //     ),
+        //     onPressed: () {
+        //       controller.toCheckPage(dataDto); //跳转到随访页面
+        //     },
+        //   ),
+        // ),
+      ],
+    );
+    return Material(
+      borderRadius: GlobalStyles.borderRadius,
+      child: Ink(
+        decoration: BoxDecoration(
+          color: Colors.white,
+          borderRadius: GlobalStyles.borderRadius,
+        ),
+        child: InkWell(
+          borderRadius: GlobalStyles.borderRadius,
+          onTap: () {
+            // controller.toFollowUpDetailPage(index, dto);
+            controller.toCheckPage(dataDto); //跳转到随访页面
+          },
+          child: body,
+        ),
+      ),
+    );
+  }
+
+  Widget _buildBaseInfoRow() {
+    return SizedBox(
+      child: RecordCommonItem(
+        itemName: '随访名称',
+        itemValue: controller.getFollowUpValueByKey(dataDto.key ?? ""),
+        fontSize: 20,
+      ),
+    );
+  }
+}
+
+// ignore: camel_case_types
+class _FollowUpRecordSignStatusTag extends StatelessWidget {
+  final FollowUpRecordDataDTO dataDto;
+
+  _FollowUpRecordSignStatusTag({required this.dataDto});
+  final controller = Get.find<FollowUpRecordController>();
+  @override
+  Widget build(BuildContext context) {
+    return Container(
+      alignment: Alignment.centerRight,
+      width: 120,
+      child: StatusLabel(
+        title: controller.followUpStateTransition(dataDto.followUpState),
+        color: controller.followUpStateColors(dataDto.followUpState),
+      ),
+    );
+  }
+}
+
+class _OfflineSyncTag extends StatelessWidget {
+  final OfflineDataSyncState? syncState;
+
+  const _OfflineSyncTag({required this.syncState});
+
+  @override
+  Widget build(BuildContext context) {
+    if (syncState == null || syncState == OfflineDataSyncState.success) {
+      return const SizedBox();
+    }
+    return Container(
+      height: 30,
+      alignment: Alignment.center,
+      padding: const EdgeInsets.symmetric(horizontal: 16),
+      decoration: BoxDecoration(
+        borderRadius: BorderRadius.circular(16),
+        color: Colors.red,
+      ),
+      child: Text(
+        syncState!.getDescription(),
+        style: const TextStyle(color: Colors.white, fontSize: 14),
+      ),
+    );
+  }
+}

+ 77 - 0
lib/pages/check/tuberculosis_management_record/widget/FormSelectDialog.dart

@@ -0,0 +1,77 @@
+import 'package:flutter/material.dart';
+import 'package:vitalapp/components/alert_dialog.dart';
+
+class FormSelectDialog extends StatefulWidget {
+  final void Function(int) onConfirm;
+  FormSelectDialog({required this.onConfirm});
+
+  @override
+  State<FormSelectDialog> createState() {
+    return FormSelectDialogState();
+  }
+}
+
+class FormSelectDialogState extends State<FormSelectDialog> {
+  int type = 1;
+  @override
+  Widget build(BuildContext context) {
+    return VAlertDialog(
+        width: 360,
+        title: "请选择随访类型",
+        contentPadding: EdgeInsets.symmetric(horizontal: 80),
+        showCancel: false,
+        onConfirm: () {
+          widget.onConfirm.call(type);
+        },
+        content: SizedBox(
+          height: 160,
+          child: Column(
+            mainAxisAlignment: MainAxisAlignment.center,
+            children: [
+              Row(
+                children: [
+                  Radio(
+                    onChanged: (v) {
+                      setState(() {
+                        type = 1;
+                      });
+                    },
+                    value: 1,
+                    groupValue: type,
+                  ),
+                  Text("肺结核患者第一次入户随访记录表"),
+                ],
+              ),
+              Row(
+                children: [
+                  Radio(
+                    onChanged: (v) {
+                      setState(() {
+                        type = 2;
+                      });
+                    },
+                    value: 2,
+                    groupValue: type,
+                  ),
+                  Text("肺结核患者随访服务记录表"),
+                ],
+              ),
+              Row(
+                children: [
+                  Radio(
+                    onChanged: (v) {
+                      setState(() {
+                        type = 3;
+                      });
+                    },
+                    value: 3,
+                    groupValue: type,
+                  ),
+                  Text("肺结核患者结论表")
+                ],
+              ),
+            ],
+          ),
+        ));
+  }
+}

+ 10 - 6
lib/pages/check/widgets/configurable_card.dart

@@ -239,9 +239,8 @@ class _ConfigurableFormState extends State<ConfigurableCard> {
     try {
       // String? templateContent = "";
       // String? template = "";
-      // if (key == "YZJSZASFFW") {
-      //   templateContent =
-      //       await loadJsonFromAssets('assets/严重精神障碍患者随访服务记录表.json');
+      // if (key == "FollowUpTuberculosisFirstRecord") {
+      // templateContent = await loadJsonFromAssets('assets/${key}.json');
       // }
       // if (templateRelation[key] == null && templateContent.isNullOrEmpty) {
       if (templateRelation[key] == null) {
@@ -572,9 +571,14 @@ class _ConfigurableFormState extends State<ConfigurableCard> {
     //     ),
     //   );
     // }
-    if (['GXY', 'TNB', 'LNRZYYJKGLFWJL', 'YZJSZASFFW']
-            .contains(widget.cardKey) ||
-        widget.cardKey.contains("ET_")) {
+    if ([
+          'GXY',
+          'TNB',
+          'LNRZYYJKGLFWJL',
+          'YZJSZASFFW',
+        ].contains(widget.cardKey) ||
+        widget.cardKey.contains("ET_") ||
+        widget.cardKey.contains("FollowUpTuberculosis")) {
       return widget.followUpWidget!;
     } else {
       return Container(

+ 9 - 0
lib/pages/patient/detail/controller.dart

@@ -87,6 +87,15 @@ class PatientDetailController extends FControllerBase with HomeNavMixin {
     );
   }
 
+  ///check/follow_up_record/tuberculosis
+
+  ///前往严重精神障碍记录页面
+  void gototuberculosisRecord() {
+    Get.toNamed(
+      "check/follow_up_record/tuberculosis",
+    );
+  }
+
   /// 前往健康体检页
   void gotoHealthCheck() {
     Get.toNamed(

+ 5 - 3
lib/pages/patient/detail/widgets/functions_panel.dart

@@ -166,11 +166,13 @@ class FunctionsPanel extends GetView<PatientDetailController> {
                 icon: _buildImgIcon("儿童健康管理.png"),
                 onTap: controller.gotoChildHealth,
               ),
-            if (kDebugMode)
+            if (Store.user
+                    .hasFeature(FeatureKeys.TuberculosisManagementRecord) &&
+                controller.state.labels.contains(CrowdLabels.TUBERCULOSIS))
               FunctionButton(
                 label: "肺结核健康管理",
-                icon: _buildImgIcon("严重精神障碍随访.png"),
-                onTap: controller.gotoMentalDisorderRecord,
+                icon: _buildImgIcon("肺结核健康管理.png"),
+                onTap: controller.gototuberculosisRecord,
               ),
           ],
         ),

+ 15 - 1
lib/routes/routes.dart

@@ -9,6 +9,7 @@ import 'package:vitalapp/pages/check/self_care_ability_assessment_record/control
 import 'package:vitalapp/pages/check/self_care_ability_assessment_record/view.dart';
 import 'package:vitalapp/pages/check/traditional_chinese_medicine_consitution_record/controller.dart';
 import 'package:vitalapp/pages/check/traditional_chinese_medicine_consitution_record/view.dart';
+import 'package:vitalapp/pages/check/tuberculosis_management_record/view.dart';
 import 'package:vitalapp/pages/consultation_record_view/controller.dart';
 import 'package:vitalapp/pages/consultation_record_view/view.dart';
 import 'package:vitalapp/pages/contract/package_list/widgets/capture_portrait.dart';
@@ -606,6 +607,19 @@ class Routes {
       binding: BindingsBuilder(() {
         Get.put(MentalDisorderInfoController());
       }),
-    )
+    ),
+
+    ///严重肺结核患者管理
+    VRouteSetting(
+      '/check/follow_up_record/tuberculosis',
+      () => const TuberculosisManagementView(
+          followUpType: 'FollowUpTuberculosisFirstRecord'),
+      binding: BindingsBuilder(
+        () {
+          Get.put(FollowUpRecordController(
+              followUpType: 'FollowUpTuberculosisFirstRecord'));
+        },
+      ),
+    ),
   ];
 }