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);
|
}
|
}
|