|
@ -10,9 +10,12 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
|
|
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
|
|
import com.yihu.jw.entity.hospital.consult.WlyyDoctorClinicRoomDO;
|
|
import com.yihu.jw.entity.hospital.consult.WlyyDoctorClinicRoomDO;
|
|
import com.yihu.jw.entity.hospital.consult.WlyyHospitalWaitingRoomDO;
|
|
import com.yihu.jw.entity.hospital.consult.WlyyHospitalWaitingRoomDO;
|
|
|
|
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
|
|
import com.yihu.jw.entity.hospital.prescription.*;
|
|
import com.yihu.jw.entity.hospital.prescription.*;
|
|
import com.yihu.jw.hospital.consult.dao.DoctorClinicRoomConsultDao;
|
|
import com.yihu.jw.hospital.consult.dao.DoctorClinicRoomConsultDao;
|
|
import com.yihu.jw.hospital.consult.dao.HospitalWaitingRoomDao;
|
|
import com.yihu.jw.hospital.consult.dao.HospitalWaitingRoomDao;
|
|
|
|
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
|
|
|
|
import com.yihu.jw.hospital.mapping.service.DoctorMappingService;
|
|
import com.yihu.jw.hospital.mapping.service.PatientMappingService;
|
|
import com.yihu.jw.hospital.mapping.service.PatientMappingService;
|
|
import com.yihu.jw.hospital.prescription.dao.*;
|
|
import com.yihu.jw.hospital.prescription.dao.*;
|
|
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
|
|
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
|
|
@ -80,6 +83,8 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
|
|
@Autowired
|
|
@Autowired
|
|
private PatientMappingService patientMappingService;
|
|
private PatientMappingService patientMappingService;
|
|
@Autowired
|
|
@Autowired
|
|
|
|
private DoctorMappingService doctorMappingService;
|
|
|
|
@Autowired
|
|
private OutpatientDao outpatientDao;
|
|
private OutpatientDao outpatientDao;
|
|
@Autowired
|
|
@Autowired
|
|
private ObjectMapper objectMapper;
|
|
private ObjectMapper objectMapper;
|
|
@ -185,7 +190,10 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
|
|
" o.origin_adm_no AS originAdmNo, " +
|
|
" o.origin_adm_no AS originAdmNo, " +
|
|
" o.register_no AS registerNo, " +
|
|
" o.register_no AS registerNo, " +
|
|
" o.origin_register_no AS originRegisterNo, " +
|
|
" o.origin_register_no AS originRegisterNo, " +
|
|
" o.hos" +
|
|
|
|
|
|
" o.hospital," +
|
|
|
|
" o.hospital_name AS hospitalName," +
|
|
|
|
" o.winNo," +
|
|
|
|
" o.type," +
|
|
" o.dept AS dept, " +
|
|
" o.dept AS dept, " +
|
|
" o.dept_name AS deptName, " +
|
|
" o.dept_name AS deptName, " +
|
|
" o.patient AS patient, " +
|
|
" o.patient AS patient, " +
|
|
@ -643,5 +651,220 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
|
|
|
|
// public JSONArray find
|
|
|
|
|
|
/**
|
|
|
|
* 挂号
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public net.sf.json.JSONObject registerOutPatient(String outPatientId,String doctor)throws Exception{
|
|
|
|
|
|
|
|
WlyyOutpatientDO outpatientDO = outpatientDao.findOne(outPatientId);
|
|
|
|
|
|
|
|
DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(doctor,outpatientDO.getHospital());
|
|
|
|
if(doctorMappingDO==null){
|
|
|
|
throw new RuntimeException("未找到医生映射信息");
|
|
|
|
}
|
|
|
|
net.sf.json.JSONObject rs = entranceService.BS10111(outpatientDO.getCardNo(),doctorMappingDO.getMappingCode(),outpatientDO.getDept(),null,outpatientDO.getWinNo(),demoFlag);
|
|
|
|
String rsCode = (String)rs.get("@RESULT");
|
|
|
|
if("0".equals(rsCode)){
|
|
|
|
//存储挂号号
|
|
|
|
String serialNo = (String)rs.get("serial_no");
|
|
|
|
outpatientDO.setRegisterNo(serialNo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rs;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取诊断
|
|
|
|
* @param pyKey
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public JSONArray getICD10(String pyKey)throws Exception{
|
|
|
|
return entranceService.MS25001(pyKey,demoFlag);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取药品
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public JSONArray getDrugDictionary(String chargeCode,String pyKey,String winNo)throws Exception{
|
|
|
|
return entranceService.MS53001(chargeCode,pyKey,null,winNo,"0",demoFlag);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取药品用法
|
|
|
|
*/
|
|
|
|
public JSONArray getDrugUse(String pyKey)throws Exception{
|
|
|
|
return entranceService.BS10110(null,pyKey,demoFlag);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 医院频次
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public JSONArray getDrugFrequency()throws Exception{
|
|
|
|
return entranceService.MS30012(demoFlag);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param outPatientId
|
|
|
|
* @param advice
|
|
|
|
* @param type 1带处方,2不带处方
|
|
|
|
* @param infoJsons
|
|
|
|
* @param diagnosisJson
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public Map<String,Object> makeDiagnosis(String outPatientId,String advice,String type,String infoJsons,String diagnosisJson)throws Exception{
|
|
|
|
|
|
|
|
Map<String,Object> result = new HashedMap();
|
|
|
|
|
|
|
|
//获取门诊记录
|
|
|
|
WlyyOutpatientDO outpatientDO = outpatientDao.findOne(outPatientId);
|
|
|
|
outpatientDO.setAdvice(advice);
|
|
|
|
|
|
|
|
//创建处方记录
|
|
|
|
List<WlyyPrescriptionDO> prescriptionDOs = prescriptionDao.findByOutpatientId(outPatientId);
|
|
|
|
WlyyPrescriptionDO prescriptionDO = null;
|
|
|
|
if(prescriptionDOs!=null&&prescriptionDOs.size()>0){
|
|
|
|
prescriptionDO = prescriptionDOs.get(0);
|
|
|
|
}else{
|
|
|
|
prescriptionDO = new WlyyPrescriptionDO();
|
|
|
|
}
|
|
|
|
prescriptionDO.setStatus(10);
|
|
|
|
prescriptionDO.setPatientCode(outpatientDO.getPatient());
|
|
|
|
prescriptionDO.setPatientName(outpatientDO.getPatientName());
|
|
|
|
prescriptionDO.setDoctor(outpatientDO.getDoctor());
|
|
|
|
prescriptionDO.setDoctorName(outpatientDO.getDoctorName());
|
|
|
|
WlyyPrescriptionDO prescription = prescriptionDao.save(prescriptionDO);
|
|
|
|
|
|
|
|
//下诊断
|
|
|
|
//删除之前诊断
|
|
|
|
List<WlyyPrescriptionDiagnosisDO> ds = prescriptionDiagnosisDao.findByPrescriptionId(prescription.getId());
|
|
|
|
prescriptionDiagnosisDao.delete(ds);
|
|
|
|
|
|
|
|
List<WlyyPrescriptionDiagnosisDO> diagnosisDOs = (List<WlyyPrescriptionDiagnosisDO>) com.alibaba.fastjson.JSONArray.parseArray(diagnosisJson, WlyyPrescriptionDiagnosisDO.class);
|
|
|
|
String Icd10 = "";
|
|
|
|
String Icd10Name = "";
|
|
|
|
for(WlyyPrescriptionDiagnosisDO diagnosisDO:diagnosisDOs){
|
|
|
|
if("1".equals(diagnosisDO.getType())){
|
|
|
|
Icd10 = diagnosisDO.getCode()+","+Icd10;
|
|
|
|
Icd10Name+=diagnosisDO.getName()+","+Icd10Name;
|
|
|
|
}else {
|
|
|
|
Icd10+=diagnosisDO.getCode()+",";
|
|
|
|
Icd10Name+=diagnosisDO.getName()+",";
|
|
|
|
}
|
|
|
|
diagnosisDO.setPrescriptionId(prescription.getId());
|
|
|
|
}
|
|
|
|
prescriptionDiagnosisDao.save(diagnosisDOs);
|
|
|
|
|
|
|
|
Icd10 = Icd10.substring(0,Icd10.length()-1);
|
|
|
|
Icd10Name = Icd10Name.substring(0,Icd10Name.length()-1);
|
|
|
|
outpatientDO.setIcd10(Icd10);
|
|
|
|
outpatientDO.setIcd10Name(Icd10Name);
|
|
|
|
outpatientDao.save(outpatientDO);
|
|
|
|
|
|
|
|
//判断是否需药品,有药品到his开处方,没有药品直接下诊断开方
|
|
|
|
if("1".equals(type)){
|
|
|
|
|
|
|
|
//doctor转换为his医生
|
|
|
|
DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(outpatientDO.getDoctor(),outpatientDO.getHospital());
|
|
|
|
if(doctorMappingDO==null){
|
|
|
|
throw new RuntimeException("未找到医生映射信息");
|
|
|
|
}
|
|
|
|
|
|
|
|
//删除原有药品信息
|
|
|
|
List<WlyyPrescriptionInfoDO> oldInfos = prescriptionInfoDao.findByPrescriptionId(prescription.getId());
|
|
|
|
if(oldInfos!=null&&oldInfos.size()>0){
|
|
|
|
prescriptionInfoDao.delete(oldInfos);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(StringUtils.isNotBlank(infoJsons)){
|
|
|
|
//药品
|
|
|
|
List<WlyyPrescriptionInfoDO> infoDOs = (List<WlyyPrescriptionInfoDO>) com.alibaba.fastjson.JSONArray.parseArray(infoJsons, WlyyPrescriptionInfoDO.class);
|
|
|
|
//his处方拼接开方条件
|
|
|
|
com.alibaba.fastjson.JSONArray jsonData = new com.alibaba.fastjson.JSONArray();
|
|
|
|
for(WlyyPrescriptionInfoDO info:infoDOs){
|
|
|
|
info.setDel(1);
|
|
|
|
info.setPrescriptionId(prescription.getId());
|
|
|
|
com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
|
|
|
|
json.put("cardNo",outpatientDO.getCardNo());
|
|
|
|
json.put("doctor",doctorMappingDO.getMappingCode());
|
|
|
|
json.put("dept",outpatientDO.getDept());
|
|
|
|
json.put("chargeCode",info.getDrugNo());
|
|
|
|
json.put("winNo",outpatientDO.getWinNo());
|
|
|
|
json.put("chargeFlag",1);
|
|
|
|
json.put("quantity",info.getQuantity());
|
|
|
|
json.put("serialNo",outpatientDO.getRegisterNo());
|
|
|
|
json.put("groupNo",info.getGroupNo());
|
|
|
|
json.put("serial",info.getSerial());
|
|
|
|
String Icd10s[] = Icd10.split(",");
|
|
|
|
for(int i=0;i<Icd10s.length;i++){
|
|
|
|
if(i==0){
|
|
|
|
json.put("icdCode",Icd10s[i]);
|
|
|
|
}else if(i==1){
|
|
|
|
json.put("diagTwo",Icd10s[i]);
|
|
|
|
}else if(i==2){
|
|
|
|
json.put("diagThree",Icd10s[i]);
|
|
|
|
}else if(i==3){
|
|
|
|
json.put("diagFour",Icd10s[i]);
|
|
|
|
}else if(i==4){
|
|
|
|
json.put("diagFive",Icd10s[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
json.put("dosage",info.getDosage());
|
|
|
|
json.put("unit",info.getUnit());
|
|
|
|
json.put("usage",info.getUsage());
|
|
|
|
json.put("supplyCode",info.getSupplyCode());
|
|
|
|
json.put("days ",info.getDays());
|
|
|
|
json.put("frequency",info.getFrequency());
|
|
|
|
jsonData.add(json);
|
|
|
|
}
|
|
|
|
//保存处方
|
|
|
|
prescriptionInfoDao.save(infoDOs);
|
|
|
|
|
|
|
|
//调用his开方接口
|
|
|
|
net.sf.json.JSONObject jsonObject = entranceService.BS10112(jsonData.toJSONString(),demoFlag);
|
|
|
|
//判断返回结果
|
|
|
|
String rs = jsonObject.getString("@RESULT");
|
|
|
|
if("0".equals(rs)){
|
|
|
|
String admNo = jsonObject.getString("@ADM_NO");
|
|
|
|
String realOrder = jsonObject.getString("@real_order");
|
|
|
|
|
|
|
|
prescription.setAdmNo(admNo);
|
|
|
|
prescription.setRealOrder(realOrder);
|
|
|
|
prescriptionDao.save(prescription);
|
|
|
|
outpatientDO.setAdmNo(admNo);
|
|
|
|
outpatientDao.save(outpatientDO);
|
|
|
|
|
|
|
|
result.put("code",1);
|
|
|
|
result.put("mes","开方提交成功");
|
|
|
|
return result;
|
|
|
|
}else{
|
|
|
|
//开方失败
|
|
|
|
prescription.setStatus(13);
|
|
|
|
prescriptionDao.save(prescription);
|
|
|
|
result.put("code",-1);
|
|
|
|
result.put("mes","开方提交失败");
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}else{
|
|
|
|
result.put("code",-2);
|
|
|
|
result.put("mes","参数错误,药品参数错误");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
}else{
|
|
|
|
//
|
|
|
|
outpatientDO.setStatus("2");
|
|
|
|
outpatientDao.save(outpatientDO);
|
|
|
|
result.put("code",1);
|
|
|
|
result.put("mes","诊断完成");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|