|
@ -13,6 +13,7 @@ import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.service.survey.ManagerQuestionnaireService;
|
|
|
import com.yihu.wlyy.task.PushMsgTask;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import com.yihu.wlyy.util.IdCardUtil;
|
|
|
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
|
|
|
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
|
|
@ -433,7 +434,7 @@ public class SurveyScreenResultService extends BaseService {
|
|
|
if (surveyScreenResult.getFollowing()==1){
|
|
|
followCount++;
|
|
|
}
|
|
|
if (surveyScreenResult.getIsOrder()==1){
|
|
|
if (surveyScreenResult.getIsOrder()>0){
|
|
|
orderCount++;
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(surveyScreenResult.getParentCode())){
|
|
@ -759,7 +760,9 @@ public class SurveyScreenResultService extends BaseService {
|
|
|
String name = null;
|
|
|
String openId = null;
|
|
|
String first = null;
|
|
|
String screenCode =null;
|
|
|
try {
|
|
|
screenCode = saveAfterBatchScreen(c,openId,name,doctor,wxTemplateCode);
|
|
|
p = patientDao.findByCode(c);
|
|
|
name = p.getName();
|
|
|
openId = p.getOpenid();
|
|
@ -767,7 +770,7 @@ public class SurveyScreenResultService extends BaseService {
|
|
|
json.put("keyword2", sdf.format(new Date()));
|
|
|
json.put("survey", wxTemplateCode+"_"+doctor);
|
|
|
json.put("toUser", c);
|
|
|
json.put("url","jkpg/html/start-survey.html?survey="+wxTemplateCode+"&doctor="+doctor+"&toUser="+c+"&toName="+name);
|
|
|
json.put("url","jkpg/html/wx-template-message.html?survey="+wxTemplateCode+"&doctor="+doctor+"&toUser="+c+"&toName="+name+"&screenCode="+screenCode);
|
|
|
// String first = name + ",您好!为了给您提供更好的家庭医生健康服务,现有一份问卷需要您填写。";
|
|
|
first = templateConfig.getFirst();
|
|
|
first = first.replace("key1",(name==null?"":name));
|
|
@ -792,7 +795,7 @@ public class SurveyScreenResultService extends BaseService {
|
|
|
if (StringUtils.isNotBlank(member.getOpenid())) {
|
|
|
json.remove("toUser");
|
|
|
json.put("toUser", member.getCode());
|
|
|
json.put("url","jkpg/html/start-survey.html?survey="+wxTemplateCode+"&doctor="+doctor+"&toUser="+member.getCode()+"&toName="+member.getName());
|
|
|
json.put("url","jkpg/html/wx-template-message.html?survey="+wxTemplateCode+"&doctor="+doctor+"&toUser="+member.getCode()+"&toName="+member.getName()+"&screenCode="+screenCode);
|
|
|
json.remove("first");
|
|
|
try {
|
|
|
json.put("keyword1", keyword1);
|
|
@ -1024,4 +1027,81 @@ public class SurveyScreenResultService extends BaseService {
|
|
|
surveyDao.save(survey);
|
|
|
return surveyCode;
|
|
|
}
|
|
|
|
|
|
public String saveAfterBatchScreen(String patientCode,String openId,String patientName,String doctorCode,String surveyCode){
|
|
|
SurveyScreenResult surveyScreenResult = new SurveyScreenResult();
|
|
|
SurveyTemplates surveyTemplates = surveyTemplatesDao.findById(surveyCode);
|
|
|
Patient patient = patientDao.findByCode(patientCode);
|
|
|
String code = getCode();
|
|
|
surveyScreenResult.setCode(code);
|
|
|
if (surveyTemplates!=null){
|
|
|
surveyScreenResult.setTemplateCode(surveyTemplates.getCode());
|
|
|
surveyScreenResult.setTemplateTitle(surveyTemplates.getTitle());
|
|
|
surveyScreenResult.setDisease(surveyTemplates.getDiseaseType());
|
|
|
}
|
|
|
surveyScreenResult.setDoctor(doctorCode);
|
|
|
surveyScreenResult.setPatientCode(patientCode);
|
|
|
if (patient!=null){
|
|
|
surveyScreenResult.setPatientName(patient.getName());
|
|
|
surveyScreenResult.setOpenId(patient.getOpenid());
|
|
|
}else {
|
|
|
surveyScreenResult.setOpenId(openId);
|
|
|
surveyScreenResult.setPatientName(patientName);
|
|
|
}
|
|
|
surveyScreenResult.setIsDanger(0);
|
|
|
surveyScreenResult.setIsOrder(0);
|
|
|
surveyScreenResult.setFollowing(0);
|
|
|
surveyScreenResult.setIsEducate(0);
|
|
|
surveyScreenResult.setOver(0);
|
|
|
surveyScreenResult.setCzrq(new Date());
|
|
|
surveyScreenResult.setIsAgain(1);
|
|
|
surveyScreenResult.setOriginCode(code);
|
|
|
surveyScreenResult.setSource(1);
|
|
|
surveyScreenResult.setScreenResultScore(0);
|
|
|
surveyScreenResultDao.save(surveyScreenResult);
|
|
|
return code;
|
|
|
}
|
|
|
|
|
|
|
|
|
public String updateScreenAndSaveAnswer(String patientCode,String screenCode, JSONObject jsonData)throws Exception{
|
|
|
System.out.println("********保存筛查结果--jsonData********* " + jsonData);
|
|
|
String surveyCode = jsonData.get("surveyCode").toString();
|
|
|
SurveyScreenResult surveyScreenResult = surveyScreenResultDao.getSurveyScreenResultByCode(screenCode);
|
|
|
//解析json保存各种答案--获取一维数组
|
|
|
JSONArray questions = jsonData.getJSONArray("questions");
|
|
|
int totalScore = 0;
|
|
|
|
|
|
for (int i = 0; i < questions.length(); i++) {
|
|
|
//获取每一道题的信息
|
|
|
JSONObject question = new JSONObject(questions.get(i).toString());
|
|
|
int type = Integer.parseInt(question.get("type").toString());
|
|
|
if (type != 2) {
|
|
|
if (question.has("options")) {
|
|
|
//获取每道题的所有选项
|
|
|
JSONArray options = question.getJSONArray("options");
|
|
|
for (int j = 0; j < options.length(); j++) {
|
|
|
JSONObject option = new JSONObject(options.get(j).toString());
|
|
|
int score = option.getInt("score");
|
|
|
totalScore += score;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//查询该筛查的结果设置
|
|
|
SurveyTemplateResult surveyTemplateResult = surveyTemplateResultDao.getByTemplateCodeAndLowScoreAndHighScore(surveyCode,totalScore);
|
|
|
/* surveyScreenResult.setOver(1);
|
|
|
surveyScreenResult.setCzrq(new Date());
|
|
|
surveyScreenResult.setScreenResultScore(totalScore);
|
|
|
if (surveyTemplateResult!=null){
|
|
|
surveyScreenResult.setScreenResultCode(surveyTemplateResult.getCode());
|
|
|
surveyScreenResult.setIsDanger(surveyTemplateResult.getWarning());
|
|
|
surveyScreenResult.setScreenResult(surveyTemplateResult.getResult());
|
|
|
}*/
|
|
|
String sql ="UPDATE wlyy_survey_screen_result SET over=1,czrq=?,screen_result_code=?,screen_result=?,screen_result_score=?,is_danger=? WHERE code=?";
|
|
|
jdbcTemplate.update(sql,new Object[]{new Date(),surveyTemplateResult.getCode(),surveyTemplateResult.getResult(),totalScore,surveyTemplateResult.getWarning(),screenCode});
|
|
|
|
|
|
//surveyScreenResultDao.updateScreenAndSaveAnswer(new Date(),totalScore,surveyTemplateResult.getCode(),surveyTemplateResult.getResult(),surveyTemplateResult.getWarning(),screenCode);
|
|
|
managerQuestionnaireService.saveAnswer(patientCode,surveyScreenResult.getCode(),jsonData);
|
|
|
return screenCode;
|
|
|
}
|
|
|
}
|