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?> 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> getAllLabels() async { List result = []; result = await rpc.vitalLabel.getCrowdLabelsAsync( GetCrowdLabelsRequest(token: Store.user.token), ); return result; } @override Future> getNormalCrowdLabels() async { return (await getLabelListByKey("RQFL")) ?? []; } @override Future> getDiseaseCrowdLabels() async { return (await getLabelListByKey("CJJB")) ?? []; } @override Future> 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 ""; } }