Commit 9c6586a7abeb39ad20e0890d1b2d570d9e6396ff

Authored by wtt
1 parent 7b8e14b926

患者登记

Showing 10 changed files with 1177 additions and 0 deletions

platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/IPatientRegistrationDao.java View file @ 9c6586a
  1 +package com.lyms.platform.biz.dal;
  2 +
  3 +import com.lyms.platform.common.dao.operator.MongoQuery;
  4 +import com.lyms.platform.pojo.PatientRegistrationModel;
  5 +
  6 +import java.util.List;
  7 +
  8 +/**
  9 + * 患者登记 dao
  10 + *
  11 + * @Author: 武涛涛
  12 + * @Date: 2020/8/12 16:50
  13 + */
  14 +public interface IPatientRegistrationDao {
  15 +
  16 + /**
  17 + * 新增 患者登记
  18 + *
  19 + * @param obj
  20 + * @Author: 武涛涛
  21 + */
  22 + public PatientRegistrationModel add(PatientRegistrationModel obj);
  23 +
  24 + /**
  25 + * 更新 患者登记
  26 + * @param obj
  27 + * @param id
  28 + */
  29 + public void update(PatientRegistrationModel obj, String id);
  30 + /**
  31 + * 获取 患者登记 列表
  32 + *
  33 + * @param query
  34 + * @Author: 武涛涛
  35 + */
  36 + public List<PatientRegistrationModel> queryList(MongoQuery query);
  37 +
  38 + /**
  39 + * 获取总条数
  40 + * @param mongoQuery
  41 + * @return
  42 + */
  43 + int queryCount(MongoQuery mongoQuery);
  44 +
  45 + /**
  46 + * 获取单条记录
  47 + *
  48 + * @param query
  49 + * @Author: 武涛涛
  50 + */
  51 + public PatientRegistrationModel queryById(MongoQuery query);
  52 +
  53 +
  54 +
  55 +}
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/dal/impl/PatientRegistrationDaoImpl.java View file @ 9c6586a
  1 +package com.lyms.platform.biz.dal.impl;
  2 +
  3 +import com.lyms.platform.biz.dal.IPatientRegistrationDao;
  4 +import com.lyms.platform.common.dao.BaseMongoDAOImpl;
  5 +import com.lyms.platform.common.dao.operator.MongoCondition;
  6 +import com.lyms.platform.common.dao.operator.MongoOper;
  7 +import com.lyms.platform.common.dao.operator.MongoQuery;
  8 +import com.lyms.platform.pojo.PatientRegistrationModel;
  9 +import org.springframework.stereotype.Repository;
  10 +
  11 +import java.util.List;
  12 +
  13 +@Repository("patientRegistrationDao")
  14 +public class PatientRegistrationDaoImpl extends BaseMongoDAOImpl<PatientRegistrationModel> implements IPatientRegistrationDao {
  15 +
  16 + @Override
  17 + public PatientRegistrationModel add(PatientRegistrationModel obj) {
  18 + return save(obj);
  19 + }
  20 +
  21 + @Override
  22 + public void update(PatientRegistrationModel obj, String id) {
  23 + update(new MongoQuery(new MongoCondition("id", id, MongoOper.IS)).convertToMongoQuery(), obj);
  24 + }
  25 +
  26 + @Override
  27 + public List<PatientRegistrationModel> queryList(MongoQuery query) {
  28 + return find(query.convertToMongoQuery());
  29 + }
  30 +
  31 + @Override
  32 + public int queryCount(MongoQuery mongoQuery) {
  33 + return (int) count(mongoQuery.convertToMongoQuery());
  34 + }
  35 +
  36 + @Override
  37 + public PatientRegistrationModel queryById(MongoQuery query) {
  38 + return findOne(query.convertToMongoQuery());
  39 + }
  40 +}
platform-biz-patient-service/src/main/java/com/lyms/platform/biz/service/PatientRegistrationService.java View file @ 9c6586a
  1 +package com.lyms.platform.biz.service;
  2 +
  3 +import com.lyms.platform.biz.dal.IPatientRegistrationDao;
  4 +import com.lyms.platform.common.dao.operator.MongoQuery;
  5 +import com.lyms.platform.common.enums.YnEnums;
  6 +import com.lyms.platform.pojo.PatientRegistrationModel;
  7 +import com.lyms.platform.query.PatientRegistrationModelQuery;
  8 +import org.apache.commons.lang.StringUtils;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.data.domain.Sort;
  11 +import org.springframework.stereotype.Service;
  12 +
  13 +import java.util.List;
  14 +
  15 +
  16 +@Service("patientRegistrationService")
  17 +public class PatientRegistrationService {
  18 +
  19 + @Autowired
  20 + private IPatientRegistrationDao patientRegistrationDao;
  21 +
  22 + /**
  23 + * 新增
  24 + * @param model
  25 + * @Author: 武涛涛
  26 + */
  27 + public PatientRegistrationModel add(PatientRegistrationModel model) {
  28 + return patientRegistrationDao.add(model);
  29 +
  30 + }
  31 +
  32 + /**
  33 + * 更新
  34 + * @param model
  35 + * @param id 根据id更新
  36 + * @Author: 武涛涛
  37 + */
  38 + public void update(PatientRegistrationModel model, String id) {
  39 + patientRegistrationDao.update(model,id);
  40 + }
  41 +
  42 + /**
  43 + * 删除
  44 + * @param id
  45 + * @Author: 武涛涛
  46 + */
  47 + public void deleteById(String id) {
  48 + PatientRegistrationModel obj = new PatientRegistrationModel();
  49 + obj.setYn(YnEnums.NO.getId());
  50 + obj.setId(id);
  51 + patientRegistrationDao.update(obj, id);
  52 + }
  53 + /**
  54 + * 查询单人,所有记录
  55 + * @Author: 武涛涛
  56 + */
  57 + public List<PatientRegistrationModel> queryListOne(PatientRegistrationModelQuery modelQuery) {
  58 + MongoQuery query = modelQuery.convertToQuery();
  59 + if (StringUtils.isNotEmpty(modelQuery.getNeed())) {
  60 + modelQuery.mysqlBuild(patientRegistrationDao.queryCount(modelQuery.convertToQuery()));
  61 + query.start(modelQuery.getOffset()).end(modelQuery.getLimit());
  62 + }
  63 + return patientRegistrationDao.queryList( query.addOrder(Sort.Direction.ASC,"checkDate"));
  64 +
  65 + }
  66 +
  67 + /**
  68 + * 查询全部,所有记录
  69 + * @param babyQuery
  70 + * @Author: 武涛涛
  71 + */
  72 + public List<PatientRegistrationModel> queryListAll(PatientRegistrationModelQuery babyQuery) {
  73 + MongoQuery query = babyQuery.convertToQuery();
  74 + if (StringUtils.isNotEmpty(babyQuery.getNeed())) {
  75 + babyQuery.mysqlBuild(patientRegistrationDao.queryCount(babyQuery.convertToQuery()));
  76 + query.start(babyQuery.getOffset()).end(babyQuery.getLimit());
  77 + }
  78 + return patientRegistrationDao.queryList(query.addOrder(Sort.Direction.DESC,"createDate"));
  79 + }
  80 +
  81 + /**
  82 + * 获取单条记录
  83 + * @param id
  84 + * @Author: 武涛涛
  85 + */
  86 + public PatientRegistrationModel queryById(String id) {
  87 + PatientRegistrationModelQuery babyQuery = new PatientRegistrationModelQuery();
  88 + babyQuery.setId(id);
  89 + MongoQuery query = babyQuery.convertToQuery();
  90 + return patientRegistrationDao.queryById(query.addOrder(Sort.Direction.ASC,"created"));
  91 + }
  92 +
  93 +
  94 +
  95 +
  96 +
  97 +}
platform-dal/src/main/java/com/lyms/platform/beans/SerialIdEnum.java View file @ 9c6586a
... ... @@ -20,6 +20,7 @@
20 20 BabyCheckModel("BabyCheckModel", 97531000070L),
21 21 BabySpecialDiseaseClinicModel("BabySpecialDiseaseClinicModel", -3921222841669886929L),
22 22 BabyPsychologistModel("BabyPsychologistModel", -2259889579698922924L),
  23 + PatientRegistrationModel("PatientRegistrationModel", 3848300584553259979L),
23 24 BabyNutritionSpecialtyModel("BabyNutritionSpecialtyModel", 3787637966909666630L),
24 25 BabyHighRiskBabyModel("BabyHighRiskBabyModel", -6200948004986994005L),
25 26 BreastModel("BreastModel", -6071802354656821905L),
platform-dal/src/main/java/com/lyms/platform/pojo/PatientRegistrationModel.java View file @ 9c6586a
  1 +package com.lyms.platform.pojo;
  2 +
  3 +import com.lyms.platform.beans.SerialIdEnum;
  4 +import com.lyms.platform.common.result.BaseModel;
  5 +import org.springframework.data.mongodb.core.mapping.Document;
  6 +import java.util.Date;
  7 +
  8 +/**
  9 + * 患者登记 实体类
  10 + * @Author: 武涛涛
  11 + */
  12 +@Document(collection = "lyms_patient_registration")
  13 +public class PatientRegistrationModel extends BaseModel {
  14 + private static final long serialVersionUID = SerialIdEnum.PatientRegistrationModel.getCid();
  15 +
  16 + /*基础信息*/
  17 + private String id;
  18 + private Integer yn;
  19 + private Date createDate;
  20 + private Date modifyDate;
  21 + private String hospitalId;
  22 +
  23 + /*表单信息*/
  24 + //姓名
  25 + private String name;
  26 + //手机号码
  27 + private String phone;
  28 + //是否在我院建档 1是 2 不是
  29 + private String type;
  30 + //末次月经
  31 + private Date lastMenses;
  32 +
  33 + public String getId() {
  34 + return id;
  35 + }
  36 +
  37 + public void setId(String id) {
  38 + this.id = id;
  39 + }
  40 +
  41 + public Integer getYn() {
  42 + return yn;
  43 + }
  44 +
  45 + public void setYn(Integer yn) {
  46 + this.yn = yn;
  47 + }
  48 +
  49 + public Date getCreateDate() {
  50 + return createDate;
  51 + }
  52 +
  53 + public void setCreateDate(Date createDate) {
  54 + this.createDate = createDate;
  55 + }
  56 +
  57 + public Date getModifyDate() {
  58 + return modifyDate;
  59 + }
  60 +
  61 + public void setModifyDate(Date modifyDate) {
  62 + this.modifyDate = modifyDate;
  63 + }
  64 +
  65 + public String getHospitalId() {
  66 + return hospitalId;
  67 + }
  68 +
  69 + public void setHospitalId(String hospitalId) {
  70 + this.hospitalId = hospitalId;
  71 + }
  72 +
  73 + public String getName() {
  74 + return name;
  75 + }
  76 +
  77 + public void setName(String name) {
  78 + this.name = name;
  79 + }
  80 +
  81 + public String getPhone() {
  82 + return phone;
  83 + }
  84 +
  85 + public void setPhone(String phone) {
  86 + this.phone = phone;
  87 + }
  88 +
  89 + public String getType() {
  90 + return type;
  91 + }
  92 +
  93 + public void setType(String type) {
  94 + this.type = type;
  95 + }
  96 +
  97 + public Date getLastMenses() {
  98 + return lastMenses;
  99 + }
  100 +
  101 + public void setLastMenses(Date lastMenses) {
  102 + this.lastMenses = lastMenses;
  103 + }
  104 +}
platform-dal/src/main/java/com/lyms/platform/query/PatientRegistrationModelQuery.java View file @ 9c6586a
  1 +package com.lyms.platform.query;
  2 +
  3 +import com.lyms.platform.common.base.IConvertToNativeQuery;
  4 +import com.lyms.platform.common.core.annotation.form.FormParam;
  5 +import com.lyms.platform.common.dao.BaseQuery;
  6 +import com.lyms.platform.common.dao.operator.MongoCondition;
  7 +import com.lyms.platform.common.dao.operator.MongoOper;
  8 +import com.lyms.platform.common.dao.operator.MongoQuery;
  9 +import com.lyms.platform.common.utils.StringUtils;
  10 +import org.hibernate.validator.constraints.NotEmpty;
  11 +import org.springframework.data.mongodb.core.query.Criteria;
  12 +
  13 +import java.util.Date;
  14 +
  15 +/**
  16 + * 患者登记 查询模型
  17 + */
  18 +public class PatientRegistrationModelQuery extends BaseQuery implements IConvertToNativeQuery {
  19 +
  20 + private String id;
  21 + private Integer yn;
  22 + @FormParam
  23 + @NotEmpty(message = "医院ID不能为空")
  24 + private String hospitalId;
  25 + //姓名
  26 + private String name;
  27 + //手机号码
  28 + private String phone;
  29 + //是否在我院建档 1是 2 不是
  30 + private String type;
  31 +
  32 + private String queryNo;
  33 + //末次月经
  34 + private Date lastMensesStart;
  35 + private Date lastMensesEnd;
  36 +
  37 + //登记时间
  38 + private Date createDateStart;
  39 + private Date createDateEnd;
  40 +
  41 + private String sort;
  42 +
  43 + public String getQueryNo() {
  44 + return queryNo;
  45 + }
  46 +
  47 + public void setQueryNo(String queryNo) {
  48 + this.queryNo = queryNo;
  49 + }
  50 +
  51 + public Date getCreateDateStart() {
  52 + return createDateStart;
  53 + }
  54 +
  55 + public void setCreateDateStart(Date createDateStart) {
  56 + this.createDateStart = createDateStart;
  57 + }
  58 +
  59 + public Date getCreateDateEnd() {
  60 + return createDateEnd;
  61 + }
  62 +
  63 + public void setCreateDateEnd(Date createDateEnd) {
  64 + this.createDateEnd = createDateEnd;
  65 + }
  66 +
  67 + public String getId() {
  68 + return id;
  69 + }
  70 +
  71 + public void setId(String id) {
  72 + this.id = id;
  73 + }
  74 +
  75 + public Integer getYn() {
  76 + return yn;
  77 + }
  78 +
  79 + public void setYn(Integer yn) {
  80 + this.yn = yn;
  81 + }
  82 +
  83 + public String getHospitalId() {
  84 + return hospitalId;
  85 + }
  86 +
  87 + public void setHospitalId(String hospitalId) {
  88 + this.hospitalId = hospitalId;
  89 + }
  90 +
  91 + public String getName() {
  92 + return name;
  93 + }
  94 +
  95 + public void setName(String name) {
  96 + this.name = name;
  97 + }
  98 +
  99 + public String getPhone() {
  100 + return phone;
  101 + }
  102 +
  103 + public void setPhone(String phone) {
  104 + this.phone = phone;
  105 + }
  106 +
  107 + public String getType() {
  108 + return type;
  109 + }
  110 +
  111 + public void setType(String type) {
  112 + this.type = type;
  113 + }
  114 +
  115 + public Date getLastMensesStart() {
  116 + return lastMensesStart;
  117 + }
  118 +
  119 + public void setLastMensesStart(Date lastMensesStart) {
  120 + this.lastMensesStart = lastMensesStart;
  121 + }
  122 +
  123 + public Date getLastMensesEnd() {
  124 + return lastMensesEnd;
  125 + }
  126 +
  127 + public void setLastMensesEnd(Date lastMensesEnd) {
  128 + this.lastMensesEnd = lastMensesEnd;
  129 + }
  130 +
  131 + @Override
  132 + public String getSort() {
  133 + return sort;
  134 + }
  135 +
  136 + @Override
  137 + public void setSort(String sort) {
  138 + this.sort = sort;
  139 + }
  140 +
  141 + @Override
  142 + public MongoQuery convertToQuery() {
  143 + MongoCondition condition = MongoCondition.newInstance();
  144 +
  145 + if (StringUtils.isNotEmpty(id)) {
  146 + condition = condition.and("id", id, MongoOper.IS);
  147 + }
  148 + if (null != yn) {
  149 + condition = condition.and("yn", yn, MongoOper.IS);
  150 + }
  151 +
  152 + if (StringUtils.isNotEmpty(name)) {
  153 +
  154 + condition = condition.and("name", name, MongoOper.IS);
  155 + }
  156 + // 就诊卡号
  157 + if (StringUtils.isNotEmpty(phone)) {
  158 +
  159 + condition = condition.and("phone", phone, MongoOper.IS);
  160 + }
  161 +
  162 + //检查医生
  163 + if (StringUtils.isNotEmpty(type)) {
  164 +
  165 + condition = condition.and("type", type, MongoOper.IS);
  166 + }
  167 +
  168 +
  169 +
  170 + Criteria c = null;
  171 + // 末次月经
  172 + if (null != lastMensesStart) {
  173 + if (null != c) {
  174 + c = c.and("lastMenses").gte(lastMensesStart);
  175 + } else {
  176 + c = Criteria.where("lastMenses").gte(lastMensesStart);
  177 + }
  178 + }
  179 + if (null != lastMensesEnd) {
  180 + if (null != c) {
  181 + c = c.lte(lastMensesEnd);
  182 + } else {
  183 + c = Criteria.where("lastMenses").lte(lastMensesEnd);
  184 + }
  185 + }
  186 + // 登记时间
  187 + if (null != createDateStart) {
  188 + if (null != c) {
  189 + c = c.and("createDate").gte(createDateStart);
  190 + } else {
  191 + c = Criteria.where("createDate").gte(createDateStart);
  192 + }
  193 + }
  194 + if (null != createDateEnd) {
  195 + if (null != c) {
  196 + c = c.lte(createDateEnd);
  197 + } else {
  198 + c = Criteria.where("createDate").lte(createDateEnd);
  199 + }
  200 + }
  201 +
  202 +
  203 + // 查询号
  204 + if (StringUtils.isNotEmpty(queryNo)) {
  205 + MongoCondition c1 = MongoCondition.newInstance();
  206 + MongoCondition con1 = MongoCondition.newInstance("name", queryNo, MongoOper.LIKE);
  207 + MongoCondition con2 = MongoCondition.newInstance("phone", queryNo, MongoOper.IS);
  208 + if (c != null) {
  209 + c1.orCondition(new MongoCondition[]{con1, con2, }).getCriteria();
  210 + condition.andCondition(c1);
  211 + } else {
  212 + c = c1.orCondition(new MongoCondition[]{con1, con2}).getCriteria();
  213 + }
  214 + }
  215 + if (c != null) {
  216 + return new MongoCondition(c.andOperator(condition.getCriteria())).toMongoQuery();
  217 + }
  218 +
  219 + return condition.toMongoQuery();
  220 + }
  221 +
  222 +
  223 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PatientRegistrationController.java View file @ 9c6586a
  1 +package com.lyms.platform.operate.web.controller;
  2 +
  3 +
  4 +import com.lyms.platform.common.annotation.TokenRequired;
  5 +import com.lyms.platform.common.base.BaseController;
  6 +import com.lyms.platform.common.base.LoginContext;
  7 +import com.lyms.platform.common.constants.ErrorCodeConstants;
  8 +import com.lyms.platform.common.result.BaseResponse;
  9 +import com.lyms.platform.common.utils.StringUtils;
  10 +import com.lyms.platform.operate.web.facade.PatientRegistrationFacade;
  11 +import com.lyms.platform.operate.web.request.PatientRegistrationRequest;
  12 +import com.lyms.platform.query.PatientRegistrationModelQuery;
  13 +import org.springframework.beans.factory.annotation.Autowired;
  14 +import org.springframework.stereotype.Controller;
  15 +import org.springframework.web.bind.annotation.*;
  16 +
  17 +import javax.servlet.http.HttpServletRequest;
  18 +import javax.servlet.http.HttpServletResponse;
  19 +import javax.validation.Valid;
  20 +
  21 +
  22 +/**
  23 + * 患者登记 控制
  24 + */
  25 +@Controller
  26 +public class PatientRegistrationController extends BaseController {
  27 +
  28 + @Autowired
  29 + private PatientRegistrationFacade patientRegistrationFacade;
  30 +
  31 +
  32 + /**
  33 + * 添加或者修改
  34 + *
  35 + * @param request
  36 + * @return
  37 + */
  38 + @RequestMapping(method = RequestMethod.POST, value = "/addOrUpPatientRegistration")
  39 + @ResponseBody
  40 + public BaseResponse addPatientRegistration(@Valid @RequestBody PatientRegistrationRequest request, HttpServletRequest httpServletRequest) {
  41 + if (request != null && !StringUtils.isEmpty(request.getId())) {
  42 + BaseResponse baseResponse = patientRegistrationFacade.update(request);
  43 + return baseResponse;
  44 + }
  45 + BaseResponse baseResponse = patientRegistrationFacade.add(request);
  46 + return baseResponse;
  47 + }
  48 +
  49 + /**
  50 + * 删除
  51 + * @param id
  52 + * @return
  53 + */
  54 + @RequestMapping(value = "/deletePatientRegistrationById/{id}", method = RequestMethod.DELETE)
  55 + @ResponseBody
  56 +// @TokenRequired
  57 + public BaseResponse deletePatientRegistrationById(@PathVariable("id") String id, HttpServletRequest request) {
  58 + patientRegistrationFacade.deleteBabyPsychologistById(id);
  59 + return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功");
  60 + }
  61 +
  62 + /**
  63 + * 查看使用
  64 + * @param id
  65 + * @return
  66 + */
  67 + @RequestMapping(value = "/queryPatientRegistrationShow/{id}", method = RequestMethod.GET)
  68 + @ResponseBody
  69 + public BaseResponse queryPatientRegistrationShow(@PathVariable("id") String id) {
  70 + return patientRegistrationFacade.queryPatientRegistrationShow(id);
  71 +
  72 + }
  73 + /**
  74 + * 编辑使用
  75 + * @param id
  76 + * @return
  77 + */
  78 + @RequestMapping(value = "/queryPatientRegistrationEdit/{id}", method = RequestMethod.GET)
  79 + @ResponseBody
  80 + public BaseResponse queryPatientRegistrationEdit(@PathVariable("id") String id) {
  81 + return patientRegistrationFacade.queryPatientRegistrationEdit(id);
  82 + }
  83 +
  84 + /**
  85 + * 查询单人所有记录
  86 + * @param
  87 + */
  88 + @RequestMapping(value = "/queryPatientRegistrationListOne", method = RequestMethod.GET)
  89 + @ResponseBody
  90 + public BaseResponse queryPatientRegistrationListOne(PatientRegistrationModelQuery modelQuery, HttpServletRequest request) {
  91 + return patientRegistrationFacade.queryPatientRegistrationListOne(modelQuery);
  92 + }
  93 +
  94 + /**
  95 + * 查询全部所有记录
  96 + * @param
  97 + */
  98 + @RequestMapping(value = "/queryPatientRegistrationListAll", method = RequestMethod.GET)
  99 + @ResponseBody
  100 + public BaseResponse queryPatientRegistrationListAll(@Valid PatientRegistrationModelQuery modelQuery, HttpServletRequest request) {
  101 + return patientRegistrationFacade.queryPatientRegistrationListAll(modelQuery);
  102 + }
  103 +
  104 +
  105 + /**
  106 + * 导出
  107 + * @Author: 武涛涛
  108 + */
  109 + @RequestMapping(value = "/exportPatientRegistration", method = RequestMethod.GET)
  110 + public void exportPatientRegistration(@Valid PatientRegistrationModelQuery modelQuery, HttpServletRequest request, HttpServletResponse response) {
  111 + patientRegistrationFacade.exportPatientRegistration(modelQuery,response);
  112 + }
  113 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientRegistrationFacade.java View file @ 9c6586a
  1 +package com.lyms.platform.operate.web.facade;
  2 +
  3 +import com.lyms.platform.biz.service.PatientRegistrationService;
  4 +import com.lyms.platform.common.constants.ErrorCodeConstants;
  5 +import com.lyms.platform.common.enums.YnEnums;
  6 +import com.lyms.platform.common.result.BaseListResponse;
  7 +import com.lyms.platform.common.result.BaseObjectResponse;
  8 +import com.lyms.platform.common.result.BaseResponse;
  9 +import com.lyms.platform.common.utils.DateUtil;
  10 +import com.lyms.platform.common.utils.ExcelUtil;
  11 +import com.lyms.platform.common.utils.ExceptionUtils;
  12 +import com.lyms.platform.common.utils.StringUtils;
  13 +import com.lyms.platform.operate.web.request.PatientRegistrationRequest;
  14 +import com.lyms.platform.operate.web.request.RiskPatientsQueryRequest;
  15 +import com.lyms.platform.operate.web.result.PatientRegistrationResult;
  16 +import com.lyms.platform.operate.web.service.impl.BaseServiceImpl;
  17 +import com.lyms.platform.operate.web.utils.CollectionUtils;
  18 +import com.lyms.platform.operate.web.utils.CommonsHelper;
  19 +import com.lyms.platform.operate.web.utils.MongoUtil;
  20 +import com.lyms.platform.permission.service.OrganizationService;
  21 +import com.lyms.platform.permission.service.UsersService;
  22 +import com.lyms.platform.pojo.PatientRegistrationModel;
  23 +import com.lyms.platform.query.PatientRegistrationModelQuery;
  24 +import org.springframework.beans.factory.annotation.Autowired;
  25 +import org.springframework.stereotype.Component;
  26 +
  27 +import javax.servlet.http.HttpServletResponse;
  28 +import java.io.OutputStream;
  29 +import java.util.*;
  30 +
  31 +/**
  32 + * 患者登记 逻辑处理
  33 + *
  34 + * @Author: 武涛涛
  35 + */
  36 +@Component
  37 +public class PatientRegistrationFacade extends BaseServiceImpl {
  38 +
  39 + @Autowired
  40 + private PatientRegistrationService patientRegistrationService;
  41 +
  42 + @Autowired
  43 + private MongoUtil mongoUtil;
  44 +
  45 + @Autowired
  46 + private AutoMatchFacade autoMatchFacade;
  47 +
  48 + @Autowired
  49 + private OrganizationService organizationService;
  50 +
  51 + @Autowired
  52 + private UsersService usersService;
  53 +
  54 + /**
  55 + * 构造保存对象
  56 + *
  57 + * @param request
  58 + * @return
  59 + */
  60 + private PatientRegistrationModel getPatientRegistrationModel(PatientRegistrationRequest request) {
  61 +
  62 + PatientRegistrationModel model = new PatientRegistrationModel();
  63 + model.setYn(YnEnums.YES.getId());
  64 + model.setModifyDate(new Date());
  65 + model.setName(request.getName());
  66 + model.setPhone(request.getPhone());
  67 + model.setType(request.getType());
  68 + model.setLastMenses(DateUtil.parseYMD(request.getLastMenses()));
  69 + return model;
  70 +
  71 + }
  72 +
  73 + /**
  74 + * 新增 患者登记
  75 + * @param request
  76 + * @Author: 武涛涛
  77 + */
  78 + public BaseResponse add(PatientRegistrationRequest request) {
  79 +// String hospitalId = autoMatchFacade.getHospitalId(userId);
  80 + List<PatientRegistrationModel> patientRegistrationModels = null;
  81 + //判断该手机号存在信息
  82 + if (StringUtils.isNotEmpty(request.getPhone())) {
  83 + PatientRegistrationModelQuery modelQuery = new PatientRegistrationModelQuery();
  84 + modelQuery.setYn(YnEnums.YES.getId());
  85 + modelQuery.setHospitalId(request.getHospitalId());
  86 + modelQuery.setPhone(request.getPhone());
  87 + modelQuery.setSort("ASC");
  88 + patientRegistrationModels = patientRegistrationService.queryListOne(modelQuery);
  89 + }
  90 + BaseObjectResponse br = new BaseObjectResponse();
  91 + if(CollectionUtils.isEmpty(patientRegistrationModels)){
  92 + PatientRegistrationModel model = getPatientRegistrationModel(request);
  93 + model.setCreateDate(new Date());
  94 + model.setHospitalId(request.getHospitalId());
  95 + model = patientRegistrationService.add(model);
  96 + br.setErrorcode(ErrorCodeConstants.SUCCESS);
  97 + br.setErrormsg("成功");
  98 + br.setData(model.getId());
  99 + }else {
  100 + br.setErrorcode(ErrorCodeConstants.DATA_EXIST);
  101 + br.setErrormsg("数据已存在");
  102 + br.setData(patientRegistrationModels.get(0));
  103 + }
  104 + return br;
  105 + }
  106 +
  107 + /**
  108 + * 更新 患者登记
  109 + * @param request
  110 + * @Author: 武涛涛
  111 + */
  112 + public BaseResponse update(PatientRegistrationRequest request) {
  113 + //当前登录人医院Id
  114 + PatientRegistrationModel model = getPatientRegistrationModel(request);
  115 + PatientRegistrationModel models = patientRegistrationService.queryById(request.getId());
  116 + if (models != null && models.getId() != null) {
  117 + patientRegistrationService.update(model, request.getId());
  118 + }
  119 + return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功");
  120 + }
  121 +
  122 + /**
  123 + * 删除
  124 + * @param id
  125 + */
  126 + public void deleteBabyPsychologistById(String id) {
  127 + //String hospitalId = autoMatchFacade.getHospitalId(userId);
  128 + PatientRegistrationModel model = patientRegistrationService.queryById(id);
  129 + if (model != null && model.getId() != null) {
  130 + patientRegistrationService.deleteById(id);
  131 + }
  132 + }
  133 +
  134 +
  135 + /**
  136 + * 根据专病id,,查看使用
  137 + *
  138 + * @Author: 武涛涛
  139 + */
  140 + public BaseObjectResponse queryPatientRegistrationShow(String id) {
  141 +
  142 + BaseObjectResponse br = new BaseObjectResponse();
  143 + if (StringUtils.isNotEmpty(id)) {
  144 + PatientRegistrationModel model = patientRegistrationService.queryById(id);
  145 + PatientRegistrationResult result = new PatientRegistrationResult();
  146 + result.convertToResult(model);
  147 + /*if (StringUtils.isNotEmpty(model.getCheckDoctor())) {
  148 + Users users = usersService.getUsers(NumberUtils.toInt(model.getCheckDoctor()));
  149 + if (users != null && StringUtils.isNotEmpty(users.getName())) {
  150 + babyPsychologistResult.setCheckDoctor(users.getName());
  151 + }
  152 + }*/
  153 + if (StringUtils.isNotEmpty(model.getHospitalId())) {
  154 + result.setHospitalName(CommonsHelper.getHospitalName(model.getHospitalId(), organizationService));
  155 + }
  156 + br.setData(result);
  157 + br.setErrorcode(ErrorCodeConstants.SUCCESS);
  158 + br.setErrormsg("成功");
  159 + }
  160 + return br;
  161 + }
  162 +
  163 + /**
  164 + * 根据专病id,编辑使用
  165 + * @Author: 武涛涛
  166 + */
  167 + public BaseObjectResponse queryPatientRegistrationEdit(String id) {
  168 +
  169 + BaseObjectResponse br = new BaseObjectResponse();
  170 + if (StringUtils.isNotEmpty(id)) {
  171 + PatientRegistrationModel model = patientRegistrationService.queryById(id);
  172 + PatientRegistrationResult result = new PatientRegistrationResult();
  173 + result.convertToResult(model);
  174 + br.setData(result);
  175 + br.setErrorcode(ErrorCodeConstants.SUCCESS);
  176 + br.setErrormsg("成功");
  177 + }
  178 + return br;
  179 + }
  180 +
  181 + /**
  182 + * 查询单人所有记录
  183 + * getPhone
  184 + * @Author: 武涛涛
  185 + */
  186 + public BaseObjectResponse queryPatientRegistrationListOne(PatientRegistrationModelQuery modelQuery) {
  187 +
  188 + BaseObjectResponse br = new BaseObjectResponse();
  189 +// String hospitalId = autoMatchFacade.getHospitalId(userId);
  190 + List <PatientRegistrationResult> results = new ArrayList <>();
  191 + try {
  192 + //单人多条记录
  193 + List <PatientRegistrationModel> patientRegistrationModels = new ArrayList <>();
  194 + if (StringUtils.isNotEmpty(modelQuery.getPhone())) {
  195 + modelQuery.setYn(YnEnums.YES.getId());
  196 + modelQuery.setHospitalId(modelQuery.getHospitalId());
  197 + modelQuery.setSort("ASC");
  198 + patientRegistrationModels = patientRegistrationService.queryListOne(modelQuery);
  199 + }
  200 + for (int i = 0; i < patientRegistrationModels.size(); i++) {
  201 + PatientRegistrationModel patientRegistrationModel = patientRegistrationModels.get(i);
  202 + PatientRegistrationResult result = new PatientRegistrationResult();
  203 + if (patientRegistrationModel != null) {
  204 + result.convertToResult(patientRegistrationModel);
  205 + if (StringUtils.isNotEmpty(patientRegistrationModel.getHospitalId())) {
  206 + result.setHospitalName(CommonsHelper.getHospitalName(patientRegistrationModel.getHospitalId(), organizationService));
  207 + }
  208 + results.add(result);
  209 + }
  210 + }
  211 + } catch (Exception e) {
  212 + e.printStackTrace();
  213 + }
  214 + br.setData(results);
  215 + br.setPageInfo(modelQuery.getPageInfo());
  216 + br.setErrorcode(ErrorCodeConstants.SUCCESS);
  217 + br.setErrormsg("成功");
  218 + return br;
  219 +
  220 + }
  221 +
  222 + /**
  223 + * 查询全部所有记录
  224 + * @Author: 武涛涛
  225 + */
  226 + public BaseListResponse queryPatientRegistrationListAll(PatientRegistrationModelQuery modelQuery) {
  227 +
  228 + BaseListResponse br = new BaseListResponse();
  229 +// String hospitalId = autoMatchFacade.getHospitalId(userId);
  230 + List <PatientRegistrationResult> results = new ArrayList <>();
  231 + try {
  232 + //单人多条专病记录
  233 + List <PatientRegistrationModel> patientRegistrationModels = new ArrayList <>();
  234 +
  235 + modelQuery.setNeed("true");
  236 + modelQuery.setYn(YnEnums.YES.getId());
  237 + modelQuery.setHospitalId(modelQuery.getHospitalId());
  238 + modelQuery.setSort(null);
  239 + if (modelQuery.getLastMensesEnd() != null) {
  240 + modelQuery.setLastMensesEnd(DateUtil.getDayLastSecond(modelQuery.getLastMensesEnd()));
  241 + }
  242 + if (modelQuery.getCreateDateEnd() != null) {
  243 + modelQuery.setCreateDateEnd(DateUtil.getDayLastSecond(modelQuery.getCreateDateEnd()));
  244 + }
  245 + patientRegistrationModels = patientRegistrationService.queryListAll(modelQuery);
  246 + System.out.println(modelQuery.convertToQuery().convertToMongoQuery());
  247 +
  248 + for (int i = 0; i < patientRegistrationModels.size(); i++) {
  249 + PatientRegistrationModel patientRegistrationModel = patientRegistrationModels.get(i);
  250 + PatientRegistrationResult result = new PatientRegistrationResult();
  251 + if (patientRegistrationModel != null) {
  252 + result.convertToResult(patientRegistrationModel);
  253 + if (StringUtils.isNotEmpty(patientRegistrationModel.getHospitalId())) {
  254 + result.setHospitalName(CommonsHelper.getHospitalName(patientRegistrationModel.getHospitalId(), organizationService));
  255 + }
  256 + results.add(result);
  257 + }
  258 + }
  259 + } catch (Exception e) {
  260 + e.printStackTrace();
  261 + }
  262 + br.setData(results);
  263 + br.setPageInfo(modelQuery.getPageInfo());
  264 + br.setErrorcode(ErrorCodeConstants.SUCCESS);
  265 + br.setErrormsg("成功");
  266 + return br;
  267 +
  268 + }
  269 +
  270 + public void exportPatientRegistration(PatientRegistrationModelQuery modelQuery, HttpServletResponse response) {
  271 +
  272 + try {
  273 + BaseListResponse listResponse = (BaseListResponse) queryPatientRegistrationListAll(modelQuery);
  274 + List <PatientRegistrationResult> list = listResponse.getData();
  275 + List<Map<String, Object>> datas = new ArrayList<>();
  276 +
  277 + if (org.apache.commons.collections.CollectionUtils.isNotEmpty(list)) {
  278 + for (PatientRegistrationResult patientRegistrationResult : list) {
  279 + Map m = new HashMap<>();
  280 + //导出: 姓名 手机号码 是否在我院建档 末次月经 登记时间
  281 + m.put("name",patientRegistrationResult.getName());
  282 + m.put("phone",patientRegistrationResult.getPhone() );
  283 + m.put("type",StringUtils.isNotEmpty(patientRegistrationResult.getType()) ? ("1".equals(patientRegistrationResult.getType())?"是":"否" ):"_");
  284 + m.put("lastMenses",patientRegistrationResult.getLastMenses() );
  285 + m.put("createDate",patientRegistrationResult.getCreateDate() );
  286 + datas.add(m);
  287 + }
  288 + }
  289 + OutputStream out = response.getOutputStream();
  290 + Map<String, String> cnames = new LinkedHashMap<>();
  291 + cnamesMap(cnames);
  292 + response.setContentType("application/octet-stream");
  293 + response.setCharacterEncoding("UTF-8");
  294 + response.setHeader("Content-Disposition", "attachment;fileName=" + "导出.xls");
  295 + ExcelUtil.toExcel(out, datas, cnames);
  296 + } catch (Exception e) {
  297 + e.printStackTrace();
  298 + ExceptionUtils.catchException(e, "导出异常");
  299 + }
  300 +
  301 + }
  302 + private void cnamesMap(Map<String, String> cnames) {
  303 + cnames.put("name", "姓名");
  304 + cnames.put("phone", "手机号码");
  305 + cnames.put("type", "是否在我院建档");
  306 + cnames.put("lastMenses", "末次月经");
  307 + cnames.put("createDate", "登记时间");
  308 + }
  309 +
  310 +
  311 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/PatientRegistrationRequest.java View file @ 9c6586a
  1 +package com.lyms.platform.operate.web.request;
  2 +
  3 +import com.lyms.platform.common.core.annotation.form.FormParam;
  4 +import org.hibernate.validator.constraints.NotEmpty;
  5 +
  6 +/**
  7 + * 患者登记 入参类
  8 + */
  9 +public class PatientRegistrationRequest {
  10 + /*基础信息*/
  11 + private String id;
  12 + private Integer yn;
  13 + private String createDate;
  14 + private String modifyDate;
  15 + @FormParam
  16 + @NotEmpty(message = "医院ID不能为空")
  17 + private String hospitalId;
  18 + private String HospitalName;
  19 +
  20 + /*表单信息*/
  21 + //姓名
  22 + private String name;
  23 + //手机号码
  24 + @FormParam
  25 + @NotEmpty(message = "手机号吗不能为空")
  26 + private String phone;
  27 + //是否在我院建档 1是 2 不是
  28 + private String type;
  29 + //末次月经
  30 + private String lastMenses;
  31 +
  32 + public String getId() {
  33 + return id;
  34 + }
  35 +
  36 + public void setId(String id) {
  37 + this.id = id;
  38 + }
  39 +
  40 + public String getHospitalName() {
  41 + return HospitalName;
  42 + }
  43 +
  44 + public void setHospitalName(String hospitalName) {
  45 + HospitalName = hospitalName;
  46 + }
  47 +
  48 + public Integer getYn() {
  49 + return yn;
  50 + }
  51 +
  52 + public void setYn(Integer yn) {
  53 + this.yn = yn;
  54 + }
  55 +
  56 + public String getCreateDate() {
  57 + return createDate;
  58 + }
  59 +
  60 + public void setCreateDate(String createDate) {
  61 + this.createDate = createDate;
  62 + }
  63 +
  64 + public String getModifyDate() {
  65 + return modifyDate;
  66 + }
  67 +
  68 + public void setModifyDate(String modifyDate) {
  69 + this.modifyDate = modifyDate;
  70 + }
  71 +
  72 + public String getHospitalId() {
  73 + return hospitalId;
  74 + }
  75 +
  76 + public void setHospitalId(String hospitalId) {
  77 + this.hospitalId = hospitalId;
  78 + }
  79 +
  80 + public String getName() {
  81 + return name;
  82 + }
  83 +
  84 + public void setName(String name) {
  85 + this.name = name;
  86 + }
  87 +
  88 + public String getPhone() {
  89 + return phone;
  90 + }
  91 +
  92 + public void setPhone(String phone) {
  93 + this.phone = phone;
  94 + }
  95 +
  96 + public String getType() {
  97 + return type;
  98 + }
  99 +
  100 + public void setType(String type) {
  101 + this.type = type;
  102 + }
  103 +
  104 + public String getLastMenses() {
  105 + return lastMenses;
  106 + }
  107 +
  108 + public void setLastMenses(String lastMenses) {
  109 + this.lastMenses = lastMenses;
  110 + }
  111 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/PatientRegistrationResult.java View file @ 9c6586a
  1 +package com.lyms.platform.operate.web.result;
  2 +
  3 +import com.lyms.platform.common.base.IBasicResultConvert;
  4 +import com.lyms.platform.common.utils.DateUtil;
  5 +import com.lyms.platform.pojo.PatientRegistrationModel;
  6 +
  7 +public class PatientRegistrationResult implements IBasicResultConvert<PatientRegistrationResult, PatientRegistrationModel> {
  8 +
  9 + /*基础信息*/
  10 + private String id;
  11 + private Integer yn;
  12 + private String createDate;
  13 + private String modifyDate;
  14 + private String hospitalId;
  15 + private String HospitalName;
  16 +
  17 + /*表单信息*/
  18 + //姓名
  19 + private String name;
  20 + //手机号码
  21 + private String phone;
  22 + //是否在我院建档 1是 2 不是
  23 + private String type;
  24 + //末次月经
  25 + private String lastMenses;
  26 +
  27 + public String getId() {
  28 + return id;
  29 + }
  30 +
  31 + public void setId(String id) {
  32 + this.id = id;
  33 + }
  34 +
  35 + public Integer getYn() {
  36 + return yn;
  37 + }
  38 +
  39 + public void setYn(Integer yn) {
  40 + this.yn = yn;
  41 + }
  42 +
  43 + public String getHospitalName() {
  44 + return HospitalName;
  45 + }
  46 +
  47 + public void setHospitalName(String hospitalName) {
  48 + HospitalName = hospitalName;
  49 + }
  50 +
  51 + public String getCreateDate() {
  52 + return createDate;
  53 + }
  54 +
  55 + public void setCreateDate(String createDate) {
  56 + this.createDate = createDate;
  57 + }
  58 +
  59 + public String getModifyDate() {
  60 + return modifyDate;
  61 + }
  62 +
  63 + public void setModifyDate(String modifyDate) {
  64 + this.modifyDate = modifyDate;
  65 + }
  66 +
  67 + public String getHospitalId() {
  68 + return hospitalId;
  69 + }
  70 +
  71 + public void setHospitalId(String hospitalId) {
  72 + this.hospitalId = hospitalId;
  73 + }
  74 +
  75 + public String getName() {
  76 + return name;
  77 + }
  78 +
  79 + public void setName(String name) {
  80 + this.name = name;
  81 + }
  82 +
  83 + public String getPhone() {
  84 + return phone;
  85 + }
  86 +
  87 + public void setPhone(String phone) {
  88 + this.phone = phone;
  89 + }
  90 +
  91 + public String getType() {
  92 + return type;
  93 + }
  94 +
  95 + public void setType(String type) {
  96 + this.type = type;
  97 + }
  98 +
  99 + public String getLastMenses() {
  100 + return lastMenses;
  101 + }
  102 +
  103 + public void setLastMenses(String lastMenses) {
  104 + this.lastMenses = lastMenses;
  105 + }
  106 +
  107 + @Override
  108 + public PatientRegistrationResult convertToResult(PatientRegistrationModel destModel) {
  109 +
  110 + setYn(destModel.getYn());
  111 + setModifyDate(DateUtil.getYyyyMmDd(destModel.getModifyDate()));
  112 + setCreateDate(DateUtil.getYyyyMmDd(destModel.getCreateDate()));
  113 + setName(destModel.getName());
  114 + setPhone(destModel.getPhone());
  115 + setType(destModel.getType());
  116 + setLastMenses(DateUtil.getYyyyMmDd(destModel.getLastMenses()));
  117 + setHospitalId(destModel.getHospitalId());
  118 + return this;
  119 + }
  120 +
  121 +
  122 +}