|
@ -21,6 +21,7 @@ import com.yihu.jw.entity.base.score.BaseEvaluateScoreDO;
|
|
|
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.entity.hospital.survey.WlyySurveyQuestionDO;
|
|
|
import com.yihu.jw.evaluate.score.dao.BaseEvaluateDao;
|
|
|
import com.yihu.jw.evaluate.score.dao.BaseEvaluateScoreDao;
|
|
|
import com.yihu.jw.hospital.dict.YkDictIcd10Dao;
|
|
@ -37,6 +38,7 @@ 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.util.http.HttpClientUtil;
|
|
|
import com.yihu.jw.utils.EntityUtils;
|
|
|
import com.yihu.jw.utils.StringUtil;
|
|
|
import com.yihu.jw.utils.hibernate.HibenateUtils;
|
|
|
import com.yihu.utils.network.HttpResponse;
|
|
@ -69,6 +71,7 @@ public class YkyyEntranceService {
|
|
|
// private final static String url="http://localhost:10023/ykyy/createSQLQuery";
|
|
|
|
|
|
private final static String saveUrl="http://192.168.20.55:10023/ykyy/save";
|
|
|
private final static String orderUrl="http://192.168.20.55:10023/ykyy/outPatientOrder";
|
|
|
|
|
|
private final static String updateUrl="http://192.168.20.55:10023/ykyy/updateBySql";
|
|
|
|
|
@ -1312,7 +1315,7 @@ public class YkyyEntranceService {
|
|
|
* @param kusl
|
|
|
* @return
|
|
|
*/
|
|
|
public JSONArray findYkYpxx(String ypdm,String ypmc,String kusl,String pydm) throws Exception {
|
|
|
public JSONArray findYkYpxx(String ypdm,String ypmc,String kusl,String pydm ,String hisCode) throws Exception {
|
|
|
String sql ="SELECT yp.ypxh AS \"ypxh\", yp.ypdm AS \"ypdm\", yp.ypmc AS \"ypmc\", yp.yfgg AS \"yfgg\"," +
|
|
|
"yp.yfdw AS \"yfdw\"," +
|
|
|
"yp.yfbz AS \"yfbz\"," +
|
|
@ -1332,7 +1335,8 @@ public class YkyyEntranceService {
|
|
|
"yp.ydyp AS \"ydyp\"," +
|
|
|
"yp.ypmc2 AS \"ypmc2\"," +
|
|
|
"yp.gyffmc as \"gyffmc\"," +
|
|
|
"yp.pzwh as \"pzwh\""+ " FROM " +
|
|
|
"yp.pzwh as \"pzwh\","+
|
|
|
"yp.yfsb as \"yfsb\""+" FROM " +
|
|
|
"V_ZKSG_MZ_YPXX yp where 1=1 ";
|
|
|
if (StringUtils.isNoneBlank(ypdm)){
|
|
|
sql+=" and lower(yp.ypdm) like '%"+ypdm.toLowerCase()+"%' ";
|
|
@ -1347,6 +1351,9 @@ public class YkyyEntranceService {
|
|
|
if (StringUtils.isNoneBlank(pydm)){
|
|
|
sql+=" and lower(yp.pydm) like '%"+pydm.toLowerCase()+"%' ";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(hisCode)){
|
|
|
sql+=" and lower(yp.yfsb) like '%"+hisCode.toLowerCase()+"%' ";
|
|
|
}
|
|
|
JSONArray array = new JSONArray();
|
|
|
Map<String,Object> params = new HashedMap();
|
|
|
params.put("sql",sql);
|
|
@ -2207,6 +2214,252 @@ public class YkyyEntranceService {
|
|
|
return "推送成功";
|
|
|
}
|
|
|
}
|
|
|
//查询组套项目
|
|
|
public JSONArray findYzztByGslb(String gslb) throws Exception {
|
|
|
String sql = "select t.ztmc as\"ztmc\",t.ztid as\"ztid\"," +
|
|
|
"t.gslb as\"gslb\",t.gsdm as\"gsdm\"," +
|
|
|
"t.pydm as\"pydm\",t.Mzsy as\"Mzsy\"" +
|
|
|
"from portal_his.emr_yzzt@ykzxtest t where 1=1";
|
|
|
if(StringUtils.isNotEmpty(gslb)){
|
|
|
sql+=" and t.gslb = "+Integer.valueOf(gslb);
|
|
|
}
|
|
|
System.out.println(sql);
|
|
|
Map<String,Object> params = new HashedMap();
|
|
|
params.put("sql",sql);
|
|
|
logger.info("findYzztByGslb:"+sql);
|
|
|
HttpResponse response = HttpUtils.doGet(jdbcUrl,params);
|
|
|
String content = response.getContent();
|
|
|
logger.info("response:"+content);
|
|
|
JSONObject rs = JSON.parseObject(content);
|
|
|
Integer status = rs.getInteger("status");
|
|
|
JSONArray array= new JSONArray();
|
|
|
if (status==200){
|
|
|
array = rs.getJSONArray("detailModelList");
|
|
|
}
|
|
|
return array;
|
|
|
|
|
|
}
|
|
|
//根据组套项目id查询组套明细
|
|
|
public JSONArray findZtmxByid(String ztId) throws Exception{
|
|
|
String sql = "select t.ztid as \"ztid\",t.xmdm as \"xmdm\"," +
|
|
|
"t.xmmc as \"xmmc\",t.mrsl as \"mrsl\",t.zxks as \"zxks\"" +
|
|
|
"from portal_his.emr_ztmx@ykzxtest t where 1=1";
|
|
|
if (StringUtils.isNotEmpty(ztId)){
|
|
|
sql += " and t.ztid = '"+ztId+"'";
|
|
|
}
|
|
|
System.out.println(sql);
|
|
|
Map<String,Object> params = new HashedMap();
|
|
|
params.put("sql",sql);
|
|
|
logger.info("findZtmxByid:"+sql);
|
|
|
HttpResponse response = HttpUtils.doGet(jdbcUrl,params);
|
|
|
String content = response.getContent();
|
|
|
logger.info("response:"+content);
|
|
|
JSONObject rs = JSON.parseObject(content);
|
|
|
Integer status = rs.getInteger("status");
|
|
|
JSONArray array= new JSONArray();
|
|
|
if (status==200){
|
|
|
array = rs.getJSONArray("detailModelList");
|
|
|
}
|
|
|
return array;
|
|
|
|
|
|
}
|
|
|
//查询诊疗项目视图
|
|
|
public JSONArray findZlxm(String itemName) throws Exception{
|
|
|
String sql = "select t.item_code as \"itemCode\",t.item_name as \"itemName\"," +
|
|
|
"t.price as \"price\",t.total_unit as \"totalUnit\"," +
|
|
|
"t.zxks as \"zxks\" from VEMR_ORDER_ITEM t where 1=1";
|
|
|
if (StringUtils.isNotEmpty(itemName)){
|
|
|
sql+=" and t.ITEM_NAME like '%"+itemName+"%'";
|
|
|
}
|
|
|
System.out.println(sql);
|
|
|
Map<String,Object> params = new HashedMap();
|
|
|
params.put("sql",sql);
|
|
|
logger.info("findZlxm:"+sql);
|
|
|
HttpResponse response = HttpUtils.doGet(jdbcUrl,params);
|
|
|
String content = response.getContent();
|
|
|
logger.info("response:"+content);
|
|
|
JSONObject rs = JSON.parseObject(content);
|
|
|
Integer status = rs.getInteger("status");
|
|
|
JSONArray array= new JSONArray();
|
|
|
if (status==200){
|
|
|
array = rs.getJSONArray("detailModelList");
|
|
|
}
|
|
|
return array;
|
|
|
}
|
|
|
//查询诊疗项目明细视图
|
|
|
public JSONArray findZlxmMx(String zlxmId) throws Exception{
|
|
|
String sql = "select t.zlxmid as \"zlxmid\",t.fyxh as \"fyxh\",t.fysl \"fysl\"" +
|
|
|
" from VEMR_ORDER_ITEM_MX t where 1=1";
|
|
|
if (StringUtils.isNotEmpty(zlxmId)){
|
|
|
sql+=" and t.zlxmid = '"+zlxmId+"'";
|
|
|
}
|
|
|
System.out.println(sql);
|
|
|
Map<String,Object> params = new HashedMap();
|
|
|
params.put("sql",sql);
|
|
|
logger.info("findZlxmMx:"+sql);
|
|
|
HttpResponse response = HttpUtils.doGet(jdbcUrl,params);
|
|
|
String content = response.getContent();
|
|
|
logger.info("response:"+content);
|
|
|
JSONObject rs = JSON.parseObject(content);
|
|
|
Integer status = rs.getInteger("status");
|
|
|
JSONArray array= new JSONArray();
|
|
|
if (status==200){
|
|
|
array = rs.getJSONArray("detailModelList");
|
|
|
}
|
|
|
return array;
|
|
|
}
|
|
|
//his.gy_ylsf明细查询
|
|
|
public JSONArray findGyYlsf(String fyxh) throws Exception{
|
|
|
String sql = "select t.xmlx as \"xmlx\",t.fydj as \"fydj\",t.fygb as \"fygb\"" +
|
|
|
"from portal_his.GY_YLSF@ykzxtest t where 1=1";
|
|
|
if (StringUtils.isNotEmpty(fyxh)){
|
|
|
sql+=" and t.fyxh = '"+fyxh+"'";
|
|
|
}
|
|
|
Map<String,Object> params = new HashedMap();
|
|
|
params.put("sql",sql);
|
|
|
logger.info("findZlxmMx:"+sql);
|
|
|
HttpResponse response = HttpUtils.doGet(jdbcUrl,params);
|
|
|
String content = response.getContent();
|
|
|
logger.info("response:"+content);
|
|
|
JSONObject rs = JSON.parseObject(content);
|
|
|
Integer status = rs.getInteger("status");
|
|
|
JSONArray array= new JSONArray();
|
|
|
if (status==200){
|
|
|
array = rs.getJSONArray("detailModelList");
|
|
|
}
|
|
|
return array;
|
|
|
}
|
|
|
//门诊开单操作
|
|
|
public String outPatientOrder(String jsonDate,Boolean demoFlag,String doctor,String patient) throws Exception{
|
|
|
List<YkEmrJcsqDO> surveys = EntityUtils.jsonToList(jsonDate, YkEmrJcsqDO.class);
|
|
|
DoctorMappingDO doctorMappingDO = new DoctorMappingDO();
|
|
|
PatientMappingDO patientMappingDO =new PatientMappingDO();
|
|
|
if (StringUtils.isNotEmpty(doctor)){
|
|
|
doctorMappingDO = doctorMappingDao.findByDoctor(doctor);
|
|
|
}
|
|
|
if(StringUtils.isNotEmpty(patient)){
|
|
|
patientMappingDO = patientMappingDao.findByPatient(patient);
|
|
|
|
|
|
}
|
|
|
BasePatientDO patientDO = basePatientDao.findById(patient);
|
|
|
PatientMedicareCardDO patientMedicareCardDO = patientMedicareCardDao.findByTypeAndPatientCodeAndDel("A_01",patient,"1");
|
|
|
Integer brxb = 0;
|
|
|
String brxm = "";
|
|
|
Date csny =null;
|
|
|
Integer brnl =0;
|
|
|
String doctorHis="";
|
|
|
Integer kdks = 0;
|
|
|
JSONArray jsonArray = findHisPatient(patientMedicareCardDO.getCode(),demoFlag);
|
|
|
if(jsonArray!=null&&jsonArray.size()>0){
|
|
|
//获取居民信息
|
|
|
JSONObject json = jsonArray.getJSONObject(0);
|
|
|
brxb = json.getInteger("brxb");
|
|
|
brxm = json.getString("brxm");
|
|
|
csny = json.getDate("csny");
|
|
|
brnl = this.getBrnl(csny);
|
|
|
}
|
|
|
//操作医生信息
|
|
|
JSONArray jsonArray1 = findHisDoctor(doctorMappingDO.getIdcard());
|
|
|
if(jsonArray1!=null&&jsonArray1.size()>0){
|
|
|
JSONObject json = jsonArray1.getJSONObject(0);
|
|
|
doctorHis=json.getString("code");
|
|
|
}
|
|
|
|
|
|
// 同一个医生同一个病人,一天一条挂号记录。
|
|
|
JSONArray ja = fingHlwGhmx(patientMappingDO.getMappingCode(),doctorMappingDO.getMappingCode());
|
|
|
|
|
|
if (surveys!=null){
|
|
|
for (YkEmrJcsqDO ykEmrJcsqDO:surveys){
|
|
|
if (demoFlag){
|
|
|
ykEmrJcsqDO.setJjbz(0);
|
|
|
ykEmrJcsqDO.setJczt(1);
|
|
|
ykEmrJcsqDO.setZfbz(0);
|
|
|
ykEmrJcsqDO.setQxbz(0);
|
|
|
ykEmrJcsqDO.setBrxb(brxb);
|
|
|
ykEmrJcsqDO.setBrxm(brxm);
|
|
|
ykEmrJcsqDO.setBrnl(brnl);
|
|
|
ykEmrJcsqDO.setKdys(doctorHis);
|
|
|
ykEmrJcsqDO.setBrks(114);
|
|
|
ykEmrJcsqDO.setTjys(doctorHis);
|
|
|
}else {
|
|
|
ykEmrJcsqDO.setJjbz(0);
|
|
|
ykEmrJcsqDO.setJczt(1);
|
|
|
ykEmrJcsqDO.setZfbz(0);
|
|
|
ykEmrJcsqDO.setQxbz(0);
|
|
|
ykEmrJcsqDO.setBrxb(1);
|
|
|
ykEmrJcsqDO.setBrxm("测试病人");
|
|
|
ykEmrJcsqDO.setBrnl(18);
|
|
|
ykEmrJcsqDO.setKdys("测试医生");
|
|
|
}
|
|
|
}
|
|
|
String jsonString = JSONObject.toJSONString(surveys);
|
|
|
Map<String,Object> params = new HashedMap();
|
|
|
params.put("json",jsonString);
|
|
|
params.put("table","ykEmrJcsqDO");
|
|
|
logger.info("ykEmrJcsqDO:"+jsonString);
|
|
|
HttpResponse response = HttpUtils.doGet(orderUrl,params);
|
|
|
String content = response.getContent();
|
|
|
logger.info("response:"+content);
|
|
|
JSONObject rs = JSON.parseObject(content);
|
|
|
Integer status = rs.getInteger("status");
|
|
|
if (status!=null&&status == 200){
|
|
|
return rs.toString();
|
|
|
}else {
|
|
|
return "failed";
|
|
|
}
|
|
|
|
|
|
}else {
|
|
|
return "failed";
|
|
|
}
|
|
|
|
|
|
}
|
|
|
//查询检查单
|
|
|
public JSONArray findOrder()throws Exception{
|
|
|
String sql = "select t.sqdh,t.brid," +
|
|
|
"t.jzlx,t.brxm,t.brks," +
|
|
|
"t.brnl,t.kdsj,t.zxks,t.jcxm,t.xmdj," +
|
|
|
"t.xmdw,t.xmid,t.sqsl from emr_jcsq@ykzxtest t where 1=1";
|
|
|
Map<String,Object> params = new HashedMap();
|
|
|
params.put("sql",sql);
|
|
|
params.put("table","ykEmrJcsqDO");
|
|
|
logger.info("ykEmrJcsqDO:"+sql);
|
|
|
HttpResponse response = HttpUtils.doGet(jdbcUrl,params);
|
|
|
String content = response.getContent();
|
|
|
logger.info("response:"+content);
|
|
|
JSONObject rs = JSON.parseObject(content);
|
|
|
Integer status = rs.getInteger("status");
|
|
|
JSONArray array= new JSONArray();
|
|
|
if (status==200){
|
|
|
array = rs.getJSONArray("detailModelList");
|
|
|
}
|
|
|
return array;
|
|
|
}
|
|
|
public Integer getBrnl(Date date){
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
if (cal.before(date)) {
|
|
|
throw new IllegalArgumentException(
|
|
|
"The birthDay is before Now.It's unbelievable!");
|
|
|
}
|
|
|
int yearNow = cal.get(Calendar.YEAR);
|
|
|
int monthNow = cal.get(Calendar.MONTH) + 1;
|
|
|
int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH);
|
|
|
cal.setTime(date);
|
|
|
int yearBirth = cal.get(Calendar.YEAR);
|
|
|
int monthBirth = cal.get(Calendar.MONTH) + 1;
|
|
|
int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH);
|
|
|
int age = yearNow - yearBirth;
|
|
|
if (monthNow <= monthBirth) {
|
|
|
if (monthNow == monthBirth) {
|
|
|
// monthNow==monthBirth
|
|
|
if (dayOfMonthNow < dayOfMonthBirth) {
|
|
|
age--;
|
|
|
}
|
|
|
} else {
|
|
|
// monthNow>monthBirth
|
|
|
age--;
|
|
|
}
|
|
|
}
|
|
|
return age;
|
|
|
}
|
|
|
|
|
|
}
|