|
@@ -3,6 +3,7 @@ import 'dart:convert';
|
|
|
import 'package:fis_common/index.dart';
|
|
|
import 'package:fis_common/logger/logger.dart';
|
|
|
import 'package:fis_jsonrpc/rpc.dart';
|
|
|
+import 'package:flutter/foundation.dart';
|
|
|
import 'package:flutter/services.dart';
|
|
|
import 'package:get/get.dart';
|
|
|
import 'package:excel/excel.dart';
|
|
@@ -37,6 +38,7 @@ class ExcelDataManager implements IExcelDataManager {
|
|
|
"Blood_PlateletDW",
|
|
|
"Blood_PlateletPct"
|
|
|
];
|
|
|
+
|
|
|
final List<String> _biochemicalKeys = [
|
|
|
"Liver_Alt",
|
|
|
"Liver_Ast",
|
|
@@ -59,14 +61,43 @@ class ExcelDataManager implements IExcelDataManager {
|
|
|
"Globulin",
|
|
|
];
|
|
|
|
|
|
+ final List<String> biochemicalValues_CQZYKeys = [
|
|
|
+ "Liver_Alt",
|
|
|
+ "Liver_Ast",
|
|
|
+ "Liver_Tbil",
|
|
|
+ "Liver_Dbil",
|
|
|
+ "Liver_Alb",
|
|
|
+ "Urea",
|
|
|
+ "Lipid_Cho",
|
|
|
+ "Lipid_Tg",
|
|
|
+ "Lipid_Ldl",
|
|
|
+ "Lipid_Hdl",
|
|
|
+ "BCH_Glu",
|
|
|
+ "Renal_Cr",
|
|
|
+ ];
|
|
|
+
|
|
|
///将csv中的数据解析成结构化数据
|
|
|
@override
|
|
|
Future<List<ExcelDataRecord>> CsvDataConvert(
|
|
|
List<List<dynamic>> datas, String key) async {
|
|
|
- var json = await Get.find<ITemplateManager>()
|
|
|
- .getTemplateByKey("BiochemicalValues");
|
|
|
+ List<String> keys = [];
|
|
|
+ if (key.contains("BiochemicalValues_CQZY")) {
|
|
|
+ keys = biochemicalValues_CQZYKeys;
|
|
|
+ } else if (key.contains("Biochemical")) {}
|
|
|
+ String json = '';
|
|
|
+
|
|
|
+ json = await Get.find<ITemplateManager>().getTemplateByKey(key);
|
|
|
+ if (kDebugMode) {
|
|
|
+ // String path = "assets/BiochemicalValues_CQZY.json";
|
|
|
+ // json = await rootBundle.loadString(path);
|
|
|
+ }
|
|
|
List<ExcelDataRecord> csvRevords = [];
|
|
|
- List<dynamic> items = jsonDecode(json);
|
|
|
+
|
|
|
+ List<dynamic> items = [];
|
|
|
+ items = jsonDecode(json);
|
|
|
+ if (kDebugMode) {
|
|
|
+ // items = jsonDecode(json)["Content"];
|
|
|
+ }
|
|
|
List<List<List<dynamic>>> result = _splitIntoChunks(datas);
|
|
|
for (List<List<dynamic>> chunkDatas in result) {
|
|
|
List<ExcelDataItem> csvDatas = [];
|
|
@@ -91,14 +122,21 @@ class ExcelDataManager implements IExcelDataManager {
|
|
|
} else {
|
|
|
continue;
|
|
|
}
|
|
|
- csvDatas.add(ExcelDataItem(
|
|
|
- key: key,
|
|
|
- value: value,
|
|
|
- des: des,
|
|
|
- unit: unit,
|
|
|
- identifier: identifier,
|
|
|
- referenceRange: referenceRange,
|
|
|
- ));
|
|
|
+
|
|
|
+ ///过滤不需要展示的数据
|
|
|
+ if (keys.contains(key) ||
|
|
|
+ key == "sampleBarcode" ||
|
|
|
+ key == "patientName" ||
|
|
|
+ key == "samplingTime") {
|
|
|
+ csvDatas.add(ExcelDataItem(
|
|
|
+ key: key,
|
|
|
+ value: value,
|
|
|
+ des: des,
|
|
|
+ unit: unit,
|
|
|
+ identifier: identifier,
|
|
|
+ referenceRange: referenceRange,
|
|
|
+ ));
|
|
|
+ }
|
|
|
}
|
|
|
} catch (e) {
|
|
|
logger.e("CsvDataManager csvDataConvert ex:", e);
|
|
@@ -176,6 +214,14 @@ class ExcelDataManager implements IExcelDataManager {
|
|
|
Future<bool> uploadDatas(
|
|
|
List<ExcelDataRecord> datas, String templateKey) async {
|
|
|
try {
|
|
|
+ List<String> keys = [];
|
|
|
+ if (templateKey.contains("BiochemicalValues_CQZY")) {
|
|
|
+ keys = biochemicalValues_CQZYKeys;
|
|
|
+ } else if (templateKey.contains("BloodRoutine")) {
|
|
|
+ keys = _bloodRoutineKeys;
|
|
|
+ } else if (templateKey.contains("Biochemical")) {
|
|
|
+ keys = _biochemicalKeys;
|
|
|
+ }
|
|
|
if (ExcelTemplateKeys.AllBiochemicalKeys.contains(templateKey)) {
|
|
|
templateKey = "HEIBiochemical";
|
|
|
} else if (ExcelTemplateKeys.AllBloodRoutineKeys.contains(templateKey)) {
|
|
@@ -188,12 +234,7 @@ class ExcelDataManager implements IExcelDataManager {
|
|
|
items.firstWhere((element) => element.key == "sampleBarcode").value;
|
|
|
String examTimeStr =
|
|
|
items.firstWhere((element) => element.key == "samplingTime").value;
|
|
|
- List<String> keys = [];
|
|
|
- if (templateKey.contains("BloodRoutine")) {
|
|
|
- keys = _bloodRoutineKeys;
|
|
|
- } else if (templateKey.contains("Biochemical")) {
|
|
|
- keys = _biochemicalKeys;
|
|
|
- }
|
|
|
+
|
|
|
// 使用DateFormat格式化日期,去除时间部分
|
|
|
DateFormat dateOnlyFormat = DateFormat('yyyy-MM-dd');
|
|
|
DateTime dateOnlyDateTime = dateOnlyFormat.parse(examTimeStr);
|