12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- import 'dart:convert';
- import 'package:fis_jsonrpc/rpc.dart';
- import 'package:get/get.dart';
- import 'interfaces/data_convert.dart';
- import 'interfaces/dictionary.dart';
- class DataConvertManager implements IDataConvertManager {
- @override
- String heartRateConversion(int heartRate) {
- if (heartRate < 60) {
- return "心率过低";
- } else if (heartRate > 100) {
- return "心率过快";
- }
- return "心率值未见异常";
- }
- @override
- Future<List<List<String>>> getTableData(String data) async {
- var currentDiagnosis = <List<String>>[];
- if (data.isEmpty) {
- return currentDiagnosis;
- }
- var jsonData = json.decode(data);
- List<String> keys = jsonData.keys.toList();
- List<DictionaryWithUnitDTO>? dtos = [];
- dtos = await Get.find<IDictionaryManager>()
- .getDictionaryNameAndUnitByKeysAsync(keys) ??
- [];
- for (var key in keys) {
- if (key == "ECG_POINT" ||
- key == "ECG_POINT12" ||
- key == "HealthGuidance") {
- continue;
- }
- var dto = dtos.firstWhereOrNull((item) => item.key == key);
- if (dto == null) {
- continue;
- }
- final value = jsonData[key].toString();
- if (value.isEmpty) {
- // 不展示空值
- continue;
- }
- currentDiagnosis.add([
- dto.name ?? '',
- value,
- dto.unit ?? '',
- ]);
- }
- return currentDiagnosis;
- }
- }
|