|
@ -15,12 +15,20 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
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.healthCare.YlzMedicalRelationInvoiceDO;
|
|
|
import com.yihu.jw.entity.hospital.httplog.WlyyHttpLogDO;
|
|
|
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.WlyyChargeDictDao;
|
|
|
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.healthCare.YlzMedicailRelationInvoiceDao;
|
|
|
import com.yihu.jw.hospital.httplog.dao.WlyyHttpLogDao;
|
|
|
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
|
|
|
import com.yihu.jw.hospital.mapping.dao.PatientMappingDao;
|
|
@ -42,6 +50,7 @@ import com.yihu.jw.utils.dsyyUtil.ZoesoftHipServiceLocator;
|
|
|
import com.yihu.jw.utils.hibernate.HibenateUtils;
|
|
|
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
|
|
|
import net.sf.json.xml.XMLSerializer;
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
@ -57,6 +66,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import java.io.BufferedReader;
|
|
|
import java.io.InputStream;
|
|
|
import java.io.InputStreamReader;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
@ -128,6 +138,14 @@ public class DsyyEntranceService {
|
|
|
private HibenateUtils hibenateUtils;
|
|
|
@Autowired
|
|
|
private OauthCaConfigDao oauthCaConfigDao;
|
|
|
@Autowired
|
|
|
private YlzMedicailIcdDao ylzMedicailIcdDao;
|
|
|
@Autowired
|
|
|
private YlzMedicailMxDao ylzMedicailMxDao;
|
|
|
@Autowired
|
|
|
private YlzMedicailRelationInvoiceDao invoiceDao;
|
|
|
@Autowired
|
|
|
private YlzMedicailRelationDao ylzMedicailRelationDao;
|
|
|
|
|
|
private static String key="bvvsf3JA0mUXMU+mVnMaOQ==";
|
|
|
|
|
@ -2638,4 +2656,215 @@ public class DsyyEntranceService {
|
|
|
|
|
|
|
|
|
//===========================CA签名==================================
|
|
|
|
|
|
//============================电子发票开始====================================
|
|
|
String dsfp = "http://10.95.8.94:20017/service/invoice/perform";
|
|
|
String appId ="862e18c18c5e4d72";
|
|
|
String appKey ="d756d7778c43e3c5b8bbcb301c48fe25";
|
|
|
String msgNo ="8901";
|
|
|
String organ = "401039";
|
|
|
String user = "hisbizadmin";
|
|
|
public String getAccessToken() throws Exception {
|
|
|
String msg = "<Voucher>\n" +
|
|
|
"<AppId>"+appId+"</AppId>\n" +
|
|
|
"<AppKey>"+appKey+"</AppKey>\n" +
|
|
|
"</Voucher>";
|
|
|
String randomStr = System.currentTimeMillis()+(int)(Math.random()*900)+100+"";
|
|
|
String params ="<?xml version='1.0' encoding='UTF-8'?>\n" +
|
|
|
"<Invoice>\n" +
|
|
|
"<Head>\n" +
|
|
|
"<MsgNo>"+msgNo+"</MsgNo>\n" +
|
|
|
"<Organ>"+organ+"</Organ>\n" +
|
|
|
"<User>"+user+"</User>\n" +
|
|
|
"<Version>1.0</Version>\n" +
|
|
|
"<AppId>"+appId+"</AppId>\n" +
|
|
|
"<MsgId>5676"+randomStr+"</MsgId>\n" +
|
|
|
"<MsgRef>5676"+randomStr+"</MsgRef>\n" +
|
|
|
"<DateTime>"+new Date().getTime()+"</DateTime>\n" +
|
|
|
"<Reserve></Reserve>\n" +
|
|
|
"</Head>\n" +
|
|
|
"<Msg>"+ Base64.encodeBase64String(msg.getBytes("utf-8"))+"</Msg>\n" +
|
|
|
"</Invoice>";
|
|
|
logger.info("请求前入参:"+params);
|
|
|
String result = httpClientUtil.sendPost(dsfp,params);
|
|
|
logger.info("请求结果:"+result);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 电子票据开具
|
|
|
* @param ylzMedicalRelationDO
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public String dsfpkj(String id) throws Exception {
|
|
|
YlzMedicalRelationDO ylzMedicalRelationDO = ylzMedicailRelationDao.findById(id).get();
|
|
|
WlyyOutpatientDO outpatientDO = outpatientDao.findById(ylzMedicalRelationDO.getRelationCode()).get();
|
|
|
BasePatientDO patientDO = basePatientDao.findById(outpatientDO.getPatient()).get();
|
|
|
PatientMappingDO patientMappingDO = patientMappingDao.findByPatient(patientDO.getId());
|
|
|
String diseases = " <DiseaseDetails>";
|
|
|
List<YlzMedicalIcdDO> icdDOS = ylzMedicailIcdDao.findByMedicalId(ylzMedicalRelationDO.getId());
|
|
|
for (int i=0;i<icdDOS.size();i++){
|
|
|
YlzMedicalIcdDO icdDO = icdDOS.get(0);
|
|
|
diseases +="<DiseaseItem>" +
|
|
|
"<DiseaseCode>"+icdDO.getDiseaseCodeIcd10()+"</DiseaseCode>" +
|
|
|
"<DiseaseName>"+icdDO.getDiseaseNameIcd10()+"</DiseaseName>" +
|
|
|
"<DiseaseFlag>"+(i+1)+"</DiseaseFlag>" +
|
|
|
"</DiseaseItem>" ;
|
|
|
}
|
|
|
diseases+="</DiseaseDetails>";
|
|
|
|
|
|
String mxInfos = "<Details>";
|
|
|
List<YlzMedicalMxDO> mxDOList = ylzMedicailMxDao.findByMedicalId(ylzMedicalRelationDO.getId());
|
|
|
for (YlzMedicalMxDO mxDO:mxDOList){
|
|
|
mxInfos +="<Item>\n" +
|
|
|
"<ItemCode>"+mxDO.getItemCode()+"</ItemCode>\n" +
|
|
|
"<ItemName>"+mxDO.getItemName()+"</ItemName>\n" +
|
|
|
"<ItemAmount>"+mxDO.getTotalMoney()+"</ItemAmount>\n" +
|
|
|
"<ItemQuantity>"+mxDO.getAmount()+"</ItemQuantity>\n" +
|
|
|
"<ItemStd>1.00</ItemStd>\n" +
|
|
|
"<InsuranceItemCode>"+mxDO.getHisItemCode()+"</InsuranceItemCode>\n" +
|
|
|
"</Item>\n" ;
|
|
|
}
|
|
|
mxInfos += "</Details>";
|
|
|
String msg = "<Voucher>\n" +
|
|
|
"<Main>\n" +
|
|
|
"<RandomNumber>123456</RandomNumber>\n" +
|
|
|
"<TotalAmount>"+ylzMedicalRelationDO.getTotalAmount()+"</TotalAmount>\n" +
|
|
|
"<IssueDate>"+DateUtil.dateToStrFormatShort(ylzMedicalRelationDO.getSettleDate())+"</IssueDate>\n" +
|
|
|
"<IssueTime>"+DateUtil.getTimeShort(ylzMedicalRelationDO.getSettleDate())+"</IssueTime>\n" +
|
|
|
"<InvoicingParty>\n" +
|
|
|
"<InvoicingPartyCode>401039</InvoicingPartyCode>\n" +
|
|
|
"<InvoicingPartyName>厦门市第三医院</InvoicingPartyName>\n" +
|
|
|
"</InvoicingParty>\n" +
|
|
|
"<PayerPartyType>1</PayerPartyType>\n" +
|
|
|
"<PayMode></PayMode>\n" +
|
|
|
"<BizCode>2020071922123</BizCode>\n" +
|
|
|
"<HandlingPerson>陈少娟</HandlingPerson>\n" +
|
|
|
"<MainExt>\n" +
|
|
|
"<MedicalType>门诊</MedicalType>\n" +
|
|
|
"<PatientNumber>"+ylzMedicalRelationDO.getHisSerial()+"</PatientNumber>\n" +
|
|
|
"<OrgType>三级乙等</OrgType>\n" +
|
|
|
"<MedicalInsuranceType>医保类型</MedicalInsuranceType>\n" +
|
|
|
"<MedicalInsuranceID>"+ylzMedicalRelationDO.getInsuranceSerial()+"</MedicalInsuranceID>\n" +
|
|
|
"<FundPayAmount>"+ylzMedicalRelationDO.getFundPrice()+"</FundPayAmount>\n" +
|
|
|
"<OtherPayAmount>"+ylzMedicalRelationDO.getOtherPay()+"</OtherPayAmount>\n" +
|
|
|
"<AccountPayAmount>"+ylzMedicalRelationDO.getPersonAccount()+"</AccountPayAmount>\n" +
|
|
|
"<OwnPayAmount>"+ylzMedicalRelationDO.getPersonCash()+"</OwnPayAmount>\n" +
|
|
|
"<SelfpaymentAmount>"+ylzMedicalRelationDO.getPersonCash()+"</SelfpaymentAmount>\n" +
|
|
|
"<CaseNumber>无</CaseNumber>\n" +
|
|
|
"<PrepaidAmount>"+ylzMedicalRelationDO.getBalance()+"</PrepaidAmount>\n" +
|
|
|
"<RechargeAmount>8</RechargeAmount>\n" +
|
|
|
"<RefundAmount>0</RefundAmount>\n" +
|
|
|
"<Age>"+patientDO.getAge()+"</Age>\n" +
|
|
|
"<InsuranceSettleNo>"+ylzMedicalRelationDO.getInsuranceSerial()+"</InsuranceSettleNo>\n" +
|
|
|
"<VisitDeptName>"+ylzMedicalRelationDO.getDeptName()+"</VisitDeptName>\n" +
|
|
|
"<VisitDeptCode>"+ylzMedicalRelationDO.getDeptCode()+"</VisitDeptCode>\n" +
|
|
|
"<MedicalAccountPayment>"+ylzMedicalRelationDO.getPersonAccount()+"</MedicalAccountPayment>\n" +
|
|
|
"<HealthAccountPay>"+ylzMedicalRelationDO.getPersonAccount()+"</HealthAccountPay>\n" +
|
|
|
"<MasonicAccountPay>"+ylzMedicalRelationDO.getJtgjPay()+"</MasonicAccountPay>\n" +
|
|
|
"<MedicalAccountBalance>"+ylzMedicalRelationDO.getAccountBalance()+"</MedicalAccountBalance>\n" +
|
|
|
"<HealthAccountBalance>0</HealthAccountBalance>\n" +
|
|
|
"<MedicalAssistance>"+ylzMedicalRelationDO.getYljzPay()+"</MedicalAssistance>\n" +
|
|
|
"<IllnessInsure>0</IllnessInsure>\n" +
|
|
|
"<HealthCareFund>"+ylzMedicalRelationDO.getOtherPay()+"</HealthCareFund>\n" +
|
|
|
"<CivilServantSubsidy>"+ylzMedicalRelationDO.getGwyPay()+"</CivilServantSubsidy>\n" +
|
|
|
"<HospitalRelief>0</HospitalRelief>\n" +
|
|
|
"<RefundableAmount>0</RefundableAmount>\n" +
|
|
|
"<OverCapPay>0</OverCapPay>\n" +
|
|
|
"<PrepaidBalance>"+ylzMedicalRelationDO.getBalance()+"</PrepaidBalance>\n" +
|
|
|
"<TimesOfMonth>0</TimesOfMonth>\n" +
|
|
|
"<MedicalDate>"+DateUtil.dateToStrFormatShort(ylzMedicalRelationDO.getDate())+"</MedicalDate>\n" +
|
|
|
"<FamilyMasonicAccountBalance>0</FamilyMasonicAccountBalance> " +
|
|
|
"<PreSelfPay>0</PreSelfPay>\n" +
|
|
|
"<SelfpaymentCost>"+ylzMedicalRelationDO.getPersonCash()+"</SelfpaymentCost>\n" +
|
|
|
"<UploadSource>2</UploadSource>\n" +
|
|
|
"<VisitType>1</VisitType>\n" +
|
|
|
"<SettlementNo>"+ylzMedicalRelationDO.getHisSettleNo()+"</SettlementNo>\n" +
|
|
|
"<SickName>"+ylzMedicalRelationDO.getName()+"</SickName>\n" +
|
|
|
"<WorkInjuredPay>0</WorkInjuredPay>\n" +
|
|
|
diseases+
|
|
|
"<SickId>"+patientMappingDO.getMappingCode()+"</SickId>" +
|
|
|
"<CardInfos>\n" +
|
|
|
"<CardInfo>\n" +
|
|
|
"<CardType>4</CardType>\n" +
|
|
|
"</CardInfo>\n" +
|
|
|
"</CardInfos>\n" +
|
|
|
"</PayerPartyExt>\n" +
|
|
|
"<AccountBalanceInfo>"+ylzMedicalRelationDO.getAccountBalance()+"</AccountBalanceInfo>\n" +
|
|
|
"<CardNum>"+outpatientDO.getCardNo()+"</CardNum>\n" +
|
|
|
"<MedicareDist></MedicareDist>\n" +
|
|
|
"</MainExt>\n" +
|
|
|
"</Main>\n" +
|
|
|
mxInfos+
|
|
|
"</Voucher>";
|
|
|
|
|
|
|
|
|
String randomStr = System.currentTimeMillis()+(int)(Math.random()*900)+100+"";
|
|
|
String params ="<?xml version='1.0' encoding='UTF-8'?>\n" +
|
|
|
"<Invoice>\n" +
|
|
|
"<Head>\n" +
|
|
|
"<MsgNo>"+msgNo+"</MsgNo>\n" +
|
|
|
"<Organ>"+organ+"</Organ>\n" +
|
|
|
"<User>"+user+"</User>\n" +
|
|
|
"<Version>1.0</Version>\n" +
|
|
|
"<AppId>"+appId+"</AppId>\n" +
|
|
|
"<AccessToken>aaaabbbbb11111333333</AccessToken>"+
|
|
|
"<AppId>862e18c18c5e4d72</AppId>\n" +
|
|
|
"<MsgId>5676"+randomStr+"</MsgId>\n" +
|
|
|
"<MsgRef>5676"+randomStr+"</MsgRef>\n" +
|
|
|
"<DateTime>"+new Date().getTime()+"</DateTime>\n" +
|
|
|
"<Reserve></Reserve>\n" +
|
|
|
"</Head>\n" +
|
|
|
"<Msg>"+ Base64.encodeBase64String(msg.getBytes("utf-8"))+"</Msg>\n" +
|
|
|
"</Invoice>";
|
|
|
logger.info("开具电子发票入参:"+params);
|
|
|
String result = httpClientUtil.sendPost(dsfp,params);
|
|
|
logger.info("开具电子发票请求结果:"+result);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 下载电子发票
|
|
|
* @param medicalId
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public String queryDzfp(String medicalId) throws Exception {
|
|
|
YlzMedicalRelationInvoiceDO invoiceDO = invoiceDao.findByMedicalId(medicalId);
|
|
|
String msg = "<Voucher>\n" +
|
|
|
"<AgencyCode>401039</AgencyCode>\n" +
|
|
|
"<AgencyName>厦门市第三医院</AgencyName>\n" +
|
|
|
"<EInvoiceCode>"+invoiceDO.getInvoiceCode()+"</EInvoiceCode>\n" +
|
|
|
"<EInvoiceNumber>"+invoiceDO.getInvoiceSerialNum()+"</EInvoiceNumber>\n" +
|
|
|
"<RandomNumber>"+invoiceDO.getInvoiceNo()+"</RandomNumber>\n" +
|
|
|
"</Voucher>\n";
|
|
|
String randomStr = System.currentTimeMillis()+(int)(Math.random()*900)+100+"";
|
|
|
String params ="<?xml version='1.0' encoding='UTF-8'?>\n" +
|
|
|
"<Invoice>\n" +
|
|
|
"<Head>\n" +
|
|
|
"<MsgNo>"+msgNo+"</MsgNo>\n" +
|
|
|
"<Organ>"+organ+"</Organ>\n" +
|
|
|
"<User>"+user+"</User>\n" +
|
|
|
"<Version>1.0</Version>\n" +
|
|
|
"<AppId>"+appId+"</AppId>\n" +
|
|
|
"<AccessToken>aaaabbbbb11111333333</AccessToken>"+
|
|
|
"<AppId>862e18c18c5e4d72</AppId>\n" +
|
|
|
"<MsgId>5676"+randomStr+"</MsgId>\n" +
|
|
|
"<MsgRef>5676"+randomStr+"</MsgRef>\n" +
|
|
|
"<DateTime>"+new Date().getTime()+"</DateTime>\n" +
|
|
|
"<Reserve></Reserve>\n" +
|
|
|
"</Head>\n" +
|
|
|
"<Msg>"+ Base64.encodeBase64String(msg.getBytes("utf-8"))+"</Msg>\n" +
|
|
|
"</Invoice>";
|
|
|
logger.info("开具电子发票入参:"+params);
|
|
|
String result = httpClientUtil.sendPost(dsfp,params);
|
|
|
logger.info("开具电子发票请求结果:"+result);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
//=============================电子发票结束===================================
|
|
|
}
|