|
@ -14,13 +14,17 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
|
|
|
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
|
|
|
import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
|
|
|
import com.yihu.jw.entity.hospital.prescription.*;
|
|
|
import com.yihu.jw.hospital.dict.YkDictIcd10Dao;
|
|
|
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
|
|
|
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
|
|
|
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
|
|
|
import com.yihu.jw.hospital.prescription.dao.PrescriptionInfoDao;
|
|
|
import com.yihu.jw.restmodel.hospital.prescription.*;
|
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.utils.StringUtil;
|
|
|
import com.yihu.jw.utils.hibernate.HibenateUtils;
|
|
|
import com.yihu.utils.network.HttpResponse;
|
|
|
import com.yihu.utils.network.HttpUtils;
|
|
|
import com.yihu.utils.security.MD5;
|
|
@ -48,7 +52,12 @@ import static com.yihu.jw.util.common.PwdUtil.randomString;
|
|
|
public class TnyyEntranceService {
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(TnyyEntranceService.class);
|
|
|
private final static String url="http://10.9.1.247:10023/ykyy/createSQLQuery";
|
|
|
private final static String url="http://10.9.1.247:10023//tnyy/queryBySql";
|
|
|
private final static String saveUrl="http://10.9.1.247:10023//tnyy/save";
|
|
|
private final static String updateUrl="http://10.9.1.247:10023//tnyy/updateBySql";
|
|
|
private final static String updateEntityUrl="http://10.9.1.247:10023/tnyy/update";
|
|
|
@Autowired
|
|
|
private PrescriptionInfoDao prescriptionInfoDao;
|
|
|
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
@ -67,6 +76,10 @@ public class TnyyEntranceService {
|
|
|
private final static String orgCode ="350211A1002";
|
|
|
@Autowired
|
|
|
private PatientMappingDao patientMappingDao;
|
|
|
@Autowired
|
|
|
private HibenateUtils hibenateUtils;
|
|
|
@Autowired
|
|
|
private PrescriptionDao prescriptionDao;
|
|
|
|
|
|
|
|
|
|
|
@ -897,4 +910,272 @@ public class TnyyEntranceService {
|
|
|
}
|
|
|
|
|
|
|
|
|
public void save(Object object){
|
|
|
hibenateUtils.save(object);
|
|
|
}
|
|
|
|
|
|
public void updateBySql(String sql){
|
|
|
hibenateUtils.updateBySql(sql);
|
|
|
}
|
|
|
public void update(Object object){
|
|
|
hibenateUtils.update(object);
|
|
|
}
|
|
|
|
|
|
public String findByRealOrder(String code,boolean demoFlag) throws Exception {
|
|
|
List<WlyyPrescriptionDO> wlyyPrescriptionDOs = prescriptionDao.findById(code);
|
|
|
if (wlyyPrescriptionDOs!=null&&wlyyPrescriptionDOs.size()!=0){
|
|
|
WlyyPrescriptionDO wlyyPrescriptionDO = wlyyPrescriptionDOs.get(0);
|
|
|
JSONObject objectString = (JSONObject) JSONObject.toJSON(wlyyPrescriptionDO);
|
|
|
WlyyPrescriptionVO prescriptionVO = JSONObject.toJavaObject(objectString,WlyyPrescriptionVO.class);
|
|
|
List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(wlyyPrescriptionDO.getId(),1);
|
|
|
List<WlyyPrescriptionInfoVO> wlyyPrescriptionInfoVOS = new ArrayList<>();
|
|
|
for (WlyyPrescriptionInfoDO wlyyPrescriptionInfoDO:wlyyPrescriptionInfoDOS){
|
|
|
JSONObject object = (JSONObject) JSONObject.toJSON(wlyyPrescriptionInfoDO);
|
|
|
logger.info("11111参数入参"+object.toJSONString());
|
|
|
WlyyPrescriptionInfoVO prescriptionInfoVO = JSONObject.toJavaObject(object,WlyyPrescriptionInfoVO.class);
|
|
|
wlyyPrescriptionInfoVOS.add(prescriptionInfoVO);
|
|
|
}
|
|
|
/* //诊断
|
|
|
synPrescriptionDiagnosis(prescriptionVO,code,demoFlag);*/
|
|
|
|
|
|
prescriptionVO.setInfoVOs(wlyyPrescriptionInfoVOS);
|
|
|
|
|
|
/* List<WlyyInspectionDO> inspectionDOS = wlyyInspectionDao.findByPrescriptionId(code,1);*/
|
|
|
synPrecriptionTnHis(prescriptionVO,code);
|
|
|
/*//同步检查检验
|
|
|
if(null!=inspectionDOS&&inspectionDOS.size()>0){
|
|
|
synInspect(inspectionDOS);
|
|
|
}*/
|
|
|
}
|
|
|
|
|
|
return wlyyPrescriptionDOs.toString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
public WlyyPrescriptionVO synPrecriptionTnHis(WlyyPrescriptionVO wlyyPrescriptionVO,String code) throws Exception {
|
|
|
HlwTnCf01DO hlwCf01DO = new HlwTnCf01DO();
|
|
|
logger.info("开始===================");
|
|
|
if (wlyyPrescriptionVO!=null){
|
|
|
try {
|
|
|
|
|
|
hlwCf01DO.setYFSB(3);
|
|
|
hlwCf01DO.setCFLX(wlyyPrescriptionVO.getType());
|
|
|
hlwCf01DO.setKFRQ(DateUtil.strToDate(DateUtil.dateToStr(wlyyPrescriptionVO.getCreateTime(),"yyyy-MM-dd HH:mm:ss")));
|
|
|
hlwCf01DO.setZFPB(0);
|
|
|
hlwCf01DO.setFYBZ(0);
|
|
|
hlwCf01DO.setPYBZ(0);
|
|
|
hlwCf01DO.setCFTS(1);
|
|
|
hlwCf01DO.setYXPB(1);
|
|
|
hlwCf01DO.setDYBZ(0);
|
|
|
hlwCf01DO.setTSCF(0);
|
|
|
hlwCf01DO.setTYBZ(0);
|
|
|
hlwCf01DO.setTSLX(6);
|
|
|
hlwCf01DO.setCFBZ(0);
|
|
|
hlwCf01DO.setJZXH(0);
|
|
|
hlwCf01DO.setYXPB(0);
|
|
|
hlwCf01DO.setPjbz(0);
|
|
|
hlwCf01DO.setFypj(0);
|
|
|
String patient = wlyyPrescriptionVO.getPatientCode();
|
|
|
PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patient);
|
|
|
hlwCf01DO.setBRID(Integer.parseInt(patientMappingDO.getMappingCode()));
|
|
|
hlwCf01DO.setBRXM(wlyyPrescriptionVO.getPatientName());
|
|
|
hlwCf01DO.setKSDM(Integer.parseInt(wlyyPrescriptionVO.getDept()));
|
|
|
String doctor = wlyyPrescriptionVO.getDoctor();
|
|
|
DoctorMappingDO doctorMappingDO = doctorMappingDao.findByDoctor(doctor);
|
|
|
hlwCf01DO.setYSDM(doctorMappingDO.getMappingCode());
|
|
|
hlwCf01DO.setJZKH(wlyyPrescriptionVO.getSsc());
|
|
|
if (StringUtils.isNoneBlank(wlyyPrescriptionVO.getAdmNo())){
|
|
|
hlwCf01DO.setJZXH(Integer.parseInt(wlyyPrescriptionVO.getAdmNo()));
|
|
|
}
|
|
|
/* hibenateUtils.save(hlwCf01DO);*/
|
|
|
if (StringUtils.isNoneBlank(wlyyPrescriptionVO.getRealOrder())){
|
|
|
hlwCf01DO.setCFSB(Integer.parseInt(wlyyPrescriptionVO.getRealOrder()));
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(wlyyPrescriptionVO.getOriginRealOrder())){
|
|
|
hlwCf01DO.setCFHM(wlyyPrescriptionVO.getOriginRealOrder());
|
|
|
}
|
|
|
|
|
|
String jsonString = JSONObject.toJSONString(hlwCf01DO);
|
|
|
Map<String,Object> params = new HashedMap();
|
|
|
params.put("json",jsonString);
|
|
|
params.put("table","HLW_CF01");
|
|
|
logger.info("HLW_CF01:"+jsonString);
|
|
|
/**
|
|
|
{"message":null,"status":200,"obj":{"cfhm":1898356,"cfsb":5390518}}
|
|
|
|
|
|
*/
|
|
|
String cfsb = null;
|
|
|
String cfhm = null;
|
|
|
if (!StringUtils.isNoneBlank(wlyyPrescriptionVO.getRealOrder())){
|
|
|
HttpResponse response = HttpUtils.doGet(saveUrl,params);
|
|
|
if (response.getStatus()==200){
|
|
|
logger.info("content"+response.getContent());
|
|
|
String content = response.getContent();
|
|
|
JSONObject jsonObject = JSONObject.parseObject(content);
|
|
|
JSONObject object = jsonObject.getJSONObject("obj");
|
|
|
if (object!=null){
|
|
|
cfsb = object.getString("cfsb");
|
|
|
cfhm = object.getString("cfhm");
|
|
|
logger.info("kaishi=========="+cfsb);
|
|
|
List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findById(code);
|
|
|
if (wlyyPrescriptionDOS!=null&&wlyyPrescriptionDOS.size()!=0){
|
|
|
WlyyPrescriptionDO wlyyPrescriptionDO = wlyyPrescriptionDOS.get(0);
|
|
|
wlyyPrescriptionDO.setRealOrder(cfsb);
|
|
|
wlyyPrescriptionDO.setOriginRealOrder(cfhm);
|
|
|
prescriptionDao.save(wlyyPrescriptionDO);
|
|
|
}
|
|
|
}
|
|
|
logger.info("表HLW_CF01同步成功!");
|
|
|
|
|
|
}else {
|
|
|
logger.info("表HLW_CF01同步失败!"+response.getErrorMsg());
|
|
|
}
|
|
|
}else {
|
|
|
cfsb = wlyyPrescriptionVO.getRealOrder();
|
|
|
|
|
|
String sql = "update v_ms_dd01 t set t.ZFPB=1,t.ZFSJ=to_date('"+DateUtil.getStringDate()+"','yyyy-mm-dd hh24:mi:ss') where t.CFSB ='"+cfsb+"' ";
|
|
|
Map<String,Object> params1 = new HashedMap();
|
|
|
params1.put("sql",sql);
|
|
|
HttpResponse response = HttpUtils.doGet(updateUrl,params1);
|
|
|
if (response.getStatus()==200){
|
|
|
logger.info("表v_ms_dd01作废成功!");
|
|
|
HttpResponse response1 = HttpUtils.doGet(saveUrl,params);
|
|
|
if (response1.getStatus()==200){
|
|
|
logger.info("content"+response1.getContent());
|
|
|
String content = response1.getContent();
|
|
|
JSONObject jsonObject = JSONObject.parseObject(content);
|
|
|
JSONObject object = jsonObject.getJSONObject("obj");
|
|
|
if (object!=null){
|
|
|
cfsb = object.getString("cfsb");
|
|
|
cfhm = object.getString("cfhm");
|
|
|
logger.info("kaishi=========="+cfsb);
|
|
|
List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findById(code);
|
|
|
if (wlyyPrescriptionDOS!=null&&wlyyPrescriptionDOS.size()!=0){
|
|
|
WlyyPrescriptionDO wlyyPrescriptionDO = wlyyPrescriptionDOS.get(0);
|
|
|
wlyyPrescriptionDO.setRealOrder(cfsb);
|
|
|
wlyyPrescriptionDO.setOriginRealOrder(cfhm);
|
|
|
prescriptionDao.save(wlyyPrescriptionDO);
|
|
|
}
|
|
|
}
|
|
|
logger.info("表HLW_CF01同步成功!");
|
|
|
|
|
|
}else {
|
|
|
logger.info("表HLW_CF01同步失败!"+response.getErrorMsg());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* hlwCf01DO.setZFPB(1);
|
|
|
hlwCf01DO.setZFSJ(new Date());
|
|
|
HttpResponse response = HttpUtils.doGet(updateEntityUrl,params);
|
|
|
if (response.getStatus()==200){
|
|
|
logger.info("content"+response.getContent());
|
|
|
logger.info("表HLW_CF01更新成功!");
|
|
|
|
|
|
}else {
|
|
|
logger.info("表HLW_CF01更新失败!"+response.getErrorMsg());
|
|
|
}*/
|
|
|
}
|
|
|
|
|
|
logger.info("处方:"+cfsb);
|
|
|
if (StringUtils.isEmpty(cfsb)){
|
|
|
throw new Exception("添加失败");
|
|
|
}
|
|
|
/* if (StringUtils.isNoneBlank(wlyyPrescriptionVO.getRealOrder())){
|
|
|
String deleteSql = "delete from v_ms_dd02 where cfsb = '"+wlyyPrescriptionVO.getRealOrder()+"'";
|
|
|
Map<String,Object> params1 = new HashedMap();
|
|
|
params1.put("sql",deleteSql);
|
|
|
HttpResponse response = HttpUtils.doGet(updateUrl,params1);
|
|
|
if (response.getStatus()==200){
|
|
|
logger.info("表v_ms_dd02删除成功!");
|
|
|
}
|
|
|
}*/
|
|
|
List<WlyyPrescriptionInfoVO> wlyyPrescriptionInfoVOS =wlyyPrescriptionVO.getInfoVOs();
|
|
|
for (WlyyPrescriptionInfoVO wlyyPrescriptionInfoVO:wlyyPrescriptionInfoVOS){
|
|
|
try {
|
|
|
logger.info("chufang1============");
|
|
|
HlwTnCf02DO hlwCf02DO = new HlwTnCf02DO();
|
|
|
hlwCf02DO.setCFSB(Integer.parseInt(cfsb));
|
|
|
hlwCf02DO.setYPXH(Integer.parseInt(wlyyPrescriptionInfoVO.getDrugNo()));
|
|
|
logger.info("drugNo"+hlwCf02DO.getYPXH());
|
|
|
if (wlyyPrescriptionInfoVO.getDrugPlace()!=null){
|
|
|
hlwCf02DO.setYPCD(Integer.parseInt(wlyyPrescriptionInfoVO.getDrugPlace()));
|
|
|
}
|
|
|
hlwCf02DO.setXMLX(1);
|
|
|
hlwCf02DO.setCFTS(1);
|
|
|
hlwCf02DO.setYPSL(Double.parseDouble(wlyyPrescriptionInfoVO.getQuantity()));
|
|
|
hlwCf02DO.setYPDJ(wlyyPrescriptionInfoVO.getPackRetprice());
|
|
|
hlwCf02DO.setHJJE(Integer.parseInt(wlyyPrescriptionInfoVO.getQuantity())*wlyyPrescriptionInfoVO.getPackRetprice());//划价价额
|
|
|
hlwCf02DO.setYPZS(1);//药品组数 待确定
|
|
|
hlwCf02DO.setYCSL("0");
|
|
|
hlwCf02DO.setFYGB(1);//费用归并
|
|
|
hlwCf02DO.setZFBL(1.0);//自负比例
|
|
|
hlwCf02DO.setYFDW(wlyyPrescriptionInfoVO.getPackUnitName());
|
|
|
hlwCf02DO.setMRCS(StringUtils.isNoneBlank(wlyyPrescriptionInfoVO.getGroupNo())?Integer.parseInt(wlyyPrescriptionInfoVO.getGroupNo()):0);//每日次数
|
|
|
hlwCf02DO.setYFBZ(3);
|
|
|
hlwCf02DO.setYPYF(wlyyPrescriptionInfoVO.getUsageCode());
|
|
|
hlwCf02DO.setGYTJ(wlyyPrescriptionInfoVO.getYpyf());
|
|
|
hlwCf02DO.setSL(Integer.parseInt(wlyyPrescriptionInfoVO.getQuantity()));
|
|
|
hlwCf02DO.setPSPB(0);
|
|
|
hlwCf02DO.setYYTS(1);
|
|
|
hlwCf02DO.setJhjg(0);
|
|
|
hlwCf02DO.setJhje(0);
|
|
|
hlwCf02DO.setJhjg1(0);
|
|
|
hlwCf02DO.setDzdr(0);
|
|
|
hlwCf02DO.setYCJL(wlyyPrescriptionInfoVO.getDosage()!=null?Double.parseDouble(wlyyPrescriptionInfoVO.getDosage()):0);
|
|
|
if (wlyyPrescriptionInfoVO.getHisCode()!=null){
|
|
|
hlwCf02DO.setSBXH(wlyyPrescriptionInfoVO.getHisCode());
|
|
|
}
|
|
|
/*hlwCf02DO.setYPZH(Integer.parseInt(wlyyPrescriptionInfoVO.getFrequency()));*/
|
|
|
hlwCf02DO.setYFGG(wlyyPrescriptionInfoVO.getSpecification());
|
|
|
/* hibenateUtils.save(hlwCf02DO);*/
|
|
|
String jsonString1 = JSONObject.toJSONString(hlwCf02DO);
|
|
|
logger.info("chufang2============");
|
|
|
Map<String,Object> params1 = new HashedMap();
|
|
|
params1.put("json",jsonString1);
|
|
|
params1.put("table","HLW_CF02");
|
|
|
logger.info("HLW_CF02:"+jsonString1);
|
|
|
if (wlyyPrescriptionInfoVO.getHisCode()==null){
|
|
|
HttpResponse response1 = HttpUtils.doGet(saveUrl,params1);
|
|
|
Integer sbxh = null;
|
|
|
if (response1.getStatus()==200){
|
|
|
logger.info("content"+response1.getContent());
|
|
|
String content = response1.getContent();
|
|
|
JSONObject jsonObject = JSONObject.parseObject(content);
|
|
|
JSONObject object = jsonObject.getJSONObject("obj");
|
|
|
if (object!=null){
|
|
|
sbxh = object.getInteger("sbxh");
|
|
|
logger.info("kaishi=========="+cfsb);
|
|
|
WlyyPrescriptionInfoDO wlyyPrescriptionInfoDO = prescriptionInfoDao.findOne(wlyyPrescriptionInfoVO.getId());
|
|
|
if (wlyyPrescriptionInfoDO!=null){
|
|
|
wlyyPrescriptionInfoDO.setHisCode(sbxh);
|
|
|
prescriptionInfoDao.save(wlyyPrescriptionInfoDO);
|
|
|
}
|
|
|
}
|
|
|
logger.info("表HLW_CF02同步成功!");
|
|
|
}else {
|
|
|
logger.info("表HLW_CF02同步失败!"+response1.getErrorMsg());
|
|
|
}
|
|
|
}else {
|
|
|
HttpResponse response1 = HttpUtils.doGet(updateEntityUrl,params1);
|
|
|
if (response1.getStatus()==200){
|
|
|
logger.info("content"+response1.getContent());
|
|
|
logger.info("表HLW_CF02更新成功!");
|
|
|
}else {
|
|
|
logger.info("表HLW_CF02更新失败!"+response1.getErrorMsg());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
e.getMessage();
|
|
|
}
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
}
|