ソースを参照

feature: 绑卡支持自动建档

Walker 2 年 前
コミット
ff4417785f

+ 13 - 14
onemini-hospital-empty/src/main/java/com/ywt/alipaympapi/service/impl/IsvMedicCardServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ywt.alipaympapi.service.impl;
 
 import com.alibaba.fastjson.JSON;
+import com.google.protobuf.TextFormat;
 import com.ywt.alipaympapi.core.utils.*;
 import com.ywt.alipaympapi.models.BaseResponse;
 import com.ywt.alipaympapi.models.enums.RelationshipEnum;
@@ -433,24 +434,22 @@ public class IsvMedicCardServiceImpl implements IsvMedicCardService {
             idCardNo = Checker.getStringValue(user.getIdno());
             phoneNumber = Checker.getStringValue(user.getMobile());
         }
-        GetPatientInfoResponse response = taiheServiceBlockingStub.getPatientInfo(GetPatientInfoRequest.newBuilder()
-                .setPatientName(name)
+        // 绑卡支持自动建档
+        // FIXME: 目前固定城市和地址,前端没有开放编辑
+        String city = "广州市";
+        String address = "-";
+        CreateMedicalCardResponse response = taiheRegisterServiceBlockingStub.createMedicalCard(CreateMedicalCardRequest.newBuilder()
+                .setPhoneNo(phoneNumber)
                 .setIdNo(idCardNo)
+                .setPatientName(name)
+                .setCity(city)
+                .setAddress(address)
                 .setHospitalId(hospitalId)
-                .build());
-        if (response.getCode() != ResultCode.SUCCEED_VALUE) throw new AppMessageException(response.getMsg());
-        String hisPatientId = response.getPatientInfo().getPatientId();
-        if (StringHelper.isNullOrEmpty(hisPatientId)) throw new AppMessageException("无法从 HIS 获取患者 id");
-        ResultInt result = userServiceBlockingStub.addTaiheMedicalCard(AddTaiheMedicalCardRequest.newBuilder()
-                .setHisPatientId(hisPatientId)
                 .setUserId(userId)
-                .setHospitalId(hospitalId)
-                .setIdNo(idCardNo)
-                .setMobile(phoneNumber)
-                .setRealName(name)
-                .setRelationship(RelationshipEnum.getByName(relationShip).getValue())
                 .build());
-        if (result.getCode() != ResultCode.SUCCEED) throw new AppMessageException(result.getInfo());
+        System.out.println(TextFormat.printToUnicodeString(response));
+        if (response.getCode() != ResultCode.SUCCEED_VALUE) throw new AppMessageException(response.getInfo());
+        if (response.getInfo().contains("已有诊疗卡")) throw new AppMessageException("已有该诊疗卡,请勿重复添加");
         AddPatientResponse r = new AddPatientResponse();
         r.setIsSuccess(true);
         return r;