|
@@ -28,6 +28,7 @@ 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.ArrayList;
|
|
import java.util.Comparator;
|
|
import java.util.Comparator;
|
|
import java.util.LinkedList;
|
|
import java.util.LinkedList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -346,7 +347,61 @@ public class IsvMedicCardServiceImpl implements IsvMedicCardService {
|
|
// 就诊人列表
|
|
// 就诊人列表
|
|
@Override
|
|
@Override
|
|
public List<QueryPatientListResponse> queryPatientList(QueryPatientListRequest request) throws Exception {
|
|
public List<QueryPatientListResponse> queryPatientList(QueryPatientListRequest request) throws Exception {
|
|
- return null;
|
|
|
|
|
|
+ int hospitalId = BizUtil.getCurrentHospitalId();
|
|
|
|
+ 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()
|
|
|
|
+ .map(c -> {
|
|
|
|
+ QueryPatientListResponse r = new QueryPatientListResponse();
|
|
|
|
+ List<MedicCard> medicCards = new ArrayList<>();
|
|
|
|
+ r.setId(String.valueOf(c.getCardId()));
|
|
|
|
+ r.setName(c.getPatientName());
|
|
|
|
+ r.setAge(getAgeFromMedicalCard(c));
|
|
|
|
+ r.setSex(SexEnum.getSexDisplayName(c.getSex()));
|
|
|
|
+ r.setPhoneNumber(c.getMobile());
|
|
|
|
+ r.setBirthDay(c.getBirthday());
|
|
|
|
+ r.setIdCardNo(c.getIdNo());
|
|
|
|
+ r.setRelationShip(RelationshipEnum.valueOf(c.getRelationship()).getDisplayName());
|
|
|
|
+ r.setDefaultPatient(false); // TODO: 怎么确定默认就诊人
|
|
|
|
+ r.setBindCardNum(c.getCardNo());
|
|
|
|
+ MedicCard card = new MedicCard();
|
|
|
|
+ card.setCardNum(c.getCardNo());
|
|
|
|
+ card.setType(0);
|
|
|
|
+ card.setBalance(String.valueOf(c.getBalance() / 100d));
|
|
|
|
+ medicCards.add(card);
|
|
|
|
+ r.setMedicCards(medicCards);
|
|
|
|
+ return r;
|
|
|
|
+ })
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private String getAgeFromMedicalCard(MedicalCard card) {
|
|
|
|
+ int age = -1;
|
|
|
|
+ String idNo = card.getIdNo();
|
|
|
|
+ String birthday = card.getBirthday();
|
|
|
|
+ if (!StringHelper.isNullOrEmpty(idNo)) {
|
|
|
|
+ try {
|
|
|
|
+ age = IdCardUtil.getCurrentAge(idNo);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("IsvMedicCardServiceImpl#getAgeFromMedicalCard(idNo = {}): 无法获取年龄 {}", idNo, e.getMessage(), e);
|
|
|
|
+ }
|
|
|
|
+ } else if (!StringHelper.isNullOrEmpty(birthday)) {
|
|
|
|
+ try {
|
|
|
|
+ age = IdCardUtil.getCurrentAgeByBirthday(birthday, IdCardUtil.DATE_PATTERN2);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("IsvMedicCardServiceImpl#getAgeFromMedicalCard(birthday = {}): 无法获取年龄 {}", birthday, e.getMessage(), e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (age < 0) {
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+ return String.valueOf(age);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|