From 827b7580f61d7f20f54a26c3b6101d91e3f3de5e Mon Sep 17 00:00:00 2001 From: liquanyu Date: Wed, 19 Sep 2018 13:42:47 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=AE=E5=8D=B7=E8=B0=83=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/lyms/platform/biz/dal/IQuestionDao.java | 7 + .../platform/biz/dal/impl/QuestionDaoImpl.java | 13 ++ .../lyms/platform/biz/service/QuestionService.java | 17 +++ .../lyms/platform/common/enums/QuestionEnums.java | 87 +++++++++++-- .../java/com/lyms/platform/pojo/QuestionModel.java | 16 ++- .../com/lyms/platform/query/QuestionQuery.java | 142 +++++++++++++++++++++ .../operate/web/controller/QuestionController.java | 10 +- .../operate/web/facade/QuestionFacade.java | 92 ++++++++++++- 8 files changed, 368 insertions(+), 16 deletions(-) create mode 100644 platform-dal/src/main/java/com/lyms/platform/query/QuestionQuery.java diff --git a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IQuestionDao.java b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IQuestionDao.java index fff1a86..e020a79 100644 --- a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IQuestionDao.java +++ b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IQuestionDao.java @@ -1,10 +1,17 @@ package com.lyms.platform.biz.dal; +import com.lyms.platform.common.dao.operator.MongoQuery; import com.lyms.platform.pojo.QuestionModel; +import java.util.List; + /** * Created by Administrator on 2018-09-19. */ public interface IQuestionDao { QuestionModel addQuestions(QuestionModel questionModel); + + int queryQuestionsCount(MongoQuery mongoQuery); + + List queryQuestions(MongoQuery created); } diff --git a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/QuestionDaoImpl.java b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/QuestionDaoImpl.java index 2a052c1..d9ef6a3 100644 --- a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/QuestionDaoImpl.java +++ b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/QuestionDaoImpl.java @@ -2,9 +2,12 @@ package com.lyms.platform.biz.dal.impl; import com.lyms.platform.biz.dal.IQuestionDao; import com.lyms.platform.common.dao.BaseMongoDAOImpl; +import com.lyms.platform.common.dao.operator.MongoQuery; import com.lyms.platform.pojo.QuestionModel; import org.springframework.stereotype.Repository; +import java.util.List; + /** * Created by Administrator on 2018-09-19. */ @@ -14,4 +17,14 @@ public class QuestionDaoImpl extends BaseMongoDAOImpl implements public QuestionModel addQuestions(QuestionModel questionModel) { return save(questionModel); } + + @Override + public int queryQuestionsCount(MongoQuery mongoQuery) { + return (int)count(mongoQuery.convertToMongoQuery()); + } + + @Override + public List queryQuestions(MongoQuery mongoQuery) { + return find(mongoQuery.convertToMongoQuery()); + } } diff --git a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/QuestionService.java b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/QuestionService.java index b69d411..857f5a0 100644 --- a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/QuestionService.java +++ b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/QuestionService.java @@ -1,12 +1,18 @@ package com.lyms.platform.biz.service; import com.lyms.platform.biz.dal.IQuestionDao; +import com.lyms.platform.common.dao.operator.MongoQuery; import com.lyms.platform.pojo.QuestionModel; +import com.lyms.platform.query.QuestionQuery; +import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Service; +import java.util.List; + /** */ @@ -21,4 +27,15 @@ public class QuestionService { public QuestionModel addQuestions(QuestionModel questionModel) { return questionDao.addQuestions(questionModel); } + + public List queryQuestions(QuestionQuery questionQuery) { + + MongoQuery query = questionQuery.convertToQuery(); + if (StringUtils.isNotEmpty(questionQuery.getNeed())) { + questionQuery.mysqlBuild(questionDao.queryQuestionsCount(questionQuery.convertToQuery())); + query.start(questionQuery.getOffset()).end(questionQuery.getLimit()); + } + + return questionDao.queryQuestions(query.addOrder(Sort.Direction.DESC, "created")); + } } \ No newline at end of file diff --git a/platform-common/src/main/java/com/lyms/platform/common/enums/QuestionEnums.java b/platform-common/src/main/java/com/lyms/platform/common/enums/QuestionEnums.java index cf6eb96..a627535 100644 --- a/platform-common/src/main/java/com/lyms/platform/common/enums/QuestionEnums.java +++ b/platform-common/src/main/java/com/lyms/platform/common/enums/QuestionEnums.java @@ -1,29 +1,98 @@ package com.lyms.platform.common.enums; - +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** - * 发送日期 - * Created by lqy on 2016/06/27 */ public enum QuestionEnums { - Q1(1,"0-4(没有或极少)","在孕期,孕妇开始出现早孕反应(疲劳,乏力,嗜睡,食欲减退,恶心,呕吐等)。这些都属于怀孕期间正常的表现,通过PHQ-9的测量表的测量分数可看出您身心状体良好,请保持充足的休息,不要剧烈运动,做好孕期检查的工作。"), - Q2(2,"5-9(轻微抑郁)","孕妈妈在怀孕期间可能会出现担心胚胎的发育情况,害怕流产或没有准备好当妈妈的心理压力等情绪问题。这种担心表达了对未出生孩子的爱,但有研究表明长期的消极情绪会对胎儿造成不良影响,所以为了更好的给予爱和被孩子感受到爱,请保持良好的心情,积极乐观的看待事情,保持充足的休息,不要剧烈运动,遵医嘱来院做孕期检查。若自我调节无效果,建议及时来我院弘毅楼三楼围产医学科心理门诊预约心理咨询。"), - Q3(3,"10-14(中等程度)","孕期因体内激素分泌水平变化,身体不适的情况增加,患者的饮食及睡眠情况下降,情绪、认知也会随之受到影响。若出现这种情况,请孕妈妈明确这种情绪及认知是由身体的不适所致,此时需放松心情,及时调整心态,建议写感恩日记。若身体不适请及时来院孕检。若自我调节无效果,建议及时来我院弘毅楼三楼围产医学科心理门诊预约心理咨询。"), - Q4(4,"15-19(较严重抑郁)","亲爱的孕妈妈,根据您的测试,您目前可能会体验到高兴不起来、不愿意动、自觉脑子不好使,记不住事、思考问题困难,觉得脑子空空、变笨了等情况。建议多与家人沟通,调整心态,写感恩日记。若自我调节无效果,建议及时来我院弘毅楼三楼围产医学科心理门诊预约心理咨询。"), - Q5(5,"20-27(严重抑郁)","亲爱的孕妈妈,根据您的测试,您目前可能会有不能集中注意力,焦虑,极端易怒,睡眠不好,非常容易疲劳,或有持续的疲劳感,不停地想吃东西或者毫无食欲,对什么都不感兴趣,总是提不起精神,持续的情绪低落,想哭,情绪起伏很大,喜怒无常,经常想一些不太现实的东西等多种体验,建议您多与家人沟通,调整心态,写感恩日记。若自我调节无效果,建议及时来我院弘毅楼三楼围产医学科心理门诊预约心理咨询。"); + Q1(1,0,4,"0-4(没有或极少)","在孕期,孕妇开始出现早孕反应(疲劳,乏力,嗜睡,食欲减退,恶心,呕吐等)。这些都属于怀孕期间正常的表现,通过PHQ-9的测量表的测量分数可看出您身心状体良好,请保持充足的休息,不要剧烈运动,做好孕期检查的工作。"), + Q2(2,5,9,"5-9(轻微抑郁)","孕妈妈在怀孕期间可能会出现担心胚胎的发育情况,害怕流产或没有准备好当妈妈的心理压力等情绪问题。这种担心表达了对未出生孩子的爱,但有研究表明长期的消极情绪会对胎儿造成不良影响,所以为了更好的给予爱和被孩子感受到爱,请保持良好的心情,积极乐观的看待事情,保持充足的休息,不要剧烈运动,遵医嘱来院做孕期检查。若自我调节无效果,建议及时来我院弘毅楼三楼围产医学科心理门诊预约心理咨询。"), + Q3(3,10,14,"10-14(中等程度)","孕期因体内激素分泌水平变化,身体不适的情况增加,患者的饮食及睡眠情况下降,情绪、认知也会随之受到影响。若出现这种情况,请孕妈妈明确这种情绪及认知是由身体的不适所致,此时需放松心情,及时调整心态,建议写感恩日记。若身体不适请及时来院孕检。若自我调节无效果,建议及时来我院弘毅楼三楼围产医学科心理门诊预约心理咨询。"), + Q4(4,15,19,"15-19(较严重抑郁)","亲爱的孕妈妈,根据您的测试,您目前可能会体验到高兴不起来、不愿意动、自觉脑子不好使,记不住事、思考问题困难,觉得脑子空空、变笨了等情况。建议多与家人沟通,调整心态,写感恩日记。若自我调节无效果,建议及时来我院弘毅楼三楼围产医学科心理门诊预约心理咨询。"), + Q5(5,20,27,"20-27(严重抑郁)","亲爱的孕妈妈,根据您的测试,您目前可能会有不能集中注意力,焦虑,极端易怒,睡眠不好,非常容易疲劳,或有持续的疲劳感,不停地想吃东西或者毫无食欲,对什么都不感兴趣,总是提不起精神,持续的情绪低落,想哭,情绪起伏很大,喜怒无常,经常想一些不太现实的东西等多种体验,建议您多与家人沟通,调整心态,写感恩日记。若自我调节无效果,建议及时来我院弘毅楼三楼围产医学科心理门诊预约心理咨询。"); - QuestionEnums(int id, String title, String content) { + QuestionEnums(int id, Integer start,Integer end,String title, String content) { this.id = id; + this.start = start; + this.end = end; this.title = title; this.content = content; } private int id; private String title; + private Integer start; + private Integer end; private String content; + public static String getContentByScore(Integer score) { + if (score != null) + { + for (QuestionEnums e : QuestionEnums.values()) { + if (score >= e.getStart() && score <= e.getEnd()) + { + return e.getContent(); + } + } + } + return ""; + } + public static String getIdByScore(Integer score) { + if (score != null) + { + for (QuestionEnums e : QuestionEnums.values()) { + if (score >= e.getStart() && score <= e.getEnd()) + { + return e.getId()+""; + } + } + } + return ""; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Integer getStart() { + return start; + } + + public void setStart(Integer start) { + this.start = start; + } + + public Integer getEnd() { + return end; + } + + public void setEnd(Integer end) { + this.end = end; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } } diff --git a/platform-dal/src/main/java/com/lyms/platform/pojo/QuestionModel.java b/platform-dal/src/main/java/com/lyms/platform/pojo/QuestionModel.java index 1f3824b..bb1eaa4 100644 --- a/platform-dal/src/main/java/com/lyms/platform/pojo/QuestionModel.java +++ b/platform-dal/src/main/java/com/lyms/platform/pojo/QuestionModel.java @@ -23,7 +23,7 @@ public class QuestionModel extends BaseModel { private List> questions; //分数 - private int score; + private Integer score; //困难 private String trouble; @@ -40,6 +40,16 @@ public class QuestionModel extends BaseModel { private Date created; private Date modified; + //评估结果id + private String resultId; + + public String getResultId() { + return resultId; + } + + public void setResultId(String resultId) { + this.resultId = resultId; + } public String getId() { return id; @@ -57,11 +67,11 @@ public class QuestionModel extends BaseModel { this.questions = questions; } - public int getScore() { + public Integer getScore() { return score; } - public void setScore(int score) { + public void setScore(Integer score) { this.score = score; } diff --git a/platform-dal/src/main/java/com/lyms/platform/query/QuestionQuery.java b/platform-dal/src/main/java/com/lyms/platform/query/QuestionQuery.java new file mode 100644 index 0000000..73c9f89 --- /dev/null +++ b/platform-dal/src/main/java/com/lyms/platform/query/QuestionQuery.java @@ -0,0 +1,142 @@ +package com.lyms.platform.query; + +import com.lyms.platform.common.base.IConvertToNativeQuery; +import com.lyms.platform.common.dao.BaseQuery; +import com.lyms.platform.common.dao.operator.MongoCondition; +import com.lyms.platform.common.dao.operator.MongoOper; +import com.lyms.platform.common.dao.operator.MongoQuery; +import org.apache.commons.collections.CollectionUtils; +import org.springframework.data.mongodb.core.query.Criteria; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * + */ +public class QuestionQuery extends BaseQuery implements IConvertToNativeQuery { + + private String id; + + //分数 + private Integer score; + + //困难 + private String trouble; + + //调查单位 + private String investHospitalId; + + //调查员 + private String investigator; + + //调查日期 + private Date investDateStart; + private Date investDateEnd; + + private String patientId; + private String resultId; + + @Override + public MongoQuery convertToQuery() { + MongoCondition condition=MongoCondition.newInstance(); + if(null != patientId){ + condition= condition.and("patientId",patientId, MongoOper.IS); + } + if(null != resultId){ + condition= condition.and("resultId",resultId, MongoOper.IS); + } + if(null != investHospitalId){ + condition= condition.and("investHospitalId",investHospitalId, MongoOper.IS); + } + if(null != id){ + condition= condition.and("id",id, MongoOper.IS); + } + if(null != investigator){ + condition= condition.and("investigator",investigator, MongoOper.IS); + } + if(null != trouble){ + condition= condition.and("trouble",trouble, MongoOper.IS); + } + if(null != score){ + condition= condition.and("score",score, MongoOper.IS); + } + Criteria c1 = null; + if (investDateStart != null && investDateEnd != null) { + if (c1 != null) { + c1 = c1.and("investDate").gte(investDateStart).lte(investDateEnd); + } else { + c1 = Criteria.where("investDate").gte(investDateStart).lte(investDateEnd); + } + } + if (null != c1) { + condition = condition.andCondition(new MongoCondition(c1)); + } + return condition.toMongoQuery(); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Integer getScore() { + return score; + } + + public void setScore(Integer score) { + this.score = score; + } + + public String getTrouble() { + return trouble; + } + + public void setTrouble(String trouble) { + this.trouble = trouble; + } + + public String getInvestHospitalId() { + return investHospitalId; + } + + public void setInvestHospitalId(String investHospitalId) { + this.investHospitalId = investHospitalId; + } + + public String getInvestigator() { + return investigator; + } + + public void setInvestigator(String investigator) { + this.investigator = investigator; + } + + public Date getInvestDateStart() { + return investDateStart; + } + + public void setInvestDateStart(Date investDateStart) { + this.investDateStart = investDateStart; + } + + public Date getInvestDateEnd() { + return investDateEnd; + } + + public void setInvestDateEnd(Date investDateEnd) { + this.investDateEnd = investDateEnd; + } + + public String getPatientId() { + return patientId; + } + + public void setPatientId(String patientId) { + this.patientId = patientId; + } +} \ No newline at end of file diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/QuestionController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/QuestionController.java index 856d7a5..cbcde0f 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/QuestionController.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/QuestionController.java @@ -18,7 +18,7 @@ import javax.validation.Valid; * Created by Administrator on 2018-08-06. */ @Controller -@RequestMapping("/assist") +@RequestMapping("/questions") public class QuestionController extends BaseController { @Autowired @@ -38,4 +38,12 @@ public class QuestionController extends BaseController { } + @RequestMapping(method = RequestMethod.GET, value = "/getQuertionByPatientId/{patientId}") + @ResponseBody + public BaseResponse getQuertionByPatientId(@PathVariable String patientId, + HttpServletRequest httpServletRequest) { + return questionFacade.getQuestionByPatientId(patientId); + } + + } diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/QuestionFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/QuestionFacade.java index 2f99f40..95ce545 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/QuestionFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/QuestionFacade.java @@ -1,19 +1,33 @@ package com.lyms.platform.operate.web.facade; +import com.lyms.platform.biz.service.BasicConfigService; +import com.lyms.platform.biz.service.PatientsService; import com.lyms.platform.biz.service.QuestionService; import com.lyms.platform.common.constants.ErrorCodeConstants; +import com.lyms.platform.common.enums.QuestionEnums; +import com.lyms.platform.common.result.BaseObjectResponse; import com.lyms.platform.common.result.BaseResponse; +import com.lyms.platform.common.utils.DateUtil; +import com.lyms.platform.operate.web.utils.CollectionUtils; +import com.lyms.platform.operate.web.utils.CommonsHelper; +import com.lyms.platform.permission.service.OrganizationService; +import com.lyms.platform.permission.service.UsersService; +import com.lyms.platform.pojo.Patients; import com.lyms.platform.pojo.QuestionModel; +import com.lyms.platform.query.QuestionQuery; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** - * 数据访问权限的门面 Created by Administrator on 2016/3/30 0030. */ @Component public class QuestionFacade { @@ -21,13 +35,85 @@ public class QuestionFacade { @Autowired private QuestionService questionService; - public BaseResponse addQuestions(QuestionModel questionModel) { + @Autowired + private PatientsService patientsService; + @Autowired + private OrganizationService organizationService; + + @Autowired + private UsersService usersService; + + @Autowired + private BasicConfigService basicConfigService; + public BaseResponse addQuestions(QuestionModel questionModel) { + questionModel.setCreated(new Date()); + questionModel.setInvestDate(new Date()); + questionModel.setModified(new Date()); + String resultId = QuestionEnums.getIdByScore(questionModel.getScore()); + questionModel.setResultId(resultId); + Patients patients = patientsService.findOnePatientById(questionModel.getPatientId()); + questionModel.setInvestigator(patients.getBookbuildingDoctor()); QuestionModel question = questionService.addQuestions(questionModel); - BaseResponse response = new BaseResponse(); + BaseObjectResponse response = new BaseObjectResponse(); + response.setData(question.getId()); response.setErrormsg("成功"); response.setErrorcode(ErrorCodeConstants.SUCCESS); return response; } + + public BaseResponse getQuestionByPatientId(String patientId) { + + BaseObjectResponse response = new BaseObjectResponse(); + + QuestionQuery questionQuery = new QuestionQuery(); + questionQuery.setPatientId(patientId); + + List questions = questionService.queryQuestions(questionQuery); + if (CollectionUtils.isNotEmpty(questions)) + { + QuestionModel questionModel = questions.get(0); + Map data = new HashMap<>(); + data.put("id",questionModel.getId()); + data.put("patientId",questionModel.getPatientId()); + + Patients patients = patientsService.findOnePatientById(patientId); + data.put("userName",patients.getUsername()); + data.put("cardNo", patients.getCardNo()); + data.put("birth", DateUtil.getyyyy_mm(patients.getBirth())); + data.put("pliveType",CommonsHelper.getName1(patients.getPliveTypeId(), basicConfigService)); + data.put("pnation", CommonsHelper.getName1(patients.getPnationId(), basicConfigService)); + data.put("plevelType", CommonsHelper.getName1(patients.getPlevelTypeId(), basicConfigService)); + + data.put("phone",patients.getPhone()); + data.put("week",DateUtil.getWeek(patients.getLastMenses(),questionModel.getInvestDate())/7); + + data.put("questions",questionModel.getQuestions()); + data.put("trouble",questionModel.getTrouble()); + data.put("score",questionModel.getScore()); + + + data.put("investDate",DateUtil.getyyyy_MM_dd1(questionModel.getInvestDate())); + data.put("investigator", CommonsHelper.getUserName(questionModel.getInvestigator(), usersService)); + data.put("hospital", CommonsHelper.getHospitalName(questionModel.getInvestHospitalId(), organizationService)); + + + data.put("content",QuestionEnums.getContentByScore(questionModel.getScore())); + String diary = ""; + if (questionModel.getScore() != null && questionModel.getScore() > 10) + { + diary= "感恩日记:准备一个专门的笔记本,每天写三件让自己感恩的事情,感恩的事情不分大小。例如感恩自己的坚持、感恩家人的付出、感恩胎儿健康、感恩饭桌上的一菜一汤,感恩今天发生的事情。"; + } + data.put("diary",diary); + + response.setErrormsg("成功"); + response.setErrorcode(ErrorCodeConstants.SUCCESS); + return response; + } + + response.setErrormsg("无调查"); + response.setErrorcode(ErrorCodeConstants.NO_DATA); + return response; + } } \ No newline at end of file -- 1.8.3.1