|
@@ -16,10 +16,14 @@ import thyyxxk.wxservice_server.entity.analyzeidcard.UploadIdCardParam;
|
|
|
import thyyxxk.wxservice_server.entity.electronichealthcard.BatchRegisterParams;
|
|
|
import thyyxxk.wxservice_server.entity.electronichealthcard.ElectronicHealthCard;
|
|
|
import thyyxxk.wxservice_server.entity.electronichealthcard.RegisterParams;
|
|
|
+import thyyxxk.wxservice_server.entity.patientcards.WechatPatientBind;
|
|
|
import thyyxxk.wxservice_server.utils.*;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
+/**
|
|
|
+ * 电子健康卡卡面规范及素材 <a href="https://open.tengmed.com/openAccess/docs/access#28">...</a>
|
|
|
+ * */
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
public class ElectronicHealthCardService {
|
|
@@ -122,21 +126,34 @@ public class ElectronicHealthCardService {
|
|
|
if (existCount == 0) {
|
|
|
dao.insert(card);
|
|
|
}
|
|
|
- if (StringUtil.isBlank(card.getPatId())) {
|
|
|
- String patientId = dao.selectLatestBindPatientId(card.getIdNumber());
|
|
|
- if (null == patientId) {
|
|
|
- createHisCard(card);
|
|
|
- patientId = dao.selectLatestBindPatientId(card.getIdNumber());
|
|
|
- }
|
|
|
- if (null != patientId) {
|
|
|
- card.setPatId(patientId);
|
|
|
- dao.updateHealthCardBatchStatus(Constants.HealthCardBatchRegister.SUCCESS, card.getIdNumber());
|
|
|
- bindCardRelation(card.getHealthCardId(), card.getQrCodeText(), patientId);
|
|
|
- }
|
|
|
+ if (StringUtil.notBlank(card.getPatId())) {
|
|
|
+ bindPatIdAndOpenId(card);
|
|
|
+ return ResultVoUtil.success(card);
|
|
|
+ }
|
|
|
+ String patientId = dao.selectLatestBindPatientId(card.getIdNumber());
|
|
|
+ if (null == patientId) {
|
|
|
+ createHisCard(card);
|
|
|
+ patientId = dao.selectLatestBindPatientId(card.getIdNumber());
|
|
|
+ }
|
|
|
+ if (null != patientId) {
|
|
|
+ card.setPatId(patientId);
|
|
|
+ bindPatIdAndOpenId(card);
|
|
|
+ dao.updateHealthCardBatchStatus(Constants.HealthCardBatchRegister.SUCCESS, card.getIdNumber());
|
|
|
+ bindCardRelation(card.getHealthCardId(), card.getQrCodeText(), patientId);
|
|
|
}
|
|
|
return ResultVoUtil.success(card);
|
|
|
}
|
|
|
|
|
|
+ private void bindPatIdAndOpenId(ElectronicHealthCard card) {
|
|
|
+ WechatPatientBind bind = dao.selectWechatPatientBind(card.getPatId(), card.getOpenId());
|
|
|
+ if (null == bind) {
|
|
|
+ card.setIsDefault(Objects.equals(card.getRelation(), "0") ? 1 : 0);
|
|
|
+ dao.insertWechatBind(card);
|
|
|
+ } else {
|
|
|
+ dao.unfrozenWechatBind(card.getIdNumber(), card.getPhone1(), bind.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public ResultVo<ElectronicHealthCard> register(RegisterParams req) {
|
|
|
if (!IdCardUtil.isValidatedIdCard(req.getIdNumber())) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "请输入正确的身份证号码。");
|
|
@@ -195,6 +212,7 @@ public class ElectronicHealthCardService {
|
|
|
}
|
|
|
if (null != patientId) {
|
|
|
card.setPatId(patientId);
|
|
|
+ bindPatIdAndOpenId(card);
|
|
|
dao.updateHealthCardBatchStatus(Constants.HealthCardBatchRegister.SUCCESS, card.getIdNumber());
|
|
|
bindCardRelation(card.getHealthCardId(), card.getQrCodeText(), patientId);
|
|
|
}
|