123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- import 'package:flutter/foundation.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:get/get.dart';
- import 'package:vitalapp/managers/interfaces/template.dart';
- import 'package:vitalapp/pages/form/form_view.dart';
- import 'prescription_form_keys.dart';
- ///处方表
- class PrescriptionForm extends StatefulWidget {
- final String formKey;
- PrescriptionForm(this.formKey);
- @override
- State<StatefulWidget> createState() {
- return PrescriptionFormState();
- }
- }
- class PrescriptionFormState extends State<PrescriptionForm> {
- String? _template;
- @override
- void initState() {
- if (kDebugMode) {
- switch (widget.formKey) {
- case PrescriptionFormKeys.PEDDP:
- var _path = "assets/pediatric_diarrhea_prescription.json";
- rootBundle.loadString(_path).then((value) {
- setState(() {
- _template = value;
- });
- });
- break;
- case PrescriptionFormKeys.PALP:
- var _path = "assets/PediatricAcuteLeukemiaPrescription.json";
- rootBundle.loadString(_path).then((value) {
- setState(() {
- _template = value;
- });
- });
- break;
- case PrescriptionFormKeys.PMP:
- var _path = "assets/PediatricMyopiaPrescription.json";
- rootBundle.loadString(_path).then((value) {
- setState(() {
- _template = value;
- });
- });
- break;
- case PrescriptionFormKeys.PCP:
- var _path = "assets/PediatricCariesPrescription.json";
- rootBundle.loadString(_path).then((value) {
- setState(() {
- _template = value;
- });
- });
- break;
- case PrescriptionFormKeys.PIDAP:
- var _path = "assets/PediatricIronDeficiencyAnemiaPrescription.json";
- rootBundle.loadString(_path).then((value) {
- setState(() {
- _template = value;
- });
- });
- break;
- case PrescriptionFormKeys.PCHDP:
- var _path = "assets/PediatricCongenitalHeartDiseasePrescription.json";
- rootBundle.loadString(_path).then((value) {
- setState(() {
- _template = value;
- });
- });
- break;
- case PrescriptionFormKeys.LCP:
- var _path = "assets/LungCancerPrescription.json";
- rootBundle.loadString(_path).then((value) {
- setState(() {
- _template = value;
- });
- });
- break;
- case PrescriptionFormKeys.CCP:
- var _path = "assets/CervicalCancerPrescription.json";
- rootBundle.loadString(_path).then((value) {
- setState(() {
- _template = value;
- });
- });
- break;
- case PrescriptionFormKeys.PFCPL:
- var _path = "assets/PrescriptionForCervicalPrecancerousLesions.json";
- rootBundle.loadString(_path).then((value) {
- setState(() {
- _template = value;
- });
- });
- break;
- case PrescriptionFormKeys.OP:
- var _path = "assets/OsteoarthritisPrescription.json";
- rootBundle.loadString(_path).then((value) {
- setState(() {
- _template = value;
- });
- });
- break;
- case PrescriptionFormKeys.PFCHD:
- var _path = "assets/PrescriptionForCoronaryHeartDisease.json";
- rootBundle.loadString(_path).then((value) {
- setState(() {
- _template = value;
- });
- });
- break;
- case PrescriptionFormKeys.PFAC:
- var _path = "assets/PrescriptionForAcuteCervicitis.json";
- rootBundle.loadString(_path).then((value) {
- setState(() {
- _template = value;
- });
- });
- break;
- case PrescriptionFormKeys.PFCC:
- var _path = "assets/PrescriptionForColorectalCancer.json";
- rootBundle.loadString(_path).then((value) {
- setState(() {
- _template = value;
- });
- });
- break;
- case PrescriptionFormKeys.PFKD:
- var _path = "assets/PrescriptionForKeshanDisease.json";
- rootBundle.loadString(_path).then((value) {
- setState(() {
- _template = value;
- });
- });
- break;
- case PrescriptionFormKeys.PFRA:
- var _path = "assets/PrescriptionForRheumatoidArthritis.json";
- rootBundle.loadString(_path).then((value) {
- setState(() {
- _template = value;
- });
- });
- break;
- case PrescriptionFormKeys.PFCOPD:
- var _path =
- "assets/PrescriptionForChronicObstructivePulmonaryDisease.json";
- rootBundle.loadString(_path).then((value) {
- setState(() {
- _template = value;
- });
- });
- break;
- case PrescriptionFormKeys.PFCD:
- var _path = "assets/PrescriptionForCerebrovascularDisease.json";
- rootBundle.loadString(_path).then((value) {
- setState(() {
- _template = value;
- });
- });
- break;
- case PrescriptionFormKeys.PFRF:
- var _path = "assets/PrescriptionForRenalFailure.json";
- rootBundle.loadString(_path).then((value) {
- setState(() {
- _template = value;
- });
- });
- break;
- case PrescriptionFormKeys.PFPID:
- var _path = "assets/PrescriptionForPelvicInflammatoryDisease.json";
- rootBundle.loadString(_path).then((value) {
- setState(() {
- _template = value;
- });
- });
- break;
- case PrescriptionFormKeys.PFTO:
- var _path = "assets/PrescriptionForTeenageObesity.json";
- rootBundle.loadString(_path).then((value) {
- setState(() {
- _template = value;
- });
- });
- break;
- case PrescriptionFormKeys.PFTD:
- var _path = "assets/PrescriptionForTeenageDepression.json";
- rootBundle.loadString(_path).then((value) {
- setState(() {
- _template = value;
- });
- });
- break;
- }
- } else {
- Get.find<ITemplateManager>()
- .getTemplateByKey(widget.formKey)
- .then((value) {
- setState(() {
- _template = value;
- });
- });
- }
- super.initState();
- }
- @override
- Widget build(BuildContext context) {
- return _template == null
- ? Center(
- child: CircularProgressIndicator(),
- )
- : FormView(_template!);
- }
- }
|