Эх сурвалжийг харах

Merge branch 'master' of http://git.ius.plus:88/Project-Wing/WingCloudServer

# Conflicts:
#	Tools/TestTools/client/lib/ConsultationList.dart
arthur.wu 2 жил өмнө
parent
commit
3743f70784

+ 470 - 0
Tools/TestTools/client/lib/ApprovalConsultationScreen.dart

@@ -0,0 +1,470 @@
+import 'package:flutter/material.dart';
+import 'package:get_it/get_it.dart';
+import 'package:ustest/Services/ConsultationService.dart';
+import 'package:ustest/Services/UserService.dart';
+import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
+import 'package:autocomplete_textfield/autocomplete_textfield.dart';
+
+import 'ConsultationList.dart';
+
+class CustomPicker extends CommonPickerModel {
+  String digits(int value, int length) {
+    return '$value'.padLeft(length, "0");
+  }
+
+  CustomPicker({DateTime? currentTime, LocaleType? locale})
+      : super(locale: locale) {
+    this.currentTime = currentTime ?? DateTime.now();
+    this.setLeftIndex(this.currentTime.hour);
+    this.setMiddleIndex(this.currentTime.minute);
+    this.setRightIndex(this.currentTime.second);
+  }
+
+  @override
+  String? leftStringAtIndex(int index) {
+    if (index >= 0 && index < 24) {
+      return this.digits(index, 2);
+    } else {
+      return null;
+    }
+  }
+
+  @override
+  String? middleStringAtIndex(int index) {
+    if (index >= 0 && index < 60) {
+      return this.digits(index, 2);
+    } else {
+      return null;
+    }
+  }
+
+  @override
+  String? rightStringAtIndex(int index) {
+    if (index >= 0 && index < 60) {
+      return this.digits(index, 2);
+    } else {
+      return null;
+    }
+  }
+
+  @override
+  String leftDivider() {
+    return "|";
+  }
+
+  @override
+  String rightDivider() {
+    return "|";
+  }
+
+  @override
+  List<int> layoutProportions() {
+    return [1, 2, 1];
+  }
+
+  @override
+  DateTime finalTime() {
+    return currentTime.isUtc
+        ? DateTime.utc(
+            currentTime.year,
+            currentTime.month,
+            currentTime.day,
+            this.currentLeftIndex(),
+            this.currentMiddleIndex(),
+            this.currentRightIndex())
+        : DateTime(
+            currentTime.year,
+            currentTime.month,
+            currentTime.day,
+            this.currentLeftIndex(),
+            this.currentMiddleIndex(),
+            this.currentRightIndex());
+  }
+}
+Consultation consultationModel=new Consultation(consultationStatus: 0, id: '', patientName: '', applyUserCode: '', expertUserCode: ''); 
+class ApprovalConsultationScreen extends StatelessWidget {
+  final Consultation model;
+  ApprovalConsultationScreen({required this.model})
+  {
+    consultationModel = model;
+  }
+
+  @override
+  Widget build(BuildContext context) {
+    return Scaffold(
+      backgroundColor: Colors.grey[200],
+      body: const Center(
+        child: SizedBox(
+          width: 400,
+          child: Card(
+            child: ApprovalConsultationForm(),
+          ),
+        ),
+      ),
+    );
+  }
+}
+
+class ApprovalConsultationForm extends StatefulWidget {
+  const ApprovalConsultationForm();
+  @override
+  _ApprovalConsultationFormState createState() => _ApprovalConsultationFormState();
+}
+
+class _ApprovalConsultationFormState extends State<ApprovalConsultationForm> {
+  final patientCodeController = TextEditingController();
+
+
+  List<Expert> selectedUsers = <Expert>[];
+  DateTime time = DateTime.now();
+  GlobalKey<AutoCompleteTextFieldState<Expert>> exportKey =
+      GlobalKey<AutoCompleteTextFieldState<Expert>>();
+
+  double _formProgress = 0;
+
+  _ApprovalConsultationFormState() {
+  }
+
+  @override
+  Widget build(BuildContext context) {
+    return Form(
+      child: FutureBuilder<AppConsultationDataModel>(
+          future: lodaDataAsync(),
+          builder: (context, snapshot) {
+            if (snapshot.hasError) {
+              return const Center(
+                child: Text('An error has occurred!'),
+              );
+            } else if (snapshot.hasData) {
+              return Column(
+                mainAxisSize: MainAxisSize.min,
+                children: [
+                  LinearProgressIndicator(value: _formProgress),
+                  Text('Approval', style: Theme.of(context).textTheme.headline4),
+                  Padding(
+                    padding: const EdgeInsets.all(24.0),
+                    child: Row(
+                      children: [
+                        Expanded(
+                          child: Text(time.toString()),
+                        ),
+                        TextButton(
+                            onPressed: () {
+                              DatePicker.showDatePicker(context,
+                                  showTitleActions: true,
+                                  minTime: DateTime(2022, 3, 5),
+                                  maxTime: DateTime(2024, 6, 7),
+                                  theme: DatePickerTheme(
+                                      headerColor: Colors.orange,
+                                      backgroundColor: Colors.blue,
+                                      itemStyle: TextStyle(
+                                          color: Colors.white,
+                                          fontWeight: FontWeight.bold,
+                                          fontSize: 18),
+                                      doneStyle: TextStyle(
+                                          color: Colors.white,
+                                          fontSize: 16)), onChanged: (date) {
+                                print('change $date in time zone ' +
+                                    date.timeZoneOffset.inHours.toString());
+                              }, onConfirm: (date) {
+                                print('confirm $date');
+                                setState(() {
+                                  this.time = date;
+                                });
+                              },
+                                  currentTime: DateTime.now(),
+                                  locale: LocaleType.en);
+                            },
+                            child: Text(
+                              'date',
+                              style: TextStyle(color: Colors.blue),
+                            )),
+                        TextButton(
+                            onPressed: () {
+                              DatePicker.showTimePicker(context,
+                                  showTitleActions: true, onChanged: (date) {
+                                print('change $date in time zone ' +
+                                    date.timeZoneOffset.inHours.toString());
+                              }, onConfirm: (date) {
+                                print('confirm $date');
+                                setState(() {
+                                  this.time = date;
+                                });
+                              }, currentTime: DateTime.now());
+                            },
+                            child: Text(
+                              'time',
+                              style: TextStyle(color: Colors.blue),
+                            )),
+                      ],
+                    ),
+                  ),
+                  Padding(
+                      padding: const EdgeInsets.all(24.0),
+                      child: DropdownButtonFormField<Expert>(
+                        
+                        decoration: InputDecoration(
+                            hintText: "Select some users",
+                            suffixIcon: Icon(Icons.search)),
+                        onChanged: (item) {
+                          setState(() => setSelectUsers(item) );
+                        },
+                        key: exportKey,
+                        items: snapshot.data!.users
+                            .map((e) => DropdownMenuItem<Expert>(
+                                  child: Text(e.userName),
+                                  value: e,
+                                ))
+                            .toList(),
+                      )),     
+                      Padding(
+              padding: EdgeInsets.all(8.0),
+              child: Row(
+                children: [
+                   
+                       Text(getSelectUsers()),
+                ],
+              ),
+            ),            
+                  Padding(
+                      padding: const EdgeInsets.all(8.0),
+                      child: Row(
+                        mainAxisAlignment: MainAxisAlignment.center,
+                        children: [
+                          TextButton(
+                            style: ButtonStyle(
+                              foregroundColor:
+                                  MaterialStateProperty.resolveWith(
+                                      (Set<MaterialState> states) {
+                                return states.contains(MaterialState.disabled)
+                                    ? null
+                                    : Colors.white;
+                              }),
+                              backgroundColor:
+                                  MaterialStateProperty.resolveWith(
+                                      (Set<MaterialState> states) {
+                                return states.contains(MaterialState.disabled)
+                                    ? null
+                                    : Colors.blue;
+                              }),
+                            ),
+                            onPressed: onSubmit,
+                            child: const Text('Submit'),
+                          ),
+                          Padding(
+                            padding: const EdgeInsets.all(8.0),
+                            child: TextButton(
+                              style: ButtonStyle(
+                                foregroundColor:
+                                    MaterialStateProperty.resolveWith(
+                                        (Set<MaterialState> states) {
+                                  return states.contains(MaterialState.disabled)
+                                      ? null
+                                      : Colors.white;
+                                }),
+                                backgroundColor:
+                                    MaterialStateProperty.resolveWith(
+                                        (Set<MaterialState> states) {
+                                  return states.contains(MaterialState.disabled)
+                                      ? null
+                                      : Colors.blue;
+                                }),
+                              ),
+                              onPressed: () => {Navigator.of(context).pop()},
+                              child: const Text('Cancel'),
+                            ),
+                          ),
+                        ],
+                      )),
+                ],
+              );
+            } else {
+              return const Center(
+                child: CircularProgressIndicator(),
+              );
+            }
+          }),
+    );
+  }
+
+  void setSelectUsers(Expert? user)
+  {
+     if(!this.selectedUsers.contains(user))
+     {
+      this.selectedUsers.add(user!);
+     }
+  }
+
+  String getSelectUsers()
+  {
+    var str = "";
+      this.selectedUsers.forEach((element) {
+        str+=element.userName+" ";
+      });
+       
+      return str;
+  }
+
+  void onSubmit() async {
+    try {
+      var userCodes =<String>[];
+        selectedUsers.forEach((element) {
+        userCodes.add(element.code);
+       });
+      ApprovalConsultationRequest _model = new ApprovalConsultationRequest(
+          consultationModel.id,consultationModel.expertUserCode,this.time,userCodes,"");
+          print(_model.toString());
+      var service = GetIt.instance.get<ConsultationService>();
+      var result = await service.ApprovalConsultationAsync(
+       _model);
+      if (result) {
+        Navigator.of(context).pushNamed('/');
+      }
+    } catch (e) {
+      print('signInAsync ex: $e');
+    }
+  }
+
+  Future<AppConsultationDataModel> lodaDataAsync() async {
+    try {
+      var service = GetIt.instance.get<ConsultationService>();
+      var model = await service.LoadDataAsync();
+      return model;
+    } catch (ex) {
+      print('lodaDataAsync ex' + ex.toString());
+      return Future.error(ex);
+    }
+  }
+}
+
+class ExportInfo {
+  final String id;
+  final String name;
+
+  ExportInfo({required this.id, required this.name});
+
+  factory ExportInfo.fromJson(Map<String, dynamic> json) {
+    var item = ExportInfo(
+      id: json['id'] as String,
+      name: json['name'] as String,
+    );
+
+    return item;
+  }
+
+  Map<String, dynamic> toMap() {
+    return {
+      'id': id,
+      'name': name,
+    };
+  }
+
+  @override
+  String toString() {
+    return 'ExportInfo{id: $id}, {name: $name}';
+  }
+}
+
+enum NotificationTypeEnum {
+  Daiding,
+
+  /// <summary>
+  /// ChatMsgNotification|1| 聊天通知
+  /// </summary>
+  ChatMsgNotification,
+
+  /// <summary>
+  /// UpgradeVersionNotification|2| 版本更新通知
+  /// </summary>
+  UpgradeVersionNotification,
+
+  /// <summary>
+  /// LogoffNotification|3| 登出通知
+  /// </summary>
+  LogoffNotification,
+
+  /// <summary>
+  /// DisconnectNotification| 4|与服务器断开连接通知
+  /// </summary>
+  DisconnectNotification,
+
+  /// <summary>
+  /// ConnectionNotification| 5|	与服务器已连接通知
+  /// </summary>
+  ConnectionNotification,
+
+  /// <summary>
+  ///FinishNotifyRecordsMessage| 6 | 检查记录完成消息类型
+  /// </summary>
+  FinishNotifyRecordsMessage,
+
+  /// <summary>
+  ///InvitedEnterRoomNotification| 7 | 邀请用户加入房间通知
+  /// </summary>
+  InvitedEnterRoomNotification,
+
+  /// <summary>
+  ///CancelInvitedEnterRoomNotification| 8 |取消邀请用户通知
+  /// </summary>
+  CancelInvitedEnterRoomNotification,
+
+  placeholder9,
+  placeholder10,
+  placeholder11,
+  placeholder12,
+  placeholder13,
+  placeholder14,
+  placeholder15,
+  placeholder16,
+  placeholder17,
+  placeholder18,
+  placeholder19,
+  placeholder20,
+  placeholder21,
+  placeholder22,
+  placeholder23,
+  placeholder24,
+
+  /// <summary>
+  /// InviteLiveConsultationNotification| 25 | 开始会诊的通知
+  /// </summary>
+  InviteLiveConsultationNotification,
+
+  /// <summary>
+  /// AcceptLiveConsultationNotification| 26 | 接受会诊的通知
+  /// </summary>
+  AcceptLiveConsultationNotification,
+
+  /// <summary>
+  /// RejectLiveConsultationNotification| 27 | 拒绝会诊的通知
+  /// </summary>
+  RejectLiveConsultationNotification,
+}
+
+class ConnectionNotification {
+  NotificationTypeEnum notificationType;
+  ConnectionNotification({
+    this.notificationType = NotificationTypeEnum.Daiding,
+  });
+  factory ConnectionNotification.fromJson(Map<String, dynamic> map) {
+    return ConnectionNotification(
+      notificationType: NotificationTypeEnum.values
+          .firstWhere((e) => e.index == map['NotificationType']),
+    );
+  }
+}
+
+class DisconnectNotification {
+  NotificationTypeEnum notificationType;
+  DisconnectNotification({
+    this.notificationType = NotificationTypeEnum.Daiding,
+  });
+  factory DisconnectNotification.fromJson(Map<String, dynamic> map) {
+    return DisconnectNotification(
+      notificationType: NotificationTypeEnum.values
+          .firstWhere((e) => e.index == map['NotificationType']),
+    );
+  }
+}
+
+class FinishNotifyRecordsMessage {}

+ 60 - 7
Tools/TestTools/client/lib/ConsultationList.dart

@@ -6,6 +6,7 @@ import 'package:get_it/get_it.dart';
 import 'package:sprintf/sprintf.dart';
 import 'package:http/http.dart' as http;
 
+import 'ApprovalConsultationScreen.dart';
 import 'Services/ConsultationService.dart';
 
 class ConsultationList extends StatefulWidget {
@@ -46,13 +47,28 @@ class _ConsultationListState extends State<ConsultationList> {
                           ),
                           title: Text(widget.consultations[index].id +
                               " - " +
-                              widget.consultations[index].expertName),
-                          subtitle:
-                              Text(widget.consultations[index].patientName),
+                              widget.consultations[index].expertUserCode),
+                          subtitle: Text(
+                              widget.consultations[index].patientName +
+                                  getStatusDesc(widget.consultations[index]
+                                      .consultationStatus)),
                           onTap: (() =>
                               onTabPatient(widget.consultations[index].id)),
                         ),
                       )),
+                      Row(
+                        children: [
+                          Offstage(
+                              offstage: widget.consultations[index]
+                                      .consultationStatus !=
+                                  1,
+                              child: TextButton.icon(
+                                  onPressed: () => onApprovalConsultation(
+                                      context, widget.consultations[index]),
+                                  icon: Icon(Icons.update),
+                                  label: Text("批准")))
+                        ],
+                      ),
                       Container(
                           alignment: Alignment.topRight,
                           child: Container(
@@ -179,21 +195,58 @@ class _ConsultationListState extends State<ConsultationList> {
       print('OnRejectLiveConsultation.to ex' + ex.toString());
     }
   }
+
+  String getStatusDesc(status) {
+    if (status == 1) {
+      return "已申请";
+    } else if (status == 2) {
+      return "已撤回";
+    } else if (status == 3) {
+      return "已拒绝";
+    } else if (status == 4) {
+      return "待开始(即申请已同意)";
+    } else if (status == 5) {
+      return "进行中";
+    } else if (status == 6) {
+      return "待报告";
+    } else if (status == 7) {
+      return "已结束(即会诊报告已提交)";
+    }
+    return "";
+  }
+
+  void onApprovalConsultation(context, Consultation model) {
+    print("onApprovalConsultation click");
+    //Navigator.of(context).pushNamed('/approvalconsultation',arguments: model);
+
+    Navigator.push(
+        context,
+        MaterialPageRoute(
+            builder: (context) => ApprovalConsultationScreen(model: model)));
+  }
 }
 
 class Consultation {
   final String id;
   final String patientName;
-  final String expertName;
+  final int consultationStatus;
+  final String expertUserCode;
+  final String applyUserCode;
 
   Consultation(
-      {required this.id, required this.patientName, required this.expertName});
+      {required this.id,
+      required this.patientName,
+      required this.consultationStatus,
+      required this.expertUserCode,
+      required this.applyUserCode});
 
   factory Consultation.fromJson(Map<String, dynamic> json) {
     var item = Consultation(
+        expertUserCode: json['ExpertUserCode'] as String,
+        applyUserCode: json['ApplyUserCode'] as String,
         id: json['ConsultationCode'] as String,
         patientName: json['PatientName'] as String,
-        expertName: json['ExpertUserName'] as String);
+        consultationStatus: json['ConsultationStatus'] as int);
 
     return item;
   }
@@ -202,7 +255,7 @@ class Consultation {
     return {
       'ConsultationCode': id,
       'PatientName': patientName,
-      'ExpertUserName': expertName,
+      'ExpertUserCode': expertUserCode,
     };
   }
 

+ 75 - 2
Tools/TestTools/client/lib/Services/ConsultationService.dart

@@ -76,7 +76,25 @@ class ConsultationService {
 
     var organs = organSource.map<String>((json) => json.toString()).toList()
         as List<String>;
-    var model = new AppConsultationDataModel(experts, devices, organs);
+
+ 
+    
+    body =
+        '{"jsonrpc": "2.0", "method": "GetUserListAsync", "params": [{"Token": "$token", "OrganizationCode": "$orgCode","OrganizationQueryType":3,"ExceptSelf":true}], "id": 1 }';
+    print('GetUserListAsync http.Client()' + body);
+    response = await client.post(
+        Uri.parse(AppSettings.host + '/IUserService'),
+        body: body);
+
+   
+    print('GetUserListAsync response.body' + response.body);
+    parsed = jsonDecode(response.body);
+    datas = parsed['result'];
+    final users = datas.map<Expert>((json) => Expert.fromJson(json)).toList()
+        as List<Expert>;
+
+
+    var model = new AppConsultationDataModel(experts, devices, organs, users);
     return model;
   }
 
@@ -211,14 +229,43 @@ class ConsultationService {
     var data = parsed['result'];
     return data;
   }
+
+
+
+  Future<bool> ApprovalConsultationAsync(
+    ApprovalConsultationRequest model) async {
+    String consultationCode=model.consultationCode;
+    String expertUserCode =model.expertUserCode;
+    DateTime consultationTime=model.consultationTime;
+    List<String> consultationMemberCodes=<String>[];
+    model.consultationMemberCodes.forEach((element) {
+      consultationMemberCodes.add('"'+element+'"');
+    });
+    var userService = GetIt.instance.get<UserService>();
+    var user = userService.getCurrentUser();
+    var token = user?.accessToken;
+    var client = http.Client();
+    DateFormat inputFormat = DateFormat("yyyy-MM-ddTHH:mm:ss");
+    var utcTime = inputFormat.format(consultationTime.toUtc()).toString();
+    var body =
+        '{"jsonrpc": "2.0", "method": "ApprovalConsultationAsync", "params": [{"Token": "$token","ConsultationCode":"$consultationCode", "ExpertUserCode":"$expertUserCode", "ConsultationTime":"$utcTime", "ConsultationMemberCodes":$consultationMemberCodes }], "id": 1 }';
+    print('ApprovalConsultationAsync http.Client()' + body);
+    var response = await client.post(
+        Uri.parse(AppSettings.host + '/ILiveConsultationService'),
+        body: body);
+    var parsed = decodeResponseBody('ApprovalConsultationAsync', response.bodyBytes);
+    var data = parsed['result'];
+    return data;
+  }
 }
 
 class AppConsultationDataModel {
   final List<Expert> experts;
   final List<Device> devices;
   final List<String> organs;
+  final List<Expert> users;
 
-  AppConsultationDataModel(this.experts, this.devices, this.organs);
+  AppConsultationDataModel(this.experts, this.devices, this.organs,this.users);
 }
 
 class TokenRequest {
@@ -324,3 +371,29 @@ class Organ {
         "Value": orgName,
       };
 }
+
+class ApprovalConsultationRequest extends TokenRequest {
+
+  String consultationCode;
+
+  String expertUserCode;
+
+  DateTime consultationTime;
+
+  List<String> consultationMemberCodes;
+
+
+  ApprovalConsultationRequest(
+      this.consultationCode,
+      this.expertUserCode,
+      this.consultationTime,
+      this.consultationMemberCodes,
+      String token)
+      : super(token);
+
+      @override
+  String toString() {
+    // TODO: implement toString
+     return 'consultationCode: $consultationCode,expertUserCode:$expertUserCode,consultationTime:$consultationTime,consultationMemberCodes:$consultationMemberCodes';
+  }
+}

+ 1 - 1
Tools/TestTools/client/lib/main.dart

@@ -37,7 +37,7 @@ class MyApp extends StatelessWidget {
       routes: {
         '/': (context) => MainScreen(),
         '/signin': (context) => const SignInScreen(),
-        '/applyconsultation': (context) => const ApplyConsultationScreen(),
+        '/applyconsultation': (context) => const ApplyConsultationScreen()      
       },
     );
   }