1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117 |
- import 'dart:convert';
- import 'package:fis_jsonrpc/rpc.dart';
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import 'package:vitalapp/architecture/utils/prompt_box.dart';
- import 'package:vitalapp/components/button.dart';
- import 'package:vitalapp/components/dialog_input.dart';
- import 'package:vitalapp/components/dialog_number.dart';
- import 'package:vitalapp/components/dynamic_drawer.dart';
- import 'package:vitalapp/managers/interfaces/cachedRecord.dart';
- import 'package:vitalapp/managers/interfaces/template.dart';
- import 'package:vitalapp/pages/check/models/form.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_blood_pressure.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_blood_sugar.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_body_temperature.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_body_weight.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_boold_oxygen.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_check_box.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_health_guidance_check_box.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_input.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_number_input.dart';
- import 'dart:math' as math;
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_radio.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_radio_score.dart';
- import 'package:vitalapp/pages/check/widgets/device_controller.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_table.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_toxic_substance.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_urinalys.dart';
- import 'package:vitalapp/pages/check/widgets/exam_table/homecare_bed_history_from.dart';
- import 'package:vitalapp/pages/check/widgets/exam_table/hospitalization_history_from.dart';
- import 'package:vitalapp/pages/check/widgets/exam_table/inoculate_history_from.dart';
- import 'package:vitalapp/pages/check/widgets/exam_table/main_medication_status_from.dart';
- import 'package:vitalapp/pages/check/widgets/title_clip_path.dart';
- class ConfigurableCard extends StatefulWidget {
- final String cardKey;
- final Function(String, String, dynamic) callBack;
- final Widget? followUpWidget;
- final String? patientCode;
- final String? examData;
- const ConfigurableCard({
- super.key,
- required this.cardKey,
- required this.callBack,
- this.followUpWidget,
- this.patientCode,
- this.examData,
- });
- @override
- State<ConfigurableCard> createState() => _ConfigurableFormState();
- }
- class _ConfigurableFormState extends State<ConfigurableCard> {
- /// 当前最新的模板的键值对
- Map<String, dynamic> templateRelation = {};
- /// 当前模板数据
- List<FormObject> currentTemplate = [];
- /// 当前title的下标
- int currentTitleIndex = 0;
- Map<String, dynamic> formValue = {};
- var scaffoldKey = GlobalKey<ScaffoldState>();
- final _templateManager = Get.find<ITemplateManager>();
- final _cachedRecordManager = Get.find<ICachedRecordManager>();
- final arrowHeight = math.tan(120 / 180) * 19;
- List<String> deviceList = ['Temp', 'GLU', 'NIBP', 'SpO2', 'BMI'];
- Map<String, dynamic> deviceCached = {};
- Map currentTable = {};
- List<String> storeTypeList = [
- 'Qi_Score',
- 'Yang_Score',
- 'Yin_Score',
- 'Tan_Score',
- 'Shi_Score',
- 'Xue_Score',
- 'Qiyu_Score',
- 'Te_Score',
- 'Ping_Score'
- ];
- @override
- void initState() {
- Get.put(DeviceController());
- super.initState();
- WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
- if (mounted) {
- initTemplate();
- }
- });
- }
- @override
- void dispose() {
- super.dispose();
- }
- Future<void> initTemplate() async {
- Get.find<DeviceController>().busy = true;
- await fetchTemplateIndex();
- await fetchTemplate(widget.cardKey);
- await fetchTemplateData();
- Get.find<DeviceController>().busy = false;
- // if (!['GXY', 'TNB'].contains(widget.cardKey)) {
- // fetchTemplateData();
- // }
- }
- /// 读取健康检测的缓存
- Future<String?> readCachedRecord(String currentDevice) async {
- if (widget.patientCode == null) {
- return null;
- }
- String? value = await _cachedRecordManager.readCachedRecord(
- currentDevice,
- widget.patientCode!,
- 'ZLZS',
- );
- return value;
- }
- /// 读取体检的缓存
- Future<String?> readCachedCheck() async {
- if (widget.patientCode == null) {
- return null;
- }
- String? value = await _cachedRecordManager.readCachedRecord(
- widget.cardKey,
- widget.patientCode!,
- 'EXAM',
- );
- return value;
- }
- Future<void> readCached() async {
- for (var element in deviceList) {
- String? value = await readCachedRecord(element);
- if (value?.isNotEmpty ?? false) {
- deviceCached.addAll(jsonDecode(value!));
- }
- }
- }
- Future<void> fetchTemplateIndex() async {
- try {
- /// 获取模板的键值对
- String? templates;
- templates = await _templateManager.readTemplate('templateRelation');
- templateRelation = jsonDecode(templates!);
- setState(() {});
- } catch (error) {
- print('发生错误: $error');
- }
- }
- Future<void> fetchTemplateData() async {
- // / 这逻辑需要优化
- if (widget.examData?.isNotEmpty ?? false) {
- formValue = jsonDecode(widget.examData!);
- return;
- }
- String? value = await readCachedCheck();
- await readCached();
- if (deviceCached.isNotEmpty) {
- formValue = deviceCached;
- setState(() {});
- return;
- }
- if (value?.isNotEmpty ?? false) {
- formValue = jsonDecode(value!);
- }
- formValue.forEach(
- (key, value) {
- if (value is List<String>) {
- formValue[key] = List<String>.from(formValue[key]);
- } else if (value is List<Map>) {
- formValue[key] = List<Map>.from(formValue[key]);
- }
- },
- );
- setState(() {});
- }
- Future<void> fetchTemplate(String key) async {
- try {
- if (templateRelation[key] == null) {
- currentTemplate = [];
- setState(() {});
- return;
- }
- var template =
- await _templateManager.readTemplate(templateRelation[key]!);
- String templateContent =
- TemplateDTO.fromJson(jsonDecode(template!)).templateContent!;
- List<Map<String, dynamic>> list =
- jsonDecode(templateContent).cast<Map<String, dynamic>>();
- for (var i in list) {
- if (i['children'] != null) {
- List<FormObject> currentChildren = [];
- for (var j in i['children']) {
- currentChildren.add(FormObject.fromJson(j));
- }
- i['children'] = currentChildren;
- }
- var item = FormObject.fromJson(i);
- currentTemplate.add(item);
- }
- if (widget.cardKey == 'LNRZYYJKGLFWJL') {
- for (var element in storeTypeList) {
- formValue[element] =
- calculatePhysicalFitnessScore(element, element == 'Ping_Score');
- }
- }
- // var list = jsonDecode(templateContent).cast<Map<String, dynamic>>();
- // if (list == null) {
- // currentTemplate = [];
- // } else {
- // currentTemplate = updateChildren(list);
- // }
- // TextStorage t = TextStorage(
- // fileName: key,
- // directory: "template",
- // );
- // await t.save(jsonEncode(currentTemplate));
- setState(() {});
- } catch (error) {
- print('发生错误: $error');
- }
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- key: scaffoldKey,
- endDrawer: VDynamicDrawerWrapper(scaffoldKey: scaffoldKey),
- resizeToAvoidBottomInset: false,
- body: Column(
- children: [
- Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- const SizedBox(
- width: 16,
- ),
- Container(
- margin: const EdgeInsets.only(top: 8),
- width: 130,
- height: 54,
- child: VButton(
- onTap: () => {Get.back()},
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: const [
- Icon(Icons.arrow_back_ios_new, size: 24),
- SizedBox(
- width: 8,
- ),
- Text("返回", style: TextStyle(fontSize: 20)),
- ],
- ),
- ),
- ),
- Expanded(
- child: Container(
- padding:
- const EdgeInsets.symmetric(vertical: 16, horizontal: 10),
- child: _buildTitleList(),
- ),
- ),
- Container(
- margin: const EdgeInsets.only(top: 8, right: 16),
- width: 130,
- height: 54,
- child: VButton(
- onTap: () {
- widget.callBack(
- widget.cardKey,
- templateRelation[widget.cardKey]!,
- jsonEncode(formValue),
- );
- Get.back();
- },
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: const [
- Icon(Icons.save, size: 24),
- SizedBox(
- width: 8,
- ),
- Text("保存", style: TextStyle(fontSize: 20)),
- ],
- ),
- ),
- ),
- ],
- ),
- Expanded(
- child: Stack(
- children: [
- Row(
- mainAxisAlignment: MainAxisAlignment.start,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- _buildDiagram(),
- _buildContent(),
- ],
- ),
- if (currentTitleIndex != currentTemplate.length - 1)
- _buildPositionedButton(
- () async {
- currentTitleIndex++;
- setState(() {});
- },
- right: -30,
- ),
- ],
- ),
- )
- ],
- ),
- );
- }
- Widget buildSingleItem(Widget item, int span) {
- return FractionallySizedBox(
- widthFactor: span == 24 ? 1 : 0.5,
- child: item,
- );
- }
- Widget buildWidget(FormObject? currentFormObject) {
- Map<String, Widget Function(FormObject)> widgetMap = {
- 'checkbox': _buildCheckBox,
- 'numberInput': _buildNumberInput,
- 'input': _buildInput,
- 'radio': _buildRadio,
- 'radioScore': _buildRadioScore,
- 'bloodPressure': _buildBloodPressure,
- 'bodyTemperature': _buildBodyTemperature,
- 'weight': _buildBodyWeight,
- 'sugar': _buildBodySugar,
- 'bloodOxygen': _buildBloodOxygen,
- 'healthGuidanceCheckBox': _buildHealthGuidanceCheckBox,
- 'medicalHistory': _buildMedicalHistory,
- 'homecareBedHistor': _buildHomecareBedHistory,
- 'table': _buildMainMedicationHistory,
- 'inoculateHistory': _buildInoculateHistory,
- 'safetyPrecautions': _buildToxicSubstance,
- 'urinalys': _buildUrinalysis,
- };
- Widget Function(FormObject) builder =
- widgetMap[currentFormObject?.type] ?? _buildInput;
- return builder(currentFormObject!);
- }
- Widget flowCardList() {
- int itemCount = 0;
- bool currentTemplateOptionsIsNotEmpty = false;
- if (currentTemplate.isNotEmpty) {
- itemCount = currentTemplate[currentTitleIndex].children?.length ?? 0;
- currentTemplateOptionsIsNotEmpty =
- currentTemplate[currentTitleIndex].options?.isNotEmpty ?? false;
- }
- List<Widget> items = List.generate(itemCount, (index) {
- FormObject? currentFormObject =
- currentTemplate[currentTitleIndex].children?[index];
- int span = currentFormObject?.span ?? 12;
- //父结构的options不等于空或null
- if (true) {
- //子结构的options若是无值则取父类的options值
- if (currentTemplateOptionsIsNotEmpty) {
- currentFormObject!.options =
- currentTemplate[currentTitleIndex].options;
- }
- }
- return buildSingleItem(buildWidget(currentFormObject), span);
- });
- return Scrollbar(
- thumbVisibility: true,
- child: SingleChildScrollView(
- child: Container(
- alignment: Alignment.topCenter,
- padding: const EdgeInsets.all(15),
- child: Wrap(
- runSpacing: 20, // 纵向元素间距
- alignment: WrapAlignment.start,
- children: items,
- ),
- ),
- ),
- );
- }
- /// title标签
- Widget _buildTitleList() {
- return Wrap(
- runSpacing: 10, // 设置子小部件之间的间距
- spacing: -12,
- alignment: WrapAlignment.start,
- children: currentTemplate.asMap().entries.map(
- (e) {
- /// TODO 这边需要改下
- MaterialColor currentColors = Colors.grey;
- e.value.children?.forEach((element) {
- if (formValue.containsKey(element.key)) {
- if (!(widget.cardKey == 'LNRZYYJKGLFWJL' &&
- element.parentKey == 'Ping_Score')) {
- currentColors = Colors.green;
- } else if (element.key == 'qusition1') {
- {
- currentColors = Colors.green;
- }
- }
- }
- });
- return TitleClipRect(
- title: e.value.label ?? '',
- color: currentTitleIndex == e.key ? null : currentColors,
- arrowHeight: arrowHeight,
- clickTitle: () {
- // if (widget.cardKey == 'LNRZYYJKGLFWJL' &&
- // currentTitleIndex == 0 &&
- // formValue.length != 33) {
- // PromptBox.toast('题目未答全,不可进行指导');
- // } else
- {
- currentTitleIndex = e.key;
- setState(() {});
- }
- },
- );
- },
- ).toList(),
- );
- }
- /// 示意图
- Widget _buildDiagram() {
- if (widget.cardKey == 'ZYYYFMYGHYFJZS') {
- return const SizedBox();
- }
- return Expanded(
- flex: 1,
- child: Stack(
- children: [
- /// TODO BAKA-优化
- _buildImageCard(),
- if (currentTitleIndex != 0)
- _buildPositionedButton(
- () async {
- if (currentTitleIndex == 0) {
- Get.back();
- } else {
- currentTitleIndex--;
- setState(() {});
- }
- },
- left: -30,
- ),
- ],
- ),
- );
- }
- Widget _buildImageCard() {
- // if (currentTemplate[currentTitleIndex].key == 'Temperature') {
- // return Container(
- // alignment: Alignment.topCenter,
- // margin: const EdgeInsets.all(16).copyWith(top: 0),
- // child: Image.asset(
- // 'assets/images/healthCheck/temp.png',
- // height: double.infinity,
- // fit: BoxFit.fitWidth, // 设置图像的适应方式
- // ),
- // );
- // }
- if (['GXY', 'TNB', 'LNRZYYJKGLFWJL'].contains(widget.cardKey)) {
- return widget.followUpWidget!;
- } else {
- return Container(
- alignment: Alignment.topCenter,
- margin: const EdgeInsets.all(16).copyWith(top: 0),
- child: Image.asset(
- 'assets/images/exam/normalMeasurementChart.png',
- height: double.infinity,
- fit: BoxFit.fitWidth, // 设置图像的适应方式
- ),
- );
- }
- }
- /// 按钮
- Widget _buildPositionedButton(Function onTap, {double? right, double? left}) {
- return Positioned(
- right: right,
- left: left,
- bottom: 0,
- top: 0,
- child: Container(
- width: 100,
- height: 100,
- alignment: Alignment.centerLeft,
- child: InkWell(
- onTap: () => onTap.call(),
- child: Container(
- width: 100,
- height: 100,
- padding: const EdgeInsets.all(20),
- alignment:
- right == null ? Alignment.centerRight : Alignment.centerLeft,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(50),
- color: Theme.of(context).primaryColor.withOpacity(
- .8,
- ),
- ),
- child: Image.asset(
- right == null
- ? "assets/images/exam/left-arrow.png"
- : "assets/images/exam/right-arrow.png",
- width: 40,
- height: 40,
- color: Colors.white,
- fit: BoxFit.contain,
- ),
- ),
- ),
- ),
- );
- }
- /// 主页面
- Widget _buildContent() {
- return Expanded(
- flex: 2,
- child: flowCardList(),
- );
- }
- /// 多选框组件
- Widget _buildCheckBox(FormObject currentFormObject) {
- List<Option> options = currentFormObject.options ?? [];
- List<dynamic> currentSelectedCheckBox =
- formValue[currentFormObject.key!] ?? [];
- dynamic disabledValue = currentFormObject.disabledValue;
- void selectCheckBoxChange(Option e) {
- if (currentSelectedCheckBox.contains(e.value)) {
- currentSelectedCheckBox.remove(e.value);
- } else {
- if (disabledValue == e.value) {
- currentSelectedCheckBox = [disabledValue];
- } else {
- if (currentSelectedCheckBox.contains(disabledValue)) {
- PromptBox.toast('选项冲突');
- } else {
- currentSelectedCheckBox.add(e.value ?? '');
- }
- }
- }
- formValue[currentFormObject.key!] = currentSelectedCheckBox;
- setState(() {});
- }
- return ExamCheckBox(
- options: options,
- currentSelectedCheckBox: currentSelectedCheckBox,
- currentFormObject: currentFormObject,
- selectCheckBoxChange: selectCheckBoxChange,
- );
- }
- ///中医药健康指导多选框组件
- Widget _buildHealthGuidanceCheckBox(FormObject currentFormObject) {
- List<Option> options = currentFormObject.options ?? [];
- List<String> currentSelectedCheckBox =
- formValue[currentFormObject.key!] ?? [];
- // var templateFromObj = currentTemplate.firstWhere(
- // (element) => element.label!.contains());
- var currentScoreKey = currentFormObject.groupKeys != null
- ? currentFormObject.groupKeys![0]
- : '';
- int score = formValue[currentScoreKey] ?? 0;
- String judgmentResult = getJudgmentResult(currentScoreKey);
- void selectCheckBoxChange(Option e) {
- if (currentSelectedCheckBox.contains(e.value)) {
- currentSelectedCheckBox.remove(e.value);
- } else {
- currentSelectedCheckBox.add(e.value ?? '');
- }
- formValue[currentFormObject.key!] = currentSelectedCheckBox;
- setState(() {});
- }
- return ExamHealthGuidanceCheckBox(
- options: options,
- currentSelectedCheckBox: currentSelectedCheckBox,
- currentFormObject: currentFormObject,
- selectCheckBoxChange: selectCheckBoxChange,
- score: score,
- judgmentResult: judgmentResult,
- );
- }
- String getJudgmentResult(String storeKey) {
- var score = formValue[storeKey] ?? 0;
- if (storeKey == 'Ping_Score') {
- if (score >= 17) {
- bool is8 = true;
- bool is10 = true;
- for (var e in storeTypeList) {
- if (formValue[e] != null && e != 'Ping_Score') {
- var otherScore = formValue[e];
- if (otherScore > 8) {
- if (is8) {
- is8 = false;
- }
- if (otherScore > 10) {
- is10 = false;
- }
- }
- if (!is10) {
- break;
- }
- }
- }
- if (is8) {
- return '是';
- } else if (is10) {
- return '基本是';
- }
- }
- return '否';
- } else {
- if (score >= 11) {
- return '是';
- } else if (9 == score && score == 10) {
- return '倾向是';
- } else {
- return '否';
- }
- }
- }
- /// 数字输入框组件
- Widget _buildNumberInput(FormObject currentFormObject) {
- String currentInputValue = formValue[currentFormObject.key!] ?? '';
- if ((formValue['Height']?.isNotEmpty ?? false) &&
- (formValue['Weight']?.isNotEmpty ?? false)) {
- formValue['Bmi'] = (double.parse(formValue['Weight']) /
- ((double.parse(formValue['Height']) / 100) *
- (double.parse(formValue['Height']) / 100)))
- .toStringAsFixed(2);
- }
- Future<void> commonInput() async {
- String? result = await VDialogNumber(
- title: currentFormObject.label,
- initialValue: formValue[currentFormObject.key],
- ).show();
- if (result?.isNotEmpty ?? false) {
- formValue[currentFormObject.key!] = result;
- currentInputValue = formValue[currentFormObject.key!];
- setState(() {});
- }
- }
- void specialInput(String value) {
- formValue[currentFormObject.key!] = value;
- currentInputValue = formValue[currentFormObject.key!];
- setState(() {});
- }
- return ExamNumberInput(
- currentInputValue: currentInputValue,
- commonInput: commonInput,
- specialInput: specialInput,
- currentFormObject: currentFormObject,
- );
- }
- Widget _buildInput(FormObject currentFormObject) {
- String currentInputValue = formValue[currentFormObject.key!] ?? '';
- Future<void> commonInput() async {
- String? result = await VDialogInput(
- title: currentFormObject.label,
- initialValue: formValue[currentFormObject.key],
- ).show();
- if (result?.isNotEmpty ?? false) {
- formValue[currentFormObject.key!] = result;
- currentInputValue = formValue[currentFormObject.key!];
- setState(() {});
- }
- }
- return ExamInput(
- currentInputValue: currentInputValue,
- commonInput: commonInput,
- currentFormObject: currentFormObject,
- );
- }
- /// 血压组件
- Widget _buildBloodPressure(FormObject currentFormObject) {
- Map currentValue = formValue[currentFormObject.key!] ?? {};
- print(currentFormObject.key!);
- void bloodPressure(Map value) {
- currentValue = value;
- formValue[currentFormObject.key!] = currentValue;
- // setState(() {});
- }
- return ExamBloodPressure(
- currentValue: currentValue,
- bloodPressure: bloodPressure,
- );
- }
- Widget _buildUrinalysis(FormObject currentFormObject) {
- Map currentValue = formValue[currentFormObject.key!] ?? {};
- void urinalysis(Map value) {
- currentValue = value;
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- return ExamUrinalysis(
- currentValue: currentValue,
- urinalysis: urinalysis,
- );
- }
- /// 单选框组件
- Widget _buildRadio(FormObject currentFormObject) {
- List<Option> options = currentFormObject.options ?? [];
- String currentSelected = formValue[currentFormObject.key!] ?? "";
- void selectRaidoChange(Option e) {
- currentSelected = e.value ?? '';
- formValue[currentFormObject.key!] = currentSelected;
- if (widget.cardKey == 'LNRZYYJKGLFWJL') {
- var pingScore = [
- 'qusition1',
- 'qusition2',
- 'qusition4',
- 'qusition5',
- 'qusition13'
- ];
- var isPingScore = pingScore.contains(currentFormObject.key);
- formValue[currentFormObject.groupKeys?[0]] =
- calculatePhysicalFitnessScore(
- currentFormObject.groupKeys?[0], false);
- if (isPingScore) {
- formValue['Ping_Score'] =
- calculatePhysicalFitnessScore('Ping_Score', isPingScore);
- }
- }
- setState(() {});
- }
- return ExamRadio(
- options: options,
- currentFormObject: currentFormObject,
- selectRaidoChange: selectRaidoChange,
- currentSelected: currentSelected,
- );
- }
- int calculatePhysicalFitnessScore(String currentScoreKey, bool isPingScore) {
- int score = 0;
- var currentTemplateStoreList = currentTemplate[0].children?.where(
- (element) =>
- element.groupKeys != null &&
- element.groupKeys!.contains(currentScoreKey));
- if (!isPingScore) {
- for (var element in currentTemplateStoreList!) {
- if (formValue[element.key!] != null) {
- score += int.parse(formValue[element.key!]!);
- }
- }
- } else {
- int index = 0;
- for (var element in currentTemplateStoreList!) {
- if (index == 0) {
- if (formValue[element.key!] != null) {
- score += int.parse(formValue[element.key!]!);
- }
- } else {
- score += formValue[element.key!] != null
- ? (6 - int.parse(formValue[element.key!]!))
- : 0;
- }
- index++;
- }
- }
- return score;
- }
- Widget _buildRadioScore(FormObject currentFormObject) {
- print(currentFormObject.toJson());
- List<Option> options = currentFormObject.options ?? [];
- String currentSelected =
- formValue[currentFormObject.childrenKey!.first] ?? "";
- String currentScore = formValue[currentFormObject.childrenKey!.last] ?? "";
- void selectRaidoChange(Option e) {
- currentSelected = e.value ?? '';
- formValue[currentFormObject.childrenKey!.first] = currentSelected;
- setState(() {});
- }
- void changeScore(String? score) {
- currentScore = score ?? '';
- formValue[currentFormObject.childrenKey!.last] = currentScore;
- setState(() {});
- }
- return ExamRadioScore(
- options: options,
- currentFormObject: currentFormObject,
- selectRaidoChange: selectRaidoChange,
- currentSelected: currentSelected,
- changeScore: changeScore,
- currentScore: currentScore,
- );
- }
- /// 体温组件
- Widget _buildBodyTemperature(FormObject currentFormObject) {
- String currentInputValue = formValue[currentFormObject.key!] ?? '';
- void bodyTemperatureInput(String value) {
- formValue[currentFormObject.key!] = value;
- currentInputValue = formValue[currentFormObject.key!];
- setState(() {});
- }
- return ExamBodyTemperature(
- currentInputValue: currentInputValue,
- bodyTemperatureInput: bodyTemperatureInput,
- currentFormObject: currentFormObject,
- );
- }
- Widget _buildToxicSubstance(FormObject currentFormObject) {
- List<Option> options = currentFormObject.options ?? [];
- String currentValue = formValue[currentFormObject.childrenKey!.first] ?? "";
- Map? currentSelectedToxicSubstance =
- formValue[currentFormObject.childrenKey!.last];
- void selectRaidoChange(Map e) {
- currentSelectedToxicSubstance = e;
- formValue[currentFormObject.childrenKey!.last] =
- currentSelectedToxicSubstance;
- setState(() {});
- }
- void selectValueChange(String e) {
- currentValue = e;
- formValue[currentFormObject.childrenKey!.first] = currentValue;
- setState(() {});
- }
- return ExamToxicSubstance(
- currentFormObject: currentFormObject,
- currentSelectedToxicSubstance: currentSelectedToxicSubstance,
- currentValue: currentValue,
- options: options,
- selectRadioChange: selectRaidoChange,
- selectValueChange: selectValueChange,
- );
- }
- /// 血氧
- Widget _buildBloodOxygen(FormObject currentFormObject) {
- Map<String, dynamic> currentValue = formValue;
- void bloodOxygenInput(Map<String, dynamic> bloodOxygen) {
- formValue['Pulse_Frequency'] = bloodOxygen['Pulse_Frequency'];
- formValue['Spo2'] = bloodOxygen['Spo2'];
- currentValue = bloodOxygen;
- setState(() {});
- }
- return ExamBloodOxygen(
- currentValue: currentValue,
- bloodOxygenInput: bloodOxygenInput,
- );
- }
- /// 住院史
- Widget _buildMedicalHistory(FormObject currentFormObject) {
- List<dynamic> currentValue = formValue[currentFormObject.key!] ?? [];
- int currentId = currentValue.length + 1;
- void resultChange(Map result) {
- currentValue.add(result);
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- void editResult(EditTableValue result) {
- currentValue[result.id! - 1] = result.value;
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- Future<void> addTableData() async {
- Get.dialog(
- HospitalizationHistoryForm(
- fromResult: (result) => resultChange(result),
- currentId: currentId,
- ),
- );
- }
- Future<void> editTableData(EditTableValue editTableValue) async {
- Get.dialog(
- HospitalizationHistoryForm(
- fromResult: (result) => editResult(result),
- currentId: editTableValue.id!,
- admissionJson: editTableValue.value,
- ),
- );
- }
- return ExamTable(
- tableThList: const ['序号', '入院日期', '出院日期', '原因', '医疗机构名称', '病案号', '操作'],
- currentFormObject: currentFormObject,
- currentValue: currentValue,
- addTableData: addTableData,
- editTableData: (value) => editTableData(value),
- );
- }
- /// 家庭病床史
- Widget _buildHomecareBedHistory(FormObject currentFormObject) {
- List<dynamic> currentValue = formValue[currentFormObject.key!] ?? [];
- int currentId = currentValue.length + 1;
- void resultChange(Map result) {
- currentValue.add(result);
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- void editResult(EditTableValue result) {
- currentValue[result.id! - 1] = result.value;
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- Future<void> addTableData() async {
- Get.dialog(
- HomecareBedHistoryFrom(
- fromResult: (result) => resultChange(result),
- currentId: currentId,
- ),
- );
- }
- Future<void> editTableData(EditTableValue editTableValue) async {
- Get.dialog(
- HomecareBedHistoryFrom(
- fromResult: (result) => editResult(result),
- currentId: editTableValue.id!,
- admissionJson: editTableValue.value,
- ),
- );
- }
- return ExamTable(
- tableThList: const ['序号', '建床日期', '撤床日期', '原因', '医疗机构名称', '病案号', '操作'],
- currentFormObject: currentFormObject,
- currentValue: currentValue,
- addTableData: addTableData,
- editTableData: (value) => editTableData(value),
- );
- }
- Widget _buildMainMedicationHistory(FormObject currentFormObject) {
- List<dynamic> currentValue = formValue[currentFormObject.key!] ?? [];
- int currentId = currentValue.length + 1;
- void resultChange(Map result) {
- currentValue.add(result);
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- void editResult(EditTableValue result) {
- currentValue[result.id! - 1] = result.value;
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- Future<void> addTableData() async {
- Get.dialog(
- MainMedicationStatusFrom(
- fromResult: (result) => resultChange(result),
- currentId: currentId,
- ),
- );
- }
- Future<void> editTableData(EditTableValue editTableValue) async {
- Get.dialog(
- MainMedicationStatusFrom(
- fromResult: (result) => editResult(result),
- currentId: editTableValue.id!,
- admissionJson: editTableValue.value,
- ),
- );
- }
- return ExamTable(
- tableThList: const ['序号', '药物名称', '用法', '用量', '用药时间', '服药依从性', '操作'],
- currentFormObject: currentFormObject,
- currentValue: currentValue,
- addTableData: addTableData,
- editTableData: (value) => editTableData(value),
- );
- }
- Widget _buildInoculateHistory(FormObject currentFormObject) {
- List<dynamic> currentValue = formValue[currentFormObject.key!] ?? [];
- int currentId = currentValue.length + 1;
- void resultChange(Map result) {
- currentValue.add(result);
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- void editResult(EditTableValue result) {
- currentValue[result.id! - 1] = result.value;
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- Future<void> addTableData() async {
- Get.dialog(
- InoculateHistoryFrom(
- fromResult: (result) => resultChange(result),
- currentId: currentId,
- ),
- );
- }
- Future<void> editTableData(EditTableValue editTableValue) async {
- Get.dialog(
- InoculateHistoryFrom(
- fromResult: (result) => editResult(result),
- currentId: editTableValue.id!,
- admissionJson: editTableValue.value,
- ),
- );
- }
- return ExamTable(
- tableThList: const ['序号', '疫苗名称', '接种日期', '接种机构', '操作'],
- currentFormObject: currentFormObject,
- currentValue: currentValue,
- addTableData: addTableData,
- editTableData: (value) => editTableData(value),
- );
- }
- /// 体重
- Widget _buildBodyWeight(FormObject currentFormObject) {
- String currentInputValue = formValue[currentFormObject.key!] ?? '';
- void bodyWeightInput(String value) {
- formValue[currentFormObject.key!] = value;
- currentInputValue = formValue[currentFormObject.key!];
- setState(() {});
- }
- return ExamBodyWeight(
- currentInputValue: currentInputValue,
- bodyWeightInput: bodyWeightInput,
- currentFormObject: currentFormObject,
- );
- }
- /// 血糖
- Widget _buildBodySugar(FormObject currentFormObject) {
- String currentInputValue = formValue[currentFormObject.key!] ?? '';
- void bloodSugarInput(String value) {
- formValue[currentFormObject.key!] = value;
- currentInputValue = formValue[currentFormObject.key!];
- setState(() {});
- }
- return ExamBloodSugar(
- currentInputValue: currentInputValue,
- bloodSugarInput: bloodSugarInput,
- currentFormObject: currentFormObject,
- );
- }
- }
|