123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- import 'package:fis_common/helpers/encrypt.dart';
- import 'package:fis_i18n/i18n.dart';
- import 'package:fis_jsonrpc/rpc.dart';
- import 'package:get/get.dart';
- import 'package:fis_common/logger/logger.dart';
- import 'package:vitalapp/helper/utc_dateTime_converter.dart';
- import 'package:vitalapp/managers/interfaces/remedical.dart';
- import 'package:vitalapp/pages/patient/create/widgets/patient_info.dart';
- import 'package:vitalapp/rpc.dart';
- import 'interfaces/base_manager.dart';
- import 'interfaces/models/process_arg.dart';
- import 'package:fis_common/event/event_type.dart';
- import 'simple_Info.dart';
- class RemedicalManager extends BaseManager implements IRemedicalManager {
- final processChange = FEventHandler<ProcessArg>();
- @override
- Future<PageResult<ClientPatientInfoBaseDTO>> findPatients({
- int pageIndex = 1,
- int pageSize = 20,
- String keyWord = '',
- DateTime? startDateTime,
- DateTime? endDateTime,
- PatientValidStatusEnum isValid = PatientValidStatusEnum.All,
- }) async {
- final patients = await rpc.patient.findPatientsAsync(
- FindPatientsPageRequest(
- token: token,
- pageIndex: pageIndex,
- pageSize: pageSize,
- keyWord: keyWord,
- startTime: startDateTime,
- endTime: endDateTime,
- isValid: isValid,
- ),
- );
- return patients;
- }
- @override
- Future<bool> createPatientByUnregisteredAsync(String patientName,
- {String? code}) async {
- final name = FEncryptHelper.encodeBase64(patientName);
- final result = await rpc.patient.createPatientByUnregisteredAsync(
- CreatePatientByUnregisteredRequest(
- token: token,
- patientName: name,
- unregisteredPatientCode: code,
- ),
- );
- return result;
- }
- @override
- Future<String> createUnregisteredPatient(String patientName,
- {String? code}) async {
- final name = FEncryptHelper.encodeBase64(patientName);
- final result = await rpc.patient.createUnregisteredPatientAsync(
- CreatePatientByUnregisteredRequest(
- token: token,
- patientName: name,
- unregisteredPatientCode: code,
- ),
- );
- return result;
- }
- @override
- Future<List<SimpleInfoItem>> findSimpleInfoPatients({
- int pageIndex = 1,
- int pageSize = 20,
- String keyWord = '',
- DateTime? startDateTime,
- DateTime? endDateTime,
- PatientValidStatusEnum isValid = PatientValidStatusEnum.All,
- bool isCounsultationPatient = false,
- }) async {
- PageResult<ClientPatientInfoBaseDTO> patients;
- if (isCounsultationPatient) {
- patients = await rpc.liveConsultation.findConsultationPatientAsync(
- FindConsultationPatientPageRequest(
- token: token,
- keyword: keyWord,
- pageIndex: pageIndex,
- pageSize: pageSize,
- ),
- );
- } else {
- patients = await findPatients(
- keyWord: keyWord,
- pageIndex: pageIndex,
- pageSize: pageSize,
- startDateTime: startDateTime,
- endDateTime: endDateTime,
- );
- }
- List<SimpleInfoItem> items = [];
- for (ClientPatientInfoBaseDTO p in patients.pageData ?? []) {
- List<DataItemDTO> patientData = p.patientData ?? [];
- var identityCard = patientData
- .firstWhereOrNull((element) => element.key == 'IdentityCard');
- items.add(
- SimpleInfoItem(
- itemCode: p.patientCode ?? '',
- name: _getPatientName(patientData),
- image: patientData
- .firstWhereOrNull((element) => element.key == 'HeadImgUrl')
- ?.value,
- role: patientData
- .firstWhereOrNull((element) => element.key == 'Phone')
- ?.value,
- des: [
- identityCard == null ? '' : identityCard.value,
- ],
- ),
- );
- }
- return items;
- }
- String? _getPatientName(List<DataItemDTO> patientData) {
- var name =
- patientData.firstWhereOrNull((element) => element.key == 'Name')?.value;
- if (name == null || name.isEmpty) {
- name = patientData
- .firstWhereOrNull((element) => element.key == 'AnimalInfoName')
- ?.value;
- }
- return name;
- }
- @override
- List<DataItemDTO>? convertPatientInfoToPatientDatas(
- PatientInfo? patientInfo) {
- if (patientInfo == null) {
- return [];
- }
- return [];
- }
- /// 根据后端接口的key值取到对应的value
- ///
- /// [patientData] 后端数据
- ///
- /// [keys] 对应的Key值
- @override
- String getKeyValue(
- List<DataItemDTO> patientData,
- List<String> keys,
- ) {
- return patientData.firstWhereOrNull((element) {
- return keys.contains(element.key);
- })?.value ??
- '';
- }
- @override
- Future<ClientPatientInfoDTO> findPatientByCode(
- String patientCode,
- ) async {
- return await rpc.remoteUltrasound.vitalFindPatientByCodeAsync(
- FindPatientByCodeRequest(
- code: patientCode,
- token: token,
- ),
- );
- }
- // @override
- // Future<List<FSelectModel>> findScanPositions() async {
- // List<FSelectModel> scanPositionsList = [];
- // return scanPositionsList;
- // }
- /// 获取测量图像
- @override
- Future<List<RemedicalMeasuredInfoDTO>> findRemedicalMeasuredInfoAsync(
- String recordCode,
- {BusinessTypeEnum businessType =
- BusinessTypeEnum.RemoteDiagnosis}) async {
- List<RemedicalMeasuredInfoDTO> result = [];
- try {
- result = await rpc.remoteUltrasound.vitalFindRemedicalMeasuredInfoAsync(
- FindRemedicalMeasuredInfoRequest(
- token: token,
- recordCode: recordCode,
- businessType: businessType,
- ),
- );
- return result;
- } catch (e) {
- logger.i("findRemedicalMeasuredInfoAsync exception:" + e.toString());
- }
- return result;
- }
- @override
- Future<List<ReportDTO>> findExamReports(String recordCode) async {
- try {
- var result = await rpc.ultrasoundReport.vitalFindReportsAsync(
- FindReportsRequest(
- token: token,
- recordCode: recordCode,
- ),
- );
- return result;
- } catch (e) {
- logger.e('RemedicalManager findExamReports ex:$e');
- return [];
- }
- }
- ///查询检查详情
- @override
- Future<QueryRecordResult?> queryRecordInfoAsync(String recordCode) async {
- try {
- return await rpc.remoteUltrasound.vitalQueryRecordInfoAsync(
- QueryRecordRequest(
- token: token,
- recordCode: recordCode,
- ),
- );
- } catch (e) {
- print('error:$recordCode');
- logger.i('queryRecordInfoAsync recordCode:$recordCode');
- logger.e('RemedicalManager queryRecordInfoAsync ex:', e);
- return null;
- }
- }
- @override
- Future<List<RemedicalAISelectedInfoDTO>> findAIImages(
- String recordCode, String patientId) async {
- final result = await rpc.remedical.getPatientAISelectedInfosAsync(
- GetPatientAISelectedInfosRequest(
- token: token,
- recordCode: recordCode,
- patientCode: patientId,
- ),
- );
- return result;
- }
- @override
- bool checkCarotidList(
- RemedicalItemList remedicalItem, CarotidScanTypeEnum scanTypeEnum) {
- return (remedicalItem.remedicalList
- ?.where(
- (element) =>
- element.carotidResult != null &&
- element.carotidResult?.carotidScanType == scanTypeEnum,
- )
- .toList() ??
- [])
- .isNotEmpty;
- }
- @override
- Future<RemedicalInfoDTO> findRemedicalByCode(String remedicalCode) async {
- return rpc.remoteUltrasound.vitalFindRemedicalByCodeAsync(
- FindRemedicalByCodeRequest(
- remedicalCode: remedicalCode,
- token: token,
- ),
- );
- }
- @override
- Future<PageResult<SimpleRecordInfoDTO>> findRecordPages({
- List<String>? organizationCodes,
- List<String>? deviceCodes,
- RecordQueryStateEnum recordQueryState = RecordQueryStateEnum.All,
- RecordProcessStateEnum recordProcessState = RecordProcessStateEnum.All,
- String? keyWord,
- DateTime? startTime,
- DateTime? endTime,
- String? patientCode,
- int pageIndex = 1,
- int pageSize = 20,
- }) async {
- try {
- return await rpc.remoteUltrasound.vitalFindRecordPagesAsync(
- FindRecordPagesRequest(
- token: token,
- pageIndex: pageIndex,
- pageSize: pageSize,
- organizationCodes: organizationCodes,
- deviceCodes: deviceCodes,
- keyWord: keyWord,
- recordQueryState: recordQueryState,
- language: i18nBook.locale.toCodeString('-'),
- recordProcessState: recordProcessState,
- patientCode: patientCode,
- startTime: UtcDateConverter.getDayStartOrEndUTCTime(startTime),
- endTime:
- UtcDateConverter.getDayStartOrEndUTCTime(endTime, isEnd: true),
- ),
- );
- } catch (e) {
- logger.e('RemedicalManager findRecordPages ex:$e');
- return PageResult<SimpleRecordInfoDTO>();
- }
- }
- @override
- void openImageMeasurePage(
- String imageUrl,
- int imageindex,
- String remedicalCode,
- String recordCode,
- String? remedicalAISelectedInfoCode,
- String patientCode) {}
- }
|