|
@ -3,14 +3,18 @@ package com.yihu.wlyy.service.app.prescription;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.wlyy.adapter.PresModeAdapter;
|
|
|
import com.yihu.wlyy.entity.dict.Icd10Dict;
|
|
|
import com.yihu.wlyy.entity.doctor.team.sign.DoctorTeam;
|
|
|
import com.yihu.wlyy.entity.followup.Followup;
|
|
|
import com.yihu.wlyy.entity.message.Message;
|
|
|
import com.yihu.wlyy.entity.message.MessageNoticeSetting;
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.Prescription;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.PrescriptionDiagnosis;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressage;
|
|
|
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
|
|
|
import com.yihu.wlyy.repository.dict.Icd10DictDao;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorTeamDao;
|
|
|
import com.yihu.wlyy.repository.followup.FollowUpDao;
|
|
|
import com.yihu.wlyy.repository.message.MessageDao;
|
|
@ -24,6 +28,7 @@ import com.yihu.wlyy.service.app.message.MessageService;
|
|
|
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
|
|
|
import com.yihu.wlyy.task.PushMsgTask;
|
|
|
import com.yihu.wlyy.util.CommonUtil;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import com.yihu.wlyy.util.MessageType;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@ -86,6 +91,10 @@ public class PrescriptionService extends BaseService {
|
|
|
private static final String gxy = "HP0093";
|
|
|
//健康问题 糖尿病
|
|
|
private static final String tnb = "HP0047";
|
|
|
@Autowired
|
|
|
private PresModeAdapter presModeAdapter;
|
|
|
@Autowired
|
|
|
private Icd10DictDao icd10DictDao;
|
|
|
|
|
|
/**
|
|
|
* 获取处方信息
|
|
@ -635,4 +644,113 @@ public class PrescriptionService extends BaseService {
|
|
|
}
|
|
|
return rsMap;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据居民CODE,时间轴,就诊类型查询用药记录
|
|
|
* @param patientCode 居民CODE
|
|
|
* @param timeline 时间轴(根据传入的时间搜索前25天后25天)YYYY-MM-DD
|
|
|
* @param type 1糖尿病,2高血压
|
|
|
* @return
|
|
|
*/
|
|
|
public String findPatientMedicationRecords(String patientCode, String timeline, Integer type) throws Exception{
|
|
|
|
|
|
Integer totalCount = 0;
|
|
|
|
|
|
String RECIPE_NO = "";//符合规则基卫处方医嘱号
|
|
|
|
|
|
Patient patient = patientDao.findByCode(patientCode);
|
|
|
|
|
|
if(patient == null){
|
|
|
throw new Exception("未找到居民!");
|
|
|
}
|
|
|
|
|
|
String medicationRecords = "";
|
|
|
|
|
|
Date timeLineDate = DateUtil.strToDateShort(timeline);
|
|
|
Date startTime = DateUtil.setDateTime(timeLineDate,-25);
|
|
|
Date endTime = DateUtil.setDateTime(timeLineDate,25);
|
|
|
|
|
|
com.alibaba.fastjson.JSONObject re = jwPrescriptionService.getRecipeMasterList(patientCode,DateUtil.dateToStrShort(startTime),DateUtil.dateToStrShort(endTime));
|
|
|
|
|
|
totalCount = re.getInteger("totalCount");
|
|
|
if(totalCount>0){
|
|
|
com.alibaba.fastjson.JSONArray pres = re.getJSONArray("list");
|
|
|
for (int i = 0; i < pres.size(); i++) {
|
|
|
com.alibaba.fastjson.JSONObject r = (com.alibaba.fastjson.JSONObject) pres.get(i);
|
|
|
com.alibaba.fastjson.JSONArray des = r.getJSONArray("prescriptionDt");
|
|
|
boolean flag = false;
|
|
|
for (int j = 0; j < des.size(); j++) {
|
|
|
PrescriptionDiagnosis ds = des.getObject(j, PrescriptionDiagnosis.class);
|
|
|
|
|
|
// String icdCode = ds.getHealthProblem();
|
|
|
// System.out.println(icdCode);
|
|
|
// Icd10Dict icd10Dict = icd10DictDao.findByCode(icdCode);
|
|
|
// if(icd10Dict==null){
|
|
|
// continue;
|
|
|
// }
|
|
|
//
|
|
|
// System.out.println(r.getString("code"));
|
|
|
// if("1".equals(type)){
|
|
|
// //血糖
|
|
|
// if(!"2".equals(icd10Dict.getType())){
|
|
|
// continue;
|
|
|
// }else{
|
|
|
// RECIPE_NO = r.getString("code");
|
|
|
// break;
|
|
|
// }
|
|
|
// }else {
|
|
|
// //血压
|
|
|
// if(!"1".equals(icd10Dict.getType())){
|
|
|
// continue;
|
|
|
// }else{
|
|
|
// RECIPE_NO = r.getString("code");
|
|
|
// break;
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
if (1 == type) {
|
|
|
//主诊断为糖尿病
|
|
|
if(tnb.equals(ds.getHealthProblem())){
|
|
|
RECIPE_NO = r.getString("code");
|
|
|
break;
|
|
|
}else{
|
|
|
continue;
|
|
|
}
|
|
|
} else if(2 == type){
|
|
|
//主诊断为高血压
|
|
|
if(gxy.equals(ds.getHealthProblem())){
|
|
|
RECIPE_NO = r.getString("code");
|
|
|
break;
|
|
|
}else{
|
|
|
continue;
|
|
|
}
|
|
|
}else{
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(org.apache.commons.lang.StringUtils.isNotBlank(RECIPE_NO)){
|
|
|
String response = jwPrescriptionService.getRecipe(RECIPE_NO,patient.getSsc());
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = presModeAdapter.modelToSinglePrescription(response);
|
|
|
//药品
|
|
|
com.alibaba.fastjson.JSONArray infos = jsonObject.getJSONArray("prescriptionInfo");
|
|
|
|
|
|
for(int i=0;i<infos.size();i++){
|
|
|
com.alibaba.fastjson.JSONObject info = infos.getJSONObject(i);
|
|
|
String drugname = info.getString("drugName");
|
|
|
if(org.apache.commons.lang.StringUtils.isNotBlank(drugname)){
|
|
|
medicationRecords = medicationRecords + drugname;
|
|
|
if(i != (infos.size() -1)){
|
|
|
medicationRecords = medicationRecords + ",";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
return medicationRecords;
|
|
|
}
|
|
|
}
|