12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871 |
- 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 = {};
- String templateCode = '';
- /// 当前模板数据
- 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(() {});
- if (!FPlatform.isWindows) {
- return;
- }
- }
- // if (templateContent.isNullOrEmpty)
- // template = await _templateManager.readTemplate(templateRelation[key]!);
- // if (templateContent.isNullOrEmpty)
- // templateContent =
- List<Map<String, dynamic>> list = [];
- String? template;
- if (templateRelation.containsKey(key)) {
- templateCode = templateRelation[key]!;
- template = await _templateManager.readTemplate(templateCode);
- }
- if (template == null) {
- var json = await loadJsonFromAssets('assets/templates/${key}.json');
- list = jsonDecode(json)["Content"].cast<Map<String, dynamic>>();
- } else {
- var templateContent =
- TemplateDTO.fromJson(jsonDecode(template)).templateContent!;
- 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,
- templateCode,
- 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 {
- if (["TNB", "GXY"].contains(widget.cardKey)) {
- for (var element in currentTemplate) {
- for (var child in element.children!) {
- if (child.required ?? false) {
- var value = formValue[child.key];
- if (value == null || value.length <= 0) {
- PromptBox.toast("有必填项未填写,请检查");
- return;
- }
- }
- }
- }
- }
- final result = await widget.callBack(
- widget.cardKey,
- templateCode,
- 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.remove("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,
- currentFormObject: currentFormObject,
- );
- }
- 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) {
- bool parseResult = false;
- try {
- DateFormat format = DateFormat('yyyy-MM-dd');
- currentDateValue = format.parse(currentInputValue);
- parseResult = true;
- } catch (e) {
- logger.e("_buildDate yyyy-MM-dd error:", e);
- }
- try {
- DateFormat format = DateFormat('yyyyMMdd');
- currentDateValue = format.parse(currentInputValue);
- parseResult = true;
- } catch (e) {
- logger.e("_buildDate yyyyMMdd error:", e);
- }
- }
- 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 && currentFormObject.key != "Appraisal") {
- return Container();
- } else if (value != null && value is List) {
- currentValue = value;
- } else if (currentFormObject.key == "Appraisal" && value is String) {
- ///老版本的用药情况就是字符串
- currentValue = [
- {"name": 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],
- );
- }
- }
|