|  | @ -10,17 +10,25 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
 | 
												
													
														
															|  | import com.yihu.jw.entity.base.patient.BasePatientDO;
 |  | import com.yihu.jw.entity.base.patient.BasePatientDO;
 | 
												
													
														
															|  | import com.yihu.jw.entity.ca.OauthCaConfigDO;
 |  | import com.yihu.jw.entity.ca.OauthCaConfigDO;
 | 
												
													
														
															|  | import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
 |  | import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.entity.hospital.healthCare.YlzMedicalIcdDO;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.entity.hospital.healthCare.YlzMedicalMxDO;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.entity.hospital.healthCare.YlzMedicalRelationDO;
 | 
												
													
														
															|  | import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
 |  | import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
 | 
												
													
														
															|  | import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
 |  | import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
 | 
												
													
														
															|  | import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
 |  | import com.yihu.jw.entity.hospital.mapping.PatientMappingDO;
 | 
												
													
														
															|  | import com.yihu.jw.entity.hospital.prescription.*;
 |  | import com.yihu.jw.entity.hospital.prescription.*;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.entity.order.BusinessOrderDO;
 | 
												
													
														
															|  | import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
 |  | import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.hospital.healthCare.YlzMedicailIcdDao;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.hospital.healthCare.YlzMedicailMxDao;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.hospital.healthCare.YlzMedicailRelationDao;
 | 
												
													
														
															|  | import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
 |  | import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
 | 
												
													
														
															|  | import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
 |  | import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
 | 
												
													
														
															|  | import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
 |  | import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
 | 
												
													
														
															|  | import com.yihu.jw.hospital.prescription.dao.*;
 |  | import com.yihu.jw.hospital.prescription.dao.*;
 | 
												
													
														
															|  | import com.yihu.jw.hospital.prescription.service.entrance.HcyyEntranceService;
 |  | import com.yihu.jw.hospital.prescription.service.entrance.HcyyEntranceService;
 | 
												
													
														
															|  | import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
 |  | import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
 | 
												
													
														
															|  | 
 |  | import com.yihu.jw.order.dao.BusinessOrderDao;
 | 
												
													
														
															|  | import com.yihu.jw.patient.dao.BasePatientDao;
 |  | import com.yihu.jw.patient.dao.BasePatientDao;
 | 
												
													
														
															|  | import com.yihu.jw.restmodel.hospital.prescription.*;
 |  | import com.yihu.jw.restmodel.hospital.prescription.*;
 | 
												
													
														
															|  | import com.yihu.jw.util.common.IdCardUtil;
 |  | import com.yihu.jw.util.common.IdCardUtil;
 | 
												
											
												
													
														
															|  | @ -28,6 +36,8 @@ import com.yihu.jw.util.date.DateUtil;
 | 
												
													
														
															|  | import com.yihu.jw.util.http.HttpClientUtil;
 |  | import com.yihu.jw.util.http.HttpClientUtil;
 | 
												
													
														
															|  | import com.yihu.jw.utils.StringUtil;
 |  | import com.yihu.jw.utils.StringUtil;
 | 
												
													
														
															|  | import com.yihu.mysql.query.BaseJpaService;
 |  | import com.yihu.mysql.query.BaseJpaService;
 | 
												
													
														
															|  | 
 |  | import com.yihu.utils.network.HttpResponse;
 | 
												
													
														
															|  | 
 |  | import com.yihu.utils.network.HttpUtils;
 | 
												
													
														
															|  | import org.apache.commons.collections.map.HashedMap;
 |  | import org.apache.commons.collections.map.HashedMap;
 | 
												
													
														
															|  | import org.apache.commons.lang3.StringUtils;
 |  | import org.apache.commons.lang3.StringUtils;
 | 
												
													
														
															|  | import org.slf4j.Logger;
 |  | import org.slf4j.Logger;
 | 
												
											
												
													
														
															|  | @ -36,6 +46,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 | 
												
													
														
															|  | import org.springframework.stereotype.Service;
 |  | import org.springframework.stereotype.Service;
 | 
												
													
														
															|  | import org.springframework.transaction.annotation.Transactional;
 |  | import org.springframework.transaction.annotation.Transactional;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | import java.security.PublicKey;
 | 
												
													
														
															|  | import java.text.DecimalFormat;
 |  | import java.text.DecimalFormat;
 | 
												
													
														
															|  | import java.util.*;
 |  | import java.util.*;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
											
												
													
														
															|  | @ -84,6 +95,21 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
 | 
												
													
														
															|  |     private HcyyEntranceService hcyyEntranceService;
 |  |     private HcyyEntranceService hcyyEntranceService;
 | 
												
													
														
															|  |     @Autowired
 |  |     @Autowired
 | 
												
													
														
															|  |     private PrescriptionDao prescriptionDao;
 |  |     private PrescriptionDao prescriptionDao;
 | 
												
													
														
															|  | 
 |  |     public static String entranceUrlLocal = "http://127.0.0.1:10023/hcyy/";
 | 
												
													
														
															|  | 
 |  |     @Autowired
 | 
												
													
														
															|  | 
 |  |     public YlzMedicailRelationDao ylzMedicailRelationDao;
 | 
												
													
														
															|  | 
 |  |     @Autowired
 | 
												
													
														
															|  | 
 |  |     public YlzMedicailMxDao ylzMedicailMxDao;
 | 
												
													
														
															|  | 
 |  |     @Autowired
 | 
												
													
														
															|  | 
 |  |     public YlzMedicailIcdDao ylzMedicailIcdDao;
 | 
												
													
														
															|  | 
 |  |     @Autowired
 | 
												
													
														
															|  | 
 |  |     public BusinessOrderDao businessOrderDao;
 | 
												
													
														
															|  | 
 |  |     @Autowired
 | 
												
													
														
															|  | 
 |  |     public PrescriptionLogDao prescriptionLogDao;
 | 
												
													
														
															|  | 
 |  |     @Autowired
 | 
												
													
														
															|  | 
 |  |     public PrescriptionService prescriptionService;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
											
												
													
														
															|  | @ -191,12 +217,12 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
 | 
												
													
														
															|  |      * @param patient 居民id
 |  |      * @param patient 居民id
 | 
												
													
														
															|  |      * @return
 |  |      * @return
 | 
												
													
														
															|  |      */
 |  |      */
 | 
												
													
														
															|  |     public List<WlyyOutpatientVO> selectOutpatientList(String patient, String startTime, String endTime, String cardNo) throws Exception {
 |  | 
 | 
												
													
														
															|  | 
 |  |     public List<WlyyOutpatientVO> selectOutpatientList(String patient,String startTime, String endTime,String ksdm, String cardNo) throws Exception {
 | 
												
													
														
															|  |         List<WlyyOutpatientVO> wlyyOutpatientVOList = new ArrayList<>();
 |  |         List<WlyyOutpatientVO> wlyyOutpatientVOList = new ArrayList<>();
 | 
												
													
														
															|  |         JSONArray array = new JSONArray();
 |  |         JSONArray array = new JSONArray();
 | 
												
													
														
															|  |         String response="";
 |  |         String response="";
 | 
												
													
														
															|  |         patient = updatePatientMapping(patient,cardNo);
 |  |         patient = updatePatientMapping(patient,cardNo);
 | 
												
													
														
															|  |         String obj = hcyyEntranceService.findOutpatientInfo(patient,null,startTime,endTime);
 |  | 
 | 
												
													
														
															|  | 
 |  |         String obj = hcyyEntranceService.findOutpatientInfo(patient,null,ksdm,startTime,endTime);
 | 
												
													
														
															|  |         if (StringUtils.isNoneBlank(obj)){
 |  |         if (StringUtils.isNoneBlank(obj)){
 | 
												
													
														
															|  |             array = JSONArray.parseArray(obj).getJSONArray(0);
 |  |             array = JSONArray.parseArray(obj).getJSONArray(0);
 | 
												
													
														
															|  |             for (int i=0;i<array.size();i++){
 |  |             for (int i=0;i<array.size();i++){
 | 
												
											
												
													
														
															|  | @ -248,7 +274,7 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
 | 
												
													
														
															|  |             patient = savePatientMapping(patient);
 |  |             patient = savePatientMapping(patient);
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         if (StringUtils.isNoneBlank(patient)) {
 |  |         if (StringUtils.isNoneBlank(patient)) {
 | 
												
													
														
															|  |             String obj = hcyyEntranceService.findOutpatientInfo(patient, conNo, null, null);
 |  | 
 | 
												
													
														
															|  | 
 |  |             String obj = hcyyEntranceService.findOutpatientInfo(patient, conNo, null,null, null);
 | 
												
													
														
															|  |             if (StringUtils.isNoneBlank(obj)) {
 |  |             if (StringUtils.isNoneBlank(obj)) {
 | 
												
													
														
															|  |                 array = JSONArray.parseArray(obj).getJSONArray(0);
 |  |                 array = JSONArray.parseArray(obj).getJSONArray(0);
 | 
												
													
														
															|  |                 if (array != null && array.size() != 0) {
 |  |                 if (array != null && array.size() != 0) {
 | 
												
											
												
													
														
															|  | @ -743,7 +769,7 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
 | 
												
													
														
															|  |                 JSONArray array = JSONArray.parseArray(obj);
 |  |                 JSONArray array = JSONArray.parseArray(obj);
 | 
												
													
														
															|  |                 if (array!=null&&array.size()!=0){
 |  |                 if (array!=null&&array.size()!=0){
 | 
												
													
														
															|  |                     JSONObject jsonObject = array.getJSONObject(0);
 |  |                     JSONObject jsonObject = array.getJSONObject(0);
 | 
												
													
														
															|  |                     operatorId = jsonObject.getString("staffNo");
 |  | 
 | 
												
													
														
															|  | 
 |  |                     operatorId = jsonObject.getString("SUPER_ADD");
 | 
												
													
														
															|  |                 }
 |  |                 }
 | 
												
													
														
															|  |             }
 |  |             }
 | 
												
													
														
															|  |             if(null!=doctorMappingDO){
 |  |             if(null!=doctorMappingDO){
 | 
												
											
												
													
														
															|  | @ -766,15 +792,34 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
 | 
												
													
														
															|  |                 paramRequest.put("outpatientCode","R"+wlyyOutpatientDO.getRegisterNo());
 |  |                 paramRequest.put("outpatientCode","R"+wlyyOutpatientDO.getRegisterNo());
 | 
												
													
														
															|  |                 paramRequest.put("eventno","R"+wlyyOutpatientDO.getRegisterNo());
 |  |                 paramRequest.put("eventno","R"+wlyyOutpatientDO.getRegisterNo());
 | 
												
													
														
															|  |             }
 |  |             }
 | 
												
													
														
															|  |             paramRequest.put("templateid","1158");
 |  | 
 | 
												
													
														
															|  |             paramRequest.put("catalogid","50");
 |  | 
 | 
												
													
														
															|  | 
 |  |             paramRequest.put("templateid","2160");
 | 
												
													
														
															|  | 
 |  |             paramRequest.put("catalogid","74");
 | 
												
													
														
															|  |             paramRequest.put("emrtype","93");
 |  |             paramRequest.put("emrtype","93");
 | 
												
													
														
															|  |             paramRequest.put("emrtitle","互联网医院");
 |  |             paramRequest.put("emrtitle","互联网医院");
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |             if (StringUtils.isNoneBlank(baseSign)){
 |  |             if (StringUtils.isNoneBlank(baseSign)){
 | 
												
													
														
															|  | 
 |  |                 JSONObject object = hcyyEntranceService.getSignPicture(doctorDO.getId());
 | 
												
													
														
															|  | 
 |  |                 if (object!=null){
 | 
												
													
														
															|  | 
 |  |                     String code = object.getString("code");
 | 
												
													
														
															|  | 
 |  |                     if (code.equalsIgnoreCase("1000")){
 | 
												
													
														
															|  | 
 |  |                         String data = object.getString("data");
 | 
												
													
														
															|  | 
 |  |                         if (StringUtils.isNoneBlank(data)){
 | 
												
													
														
															|  | 
 |  |                             JSONObject re = JSONObject.parseObject(data);
 | 
												
													
														
															|  | 
 |  |                             String image = re.getString("image");
 | 
												
													
														
															|  | 
 |  |                             paramRequest.put("baseSign",image);
 | 
												
													
														
															|  | 
 |  |                         }else {
 | 
												
													
														
															|  | 
 |  |                             paramRequest.put("baseSign","");
 | 
												
													
														
															|  | 
 |  |                         }
 | 
												
													
														
															|  | 
 |  |                     }else {
 | 
												
													
														
															|  | 
 |  |                         paramRequest.put("baseSign","");
 | 
												
													
														
															|  | 
 |  |                     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |                 }else {
 | 
												
													
														
															|  | 
 |  |                     paramRequest.put("baseSign","");
 | 
												
													
														
															|  | 
 |  |                 }
 | 
												
													
														
															|  |                 //UploadVO uploadVO=fileUploadService.uploadImagesBase64(baseSign,fastdfs_file_url);
 |  |                 //UploadVO uploadVO=fileUploadService.uploadImagesBase64(baseSign,fastdfs_file_url);
 | 
												
													
														
															|  |                 //paramRequest.put("baseSign","https://ih.xmheart.com/fastdfs/"+uploadVO.getFullUri());
 |  |                 //paramRequest.put("baseSign","https://ih.xmheart.com/fastdfs/"+uploadVO.getFullUri());
 | 
												
													
														
															|  |                 paramRequest.put("baseSign",baseSign);
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |             }
 |  |             }
 | 
												
													
														
															|  |         }
 |  |         }
 | 
												
													
														
															|  |         params.put("jsonInfo",paramRequest.toJSONString());
 |  |         params.put("jsonInfo",paramRequest.toJSONString());
 | 
												
											
												
													
														
															|  | @ -1561,4 +1606,292 @@ public class HcyyPrescriptionService extends BaseJpaService<WlyyPrescriptionDO,
 | 
												
													
														
															|  |         optPatient+="</opt_prescription_item>";
 |  |         optPatient+="</opt_prescription_item>";
 | 
												
													
														
															|  |         return optPatient;
 |  |         return optPatient;
 | 
												
													
														
															|  |     }
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     public YlzMedicalRelationDO getSettlementInfo(String cardno,String outpatientId) throws Exception {
 | 
												
													
														
															|  | 
 |  |         YlzMedicalRelationDO ylzMedicalRelationDO =new YlzMedicalRelationDO();
 | 
												
													
														
															|  | 
 |  |         WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId);
 | 
												
													
														
															|  | 
 |  |         String resNo = outpatientDO.getRegisterNo();
 | 
												
													
														
															|  | 
 |  |         //请求his获取待结算存储
 | 
												
													
														
															|  | 
 |  |         Map<String,Object> params = new HashedMap();
 | 
												
													
														
															|  | 
 |  |         String url =entranceUrlLocal +"getSettleMent";
 | 
												
													
														
															|  | 
 |  |         params.put("mct","03");
 | 
												
													
														
															|  | 
 |  |         params.put("mcn",cardno);
 | 
												
													
														
															|  | 
 |  |         HttpResponse response = HttpUtils.doGet(url,params);
 | 
												
													
														
															|  | 
 |  |         //获取his结算基本信息表
 | 
												
													
														
															|  | 
 |  |         String basicSql ="select * from SST_JSDP_JBXX_GJYB where CARD_NO ='"+cardno+"'";
 | 
												
													
														
															|  | 
 |  |         String res = hcyyEntranceService.getSql(basicSql);
 | 
												
													
														
															|  | 
 |  |         if (StringUtils.isNoneBlank(res)){
 | 
												
													
														
															|  | 
 |  |             JSONObject rs = JSONObject.parseObject(res);
 | 
												
													
														
															|  | 
 |  |             Integer status = rs.getInteger("status");
 | 
												
													
														
															|  | 
 |  |             if(status!=null&&status == 200){
 | 
												
													
														
															|  | 
 |  |                 JSONArray array = rs.getJSONArray("detailModelList");
 | 
												
													
														
															|  | 
 |  |                 for (int i=0;i<array.size();i++){
 | 
												
													
														
															|  | 
 |  |                     JSONObject object = array.getJSONObject(i);
 | 
												
													
														
															|  | 
 |  |                     String logNo = object.getString("LOG_NO");
 | 
												
													
														
															|  | 
 |  |                     String registerNo = object.getString("IPT_OTP_NO");
 | 
												
													
														
															|  | 
 |  |                     logger.info("logNo=="+logNo +"registerNo=="+registerNo);
 | 
												
													
														
															|  | 
 |  |                     if (registerNo.equalsIgnoreCase(resNo)){
 | 
												
													
														
															|  | 
 |  |                         logger.info("logNo=="+logNo +"registerNo=="+registerNo);
 | 
												
													
														
															|  | 
 |  |                         ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
 | 
												
													
														
															|  | 
 |  |                         if (ylzMedicalRelationDO==null){
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO = new YlzMedicalRelationDO();
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setLogNo(logNo);
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setRelationCode(outpatientId);
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setName(object.getString("PSN_NAME"));
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setTotalAmount(object.getString("COST"));
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setPersonCash(object.getString("ORIGIN_CHARGES"));
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setHisSerial(object.getString("RESIDENCE_NO"));
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setHisBillSerial(object.getString("SETTLE_NO"));
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setDeptCode(object.getString("DEPT_CODE"));
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setDeptName(object.getString("DEPT_NAME"));
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setHisDeptCode(object.getString("DEPT_CODE"));
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setHisDeptName(object.getString("DEPT_NAME"));
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setStatus(0);
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setState(0);
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setPersonAccount("0");
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setMedicalPrice("0");
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setHisSettleNo(object.getString("IPT_OTP_NO"));
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setCardNo(object.getString("CARD_NO"));
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setDate(DateUtil.strToDate(object.getString("BEGNTIME")));
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setBcwkje(object.getString("MEDFEE_SUMAMT"));
 | 
												
													
														
															|  | 
 |  |                         }else {
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setLogNo(logNo);
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setRelationCode(outpatientId);
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setName(object.getString("PSN_NAME"));
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setTotalAmount(object.getString("COST"));
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setPersonCash(object.getString("ORIGIN_CHARGES"));
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setHisSerial(object.getString("RESIDENCE_NO"));
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setHisBillSerial(object.getString("SETTLE_NO"));
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setDeptCode(object.getString("DEPT_CODE"));
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setDeptName(object.getString("DEPT_NAME"));
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setHisDeptCode(object.getString("DEPT_CODE"));
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setHisDeptName(object.getString("DEPT_NAME"));
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setPersonAccount("0");
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setMedicalPrice("0");
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setHisSettleNo(object.getString("IPT_OTP_NO"));
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setCardNo(object.getString("CARD_NO"));
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setDate(DateUtil.strToDate(object.getString("BEGNTIME")));
 | 
												
													
														
															|  | 
 |  |                             ylzMedicalRelationDO.setBcwkje(object.getString("MEDFEE_SUMAMT"));
 | 
												
													
														
															|  | 
 |  |                         }
 | 
												
													
														
															|  | 
 |  |                         ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
 | 
												
													
														
															|  | 
 |  |                         ylzMedicailMxDao.deleteByMedicalId(ylzMedicalRelationDO.getId());
 | 
												
													
														
															|  | 
 |  |                         //获取结算明细
 | 
												
													
														
															|  | 
 |  |                         String detailSql =" select * from SST_JSDP_JSMX_GJYB where LOG_NO ='"+logNo+"' ";
 | 
												
													
														
															|  | 
 |  |                         String detailRes = hcyyEntranceService.getSql(detailSql);
 | 
												
													
														
															|  | 
 |  |                         List<YlzMedicalMxDO> mxDOList = new ArrayList<>();
 | 
												
													
														
															|  | 
 |  |                         if (StringUtils.isNoneBlank(detailRes)) {
 | 
												
													
														
															|  | 
 |  |                             JSONObject drs = JSONObject.parseObject(detailRes);
 | 
												
													
														
															|  | 
 |  |                             Integer dstatus = drs.getInteger("status");
 | 
												
													
														
															|  | 
 |  |                             if (dstatus != null && dstatus == 200) {
 | 
												
													
														
															|  | 
 |  |                                 JSONArray darray = drs.getJSONArray("detailModelList");
 | 
												
													
														
															|  | 
 |  |                                 for (int j = 0; j < darray.size(); j++) {
 | 
												
													
														
															|  | 
 |  |                                     JSONObject dobject = darray.getJSONObject(j);
 | 
												
													
														
															|  | 
 |  |                                     YlzMedicalMxDO medicalMxDO = new YlzMedicalMxDO();
 | 
												
													
														
															|  | 
 |  |                                     medicalMxDO.setDel(1);
 | 
												
													
														
															|  | 
 |  |                                     medicalMxDO.setCreateTime(new Date());
 | 
												
													
														
															|  | 
 |  |                                     medicalMxDO.setItemName(dobject.getString("XMMC00"));
 | 
												
													
														
															|  | 
 |  |                                     medicalMxDO.setHisDetailSn(dobject.getString("FEEDETL_SN"));
 | 
												
													
														
															|  | 
 |  |                                     medicalMxDO.setItemCode(dobject.getString("MED_LIST_CODG"));
 | 
												
													
														
															|  | 
 |  |                                     medicalMxDO.setPrescriptionCode(dobject.getString(""));
 | 
												
													
														
															|  | 
 |  |                                     medicalMxDO.setChargeUnit(dobject.getString("PRCUNT"));
 | 
												
													
														
															|  | 
 |  |                                     medicalMxDO.setSpecificationType(dobject.getString(""));
 | 
												
													
														
															|  | 
 |  |                                     medicalMxDO.setAmount(dobject.getString("CNT"));
 | 
												
													
														
															|  | 
 |  |                                     medicalMxDO.setPrice(dobject.getString("PRIC"));
 | 
												
													
														
															|  | 
 |  |                                     medicalMxDO.setSingleDose(dobject.getString("SIN_DOS_DSCR"));
 | 
												
													
														
															|  | 
 |  |                                     medicalMxDO.setUseFrequency(dobject.getString("USED_FRQU_DSCR"));
 | 
												
													
														
															|  | 
 |  |                                     medicalMxDO.setMedicationDays(dobject.getString("PRD_DAYS"));
 | 
												
													
														
															|  | 
 |  |                                     medicalMxDO.setMedicalWay(dobject.getString("MEDC_WAY_DSCR"));
 | 
												
													
														
															|  | 
 |  |                                     medicalMxDO.setDeptCode(dobject.getString("BILG_DEPT_CODG"));
 | 
												
													
														
															|  | 
 |  |                                     medicalMxDO.setDeptName(dobject.getString("BILG_DEPT_NAME"));
 | 
												
													
														
															|  | 
 |  |                                     medicalMxDO.setHisDeptCode(dobject.getString("BILG_DEPT_CODG"));
 | 
												
													
														
															|  | 
 |  |                                     medicalMxDO.setHisDeptName(dobject.getString("BILG_DEPT_NAME"));
 | 
												
													
														
															|  | 
 |  |                                     medicalMxDO.setMedicalPerId(dobject.getString("BILG_DR_CODG"));
 | 
												
													
														
															|  | 
 |  |                                     medicalMxDO.setMedicalPerName(dobject.getString("BILG_DR_NAME"));
 | 
												
													
														
															|  | 
 |  |                                     medicalMxDO.setLimitType(dobject.getString("HOSP_APPR_FLAG"));
 | 
												
													
														
															|  | 
 |  |                                     medicalMxDO.setHisItemCode(dobject.getString("MED_LIST_CODG"));
 | 
												
													
														
															|  | 
 |  |                                     medicalMxDO.setHisItemName(dobject.getString("XMMC00"));
 | 
												
													
														
															|  | 
 |  |                                     medicalMxDO.setTotalMoney(dobject.getString("DET_ITEM_FEE_SUMAMT"));
 | 
												
													
														
															|  | 
 |  |                                     medicalMxDO = ylzMedicailMxDao.save(medicalMxDO);
 | 
												
													
														
															|  | 
 |  |                                     mxDOList.add(medicalMxDO);
 | 
												
													
														
															|  | 
 |  |                                 }
 | 
												
													
														
															|  | 
 |  |                             }
 | 
												
													
														
															|  | 
 |  |                         }
 | 
												
													
														
															|  | 
 |  |                         ylzMedicalRelationDO.setYlzMedicalMxDOList(mxDOList);
 | 
												
													
														
															|  | 
 |  |                         List<YlzMedicalIcdDO> icdDOS = new ArrayList<>();
 | 
												
													
														
															|  | 
 |  |                         ylzMedicailIcdDao.deleteByMedicalId(ylzMedicalRelationDO.getId());
 | 
												
													
														
															|  | 
 |  |                         //获取诊断
 | 
												
													
														
															|  | 
 |  |                         String icdSql =" select * from SST_JSDP_JSMX_GJYB where LOG_NO ='"+logNo+"' ";
 | 
												
													
														
															|  | 
 |  |                         String icdRes = hcyyEntranceService.getSql(icdSql);
 | 
												
													
														
															|  | 
 |  |                         if (StringUtils.isNoneBlank(icdRes)) {
 | 
												
													
														
															|  | 
 |  |                             JSONObject drs = JSONObject.parseObject(icdRes);
 | 
												
													
														
															|  | 
 |  |                             Integer dstatus = drs.getInteger("status");
 | 
												
													
														
															|  | 
 |  |                             if (dstatus != null && dstatus == 200) {
 | 
												
													
														
															|  | 
 |  |                                 JSONArray darray = drs.getJSONArray("detailModelList");
 | 
												
													
														
															|  | 
 |  |                                 for (int j = 0; j < darray.size(); j++) {
 | 
												
													
														
															|  | 
 |  |                                     JSONObject dobject = darray.getJSONObject(j);
 | 
												
													
														
															|  | 
 |  |                                     YlzMedicalIcdDO icdDO = new YlzMedicalIcdDO();
 | 
												
													
														
															|  | 
 |  |                                     icdDO.setCreateTime(new Date());
 | 
												
													
														
															|  | 
 |  |                                     icdDO.setDel(1);
 | 
												
													
														
															|  | 
 |  |                                     icdDO.setDiseaseCodeIcd10(dobject.getString("DIAG_CODE"));
 | 
												
													
														
															|  | 
 |  |                                     icdDO.setDiseaseNameIcd10(dobject.getString("DIAG_NAME"));
 | 
												
													
														
															|  | 
 |  |                                     icdDO.setDiseaseType(dobject.getString("DIAG_TYPE"));
 | 
												
													
														
															|  | 
 |  |                                     icdDO.setDiseaseOrder(dobject.getString("DIAG_SRT_NO"));
 | 
												
													
														
															|  | 
 |  |                                     icdDO.setMedicalId(ylzMedicalRelationDO.getId());
 | 
												
													
														
															|  | 
 |  |                                     icdDO = ylzMedicailIcdDao.save(icdDO);
 | 
												
													
														
															|  | 
 |  |                                     icdDOS.add(icdDO);
 | 
												
													
														
															|  | 
 |  |                                 }
 | 
												
													
														
															|  | 
 |  |                             }
 | 
												
													
														
															|  | 
 |  |                         }
 | 
												
													
														
															|  | 
 |  |                         ylzMedicalRelationDO.setYlzMedicalIcdDOList(icdDOS);
 | 
												
													
														
															|  | 
 |  |                     }
 | 
												
													
														
															|  | 
 |  |                 }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         return  ylzMedicalRelationDO;
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     public String confirmSettlement(String outpatientId) throws Exception {
 | 
												
													
														
															|  | 
 |  |         try {
 | 
												
													
														
															|  | 
 |  |             WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId);
 | 
												
													
														
															|  | 
 |  |             if (outpatientDO==null){
 | 
												
													
														
															|  | 
 |  |                 throw new Exception("未找到待结算记录");
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |             YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findByOutpatient(outpatientId);
 | 
												
													
														
															|  | 
 |  |             if (ylzMedicalRelationDO.getState()==1){
 | 
												
													
														
															|  | 
 |  |                 return "已结算";
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |             BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(ylzMedicalRelationDO.getId());
 | 
												
													
														
															|  | 
 |  |             ylzMedicalRelationDO.setState(1);
 | 
												
													
														
															|  | 
 |  |             ylzMedicalRelationDO.setSettleDate(new Date());
 | 
												
													
														
															|  | 
 |  |             ylzMedicalRelationDO = ylzMedicailRelationDao.save(ylzMedicalRelationDO);
 | 
												
													
														
															|  | 
 |  |             String sql = "update SST_JSDP_JBXX_GJYB\n" +
 | 
												
													
														
															|  | 
 |  |                     "   set SETL_ID           = '', \n" +
 | 
												
													
														
															|  | 
 |  |                     "       ACCT_PAY          = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       PSN_CASH_PAY      = '"+ylzMedicalRelationDO.getTotalAmount()+"',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       FUND_PAY_SUMAMT   = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       CVLSERV_PAY       = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       PSN_PART_AMT      = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       HIFMI_PAY         = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       MEDFEE_SUMAMT     = '"+ylzMedicalRelationDO.getBcwkje()+"',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       SETL_TIME         = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       BALC              = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       ACCT_MULAID_PAY   = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       HIFOB_PAY         = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       MDTRT_ID          = '',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       HIFP_PAY          = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       MAF_PAY           = '',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       OTH_PAY           = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       HIFES_PAY         = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       OUTCHARGENO       = '"+businessOrderDO.getOrderNo()+"',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       PSN_CERT_TYPE     = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       NATY              = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       BRDY              = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       CVLSERV_FLAG      = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       ACT_PAY_DEDC      = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       PSN_TYPE          = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       HOSP_PART_AMT     = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       CLR_OPTINS        = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       CLR_WAY           = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       CLR_TYPE          = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       POOL_PROP_SELFPAY = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       INSUPLC_ADMDVS    = '',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       INSUTYPE          = '',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       PSN_NO            = '',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       CHANNEL_TYPE      = '',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       ACSIGN_TYPE       = 'null',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       MDTRT_CERT_TYPE   = '03',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       CVL_ACCT_PAY      = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       CVL_ACCT_BALC     = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       HL_ACCT_PAY       = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       HL_ACCT_BALC      = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       FM_ACCT_BALC      = '0',\n" +
 | 
												
													
														
															|  | 
 |  |                     "       PUR_ACCT_PAY      = '0'\n" +
 | 
												
													
														
															|  | 
 |  |                     " where 1 = 1\n" +
 | 
												
													
														
															|  | 
 |  |                     "   and LOG_NO = '"+ylzMedicalRelationDO.getLogNo()+"'";
 | 
												
													
														
															|  | 
 |  |             //结算更新
 | 
												
													
														
															|  | 
 |  |             System.out.println("sql=="+sql);
 | 
												
													
														
															|  | 
 |  |             String res = hcyyEntranceService.updateUrl(sql);
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |             Map<String,Object> params = new HashedMap();
 | 
												
													
														
															|  | 
 |  |             String url =entranceUrlLocal +"comfirmSettleMent";
 | 
												
													
														
															|  | 
 |  |             params.put("mct","03");
 | 
												
													
														
															|  | 
 |  |             params.put("mcn",ylzMedicalRelationDO.getCardNo());
 | 
												
													
														
															|  | 
 |  |             params.put("xtgzh0",ylzMedicalRelationDO.getLogNo());
 | 
												
													
														
															|  | 
 |  |             HttpResponse response = HttpUtils.doGet(url,params);
 | 
												
													
														
															|  | 
 |  |             System.out.println("response=="+response.getContent());
 | 
												
													
														
															|  | 
 |  |             List<WlyyPrescriptionDO> wlyyPrescriptionDOS = prescriptionDao.findByOutPatientIdList(ylzMedicalRelationDO.getRelationCode());
 | 
												
													
														
															|  | 
 |  |             /*String */
 | 
												
													
														
															|  | 
 |  |             String realOrder = "";
 | 
												
													
														
															|  | 
 |  |             for (WlyyPrescriptionDO prescriptionDO:wlyyPrescriptionDOS){
 | 
												
													
														
															|  | 
 |  |                 if (prescriptionDO.getStatus()==20){
 | 
												
													
														
															|  | 
 |  |                     WlyyPrescriptionLogDO prescriptionLogDO = new WlyyPrescriptionLogDO();
 | 
												
													
														
															|  | 
 |  |                     prescriptionLogDO.setCreateTime(new Date());
 | 
												
													
														
															|  | 
 |  |                     prescriptionLogDO.setStatus(30);
 | 
												
													
														
															|  | 
 |  |                     prescriptionLogDO.setOutpatientId(prescriptionDO.getOutpatientId());
 | 
												
													
														
															|  | 
 |  |                     prescriptionLogDO.setPrescriptionCode(prescriptionDO.getId());
 | 
												
													
														
															|  | 
 |  |                     prescriptionLogDO.setUserCode(prescriptionDO.getPatientCode());
 | 
												
													
														
															|  | 
 |  |                     prescriptionLogDO.setUserName(prescriptionDO.getPatientName());
 | 
												
													
														
															|  | 
 |  |                     prescriptionLogDO.setUserType(1);
 | 
												
													
														
															|  | 
 |  |                     prescriptionLogDO.setDatajson("处方结算");
 | 
												
													
														
															|  | 
 |  |                     prescriptionLogDao.save(prescriptionLogDO);
 | 
												
													
														
															|  | 
 |  |                     prescriptionDO.setStatus(30);
 | 
												
													
														
															|  | 
 |  |                     prescriptionDO.setPayTime(new Date());
 | 
												
													
														
															|  | 
 |  |                     prescriptionDao.save(prescriptionDO);
 | 
												
													
														
															|  | 
 |  |                     logger.info("变更处方结算状态成功");
 | 
												
													
														
															|  | 
 |  |                     realOrder = prescriptionDO.getRealOrder();
 | 
												
													
														
															|  | 
 |  |                 }
 | 
												
													
														
															|  | 
 |  |                 try {
 | 
												
													
														
															|  | 
 |  |                     sfToHis(outpatientId, realOrder);
 | 
												
													
														
															|  | 
 |  |                 }catch (Exception e){
 | 
												
													
														
															|  | 
 |  |                     e.printStackTrace();
 | 
												
													
														
															|  | 
 |  |                 }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |             return "结算成功!";
 | 
												
													
														
															|  | 
 |  |         }catch (Exception e){
 | 
												
													
														
															|  | 
 |  |             e.printStackTrace();
 | 
												
													
														
															|  | 
 |  |             return "结算失败";
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     /**
 | 
												
													
														
															|  | 
 |  |      * 顺丰下订单后同步his
 | 
												
													
														
															|  | 
 |  |      * @param outpatientId
 | 
												
													
														
															|  | 
 |  |      * @param realorder
 | 
												
													
														
															|  | 
 |  |      * @return
 | 
												
													
														
															|  | 
 |  |      * @throws Exception
 | 
												
													
														
															|  | 
 |  |      */
 | 
												
													
														
															|  | 
 |  |     public String sfToHis(String outpatientId,String realorder) throws Exception {
 | 
												
													
														
															|  | 
 |  |         WlyyOutpatientDO outpatientDO = outpatientDao.findById(outpatientId);
 | 
												
													
														
															|  | 
 |  |         String registerNo = outpatientDO.getRegisterNo();
 | 
												
													
														
															|  | 
 |  |         List<WlyyPrescriptionExpressageDO> prescriptionExpressageDOS = prescriptionExpressageDao.findByOutpatientId(outpatientId);
 | 
												
													
														
															|  | 
 |  |         WlyyPrescriptionExpressageDO expressageDO = new WlyyPrescriptionExpressageDO();
 | 
												
													
														
															|  | 
 |  |         if (prescriptionExpressageDOS!=null&&prescriptionExpressageDOS.size()!=0){
 | 
												
													
														
															|  | 
 |  |             expressageDO = prescriptionExpressageDOS.get(0);
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         if (expressageDO!=null){
 | 
												
													
														
															|  | 
 |  |             if (expressageDO.getOneselfPickupFlg()==0){
 | 
												
													
														
															|  | 
 |  |                 Object result=prescriptionService.getSFExpressInfoNew(registerNo,realorder,"");
 | 
												
													
														
															|  | 
 |  |                 String re = result.toString();
 | 
												
													
														
															|  | 
 |  |                 if (re!=null){
 | 
												
													
														
															|  | 
 |  |                     JSONObject object = JSONObject.parseObject(re);
 | 
												
													
														
															|  | 
 |  |                     String sfOrder = object.getString("mainMailNo");
 | 
												
													
														
															|  | 
 |  |                     String address = expressageDO.getProvinceName()+expressageDO.getCityName()+expressageDO.getTownName()+expressageDO.getStreetName()+expressageDO.getAddress();
 | 
												
													
														
															|  | 
 |  |                     String phone = expressageDO.getMobile();
 | 
												
													
														
															|  | 
 |  |                     String remark = expressageDO.getRemark();
 | 
												
													
														
															|  | 
 |  |                     String cardNo = outpatientDO.getCardNo();
 | 
												
													
														
															|  | 
 |  |                     return  hcyyEntranceService.updateSftoHis(registerNo,cardNo,sfOrder,address,phone,remark);
 | 
												
													
														
															|  | 
 |  |                 }else {
 | 
												
													
														
															|  | 
 |  |                     return null;
 | 
												
													
														
															|  | 
 |  |                 }
 | 
												
													
														
															|  | 
 |  |             }else {
 | 
												
													
														
															|  | 
 |  |                 return null;
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         return null;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | }
 |  | }
 |