123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827 |
- import 'dart:convert';
- import 'package:fis_common/index.dart';
- import 'package:fis_common/logger/logger.dart';
- import 'package:fis_jsonrpc/rpc.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:get/get.dart';
- import 'package:intl/intl.dart';
- import 'package:vitalapp/architecture/utils/compute_children_level.dart';
- import 'package:vitalapp/architecture/utils/prompt_box.dart';
- import 'package:vitalapp/components/button.dart';
- import 'package:vitalapp/components/dialog_date.dart';
- import 'package:vitalapp/components/dialog_gxy_medication.dart';
- import 'package:vitalapp/components/dialog_input.dart';
- import 'package:vitalapp/components/dialog_medication.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/follow_up.dart';
- import 'package:vitalapp/managers/interfaces/template.dart';
- import 'package:vitalapp/pages/check/models/form.dart';
- import 'package:vitalapp/pages/check/prescription/prescription.dart';
- import 'package:vitalapp/pages/check/widgets/follow_up_configurable/follow_up_child_anterior_fontanelle.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_checkbox_frequency.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_input.dart';
- import 'package:vitalapp/pages/check/widgets/exam_configurable/exam_medication.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_configurable/follow_blood_pressure.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/follow_up_configurable/follow_up_child_anterior_fontanelle_other.dart';
- import 'package:vitalapp/pages/check/widgets/follow_up_configurable/follow_up_child_height_and_weight.dart';
- import 'package:vitalapp/pages/check/widgets/follow_up_configurable/follow_up_child_radio_input.dart';
- import 'package:vitalapp/pages/check/widgets/follow_up_configurable/follow_up_child_referral.dart';
- import 'package:vitalapp/pages/check/widgets/follow_up_configurable/follow_up_medication.dart';
- import 'package:vitalapp/pages/check/widgets/follow_up_configurable/follow_up_resident_detail.dart';
- import 'package:vitalapp/pages/check/widgets/title_clip_path.dart';
- import 'package:flutter/services.dart' show rootBundle;
- import 'package:vitalapp/pages/form/form_info.dart';
- import 'package:vitalapp/store/store.dart';
- class ConfigurableCard extends StatefulWidget {
- final String cardKey;
- final Future<bool> Function(String, String, dynamic, String?) callBack;
- final Widget? followUpWidget;
- final String? patientCode;
- final String? examData;
- final bool canPrescribe;
- final void Function(String, String, dynamic)? onClickPrescribe;
- const ConfigurableCard({
- super.key,
- required this.cardKey,
- required this.callBack,
- this.followUpWidget,
- this.patientCode,
- this.examData,
- this.canPrescribe = false,
- this.onClickPrescribe,
- });
- @override
- State<ConfigurableCard> createState() => _ConfigurableFormState();
- }
- class _ConfigurableFormState extends State<ConfigurableCard> {
- /// 当前最新的模板的键值对
- Map<String, dynamic> templateRelation = {};
- /// 当前模板数据
- List<FormObject> currentTemplate = [];
- /// 当前title的下标
- int currentTitleIndex = 0;
- /// 处方key
- String prescriptionKey = '';
- Map<String, dynamic> formValue = {};
- var scaffoldKey = GlobalKey<ScaffoldState>();
- final _templateManager = Get.find<ITemplateManager>();
- final _cachedRecordManager = Get.find<ICachedRecordManager>();
- final _followUpManager = Get.find<IFollowUpManager>();
- // _followUpManager.onFollowMedicalData
- final arrowHeight = math.tan(120 / 180) * 19;
- List<String> deviceList = ['Temp', 'GLU', 'NIBP', 'SpO2', 'BMI'];
- Map<String, dynamic> deviceCached = {};
- Map currentTable = {};
- @override
- void initState() {
- Get.put(DeviceController());
- WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
- if (mounted) {
- initTemplate();
- }
- });
- _followUpManager.onFollowMedicalData.addListener(_setFollowUpData);
- super.initState();
- switch (widget.cardKey) {
- case "TNB":
- prescriptionKey = "DiabetesPrescription";
- break;
- case "GXY":
- prescriptionKey = "HypertensionPrescription";
- break;
- case "FollowUpTuberculosisRecord":
- prescriptionKey = "TuberculosisPrescription";
- break;
- case "YZJSZASFFW":
- prescriptionKey = "PsychiatricPrescription";
- break;
- }
- }
- @override
- void dispose() {
- _followUpManager.onFollowMedicalData.removeListener(_setFollowUpData);
- super.dispose();
- }
- Future<void> initTemplate() async {
- Get.find<DeviceController>().busy = true;
- await fetchTemplateIndex();
- await fetchTemplate(widget.cardKey);
- await fetchTemplateData();
- Get.find<DeviceController>().busy = false;
- }
- /// 读取健康检测的缓存
- 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.readTemplateRelation('templateRelation');
- templateRelation = jsonDecode(templates!);
- setState(() {});
- } catch (error) {
- print('发生错误: $error');
- }
- }
- Future<String> loadJsonData() async {
- return await rootBundle.loadString('assets/data/3-6.json');
- }
- 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<String> loadJsonFromAssets(String filePath) async {
- String jsonString = await rootBundle.loadString(filePath);
- return jsonString;
- }
- Future<void> fetchTemplateDebug() async {
- try {
- // if (templateRelation[key] == null) {
- // currentTemplate = [];
- // setState(() {});
- // return;
- // }
- // var template =
- // await _templateManager.readTemplate(templateRelation[key]!);
- var template = await loadJsonData();
- List<Map<String, dynamic>> list =
- jsonDecode(template)["Content"].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);
- }
- setState(() {});
- } catch (error) {
- print('发生错误: $error');
- }
- }
- Future<void> fetchTemplate(String key) async {
- try {
- // String? templateContent = "";
- // String? template = "";
- // if (key == "FollowUpTuberculosisFirstRecord") {
- // templateContent = await loadJsonFromAssets('assets/${key}.json');
- // }
- // if (templateRelation[key] == null && templateContent.isNullOrEmpty) {
- if (templateRelation[key] == null) {
- logger.i(
- "ConfigurableCard - fetchTemplate Template not exist key: $key.");
- currentTemplate = [];
- setState(() {});
- return;
- }
- // if (templateContent.isNullOrEmpty)
- // template = await _templateManager.readTemplate(templateRelation[key]!);
- // if (templateContent.isNullOrEmpty)
- // templateContent =
- 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',
- // );
- // }
- // }
- 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: () {
- FormInfo.instance.formValue.clear();
- 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(),
- ),
- ),
- if (widget.canPrescribe)
- Container(
- margin: const EdgeInsets.only(top: 8, right: 16),
- width: 130,
- height: 54,
- child: VButton(
- onTap: () {
- widget.onClickPrescribe?.call(
- widget.cardKey,
- templateRelation[widget.cardKey]!,
- jsonEncode(formValue),
- );
- },
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: const [
- Icon(Icons.assignment_outlined, size: 24),
- SizedBox(
- width: 8,
- ),
- Text("处方", style: TextStyle(fontSize: 20)),
- ],
- ),
- ),
- ),
- Container(
- margin: const EdgeInsets.only(top: 8, right: 16),
- width: 130,
- height: 54,
- child: VButton(
- onTap: () async {
- final result = await widget.callBack(
- widget.cardKey,
- templateRelation[widget.cardKey]!,
- jsonEncode(formValue),
- prescriptionKey,
- );
- if (result) {
- 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,
- 'radioInput': _buildRadioInput,
- 'bloodPressure': _buildBloodPressure,
- 'bodyTemperature': _buildBodyTemperature,
- 'weight': _buildBodyWeight,
- 'sugar': _buildBodySugar,
- 'bloodOxygen': _buildBloodOxygen,
- 'medicalHistory': _buildMedicalHistory,
- 'homecareBedHistor': _buildHomecareBedHistory,
- 'table': _buildMainMedicationHistory,
- 'inoculateHistory': _buildInoculateHistory,
- 'safetyPrecautions': _buildToxicSubstance,
- 'urinalys': _buildUrinalysis,
- 'date': _buildDate,
- 'checkBoxFrequency': _buildCheckBoxFrequency,
- 'radioHospitalization': _buildRadioHospitalization,
- 'radioReferral': _buildRadioReferral,
- 'medication': _buildMedication,
- 'gxyAndTnbMedication': _buildGxyAndTnbMedication,
- 'radioExtraDescription': _buildRadioExtraDescription,
- 'checkBoxIncludeOther': _buildCheckBoxIncludeOther,
- 'inputAndRadio': _buildChildHeightAndWeight,
- 'anteriorFontanelle': _buildAnteriorFontanelle,
- 'anteriorFontanelleOther': _buildAnteriorFontanelleOther,
- 'referral': _buildFollowUpChildReferral,
- 'prescriptionType': _buildPrescription,
- 'residentdetail': _buildResidentDetail,
- };
- 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,
- ),
- ),
- ),
- );
- }
- void _setFollowUpData(sender, e) {
- if (mounted) {
- print(e);
- Map<String, dynamic> followUpData = jsonDecode(e);
- followUpData.forEach((key, value) {
- if (key == "BMI") {
- formValue.addAll(value);
- }
- if (key == "NIBP") {
- /// 之前区分左右,后面重新设计
- List bloodValue = [];
- if (value["Sbp"] != null &&
- value["Dbp"] != null &&
- value["Pulse_Beat"] != null) {
- bloodValue.addAll([value["Sbp"], value["Dbp"]]);
- Map<String, dynamic> nibpData = {
- "Blood": {"Blood": jsonEncode(bloodValue)},
- "Heart_Rate": value["Pulse_Beat"],
- };
- formValue.addAll(nibpData);
- }
- }
- if (key == "GLU") {
- Map<String, dynamic> sugar = {
- "Blood_Sugar": value["sugar"],
- };
- formValue.addAll(sugar);
- }
- });
- logger.i("当前表单数据:${formValue}");
- setState(() {});
- print(e);
- }
- }
- /// title标签
- Widget _buildTitleList() {
- return Wrap(
- runSpacing: 10, // 设置子小部件之间的间距
- spacing: -12,
- alignment: WrapAlignment.start,
- children: currentTemplate.asMap().entries.map(
- (e) {
- /// 处方的处理
- if (FormInfo.instance.formValue.isNotEmpty) {
- formValue["Prescription"] = [];
- }
- /// TODO 这边需要改下
- MaterialColor currentColors = Colors.grey;
- e.value.children?.forEach((element) {
- if (formValue.containsKey(element.key))
- currentColors = Colors.green;
- });
- return TitleClipRect(
- title: e.value.label ?? '',
- color: currentTitleIndex == e.key ? null : currentColors,
- arrowHeight: arrowHeight,
- clickTitle: () {
- 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',
- 'YZJSZASFFW',
- ].contains(widget.cardKey) ||
- widget.cardKey.contains("ET_") ||
- widget.cardKey.contains("FollowUpTuberculosis")) {
- 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 _buildAnteriorFontanelle(FormObject currentFormObject) {
- List<Option> options = currentFormObject.options ?? [];
- String currentSelected = formValue[currentFormObject.key!] ?? "";
- String currentLength = formValue["Fontanel_Length"] ?? "";
- String currentWidth = formValue["Fontanel_Width"] ?? "";
- void selectRaidoChange(Option e) {
- currentSelected = e.value ?? '';
- formValue[currentFormObject.key!] = currentSelected;
- if (e.value == '1' && options.length == 2) {
- formValue["Fontanel_Length"] = "";
- formValue["Fontanel_Width"] = "";
- }
- setState(() {});
- }
- void selectInputChange(String inputKey, String? inputValue) {
- if (inputValue == null) return;
- if (inputKey == "length") {
- currentLength = inputValue;
- formValue["Fontanel_Length"] = currentLength;
- } else if (inputKey == "width") {
- currentWidth = inputValue;
- formValue["Fontanel_Width"] = currentWidth;
- }
- setState(() {});
- }
- return FollowUpChildAnteriorFontanelle(
- options: options,
- currentFormObject: currentFormObject,
- selectRaidoChange: selectRaidoChange,
- currentSelected: currentSelected,
- selectInputChange: selectInputChange,
- formValue: formValue,
- );
- }
- /// 前囟其他
- Widget _buildAnteriorFontanelleOther(FormObject currentFormObject) {
- List<Option> options = currentFormObject.options ?? [];
- String currentSelected = formValue[currentFormObject.key!] ?? "";
- String currentLength = formValue["Fontanel_Length"] ?? "";
- String currentWidth = formValue["Fontanel_Width"] ?? "";
- void selectRaidoChange(Option e) {
- currentSelected = e.value ?? '';
- formValue[currentFormObject.key!] = currentSelected;
- if (e.value == '1' && options.length == 2) {
- formValue["Fontanel_Length"] = "";
- formValue["Fontanel_Width"] = "";
- }
- setState(() {});
- }
- void selectOtherValue(String value) {
- formValue["Fontanel_Other"] = value;
- setState(() {});
- }
- if (currentSelected != '4') {
- formValue["Fontanel_Other"] = "";
- }
- void selectInputChange(String inputKey, String? inputValue) {
- if (inputValue == null) return;
- if (inputKey == "length") {
- currentLength = inputValue;
- formValue["Fontanel_Length"] = currentLength;
- } else if (inputKey == "width") {
- currentWidth = inputValue;
- formValue["Fontanel_Width"] = currentWidth;
- }
- setState(() {});
- }
- return FollowUpChildAnteriorFontanelleOther(
- options: options,
- currentFormObject: currentFormObject,
- selectRaidoChange: selectRaidoChange,
- currentSelected: currentSelected,
- selectInputChange: selectInputChange,
- selectOtherValue: selectOtherValue,
- formValue: formValue,
- );
- }
- /// 转诊建议
- Widget _buildFollowUpChildReferral(FormObject currentFormObject) {
- List<Option> options = currentFormObject.options ?? [];
- String currentSelected = formValue[currentFormObject.key!] ?? "";
- String referralReason = formValue["referralReason"] ?? "";
- String referralOrg = formValue["referralOrg"] ?? "";
- void selectRaidoChange(Option e) {
- currentSelected = e.value ?? '';
- formValue[currentFormObject.key!] = currentSelected;
- if (e.value == '1') {
- formValue["referralReason"] = "";
- formValue["referralOrg"] = "";
- }
- setState(() {});
- }
- void selectInputChange(String inputKey, String? inputValue) {
- if (inputValue == null) return;
- if (inputKey == "reason") {
- referralReason = inputValue;
- formValue["referralReason"] = referralReason;
- } else if (inputKey == "org") {
- referralOrg = inputValue;
- formValue["referralOrg"] = referralOrg;
- }
- setState(() {});
- }
- return FollowUpChildReferral(
- options: options,
- currentFormObject: currentFormObject,
- selectRaidoChange: selectRaidoChange,
- currentSelected: currentSelected,
- selectInputChange: selectInputChange,
- formValue: formValue,
- );
- }
- /// 按钮
- 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 ?? [];
- if (currentFormObject.key == "Diseases_Type") {
- String deathCauseValue = formValue["Death_Cause"] ?? "";
- if (deathCauseValue.isEmpty || deathCauseValue != '1') {
- formValue.remove('Diseases_Type');
- return Container();
- }
- }
- List<dynamic> currentSelectedCheckBox = [];
- if (formValue[currentFormObject.key!] is List<dynamic>) {
- currentSelectedCheckBox = formValue[currentFormObject.key!] ?? [];
- } else {
- currentSelectedCheckBox = [];
- }
- 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 {
- // 最大可选处理
- if (currentFormObject.maxItems != null &&
- currentSelectedCheckBox.length >= currentFormObject.maxItems!) {
- PromptBox.toast('最多选择${currentFormObject.maxItems}项');
- return;
- }
- currentSelectedCheckBox.add(e.value ?? '');
- }
- }
- }
- formValue[currentFormObject.key!] = currentSelectedCheckBox;
- setState(() {});
- }
- return ExamCheckBox(
- options: options,
- currentSelectedCheckBox: currentSelectedCheckBox,
- currentFormObject: currentFormObject,
- selectCheckBoxChange: selectCheckBoxChange,
- disbaleOthers: currentSelectedCheckBox.contains(disabledValue),
- );
- }
- Widget _buildCheckBoxIncludeOther(FormObject currentFormObject) {
- List<Option> options = currentFormObject.options ?? [];
- List<dynamic> currentSelected = formValue[currentFormObject.key!] ?? [];
- dynamic disabledValue = currentFormObject.disabledValue;
- dynamic otherItem = currentFormObject.groupKeys!.first;
- String otherDecrition =
- formValue[currentFormObject.childrenKey!.first] ?? "";
- void selectCheckBoxChange(Option e) {
- if (currentSelected.contains(e.value)) {
- currentSelected.remove(e.value);
- if (e.value == otherItem) {
- otherDecrition = '';
- }
- } else {
- if (disabledValue == e.value) {
- currentSelected = [disabledValue];
- } else {
- if (currentSelected.contains(disabledValue)) {
- // PromptBox.toast('选项冲突');
- } else {
- // 最大可选处理
- if (currentFormObject.maxItems != null &&
- currentSelected.length >= currentFormObject.maxItems!) {
- PromptBox.toast('最多选择${currentFormObject.maxItems}项');
- return;
- }
- currentSelected.add(e.value ?? '');
- }
- }
- }
- formValue[currentFormObject.key!] = currentSelected;
- setState(() {});
- }
- void changeExtraDescription(String? extraDescription) {
- otherDecrition = extraDescription ?? '';
- formValue[currentFormObject.childrenKey!.first] = otherDecrition;
- setState(() {});
- }
- return ExamCheckBoxIncludeOther(
- options: options,
- currentSelectedCheckBox: currentSelected,
- currentFormObject: currentFormObject,
- selectCheckBoxChange: selectCheckBoxChange,
- disbaleOthers: currentSelected.contains(disabledValue),
- changeExtraDescription: changeExtraDescription,
- currentExtraDescription: otherDecrition,
- extraDescriptiveItem: otherItem,
- );
- }
- /// 危险行为
- Widget _buildCheckBoxFrequency(FormObject currentFormObject) {
- List<Option> options = currentFormObject.options ?? [];
- List<dynamic> currentFormObjectFrom =
- formValue[currentFormObject.key!] ?? [];
- String? otherItem = currentFormObject.groupKeys != null &&
- currentFormObject.groupKeys!.length > 0
- ? currentFormObject.groupKeys?.first
- : '';
- String otherDecrition =
- formValue[currentFormObject.childrenKey?.first] ?? "";
- List<DangerFrequency> currentSelectedCheckBox =
- currentFormObjectFrom.map((e) {
- if (e is Map<String, dynamic>) {
- return DangerFrequency.fromJson(e);
- } else {
- return DangerFrequency.fromJson(e.toJson());
- }
- }).toList();
- dynamic disabledValue = currentFormObject.disabledValue;
- Future<void> selectCheckBoxChange(Option e) async {
- var ddd =
- currentSelectedCheckBox.firstWhereOrNull((f) => f.value == e.value);
- if (ddd != null) {
- currentSelectedCheckBox.remove(ddd);
- if (otherItem == e.value) {
- formValue[currentFormObject.childrenKey?.first] = "";
- }
- } else {
- if (disabledValue == e.value) {
- currentSelectedCheckBox = [
- DangerFrequency(frequency: "0", value: disabledValue)
- ];
- } else {
- if (otherItem == e.value) {
- currentSelectedCheckBox
- .add(DangerFrequency(frequency: "0", value: otherItem));
- } else {
- var ccc = currentSelectedCheckBox
- .firstWhereOrNull((f) => f.value == disabledValue);
- if (ccc != null) {
- // PromptBox.toast('选项冲突');
- } else {
- String? result = await VDialogNumber(
- title: "${e.label}次数",
- // initialValue: formValue[currentFormObject.key],
- ).show();
- if (result?.isNotEmpty ?? false) {
- currentSelectedCheckBox.add(
- DangerFrequency(frequency: result, value: e.value ?? ''));
- }
- }
- }
- }
- }
- formValue[currentFormObject.key!] = currentSelectedCheckBox;
- setState(() {});
- }
- void changeExtraDescription(String? extraDescription) {
- otherDecrition = extraDescription ?? '';
- formValue[currentFormObject.childrenKey?.first] = otherDecrition;
- setState(() {});
- }
- return ExamCheckBoxFrequency(
- options: options,
- currentSelectedCheckBox: currentSelectedCheckBox,
- currentFormObject: currentFormObject,
- func: selectCheckBoxChange,
- disbaleOthers: currentSelectedCheckBox
- .firstWhereOrNull((f) => f.value == disabledValue) !=
- null,
- changeExtraDescription: changeExtraDescription,
- currentExtraDescription: otherDecrition,
- extraDescriptiveItem: otherItem,
- );
- }
- /// 数字输入框组件
- 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 FollowBloodPressure(
- 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 _buildDate(FormObject currentFormObject) {
- String currentInputValue = formValue[currentFormObject.key!] ?? '';
- DateTime currentDateValue = DateTime.now();
- if (currentInputValue.isNotNullOrEmpty) {
- DateFormat format = DateFormat('yyyy-MM-dd');
- currentDateValue = format.parse(currentInputValue);
- }
- Future<void> commonInput() async {
- DateTime? result = await VDialogDate(
- title: currentFormObject.label,
- initialValue: currentDateValue,
- maxValue: DateTime.now(),
- ).show();
- if (result != null) {
- formValue[currentFormObject.key!] =
- DateFormat("yyyy-MM-dd").format(result);
- currentInputValue = formValue[currentFormObject.key!];
- setState(() {});
- }
- }
- return ExamInput(
- currentInputValue: currentInputValue,
- commonInput: commonInput,
- currentFormObject: currentFormObject,
- );
- }
- ///两次随访期间住院情况
- Widget _buildRadioHospitalization(FormObject currentFormObject) {
- List<Option> options = currentFormObject.options ?? [];
- String currentSelected = formValue[currentFormObject.key!] ?? '';
- String dateOfDischarge =
- formValue[currentFormObject.childrenKey!.first] ?? '';
- void selectRaidoChange(Option e) {
- currentSelected = currentSelected = e.value ?? "";
- formValue[currentFormObject.key!] = currentSelected;
- setState(() {});
- }
- Future<void> commonInputDate() async {
- DateTime? result = await VDialogDate(
- title: currentFormObject.label,
- // initialValue: currentDateValue,
- maxValue: DateTime.now(),
- ).show();
- if (result != null) {
- dateOfDischarge = DateFormat("yyyy-MM-dd").format(result);
- formValue[currentFormObject.childrenKey!.first] = dateOfDischarge;
- setState(() {});
- }
- }
- return ExamRadioHospitalization(
- options: options,
- currentFormObject: currentFormObject,
- selectRaidoChange: selectRaidoChange,
- currentSelected: currentSelected,
- commonInput: commonInputDate,
- dateOfDischarge: dateOfDischarge,
- );
- }
- ///用药情况与指导
- Widget _buildMedication(FormObject currentFormObject) {
- List<dynamic> currentValue = [];
- var value = formValue[currentFormObject.key!];
- if (value is String) {
- return Container();
- } else {
- if (value != null) currentValue = value;
- }
- Future<void> addVeterinaryDrug() async {
- MedicationModel? result = await VDialogMedication(
- title: currentFormObject.label,
- ).show();
- if (result != null) {
- currentValue.add(result.toJson());
- formValue[currentFormObject.key!] = null;
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- }
- Future<void> deleteVeterinaryDrug(int index) async {
- currentValue.removeAt(index);
- formValue[currentFormObject.key!] = null;
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- Future<void> editVeterinaryDrug(int index) async {
- MedicationModel medicationModel =
- MedicationModel.fromJson(currentValue[index]);
- MedicationModel? result = await VDialogMedication(
- title: currentFormObject.label,
- medicationModel: medicationModel,
- ).show();
- if (result != null) {
- currentValue[index] = result.toJson();
- formValue[currentFormObject.key!] = null;
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- }
- return ExamMedication(
- currentFormObject: currentFormObject,
- currentValues: currentValue,
- addVeterinaryDrug: addVeterinaryDrug,
- deleteVeterinaryDrug: deleteVeterinaryDrug,
- editVeterinaryDrug: editVeterinaryDrug,
- );
- }
- /// 高血压和糖尿病用药情况与指导
- Widget _buildGxyAndTnbMedication(FormObject currentFormObject) {
- List<dynamic> currentValue = [];
- var value = formValue[currentFormObject.key!];
- if (value is String) {
- return Container();
- } else {
- if (value != null) currentValue = value;
- }
- Future<void> addVeterinaryDrug() async {
- MedicationModel? result = await VDialogGxyMedication(
- title: currentFormObject.label,
- ).show();
- if (result != null) {
- currentValue.add(result.toJson());
- formValue[currentFormObject.key!] = null;
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- }
- Future<void> deleteVeterinaryDrug(int index) async {
- currentValue.removeAt(index);
- formValue[currentFormObject.key!] = null;
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- Future<void> editVeterinaryDrug(int index) async {
- MedicationModel medicationModel =
- MedicationModel.fromJson(currentValue[index]);
- MedicationModel? result = await VDialogGxyMedication(
- title: currentFormObject.label,
- medicationModel: medicationModel,
- ).show();
- if (result != null) {
- currentValue[index] = result.toJson();
- formValue[currentFormObject.key!] = null;
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- }
- return FollowUpGxyAndTnbMedication(
- currentFormObject: currentFormObject,
- currentValues: currentValue,
- addVeterinaryDrug: addVeterinaryDrug,
- deleteVeterinaryDrug: deleteVeterinaryDrug,
- editVeterinaryDrug: editVeterinaryDrug,
- );
- }
- ///转诊
- Widget _buildRadioReferral(FormObject currentFormObject) {
- List<Option> options = currentFormObject.options ?? [];
- String currentSelected = formValue[currentFormObject.key!] ?? '';
- String reasonReferral =
- formValue[currentFormObject.childrenKey!.first] ?? '';
- String organizationSection =
- formValue[currentFormObject.childrenKey!.last] ?? '';
- void selectRaidoChange(Option e) {
- currentSelected = e.value ?? '';
- formValue[currentFormObject.key!] = currentSelected;
- setState(() {});
- }
- Future<void> commonInputDate(bool isReasonReferral) async {
- String? result = await VDialogInput(
- title: isReasonReferral ? "转诊原因" : "转诊至机构及科室",
- initialValue: isReasonReferral ? reasonReferral : organizationSection,
- ).show();
- if (result?.isNotEmpty ?? false) {
- if (isReasonReferral) {
- reasonReferral = result ?? '';
- } else {
- organizationSection = result ?? '';
- }
- var currentKey = isReasonReferral
- ? currentFormObject.childrenKey!.first
- : currentFormObject.childrenKey!.last;
- formValue[currentKey] = result ?? '';
- setState(() {});
- }
- }
- return ExamRadioReferral(
- options: options,
- currentFormObject: currentFormObject,
- selectRaidoChange: selectRaidoChange,
- currentSelected: currentSelected,
- commonInput: commonInputDate,
- organizationSection: organizationSection,
- reasonReferral: reasonReferral,
- );
- }
- /// 单选框组件
- 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;
- setState(() {});
- }
- return ExamRadio(
- options: options,
- currentFormObject: currentFormObject,
- selectRaidoChange: selectRaidoChange,
- currentSelected: currentSelected,
- );
- }
- /// 居民详情组件
- Widget _buildResidentDetail(FormObject currentFormObject) {
- return FollowUpResidentDetail();
- }
- 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 _buildRadioInput(FormObject currentFormObject) {
- List<Option> options = currentFormObject.options ?? [];
- String currentSelected =
- formValue[currentFormObject.childrenKey!.first] ?? "";
- String currentValue = formValue[currentFormObject.childrenKey!.last] ?? "";
- void selectRaidoChange(Option e) {
- currentSelected = e.value ?? '';
- formValue[currentFormObject.childrenKey!.first] = currentSelected;
- setState(() {});
- }
- void changeValue(String? value) {
- currentValue = value ?? '';
- formValue[currentFormObject.childrenKey!.last] = currentValue;
- setState(() {});
- }
- return FollowUpChildRadioInput(
- options: options,
- currentFormObject: currentFormObject,
- selectRaidoChange: selectRaidoChange,
- currentSelected: currentSelected,
- changeValue: changeValue,
- currentValue: currentValue,
- );
- }
- Widget _buildRadioExtraDescription(FormObject currentFormObject) {
- print(currentFormObject.toJson());
- List<Option> options = currentFormObject.options ?? [];
- String currentValue = formValue[currentFormObject.key!] ?? "";
- String otherDecrition =
- formValue[currentFormObject.childrenKey!.first] ?? "";
- dynamic otherItem = currentFormObject.groupKeys!.first;
- void selectRaidoChange(Option e) {
- currentValue = e.value ?? '';
- formValue[currentFormObject.key!] = currentValue;
- setState(() {});
- }
- void changeExtraDescription(String? extraDescription) {
- otherDecrition = extraDescription ?? '';
- formValue[currentFormObject.childrenKey!.first] = otherDecrition;
- setState(() {});
- }
- return ExamRadioExtraDescription(
- options: options,
- currentFormObject: currentFormObject,
- selectRaidoChange: selectRaidoChange,
- currentSelected: currentValue,
- changeExtraDescription: changeExtraDescription,
- currentExtraDescription: otherDecrition,
- extraDescriptiveItem: otherItem,
- );
- }
- /// 体温组件
- 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) {
- for (var i in result.keys) {
- if (result[i] == "") {
- return;
- }
- }
- 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,
- );
- }
- /// 处方组件
- Widget _buildPrescription(FormObject currentFormObject) {
- List<dynamic> currentValue = formValue[currentFormObject.key!] ?? [];
- prescriptionKey = currentFormObject.buttonName ?? '';
- return Prescription(
- prescription: prescriptionKey,
- );
- }
- /// 计算儿童状态的方法
- String _setChildHeightAndWeightStatus(
- String currentKey,
- String currentValue,
- ) {
- PatientDTO? currentSelectPatientInfo = Store.user.currentSelectPatientInfo;
- String statusValue = "";
- if (currentSelectPatientInfo != null) {
- int birthdayMonths = int.parse(
- ComputeChildrenLevel.calculateMonthsFromBirthday(
- Store.user.currentSelectPatientInfo?.birthday,
- ),
- );
- switch (currentKey) {
- case "Stature":
- statusValue = ComputeChildrenLevel.calculateHeightStatus(
- Store.user.currentSelectPatientInfo?.patientGender ??
- GenderEnum.Male,
- birthdayMonths,
- double.parse(currentValue),
- );
- break;
- case "Weight":
- statusValue = ComputeChildrenLevel.calculateWidthStatus(
- Store.user.currentSelectPatientInfo?.patientGender ??
- GenderEnum.Male,
- birthdayMonths,
- double.parse(currentValue),
- );
- break;
- case "Wh":
- statusValue = ComputeChildrenLevel.calculateBmiStatus(
- Store.user.currentSelectPatientInfo?.patientGender ??
- GenderEnum.Male,
- birthdayMonths,
- double.parse(formValue["Weight"]),
- double.parse(formValue["Stature"]),
- );
- break;
- default:
- break;
- }
- }
- return statusValue;
- }
- /// 儿童身高、体重、BMI
- Widget _buildChildHeightAndWeight(FormObject currentFormObject) {
- List<Option> options = currentFormObject.options ?? [];
- List<dynamic>? childrenKey = currentFormObject.childrenKey;
- String inputKey = "";
- String radioKey = "";
- if (childrenKey != null && childrenKey.isNotEmpty) {
- inputKey = childrenKey.first;
- radioKey = childrenKey.last;
- }
- void childHeightAndWeightInput(String value) async {
- formValue[inputKey] = value;
- var currentSelectValue =
- await _setChildHeightAndWeightStatus(inputKey, value);
- formValue[radioKey] = options
- .firstWhereOrNull((element) => element.label == currentSelectValue)
- ?.value;
- if (formValue["Stature"] != null && formValue["Weight"] != null) {
- formValue["Wh"] = ((double.parse(formValue["Weight"])) /
- ((double.parse(formValue["Stature"]) / 100) *
- (double.parse(formValue["Stature"]) / 100)))
- .toStringAsFixed(2);
- var currentWhEvaluateSelectValue =
- await _setChildHeightAndWeightStatus("Wh", formValue["Wh"]);
- formValue["Wh_Evaluate"] = options
- .firstWhereOrNull(
- (element) => element.label == currentWhEvaluateSelectValue)
- ?.value;
- print(formValue["Wh_Evaluate"]);
- }
- setState(() {});
- }
- void selectRaidoChange(Option e) {
- formValue[radioKey] = e.value ?? '';
- setState(() {});
- }
- return FollowUpChildHeightAndWeight(
- options: options,
- currentFormObject: currentFormObject,
- childHeightAndWeightInput: childHeightAndWeightInput,
- formValue: formValue,
- selectRaidoChange: selectRaidoChange,
- keys: [inputKey, radioKey],
- );
- }
- }
|