ConsultationList.dart 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. import 'dart:convert';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter/widgets.dart';
  4. import 'package:get_it/get_it.dart';
  5. import 'package:sprintf/sprintf.dart';
  6. import 'package:http/http.dart' as http;
  7. import 'ApprovalConsultationScreen.dart';
  8. import 'Services/ConsultationService.dart';
  9. class ConsultationList extends StatefulWidget {
  10. ConsultationList({Key? key, required this.token, required this.consultations})
  11. : super();
  12. final String token;
  13. final List<Consultation> consultations;
  14. @override
  15. _ConsultationListState createState() => _ConsultationListState();
  16. }
  17. class _ConsultationListState extends State<ConsultationList> {
  18. @override
  19. Widget build(BuildContext context) {
  20. return Scaffold(
  21. body: Container(
  22. height: 600,
  23. child: Row(
  24. children: [
  25. Container(
  26. height: 500,
  27. width: 400,
  28. child: ListView(
  29. restorationId: 'list_demo_list_view',
  30. padding: const EdgeInsets.symmetric(vertical: 0),
  31. children: [
  32. for (int index = 0;
  33. index < widget.consultations.length;
  34. index++)
  35. Row(
  36. children: [
  37. Expanded(
  38. child: Container(
  39. child: ListTile(
  40. leading: ExcludeSemantics(
  41. child: Icon(Icons.person),
  42. ),
  43. title: Text(widget.consultations[index].id +
  44. " - " +
  45. widget.consultations[index].expertUserCode),
  46. subtitle: Text(
  47. widget.consultations[index].patientName +
  48. getStatusDesc(widget.consultations[index]
  49. .consultationStatus)),
  50. onTap: (() =>
  51. onTabPatient(widget.consultations[index].id)),
  52. ),
  53. )),
  54. Row(
  55. children: [
  56. Offstage(
  57. offstage: widget.consultations[index]
  58. .consultationStatus !=
  59. 1,
  60. child: TextButton.icon(
  61. onPressed: () => onApprovalConsultation(
  62. context, widget.consultations[index]),
  63. icon: Icon(Icons.update),
  64. label: Text("批准")))
  65. ],
  66. ),
  67. Container(
  68. alignment: Alignment.topRight,
  69. child: Container(
  70. child: Column(
  71. children: [
  72. ClipRRect(
  73. borderRadius: BorderRadius.circular(2),
  74. child: Container(
  75. color: Colors.amber[50],
  76. child: Row(children: [
  77. Icon(
  78. Icons.star,
  79. color: Colors.amber[500],
  80. size: 12,
  81. ),
  82. Text(
  83. "5.0",
  84. style: TextStyle(
  85. color: Colors.amber[900],
  86. fontSize: 9),
  87. ),
  88. ]))),
  89. Container(
  90. child: TextButton(
  91. child: Text("Start"),
  92. onPressed: (() =>
  93. OnStartLiveConsultation(widget
  94. .consultations[index].id))))
  95. ],
  96. ),
  97. )),
  98. Container(
  99. alignment: Alignment.topRight,
  100. child: Container(
  101. child: Column(
  102. children: [
  103. ClipRRect(
  104. borderRadius: BorderRadius.circular(2),
  105. child: Container(
  106. color: Colors.amber[50],
  107. child: Row(children: [
  108. Icon(
  109. Icons.phone_callback,
  110. color: Colors.amber[500],
  111. size: 12,
  112. ),
  113. ]))),
  114. Container(
  115. child: TextButton(
  116. child: Text("Accept"),
  117. onPressed: (() =>
  118. OnAcceptLiveConsultation(widget
  119. .consultations[index].id))))
  120. ],
  121. ),
  122. )),
  123. Container(
  124. alignment: Alignment.topRight,
  125. child: Container(
  126. child: Column(
  127. children: [
  128. ClipRRect(
  129. borderRadius: BorderRadius.circular(2),
  130. child: Container(
  131. color: Colors.amber[50],
  132. child: Row(children: [
  133. Icon(
  134. Icons.phone_callback_outlined,
  135. color:
  136. Color.fromARGB(255, 255, 0, 0),
  137. size: 12,
  138. ),
  139. ]))),
  140. Container(
  141. child: TextButton(
  142. child: Text("Reject"),
  143. onPressed: (() =>
  144. OnRejectLiveConsultation(widget
  145. .consultations[index].id))))
  146. ],
  147. ),
  148. )),
  149. ],
  150. ),
  151. ],
  152. ),
  153. ),
  154. ],
  155. ),
  156. ));
  157. }
  158. void onTabPatient(String id) async {}
  159. void OnStartLiveConsultation(id) async {
  160. try {
  161. var service = GetIt.instance.get<ConsultationService>();
  162. var result = await service.InitiateLiveConsultationAsync(id);
  163. print("InitiateLiveConsultationAsync");
  164. } catch (ex) {
  165. print('OnStartLiveConsultation.to ex' + ex.toString());
  166. }
  167. }
  168. void OnAcceptLiveConsultation(id) async {
  169. try {
  170. var service = GetIt.instance.get<ConsultationService>();
  171. var result = await service.AcceptLiveConsultationAsync(id);
  172. print("AcceptLiveConsultationAsync");
  173. } catch (ex) {
  174. print('OnAcceptLiveConsultation.to ex' + ex.toString());
  175. }
  176. }
  177. void OnRejectLiveConsultation(id) async {
  178. try {
  179. var service = GetIt.instance.get<ConsultationService>();
  180. var result = await service.RejectLiveConsultationAsync(id);
  181. print("RejectLiveConsultationAsync");
  182. } catch (ex) {
  183. print('OnRejectLiveConsultation.to ex' + ex.toString());
  184. }
  185. }
  186. String getStatusDesc(status) {
  187. if (status == 1) {
  188. return "已申请";
  189. } else if (status == 2) {
  190. return "已撤回";
  191. } else if (status == 3) {
  192. return "已拒绝";
  193. } else if (status == 4) {
  194. return "待开始(即申请已同意)";
  195. } else if (status == 5) {
  196. return "进行中";
  197. } else if (status == 6) {
  198. return "待报告";
  199. } else if (status == 7) {
  200. return "已结束(即会诊报告已提交)";
  201. }
  202. return "";
  203. }
  204. void onApprovalConsultation(context, Consultation model) {
  205. print("onApprovalConsultation click");
  206. //Navigator.of(context).pushNamed('/approvalconsultation',arguments: model);
  207. Navigator.push(
  208. context,
  209. MaterialPageRoute(
  210. builder: (context) => ApprovalConsultationScreen(model: model)));
  211. }
  212. }
  213. class Consultation {
  214. final String id;
  215. final String patientName;
  216. final int consultationStatus;
  217. final String expertUserCode;
  218. final String applyUserCode;
  219. Consultation(
  220. {required this.id,
  221. required this.patientName,
  222. required this.consultationStatus,
  223. required this.expertUserCode,
  224. required this.applyUserCode});
  225. factory Consultation.fromJson(Map<String, dynamic> json) {
  226. var item = Consultation(
  227. expertUserCode: json['ExpertUserCode'] as String,
  228. applyUserCode: json['ApplyUserCode'] as String,
  229. id: json['ConsultationCode'] as String,
  230. patientName: json['PatientName'] as String,
  231. consultationStatus: json['ConsultationStatus'] as int);
  232. return item;
  233. }
  234. Map<String, dynamic> toMap() {
  235. return {
  236. 'ConsultationCode': id,
  237. 'PatientName': patientName,
  238. 'ExpertUserCode': expertUserCode,
  239. };
  240. }
  241. @override
  242. String toString() {
  243. return 'Patient{id: $id}';
  244. }
  245. }