patient.dart 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import 'package:fis_jsonrpc/rpc.dart';
  2. abstract class PatientDtoConverter {
  3. /// 根据新建请求创建DTO
  4. static PatientDTO create2Dto(CreatePatientRequest2 request) {
  5. final dto = PatientDTO();
  6. dto.code = request.code;
  7. dto.patientName = request.patientName;
  8. dto.phone = request.phone;
  9. dto.cardNo = request.cardNo;
  10. dto.nationality = request.nationality;
  11. dto.birthday = request.birthday;
  12. dto.crowdLabels = request.crowdLabels;
  13. dto.cardType = request.cardType;
  14. dto.patientGender = request.patientGender;
  15. dto.patientAddress = request.patientAddress;
  16. dto.permanentResidenceAddress = request.permanentResidenceAddress;
  17. dto.teamRegionCode = request.teamRegionCode;
  18. dto.contractedDoctor = request.contractedDoctor;
  19. return dto;
  20. }
  21. /// 根据DTO创建新建请求
  22. static CreatePatientRequest2 dto2Create(PatientDTO dto) {
  23. final dtoJson = dto.toJson();
  24. final request = CreatePatientRequest2.fromJson(dtoJson);
  25. return request;
  26. }
  27. /// 同步更新到DTO
  28. static void syncUpdate2Dto(PatientDTO dto, UpdatePatientRequest2 request) {
  29. dto.code = request.code;
  30. dto.patientName = request.patientName;
  31. dto.phone = request.phone;
  32. dto.cardNo = request.cardNo;
  33. dto.nationality = request.nationality;
  34. dto.birthday = request.birthday;
  35. dto.crowdLabels = request.crowdLabels;
  36. if (request.cardType != null) {
  37. dto.cardType = request.cardType!;
  38. }
  39. if (request.patientGender != null) {
  40. dto.patientGender = request.patientGender!;
  41. }
  42. dto.patientAddress = request.patientAddress;
  43. dto.permanentResidenceAddress = request.permanentResidenceAddress;
  44. dto.teamRegionCode = request.teamRegionCode;
  45. dto.contractedDoctor = request.contractedDoctor;
  46. }
  47. /// 根据DTO创建更新请求
  48. static UpdatePatientRequest dto2Update(PatientDTO dto) {
  49. final dtoJson = dto.toJson();
  50. final request = UpdatePatientRequest.fromJson(dtoJson);
  51. return request;
  52. }
  53. }
  54. abstract class PatientExtDtoConverter {
  55. /// 根据新建请求创建DTO
  56. static PatientExtensionDTO create2Dto(CreatePatientExtensionRequest request) {
  57. final dto = PatientExtensionDTO();
  58. // dto.code = request.code;
  59. // dto.patientName = request.patientName;
  60. // dto.phone = request.phone;
  61. // dto.cardNo = request.cardNo;
  62. // dto.nationality = request.nationality;
  63. // dto.birthday = request.birthday;
  64. // dto.crowdLabels = request.crowdLabels;
  65. // dto.cardType = request.cardType;
  66. // dto.patientGender = request.patientGender;
  67. // dto.patientAddress = request.patientAddress;
  68. // dto.permanentResidenceAddress = request.permanentResidenceAddress;
  69. // dto.teamRegionCode = request.teamRegionCode;
  70. // dto.contractedDoctor = request.contractedDoctor;
  71. return dto;
  72. }
  73. /// 根据DTO创建新建请求
  74. static CreatePatientExtensionRequest dto2Create(PatientExtensionDTO dto) {
  75. final dtoJson = dto.toJson();
  76. final request = CreatePatientExtensionRequest.fromJson(dtoJson);
  77. return request;
  78. }
  79. /// 同步更新到DTO
  80. static void syncUpdate2Dto(
  81. PatientExtensionDTO dto, UpdatePatientExtensionRequest request) {}
  82. /// 根据DTO创建更新请求
  83. static UpdatePatientExtensionRequest dto2Update(PatientExtensionDTO dto) {
  84. final dtoJson = dto.toJson();
  85. final request = UpdatePatientExtensionRequest.fromJson(dtoJson);
  86. return request;
  87. }
  88. }