1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import 'package:fis_jsonrpc/rpc.dart';
- import 'package:vitalapp/rpc.dart';
- import 'package:vitalapp/store/store.dart';
- import 'interfaces/label.dart';
- import 'package:fis_common/logger/logger.dart';
- import 'interfaces/models/crowd_labels.dart';
- class LabelManager implements ILabelManager {
- @override
- Future<List<LabelDTO>?> getLabelListByKey(String key) async {
- try {
- final result = await rpc.vitalLabel.getLabelListByKeyAsync(
- GetLabelListByKeyRequest(key: key, token: Store.user.token),
- );
- return result;
- } catch (e) {
- logger.e("LabelManager get labels by key-$key error.", e);
- return null;
- }
- }
- @override
- Future<List<LabelDTO>> getAllLabels() async {
- List<LabelDTO> result = [];
- result = await rpc.vitalLabel.getCrowdLabelsAsync(
- GetCrowdLabelsRequest(token: Store.user.token),
- );
- return result;
- }
- @override
- Future<List<LabelDTO>> getNormalCrowdLabels() async {
- return (await getLabelListByKey("RQFL")) ?? [];
- }
- @override
- Future<List<LabelDTO>> getDiseaseCrowdLabels() async {
- return (await getLabelListByKey("CJJB")) ?? [];
- }
- @override
- Future<List<LabelDTO>> getSpecialCareCrowdLabels() async {
- return (await getLabelListByKey("TSZG")) ?? [];
- }
- @override
- String transparent(String e) {
- switch (e) {
- case CrowdLabelKeys.CHILDREN:
- return CrowdLabels.CHILDREN;
- case CrowdLabelKeys.ELDERLY:
- return CrowdLabels.ELDERLY;
- case CrowdLabelKeys.HYPERTENSION:
- return CrowdLabels.HYPERTENSION;
- case CrowdLabelKeys.MENTAlDISORDER:
- return CrowdLabels.MENTAlDISORDER;
- case CrowdLabelKeys.TYPE2_DIABETES:
- return CrowdLabels.TYPE2_DIABETES;
- case CrowdLabelKeys.TUBERCULOSIS:
- return CrowdLabels.TUBERCULOSIS;
- case CrowdLabelKeys.PREGNAMTWOMAN:
- return CrowdLabels.PREGNAMTWOMAN;
- }
- return "";
- }
- }
|