|
@ -2,10 +2,13 @@ package com.yihu.mm.controller.medicine;
|
|
|
|
|
|
import com.yihu.mm.controller.BaseController;
|
|
import com.yihu.mm.controller.BaseController;
|
|
import com.yihu.mm.entity.patient.PatientExam;
|
|
import com.yihu.mm.entity.patient.PatientExam;
|
|
|
|
import com.yihu.mm.entity.questionnaire.MedicineAnswerLog;
|
|
|
|
import com.yihu.mm.service.MedicineAnswerLogService;
|
|
import com.yihu.mm.service.PatientExamService;
|
|
import com.yihu.mm.service.PatientExamService;
|
|
import com.yihu.mm.service.PatientService;
|
|
import com.yihu.mm.service.PatientService;
|
|
import com.yihu.mm.service.PhysicalExaminationService;
|
|
import com.yihu.mm.service.PhysicalExaminationService;
|
|
import com.yihu.mm.util.HttpClientUtil;
|
|
import com.yihu.mm.util.HttpClientUtil;
|
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiParam;
|
|
import io.swagger.annotations.ApiParam;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@ -19,6 +22,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpSession;
|
|
import javax.servlet.http.HttpSession;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping(value = "/medicine/physicalExamination")
|
|
@RequestMapping(value = "/medicine/physicalExamination")
|
|
@ -35,6 +40,8 @@ public class PhysicalExaminationController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private PhysicalExaminationService physicalExaminationService;
|
|
private PhysicalExaminationService physicalExaminationService;
|
|
|
|
@Autowired
|
|
|
|
private MedicineAnswerLogService medicineAnswerLogService;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private PatientExamService patientExamService;
|
|
private PatientExamService patientExamService;
|
|
@ -47,22 +54,33 @@ public class PhysicalExaminationController extends BaseController {
|
|
HttpServletRequest req
|
|
HttpServletRequest req
|
|
) {
|
|
) {
|
|
HttpSession session = req.getSession();
|
|
HttpSession session = req.getSession();
|
|
String key = (String) session.getAttribute("key");
|
|
|
|
if(StringUtils.isBlank(key)){
|
|
|
|
//通过接口查询key
|
|
|
|
String result = HttpClientUtil.postBody(yuerenApi + "/phonekey", new JSONObject());
|
|
|
|
JSONObject jsonObject = new JSONObject(result);
|
|
|
|
String status = jsonObject.get("status").toString();
|
|
|
|
if ("200".equals(status)) {
|
|
|
|
JSONObject recordset = jsonObject.getJSONObject("recordset");
|
|
|
|
key = recordset.getString("key");
|
|
|
|
}else{
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
session.setMaxInactiveInterval(60*60*4);
|
|
|
|
session.setAttribute("key",key);
|
|
|
|
|
|
String key = (String) session.getAttribute("key");
|
|
|
|
if(StringUtils.isBlank(key)){
|
|
|
|
//通过接口查询key
|
|
|
|
String result = HttpClientUtil.postBody(yuerenApi + "/phonekey", new JSONObject());
|
|
|
|
JSONObject jsonObject = new JSONObject(result);
|
|
|
|
String status = jsonObject.get("status").toString();
|
|
|
|
if ("200".equals(status)) {
|
|
|
|
JSONObject recordset = jsonObject.getJSONObject("recordset");
|
|
|
|
key = recordset.getString("key");
|
|
|
|
}else{
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
session.setMaxInactiveInterval(60*60*4);
|
|
|
|
session.setAttribute("key",key);
|
|
}
|
|
}
|
|
return physicalExaminationService.findExames(key,tp_type, examCode);
|
|
|
|
|
|
String exames = physicalExaminationService.findExames(tp_type, examCode);
|
|
|
|
//if(StringUtils.isNotBlank(examCode)){
|
|
|
|
// JSONObject examJson = new JSONObject(exames);
|
|
|
|
// String exam_status = examJson.get("status").toString();
|
|
|
|
// if ("200".equals(exam_status)) {
|
|
|
|
// JSONObject recordset = examJson.getJSONObject("recordset");
|
|
|
|
// key = recordset.getString("key");
|
|
|
|
// }else{
|
|
|
|
// return result;
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
return exames;
|
|
}
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "新增预约单/获取咨询编号等信息")
|
|
@ApiOperation(value = "新增预约单/获取咨询编号等信息")
|
|
@ -70,9 +88,8 @@ public class PhysicalExaminationController extends BaseController {
|
|
@ResponseBody
|
|
@ResponseBody
|
|
public String insertslip(@ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode, HttpServletRequest req){
|
|
public String insertslip(@ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode, HttpServletRequest req){
|
|
String key = (String) req.getSession().getAttribute("key");
|
|
String key = (String) req.getSession().getAttribute("key");
|
|
//Patient patient = patientService.findByCode(patientCode);
|
|
|
|
//return physicalExaminationService.insertslip(key,patient);
|
|
|
|
return null;
|
|
|
|
|
|
Patient patient = patientService.findByCode(patientCode);
|
|
|
|
return physicalExaminationService.insertslip(patient);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -82,31 +99,42 @@ public class PhysicalExaminationController extends BaseController {
|
|
public String findQuestion(@ApiParam(name = "tp_id", value = "试卷id", required = true)@RequestParam(required = true, name = "tp_id") String tp_id,
|
|
public String findQuestion(@ApiParam(name = "tp_id", value = "试卷id", required = true)@RequestParam(required = true, name = "tp_id") String tp_id,
|
|
@ApiParam(name = "pb_id", value = "问卷编号,第一题为0", required = true)@RequestParam(required = true, name = "pb_id") String pb_id,
|
|
@ApiParam(name = "pb_id", value = "问卷编号,第一题为0", required = true)@RequestParam(required = true, name = "pb_id") String pb_id,
|
|
@ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode,
|
|
@ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode,
|
|
HttpServletRequest req){
|
|
|
|
HttpSession session = req.getSession();
|
|
|
|
String key = (String) session.getAttribute("key");
|
|
|
|
|
|
|
|
|
|
HttpServletRequest req) throws IOException {
|
|
String ct_id="";
|
|
String ct_id="";
|
|
PatientExam patientExam = patientExamService.findByPatientAndTpId(patientCode, tp_id);
|
|
PatientExam patientExam = patientExamService.findByPatientAndTpId(patientCode, tp_id);
|
|
if(patientExam==null){
|
|
if(patientExam==null){
|
|
//Patient patient = patientService.findByCode(patientCode);
|
|
|
|
//String result = physicalExaminationService.insertslip(key, patient);
|
|
|
|
//JSONObject jsonObject = new JSONObject(result);
|
|
|
|
//String status = jsonObject.get("status").toString();
|
|
|
|
//if ("200".equals(status)) {
|
|
|
|
// JSONObject recordset = jsonObject.getJSONObject("recordset");
|
|
|
|
// ct_id = recordset.getString("ct_id");
|
|
|
|
// patientExam = new PatientExam();
|
|
|
|
// patientExam.setCtId(ct_id);
|
|
|
|
// patientExam.setPatient(patientCode);
|
|
|
|
// patientExam.setIsComplete(0);
|
|
|
|
// patientExam.setTpId(tp_id);
|
|
|
|
// patientExamService.save(patientExam);
|
|
|
|
//}else{
|
|
|
|
// return result;
|
|
|
|
//}
|
|
|
|
|
|
Patient patient = patientService.findByCode(patientCode);
|
|
|
|
String result = physicalExaminationService.insertslip(patient);
|
|
|
|
JSONObject jsonObject = new JSONObject(result);
|
|
|
|
String status = jsonObject.get("status").toString();
|
|
|
|
if ("200".equals(status)) {
|
|
|
|
JSONObject recordset = jsonObject.getJSONObject("recordset");
|
|
|
|
ct_id = recordset.get("ct_id").toString();
|
|
|
|
patientExam = new PatientExam();
|
|
|
|
patientExam.setCtId(ct_id);
|
|
|
|
patientExam.setPatient(patientCode);
|
|
|
|
patientExam.setIsComplete(0);
|
|
|
|
patientExam.setTpId(tp_id);
|
|
|
|
patientExamService.save(patientExam);
|
|
|
|
}else{
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
ct_id = patientExam.getCtId();
|
|
|
|
}
|
|
|
|
String question = physicalExaminationService.findQuestion(tp_id, pb_id, ct_id);
|
|
|
|
|
|
|
|
JSONObject jsonQuestion = new JSONObject(question);
|
|
|
|
jsonQuestion.put("answer","");
|
|
|
|
//查找居民是否已经答过该试题
|
|
|
|
MedicineAnswerLog answer = medicineAnswerLogService.findAnswer(patientCode, tp_id, pb_id);
|
|
|
|
if(answer!=null){
|
|
|
|
jsonQuestion.put("answer",answer);
|
|
}
|
|
}
|
|
String question = physicalExaminationService.findQuestion(key, tp_id, pb_id, ct_id);
|
|
|
|
|
|
|
|
|
|
//Map<String, Object> resp = customerService.findServerInfo(patient);
|
|
|
|
//resp.put("patient",patient);
|
|
|
|
//return write(1,"查询成功","data",resp);
|
|
return question;
|
|
return question;
|
|
}
|
|
}
|
|
|
|
|
|
@ -115,14 +143,30 @@ public class PhysicalExaminationController extends BaseController {
|
|
@ResponseBody
|
|
@ResponseBody
|
|
public String handleExam(@ApiParam(name = "tp_id", value = "试卷id", required = true)@RequestParam(required = true, name = "tp_id") String tp_id,
|
|
public String handleExam(@ApiParam(name = "tp_id", value = "试卷id", required = true)@RequestParam(required = true, name = "tp_id") String tp_id,
|
|
@ApiParam(name = "pb_id", value = "问卷编号,第一题为0", required = true)@RequestParam(required = true, name = "pb_id") String pb_id,
|
|
@ApiParam(name = "pb_id", value = "问卷编号,第一题为0", required = true)@RequestParam(required = true, name = "pb_id") String pb_id,
|
|
|
|
@ApiParam(name = "i_multiselect", value = "试题类型(0单选 ,1多选)", required = true)@RequestParam(required = true, name = "i_multiselect") String i_multiselect,
|
|
@ApiParam(name = "dc_answer", value = "问题答案", required = true)@RequestParam(required = true, name = "dc_answer") String dc_answer,
|
|
@ApiParam(name = "dc_answer", value = "问题答案", required = true)@RequestParam(required = true, name = "dc_answer") String dc_answer,
|
|
@ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode,
|
|
@ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode,
|
|
|
|
@ApiParam(name = "isLast", value = "是否是最后一题(0否 ,1是)", required = true)@RequestParam(required = true, name = "isLast") String isLast,
|
|
HttpServletRequest req){
|
|
HttpServletRequest req){
|
|
String key = (String) req.getSession().getAttribute("key");
|
|
|
|
PatientExam patientExam = patientExamService.findByPatientAndTpId(patientCode, tp_id);
|
|
PatientExam patientExam = patientExamService.findByPatientAndTpId(patientCode, tp_id);
|
|
|
|
String tpName = patientExam.getTpName();
|
|
String ct_id = patientExam.getCtId();
|
|
String ct_id = patientExam.getCtId();
|
|
String result = physicalExaminationService.handleExam(key, tp_id, pb_id, dc_answer, ct_id);
|
|
|
|
|
|
String result = physicalExaminationService.handleExam(tp_id, pb_id, dc_answer, ct_id);
|
|
|
|
|
|
|
|
//将答案保存到自己数据库
|
|
|
|
MedicineAnswerLog medicineAnswerLog = new MedicineAnswerLog();
|
|
|
|
medicineAnswerLog.setPatientCode(patientCode);
|
|
|
|
medicineAnswerLog.setTpId(tp_id);
|
|
|
|
medicineAnswerLog.setTpName(tpName);
|
|
|
|
medicineAnswerLog.setPbType(String.valueOf(i_multiselect));
|
|
|
|
medicineAnswerLog.setCreateTime(new Date());
|
|
|
|
medicineAnswerLog.setProblems(dc_answer);
|
|
|
|
medicineAnswerLogService.save(medicineAnswerLog);
|
|
|
|
|
|
|
|
//最后一题
|
|
|
|
if("1".equals(isLast)){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
@ -142,6 +186,9 @@ public class PhysicalExaminationController extends BaseController {
|
|
@RequestMapping(value = "/findconconhealth",produces="application/json;charset=UTF-8")
|
|
@RequestMapping(value = "/findconconhealth",produces="application/json;charset=UTF-8")
|
|
@ResponseBody
|
|
@ResponseBody
|
|
public String findconconhealth(@ApiParam(name = "ct_id", value = "咨询编号", required = true)@RequestParam(required = true, name = "ct_id") String ct_id){
|
|
public String findconconhealth(@ApiParam(name = "ct_id", value = "咨询编号", required = true)@RequestParam(required = true, name = "ct_id") String ct_id){
|
|
|
|
String result = physicalExaminationService.findconconhealth(ct_id);
|
|
|
|
|
|
|
|
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|