路泰机电科技体检——数据平台后端
zhaowenxuan
2025-01-02 06f3d4be5f282dea252070a1df496ab4ab5b738a
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
package com.example.service.shanxiqin.xian;
 
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.pinyin.PinyinUtil;
import cn.hutool.json.JSON;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.example.config.ConfigValue;
import com.example.constant.ApiParamsConstants;
import com.example.constant.ApiParamsConstantsLis;
import com.example.service.LisService;
import com.example.utils.AjaxResult;
import com.example.utils.FieldNameConverter;
import com.example.utils.HttpClientUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
 
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.*;
 
/**
 * @Company: 西安路泰科技有限公司
 * @Author: zhaowenxuan
 * @Date: 2024/12/25 10:14
 */
@Slf4j
@Service("ShanXiQinXiAnMeiJiLis")
public class MeiJiLisService implements LisService {
    @Autowired
    private ConfigValue configValue;
 
    private final ApplicationContext applicationContext;
 
    private final String LIS_URL;
    private final String TJ_URL;
 
    @Autowired
    public MeiJiLisService(ApplicationContext applicationContext, ConfigValue configValue) {
        this.applicationContext = applicationContext;
        this.configValue = configValue;
        LIS_URL = configValue.getConfigValue("ShanXi_Qin_XiAn_MeiJi.lis_api_url") + ":" + configValue.getConfigValue("ShanXi_Qin_XiAn_MeiJi.lis_api_port") + configValue.getConfigValue("ShanXi_Qin_XiAn_MeiJi.lisapiappend");
        TJ_URL = configValue.getConfigValue("ShanXi_Qin_XiAn_MeiJi.tjUrl");
    }
 
    @Override
    public String makeSqd(Map<String, Object> map) {
        HashMap<String, Object> hashMap = new HashMap<>();
        // 门诊号码
        hashMap.put("PATIENTNO", map.get(ApiParamsConstantsLis.PATIENTNO));
        // 挂号号码
        hashMap.put("GH_PATIENTNO", map.get(ApiParamsConstantsLis.GH_PATIENTNO));
        // 标本条形码
        hashMap.put("TXM", map.get(ApiParamsConstantsLis.TXM));
        // 辅助号码
        hashMap.put("PRINTNO",map.get(ApiParamsConstantsLis.PRINTNO));
        // 病人姓名
        hashMap.put("PATIENTNAME",map.get(ApiParamsConstants.CUS_NAME));
        // 出生日期
        hashMap.put("BIRTHDAY",map.get(ApiParamsConstants.CUS_BRITHDAY));
        // 身份证号
        hashMap.put("SFZH",map.get(ApiParamsConstants.CUS_ID_CARD));
        // 性别
        long cusSex = Long.parseLong(map.get(ApiParamsConstants.CUS_SEX).toString());
        if(cusSex==0L){
            hashMap.put ("GENDER","1");
        }else if(cusSex==1L){
            hashMap.put ("GENDER","2");
        }else {
            hashMap.put ("GENDER","0");
        }
        hashMap.put("ADDRESS",map.get(ApiParamsConstants.CUS_ADDR));
        hashMap.put("TELEPHONE",map.get(ApiParamsConstants.CUS_PHONE));
        hashMap.put("YBKH","");
        hashMap.put("TJDW",map.get(ApiParamsConstants.COMP_NAME));
        hashMap.put("ISACTIVE","1");
        hashMap.put("SENDDOCTOR","1573");
        hashMap.put("SENDDOCTORNAME","孙鹏侠");
        hashMap.put("SENDDEPARTCODE","533");
        hashMap.put("SENDDEPARTNAME","体检中心");
        hashMap.put("APPLYDEPARTCODE","533");
        hashMap.put("APPLYDEPARTNAME","体检中心");
        hashMap.put("APPLYDOCTORCODE","1573");
        hashMap.put("APPLYDOCTORNAME","孙鹏侠");
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String dqsj = format.format(new Date());
        hashMap.put("APPLYDATETIME",dqsj);
        hashMap.put("BEDNO","");
        hashMap.put("SENDDATE",dqsj);
        hashMap.put("SFDATE",dqsj);
        // TODO
        hashMap.put("HOSPITALID","xamjyy");
        // TODO
//        hashMap.put("CARDTYPE","");
        hashMap.put("PATIENTTYPE","3");
        hashMap.put("SFYNAME",map.get(ApiParamsConstantsLis.SFYNAME));
        hashMap.put("jizhenBz","0");
 
        JSONArray array = JSONUtil.parseArray(map.get(ApiParamsConstantsLis.mxList));
        JSONArray orderInfoList = JSONUtil.createArray();
        for (Object o : array) {
            JSONObject entries = (JSONObject) o;
            JSONObject object = JSONUtil.createObj();
            object.putOpt("SFXMID",entries.getStr(ApiParamsConstantsLis.SFXMID));
            object.putOpt("SFXMNAME",entries.getStr(ApiParamsConstantsLis.SFXMNAME));
            object.putOpt("SFXMPRICE",entries.getStr(ApiParamsConstantsLis.SFXMPRICE));
            object.putOpt("QUALITY",entries.getStr(ApiParamsConstantsLis.QUALITY));
            object.putOpt("SpecimenCode",entries.getStr(ApiParamsConstantsLis.SpecimenCode));
            object.putOpt("SpecimenDesc",entries.getStr(ApiParamsConstantsLis.SpecimenDesc));
            object.putOpt("KEYVALUE",entries.getStr(ApiParamsConstantsLis.PRIMARY_KEY));
            orderInfoList.add(object);
        }
        hashMap.put("OderInfoList",orderInfoList);
        log.info("申请单 ->{}",JSONUtil.toJsonStr(hashMap));
        String post = sendPost(LIS_URL + "/lisinterface" + "/HisApplyList", hashMap);
        JSONObject entries = JSONUtil.parseObj(post);
        if (entries.getStr("MsgCode").equals("0"))
            return AjaxResult.success();
        else return AjaxResult.error();
    }
 
    @Override
    public String getXmlList(Map<String, Object> map) {
        Map<String, Object> request = (Map<String, Object>) map.get("Request");
        String hospitalId = request.get("HospitalId").toString();
        String json = sendPost(TJ_URL + "/callBack/getZdList", new HashMap<>());
        JSONObject entries = JSONUtil.parseObj(json);
        JSONObject result = JSONUtil.createObj();
        if (entries.getStr("code").equals("200")){
            result.putOpt("returnCode","200");
            result.putOpt("returnMessage","获取成功");
            result.putOpt("HOSPITALID",hospitalId);
            JSONArray array = entries.getJSONArray("data");
            result.putOpt("Rows",array.size());
            JSONArray dataInfoList = JSONUtil.createArray();
            for (Object o : array) {
                JSONObject object = (JSONObject) o;
                JSONObject obj = JSONUtil.createObj();
                obj.putOpt("SFXMID",object.getStr("SFXMID"));
                String sfxmname = object.getStr("SFXMNAME");
                obj.putOpt("SFXMNAME",sfxmname);
                obj.putOpt("UNIT","");
                obj.putOpt("SFKZ","");
                obj.putOpt("SFXM","");
                obj.putOpt("PRICE",object.getStr("PRICE"));
                obj.putOpt("SRM1", PinyinUtil.getFirstLetter(sfxmname,""));
                obj.putOpt("SRM2","");
                obj.putOpt("SRM3","");
                obj.putOpt("MEMO","");
                obj.putOpt("PATIENTTYPE","3");
                dataInfoList.add(obj);
            }
            result.putOpt("DataInfoList",dataInfoList);
            return JSONUtil.toJsonStr(result);
        }else {
            result.putOpt("returnCode","400");
            result.putOpt("returnMessage","获取失败");
            result.putOpt("HospitalId",hospitalId);
            return JSONUtil.toJsonStr(result);
        }
    }
 
    @Override
    public String revoke(Map<String, Object> map) {
        HashMap<String, Object> params = new HashMap<>();
        JSONArray list = (JSONArray) map.get("list");
        JSONArray array = JSONUtil.createArray();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String sj = format.format(new Date());
        for (Object o : list) {
            JSONObject object = (JSONObject) o;
            JSONObject entries = JSONUtil.createObj();
            entries.putOpt("TXM",object.getStr(ApiParamsConstantsLis.TXM));
            entries.putOpt("TFDOCTORID","1573");
            entries.putOpt("TFDOCTORNAME","孙鹏侠");
            entries.putOpt("TFDATE",sj);
            entries.putOpt("TFDEPARTID","533");
            entries.putOpt("TFDEPARTNAME","体检中心");
            entries.putOpt("HOSPITALID","xamjyy");
            entries.putOpt("TFSFXMID",object.getStr(ApiParamsConstantsLis.SFXMID));
            entries.putOpt("TFSFXMNAME",object.getStr(ApiParamsConstantsLis.SFXMNAME));
            entries.putOpt("TFKEYVALUE",object.getStr(ApiParamsConstantsLis.PRIMARY_KEY));
            array.add(entries);
        }
        String post = HttpClientUtils.sendPost(LIS_URL + "/lisinterface/FetchChargebacksInformation", JSONUtil.toJsonStr(array));
        if (JSONUtil.parseObj(post).getStr("MsgCode").equals("0"))
            return AjaxResult.success();
        else return AjaxResult.error();
    }
 
    @Override
    public String confirmRevoke(Map<String, Object> map) {
        String personid = map.get("PERSONID").toString();
        String hospitalid = map.get("HOSPITALID").toString();
        List<String> keys = Arrays.asList((String[]) map.get("KEYVALUELIST"));
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("keys",keys);
        hashMap.put("czy",personid);
        hashMap.put("hospid",hospitalid);
        String post = sendPost(TJ_URL + "/callBack/lisRevoke", hashMap);
        JSONObject entries = JSONUtil.parseObj(post);
        JSONObject object = JSONUtil.createObj();
        if (entries.getStr("code").equals("200")){
            object.putOpt("returnCode","200");
            return JSONUtil.toJsonStr(object);
        }else {
            object.putOpt("returnCode","500");
            return JSONUtil.toJsonStr(object);
        }
    }
 
    private String sendPost(String url, Map<String, Object> hashMap){
        return HttpClientUtils.sendPost(url, hashMap);
    }
}