|
@ -36,7 +36,7 @@ public class PatientRecordService {
|
|
private JdbcTemplate jdbcTemplate;
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private ObjectMapper objectMapper;
|
|
|
|
|
|
private ObjectMapper objectMapper;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 字符串List排序
|
|
* 字符串List排序
|
|
@ -59,24 +59,28 @@ public class PatientRecordService {
|
|
/**
|
|
/**
|
|
* 获取门/急诊记录 + 住院记录
|
|
* 获取门/急诊记录 + 住院记录
|
|
*/
|
|
*/
|
|
public List<Map<String,String>> getAllEvent(String patientCode, String type, String page, String pageSize,String lastTime) throws Exception
|
|
|
|
{
|
|
|
|
List<Map<String,String>> re = new ArrayList<>();
|
|
|
|
|
|
public List<Map<String, String>> getAllEvent(String patientCode, String type, String page, String pageSize, String lastTime) throws Exception {
|
|
|
|
List<Map<String, String>> re = new ArrayList<>();
|
|
|
|
|
|
//获取患者
|
|
//获取患者
|
|
Patient patient = patientDao.findByCode(patientCode);
|
|
Patient patient = patientDao.findByCode(patientCode);
|
|
//获取基卫数据
|
|
//获取基卫数据
|
|
String response = jwSmjkService.getResidentEventListJson(patient.getSsc(),type,page,pageSize);
|
|
|
|
|
|
String response = jwSmjkService.getResidentEventListJson(patient.getSsc(), type, page, pageSize);
|
|
|
|
|
|
//获取app数据
|
|
//获取app数据
|
|
List<PatientEvent> eventList = patientEventDao.findByPatient(patientCode);
|
|
|
|
|
|
List<PatientEvent> eventList = new ArrayList<>();
|
|
|
|
|
|
if(!StringUtils.isEmpty(response))
|
|
|
|
{
|
|
|
|
|
|
if (StringUtils.isEmpty(type)) {
|
|
|
|
eventList = patientEventDao.findByPatient(patientCode);
|
|
|
|
} else {
|
|
|
|
eventList = patientEventDao.findByPatientAndEventType(patientCode, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(response)) {
|
|
JSONArray array = new JSONArray(response);
|
|
JSONArray array = new JSONArray(response);
|
|
String max = "";
|
|
String max = "";
|
|
String min = "";
|
|
String min = "";
|
|
if(!"[{}]".equals(response)) {
|
|
|
|
|
|
if (!"[{}]".equals(response)) {
|
|
for (int i = 0; i < array.length(); i++) {
|
|
for (int i = 0; i < array.length(); i++) {
|
|
JSONObject item = array.getJSONObject(i);
|
|
JSONObject item = array.getJSONObject(i);
|
|
if (i == 0) //最大值
|
|
if (i == 0) //最大值
|
|
@ -101,35 +105,30 @@ public class PatientRecordService {
|
|
}
|
|
}
|
|
|
|
|
|
//过滤
|
|
//过滤
|
|
for(PatientEvent item:eventList)
|
|
|
|
{
|
|
|
|
|
|
|
|
String eventDate = DateUtil.dateToStrLong(item.getEventDate());
|
|
|
|
|
|
for (PatientEvent item : eventList) {
|
|
|
|
String eventDate = DateUtil.dateToStrLong(item.getEventDate());
|
|
int maxCompare = eventDate.compareTo(max);
|
|
int maxCompare = eventDate.compareTo(max);
|
|
int minCompare = eventDate.compareTo(min);
|
|
int minCompare = eventDate.compareTo(min);
|
|
Boolean contain = false;
|
|
Boolean contain = false;
|
|
if(maxCompare<0 && minCompare>=0) //时间范围内
|
|
|
|
|
|
if (maxCompare < 0 && minCompare >= 0) //时间范围内
|
|
{
|
|
{
|
|
contain = true;
|
|
contain = true;
|
|
}
|
|
}
|
|
|
|
|
|
//第一页特殊处理
|
|
//第一页特殊处理
|
|
if("1".equals(page) && maxCompare>=0)
|
|
|
|
{
|
|
|
|
|
|
if ("1".equals(page) && maxCompare >= 0) {
|
|
contain = true;
|
|
contain = true;
|
|
}
|
|
}
|
|
|
|
|
|
//最后一页特殊处理
|
|
//最后一页特殊处理
|
|
if(!"1".equals(page) && (array.length()==0||"[{}]".equals(response)) && !StringUtils.isEmpty(lastTime))
|
|
|
|
{
|
|
|
|
|
|
if (!"1".equals(page) && (array.length() == 0 || "[{}]".equals(response)) && !StringUtils.isEmpty(lastTime)) {
|
|
int lastTimeCompare = eventDate.compareTo(lastTime);
|
|
int lastTimeCompare = eventDate.compareTo(lastTime);
|
|
if(lastTimeCompare<0)
|
|
|
|
{
|
|
|
|
|
|
if (lastTimeCompare < 0) {
|
|
contain = true;
|
|
contain = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if(contain) {
|
|
|
|
|
|
if (contain) {
|
|
Map<String, String> map = new HashMap<>();
|
|
Map<String, String> map = new HashMap<>();
|
|
map.put("id", item.getId().toString());
|
|
map.put("id", item.getId().toString());
|
|
map.put("patient", item.getPatient());
|
|
map.put("patient", item.getPatient());
|
|
@ -144,10 +143,9 @@ public class PatientRecordService {
|
|
}
|
|
}
|
|
|
|
|
|
//排序
|
|
//排序
|
|
re = sortMapList(re,"eventDate","DESC");
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
if("1".equals(page)) {
|
|
|
|
|
|
re = sortMapList(re, "eventDate", "DESC");
|
|
|
|
} else {
|
|
|
|
if ("1".equals(page)) {
|
|
for (PatientEvent item : eventList) {
|
|
for (PatientEvent item : eventList) {
|
|
Map<String, String> map = new HashMap<>();
|
|
Map<String, String> map = new HashMap<>();
|
|
map.put("id", item.getId().toString());
|
|
map.put("id", item.getId().toString());
|
|
@ -169,25 +167,22 @@ public class PatientRecordService {
|
|
/**
|
|
/**
|
|
* 基卫通过event获取档案类型列表
|
|
* 基卫通过event获取档案类型列表
|
|
*/
|
|
*/
|
|
public List<Map<String,String>> getEventCatalog(String patientCode,String strEvent) throws Exception
|
|
|
|
{
|
|
|
|
|
|
public List<Map<String, String>> getEventCatalog(String patientCode, String strEvent) throws Exception {
|
|
//获取患者
|
|
//获取患者
|
|
Patient patient = patientDao.findByCode(patientCode);
|
|
Patient patient = patientDao.findByCode(patientCode);
|
|
List<Map<String,String>> re = new ArrayList<>();
|
|
|
|
|
|
List<Map<String, String>> re = new ArrayList<>();
|
|
|
|
|
|
String response = jwSmjkService.getEventCatalog(patient.getSsc(),strEvent); //【基卫接口】
|
|
|
|
|
|
String response = jwSmjkService.getEventCatalog(patient.getSsc(), strEvent); //【基卫接口】
|
|
JSONObject json = new JSONObject(response);
|
|
JSONObject json = new JSONObject(response);
|
|
JSONArray array = json.getJSONArray("RecordList");
|
|
JSONArray array = json.getJSONArray("RecordList");
|
|
|
|
|
|
if(array!=null && array.length()>0)
|
|
|
|
{
|
|
|
|
for(int i=0;i<array.length();i++)
|
|
|
|
{
|
|
|
|
|
|
if (array != null && array.length() > 0) {
|
|
|
|
for (int i = 0; i < array.length(); i++) {
|
|
JSONObject item = array.getJSONObject(i);
|
|
JSONObject item = array.getJSONObject(i);
|
|
Map<String,String> map = new HashMap<>();
|
|
|
|
map.put("catalog",item.optString("CATALOG_CODE"));
|
|
|
|
map.put("title",item.optString("TITLE"));
|
|
|
|
map.put("serial",item.optString("SERIAL"));
|
|
|
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
|
map.put("catalog", item.optString("CATALOG_CODE"));
|
|
|
|
map.put("title", item.optString("TITLE"));
|
|
|
|
map.put("serial", item.optString("SERIAL"));
|
|
re.add(map);
|
|
re.add(map);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@ -197,8 +192,7 @@ public class PatientRecordService {
|
|
/**
|
|
/**
|
|
* 获取健康档案信息详情
|
|
* 获取健康档案信息详情
|
|
*/
|
|
*/
|
|
public String getHealthData(String patientCode, String strEvent, String strCatalog, String strSerial) throws Exception
|
|
|
|
{
|
|
|
|
|
|
public String getHealthData(String patientCode, String strEvent, String strCatalog, String strSerial) throws Exception {
|
|
//获取患者
|
|
//获取患者
|
|
Patient patient = patientDao.findByCode(patientCode);
|
|
Patient patient = patientDao.findByCode(patientCode);
|
|
|
|
|
|
@ -212,101 +206,87 @@ public class PatientRecordService {
|
|
/**
|
|
/**
|
|
* 获取检查检验列表
|
|
* 获取检查检验列表
|
|
*/
|
|
*/
|
|
public List<Map<String,String>> getExamAndLabReport(String patientCode,String page,String pageSize) throws Exception
|
|
|
|
{
|
|
|
|
List<Map<String,String>> re = new ArrayList<>();
|
|
|
|
|
|
public List<Map<String, String>> getExamAndLabReport(String patientCode, String page, String pageSize) throws Exception {
|
|
|
|
List<Map<String, String>> re = new ArrayList<>();
|
|
|
|
|
|
//获取患者
|
|
//获取患者
|
|
Patient patient = patientDao.findByCode(patientCode);
|
|
Patient patient = patientDao.findByCode(patientCode);
|
|
|
|
|
|
//获取基卫数据
|
|
//获取基卫数据
|
|
String response = jwSmjkService.getExamAndLabReport(patient.getSsc(),page,pageSize); //【基卫接口】
|
|
|
|
|
|
String response = jwSmjkService.getExamAndLabReport(patient.getSsc(), page, pageSize); //【基卫接口】
|
|
|
|
|
|
//获取app数据
|
|
//获取app数据
|
|
String sql = "select a.*,b.img_type as catalog,GROUP_CONCAT(b.img_label) as label from wlyy_patient_event a\n" +
|
|
String sql = "select a.*,b.img_type as catalog,GROUP_CONCAT(b.img_label) as label from wlyy_patient_event a\n" +
|
|
"left join wlyy_patient_event_img b on b.event_id=a.id and b.img_type in ('检查报告','检验报告')\n" +
|
|
"left join wlyy_patient_event_img b on b.event_id=a.id and b.img_type in ('检查报告','检验报告')\n" +
|
|
"where a.patient='"+patientCode+"'\n" +
|
|
|
|
|
|
"where a.patient='" + patientCode + "'\n" +
|
|
"group by b.img_type order by a.event_date desc";
|
|
"group by b.img_type order by a.event_date desc";
|
|
List<Map<String,Object>> appList = jdbcTemplate.queryForList(sql);
|
|
|
|
|
|
List<Map<String, Object>> appList = jdbcTemplate.queryForList(sql);
|
|
|
|
|
|
if(!StringUtils.isEmpty(response))
|
|
|
|
{
|
|
|
|
|
|
if (!StringUtils.isEmpty(response)) {
|
|
JSONArray array = new JSONArray(response);
|
|
JSONArray array = new JSONArray(response);
|
|
|
|
|
|
for (int i=0;i<array.length();i++) {
|
|
|
|
|
|
for (int i = 0; i < array.length(); i++) {
|
|
JSONObject item = array.getJSONObject(i);
|
|
JSONObject item = array.getJSONObject(i);
|
|
Map<String,String> map = new HashMap<>();
|
|
|
|
map.put("id",item.optString("EVENT"));
|
|
|
|
map.put("patient",patientCode);
|
|
|
|
map.put("eventDate",item.optString("END_TIME"));
|
|
|
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
|
map.put("id", item.optString("EVENT"));
|
|
|
|
map.put("patient", patientCode);
|
|
|
|
map.put("eventDate", item.optString("END_TIME"));
|
|
String type = "";
|
|
String type = "";
|
|
if("0221".equals(item.optString("CATALOG_CODE")))
|
|
|
|
{
|
|
|
|
|
|
if ("0221".equals(item.optString("CATALOG_CODE"))) {
|
|
type = "检验";
|
|
type = "检验";
|
|
}
|
|
|
|
else if("0231".equals(item.optString("CATALOG_CODE")))
|
|
|
|
{
|
|
|
|
|
|
} else if ("0231".equals(item.optString("CATALOG_CODE"))) {
|
|
type = "检查";
|
|
type = "检查";
|
|
}
|
|
}
|
|
map.put("type",type);
|
|
|
|
map.put("catalogCode",item.optString("CATALOG_CODE")); //【基卫】档案类型
|
|
|
|
map.put("serial",item.optString("SERIAL")); //【基卫】档案序号
|
|
|
|
map.put("orgName",item.optString("ORG_NAME"));
|
|
|
|
map.put("label",item.optString("ITEM")); //检测项目
|
|
|
|
map.put("dataFrom","1");//基卫数据
|
|
|
|
|
|
map.put("type", type);
|
|
|
|
map.put("catalogCode", item.optString("CATALOG_CODE")); //【基卫】档案类型
|
|
|
|
map.put("serial", item.optString("SERIAL")); //【基卫】档案序号
|
|
|
|
map.put("orgName", item.optString("ORG_NAME"));
|
|
|
|
map.put("label", item.optString("ITEM")); //检测项目
|
|
|
|
map.put("dataFrom", "1");//基卫数据
|
|
re.add(map);
|
|
re.add(map);
|
|
}
|
|
}
|
|
|
|
|
|
//*******过滤
|
|
//*******过滤
|
|
for(Map<String,Object> item:appList)
|
|
|
|
{
|
|
|
|
Map<String,String> map = new HashMap<>();
|
|
|
|
map.put("id",item.get("id").toString());
|
|
|
|
map.put("patient",patientCode);
|
|
|
|
map.put("eventDate",DateUtil.dateToStrLong((Date) item.get("event_date")));
|
|
|
|
|
|
for (Map<String, Object> item : appList) {
|
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
|
map.put("id", item.get("id").toString());
|
|
|
|
map.put("patient", patientCode);
|
|
|
|
map.put("eventDate", DateUtil.dateToStrLong((Date) item.get("event_date")));
|
|
String type = "";
|
|
String type = "";
|
|
if("检验报告".equals(item.get("catalog")))
|
|
|
|
{
|
|
|
|
|
|
if ("检验报告".equals(item.get("catalog"))) {
|
|
type = "检验";
|
|
type = "检验";
|
|
}
|
|
|
|
else if("检查报告".equals(item.get("catalog")))
|
|
|
|
{
|
|
|
|
|
|
} else if ("检查报告".equals(item.get("catalog"))) {
|
|
type = "检查";
|
|
type = "检查";
|
|
}
|
|
}
|
|
map.put("type",type);
|
|
|
|
map.put("catalogCode","");
|
|
|
|
map.put("serial","");
|
|
|
|
map.put("orgName",String.valueOf(item.get("org_name")));
|
|
|
|
map.put("label",String.valueOf(item.get("label"))); //检测项目
|
|
|
|
map.put("dataFrom","2");//基卫数据
|
|
|
|
|
|
map.put("type", type);
|
|
|
|
map.put("catalogCode", "");
|
|
|
|
map.put("serial", "");
|
|
|
|
map.put("orgName", String.valueOf(item.get("org_name")));
|
|
|
|
map.put("label", String.valueOf(item.get("label"))); //检测项目
|
|
|
|
map.put("dataFrom", "2");//基卫数据
|
|
re.add(map);
|
|
re.add(map);
|
|
}
|
|
}
|
|
|
|
|
|
//排序
|
|
//排序
|
|
re = sortMapList(re,"eventDate","DESC");
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
for(Map<String,Object> item:appList)
|
|
|
|
{
|
|
|
|
Map<String,String> map = new HashMap<>();
|
|
|
|
map.put("id",String.valueOf(item.get("id")));
|
|
|
|
map.put("patient",patientCode);
|
|
|
|
map.put("eventDate",DateUtil.dateToStrLong((Date) item.get("event_date")));
|
|
|
|
|
|
re = sortMapList(re, "eventDate", "DESC");
|
|
|
|
} else {
|
|
|
|
for (Map<String, Object> item : appList) {
|
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
|
map.put("id", String.valueOf(item.get("id")));
|
|
|
|
map.put("patient", patientCode);
|
|
|
|
map.put("eventDate", DateUtil.dateToStrLong((Date) item.get("event_date")));
|
|
String type = "";
|
|
String type = "";
|
|
if("检验报告".equals(item.get("catalog")))
|
|
|
|
{
|
|
|
|
|
|
if ("检验报告".equals(item.get("catalog"))) {
|
|
type = "检验";
|
|
type = "检验";
|
|
}
|
|
|
|
else if("检查报告".equals(item.get("catalog")))
|
|
|
|
{
|
|
|
|
|
|
} else if ("检查报告".equals(item.get("catalog"))) {
|
|
type = "检查";
|
|
type = "检查";
|
|
}
|
|
}
|
|
map.put("type",type);
|
|
|
|
map.put("catalogCode","");
|
|
|
|
map.put("serial","");
|
|
|
|
map.put("orgName",String.valueOf(item.get("org_name")));
|
|
|
|
map.put("label",String.valueOf(item.get("label"))); //检测项目
|
|
|
|
map.put("dataFrom","2");//基卫数据
|
|
|
|
|
|
map.put("type", type);
|
|
|
|
map.put("catalogCode", "");
|
|
|
|
map.put("serial", "");
|
|
|
|
map.put("orgName", String.valueOf(item.get("org_name")));
|
|
|
|
map.put("label", String.valueOf(item.get("label"))); //检测项目
|
|
|
|
map.put("dataFrom", "2");//基卫数据
|
|
re.add(map);
|
|
re.add(map);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@ -318,13 +298,11 @@ public class PatientRecordService {
|
|
/**
|
|
/**
|
|
* 获取用药列表
|
|
* 获取用药列表
|
|
*/
|
|
*/
|
|
public String getDrugsListPage(String patientCode,String page,String pageSize) throws Exception
|
|
|
|
{
|
|
|
|
|
|
public String getDrugsListPage(String patientCode, String page, String pageSize) throws Exception {
|
|
//获取患者
|
|
//获取患者
|
|
Patient patient = patientDao.findByCode(patientCode);
|
|
Patient patient = patientDao.findByCode(patientCode);
|
|
return jwSmjkService.getDrugsListPage(patient.getSsc(),page,pageSize);
|
|
|
|
|
|
return jwSmjkService.getDrugsListPage(patient.getSsc(), page, pageSize);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|