import 'authentication.m.dart'; import 'connect.m.dart'; import 'package:fis_jsonrpc/utils.dart'; import 'package:fis_common/json_convert.dart'; class DataItemDTO { String? key; String? value; DataItemDTO({ this.key, this.value, }); factory DataItemDTO.fromJson(Map map) { return DataItemDTO( key: map['Key'], value: map['Value'], ); } Map toJson() { final map = Map(); if(key != null) map['Key'] = key; if(value != null) map['Value'] = value; return map; } } class CreatePatientRequest extends TokenRequest{ List? patientData; List? assignmentUserCodes; CreatePatientRequest({ this.patientData, this.assignmentUserCodes, String? token, }) : super( token: token, ); factory CreatePatientRequest.fromJson(Map map) { return CreatePatientRequest( patientData: map['PatientData'] != null ? (map['PatientData'] as List).map((e)=>DataItemDTO.fromJson(e as Map)).toList() : null, assignmentUserCodes: map['AssignmentUserCodes'] != null ? map['AssignmentUserCodes'].cast().toList() : null, token: map['Token'], ); } Map toJson() { final map = super.toJson(); if(patientData != null) map['PatientData'] = patientData; if(assignmentUserCodes != null) map['AssignmentUserCodes'] = assignmentUserCodes; return map; } } class UpdatePatientRequest extends TokenRequest{ String? code; List? patientData; List? assignmentUserCodes; UpdatePatientRequest({ this.code, this.patientData, this.assignmentUserCodes, String? token, }) : super( token: token, ); factory UpdatePatientRequest.fromJson(Map map) { return UpdatePatientRequest( code: map['Code'], patientData: map['PatientData'] != null ? (map['PatientData'] as List).map((e)=>DataItemDTO.fromJson(e as Map)).toList() : null, assignmentUserCodes: map['AssignmentUserCodes'] != null ? map['AssignmentUserCodes'].cast().toList() : null, token: map['Token'], ); } Map toJson() { final map = super.toJson(); if(code != null) map['Code'] = code; if(patientData != null) map['PatientData'] = patientData; if(assignmentUserCodes != null) map['AssignmentUserCodes'] = assignmentUserCodes; return map; } } class PatientInfoBaseDTO extends BaseDTO{ String? patientCode; String? name; String? phone; String? identityCard; String? insuranceCode; String? age; int gender; bool isValid; String? organizationCode; List? assignmentUserCodes; List? patientData; int unReadRecordCount; PatientInfoBaseDTO({ this.patientCode, this.name, this.phone, this.identityCard, this.insuranceCode, this.age, this.gender = 0, this.isValid = false, this.organizationCode, this.assignmentUserCodes, this.patientData, this.unReadRecordCount = 0, DateTime? createTime, DateTime? updateTime, }) : super( createTime: createTime, updateTime: updateTime, ); factory PatientInfoBaseDTO.fromJson(Map map) { return PatientInfoBaseDTO( patientCode: map['PatientCode'], name: map['Name'], phone: map['Phone'], identityCard: map['IdentityCard'], insuranceCode: map['InsuranceCode'], age: map['Age'], gender: map['Gender'], isValid: map['IsValid'], organizationCode: map['OrganizationCode'], assignmentUserCodes: map['AssignmentUserCodes'] != null ? map['AssignmentUserCodes'].cast().toList() : null, patientData: map['PatientData'] != null ? (map['PatientData'] as List).map((e)=>DataItemDTO.fromJson(e as Map)).toList() : null, unReadRecordCount: map['UnReadRecordCount'], createTime: map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null, updateTime: map['UpdateTime'] != null ? DateTime.parse(map['UpdateTime']) : null, ); } Map toJson() { final map = super.toJson(); if(patientCode != null) map['PatientCode'] = patientCode; if(name != null) map['Name'] = name; if(phone != null) map['Phone'] = phone; if(identityCard != null) map['IdentityCard'] = identityCard; if(insuranceCode != null) map['InsuranceCode'] = insuranceCode; if(age != null) map['Age'] = age; map['Gender'] = gender; map['IsValid'] = isValid; if(organizationCode != null) map['OrganizationCode'] = organizationCode; if(assignmentUserCodes != null) map['AssignmentUserCodes'] = assignmentUserCodes; if(patientData != null) map['PatientData'] = patientData; map['UnReadRecordCount'] = unReadRecordCount; return map; } } class PatientInfoDTO extends PatientInfoBaseDTO{ String? creatorCode; String? deviceCode; PatientInfoDTO({ this.creatorCode, this.deviceCode, String? patientCode, String? name, String? phone, String? identityCard, String? insuranceCode, String? age, int gender = 0, bool isValid = false, String? organizationCode, List? assignmentUserCodes, List? patientData, int unReadRecordCount = 0, DateTime? createTime, DateTime? updateTime, }) : super( patientCode: patientCode, name: name, phone: phone, identityCard: identityCard, insuranceCode: insuranceCode, age: age, gender: gender, isValid: isValid, organizationCode: organizationCode, assignmentUserCodes: assignmentUserCodes, patientData: patientData, unReadRecordCount: unReadRecordCount, createTime: createTime, updateTime: updateTime, ); factory PatientInfoDTO.fromJson(Map map) { return PatientInfoDTO( creatorCode: map['CreatorCode'], deviceCode: map['DeviceCode'], patientCode: map['PatientCode'], name: map['Name'], phone: map['Phone'], identityCard: map['IdentityCard'], insuranceCode: map['InsuranceCode'], age: map['Age'], gender: map['Gender'], isValid: map['IsValid'], organizationCode: map['OrganizationCode'], assignmentUserCodes: map['AssignmentUserCodes'] != null ? map['AssignmentUserCodes'].cast().toList() : null, patientData: map['PatientData'] != null ? (map['PatientData'] as List).map((e)=>DataItemDTO.fromJson(e as Map)).toList() : null, unReadRecordCount: map['UnReadRecordCount'], createTime: map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null, updateTime: map['UpdateTime'] != null ? DateTime.parse(map['UpdateTime']) : null, ); } Map toJson() { final map = super.toJson(); if(creatorCode != null) map['CreatorCode'] = creatorCode; if(deviceCode != null) map['DeviceCode'] = deviceCode; return map; } } class CreatePatientsRequest extends TokenRequest{ List? patients; CreatePatientsRequest({ this.patients, String? token, }) : super( token: token, ); factory CreatePatientsRequest.fromJson(Map map) { return CreatePatientsRequest( patients: map['Patients'] != null ? (map['Patients'] as List).map((e)=>PatientInfoDTO.fromJson(e as Map)).toList() : null, token: map['Token'], ); } Map toJson() { final map = super.toJson(); if(patients != null) map['Patients'] = patients; return map; } } class ClientPatientInfoBaseDTO extends BaseDTO{ String? patientCode; bool isValid; List? patientData; int unReadRecordCount; ClientPatientInfoBaseDTO({ this.patientCode, this.isValid = false, this.patientData, this.unReadRecordCount = 0, DateTime? createTime, DateTime? updateTime, }) : super( createTime: createTime, updateTime: updateTime, ); factory ClientPatientInfoBaseDTO.fromJson(Map map) { return ClientPatientInfoBaseDTO( patientCode: map['PatientCode'], isValid: map['IsValid'], patientData: map['PatientData'] != null ? (map['PatientData'] as List).map((e)=>DataItemDTO.fromJson(e as Map)).toList() : null, unReadRecordCount: map['UnReadRecordCount'], createTime: map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null, updateTime: map['UpdateTime'] != null ? DateTime.parse(map['UpdateTime']) : null, ); } Map toJson() { final map = super.toJson(); if(patientCode != null) map['PatientCode'] = patientCode; map['IsValid'] = isValid; if(patientData != null) map['PatientData'] = patientData; map['UnReadRecordCount'] = unReadRecordCount; return map; } } class PageResult { int pageIndex; int pageSize; int totalCount; List? pageData; PageResult({ this.pageIndex = 0, this.pageSize = 0, this.totalCount = 0, this.pageData, }); factory PageResult.fromJson(Map map) { List pageDataList = []; if (map['PageData'] != null) { pageDataList.addAll( (map['PageData'] as List).map((e) => FJsonConvert.fromJson(e)!)); } return PageResult( pageIndex: map['PageIndex'], pageSize: map['PageSize'], totalCount: map['TotalCount'], pageData: pageDataList, ); } Map toJson() { final map = Map(); map['PageIndex'] = pageIndex; map['PageSize'] = pageSize; map['TotalCount'] = totalCount; if(pageData != null) map['PageData'] = pageData; return map; } } class PageRequest extends TokenRequest{ int pageIndex; int pageSize; PageRequest({ this.pageIndex = 0, this.pageSize = 0, String? token, }) : super( token: token, ); factory PageRequest.fromJson(Map map) { return PageRequest( pageIndex: map['PageIndex'], pageSize: map['PageSize'], token: map['Token'], ); } Map toJson() { final map = super.toJson(); map['PageIndex'] = pageIndex; map['PageSize'] = pageSize; return map; } } enum PatientValidStatusEnum { All, CheckOut, CheckIn, } class FindPatientsPageRequest extends PageRequest{ String? keyWord; DateTime? startTime; DateTime? endTime; PatientValidStatusEnum isValid; FindPatientsPageRequest({ this.keyWord, this.startTime, this.endTime, this.isValid = PatientValidStatusEnum.All, int pageIndex = 0, int pageSize = 0, String? token, }) : super( pageIndex: pageIndex, pageSize: pageSize, token: token, ); factory FindPatientsPageRequest.fromJson(Map map) { return FindPatientsPageRequest( keyWord: map['KeyWord'], startTime: map['StartTime'] != null ? DateTime.parse(map['StartTime']) : null, endTime: map['EndTime'] != null ? DateTime.parse(map['EndTime']) : null, isValid: PatientValidStatusEnum.values.firstWhere((e) => e.index == map['IsValid']), pageIndex: map['PageIndex'], pageSize: map['PageSize'], token: map['Token'], ); } Map toJson() { final map = super.toJson(); if(keyWord != null) map['KeyWord'] = keyWord; if(startTime != null) map['StartTime'] = JsonRpcUtils.dateFormat(startTime!); if(endTime != null) map['EndTime'] = JsonRpcUtils.dateFormat(endTime!); map['IsValid'] = isValid.index; return map; } } class UserBaseDTO extends BaseDTO{ String? userCode; String? userName; String? headImageUrl; UserBaseDTO({ this.userCode, this.userName, this.headImageUrl, DateTime? createTime, DateTime? updateTime, }) : super( createTime: createTime, updateTime: updateTime, ); factory UserBaseDTO.fromJson(Map map) { return UserBaseDTO( userCode: map['UserCode'], userName: map['UserName'], headImageUrl: map['HeadImageUrl'], createTime: map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null, updateTime: map['UpdateTime'] != null ? DateTime.parse(map['UpdateTime']) : null, ); } Map toJson() { final map = super.toJson(); if(userCode != null) map['UserCode'] = userCode; if(userName != null) map['UserName'] = userName; if(headImageUrl != null) map['HeadImageUrl'] = headImageUrl; return map; } } class ClientPatientInfoDTO extends ClientPatientInfoBaseDTO{ String? creatorCode; String? creatorName; String? deviceCode; List? assignmentUserList; ClientPatientInfoDTO({ this.creatorCode, this.creatorName, this.deviceCode, this.assignmentUserList, String? patientCode, bool isValid = false, List? patientData, int unReadRecordCount = 0, DateTime? createTime, DateTime? updateTime, }) : super( patientCode: patientCode, isValid: isValid, patientData: patientData, unReadRecordCount: unReadRecordCount, createTime: createTime, updateTime: updateTime, ); factory ClientPatientInfoDTO.fromJson(Map map) { return ClientPatientInfoDTO( creatorCode: map['CreatorCode'], creatorName: map['CreatorName'], deviceCode: map['DeviceCode'], assignmentUserList: map['AssignmentUserList'] != null ? (map['AssignmentUserList'] as List).map((e)=>UserBaseDTO.fromJson(e as Map)).toList() : null, patientCode: map['PatientCode'], isValid: map['IsValid'], patientData: map['PatientData'] != null ? (map['PatientData'] as List).map((e)=>DataItemDTO.fromJson(e as Map)).toList() : null, unReadRecordCount: map['UnReadRecordCount'], createTime: map['CreateTime'] != null ? DateTime.parse(map['CreateTime']) : null, updateTime: map['UpdateTime'] != null ? DateTime.parse(map['UpdateTime']) : null, ); } Map toJson() { final map = super.toJson(); if(creatorCode != null) map['CreatorCode'] = creatorCode; if(creatorName != null) map['CreatorName'] = creatorName; if(deviceCode != null) map['DeviceCode'] = deviceCode; if(assignmentUserList != null) map['AssignmentUserList'] = assignmentUserList; return map; } } class FindPatientByCodeRequest extends TokenRequest{ String? code; FindPatientByCodeRequest({ this.code, String? token, }) : super( token: token, ); factory FindPatientByCodeRequest.fromJson(Map map) { return FindPatientByCodeRequest( code: map['Code'], token: map['Token'], ); } Map toJson() { final map = super.toJson(); if(code != null) map['Code'] = code; return map; } } class AssignPatientToUsersRequest extends TokenRequest{ String? patientCode; List? userCodes; AssignPatientToUsersRequest({ this.patientCode, this.userCodes, String? token, }) : super( token: token, ); factory AssignPatientToUsersRequest.fromJson(Map map) { return AssignPatientToUsersRequest( patientCode: map['PatientCode'], userCodes: map['UserCodes'] != null ? map['UserCodes'].cast().toList() : null, token: map['Token'], ); } Map toJson() { final map = super.toJson(); if(patientCode != null) map['PatientCode'] = patientCode; if(userCodes != null) map['UserCodes'] = userCodes; return map; } } class FindValidPatientsByNameRequest extends TokenRequest{ String? name; FindValidPatientsByNameRequest({ this.name, String? token, }) : super( token: token, ); factory FindValidPatientsByNameRequest.fromJson(Map map) { return FindValidPatientsByNameRequest( name: map['Name'], token: map['Token'], ); } Map toJson() { final map = super.toJson(); if(name != null) map['Name'] = name; return map; } } class SetValidPatientRequest extends TokenRequest{ String? newPatientCode; String? oldPatientCode; SetValidPatientRequest({ this.newPatientCode, this.oldPatientCode, String? token, }) : super( token: token, ); factory SetValidPatientRequest.fromJson(Map map) { return SetValidPatientRequest( newPatientCode: map['NewPatientCode'], oldPatientCode: map['OldPatientCode'], token: map['Token'], ); } Map toJson() { final map = super.toJson(); if(newPatientCode != null) map['NewPatientCode'] = newPatientCode; if(oldPatientCode != null) map['OldPatientCode'] = oldPatientCode; return map; } }