|
@@ -1,76 +1,16 @@
|
|
|
-import 'package:fis_jsonrpc/rpc.dart';
|
|
|
-import 'package:get/get.dart';
|
|
|
-import 'package:uuid/uuid.dart';
|
|
|
import 'package:vitalapp/architecture/defines.dart';
|
|
|
-import 'package:vitalapp/architecture/storage/text_storage.dart';
|
|
|
-import 'package:vitalapp/architecture/utils/prompt_box.dart';
|
|
|
-import 'package:vitalapp/managers/interfaces/follow_up.dart';
|
|
|
import 'package:vitalapp/store/store.dart';
|
|
|
|
|
|
import 'state.dart';
|
|
|
|
|
|
class TraditionalChineseMedicineConstitutionController extends FControllerBase {
|
|
|
final state = TraditionalChineseMedicineConstitutionState();
|
|
|
- final _followUpManager = Get.find<IFollowUpManager>();
|
|
|
late String patientCode;
|
|
|
- late String batchNumber;
|
|
|
+
|
|
|
@override
|
|
|
void onReady() {
|
|
|
update(["traditionalChineseMedicineConstitution"]);
|
|
|
patientCode = Store.user.currentSelectPatientInfo?.code ?? '';
|
|
|
- getBatchNumber();
|
|
|
super.onReady();
|
|
|
}
|
|
|
-
|
|
|
- Future<void> getBatchNumber() async {
|
|
|
- var cachedBatchNumber = await readCachedBatchNumber();
|
|
|
- if (cachedBatchNumber != null) {
|
|
|
- batchNumber = cachedBatchNumber;
|
|
|
- } else {
|
|
|
- await saveCachedBatchNumber();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- Future<bool?> saveCachedBatchNumber() async {
|
|
|
- batchNumber = const Uuid().v4().replaceAll('-', '');
|
|
|
- TextStorage cachedRecord = TextStorage(
|
|
|
- fileName: 'batchNumber',
|
|
|
- directory: "patient/$patientCode",
|
|
|
- );
|
|
|
- return cachedRecord.save(batchNumber);
|
|
|
- }
|
|
|
-
|
|
|
- Future<String?> readCachedBatchNumber() async {
|
|
|
- TextStorage cachedRecord = TextStorage(
|
|
|
- fileName: 'batchNumber',
|
|
|
- directory: "patient/$patientCode",
|
|
|
- );
|
|
|
- return cachedRecord.read();
|
|
|
- }
|
|
|
-
|
|
|
- Future<bool> createFollowUp(key, templateCode, data) async {
|
|
|
- if (data.length < 7) {
|
|
|
- //空数据
|
|
|
- PromptBox.toast('不能提交空数据');
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- final result = await _followUpManager.createFollowUp(
|
|
|
- CreateFollowUpRequest(
|
|
|
- key: key,
|
|
|
- patientCode: patientCode,
|
|
|
- templateCode: templateCode,
|
|
|
- followUpData: data,
|
|
|
- followUpTime: DateTime.now(),
|
|
|
- nextFollowUpTime: DateTime.now(),
|
|
|
- followUpMode: FollowUpModeEnum.Outpatient,
|
|
|
- followUpPhotos: List.empty(),
|
|
|
- ),
|
|
|
- );
|
|
|
- if (result.isNotEmpty) {
|
|
|
- PromptBox.toast('保存成功');
|
|
|
- }
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
}
|