MeiZhongYiHeServiceImpl.java
2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.infoloop.tianting.service.impl;
import com.infoloop.tianting.model.dto.ClientLabelDTO.HisAllergy;
import com.infoloop.tianting.model.dto.ClientLabelDTO.HisMedicalAdviceDto;
import com.infoloop.tianting.service.MeiZhongYiHeService;
import com.infoloop.tianting.service.client.MeiZhongYiHeServiceClient;
import com.infoloop.tianting.utils.DateUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class MeiZhongYiHeServiceImpl implements MeiZhongYiHeService {
private final MeiZhongYiHeServiceClient meiZhongYiHeServiceClient;
@Override
public List<HisAllergy> getHisCustomerAllergiesByCustomerId(String hisCustomerId) {
final var response = meiZhongYiHeServiceClient.getHisCustomerAllergiesByCustomerId(hisCustomerId);
if (response.getCustomerAllergiesCount() == 0) {
return new ArrayList<>();
}
return response.getCustomerAllergies(0).getAllergiesList().stream().map(allergy ->
HisAllergy.builder()
.allergyCode(allergy.getAllergyCode())
.allergyDescription(allergy.getAllergyDescription())
.allergyId(allergy.getAllergyId())
.createdAt(DateUtil.formatDate(allergy.getCreatedAt()))
.build()).collect(Collectors.toList());
}
@Override
public List<HisMedicalAdviceDto> getHisCustomerMedicalAdvicesByContractNo(String contractNo) {
final var response = meiZhongYiHeServiceClient.getHisCustomerMedicalAdvicesByContractNo(
contractNo);
if (response.getCustomerMedicalAdvicesCount() == 0) {
return new ArrayList<>();
}
return response.getCustomerMedicalAdvices(0).getMedicalAdvicesList().stream().map(
advice ->
HisMedicalAdviceDto.builder()
.connotation(advice.getConnotation())
.effectDate(DateUtil.formatDate(advice.getEffectDate()))
.medicalAdvice(advice.getMedicalAdvice())
.medicalAdviceCode(advice.getMedicalAdviceCode())
.medicalAdviceId(advice.getMedicalAdviceId())
.medicalAdviceType(advice.getMedicalAdviceType())
.medicalTime(DateUtil.formatDate(advice.getMedicalTime()))
.build()
).collect(Collectors.toList());
}
}