|
@@ -21,11 +21,11 @@ class ConsultationService {
|
|
|
var date = DateTime.utc(
|
|
|
now.year, now.month, now.day, now.hour, now.minute, now.second);
|
|
|
var data = new List<DataItemDTO>.empty();
|
|
|
- data.add(new DataItemDTO("key", "value"));
|
|
|
+ //data.add(new DataItemDTO("key", "value"));
|
|
|
var requet = new ApplyConsultationRequest(
|
|
|
"expertusercode", "d", "s", date, data, "", "");
|
|
|
var body = sprintf(
|
|
|
- '{"jsonrpc": "2.0", "method": "CommonLoginAsync", "params": [{"AnyAccount": "%s", "AnyCode": "", "Password": "%s" }], "id": 1 }',
|
|
|
+ '{"jsonrpc": "2.0", "method": "CommonLoginAsync", "params": [{"AnyAccount": "%s", "AnyCode": "", "Password": "%s", }], "id": 1 }',
|
|
|
[userName, password]);
|
|
|
final response = await client
|
|
|
.post(Uri.parse(AppSettings.host + '/ILoginService'), body: body);
|
|
@@ -72,16 +72,14 @@ class ConsultationService {
|
|
|
as List<Expert>;
|
|
|
|
|
|
body =
|
|
|
- '{"jsonrpc": "2.0", "method": "GetOrganizationSettingAsync", "params": [{"Token": "$token", "SettingType": 2, "Version": "0.0"}], "id": 1 }';
|
|
|
- print('GetOrganizationSettingAsync http.Client()' + body);
|
|
|
+ '{"jsonrpc": "2.0", "method": "FindScanPositionsAsync", "params": [{"Token": "$token"}], "id": 1 }';
|
|
|
+ print('FindScanPositionsAsync http.Client()' + body);
|
|
|
response = await client.post(
|
|
|
- Uri.parse(AppSettings.host + '/IOrganizationService'),
|
|
|
+ Uri.parse(AppSettings.host + '/ILiveConsultationService'),
|
|
|
body: body);
|
|
|
- parsed =
|
|
|
- decodeResponseBody('GetOrganizationSettingAsync', response.bodyBytes);
|
|
|
- var data = jsonDecode(parsed['result']['SettingData']);
|
|
|
- var organSource =
|
|
|
- data['ConsultationInfo']['Booking']['ScanPosition']['Source'];
|
|
|
+ parsed = decodeResponseBody('FindScanPositionsAsync', response.bodyBytes);
|
|
|
+ //var data = jsonDecode(parsed['result']);
|
|
|
+ var organSource = parsed['result'];
|
|
|
|
|
|
var organs = organSource.map<String>((json) => json.toString()).toList()
|
|
|
as List<String>;
|
|
@@ -141,19 +139,48 @@ class ConsultationService {
|
|
|
var token = user?.accessToken;
|
|
|
var client = http.Client();
|
|
|
var patientCode = "2D6DA689ECC54F52A17F20A05BDF5C27"; //TODO should from UI
|
|
|
+ var organizationCode = "Organization_20221020115006aAjF6l";
|
|
|
DateFormat inputFormat = DateFormat("yyyy-MM-ddTHH:mm:ss");
|
|
|
var utcTime = inputFormat.format(time.toUtc()).toString();
|
|
|
var body =
|
|
|
- '{"jsonrpc": "2.0", "method": "ApplyConsultationAsync", "params": [{"Token": "$token", "PatientCode":"$patientCode", "ExpertUserCode": "$expertCode", "DeviceCode": "$deviceCode", "ScanPosition": "$organ", "ConsultationTime":"$utcTime"}], "id": 1 }';
|
|
|
+ '{"jsonrpc": "2.0", "method": "FindPatientByCodeAsync", "params": [{"Token": "$token", "Code":"$patientCode"}], "id": 1 }';
|
|
|
+ print('FindPatientByCodeAsync http.Client()' + body);
|
|
|
+ var response = await client
|
|
|
+ .post(Uri.parse(AppSettings.host + '/IPatientService'), body: body);
|
|
|
+ var parsed =
|
|
|
+ decodeResponseBody('FindPatientByCodeAsync', response.bodyBytes);
|
|
|
+ var data = parsed['result']['PatientData'];
|
|
|
+ var list =
|
|
|
+ data.map<DataItemDTO>((json) => DataItemDTO.fromJson(json)).toList();
|
|
|
+ var patientDatas = jsonEncode(list);
|
|
|
+ body =
|
|
|
+ '{"jsonrpc": "2.0", "method": "ApplyConsultationAsync", "params": [{"Token": "$token","ApplyUserCode":"3C135B470E6448F6854974D46022F7FD", "PatientCode":"$patientCode", "ExpertOrganizationCode":"$organizationCode", "PatientDatas":$patientDatas, "ExpertUserCode": "$expertCode", "DeviceCode": "$deviceCode", "ScanPosition": "$organ", "ConsultationTime":"$utcTime"}], "id": 1 }';
|
|
|
print('ApplyConsultationAsync http.Client()' + body);
|
|
|
- final response = await client.post(
|
|
|
+ response = await client.post(
|
|
|
Uri.parse(AppSettings.host + '/ILiveConsultationService'),
|
|
|
body: body);
|
|
|
- print('ApplyConsultationAsync response.body' + response.body);
|
|
|
- final parsed = jsonDecode(response.body);
|
|
|
- var datas = parsed['result'];
|
|
|
+ parsed = decodeResponseBody('ApplyConsultationAsync', response.bodyBytes);
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+ Future<dynamic> InitiateLiveConsultationAsync(String consultationCode) async {
|
|
|
+ var userService = GetIt.instance.get<UserService>();
|
|
|
+ var user = userService.getCurrentUser();
|
|
|
+ var token = user?.accessToken;
|
|
|
+ var client = http.Client();
|
|
|
+
|
|
|
+ var body =
|
|
|
+ '{"jsonrpc": "2.0", "method": "InitiateLiveConsultationAsync", "params": [{"Token": "$token", "ConsultationCode":"$consultationCode"}], "id": 1 }';
|
|
|
+ print('InitiateLiveConsultationAsync http.Client()' + body);
|
|
|
+ final response = await client.post(
|
|
|
+ Uri.parse(AppSettings.host + '/ILiveConsultationService'),
|
|
|
+ body: body);
|
|
|
+ var parsed =
|
|
|
+ decodeResponseBody('InitiateLiveConsultationAsync', response.bodyBytes);
|
|
|
+ var data = parsed['result'];
|
|
|
+ return data;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
class AppConsultationDataModel {
|
|
@@ -170,9 +197,21 @@ class TokenRequest {
|
|
|
}
|
|
|
|
|
|
class DataItemDTO {
|
|
|
- String key;
|
|
|
- String value;
|
|
|
- DataItemDTO(this.key, this.value);
|
|
|
+ final String key;
|
|
|
+ final String value;
|
|
|
+ DataItemDTO({required this.key, required this.value});
|
|
|
+
|
|
|
+ factory DataItemDTO.fromJson(Map<String, dynamic> json) {
|
|
|
+ return DataItemDTO(
|
|
|
+ key: json['Key'] as String,
|
|
|
+ value: json['Value'] as String,
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, dynamic> toJson() => {
|
|
|
+ "Key": key,
|
|
|
+ "Value": value,
|
|
|
+ };
|
|
|
}
|
|
|
|
|
|
class ApplyConsultationRequest extends TokenRequest {
|