prescription_form.dart 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. import 'package:flutter/foundation.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/services.dart';
  4. import 'package:get/get.dart';
  5. import 'package:vitalapp/managers/interfaces/template.dart';
  6. import 'package:vitalapp/pages/form/form_view.dart';
  7. import 'prescription_form_keys.dart';
  8. ///处方表
  9. class PrescriptionForm extends StatefulWidget {
  10. final String formKey;
  11. PrescriptionForm(this.formKey);
  12. @override
  13. State<StatefulWidget> createState() {
  14. return PrescriptionFormState();
  15. }
  16. }
  17. class PrescriptionFormState extends State<PrescriptionForm> {
  18. String? _template;
  19. @override
  20. void initState() {
  21. if (kDebugMode) {
  22. switch (widget.formKey) {
  23. case PrescriptionFormKeys.PEDDP:
  24. var _path = "assets/pediatric_diarrhea_prescription.json";
  25. rootBundle.loadString(_path).then((value) {
  26. setState(() {
  27. _template = value;
  28. });
  29. });
  30. break;
  31. case PrescriptionFormKeys.PALP:
  32. var _path = "assets/PediatricAcuteLeukemiaPrescription.json";
  33. rootBundle.loadString(_path).then((value) {
  34. setState(() {
  35. _template = value;
  36. });
  37. });
  38. break;
  39. case PrescriptionFormKeys.PMP:
  40. var _path = "assets/PediatricMyopiaPrescription.json";
  41. rootBundle.loadString(_path).then((value) {
  42. setState(() {
  43. _template = value;
  44. });
  45. });
  46. break;
  47. case PrescriptionFormKeys.PCP:
  48. var _path = "assets/PediatricCariesPrescription.json";
  49. rootBundle.loadString(_path).then((value) {
  50. setState(() {
  51. _template = value;
  52. });
  53. });
  54. break;
  55. case PrescriptionFormKeys.PIDAP:
  56. var _path = "assets/PediatricIronDeficiencyAnemiaPrescription.json";
  57. rootBundle.loadString(_path).then((value) {
  58. setState(() {
  59. _template = value;
  60. });
  61. });
  62. break;
  63. case PrescriptionFormKeys.PCHDP:
  64. var _path = "assets/PediatricCongenitalHeartDiseasePrescription.json";
  65. rootBundle.loadString(_path).then((value) {
  66. setState(() {
  67. _template = value;
  68. });
  69. });
  70. break;
  71. case PrescriptionFormKeys.LCP:
  72. var _path = "assets/LungCancerPrescription.json";
  73. rootBundle.loadString(_path).then((value) {
  74. setState(() {
  75. _template = value;
  76. });
  77. });
  78. break;
  79. case PrescriptionFormKeys.CCP:
  80. var _path = "assets/CervicalCancerPrescription.json";
  81. rootBundle.loadString(_path).then((value) {
  82. setState(() {
  83. _template = value;
  84. });
  85. });
  86. break;
  87. case PrescriptionFormKeys.PFCPL:
  88. var _path = "assets/PrescriptionForCervicalPrecancerousLesions.json";
  89. rootBundle.loadString(_path).then((value) {
  90. setState(() {
  91. _template = value;
  92. });
  93. });
  94. break;
  95. case PrescriptionFormKeys.OP:
  96. var _path = "assets/OsteoarthritisPrescription.json";
  97. rootBundle.loadString(_path).then((value) {
  98. setState(() {
  99. _template = value;
  100. });
  101. });
  102. break;
  103. case PrescriptionFormKeys.PFCHD:
  104. var _path = "assets/PrescriptionForCoronaryHeartDisease.json";
  105. rootBundle.loadString(_path).then((value) {
  106. setState(() {
  107. _template = value;
  108. });
  109. });
  110. break;
  111. case PrescriptionFormKeys.PFAC:
  112. var _path = "assets/PrescriptionForAcuteCervicitis.json";
  113. rootBundle.loadString(_path).then((value) {
  114. setState(() {
  115. _template = value;
  116. });
  117. });
  118. break;
  119. case PrescriptionFormKeys.PFCC:
  120. var _path = "assets/PrescriptionForColorectalCancer.json";
  121. rootBundle.loadString(_path).then((value) {
  122. setState(() {
  123. _template = value;
  124. });
  125. });
  126. break;
  127. case PrescriptionFormKeys.PFKD:
  128. var _path = "assets/PrescriptionForKeshanDisease.json";
  129. rootBundle.loadString(_path).then((value) {
  130. setState(() {
  131. _template = value;
  132. });
  133. });
  134. break;
  135. case PrescriptionFormKeys.PFRA:
  136. var _path = "assets/PrescriptionForRheumatoidArthritis.json";
  137. rootBundle.loadString(_path).then((value) {
  138. setState(() {
  139. _template = value;
  140. });
  141. });
  142. break;
  143. case PrescriptionFormKeys.PFCOPD:
  144. var _path =
  145. "assets/PrescriptionForChronicObstructivePulmonaryDisease.json";
  146. rootBundle.loadString(_path).then((value) {
  147. setState(() {
  148. _template = value;
  149. });
  150. });
  151. break;
  152. case PrescriptionFormKeys.PFCD:
  153. var _path = "assets/PrescriptionForCerebrovascularDisease.json";
  154. rootBundle.loadString(_path).then((value) {
  155. setState(() {
  156. _template = value;
  157. });
  158. });
  159. break;
  160. case PrescriptionFormKeys.PFRF:
  161. var _path = "assets/PrescriptionForRenalFailure.json";
  162. rootBundle.loadString(_path).then((value) {
  163. setState(() {
  164. _template = value;
  165. });
  166. });
  167. break;
  168. case PrescriptionFormKeys.PFPID:
  169. var _path = "assets/PrescriptionForPelvicInflammatoryDisease.json";
  170. rootBundle.loadString(_path).then((value) {
  171. setState(() {
  172. _template = value;
  173. });
  174. });
  175. break;
  176. case PrescriptionFormKeys.PFTO:
  177. var _path = "assets/PrescriptionForTeenageObesity.json";
  178. rootBundle.loadString(_path).then((value) {
  179. setState(() {
  180. _template = value;
  181. });
  182. });
  183. break;
  184. case PrescriptionFormKeys.PFTD:
  185. var _path = "assets/PrescriptionForTeenageDepression.json";
  186. rootBundle.loadString(_path).then((value) {
  187. setState(() {
  188. _template = value;
  189. });
  190. });
  191. break;
  192. }
  193. } else {
  194. Get.find<ITemplateManager>()
  195. .getTemplateByKey(widget.formKey)
  196. .then((value) {
  197. setState(() {
  198. _template = value;
  199. });
  200. });
  201. }
  202. super.initState();
  203. }
  204. @override
  205. Widget build(BuildContext context) {
  206. return _template == null
  207. ? Center(
  208. child: CircularProgressIndicator(),
  209. )
  210. : FormView(_template!);
  211. }
  212. }