import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';
import 'package:vitalapp/components/cell.dart';
import 'package:vitalapp/components/dialog_check.dart';
import 'package:vitalapp/components/dialog_date.dart';
import 'package:vitalapp/components/dialog_input.dart';
import 'package:vitalapp/components/dialog_profile_time_input.dart';
import 'package:vitalapp/components/dialog_select.dart';
import 'package:vitalapp/pages/patient/info/controller.dart';
import 'package:vitalapp/pages/patient/info/patientInfoRecord.dart';

/// TODO 优化组件
class PatientInfoHealthView extends GetView<PatientInfoController> {
  const PatientInfoHealthView({super.key});

  @override
  Widget build(BuildContext context) {
    return Scrollbar(
        child: SingleChildScrollView(
      child: Container(
        alignment: Alignment.topCenter,
        color: Colors.grey.shade200,
        child: Column(
          children: [
            Padding(
              padding: const EdgeInsets.only(
                top: 16,
                left: 16,
                right: 16,
                bottom: 16,
              ),
              child: Obx(
                () => VListFormCellGroup(
                  formTitle: '过敏史',
                  children: [
                    VListFormCell(
                      label: "药物过敏史",
                      content:
                          controller.state.historyDrugAllergies.map((index) {
                        return PatientInfoRecord.historyDrugAllergiesList
                            .firstWhere((element) => element.key == index)
                            .value;
                      }).join('，'),
                      onTap: () async {
                        final result = await VDialogCheck<
                            MapEntry<String, String>, String>(
                          title: "药物过敏史",
                          source: PatientInfoRecord.historyDrugAllergiesList,
                          initialValue: controller.state.historyDrugAllergies,
                          valueGetter: (data) => data.key,
                          labelGetter: (data) => data.value,
                          MutexValue: '1',
                        ).show();
                        if (result != null) {
                          controller.state.historyDrugAllergies = result;
                        }
                      },
                    ),
                    if (controller.state.historyDrugAllergies.contains("5"))
                      VListFormCell(
                        label: "药物过敏史-其他",
                        content: controller.state.historyDrugAllergiesOther,
                        onTap: () async {
                          final result = await VDialogInput(
                                  title: "药物过敏史-其他",
                                  initialValue: controller
                                      .state.historyDrugAllergiesOther,
                                  placeholder: '请输入')
                              .show();
                          if (result != null) {
                            controller.state.historyDrugAllergiesOther = result;
                          }
                        },
                      ),
                    VListFormCell(
                      label: "暴露史",
                      content: controller.state.historyExposure.map((index) {
                        return PatientInfoRecord.historyExposureList
                            .firstWhere((element) => element.key == index)
                            .value;
                      }).join('，'),
                      onTap: () async {
                        final result = await VDialogCheck<
                            MapEntry<String, String>, String>(
                          title: "暴露史",
                          source: PatientInfoRecord.historyExposureList,
                          initialValue: controller.state.historyExposure,
                          valueGetter: (data) => data.key,
                          labelGetter: (data) => data.value,
                          MutexValue: '1',
                        ).show();
                        if (result != null) {
                          controller.state.historyExposure = result;
                        }
                      },
                    ),
                  ],
                ),
              ),
            ),
            Padding(
              padding: const EdgeInsets.only(
                left: 16,
                right: 16,
                bottom: 16,
              ),
              child: Obx(
                () => VListFormCellGroup(
                  formTitle: '既往史',
                  children: [
                    VListFormCell(
                      label: "疾病",
                      content:
                          controller.state.historyPreviousDisease.map((index) {
                        return PatientInfoRecord.historyPreviousDiseaseList
                            .firstWhere((element) => element.key == index)
                            .value;
                      }).join('，'),
                      onTap: () async {
                        final result = await VDialogCheck<
                            MapEntry<String, String>, String>(
                          title: "疾病",
                          source: PatientInfoRecord.historyPreviousDiseaseList,
                          initialValue: controller.state.historyPreviousDisease,
                          valueGetter: (data) => data.key,
                          labelGetter: (data) => data.value,
                          MutexValue: '1',
                        ).show();
                        if (result != null) {
                          controller.state.historyPreviousDisease = result;
                        }
                      },
                    ),
                    if (controller.state.historyPreviousDisease.contains("6"))
                      VListFormCell(
                        label: "    疾病-恶性肿瘤",
                        content:
                            controller.state.historyPreviousDiseaseMalignancy,
                        onTap: () async {
                          final result = await VDialogInput(
                                  title: "疾病-恶性肿瘤",
                                  initialValue: controller
                                      .state.historyPreviousDiseaseMalignancy,
                                  placeholder: '请输入恶性肿瘤详情')
                              .show();
                          if (result != null) {
                            controller.state.historyPreviousDiseaseMalignancy =
                                result;
                          }
                        },
                      ),
                    if (controller.state.historyPreviousDisease.contains("12"))
                      VListFormCell(
                        label: "    疾病-职业病",
                        content: controller
                            .state.historyPreviousDiseaseOccupationalDisease,
                        onTap: () async {
                          final result = await VDialogInput(
                                  title: "疾病-职业病",
                                  initialValue: controller.state
                                      .historyPreviousDiseaseOccupationalDisease,
                                  placeholder: '请输入职业病详情')
                              .show();
                          if (result != null) {
                            controller.state
                                    .historyPreviousDiseaseOccupationalDisease =
                                result;
                          }
                        },
                      ),
                    if (controller.state.historyPreviousDisease.contains("13"))
                      VListFormCell(
                        label: "    疾病-其他",
                        content: controller.state.historyPreviousDiseaseOther,
                        onTap: () async {
                          final result = await VDialogInput(
                                  title: "疾病-其他",
                                  initialValue: controller
                                      .state.historyPreviousDiseaseOther,
                                  placeholder: '请输入其他疾病详情')
                              .show();
                          if (result != null) {
                            controller.state.historyPreviousDiseaseOther =
                                result;
                          }
                        },
                      ),
                    if (controller.state.historyPreviousDisease.isNotEmpty)
                      ...controller.state.historyPreviousDisease
                          .map((e) => VListFormCell(
                                label:
                                    '    ${PatientInfoRecord.historyPreviousDiseaseList.firstWhere((element) => element.key == e).value} 确诊时间',
                                content: controller
                                            .state.diseaseDiagnosisTime[e] !=
                                        null
                                    ? DateFormat('yyyy-MM-dd').format(controller
                                        .state.diseaseDiagnosisTime[e]!)
                                    : '',
                                onTap: () async {
                                  var result = await VDialogDate(
                                    maxValue: DateTime.now(),
                                  ).show();
                                  if (result != null) {
                                    controller.state.diseaseDiagnosisTime[e] =
                                        result;
                                  }
                                },
                              ))
                          .toList(),
                    VListFormCell(
                      label: "手术",
                      content: controller.state.trauma.isNotEmpty
                          ? PatientInfoRecord.historyPreviousOtherList
                              .firstWhere((element) =>
                                  element.key == controller.state.operation)
                              .value
                          : '',
                      onTap: () async {
                        final result = await VDialogSelect<
                            MapEntry<String, String>, String>(
                          title: "既往史-手术",
                          source: PatientInfoRecord.historyPreviousOtherList,
                          initialValue: controller.state.operation,
                          valueGetter: (data) => data.key,
                          labelGetter: (data) => data.value,
                        ).show();
                        if (result != null) {
                          controller.state.operation = result;
                        }
                      },
                    ),
                    if (controller.state.operation.contains('2'))
                      Row(
                        children: [
                          const SizedBox(
                            width: 16,
                          ),
                          Expanded(
                            child: InkWell(
                              onTap: () async {
                                final result = await VDialogProfileTimeInput(
                                  title: "手术1",
                                  initialValue: controller.state.operationOne,
                                ).show();
                                if (result != null) {
                                  controller.state.operationOne = result;
                                }
                              },
                              child: Card(
                                elevation: 0,
                                child: Container(
                                  decoration: BoxDecoration(
                                      border: Border.all(
                                        color: Colors.grey.shade300,
                                      ),
                                      borderRadius: BorderRadius.circular(8)),
                                  padding: const EdgeInsets.all(16),
                                  child: Column(
                                    crossAxisAlignment:
                                        CrossAxisAlignment.start,
                                    children: [
                                      const Text(
                                        '手术1',
                                        style: TextStyle(
                                          fontSize: 24,
                                        ),
                                      ),
                                      Text(
                                        '名称：${controller.state.operationOne?.name ?? ''}',
                                        style: const TextStyle(
                                          fontSize: 20,
                                        ),
                                      ),
                                      Text(
                                        '时间：${controller.state.operationOne?.time != null ? DateFormat('yyyy-MM-dd').format(controller.state.operationOne!.time!) : ''}',
                                        style: const TextStyle(
                                          fontSize: 20,
                                        ),
                                      ),
                                      const SizedBox(
                                        height: 4,
                                      )
                                    ],
                                  ),
                                ),
                              ),
                            ),
                          ),
                          Expanded(
                            child: InkWell(
                              onTap: () async {
                                final result = await VDialogProfileTimeInput(
                                  title: "手术2",
                                  initialValue: controller.state.operationTwo,
                                ).show();
                                if (result != null) {
                                  controller.state.operationTwo = result;
                                }
                              },
                              child: Card(
                                elevation: 0,
                                child: Container(
                                  decoration: BoxDecoration(
                                      border: Border.all(
                                        color: Colors.grey.shade300,
                                      ),
                                      borderRadius: BorderRadius.circular(8)),
                                  padding: const EdgeInsets.all(16),
                                  child: Column(
                                    crossAxisAlignment:
                                        CrossAxisAlignment.start,
                                    children: [
                                      const Text(
                                        '手术2',
                                        style: TextStyle(
                                          fontSize: 24,
                                        ),
                                      ),
                                      Text(
                                        '名称：${controller.state.operationTwo?.name ?? ''}',
                                        style: const TextStyle(
                                          fontSize: 20,
                                        ),
                                      ),
                                      Text(
                                        '时间：${controller.state.operationTwo?.time != null ? DateFormat('yyyy-MM-dd').format(controller.state.operationTwo!.time!) : ''}',
                                        style: const TextStyle(
                                          fontSize: 20,
                                        ),
                                      ),
                                      const SizedBox(
                                        height: 4,
                                      )
                                    ],
                                  ),
                                ),
                              ),
                            ),
                          ),
                          const SizedBox(
                            width: 16,
                          ),
                        ],
                      ),
                    VListFormCell(
                      label: "外伤",
                      content: controller.state.trauma.isNotEmpty
                          ? PatientInfoRecord.historyPreviousOtherList
                              .firstWhere((element) =>
                                  element.key == controller.state.trauma)
                              .value
                          : '',
                      onTap: () async {
                        final result = await VDialogSelect<
                            MapEntry<String, String>, String>(
                          title: "既往史-外伤",
                          source: PatientInfoRecord.historyPreviousOtherList,
                          initialValue: controller.state.trauma,
                          valueGetter: (data) => data.key,
                          labelGetter: (data) => data.value,
                        ).show();
                        if (result != null) {
                          controller.state.trauma = result;
                        }
                      },
                    ),
                    if (controller.state.trauma.contains('2'))
                      Row(
                        children: [
                          const SizedBox(
                            width: 16,
                          ),
                          Expanded(
                            child: InkWell(
                              onTap: () async {
                                final result = await VDialogProfileTimeInput(
                                  title: "外伤1",
                                  initialValue: controller.state.traumaOne,
                                ).show();
                                if (result != null) {
                                  controller.state.traumaOne = result;
                                }
                              },
                              child: Card(
                                elevation: 0,
                                child: Container(
                                  decoration: BoxDecoration(
                                      border: Border.all(
                                        color: Colors.grey.shade300,
                                      ),
                                      borderRadius: BorderRadius.circular(8)),
                                  padding: const EdgeInsets.all(16),
                                  child: Column(
                                    crossAxisAlignment:
                                        CrossAxisAlignment.start,
                                    children: [
                                      const Text(
                                        '外伤1',
                                        style: TextStyle(
                                          fontSize: 24,
                                        ),
                                      ),
                                      Text(
                                        '名称：${controller.state.traumaOne?.name ?? ''}',
                                        style: const TextStyle(
                                          fontSize: 20,
                                        ),
                                      ),
                                      Text(
                                        '时间：${controller.state.traumaOne?.time != null ? DateFormat('yyyy-MM-dd').format(controller.state.traumaOne!.time!) : ''}',
                                        style: const TextStyle(
                                          fontSize: 20,
                                        ),
                                      ),
                                      const SizedBox(
                                        height: 4,
                                      )
                                    ],
                                  ),
                                ),
                              ),
                            ),
                          ),
                          Expanded(
                            child: InkWell(
                              onTap: () async {
                                final result = await VDialogProfileTimeInput(
                                  title: "外伤2",
                                  initialValue: controller.state.traumaTwo,
                                ).show();
                                if (result != null) {
                                  controller.state.traumaTwo = result;
                                }
                              },
                              child: Card(
                                elevation: 0,
                                child: Container(
                                  decoration: BoxDecoration(
                                      border: Border.all(
                                        color: Colors.grey.shade300,
                                      ),
                                      borderRadius: BorderRadius.circular(8)),
                                  padding: const EdgeInsets.all(16),
                                  child: Column(
                                    crossAxisAlignment:
                                        CrossAxisAlignment.start,
                                    children: [
                                      const Text(
                                        '外伤2',
                                        style: TextStyle(
                                          fontSize: 24,
                                        ),
                                      ),
                                      Text(
                                        '名称：${controller.state.traumaTwo?.name ?? ''}',
                                        style: const TextStyle(
                                          fontSize: 20,
                                        ),
                                      ),
                                      Text(
                                        '时间：${controller.state.traumaTwo?.time != null ? DateFormat('yyyy-MM-dd').format(controller.state.traumaTwo!.time!) : ''}',
                                        style: const TextStyle(
                                          fontSize: 20,
                                        ),
                                      ),
                                      const SizedBox(
                                        height: 4,
                                      )
                                    ],
                                  ),
                                ),
                              ),
                            ),
                          ),
                          const SizedBox(
                            width: 16,
                          ),
                        ],
                      ),
                    VListFormCell(
                      label: "输血",
                      content: controller.state.transfusion.isNotEmpty
                          ? PatientInfoRecord.historyPreviousOtherList
                              .firstWhere((element) =>
                                  element.key == controller.state.transfusion)
                              .value
                          : '',
                      onTap: () async {
                        final result = await VDialogSelect<
                            MapEntry<String, String>, String>(
                          title: "既往史-输血",
                          source: PatientInfoRecord.historyPreviousOtherList,
                          initialValue: controller.state.transfusion,
                          valueGetter: (data) => data.key,
                          labelGetter: (data) => data.value,
                        ).show();
                        if (result != null) {
                          controller.state.transfusion = result;
                        }
                      },
                    ),
                    if (controller.state.transfusion.contains('2'))
                      Row(
                        children: [
                          const SizedBox(
                            width: 16,
                          ),
                          Expanded(
                            child: InkWell(
                              onTap: () async {
                                final result = await VDialogProfileTimeInput(
                                  title: "输血1",
                                  initialValue: controller.state.transfusionOne,
                                ).show();
                                if (result != null) {
                                  controller.state.transfusionOne = result;
                                }
                              },
                              child: Card(
                                elevation: 0,
                                child: Container(
                                  decoration: BoxDecoration(
                                      border: Border.all(
                                        color: Colors.grey.shade300,
                                      ),
                                      borderRadius: BorderRadius.circular(8)),
                                  padding: const EdgeInsets.all(16),
                                  child: Column(
                                    crossAxisAlignment:
                                        CrossAxisAlignment.start,
                                    children: [
                                      const Text(
                                        '输血1',
                                        style: TextStyle(
                                          fontSize: 24,
                                        ),
                                      ),
                                      Text(
                                        '名称：${controller.state.transfusionOne?.name ?? ''}',
                                        style: const TextStyle(
                                          fontSize: 20,
                                        ),
                                      ),
                                      Text(
                                        '时间：${controller.state.transfusionOne?.time != null ? DateFormat('yyyy-MM-dd').format(controller.state.transfusionOne!.time!) : ''}',
                                        style: const TextStyle(
                                          fontSize: 20,
                                        ),
                                      ),
                                      const SizedBox(
                                        height: 4,
                                      )
                                    ],
                                  ),
                                ),
                              ),
                            ),
                          ),
                          Expanded(
                            child: InkWell(
                              onTap: () async {
                                final result = await VDialogProfileTimeInput(
                                  title: "输血2",
                                  initialValue: controller.state.transfusionTwo,
                                ).show();
                                if (result != null) {
                                  controller.state.transfusionTwo = result;
                                }
                              },
                              child: Card(
                                elevation: 0,
                                child: Container(
                                  decoration: BoxDecoration(
                                      border: Border.all(
                                        color: Colors.grey.shade300,
                                      ),
                                      borderRadius: BorderRadius.circular(8)),
                                  padding: const EdgeInsets.all(16),
                                  child: Column(
                                    crossAxisAlignment:
                                        CrossAxisAlignment.start,
                                    children: [
                                      const Text(
                                        '输血2',
                                        style: TextStyle(
                                          fontSize: 24,
                                        ),
                                      ),
                                      Text(
                                        '名称：${controller.state.transfusionTwo?.name ?? ''}',
                                        style: const TextStyle(
                                          fontSize: 20,
                                        ),
                                      ),
                                      Text(
                                        '时间：${controller.state.transfusionTwo?.time != null ? DateFormat('yyyy-MM-dd').format(controller.state.transfusionTwo!.time!) : ''}',
                                        style: const TextStyle(
                                          fontSize: 20,
                                        ),
                                      ),
                                      const SizedBox(
                                        height: 4,
                                      )
                                    ],
                                  ),
                                ),
                              ),
                            ),
                          ),
                          const SizedBox(
                            width: 16,
                          ),
                        ],
                      ),
                  ],
                ),
              ),
            ),
            Padding(
              padding: const EdgeInsets.only(
                left: 16,
                right: 16,
                bottom: 16,
              ),
              child: Obx(
                () => VListFormCellGroup(
                  formTitle: '家族病史',
                  children: [
                    VListFormCell(
                      label: "父亲",
                      content: controller.state.father.isNotEmpty
                          ? controller.state.father.map((index) {
                              return PatientInfoRecord.historyFamilyList
                                  .firstWhere((element) => element.key == index)
                                  .value;
                            }).join('，')
                          : '',
                      onTap: () async {
                        final result = await VDialogCheck<
                            MapEntry<String, String>, String>(
                          title: "父亲",
                          source: PatientInfoRecord.historyFamilyList,
                          initialValue: controller.state.father,
                          valueGetter: (data) => data.key,
                          labelGetter: (data) => data.value,
                          MutexValue: '1',
                        ).show();
                        if (result != null) {
                          controller.state.father = result;
                        }
                      },
                    ),
                    if (controller.state.father.contains("12"))
                      VListFormCell(
                        label: "父亲-其他",
                        content: controller.state.fatherOther,
                        onTap: () async {
                          final result = await VDialogInput(
                                  title: "父亲-其他",
                                  initialValue: controller.state.fatherOther,
                                  placeholder: '请输入')
                              .show();
                          if (result != null) {
                            controller.state.fatherOther = result;
                          }
                        },
                      ),
                    VListFormCell(
                      label: "母亲",
                      content: controller.state.mother.map((index) {
                        return PatientInfoRecord.historyFamilyList
                            .firstWhere((element) => element.key == index)
                            .value;
                      }).join('，'),
                      onTap: () async {
                        final result = await VDialogCheck<
                            MapEntry<String, String>, String>(
                          title: "母亲",
                          source: PatientInfoRecord.historyFamilyList,
                          initialValue: controller.state.mother,
                          valueGetter: (data) => data.key,
                          labelGetter: (data) => data.value,
                          MutexValue: '1',
                        ).show();
                        if (result != null) {
                          controller.state.mother = result;
                        }
                      },
                    ),
                    if (controller.state.mother.contains("12"))
                      VListFormCell(
                        label: "母亲-其他",
                        content: controller.state.motherOther,
                        onTap: () async {
                          final result = await VDialogInput(
                                  title: "母亲-其他",
                                  initialValue: controller.state.motherOther,
                                  placeholder: '请输入')
                              .show();
                          if (result != null) {
                            controller.state.motherOther = result;
                          }
                        },
                      ),
                    VListFormCell(
                      label: "兄弟姐妹",
                      content: controller.state.sibling.map((index) {
                        return PatientInfoRecord.historyFamilyList
                            .firstWhere((element) => element.key == index)
                            .value;
                      }).join('，'),
                      onTap: () async {
                        final result = await VDialogCheck<
                            MapEntry<String, String>, String>(
                          title: "兄弟姐妹",
                          source: PatientInfoRecord.historyFamilyList,
                          initialValue: controller.state.sibling,
                          valueGetter: (data) => data.key,
                          labelGetter: (data) => data.value,
                          MutexValue: '1',
                        ).show();
                        if (result != null) {
                          controller.state.sibling = result;
                        }
                      },
                    ),
                    if (controller.state.sibling.contains("12"))
                      VListFormCell(
                        label: "兄弟姐妹-其他",
                        content: controller.state.siblingOther,
                        onTap: () async {
                          final result = await VDialogInput(
                                  title: "兄弟姐妹-其他",
                                  initialValue: controller.state.siblingOther,
                                  placeholder: '请输入')
                              .show();
                          if (result != null) {
                            controller.state.siblingOther = result;
                          }
                        },
                      ),
                    VListFormCell(
                      label: "子女",
                      content: controller.state.children.map((index) {
                        return PatientInfoRecord.historyFamilyList
                            .firstWhere((element) => element.key == index)
                            .value;
                      }).join('，'),
                      onTap: () async {
                        final result = await VDialogCheck<
                            MapEntry<String, String>, String>(
                          title: "子女",
                          source: PatientInfoRecord.historyFamilyList,
                          initialValue: controller.state.children,
                          valueGetter: (data) => data.key,
                          labelGetter: (data) => data.value,
                          MutexValue: '1',
                        ).show();
                        if (result != null) {
                          controller.state.children = result;
                        }
                      },
                    ),
                    if (controller.state.children.contains("12"))
                      VListFormCell(
                        label: "子女-其他",
                        content: controller.state.childrenOther,
                        onTap: () async {
                          final result = await VDialogInput(
                                  title: "子女-其他",
                                  initialValue: controller.state.childrenOther,
                                  placeholder: '请输入')
                              .show();
                          if (result != null) {
                            controller.state.childrenOther = result;
                          }
                        },
                      ),
                  ],
                ),
              ),
            ),
            Padding(
              padding: const EdgeInsets.only(
                left: 16,
                right: 16,
                bottom: 16,
              ),
              child: Obx(() => VListFormCellGroup(formTitle: '遗传病史', children: [
                    VListFormCell(
                      label: "遗传病史",
                      content: controller.state.historyGenetic.isNotEmpty
                          ? PatientInfoRecord.historyPreviousOtherList
                              .firstWhere((element) =>
                                  element.key ==
                                  controller.state.historyGenetic)
                              .value
                          : '',
                      onTap: () async {
                        final result = await VDialogSelect<
                            MapEntry<String, String>, String>(
                          title: "遗传病史",
                          source: PatientInfoRecord.historyPreviousOtherList,
                          initialValue: controller.state.historyGenetic,
                          valueGetter: (data) => data.key,
                          labelGetter: (data) => data.value,
                        ).show();
                        if (result != null) {
                          controller.state.historyGenetic = result;
                        }
                      },
                    ),
                    if (controller.state.historyGenetic.contains("2"))
                      VListFormCell(
                        label: "疾病名称",
                        content: controller.state.historyGeneticName,
                        onTap: () async {
                          final result = await VDialogInput(
                                  title: "疾病名称",
                                  initialValue:
                                      controller.state.historyGeneticName,
                                  placeholder: '请输入')
                              .show();
                          if (result != null) {
                            controller.state.historyGeneticName = result;
                          }
                        },
                      ),
                    VListFormCell(
                      label: "残疾情况",
                      content:
                          controller.state.disabilitySituation.map((index) {
                        return PatientInfoRecord.disabilitySituationList
                            .firstWhere((element) => element.key == index)
                            .value;
                      }).join('，'),
                      onTap: () async {
                        final result = await VDialogCheck<
                            MapEntry<String, String>, String>(
                          title: "残疾情况",
                          source: PatientInfoRecord.disabilitySituationList,
                          initialValue: controller.state.disabilitySituation,
                          valueGetter: (data) => data.key,
                          labelGetter: (data) => data.value,
                          MutexValue: '1',
                        ).show();
                        if (result != null) {
                          controller.state.disabilitySituation = result;
                        }
                      },
                    ),
                    if (controller.state.disabilitySituation.contains("8"))
                      VListFormCell(
                        label: "其他残疾-疾病名称",
                        content: controller.state.disabilitySituationOther,
                        onTap: () async {
                          final result = await VDialogInput(
                                  title: "其他残疾-疾病名称",
                                  initialValue:
                                      controller.state.disabilitySituationOther,
                                  placeholder: '请输入')
                              .show();
                          if (result != null) {
                            controller.state.disabilitySituationOther = result;
                          }
                        },
                      ),
                  ])),
            ),
            Padding(
              padding: const EdgeInsets.only(left: 16, right: 16, bottom: 50),
              child: Obx(() => VListFormCellGroup(formTitle: '生活环境', children: [
                    VListFormCell(
                      label: "厨房排风设施",
                      content:
                          controller.state.kitchenExhaustFacilities.isNotEmpty
                              ? PatientInfoRecord.kitchenExhaustFacilitiesList
                                  .firstWhere((element) =>
                                      element.key ==
                                      controller.state.kitchenExhaustFacilities)
                                  .value
                              : '',
                      onTap: () async {
                        final result = await VDialogSelect<
                            MapEntry<String, String>, String>(
                          title: "厨房排风设施",
                          source:
                              PatientInfoRecord.kitchenExhaustFacilitiesList,
                          initialValue:
                              controller.state.kitchenExhaustFacilities,
                          valueGetter: (data) => data.key,
                          labelGetter: (data) => data.value,
                        ).show();
                        if (result != null) {
                          controller.state.kitchenExhaustFacilities = result;
                        }
                      },
                    ),
                    VListFormCell(
                      label: "燃气类型",
                      content: controller.state.fuel.isNotEmpty
                          ? PatientInfoRecord.fuelList
                              .firstWhere((element) =>
                                  element.key == controller.state.fuel)
                              .value
                          : '',
                      onTap: () async {
                        final result = await VDialogSelect<
                            MapEntry<String, String>, String>(
                          title: "燃气类型",
                          source: PatientInfoRecord.fuelList,
                          initialValue: controller.state.fuel,
                          valueGetter: (data) => data.key,
                          labelGetter: (data) => data.value,
                        ).show();
                        if (result != null) {
                          controller.state.fuel = result;
                        }
                      },
                    ),
                    if (controller.state.fuel.contains("6"))
                      VListFormCell(
                        label: "燃气类型-其他",
                        content: controller.state.fuelOther,
                        onTap: () async {
                          final result = await VDialogInput(
                                  title: "燃气类型-其他",
                                  initialValue: controller.state.fuelOther,
                                  placeholder: '请输入')
                              .show();
                          if (result != null) {
                            controller.state.fuelOther = result;
                          }
                        },
                      ),
                    VListFormCell(
                      label: "饮水",
                      content: controller.state.drinkingWater.isNotEmpty
                          ? PatientInfoRecord.drinkingWaterList
                              .firstWhere((element) =>
                                  element.key == controller.state.drinkingWater)
                              .value
                          : '',
                      onTap: () async {
                        final result = await VDialogSelect<
                            MapEntry<String, String>, String>(
                          title: "饮水",
                          source: PatientInfoRecord.drinkingWaterList,
                          initialValue: controller.state.drinkingWater,
                          valueGetter: (data) => data.key,
                          labelGetter: (data) => data.value,
                        ).show();
                        if (result != null) {
                          controller.state.drinkingWater = result;
                        }
                      },
                    ),
                    if (controller.state.drinkingWater.contains("6"))
                      VListFormCell(
                        label: "饮水-其他",
                        content: controller.state.drinkingWaterOther,
                        onTap: () async {
                          final result = await VDialogInput(
                                  title: "饮水-其他",
                                  initialValue:
                                      controller.state.drinkingWaterOther,
                                  placeholder: '请输入')
                              .show();
                          if (result != null) {
                            controller.state.drinkingWaterOther = result;
                          }
                        },
                      ),
                    VListFormCell(
                      label: "厕所",
                      content: controller.state.toilet.isNotEmpty
                          ? PatientInfoRecord.toiletList
                              .firstWhere((element) =>
                                  element.key == controller.state.toilet)
                              .value
                          : '',
                      onTap: () async {
                        final result = await VDialogSelect<
                            MapEntry<String, String>, String>(
                          title: "厕所",
                          source: PatientInfoRecord.toiletList,
                          initialValue: controller.state.toilet,
                          valueGetter: (data) => data.key,
                          labelGetter: (data) => data.value,
                        ).show();
                        if (result != null) {
                          controller.state.toilet = result;
                        }
                      },
                    ),
                    VListFormCell(
                      label: "禽兽栏",
                      content: controller.state.animalPen.isNotEmpty
                          ? PatientInfoRecord.animalPenList
                              .firstWhere((element) =>
                                  element.key == controller.state.animalPen)
                              .value
                          : '',
                      onTap: () async {
                        final result = await VDialogSelect<
                            MapEntry<String, String>, String>(
                          title: "禽兽栏",
                          source: PatientInfoRecord.animalPenList,
                          initialValue: controller.state.animalPen,
                          valueGetter: (data) => data.key,
                          labelGetter: (data) => data.value,
                        ).show();
                        if (result != null) {
                          controller.state.animalPen = result;
                        }
                      },
                    ),
                  ])),
            )
          ],
        ),
      ),
    ));
  }
}
