123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- import 'package:fis_jsonrpc/rpc.dart';
- abstract class PatientDtoConverter {
- /// 根据新建请求创建DTO
- static PatientDTO create2Dto(CreatePatientRequest2 request) {
- final dto = PatientDTO();
- dto.code = request.code;
- dto.patientName = request.patientName;
- dto.phone = request.phone;
- dto.cardNo = request.cardNo;
- dto.nationality = request.nationality;
- dto.birthday = request.birthday;
- dto.crowdLabels = request.crowdLabels;
- dto.cardType = request.cardType;
- dto.patientGender = request.patientGender;
- dto.patientAddress = request.patientAddress;
- dto.permanentResidenceAddress = request.permanentResidenceAddress;
- dto.teamRegionCode = request.teamRegionCode;
- dto.contractedDoctor = request.contractedDoctor;
- return dto;
- }
- /// 根据DTO创建新建请求
- static CreatePatientRequest2 dto2Create(PatientDTO dto) {
- final dtoJson = dto.toJson();
- final request = CreatePatientRequest2.fromJson(dtoJson);
- return request;
- }
- /// 同步更新到DTO
- static void syncUpdate2Dto(PatientDTO dto, UpdatePatientRequest2 request) {
- dto.code = request.code;
- dto.patientName = request.patientName;
- dto.phone = request.phone;
- dto.cardNo = request.cardNo;
- dto.nationality = request.nationality;
- dto.birthday = request.birthday;
- dto.crowdLabels = request.crowdLabels;
- if (request.cardType != null) {
- dto.cardType = request.cardType!;
- }
- if (request.patientGender != null) {
- dto.patientGender = request.patientGender!;
- }
- dto.patientAddress = request.patientAddress;
- dto.permanentResidenceAddress = request.permanentResidenceAddress;
- dto.teamRegionCode = request.teamRegionCode;
- dto.contractedDoctor = request.contractedDoctor;
- }
- /// 根据DTO创建更新请求
- static UpdatePatientRequest dto2Update(PatientDTO dto) {
- final dtoJson = dto.toJson();
- final request = UpdatePatientRequest.fromJson(dtoJson);
- return request;
- }
- }
- abstract class PatientExtDtoConverter {
- /// 根据新建请求创建DTO
- static PatientExtensionDTO create2Dto(CreatePatientExtensionRequest request) {
- final dto = PatientExtensionDTO();
- // dto.code = request.code;
- // dto.patientName = request.patientName;
- // dto.phone = request.phone;
- // dto.cardNo = request.cardNo;
- // dto.nationality = request.nationality;
- // dto.birthday = request.birthday;
- // dto.crowdLabels = request.crowdLabels;
- // dto.cardType = request.cardType;
- // dto.patientGender = request.patientGender;
- // dto.patientAddress = request.patientAddress;
- // dto.permanentResidenceAddress = request.permanentResidenceAddress;
- // dto.teamRegionCode = request.teamRegionCode;
- // dto.contractedDoctor = request.contractedDoctor;
- return dto;
- }
- /// 根据DTO创建新建请求
- static CreatePatientExtensionRequest dto2Create(PatientExtensionDTO dto) {
- final dtoJson = dto.toJson();
- final request = CreatePatientExtensionRequest.fromJson(dtoJson);
- return request;
- }
- /// 同步更新到DTO
- static void syncUpdate2Dto(
- PatientExtensionDTO dto, UpdatePatientExtensionRequest request) {}
- /// 根据DTO创建更新请求
- static UpdatePatientExtensionRequest dto2Update(PatientExtensionDTO dto) {
- final dtoJson = dto.toJson();
- final request = UpdatePatientExtensionRequest.fromJson(dtoJson);
- return request;
- }
- }
|