|
@ -1,5 +1,6 @@
|
|
package com.yihu.wlyy.service.app.prenatalInspector;
|
|
package com.yihu.wlyy.service.app.prenatalInspector;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.yihu.device.entity.DevicePatientHealthIndex;
|
|
import com.yihu.device.entity.DevicePatientHealthIndex;
|
|
@ -723,10 +724,10 @@ public class PrenatalInspectorPreCardService extends BaseService {
|
|
*
|
|
*
|
|
* @param prenatalId
|
|
* @param prenatalId
|
|
*/
|
|
*/
|
|
public JSONObject getPrenatalStatus(Long prenatalId) throws Exception {
|
|
|
|
|
|
public JSONObject getPrenatalStatusBak(Long prenatalId) throws Exception {
|
|
JSONObject json = new JSONObject();
|
|
JSONObject json = new JSONObject();
|
|
try {
|
|
try {
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
PrenatalInspectorPlan plan = prenatalInspectorPlanDao.findOne(prenatalId);
|
|
PrenatalInspectorPlan plan = prenatalInspectorPlanDao.findOne(prenatalId);
|
|
Date planTime = plan.getInspectionTime();
|
|
Date planTime = plan.getInspectionTime();
|
|
Boolean flag = getSendStatus(prenatalId);
|
|
Boolean flag = getSendStatus(prenatalId);
|
|
@ -793,6 +794,83 @@ public class PrenatalInspectorPreCardService extends BaseService {
|
|
return json;
|
|
return json;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 根据待产检ID查询最近一条待产检计划状态
|
|
|
|
*
|
|
|
|
* @param prenatalId
|
|
|
|
*/
|
|
|
|
public JSONObject getPrenatalStatus(Long prenatalId) throws Exception {
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
try {
|
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
PrenatalInspectorPlan plan = prenatalInspectorPlanDao.findOne(prenatalId);
|
|
|
|
Date planTime = plan.getInspectionTime();
|
|
|
|
String pregnancyNo = plan.getInspectionCode();
|
|
|
|
String patient = plan.getPatient();
|
|
|
|
Boolean flag = getSendStatus(prenatalId);
|
|
|
|
Long days = DateUtil.getDays(new Date(), planTime);
|
|
|
|
Date begin = DateUtil.getPreDays(planTime,-14);
|
|
|
|
Date end = DateUtil.getPreDays(planTime,14);
|
|
|
|
//有产检code
|
|
|
|
if (StringUtils.isNotEmpty(pregnancyNo) && (pregnancyNo != null)){
|
|
|
|
Boolean examStatus = getExamStatus(patient,pregnancyNo,begin,end);
|
|
|
|
if (examStatus){
|
|
|
|
json.put("renatalStatus", "4");
|
|
|
|
}else {
|
|
|
|
if (days > 7) {
|
|
|
|
json.put("renatalStatus", "3");
|
|
|
|
json.put("sendStatus", flag == true ? "1" : "0");
|
|
|
|
}else{
|
|
|
|
PrenatalInspectorRecord record = recordDao.findByRelationAndType(prenatalId.toString(), 0);
|
|
|
|
if (record == null) {
|
|
|
|
json.put("renatalStatus", "1");
|
|
|
|
if (days < -7) {
|
|
|
|
json.put("reason", "未到提醒时间(" + format.format(DateUtil.getPreDays(plan.getInspectionTime(), -7)) + " 08:00)");
|
|
|
|
}else {
|
|
|
|
json.put("reason", "提醒时间(" + format.format(DateUtil.getPreDays(plan.getInspectionTime(), -7)) + " 08:00)");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
PrenatalInspectorRecord docRecord = recordDao.findByRelationAndType(prenatalId.toString(), 1);
|
|
|
|
json.put("renatalStatus", "2");
|
|
|
|
json.put("sendStatus", flag == true ? "1" : "0");
|
|
|
|
if (docRecord == null) {
|
|
|
|
json.put("sendTime", format.format(record.getSendTime()));
|
|
|
|
} else {
|
|
|
|
json.put("sendTime", format.format(docRecord.getSendTime()));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
PrenatalInspectorRecord record = recordDao.findByRelationAndType(prenatalId.toString(), 0);
|
|
|
|
if (record == null) {
|
|
|
|
json.put("renatalStatus", "1");
|
|
|
|
if (days < -7) {
|
|
|
|
json.put("reason", "未到提醒时间(" + format.format(DateUtil.getPreDays(plan.getInspectionTime(), -7)) + " 08:00)");
|
|
|
|
}else {
|
|
|
|
json.put("reason", "提醒时间(" + format.format(DateUtil.getPreDays(plan.getInspectionTime(), -7)) + " 08:00)");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
PrenatalInspectorRecord docRecord = recordDao.findByRelationAndType(prenatalId.toString(), 1);
|
|
|
|
json.put("renatalStatus", "2");
|
|
|
|
json.put("sendStatus", flag == true ? "1" : "0");
|
|
|
|
if (docRecord == null) {
|
|
|
|
json.put("sendTime", format.format(record.getSendTime()));
|
|
|
|
} else {
|
|
|
|
json.put("sendTime", format.format(docRecord.getSendTime()));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
json.put("prenatalId", prenatalId);
|
|
|
|
return json;
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 提醒居民(每24小时可提醒一次)
|
|
* 提醒居民(每24小时可提醒一次)
|
|
*
|
|
*
|
|
@ -902,4 +980,32 @@ public class PrenatalInspectorPreCardService extends BaseService {
|
|
return flag;
|
|
return flag;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询待产检计划产检时间在该时间段内是否有过真实产检
|
|
|
|
* @param patient 居民code
|
|
|
|
* @param pregnancyNo 产检号
|
|
|
|
* @param begin 起始时间
|
|
|
|
* @param end 截止时间
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public Boolean getExamStatus(String patient,String pregnancyNo,Date begin,Date end) throws Exception {
|
|
|
|
Boolean flag = false;
|
|
|
|
try {
|
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
JSONArray natals = reExamRecode(patient,pregnancyNo);
|
|
|
|
for (Object natal : natals) {
|
|
|
|
JSONObject examRecord = JSON.parseObject(natal.toString());
|
|
|
|
String exam_time = examRecord.getString("EXAM_TIME");
|
|
|
|
Date examTime = format.parse(exam_time);
|
|
|
|
if ((examTime.getTime()<= end.getTime()) && (examTime.getTime() >= begin.getTime())){
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return flag;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|