|
@@ -0,0 +1,85 @@
|
|
|
+import 'dart:convert';
|
|
|
+
|
|
|
+import 'package:fis_jsonrpc/services/analyzeConfig.m.dart';
|
|
|
+import 'package:fis_jsonrpc/services/followUp.dart';
|
|
|
+import 'package:fis_jsonrpc/services/followUp.m.dart';
|
|
|
+import 'package:uuid/uuid.dart';
|
|
|
+import 'package:vitalapp/database/db.dart';
|
|
|
+import 'package:vitalapp/database/entities/defines.dart';
|
|
|
+import 'package:vitalapp/database/entities/followup.dart';
|
|
|
+import 'package:vitalapp/store/store.dart';
|
|
|
+
|
|
|
+class FollowUpServiceMock extends VitalFollowUpService {
|
|
|
+ FollowUpServiceMock(super.host);
|
|
|
+
|
|
|
+ @override
|
|
|
+ Future<String> createFollowUpAsync(CreateFollowUpRequest request) async {
|
|
|
+ final entity = FollowUpEntity();
|
|
|
+ entity.code = const Uuid().v4().replaceAll('-', ''); // 本地先生成一个Code
|
|
|
+ entity.isValid = true;
|
|
|
+ entity.syncType = OfflineDataSyncType.create;
|
|
|
+ entity.userCode = Store.user.userCode!;
|
|
|
+ entity.patientCode = Store.user.currentSelectPatientInfo!.code!;
|
|
|
+ entity.typeKey = request.key!;
|
|
|
+ entity.templateCode = request.templateCode!;
|
|
|
+ entity.mode = request.followUpMode;
|
|
|
+ entity.followUpTime = request.followUpTime!;
|
|
|
+ entity.dataJson = jsonEncode(request); // 完整缓存请求
|
|
|
+
|
|
|
+ final id = await db.repositories.followUp.insert(entity);
|
|
|
+ final result = id > 0 ? entity.code : "";
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @override
|
|
|
+ Future<bool> updateFollowUpAsync(UpdateFollowUpRequest request) async {
|
|
|
+ FollowUpEntity? entity =
|
|
|
+ await db.repositories.followUp.singleByCode(request.code!);
|
|
|
+ if (entity == null) {
|
|
|
+ entity = FollowUpEntity();
|
|
|
+ entity.isValid = true;
|
|
|
+ entity.syncType = OfflineDataSyncType.update;
|
|
|
+ entity.dataJson = jsonEncode(request);
|
|
|
+ } else {
|
|
|
+ if (entity.syncType == OfflineDataSyncType.create) {
|
|
|
+ final jsonMap = jsonDecode(entity.dataJson);
|
|
|
+ // 创建类型里含有templateCode,不能丢了
|
|
|
+ final createReq = CreateFollowUpRequest.fromJson(jsonMap);
|
|
|
+ createReq.followUpMode = request.followUpMode!;
|
|
|
+ createReq.followUpTime = request.followUpTime;
|
|
|
+ createReq.nextFollowUpTime = request.nextFollowUpTime;
|
|
|
+ createReq.followUpPhotos = request.followUpPhotos;
|
|
|
+ createReq.followUpData = request.followUpData;
|
|
|
+ } else {
|
|
|
+ entity.dataJson = jsonEncode(request);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ entity.code = request.code!;
|
|
|
+ entity.userCode = Store.user.userCode!;
|
|
|
+ entity.patientCode = Store.user.currentSelectPatientInfo!.code!;
|
|
|
+ entity.typeKey = request.key!;
|
|
|
+ entity.followUpTime = request.followUpTime!;
|
|
|
+
|
|
|
+ int result;
|
|
|
+ if (entity.id == 0) {
|
|
|
+ result = await db.repositories.followUp.insert(entity);
|
|
|
+ } else {
|
|
|
+ result = await db.repositories.followUp.update(entity);
|
|
|
+ }
|
|
|
+ return result > 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ @override
|
|
|
+ Future<List<FollowUpRecordDTO>> getFollowUpRecordListAsync(
|
|
|
+ GetFollowUpRecordListRequest request) async {
|
|
|
+ final entities = await db.repositories.followUp
|
|
|
+ .queryPatientAllList(request.patientCode!, Store.user.userCode!);
|
|
|
+ final list = entities.map((e) {
|
|
|
+ final dto = FollowUpRecordDTO();
|
|
|
+// dto.birthday
|
|
|
+ return dto;
|
|
|
+ }).toList();
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+}
|