|
@@ -44,6 +44,11 @@ public class IsvMedicCardServiceImpl implements IsvMedicCardService {
|
|
@Autowired
|
|
@Autowired
|
|
private MessageSrv messageSrv;
|
|
private MessageSrv messageSrv;
|
|
|
|
|
|
|
|
+ public static final int CARD_TYPE_NORMAL = 0; // 普通卡
|
|
|
|
+ public static final int CARD_TYPE_MED_INSU = 1; // 医保卡
|
|
|
|
+ public static final String CARD_TYPE_STR_NORMAL = "0"; // 普通卡
|
|
|
|
+ public static final String CARD_TYPE_STR_MED_INSU = "1"; // 医保卡
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public CreateOrBindCardResponseData createOrBindMedicCard(CreateOrBindCardRequest request) throws Exception {
|
|
public CreateOrBindCardResponseData createOrBindMedicCard(CreateOrBindCardRequest request) throws Exception {
|
|
//用户唯一id
|
|
//用户唯一id
|
|
@@ -160,10 +165,7 @@ public class IsvMedicCardServiceImpl implements IsvMedicCardService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public UpdateCardResponseData updateMedicCard(UpdateCardRequest request) throws Exception {
|
|
public UpdateCardResponseData updateMedicCard(UpdateCardRequest request) throws Exception {
|
|
- if (1 == 1) {
|
|
|
|
- throw new AppMessageException("尚无修改诊疗卡功能");
|
|
|
|
- }
|
|
|
|
- return null;
|
|
|
|
|
|
+ throw new AppMessageException("暂不支持修改诊疗卡功能");
|
|
}
|
|
}
|
|
|
|
|
|
// 就诊卡详情
|
|
// 就诊卡详情
|
|
@@ -174,14 +176,7 @@ public class IsvMedicCardServiceImpl implements IsvMedicCardService {
|
|
CheckUtil.ensureNotEmpty(cardNum, "诊疗卡号不能为空");
|
|
CheckUtil.ensureNotEmpty(cardNum, "诊疗卡号不能为空");
|
|
int hospitalId = BizUtil.getCurrentHospitalId();
|
|
int hospitalId = BizUtil.getCurrentHospitalId();
|
|
int userId = ContextHelper.getCurrentUserIdWrapped();
|
|
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) throw new AppMessageException(result.getInfo());
|
|
|
|
- List<MedicalCard> list = getMedicalCardListResponse.getMedicalCardsList().stream()
|
|
|
|
|
|
+ List<MedicalCard> list = getUserMedCardList(userId, hospitalId).stream()
|
|
.filter(c -> Checker.getStringValue(c.getCardNo()).equals(cardNum))
|
|
.filter(c -> Checker.getStringValue(c.getCardNo()).equals(cardNum))
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
if (list.isEmpty()) return null;
|
|
if (list.isEmpty()) return null;
|
|
@@ -189,8 +184,7 @@ public class IsvMedicCardServiceImpl implements IsvMedicCardService {
|
|
double balance = medicalCard.getBalance() / 100d;
|
|
double balance = medicalCard.getBalance() / 100d;
|
|
QuerySingleCardResponseData item = new QuerySingleCardResponseData();
|
|
QuerySingleCardResponseData item = new QuerySingleCardResponseData();
|
|
item.setCardNum(medicalCard.getCardNo());//就诊卡卡号/医保卡卡号
|
|
item.setCardNum(medicalCard.getCardNo());//就诊卡卡号/医保卡卡号
|
|
- String cardType = medicalCard.getCardType();
|
|
|
|
- item.setType("0");// 标记查询卡类型
|
|
|
|
|
|
+ item.setType(CARD_TYPE_STR_NORMAL);// 标记查询卡类型
|
|
item.setName(medicalCard.getPatientName());//姓名
|
|
item.setName(medicalCard.getPatientName());//姓名
|
|
item.setSex(SexEnum.getSexDisplayName(medicalCard.getSex()));//性别
|
|
item.setSex(SexEnum.getSexDisplayName(medicalCard.getSex()));//性别
|
|
item.setBirthDay(medicalCard.getBirthday());//生日
|
|
item.setBirthDay(medicalCard.getBirthday());//生日
|
|
@@ -208,14 +202,7 @@ public class IsvMedicCardServiceImpl implements IsvMedicCardService {
|
|
public QueryDefaultCardResponseData queryDefaultMedicCard(QueryDefaultCardRequest request) throws Exception {
|
|
public QueryDefaultCardResponseData queryDefaultMedicCard(QueryDefaultCardRequest request) throws Exception {
|
|
int hospitalId = BizUtil.getCurrentHospitalId();
|
|
int hospitalId = BizUtil.getCurrentHospitalId();
|
|
int userId = ContextHelper.getCurrentUserIdWrapped();
|
|
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) throw new AppMessageException(result.getInfo());
|
|
|
|
- List<MedicalCard> list = getMedicalCardListResponse.getMedicalCardsList().stream()
|
|
|
|
|
|
+ List<MedicalCard> list = getUserMedCardList(userId, hospitalId).stream()
|
|
.sorted(Comparator.comparing(MedicalCard::getLastChosenTime).reversed())
|
|
.sorted(Comparator.comparing(MedicalCard::getLastChosenTime).reversed())
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
if (list.isEmpty()) return null;
|
|
if (list.isEmpty()) return null;
|
|
@@ -223,7 +210,7 @@ public class IsvMedicCardServiceImpl implements IsvMedicCardService {
|
|
double balance = medicalCard.getBalance() / 100d;
|
|
double balance = medicalCard.getBalance() / 100d;
|
|
QueryDefaultCardResponseData item = new QueryDefaultCardResponseData();
|
|
QueryDefaultCardResponseData item = new QueryDefaultCardResponseData();
|
|
item.setCardNum(medicalCard.getCardNo());//就诊卡卡号/医保卡卡号
|
|
item.setCardNum(medicalCard.getCardNo());//就诊卡卡号/医保卡卡号
|
|
- item.setType("0");// 标记查询卡类型,默认普通卡
|
|
|
|
|
|
+ item.setType(CARD_TYPE_STR_NORMAL);// 标记查询卡类型,默认普通卡
|
|
item.setName(medicalCard.getPatientName());//姓名
|
|
item.setName(medicalCard.getPatientName());//姓名
|
|
item.setSex(SexEnum.getSexDisplayName(medicalCard.getSex()));//性别
|
|
item.setSex(SexEnum.getSexDisplayName(medicalCard.getSex()));//性别
|
|
item.setBirthDay(medicalCard.getBirthday());//生日
|
|
item.setBirthDay(medicalCard.getBirthday());//生日
|
|
@@ -242,23 +229,15 @@ public class IsvMedicCardServiceImpl implements IsvMedicCardService {
|
|
public PageVO<QueryListCardResponseData> queryListMedicCard(QueryListCardRequest request) throws Exception {
|
|
public PageVO<QueryListCardResponseData> queryListMedicCard(QueryListCardRequest request) throws Exception {
|
|
int hospitalId = BizUtil.getCurrentHospitalId();
|
|
int hospitalId = BizUtil.getCurrentHospitalId();
|
|
int userId = ContextHelper.getCurrentUserIdWrapped();
|
|
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) throw new AppMessageException(result.getInfo());
|
|
|
|
int total;
|
|
int total;
|
|
List<QueryListCardResponseData> lst = new LinkedList<>();
|
|
List<QueryListCardResponseData> lst = new LinkedList<>();
|
|
- List<MedicalCard> medicalCards = getMedicalCardListResponse.getMedicalCardsList();
|
|
|
|
|
|
+ List<MedicalCard> medicalCards = getUserMedCardList(userId, hospitalId);
|
|
total = medicalCards.size();
|
|
total = medicalCards.size();
|
|
for (MedicalCard medicalCard : medicalCards) {
|
|
for (MedicalCard medicalCard : medicalCards) {
|
|
double balance = medicalCard.getBalance() / 100d;
|
|
double balance = medicalCard.getBalance() / 100d;
|
|
QueryListCardResponseData item = new QueryListCardResponseData();
|
|
QueryListCardResponseData item = new QueryListCardResponseData();
|
|
item.setCardNum(medicalCard.getCardNo());//就诊卡卡号/医保卡卡号
|
|
item.setCardNum(medicalCard.getCardNo());//就诊卡卡号/医保卡卡号
|
|
- String cardType = medicalCard.getCardType();
|
|
|
|
- item.setType(1);//标记查询卡类型
|
|
|
|
|
|
+ item.setType(CARD_TYPE_NORMAL);//标记查询卡类型
|
|
item.setName(medicalCard.getPatientName());//姓名
|
|
item.setName(medicalCard.getPatientName());//姓名
|
|
item.setSex(SexEnum.getSexDisplayName(medicalCard.getSex()));//性别
|
|
item.setSex(SexEnum.getSexDisplayName(medicalCard.getSex()));//性别
|
|
item.setBirthDay(medicalCard.getBirthday());//生日
|
|
item.setBirthDay(medicalCard.getBirthday());//生日
|
|
@@ -349,14 +328,7 @@ public class IsvMedicCardServiceImpl implements IsvMedicCardService {
|
|
public List<QueryPatientListResponse> queryPatientList(QueryPatientListRequest request) throws Exception {
|
|
public List<QueryPatientListResponse> queryPatientList(QueryPatientListRequest request) throws Exception {
|
|
int hospitalId = BizUtil.getCurrentHospitalId();
|
|
int hospitalId = BizUtil.getCurrentHospitalId();
|
|
int userId = ContextHelper.getCurrentUserIdWrapped();
|
|
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) throw new AppMessageException(result.getInfo());
|
|
|
|
- return getMedicalCardListResponse.getMedicalCardsList().stream()
|
|
|
|
|
|
+ return getUserMedCardList(userId, hospitalId).stream()
|
|
.map(c -> {
|
|
.map(c -> {
|
|
QueryPatientListResponse r = new QueryPatientListResponse();
|
|
QueryPatientListResponse r = new QueryPatientListResponse();
|
|
List<MedicCard> medicCards = new ArrayList<>();
|
|
List<MedicCard> medicCards = new ArrayList<>();
|
|
@@ -372,7 +344,7 @@ public class IsvMedicCardServiceImpl implements IsvMedicCardService {
|
|
r.setBindCardNum(c.getCardNo());
|
|
r.setBindCardNum(c.getCardNo());
|
|
MedicCard card = new MedicCard();
|
|
MedicCard card = new MedicCard();
|
|
card.setCardNum(c.getCardNo());
|
|
card.setCardNum(c.getCardNo());
|
|
- card.setType(0);
|
|
|
|
|
|
+ card.setType(CARD_TYPE_NORMAL);
|
|
card.setBalance(String.valueOf(c.getBalance() / 100d));
|
|
card.setBalance(String.valueOf(c.getBalance() / 100d));
|
|
medicCards.add(card);
|
|
medicCards.add(card);
|
|
r.setMedicCards(medicCards);
|
|
r.setMedicCards(medicCards);
|
|
@@ -398,6 +370,7 @@ public class IsvMedicCardServiceImpl implements IsvMedicCardService {
|
|
log.error("IsvMedicCardServiceImpl#getAgeFromMedicalCard(birthday = {}): 无法获取年龄 {}", birthday, e.getMessage(), e);
|
|
log.error("IsvMedicCardServiceImpl#getAgeFromMedicalCard(birthday = {}): 无法获取年龄 {}", birthday, e.getMessage(), e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ // 不返回年龄为 "-1"
|
|
if (age < 0) {
|
|
if (age < 0) {
|
|
return "";
|
|
return "";
|
|
}
|
|
}
|
|
@@ -425,8 +398,24 @@ public class IsvMedicCardServiceImpl implements IsvMedicCardService {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 根据 userId & hospitalId 获取用户可用就诊卡列表
|
|
|
|
+ */
|
|
|
|
+ public List<MedicalCard> getUserMedCardList(int userId, int hospitalId) throws AppMessageException {
|
|
|
|
+ GetMedicalCardListRequest getMedicalCardListRequest = GetMedicalCardListRequest.newBuilder()
|
|
|
|
+ .setHospitalId(hospitalId)
|
|
|
|
+ .setUserId(userId)
|
|
|
|
+ .build();
|
|
|
|
+ GetMedicalCardListResponse getMedicalCardListResponse = userServiceBlockingStub.getMedicalCardList(getMedicalCardListRequest);
|
|
|
|
+ Result result = getMedicalCardListResponse.getResult();
|
|
|
|
+ if (result.getCode() != ResultCode.SUCCEED) throw new AppMessageException(result.getInfo());
|
|
|
|
+ return getMedicalCardListResponse.getMedicalCardsList();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 查看就诊人详情
|
|
@Override
|
|
@Override
|
|
public QueryPatientDetailResponse querySinglePatient(QueryPatientDetailRequest request) throws Exception {
|
|
public QueryPatientDetailResponse querySinglePatient(QueryPatientDetailRequest request) throws Exception {
|
|
|
|
+ String id = request.getId(); // 对应 medicalCard 的 id
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|