|
@@ -2,29 +2,32 @@ package com.ywt.alipaympapi.service.impl;
|
|
|
|
|
|
import com.ywt.alipaympapi.core.utils.*;
|
|
import com.ywt.alipaympapi.core.utils.*;
|
|
import com.ywt.alipaympapi.models.BaseResponse;
|
|
import com.ywt.alipaympapi.models.BaseResponse;
|
|
|
|
+import com.ywt.alipaympapi.models.enums.RelationshipEnum;
|
|
|
|
+import com.ywt.alipaympapi.models.enums.SexEnum;
|
|
import com.ywt.alipaympapi.models.enums.SmsCodeTypeEnum;
|
|
import com.ywt.alipaympapi.models.enums.SmsCodeTypeEnum;
|
|
import com.ywt.alipaympapi.service.AuthService;
|
|
import com.ywt.alipaympapi.service.AuthService;
|
|
|
|
+import com.ywt.alipaympapi.service.IsvMedicCardService;
|
|
import com.ywt.alipaympapi.service.services.MessageSrv;
|
|
import com.ywt.alipaympapi.service.services.MessageSrv;
|
|
import com.ywt.core.exception.AppMessageException;
|
|
import com.ywt.core.exception.AppMessageException;
|
|
|
|
+import com.ywt.gapi.Result;
|
|
import com.ywt.gapi.ResultCode;
|
|
import com.ywt.gapi.ResultCode;
|
|
import com.ywt.gapi.ResultInt;
|
|
import com.ywt.gapi.ResultInt;
|
|
import com.ywt.gapi.taihe.register.CreateMedicalCardRequest;
|
|
import com.ywt.gapi.taihe.register.CreateMedicalCardRequest;
|
|
import com.ywt.gapi.taihe.register.CreateMedicalCardResponse;
|
|
import com.ywt.gapi.taihe.register.CreateMedicalCardResponse;
|
|
import com.ywt.gapi.taihe.register.TaiheRegisterServiceGrpc;
|
|
import com.ywt.gapi.taihe.register.TaiheRegisterServiceGrpc;
|
|
-import com.ywt.gapi.user.AddMedicalCardRequest;
|
|
|
|
-import com.ywt.gapi.user.UserServiceGrpc;
|
|
|
|
|
|
+import com.ywt.gapi.user.*;
|
|
import com.ywt.model.PageVO;
|
|
import com.ywt.model.PageVO;
|
|
|
|
+import com.ywt.model.Pagination;
|
|
|
|
+import com.ywt.request.card.UpdatePatientRequest;
|
|
import com.ywt.request.card.*;
|
|
import com.ywt.request.card.*;
|
|
import com.ywt.response.card.*;
|
|
import com.ywt.response.card.*;
|
|
-import com.ywt.alipaympapi.service.IsvMedicCardService;
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
|
|
+import java.util.LinkedList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
-import java.util.Map;
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class IsvMedicCardServiceImpl implements IsvMedicCardService {
|
|
public class IsvMedicCardServiceImpl implements IsvMedicCardService {
|
|
@@ -56,7 +59,7 @@ public class IsvMedicCardServiceImpl implements IsvMedicCardService {
|
|
String authCode = request.getAuthCode();
|
|
String authCode = request.getAuthCode();
|
|
//关系
|
|
//关系
|
|
String relationShip = request.getRelationShip();
|
|
String relationShip = request.getRelationShip();
|
|
- //是否默认
|
|
|
|
|
|
+ //是否默认(1-是,2-否)
|
|
String defaultCard = request.getDefaultCard();
|
|
String defaultCard = request.getDefaultCard();
|
|
//手机号
|
|
//手机号
|
|
String phoneNo = request.getPhoneNumber();
|
|
String phoneNo = request.getPhoneNumber();
|
|
@@ -122,7 +125,10 @@ public class IsvMedicCardServiceImpl implements IsvMedicCardService {
|
|
if (response.getCode() != BaseResponse.SUCCEED) {
|
|
if (response.getCode() != BaseResponse.SUCCEED) {
|
|
throw new AppMessageException(response.getInfo());
|
|
throw new AppMessageException(response.getInfo());
|
|
}
|
|
}
|
|
- int relationshipInt = 5, defaultCardInt = 0;
|
|
|
|
|
|
+ // 通过枚举类的方法,将文字转换成数字
|
|
|
|
+ int relationshipInt = RelationshipEnum.valueOf(relationShip).getValue();
|
|
|
|
+ // defaultCardInt: 1-是,0-否
|
|
|
|
+ int defaultCardInt = "1".equals(defaultCard) ? 1 : 0;
|
|
AddMedicalCardRequest addMedicalCardRequest = AddMedicalCardRequest.newBuilder()
|
|
AddMedicalCardRequest addMedicalCardRequest = AddMedicalCardRequest.newBuilder()
|
|
.setUserId(userId)
|
|
.setUserId(userId)
|
|
.setHospitalId(hospitalId)
|
|
.setHospitalId(hospitalId)
|
|
@@ -152,76 +158,244 @@ public class IsvMedicCardServiceImpl implements IsvMedicCardService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public UpdateCardResponseData updateMedicCard(UpdateCardRequest request) {
|
|
|
|
|
|
+ public UpdateCardResponseData updateMedicCard(UpdateCardRequest request) throws Exception {
|
|
|
|
+ if (1 == 1) {
|
|
|
|
+ throw new AppMessageException("尚无修改诊疗卡功能");
|
|
|
|
+ }
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public QuerySingleCardResponseData querySingleMedicCard(QuerySingleCardRequest request) throws Exception {
|
|
public QuerySingleCardResponseData querySingleMedicCard(QuerySingleCardRequest request) throws Exception {
|
|
- QuerySingleCardResponseData data = new QuerySingleCardResponseData();
|
|
|
|
- String userId = request.getUserId();
|
|
|
|
- if (userId.equals("1")) {
|
|
|
|
- data.setBalance("0.02");
|
|
|
|
- data.setBirthDay("2022-09-08");
|
|
|
|
- data.setCardNum("123456");
|
|
|
|
- return data;
|
|
|
|
- } else {
|
|
|
|
- throw new AppMessageException("userId有误");
|
|
|
|
|
|
+ // 此处传诊疗卡ID和userId
|
|
|
|
+ String cardNum = request.getCardNum();
|
|
|
|
+ if (Checker.isNone(cardNum)) {
|
|
|
|
+ throw new AppMessageException("诊疗卡不存在");
|
|
|
|
+ }
|
|
|
|
+ int cardId = Integer.parseInt(cardNum);
|
|
|
|
+ String appId = request.getAppId();
|
|
|
|
+ int hospitalId = authService.getHospitalIdByAppId(appId);
|
|
|
|
+ int userId = ContextHelper.getCurrentUserIdWrapped();
|
|
|
|
+ GetMedicalCardListRequest getMedicalCardListRequest = GetMedicalCardListRequest.newBuilder()
|
|
|
|
+ .setHospitalId(hospitalId)
|
|
|
|
+ .setUserId(userId)
|
|
|
|
+ .build();
|
|
|
|
+ GetMedicalCardListResponse getMedicalCardListResponse = userServiceBlockingStub.getMedicalCardList(getMedicalCardListRequest);
|
|
|
|
+ Result result = getMedicalCardListResponse.getResult();
|
|
|
|
+
|
|
|
|
+ if (result.getCode() == ResultCode.SUCCEED) {
|
|
|
|
+ for (MedicalCard medicalCard : getMedicalCardListResponse.getMedicalCardsList()) {
|
|
|
|
+ if (medicalCard.getCardId() == cardId) {
|
|
|
|
+ double balance = medicalCard.getBalance() / 100d;
|
|
|
|
+ QuerySingleCardResponseData item = new QuerySingleCardResponseData();
|
|
|
|
+ item.setCardNum(medicalCard.getCardNo());//就诊卡卡号/医保卡卡号
|
|
|
|
+ String cardType = medicalCard.getCardType();
|
|
|
|
+ item.setType("0");//标记查询卡类型
|
|
|
|
+ item.setName(medicalCard.getPatientName());//姓名
|
|
|
|
+ item.setSex(SexEnum.getSexDisplayName(medicalCard.getSex()));//性别
|
|
|
|
+ item.setBirthDay(medicalCard.getBirthday());//生日
|
|
|
|
+ item.setIdCardNo(medicalCard.getIdNo());//身份证号码
|
|
|
|
+ item.setPhoneNumber(medicalCard.getMobile());//手机号
|
|
|
|
+ item.setBalance(balance + "");//卡内余额
|
|
|
|
+ item.setRelationShip(RelationshipEnum.valueOf(medicalCard.getRelationship()).getDisplayName()); // 关系
|
|
|
|
+ item.setDefaultCard(medicalCard.getIsDefault() ? "是" : "否");//是否是默认就诊卡
|
|
|
|
+ return item;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public QueryDefaultCardResponseData queryDefaultMedicCard(QueryDefaultCardRequest request) {
|
|
|
|
|
|
+ public QueryDefaultCardResponseData queryDefaultMedicCard(QueryDefaultCardRequest request) throws Exception {
|
|
|
|
+ String appId = request.getAppId();
|
|
|
|
+ int hospitalId = authService.getHospitalIdByAppId(appId);
|
|
|
|
+ int userId = ContextHelper.getCurrentUserIdWrapped();
|
|
|
|
+ GetMedicalCardListRequest getMedicalCardListRequest = GetMedicalCardListRequest.newBuilder()
|
|
|
|
+ .setHospitalId(hospitalId)
|
|
|
|
+ .setUserId(userId)
|
|
|
|
+ .build();
|
|
|
|
+ GetMedicalCardListResponse getMedicalCardListResponse = userServiceBlockingStub.getMedicalCardList(getMedicalCardListRequest);
|
|
|
|
+ Result result = getMedicalCardListResponse.getResult();
|
|
|
|
+
|
|
|
|
+ if (result.getCode() == ResultCode.SUCCEED) {
|
|
|
|
+ for (MedicalCard medicalCard : getMedicalCardListResponse.getMedicalCardsList()) {
|
|
|
|
+ if (medicalCard.getIsDefault()) {
|
|
|
|
+ double balance = medicalCard.getBalance() / 100d;
|
|
|
|
+ QueryDefaultCardResponseData item = new QueryDefaultCardResponseData();
|
|
|
|
+ item.setCardNum(medicalCard.getCardNo());//就诊卡卡号/医保卡卡号
|
|
|
|
+ String cardType = medicalCard.getCardType();
|
|
|
|
+ item.setType("0");//标记查询卡类型
|
|
|
|
+ item.setName(medicalCard.getPatientName());//姓名
|
|
|
|
+ item.setSex(SexEnum.getSexDisplayName(medicalCard.getSex()));//性别
|
|
|
|
+ item.setBirthDay(medicalCard.getBirthday());//生日
|
|
|
|
+ item.setIdCardNo(medicalCard.getIdNo());//身份证号码
|
|
|
|
+ item.setPhoneNumber(medicalCard.getMobile());//手机号
|
|
|
|
+ item.setBalance(balance + "");//卡内余额
|
|
|
|
+ item.setRelationShip(RelationshipEnum.valueOf(medicalCard.getRelationship()).getDisplayName()); // 关系
|
|
|
|
+ item.setDefaultCard(medicalCard.getIsDefault() ? "是" : "否");//是否是默认就诊卡
|
|
|
|
+ item.setPatientId("");//如果是医保卡,传参保城市
|
|
|
|
+ return item;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public PageVO<QueryListCardResponseData> queryListMedicCard(QueryListCardRequest request) {
|
|
|
|
- return null;
|
|
|
|
|
|
+ public PageVO<QueryListCardResponseData> queryListMedicCard(QueryListCardRequest request) throws Exception {
|
|
|
|
+
|
|
|
|
+ String appId = request.getAppId();
|
|
|
|
+ int hospitalId = authService.getHospitalIdByAppId(appId);
|
|
|
|
+ int userId = ContextHelper.getCurrentUserIdWrapped();
|
|
|
|
+ GetMedicalCardListRequest getMedicalCardListRequest = GetMedicalCardListRequest.newBuilder()
|
|
|
|
+ .setHospitalId(hospitalId)
|
|
|
|
+ .setUserId(userId)
|
|
|
|
+ .build();
|
|
|
|
+ GetMedicalCardListResponse getMedicalCardListResponse = userServiceBlockingStub.getMedicalCardList(getMedicalCardListRequest);
|
|
|
|
+ Result result = getMedicalCardListResponse.getResult();
|
|
|
|
+
|
|
|
|
+ int total = 0;
|
|
|
|
+ List<QueryListCardResponseData> lst = new LinkedList<>();
|
|
|
|
+ if (result.getCode() == ResultCode.SUCCEED) {
|
|
|
|
+ total = Checker.getIntegerValue(getMedicalCardListResponse.getMedicalCardsList().size());
|
|
|
|
+ for (MedicalCard medicalCard : getMedicalCardListResponse.getMedicalCardsList()) {
|
|
|
|
+ double balance = medicalCard.getBalance() / 100d;
|
|
|
|
+ QueryListCardResponseData item = new QueryListCardResponseData();
|
|
|
|
+ item.setCardNum(medicalCard.getCardNo());//就诊卡卡号/医保卡卡号
|
|
|
|
+ String cardType = medicalCard.getCardType();
|
|
|
|
+ item.setType(1);//标记查询卡类型
|
|
|
|
+ item.setName(medicalCard.getPatientName());//姓名
|
|
|
|
+ item.setSex(SexEnum.getSexDisplayName(medicalCard.getSex()));//性别
|
|
|
|
+ item.setBirthDay(medicalCard.getBirthday());//生日
|
|
|
|
+ item.setIdCardNo(medicalCard.getIdNo());//身份证号码
|
|
|
|
+ item.setPhoneNumber(medicalCard.getMobile());//手机号
|
|
|
|
+ item.setBalance(balance + "");//卡内余额
|
|
|
|
+ item.setIsDefault(medicalCard.getIsDefault());//是否是默认就诊卡
|
|
|
|
+ item.setCity("");//如果是医保卡,传参保城市
|
|
|
|
+ item.setCardOrgName("");//如果是医保卡,传发卡机构
|
|
|
|
+ lst.add(item);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Pagination pagination = new Pagination(1, 1, total);
|
|
|
|
+ PageVO<QueryListCardResponseData> res = new PageVO<>(pagination, lst);
|
|
|
|
+ return res;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public DeleteCardResponseData deleteMedicCard(DeleteCardRequest request) {
|
|
|
|
- return null;
|
|
|
|
|
|
+ public DeleteCardResponseData deleteMedicCard(DeleteCardRequest request) throws Exception {
|
|
|
|
+ // 此处传诊疗卡ID和userId
|
|
|
|
+ String cardNum = request.getCardNum();
|
|
|
|
+ if (Checker.isNone(cardNum)) {
|
|
|
|
+ throw new AppMessageException("诊疗卡不存在");
|
|
|
|
+ }
|
|
|
|
+ int cardId = Integer.parseInt(cardNum);
|
|
|
|
+ int userId = ContextHelper.getCurrentUserIdWrapped();
|
|
|
|
+ if (cardId < 1) {
|
|
|
|
+ throw new AppMessageException("诊疗卡不存在");
|
|
|
|
+ }
|
|
|
|
+ DeleteCardResponseData responseData = new DeleteCardResponseData();
|
|
|
|
+ DeleteMedicalCardRequest deleteMedicalCardRequest = DeleteMedicalCardRequest.newBuilder()
|
|
|
|
+ .setCardId(cardId)
|
|
|
|
+ .setUserId(userId)
|
|
|
|
+ .build();
|
|
|
|
+ Result result = userServiceBlockingStub.deleteMedicalCard(deleteMedicalCardRequest);
|
|
|
|
+
|
|
|
|
+ if (result.getCode() == ResultCode.SUCCEED) {
|
|
|
|
+ responseData.setIsSuccess(true);
|
|
|
|
+ }
|
|
|
|
+ responseData.setIsSuccess(false);
|
|
|
|
+ return responseData;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public BindMedInsuranceCardResponseData bindMedInsuranceCard(BindMedInsuranceCardRequest request) {
|
|
|
|
- return null;
|
|
|
|
|
|
+ public BindMedInsuranceCardResponseData bindMedInsuranceCard(BindMedInsuranceCardRequest request) throws Exception {
|
|
|
|
+ BindMedInsuranceCardResponseData resp = new BindMedInsuranceCardResponseData();
|
|
|
|
+ String appId = request.getAppId();//医院小程序的AppId
|
|
|
|
+// String userId = request.getUserId();//用户唯一id
|
|
|
|
+ String patientName = request.getName();//姓名
|
|
|
|
+ String sex = request.getSex();//性别
|
|
|
|
+ String birthDay = request.getBirthDay();//生日
|
|
|
|
+ String idCardNo = request.getIdCardNo();//身份证号码
|
|
|
|
+ String phoneNo = request.getPhoneNumber();//手机号
|
|
|
|
+ String cardNum = request.getMedInsuranceNum();//医保卡识别号
|
|
|
|
+
|
|
|
|
+ int hospitalId = authService.getHospitalIdByAppId(appId);
|
|
|
|
+ int userId = ContextHelper.getCurrentUserIdWrapped();
|
|
|
|
+ if (hospitalId < 1) {
|
|
|
|
+ throw new AppMessageException("请选择医院");
|
|
|
|
+ }
|
|
|
|
+ if (StringHelper.isNullOrWhiteSpace(cardNum)) {
|
|
|
|
+ throw new AppMessageException("请填写就诊卡号");
|
|
|
|
+ }
|
|
|
|
+ if (StringHelper.isNullOrWhiteSpace(patientName)) {
|
|
|
|
+ throw new AppMessageException("请填写真实的姓名");
|
|
|
|
+ }
|
|
|
|
+ if (StringHelper.isNullOrWhiteSpace(phoneNo)) {
|
|
|
|
+ throw new AppMessageException("请填写在医院预留的手机号");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 通过枚举类的方法,将文字转换成数字
|
|
|
|
+ int relationshipInt = 0;
|
|
|
|
+ // defaultCardInt: 1-是,0-否
|
|
|
|
+ int defaultCardInt = 0;
|
|
|
|
+ AddMedicalCardRequest addMedicalCardRequest = AddMedicalCardRequest.newBuilder()
|
|
|
|
+ .setUserId(userId)
|
|
|
|
+ .setHospitalId(hospitalId)
|
|
|
|
+ .setCardNo(cardNum)
|
|
|
|
+ .setRealName(patientName)
|
|
|
|
+ .setMobile(phoneNo)
|
|
|
|
+ .setRelationship(relationshipInt)
|
|
|
|
+ .setDefaultCard(defaultCardInt)
|
|
|
|
+ .build();
|
|
|
|
+ ResultInt resultInt = userServiceBlockingStub.addMedicalCard(addMedicalCardRequest);
|
|
|
|
+ if (resultInt.getCode() == ResultCode.SUCCEED) {
|
|
|
|
+ resp.setUserId(request.getUserId());
|
|
|
|
+ resp.setCardNum(request.getMedInsuranceNum());
|
|
|
|
+ resp.setName(patientName);
|
|
|
|
+ resp.setSex(sex);
|
|
|
|
+ resp.setBirthDay(birthDay);
|
|
|
|
+ resp.setIdCardNo(idCardNo);
|
|
|
|
+ resp.setPhoneNumber(phoneNo);
|
|
|
|
+ } else {
|
|
|
|
+ throw new AppMessageException(resultInt.getInfo());
|
|
|
|
+ }
|
|
|
|
+ return resp;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<QueryPatientListResponse> queryPatientList(QueryPatientListRequest request) {
|
|
|
|
|
|
+ public List<QueryPatientListResponse> queryPatientList(QueryPatientListRequest request) throws Exception {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public PatientBindCardResponse bindMedicCard(PatientBindCardRequest request) {
|
|
|
|
|
|
+ public PatientBindCardResponse bindMedicCard(PatientBindCardRequest request) throws Exception {
|
|
|
|
+
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public DeletePatientResponse deletePatient(DeletePatientRequest request) {
|
|
|
|
|
|
+ public DeletePatientResponse deletePatient(DeletePatientRequest request) throws Exception {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public AddPatientResponse addPatient(AddPatientRequest request) {
|
|
|
|
|
|
+ public AddPatientResponse addPatient(AddPatientRequest request) throws Exception {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public UpdatePatientResponse updatePatient(UpdatePatientRequest request) {
|
|
|
|
|
|
+ public UpdatePatientResponse updatePatient(UpdatePatientRequest request) throws Exception {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public QueryPatientDetailResponse querySinglePatient(QueryPatientDetailRequest request) {
|
|
|
|
|
|
+ public QueryPatientDetailResponse querySinglePatient(QueryPatientDetailRequest request) throws Exception {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<MyCardListResponse> myCardList(MyCardListRequest request) {
|
|
|
|
|
|
+ public List<MyCardListResponse> myCardList(MyCardListRequest request) throws Exception {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|