wangjun 4 лет назад
Родитель
Сommit
90478c9119
24 измененных файлов с 1078 добавлено и 40 удалено
  1. 1 1
      business/base-service/src/main/java/com/yihu/jw/dict/dao/PrivateDictDao.java
  2. 3 2
      business/base-service/src/main/java/com/yihu/jw/dict/service/PrivateDictService.java
  3. 3 0
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/OutpatientDao.java
  4. 41 1
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  5. 2 2
      business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java
  6. 14 0
      business/base-service/src/main/java/com/yihu/jw/patient/dao/BasePatientGroupDao.java
  7. 18 0
      business/base-service/src/main/java/com/yihu/jw/patient/dao/BasePatientGroupDictDao.java
  8. 183 0
      business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientGroupDictService.java
  9. 306 12
      business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientService.java
  10. 110 2
      business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java
  11. 5 1
      common/common-entity/sql记录
  12. 9 2
      common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/PatientMedicareCardDO.java
  13. 10 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageItemDO.java
  14. 67 0
      common/common-entity/src/main/java/com/yihu/jw/entity/patient/BasePatientGroupDO.java
  15. 69 0
      common/common-entity/src/main/java/com/yihu/jw/entity/patient/BasePatientGroupDictDO.java
  16. 11 1
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java
  17. 2 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java
  18. 2 2
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/patient/BasePatientEndpoint.java
  19. 17 2
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/servicePackage/ServicePackageItemEndpoint.java
  20. 7 6
      svr/svr-base/src/main/java/com/yihu/jw/base/service/servicePackage/ServicePackageItemService.java
  21. 158 2
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/account/PatientEndpoint.java
  22. 35 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java
  23. 3 1
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/dict/PrivateDictEndpoint.java
  24. 2 2
      svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/ykyy/YkyyController.java

+ 1 - 1
business/base-service/src/main/java/com/yihu/jw/dict/dao/PrivateDictDao.java

@ -14,5 +14,5 @@ public interface PrivateDictDao extends PagingAndSortingRepository<PrivateDictDO
    @Query("from PrivateDictDO t where t.isDel = 1")
    List<PrivateDictDO> findALL();
    @Query("from PrivateDictDO t where t.dictCode= ?1 and t.isDel = 1")
    List<PrivateDictDO> findoneByCode(String dictCode);
    List<PrivateDictDO> findByDictCodeAndIsDel(String dictCode);
}

+ 3 - 2
business/base-service/src/main/java/com/yihu/jw/dict/service/PrivateDictService.java

@ -23,11 +23,12 @@ public class PrivateDictService extends BaseJpaService<PrivateDictDO, PrivateDic
    private HibenateUtils hibenateUtils;
    //查找隐私策略
    public List<PrivateDictDO> findByHospitalCodeAndDictCode(String dictCode){
        if (StringUtils.isNotBlank(dictCode)){
        return privateDictDao.findByDictCodeAndIsDel(dictCode);
        /*if (StringUtils.isNotBlank(dictCode)){
            return privateDictDao.findoneByCode(dictCode);
        }else {
            return privateDictDao.findALL();
        }
        }*/
    }
    //添加隐私策略
    public MixEnvelop addPrivateDict(String id,String dictCode,String dictName, String dictValue,String hospitalCode,String hospitalName,String imgUrl){

+ 3 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/OutpatientDao.java

@ -92,5 +92,8 @@ public interface OutpatientDao extends PagingAndSortingRepository<WlyyOutpatient
    @Query("from WlyyOutpatientDO a where a.status=0 and a.payStatus =1 order by a.createTime desc")
    List<WlyyOutpatientDO> findDoctorRemindMessage();
    @Query("from WlyyOutpatientDO a where a.status = 0 and a.payStatus =1 and a.doctor=?1 and a.outpatientType =?2 and a.patient=?3")
    List<WlyyOutpatientDO> findByDoctorAndOutpatientType(String doctor,String outpatientType,String patient);
}

+ 41 - 1
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -5863,7 +5863,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
        List<WlyyHospitalSysDictDO> doctorFrontList = wlyyHospitalSysDictDao.findByDictNameOrderBySort("doctorFrontList",orgCode);
        List<Map<String,Object>> frontDoctor = new ArrayList<>();
        if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
            sql= sql.replace("AS \"id\"","");
            sql= sql.replace("AS \"id\"","AS \"ID\"");
        }
        String sqlCharge = "SELECT t.id as \"id\",\n" +
                "\tm.req_fee as \"twfzFee\",\n" +
@ -10415,6 +10415,46 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                    }
                }
            }
            if("xm_zsyy_wx".equalsIgnoreCase(wechatId)){
                /*prescriptionDao.updateCheckStatus(prescriptionId,2,reason,20);*/
                logger.info("作废处方开始" + prescriptionDO.getCheckStatus());
                WlyyOutpatientDO outpatientDO = outpatientDao.findById(prescriptionDO.getOutpatientId());
                DoctorMappingDO doctorMappingDO = doctorMappingService.findMappingCode(outpatientDO.getDoctor(), outpatientDO.getHospital());
                List<WlyyPrescriptionInfoDO> infoDOS = prescriptionInfoDao.findByPrescriptionId(prescriptionId, 1);
                List<WlyyInspectionDO> inspectionDOS = wlyyInspectionDao.findByPrescriptionId(prescriptionId, 1);
                List<WlyyPrescriptionDiagnosisDO> prescriptionDiagnosisDOS = prescriptionDiagnosisDao.findByPrescriptionId(prescriptionId,1);
                List<WlyyPrescriptionExpressageDO> expressageDOS = prescriptionExpressageDao.findByOutpatientId(outpatientDO.getId());
                com.alibaba.fastjson.JSONArray jsonData = new com.alibaba.fastjson.JSONArray();
                for (WlyyPrescriptionInfoDO info : infoDOS) {
                    //设置his药品查询条件
                    setInfoJsonParam(jsonData, doctorMappingDO, outpatientDO, prescriptionDO, info, outpatientDO.getIcd10());
                }
                for (WlyyInspectionDO ins : inspectionDOS) {
                    //设置his药品查询条件
                    setInspectionParam(jsonData, doctorMappingDO, outpatientDO, prescriptionDO, ins, outpatientDO.getIcd10());
                }
                if (expressageDOS!=null&&expressageDOS.size()!=0){
                    WlyyPrescriptionExpressageDO prescriptionExpressageDO = expressageDOS.get(0);
                    if (prescriptionExpressageDO!=null&&prescriptionExpressageDO.getOneselfPickupFlg()==0){
                        for (int i=0;i<jsonData.size();i++){
                            com.alibaba.fastjson.JSONObject object = jsonData.getJSONObject(i);
                            object.put("selfDelivered",0);
                        }
                    }else if (prescriptionExpressageDO!=null&&prescriptionExpressageDO.getOneselfPickupFlg()==1){
                        for (int i=0;i<jsonData.size();i++){
                            com.alibaba.fastjson.JSONObject object = jsonData.getJSONObject(i);
                            object.put("selfDelivered",1);
                        }
                    }
                }
                try {
                    net.sf.json.JSONObject jsonObject = entranceService.BS10112(jsonData.toJSONString(), demoFlag);
                }catch (Exception e){
                    e.printStackTrace();
                    return "删除失败";
                }
            }
            prescriptionDO.setStatus(-1);
            prescriptionDO.setCheckStatus(4);
            prescriptionDO.setCheckReason("已删除");

+ 2 - 2
business/base-service/src/main/java/com/yihu/jw/order/BusinessOrderService.java

@ -1507,7 +1507,7 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
        if (businessOrderDO==null){
            throw new Exception("查不到订单!");
        }
        if (businessOrderDO.getOrderCategory().equalsIgnoreCase("1")){
        if (businessOrderDO.getOrderCategory().equalsIgnoreCase("1")&&0==businessOrderDO.getStatus()){
            if ("0".equalsIgnoreCase(changeflag)){
                ConsultDo consultDo = consultOrderDao.findOne(businessOrderDO.getRelationCode());
                consultDo.setPayStatus(1);
@ -1557,7 +1557,7 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
                    System.out.println("发送企业模板消息成功");
                }
            }
        }else if (businessOrderDO.getOrderCategory().equalsIgnoreCase("2")||businessOrderDO.getOrderCategory().equalsIgnoreCase("3")){
        }else if (businessOrderDO.getOrderCategory().equalsIgnoreCase("2")||businessOrderDO.getOrderCategory().equalsIgnoreCase("3")&&0==businessOrderDO.getStatus()){
            WlyyOutpatientDO wlyyOutpatientDO = outpatientDao.findById(businessOrderDO.getRelationCode());
            wlyyOutpatientDO.setPayStatus(1);
            WlyyOutpatientDO outpatientDO = outpatientDao.save(wlyyOutpatientDO);

+ 14 - 0
business/base-service/src/main/java/com/yihu/jw/patient/dao/BasePatientGroupDao.java

@ -0,0 +1,14 @@
package com.yihu.jw.patient.dao;
import com.yihu.jw.entity.patient.BasePatientGroupDO;
import com.yihu.jw.entity.patient.BasePatientGroupDictDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface BasePatientGroupDao extends PagingAndSortingRepository<BasePatientGroupDO, String>, JpaSpecificationExecutor<BasePatientGroupDO> {
    @Query("from BasePatientGroupDO t where t.doctor=?1 and t.patient=?2 and t.groupId=?3")
    BasePatientGroupDO findOneGroupByDoctorAndPatientAndGroupId(String doctor,String patient,String groupId);
    @Query("select count(1) from BasePatientGroupDO t where t.doctor=?1  and t.groupId=?2")
    int getCountByDoctor(String doctor,String dictId);
}

+ 18 - 0
business/base-service/src/main/java/com/yihu/jw/patient/dao/BasePatientGroupDictDao.java

@ -0,0 +1,18 @@
package com.yihu.jw.patient.dao;
import com.yihu.jw.entity.patient.BasePatientGroupDictDO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface BasePatientGroupDictDao extends PagingAndSortingRepository<BasePatientGroupDictDO, String>, JpaSpecificationExecutor<BasePatientGroupDictDO> {
    Page<BasePatientGroupDictDO> findByCreateUserAndDel(String doctor,String del, Pageable pageable);
    @Query("select count(id) from BasePatientGroupDictDO where createUser=?1 and del='1'")
    int findByDoctorCount(String doctor);
}

+ 183 - 0
business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientGroupDictService.java

@ -0,0 +1,183 @@
package com.yihu.jw.patient.service;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.patient.BasePatientGroupDO;
import com.yihu.jw.entity.patient.BasePatientGroupDictDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientGroupDao;
import com.yihu.jw.patient.dao.BasePatientGroupDictDao;
import com.yihu.jw.patient.dao.BasePatientMedicareCardDao;
import com.yihu.jw.patient.util.ConstantUtils;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Service;
import java.util.*;
@Service
public class BasePatientGroupDictService <T, R extends CrudRepository> extends BaseJpaService<BasePatientGroupDictDO, BasePatientGroupDictDao> {
    @Autowired
    private BasePatientGroupDao basePatientGroupDao;
    @Autowired
    private BasePatientGroupDictDao basePatientGroupDictDao;
    @Autowired
    private BaseDoctorDao basedoctorDao;
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    private HibenateUtils hibenateUtils;
    //创建/修改分组
    public BasePatientGroupDictDO createPatientGroupDict(String dictId,String doctor,String groupCode,String groupName){
        BaseDoctorDO baseDoctorDO = basedoctorDao.findById(doctor);
        BasePatientGroupDictDO basePatientGroupDictDO=null;
        if (StringUtils.isNotBlank(dictId)){
            basePatientGroupDictDO = basePatientGroupDictDao.findOne(dictId);
        }else {
            basePatientGroupDictDO = new BasePatientGroupDictDO();
        }
        if (baseDoctorDO!=null){
            basePatientGroupDictDO.setCreateUser(doctor);
            basePatientGroupDictDO.setCreateUserName(baseDoctorDO.getName());
        }
        basePatientGroupDictDO.setDel("1");
        basePatientGroupDictDO.setCreateTime(new Date());
        basePatientGroupDictDO.setGroupCode(groupCode);
        basePatientGroupDictDO.setGroupName(groupName);
       return basePatientGroupDictDao.save(basePatientGroupDictDO);
    }
    //删除分组
    public BasePatientGroupDictDO delPatientGroupDict(String dictId,String del){
        BasePatientGroupDictDO  basePatientGroupDictDO = basePatientGroupDictDao.findOne(dictId);
        basePatientGroupDictDO.setDel(del);
        return basePatientGroupDictDao.save(basePatientGroupDictDO);
    }
    public MixEnvelop findByDoctor(String doctor,String groupName,Integer page,Integer pageSize){
        Page<BasePatientGroupDictDO> list= basePatientGroupDictDao.findByCreateUserAndDel(doctor,"1",new PageRequest(page-1,pageSize));
        int listCount= basePatientGroupDictDao.findByDoctorCount(doctor);
        MixEnvelop mixEnvelop = new MixEnvelop();
        mixEnvelop.setPageSize(pageSize);
        mixEnvelop.setCurrPage(page+1);
        mixEnvelop.setDetailModelList(list.getContent());
        mixEnvelop.setTotalCount(listCount);
        return mixEnvelop;
    }
    /**
     * 创建分页对象
     * @param page
     * @param size
     * @param sorts
     * @return
     */
    public Pageable creatPage(Integer page, Integer size, String sorts){
        PageRequest pageRequest = null;
        if(null == page || page <= 0){
            page = defaultPage;
        }
        if(null == size || size <= 0){
            size = defaultSize;
        }
        if(!org.apache.commons.lang3.StringUtils.isEmpty(sorts)){
            pageRequest = new PageRequest(page,size,createSort(sorts));
        }else{
            pageRequest = new PageRequest(page,size);
        }
        return pageRequest;
    }
    //将患者移动到指定分组中
    public void movePatientToGroup(String groupId,String patient,String doctor) throws Exception{
        BasePatientGroupDO basePatientGroupDO= basePatientGroupDao.findOneGroupByDoctorAndPatientAndGroupId(doctor,patient,groupId);
        if (basePatientGroupDO==null){
            basePatientGroupDO = new BasePatientGroupDO();
            basePatientGroupDO.setCreateTime(new Date());
            BasePatientDO basePatientDO = basePatientDao.findById(patient);
            if (basePatientDO!=null){
                basePatientGroupDO.setPatient(patient);
                basePatientGroupDO.setPatientName(basePatientDO.getName());
            }
            BaseDoctorDO baseDoctorDO = basedoctorDao.findById(doctor);
            if (baseDoctorDO!=null){
                basePatientGroupDO.setDoctor(doctor);
                basePatientGroupDO.setDoctorName(baseDoctorDO.getName());
            }
            basePatientGroupDO.setGroupId(groupId);
            basePatientGroupDao.save(basePatientGroupDO);
        }else {
            throw  new Exception("该患者已存在该分组中");
        }
    }
    //将患者从指定分组中删除
    public void delPatientGroup(String id) throws Exception{
        BasePatientGroupDO basePatientGroupDO= basePatientGroupDao.findOne(id);
        if (basePatientGroupDO!=null){
            basePatientGroupDao.delete(id);
        }else {
            throw  new Exception("该记录已删除");
        }
    }
    //查询患者分组
    public MixEnvelop findPatientGroup(String patientName,String doctor,String dictId,Integer page,Integer pageSize){
        String sql = "select t.id as \"id\"," +
                "  t.group_id as \"groupId\"," +
                "  t.patient as \"patient\"," +
                "  t.patient_name as \"patientName\"," +
                "  t.doctor as \"doctor\"," +
                "  b.idcard as \"idcard\"," +
                "  t.create_time as \"createTime\"" +
                " from base_patient_group t left join base_patient b " +
                " on t.patient = b.id where b.del = '1'";
        String sqlCount ="select count(1) as \"total\"" +
                " from base_patient_group t left join base_patient b " +
                " on t.patient = b.id where b.del = '1'";
        if (StringUtils.isNoneBlank(patientName)){
            sql +=" and b.name like '%"+patientName+"%'";
            sqlCount +=" and b.name like '%"+patientName+"%'";
        }
        if (StringUtils.isNoneBlank(doctor)){
            sql +=" and t.doctor ='"+doctor+"'";
            sqlCount +=" and t.doctor ='"+doctor+"'";
        }
        if (StringUtils.isNoneBlank(dictId)){
            sql +=" and t.group_id ='"+dictId+"'";
            sqlCount +=" and t.group_id ='"+dictId+"'";
        }
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql ,page,pageSize);
        List<Map<String,Object>> rstotal = hibenateUtils.createSQLQuery(sqlCount);
        Long count = 0L;
        if (rstotal != null && rstotal.size() > 0) {
            count = Long.parseLong(rstotal.get(0).get("total").toString());
        }
        MixEnvelop mixEnvelop = new MixEnvelop();
        mixEnvelop.setTotalCount(count.intValue());
        mixEnvelop.setPageSize(pageSize);
        mixEnvelop.setCurrPage(page);
        mixEnvelop.setDetailModelList(list);
        return mixEnvelop;
    }
    //查询分组患者数量
    public List<Map<String,Object>> findPatientGroupNum(String doctor,String dictIds){
        List<Map<String,Object>> list = new ArrayList<>();
        if (StringUtils.isNoneBlank(dictIds)){
            String[] dictIdGroup = dictIds.split(",");
            for (int i=0;i<dictIdGroup.length;i++){
                int count = basePatientGroupDao.getCountByDoctor(doctor,dictIdGroup[i]);
                Map map = new HashMap();
                map.put(dictIdGroup[i],count);
                list.add(map);
            }
        }
        return list;
    }
}

+ 306 - 12
business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientService.java

@ -2,30 +2,52 @@ package com.yihu.jw.patient.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.hospital.prescription.WlyyInspectionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionInfoDO;
import com.yihu.jw.hospital.prescription.dao.OutpatientDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionInfoDao;
import com.yihu.jw.hospital.prescription.dao.WlyyInspectionDao;
import com.yihu.jw.hospital.prescription.service.PrescriptionService;
import com.yihu.jw.hospital.ykyy.service.YkyyService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientGroupDao;
import com.yihu.jw.patient.dao.BasePatientGroupDictDao;
import com.yihu.jw.patient.util.ConstantUtils;
import com.yihu.jw.restmodel.hospital.prescription.WlyyInspectionVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionInfoVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.utils.hibernate.HibenateUtils;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.security.MD5;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.A;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.repository.CrudRepository;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
/**
 * 
@ -41,6 +63,7 @@ import java.util.Set;
 */
@Service
public class BasePatientService<T, R extends CrudRepository> extends BaseJpaService<BasePatientDO, BasePatientDao> {
    private static final Logger logger = LoggerFactory.getLogger(BasePatientService.class);
    @Autowired
    private BasePatientDao basePatientDao;
@ -59,7 +82,22 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
    private YkyyService ykyyService;
    @Value("${wechat.id}")
    private String wxId;
    @Autowired
    private OutpatientDao outpatientDao;
    @Value("${demo.flag}")
    private boolean demoFlag;
    @Value("${wechat.flag}")
    private boolean flag;
    @Autowired
    private WlyyInspectionDao wlyyInspectionDao;
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired
    private PrescriptionInfoDao prescriptionInfoDao;
    @Autowired
    private BasePatientGroupDao basePatientGroupDao;
    @Autowired
    private BasePatientGroupDictDao basePatientGroupDictDao;
    /**
     * 居民id
     * @param patientId
@ -74,21 +112,23 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
     * @param patientId
     * @return
     */
    public String getPatientById(String patientId) throws Exception{
        JSONObject result = new JSONObject();
    public Map getPatientById(String patientId) throws Exception{
        Map result = new HashMap();
        if(StringUtils.isEmpty(patientId)){
            result.put("result","parameter patientId is null");
            return result.toString();
            return result;
        }
        List<BasePatientDO> patientDOList = this.findByField("id",patientId);
        BasePatientDO basePatientDO = basePatientDao.findById(patientId);
        /*List<BasePatientDO> patientDOList = this.findByField("id",patientId);
        if(CollectionUtils.isEmpty(patientDOList)){
            result.put("result","not exist patient for id:"+patientId);
            return result.toString();
        }
        result.put("patient",patientDOList.get(0));
        }*/
        result.put("patient", basePatientDO);
        List<PatientMedicareCardDO> cards = basePatientMedicardCardService.findPatientCardByCode(patientId);
        result.put("medicareCard",cards);
        return result.toJSONString();
        return result;
    }
@ -263,6 +303,18 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
            basePatientDO1.setTownName(basePatientDO.getTownName());
            basePatientDO1.setCityName(basePatientDO.getCityName());
            basePatientDO1.setMobile(basePatientDO.getMobile());
            basePatientDO1.setRemark(basePatientDO.getRemark());
            basePatientDO1.setLiveCityCode(basePatientDO.getLiveCityCode());
            basePatientDO1.setLiveCityName(basePatientDO.getLiveCityName());
            basePatientDO1.setLiveProvinceCode(basePatientDO.getLiveProvinceCode());
            basePatientDO1.setLiveProvinceName(basePatientDO.getLiveProvinceName());
            basePatientDO1.setLiveStreetCode(basePatientDO.getLiveStreetCode());
            basePatientDO1.setLiveStreetName(basePatientDO.getLiveStreetName());
            basePatientDO1.setLiveTownCode(basePatientDO.getLiveTownCode());
            basePatientDO1.setLiveTownName(basePatientDO.getLiveTownName());
            basePatientDO1.setAddress(basePatientDO.getAddress());
            basePatientDO1.setCommitteeCode(basePatientDO.getCommitteeCode());
            basePatientDO1.setCommitteeName(basePatientDO.getCommitteeName());
            // 保存修改的居民信息
            this.save(basePatientDO1);
        }
@ -272,6 +324,7 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
        for (Object obj : patientMedicareCards) {
            PatientMedicareCardDO card = objectMapper.readValue(obj.toString(), PatientMedicareCardDO.class);
            card.setPatientCode(basePatientDO.getId());
            card.setDel("1");
            if(cardIdList.contains(card.getId())){
                cardIdList.remove(card.getId());
            }
@ -342,5 +395,246 @@ public class BasePatientService<T, R extends CrudRepository> extends BaseJpaServ
        saveDoctorPwlimitDate(id);*/
        return true;
    }
    public Map<String,Object> getPatientCountByDoctor(String doctor,String patient) throws  Exception{
        List<WlyyOutpatientDO> fzList = outpatientDao.findByDoctorAndOutpatientType(doctor,"1",patient);
        List<WlyyOutpatientDO> xtList = outpatientDao.findByDoctorAndOutpatientType(doctor,"2",patient);
        List<WlyyOutpatientDO> zxList = outpatientDao.findByDoctorAndOutpatientType(doctor,"3",patient);
        Map<String,Object> resultMap = new HashMap<>();
        resultMap.put("fzNum",fzList==null?0:fzList.size());
        resultMap.put("xtNum",xtList==null?0:xtList.size());
        resultMap.put("zxNum",zxList==null?0:zxList.size());
        return resultMap;
    }
    //查询电子病历
        public MixEnvelop findEmrByPatientId(String patient,String doctor,Integer page ,Integer pageSize){
        String sql ="select e.id as \"id\"," +
                " e.prescription_id as \"prescriptionId\"," +
                " e.complaint as \"complaint\"," +
                " e.medical_history as \"medicalHistory\"," +
                " e.past_history as \"pastHistory\"," +
                " e.physical_examination as \"physicalExamination\"," +
                " e.assist_examination as \"assistExamination\"," +
                " p.doctor_name as \"doctorName\"," +
                " p.doctor as \"doctor\"," +
                " e.popular_history as \"popularHistory\"," +
                " e.special_history as \"specialHistory\"," +
                " e.create_time as \"createTime\"," +
                " e.allergic_history as \"allergicHistory\"" +
                " from wlyy_prescription_emr e " +
                " left join  wlyy_prescription p on e.prescription_id = p.id" +
                " where p.status >= 20";
        if (StringUtils.isNoneBlank(patient)){
            sql+=" and p.patient_code ='"+patient+"'";
        }
        if (StringUtils.isNoneBlank(doctor)){
            sql+=" and p.doctor ='"+doctor+"'";
        }
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql,page,pageSize);
        MixEnvelop mixEnvelop = new MixEnvelop();
        mixEnvelop.setTotalCount(list==null?0:list.size());
        mixEnvelop.setPageSize(pageSize);
        mixEnvelop.setCurrPage(page);
        mixEnvelop.setDetailModelList(list);
        return mixEnvelop;
    }
    //查询电子病历
   /* public MixEnvelop findPrescriptionByPatientAndDoctor(String patient,String doctor,Integer page ,Integer pageSize){
        String sql ="select p.id as \"id\"," +
                " p.outpatient_id as \"outpatient_id\"," +
                " p.real_order as \"real_order\"," +
                " p.origin_real_order as \"origin_real_order\"," +
                " p.adm_no as \"adm_no\"," +
                " p.origin_adm_no as \"origin_adm_no\"," +
                " p.serial_no as \"serial_no\"," +
                " p.origin_serial_no as \"origin_serial_no\"," +
                " p.type as \"type\"," +
                " p.patient_code as \"patient_code\"," +
                " p.patient_name as \"patient_name\"," +
                " p.status as \"status\"," +
                " p.mk_fail_reason as \"mk_fail_reason\"," +
                " p.idcard as \"idcard\"," +
                " p.idcard as \"idcard\"," +
                " p.idcard as \"idcard\"," +
                " p.idcard as \"idcard\"," +
                " p.idcard as \"idcard\"," +
                " p.idcard as \"idcard\"," +
                " p.idcard as \"idcard\"," +
                " p.idcard as \"idcard\"," +
                " p.idcard as \"idcard\"," +
                " p.idcard as \"idcard\"," +
                " p.ssc as \"ssc\"" +
                " from wlyy_prescription p " +
                " where p.status >= 20";
        if (StringUtils.isNoneBlank(patient)){
            sql+=" and p.patient_code ='"+patient+"'";
        }
        if (StringUtils.isNoneBlank(doctor)){
            sql+=" and p.doctor ='"+doctor+"'";
        }
        List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql,page,pageSize);
        MixEnvelop mixEnvelop = new MixEnvelop();
        mixEnvelop.setTotalCount(list==null?0:list.size());
        mixEnvelop.setPageSize(pageSize);
        mixEnvelop.setCurrPage(page);
        mixEnvelop.setDetailModelList(list);
        return mixEnvelop;
    }*/
    /**
     * 查询患者所有处方信息
     *
     * @param page
     * @param size
     * @return
     */
    public PageEnvelop findPatientAllPrescription(String doctor,String keyName, String status, Integer page, Integer size,String patient,String isSelectDrug) {
        BasePatientDO patientDO = basePatientDao.findById(patient);
        if (patientDO==null){
            return PageEnvelop.getError("找不到该患者",-1);
        }
        StringBuffer sql = new StringBuffer(" SELECT DISTINCT b.*, c.oneself_pickup_flg,f.job_title_code,f.job_title_name  FROM (SELECT a.* FROM wlyy_prescription a left join wlyy_outpatient o ON o.id=a.outpatient_id  WHERE o.consumer = '");
        StringBuffer countSql = new StringBuffer("select COUNT(DISTINCT b.id) count FROM (SELECT a.* FROM wlyy_prescription a left join wlyy_outpatient o ON o.id=a.outpatient_id  WHERE o.consumer = '");
        sql.append(patient).append("') b  LEFT JOIN wlyy_prescription_expressage c ON c.outpatient_id = b.outpatient_id LEFT JOIN base_doctor f ON b.doctor=f.id  ");
        countSql.append(patient).append("') b  LEFT JOIN wlyy_prescription_expressage c ON c.outpatient_id = b.outpatient_id LEFT JOIN base_doctor f ON b.doctor=f.id  ");
        if (StringUtils.isNoneBlank(isSelectDrug)){
            if("0".equalsIgnoreCase(isSelectDrug)){
                sql.append(" left join wlyy_inspection m on b.outpatient_id =m.outpatient_id");
                countSql.append(" left join wlyy_inspection m on b.outpatient_id =m.outpatient_id");
            }
            if ("1".equalsIgnoreCase(isSelectDrug)){
                sql.append(" left join wlyy_prescription_info m on b.id =m.prescription_id");
                countSql.append(" left join wlyy_prescription_info m on b.id =m.prescription_id");
            }
        }
        if (StringUtils.isNotEmpty(status)) {
            status = status.substring(1, status.length() - 1);
            if (StringUtils.isNoneBlank(isSelectDrug)){
                if("0".equalsIgnoreCase(isSelectDrug)){
                    sql.append(" where b.status IN( 9,").append(status).append(")");
                    countSql.append(" where b.status IN( 9,").append(status).append(")");
                }else {
                    sql.append(" where b.status IN(").append(status).append(")");
                    countSql.append(" where b.status IN(").append(status).append(")");
                }
            }else{
                sql.append(" where b.status IN(").append(status).append(")");
                countSql.append(" where b.status IN(").append(status).append(")");
            }
        } else {
            sql.append("  where b.status IN(20,21,30,31,32,100,101)");
            countSql.append(" where b.status IN(20,21,30,31,32,100,101) ");
        }
        if (StringUtils.isNoneBlank(isSelectDrug)){
            if("0".equalsIgnoreCase(isSelectDrug)){
                sql.append(" and m.del =1 ");
                countSql.append(" and m.del =1 ");
            }
            if ("1".equalsIgnoreCase(isSelectDrug)){
                sql.append(" and m.del =1");
                countSql.append(" and m.del =1");
            }
        }
        if (StringUtils.isNotEmpty(keyName)) {
            sql.append(" and (" +
                    " b.doctor_name LIKE '%" + keyName + "%' " +
                    " OR b.dept_name LIKE'%" + keyName + "%' " +
                    " OR b.hospital_name LIKE '%" + keyName + "%' " +
                    " OR d.drug_name LIKE '%" + keyName + "%' " +
                    " OR b.real_order LIKE '%" + keyName + "%' " +
                    ")");
            countSql.append(" and (" +
                    " b.doctor_name LIKE '%" + keyName + "%' " +
                    " OR b.dept_name LIKE'%" + keyName + "%' " +
                    " OR b.hospital_name LIKE '%" + keyName + "%' " +
                    " OR d.drug_name LIKE '%" + keyName + "%' " +
                    " OR b.real_order LIKE '%" + keyName + "%' " +
                    ")");
        }
        if (StringUtils.isNotEmpty(doctor)) {
            sql.append(" and  b.doctor ='" +doctor+"'");
            countSql.append(" and  b.doctor ='" +doctor+"'");
        }
        sql.append(" order by b.prescribe_time DESC ");
        List<WlyyPrescriptionVO> list = null;
        if ("xm_ykyy_wx".equalsIgnoreCase(wxId)) {
            String oracleSql = "SELECT\n" +
                    "\t*\n" +
                    "FROM\n" +
                    "\t(\n" +
                    "\t\tSELECT\n" +
                    "\t\t\tA .*\n" +
                    "\t\tFROM\n" +
                    "\t\t\t(";
            oracleSql += sql.toString();
            oracleSql += "\t\t\t) A\n" +
                    "\t\tWHERE\n" +
                    "  ROWNUM <=" + page * size +
                    "\t) \n" +
                    "WHERE\n" +
                    "\tROWNUM >= " + (page - 1) * size;
            if (flag){
                sql.append("  limit ").append((page - 1) * size).append(",").append(size);
                logger.info("MySql=" + sql.toString());
                list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(WlyyPrescriptionVO.class));
            }else {
                logger.info("oracleSql=" + oracleSql);
                list = jdbcTemplate.query(oracleSql, new BeanPropertyRowMapper<>(WlyyPrescriptionVO.class));
            }
        } else {
//            sql+=" LIMIT  " + (page - 1) * size + "," + size + "";
            sql.append("  limit ").append((page - 1) * size).append(",").append(size);
            logger.info("MySql=" + sql.toString());
            list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(WlyyPrescriptionVO.class));
        }
        for (WlyyPrescriptionVO singlePre:list){
            List<WlyyPrescriptionInfoDO> infoDOs = prescriptionInfoDao.findByPrescriptionId(singlePre.getId(),1);
            logger.info("singlePreId===="+singlePre.getId());
            logger.info("infoDOs"+infoDOs);
            List<WlyyPrescriptionInfoVO> infoVOS = new ArrayList<>();
            convertToModels(infoDOs, infoVOS, WlyyPrescriptionInfoVO.class);
            logger.info("infoVOS"+infoVOS);
            singlePre.setInfoVOs(infoVOS);
            List<WlyyInspectionDO> inspectionDOS = wlyyInspectionDao.findByPrescriptionId(singlePre.getId(),1);
            List<WlyyInspectionVO> inspectionVOS = new ArrayList<>();
            convertToModels(inspectionDOS, inspectionVOS, WlyyInspectionVO.class);
            //BeanUtils.copyProperties(inspectionDOS,inspectionVOS);
            singlePre.setInspectionVOs(inspectionVOS);
        }
//        List<WlyyPrescriptionVO> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(WlyyPrescriptionVO.class));
        logger.info("countSql=" + countSql.toString());
        List<Map<String, Object>> mapList = jdbcTemplate.queryForList(countSql.toString());
        long count = Long.parseLong(mapList.get(0).get("count").toString());
        return PageEnvelop.getSuccessListWithPage(IotRequestMapping.Common.message_success_find, list, page, size, count);
    }
    public Map<String,Object>  findPatientInfoById(String patientId,String doctor){
        String sql = "select b.id as \"id\"," +
                "  b.group_code as \"groupCode\"," +
                "  b.group_name as \"groupName\"" +
                "  from base_patient_group t " +
                " left join base_patient_group_dict b on t.group_id = b.id" +
                " where b.del = '1' and t.patient ='"+patientId+"' and t.doctor ='"+doctor+"'";
        sql+=" group by b.id,b.group_code,b.group_name";
        List<Map<String,Object>> list = hibenateUtils.createSQLQuery(sql);
        String patientSql= "select t.id as \"id\"," +
                " t.name as \"name\"," +
                " t.idcard as \"idcard\"," +
                " t.disease as \"disease\"" +
                "  from base_patient t where t.del = '1' and t.id='"+patientId+"'";
        List<Map<String,Object>> patientInfo = hibenateUtils.createSQLQuery(patientSql);
        if (patientInfo!=null&&patientInfo.size()>0){
            Map<String,Object> patient = patientInfo.get(0);
            String sex = IdCardUtil.getSexForIdcard_new(patient.get("idcard").toString());
            Integer age = IdCardUtil.getAgeForIdcard(patient.get("idcard").toString());
            patient.put("sex",sex);
            patient.put("age",age);
            patient.put("groupList",list);
            return patient;
        }
        return null;
    }
}

+ 110 - 2
business/im-service/src/main/java/com/yihu/jw/im/service/ImService.java

@ -475,13 +475,13 @@ public class ImService {
		if (consultModel == null) {
			throw new Exception("咨询记录不存在!");
		}
		/*try {
		try {
			if (wxId.equalsIgnoreCase("xm_ykyy_wx")){
				prescriptionService.wxTempalteJPush("consult_remind_doctor",null,consultModel,content,"","","");
			}
		}catch (Exception e){
			e.printStackTrace();
		}*/
		}
		if (consultModel.getEndMsgId() != null) {
			throw new Exception("咨询已结束!");
		}
@ -4489,4 +4489,112 @@ public class ImService {
		}
		return mapList;
	}
	/**
	 * 查询医生所有的咨询记录
	 * @param doctor 医生标识
	 * @param type 咨询会话类型 : 0 全部
	 * @param pagesize 分页大小
	 * @return
	 */
	@Transactional(readOnly = true)
	public List<Map<String,Object>>  findRecordByDoctor(String doctor,
																  String type, String patientIdCard,String patientName,
																  int page,int pagesize) throws Exception {
		String  sql = "select DISTINCT t.id as \"id\"," +
				"  t.name as \"name\"," +
				"  t.idcard as \"idcard\"," +
				"  t.mobile as \"mobile\"," +
				"  op.doctor as \"doctor\"," +
				"  op.doctor_name as \"doctorName\"," +
				"  op.outpatient_type as \"outpatientType\"" +
				" from base_patient t left join wlyy_outpatient op " +
				" on t.id = op.patient where t.del ='1' and op.status!= -1";
		if (org.apache.commons.lang3.StringUtils.isNoneBlank(doctor)){
			sql+=" and op.doctor = '"+doctor+"'";
		}
		if (org.apache.commons.lang3.StringUtils.isNoneBlank(patientIdCard)){
			sql+=" and t.idcard like '%"+patientIdCard+"%'";
		}
		if (org.apache.commons.lang3.StringUtils.isNoneBlank(patientName)){
			sql+=" and t.name like '%"+patientName+"%'";
		}
		//咨询类型
		if(!StringUtils.isEmpty(type)){
			if (type.equalsIgnoreCase("1")){
				sql +=" AND  op.outpatient_type = 1";
			}else if (type.equalsIgnoreCase("2")){
				sql +=" AND op.outpatient_type = 2";
			}else if (type.equalsIgnoreCase("3")){
				sql +=" AND  op.outpatient_type = 3";
			}else {
				sql +=" AND op.outpatient_type in (1,2,3) ";
			}
		}
		sql+=" order by op.create_time  ";
		logger.info("findRecordByDoctorSQL==="+sql);
		List<Map<String,Object>>  list = hibenateUtils.createSQLQuery(sql,page,pagesize);
		for (Map<String,Object> map:list){
			if (map.get("idcard")!=null){
				String idcard = map.get("idcard").toString();
				Integer age = IdCardUtil.getAgeForIdcard(idcard);
				String sex = IdCardUtil.getSexForIdcard(idcard);
				map.put("patientAge",age);
				map.put("patientSex",sex);
			}
		}
		return list;
	}
	@Transactional(readOnly = true)
	public List<Map<String,Object>>  findRecordCountByDoctor(String doctor,
														String type, String patientIdCard,String patientName) {
		String[] outpatientType = type.split(",");
		List<Map<String,Object>> resultList = new ArrayList<>();
		for (int i=0;i<outpatientType.length;i++){
			String  sql = "select DISTINCT t.id as \"id\"," +
					"  t.name as \"name\"," +
					"  t.idcard as \"idcard\"," +
					"  t.mobile as \"mobile\"," +
					"  op.doctor as \"doctor\"," +
					"  op.doctor_name as \"doctorName\"," +
					"  op.outpatient_type as \"outpatientType\"" +
					" from base_patient t left join wlyy_outpatient op " +
					" on t.id = op.patient where t.del ='1' and op.status!= -1";
			if (org.apache.commons.lang3.StringUtils.isNoneBlank(doctor)){
				sql+=" and op.doctor = '"+doctor+"'";
			}
			if (org.apache.commons.lang3.StringUtils.isNoneBlank(patientIdCard)){
				sql+=" and t.idcard like '%"+patientIdCard+"%'";
			}
			if (org.apache.commons.lang3.StringUtils.isNoneBlank(patientName)){
				sql+=" and t.name like '%"+patientName+"%'";
			}
			//咨询类型
			String mapKey = "";
			Map map = new HashMap();
			if(!StringUtils.isEmpty(outpatientType[i])){
				if (outpatientType[i].equalsIgnoreCase("1")){
					sql +=" AND  op.outpatient_type = 1";
					mapKey="fzNum";
				}else if (outpatientType[i].equalsIgnoreCase("2")){
					sql +=" AND op.outpatient_type = 2";
					mapKey="xtNum";
				}else if (outpatientType[i].equalsIgnoreCase("3")){
					sql +=" AND  op.outpatient_type = 3";
					mapKey="zxNum";
				}else {
					sql +=" AND op.outpatient_type in (1,2,3) ";
					mapKey="zxNum";
				}
				logger.info("findRecordCountByDoctor==="+sql);
				List<Map<String,Object>>  list = hibenateUtils.createSQLQuery(sql);
				map.put(mapKey,list==null?0:list.size());
			}
			resultList.add(map);
		}
		return resultList;
	}
}

+ 5 - 1
common/common-entity/sql记录

@ -433,4 +433,8 @@ ALTER table base.base_emergency_assistance_order add COLUMN `team_code` varchar(
-- 2021-04-20 wj
alter table base_doctor add doctor_level tinyint(4) DEFAULT NULL COMMENT '类型 1社区医生,2助老员';
alter table base_doctor add doctor_level tinyint(4) DEFAULT NULL COMMENT '类型 1社区医生,2助老员';
-- 2021-04-29 wj
alter table base_patient ADD disease varchar(50) ;
alter table patient_medicare_card ADD medicare_number varchar(50) ;

+ 9 - 2
common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/PatientMedicareCardDO.java

@ -78,7 +78,7 @@ public class PatientMedicareCardDO extends IntegerIdentityEntity {
           this.desc = desc;
       }
   }
    private String medicareNumber;
    /**
	 * 卡标识
	 */
@ -123,9 +123,16 @@ public class PatientMedicareCardDO extends IntegerIdentityEntity {
	 * 状态,0-解除绑定,1-绑定中
	 */
	private String del;
    @Column(name = "medicare_number")
    public String getMedicareNumber() {
        return medicareNumber;
    }
    public void setMedicareNumber(String medicareNumber) {
        this.medicareNumber = medicareNumber;
    }
	@Column(name = "code")
    @Column(name = "code")
    public String getCode() {
        return code;
    }

+ 10 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageItemDO.java

@ -5,6 +5,7 @@ import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.math.BigDecimal;
/**
@ -23,6 +24,7 @@ public class ServicePackageItemDO extends UuidIdentityEntity implements java.io.
    private String orgName;//'机构名称'
    private String introduce;//'服务简介'
    private String del;//是否生效(1 生效,0 失效)
    private String delName;
    private String teamCode;//'服务团队code'
    private String teamName;//'服务团队名称'
    private String createTime;//
@ -143,4 +145,12 @@ public class ServicePackageItemDO extends UuidIdentityEntity implements java.io.
    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }
    @Transient
    public String getDelName() {
        return delName;
    }
    public void setDelName(String delName) {
        this.delName = delName;
    }
}

+ 67 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/patient/BasePatientGroupDO.java

@ -0,0 +1,67 @@
package com.yihu.jw.entity.patient;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
@Entity
@Table(name = "base_patient_group")
public class BasePatientGroupDO extends UuidIdentityEntity {
    private String groupId;
    private String patient;
    private String patientName;
    private String doctor;
    private String doctorName;
    private Date createTime;
    @Column(name = "group_id")
    public String getGroupId() {
        return groupId;
    }
    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "patient_name")
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    @Column(name = "doctor")
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    @Column(name = "doctor_name")
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 69 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/patient/BasePatientGroupDictDO.java

@ -0,0 +1,69 @@
package com.yihu.jw.entity.patient;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
@Entity
@Table(name = "base_patient_group_dict")
public class BasePatientGroupDictDO extends UuidIdentityEntity {
    private String groupCode;
    private String groupName;
    private String del;
    private Date createTime;
    private String createUser;
    private String createUserName;
    @Column(name = "group_code")
    public String getGroupCode() {
        return groupCode;
    }
    public void setGroupCode(String groupCode) {
        this.groupCode = groupCode;
    }
    @Column(name = "group_name")
    public String getGroupName() {
        return groupName;
    }
    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }
    @Column(name = "del")
    public String getDel() {
        return del;
    }
    public void setDel(String del) {
        this.del = del;
    }
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Column(name = "create_user")
    public String getCreateUser() {
        return createUser;
    }
    public void setCreateUser(String createUser) {
        this.createUser = createUser;
    }
    @Column(name = "create_user_name")
    public String getCreateUserName() {
        return createUserName;
    }
    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }
}

+ 11 - 1
common/common-request-mapping/src/main/java/com/yihu/jw/rm/base/BaseRequestMapping.java

@ -509,7 +509,17 @@ public class BaseRequestMapping {
        public static final String GetKey = "getKey";
        public static final String Login = "login";
        public static final String updatePatientPw = "/updatePatientPw";
        public static final String getPatientCountByDoctor  = "/getPatientCountByDoctor";
        public static final String getPatientEmrByDoctor  = "/getPatientEmrByDoctor";
        public static final String findPaitentPrescription  = "/findPaitentPrescription";
        public static final String createPatientGroupDict  = "/createPatientGroupDict";
        public static final String deletePatientGroupDict  = "/deletePatientGroupDict";
        public static final String findGroupByDoctor  = "/findGroupByDoctor";
        public static final String movePatientToGroup  = "/movePatientToGroup";
        public static final String delPatientGroup  = "/delPatientGroup";
        public static final String findPatientGroup  = "/findPatientGroup";
        public static final String findPatientGroupNum  = "/findPatientGroupNum";
        public static final String findOnePatientInfo  = "/findOnePatientInfo";
    }
   /**

+ 2 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -1107,6 +1107,8 @@ public class BaseHospitalRequestMapping {
        public static final String findZlxm = "/findZlxm";
        public static final String findZlxmMx = "/findZlxmMx";
        public static final String getPrevious = "/getPrevious";
        public static final String findRecordByDoctor = "/findRecordByDoctor";
        public static final String findRecordCountByDoctor = "/findRecordCountByDoctor";
    }

+ 2 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/patient/BasePatientEndpoint.java

@ -72,8 +72,8 @@ public class BasePatientEndpoint extends EnvelopRestEndpoint {
    public Envelop getPatientById(
            @ApiParam(name = "id", value = "居民id")
            @RequestParam(value = "id", required = true) String id) throws Exception {
        String result = basePatientService.getPatientById(id);
        return success(result);
        return success(basePatientService.getPatientById(id));
    }
    @GetMapping(value = "findPatientById")

+ 17 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/servicePackage/ServicePackageItemEndpoint.java

@ -1,9 +1,12 @@
package com.yihu.jw.base.endpoint.servicePackage;
import com.alibaba.fastjson.JSONObject;
import com.netflix.discovery.converters.Auto;
import com.yihu.jw.base.service.servicePackage.ServicePackageItemService;
import com.yihu.jw.base.util.ConstantUtils;
import com.yihu.jw.entity.base.servicePackage.ServicePackageItemDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
@ -12,11 +15,15 @@ import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.codec.binary.Base64;
import org.nlpcn.es4sql.domain.From;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
/**
@ -29,6 +36,8 @@ public class ServicePackageItemEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private ServicePackageItemService servicePackageItemService;
    @Autowired
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    @PostMapping(value = "create")
    @ApiOperation(value = "创建")
@ -79,6 +88,14 @@ public class ServicePackageItemEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        List<ServicePackageItemDO> servicePackageItemDOS = servicePackageItemService.search(fields, filters, sorts, page, size);
        for (ServicePackageItemDO servicePackageItemDO:servicePackageItemDOS){
            List<WlyyHospitalSysDictDO> wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findByDictName("isEffect");
            for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO1:wlyyHospitalSysDictDO){
                if (servicePackageItemDO.getDel().equalsIgnoreCase(wlyyHospitalSysDictDO1.getDictCode())){
                    servicePackageItemDO.setDelName(wlyyHospitalSysDictDO1.getDictValue());
                }
            }
        }
        int count = (int)servicePackageItemService.getCount(filters);
        return success(servicePackageItemDOS, count, page, size);
    }
@ -95,6 +112,4 @@ public class ServicePackageItemEndpoint extends EnvelopRestEndpoint {
        List<ServicePackageItemDO> servicePackageItemDOS = servicePackageItemService.search(fields, filters, sorts);
        return success(servicePackageItemDOS);
    }
}

+ 7 - 6
svr/svr-base/src/main/java/com/yihu/jw/base/service/servicePackage/ServicePackageItemService.java

@ -38,12 +38,7 @@ public class ServicePackageItemService extends BaseJpaService<ServicePackageItem
            result.put("response", ConstantUtils.FAIL);
            return result;
        }
       List<ServicePackageItemDO> itemDOList = servicePackageItemDao.findByTeamCode(itemDO.getTeamCode(),itemDO.getCode());
        if(itemDOList!=null&&itemDOList.size()>0){
            result.put("msg","该服务团队已存在此服务项,请勿重复添加");
            result.put("response", ConstantUtils.FAIL);
            return result;
        }
        BaseOrgDO baseOrgDO = baseOrgDao.findByCode(itemDO.getOrgCode());
        if (baseOrgDO!=null){
            itemDO.setOrgName(baseOrgDO.getName());
@ -54,6 +49,12 @@ public class ServicePackageItemService extends BaseJpaService<ServicePackageItem
        }
        if(StringUtil.isEmpty(itemDO.getId())){
            //新增
            List<ServicePackageItemDO> itemDOList = servicePackageItemDao.findByTeamCode(itemDO.getTeamCode(),itemDO.getCode());
            if(itemDOList!=null&&itemDOList.size()>0){
                result.put("msg","该服务团队已存在此服务项,请勿重复添加");
                result.put("response", ConstantUtils.FAIL);
                return result;
            }
            itemDO.setPrice(new BigDecimal(0));
            itemDO.setServicePackageId("system");
            itemDO.setCreateTime(DateUtil.getStringDate());

+ 158 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/account/PatientEndpoint.java

@ -1,7 +1,10 @@
package com.yihu.jw.hospital.endpoint.account;
import com.yihu.jw.patient.service.BasePatientGroupDictService;
import com.yihu.jw.patient.service.BasePatientService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
@ -18,6 +21,8 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private BasePatientService basePatientService;
    @Autowired
    private BasePatientGroupDictService basePatientGroupDictService;
    @GetMapping(value = BaseRequestMapping.BasePatient.getPatientById)
@ -25,8 +30,8 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
    public Envelop getPatientById(
            @ApiParam(name = "id", value = "居民id")
            @RequestParam(value = "id", required = true) String id) throws Exception {
        String result = basePatientService.getPatientById(id);
        return success(result);
        return success(basePatientService.getPatientById(id));
    }
    @PostMapping(value = BaseRequestMapping.BasePatient.updatePatientPw)
@ -45,4 +50,155 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = BaseRequestMapping.BasePatient.getPatientCountByDoctor)
    @ApiOperation(value = "获取居民候诊数量信息")
    public Envelop getPatientCountByDoctor(
            @ApiParam(name = "doctor", value = "doctor")
            @RequestParam(value = "doctor", required = true) String doctor,
            @ApiParam(name = "patient", value = "patient")
            @RequestParam(value = "patient", required = false) String patient) throws Exception {
        return success(basePatientService.getPatientCountByDoctor(doctor,patient));
    }
    @GetMapping(value = BaseRequestMapping.BasePatient.getPatientEmrByDoctor)
    @ApiOperation(value = "获取居民电子病历信息")
    public MixEnvelop getPatientEmrByDoctor(@ApiParam(name = "patient", value = "patient")
                                             @RequestParam(value = "patient", required = false) String patient,
                                            @ApiParam(name = "doctor", value = "doctor")
                                        @RequestParam(value = "doctor", required = false) String doctor,
                                            @ApiParam(name = "page", value = "page")
                                             @RequestParam(value = "page", required = false) Integer page,
                                            @ApiParam(name = "pageSize", value = "pageSize")
                                             @RequestParam(value = "pageSize", required = false) Integer pageSize) throws Exception {
        return basePatientService.findEmrByPatientId(patient,doctor,page,pageSize);
    }
    @GetMapping(value = BaseRequestMapping.BasePatient.findPaitentPrescription)
    @ApiOperation(value = "查询患者所有处方信息", notes = "查询患者所有处方信息")
    public PageEnvelop findPaitentPrescription(@ApiParam(name = "keyName", value = "搜索关键字")
                                                  @RequestParam(value = "keyName", required = false)String keyName,
                                               @ApiParam(name = "patient", value = "患者id")
                                               @RequestParam(value = "patient", required = false)String patient,
                                               @ApiParam(name = "doctor", value = "医生id")
                                                   @RequestParam(value = "doctor", required = false)String doctor,
                                                  @ApiParam(name = "status[]", value = "状态")
                                                  @RequestParam(value = "status[]", required = false)String status,
                                                  @ApiParam(name = "isSelectDrug", value = "1查询处方药品1是0查询检查")
                                                  @RequestParam(value = "isSelectDrug", required = false)String isSelectDrug,
                                                  @ApiParam(name = "page", value = "第几页")
                                                  @RequestParam(value = "page",required = false,defaultValue = "1") Integer page,
                                                  @ApiParam(name = "size", value = "页面大小")
                                                  @RequestParam(value = "size",required = false,defaultValue = "10") Integer size)throws Exception {
        try {
            return basePatientService.findPatientAllPrescription(doctor,keyName,status,page,size,patient,isSelectDrug);
        } catch (Exception e) {
            return PageEnvelop.getError(e.getMessage(),-1);
        }
    }
    @PostMapping(value = BaseRequestMapping.BasePatient.createPatientGroupDict)
    @ApiOperation(value = "创建分组")
    public Envelop createPatientGroupDict(@ApiParam(name = "groupId", value = "groupId")
                                            @RequestParam(value = "groupId", required = false) String groupId,
                                            @ApiParam(name = "doctor", value = "doctor")
                                            @RequestParam(value = "doctor", required = false) String doctor,
                                            @ApiParam(name = "groupCode", value = "groupCode")
                                            @RequestParam(value = "groupCode", required = false) String groupCode,
                                            @ApiParam(name = "groupName", value = "groupName")
                                            @RequestParam(value = "groupName", required = false) String groupName) throws Exception {
        return success(basePatientGroupDictService.createPatientGroupDict(groupId,doctor,groupCode,groupName));
    }
    @GetMapping(value = BaseRequestMapping.BasePatient.deletePatientGroupDict)
    @ApiOperation(value = "删除分组")
    public Envelop deletePatientGroupDict(@ApiParam(name = "groupId", value = "groupId")
                                          @RequestParam(value = "groupId", required = false) String groupId,
                                          @ApiParam(name = "del", value = "del")
                                          @RequestParam(value = "del", required = false) String del) throws Exception {
        return success(basePatientGroupDictService.delPatientGroupDict(groupId,del));
    }
    @GetMapping(value = BaseRequestMapping.BasePatient.findGroupByDoctor)
    @ApiOperation(value = "查询词典")
    public MixEnvelop findByDoctor(@ApiParam(name = "doctor", value = "doctor")
                                          @RequestParam(value = "doctor", required = false) String doctor,
                                          @ApiParam(name = "groupName", value = "groupName")
                                          @RequestParam(value = "groupName", required = false) String groupName,
                                @ApiParam(name = "page", value = "page")
                                    @RequestParam(value = "page", required = false) Integer page,
                                @ApiParam(name = "pageSize", value = "pageSize")
                                    @RequestParam(value = "pageSize", required = false) Integer pageSize) throws Exception {
        return basePatientGroupDictService.findByDoctor(doctor,groupName,page,pageSize);
    }
    @GetMapping(value = BaseRequestMapping.BasePatient.movePatientToGroup)
    @ApiOperation(value = "将患者移动到指定分组中")
    public Envelop movePatientToGroup(@ApiParam(name = "groupId", value = "groupId")
                                   @RequestParam(value = "groupId", required = false) String groupId,
                                   @ApiParam(name = "patient", value = "patient")
                                   @RequestParam(value = "patient", required = false) String patient,
                                   @ApiParam(name = "doctor", value = "doctor")
                                   @RequestParam(value = "doctor", required = false) String doctor)  {
        try {
            basePatientGroupDictService.movePatientToGroup(groupId,patient,doctor);
            return Envelop.getSuccess("操作成功");
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = BaseRequestMapping.BasePatient.delPatientGroup)
    @ApiOperation(value = "删除组中患者")
    public Envelop delPatientGroup(@ApiParam(name = "groupId", value = "groupId")
                                      @RequestParam(value = "groupId", required = false) String groupId)  {
        try {
            basePatientGroupDictService.delPatientGroup(groupId);
            return Envelop.getSuccess("操作成功");
        }catch (Exception e){
            return Envelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = BaseRequestMapping.BasePatient.findPatientGroup)
    @ApiOperation(value = "查询分组患者")
    public MixEnvelop findPatientGroup(@ApiParam(name = "patientName", value = "patientName")
                                   @RequestParam(value = "patientName", required = false) String patientName,
                                   @ApiParam(name = "doctor", value = "doctor")
                                   @RequestParam(value = "doctor", required = false) String doctor,
                                       @ApiParam(name = "groupId", value = "groupId")
                                           @RequestParam(value = "groupId", required = false) String groupId,
                                   @ApiParam(name = "page", value = "page")
                                   @RequestParam(value = "page", required = false) Integer page,
                                   @ApiParam(name = "pageSize", value = "pageSize")
                                   @RequestParam(value = "pageSize", required = false) Integer pageSize) throws Exception {
        return basePatientGroupDictService.findPatientGroup(patientName,doctor,groupId,page,pageSize);
    }
    @GetMapping(value = BaseRequestMapping.BasePatient.findPatientGroupNum)
    @ApiOperation(value = "查询分组患者数量")
    public Envelop findPatientGroupNum(@ApiParam(name = "doctor", value = "doctor")
                                          @RequestParam(value = "doctor", required = false) String doctor,
                                          @ApiParam(name = "groupIds", value = "多个用逗号隔开")
                                          @RequestParam(value = "groupIds", required = false) String groupIds) throws Exception {
        return success(basePatientGroupDictService.findPatientGroupNum(doctor,groupIds));
    }
    @GetMapping(value = BaseRequestMapping.BasePatient.findOnePatientInfo)
    @ApiOperation(value = "查询单个患者信息")
    public Envelop findOnePatientInfo(@ApiParam(name = "doctor", value = "doctor")
                                       @RequestParam(value = "doctor", required = false) String doctor,
                                       @ApiParam(name = "patient", value = "patient")
                                       @RequestParam(value = "patient", required = false) String patient) throws Exception {
        return success(basePatientService.findPatientInfoById(patient,doctor));
    }
}

+ 35 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/consult/DoctorConsultEndpoint.java

@ -1264,11 +1264,45 @@ public class DoctorConsultEndpoint extends EnvelopRestEndpoint {
	@PostMapping(value = BaseHospitalRequestMapping.DodtorIM.getPrevious)
	@ApiOperation(value = "查询病人的电子病历", notes = "查询病人的电子病历")
	public ObjEnvelop findPatientEmr(@ApiParam(name = "patientId", value = "patientId")
								 @RequestParam(value = "patientId", required = true)String patientId)throws Exception {
									 @RequestParam(value = "patientId", required = true)String patientId)throws Exception {
		List<WlyyPrescriptionEmrDO> array= ykyyEntranceService.getPrevious(patientId);
		ObjEnvelop objEnvelop = new ObjEnvelop();
		objEnvelop.setObj(array);
		return objEnvelop;
	}
	@GetMapping (value = BaseHospitalRequestMapping.DodtorIM.findRecordByDoctor)
	@ApiOperation(value = "查询服务患者", notes = "查询服务患者")
	public ObjEnvelop findRecordByDoctor(@ApiParam(name = "doctor", value = "医生id")
											 @RequestParam(value = "doctor",required = false) String doctor,
										 @ApiParam(name = "type", value = "咨询类型")
											 @RequestParam(value = "type",required = true) String type,
										 @ApiParam(name = "patientName", value = "patientName")
											 @RequestParam(value = "patientName",required = false) String patientName,
										 @ApiParam(name = "idcard", value = "idcard")
											 @RequestParam(value = "idcard",required = false) String idcard,
										 @ApiParam(name = "page", value = "第几页")
											 @RequestParam(value = "page",required = false) int page,
										 @ApiParam(name = "pagesize", value = "分页大小")
											 @RequestParam(value = "pagesize",required = false) int pagesize)throws Exception {
		List<Map<String,Object>> list = imService.findRecordByDoctor(doctor,type,idcard,patientName,page,pagesize);
		return ObjEnvelop.getSuccess("操作成功",list);
	}
	@GetMapping (value = BaseHospitalRequestMapping.DodtorIM.findRecordCountByDoctor)
	@ApiOperation(value = "查询服务患者数量", notes = "查询服务患者数量")
	public ObjEnvelop findRecordCountByDoctor(@ApiParam(name = "doctor", value = "医生id")
										 @RequestParam(value = "doctor",required = false) String doctor,
										 @ApiParam(name = "type", value = "咨询类型多个用逗号隔开")
										 @RequestParam(value = "type",required = true) String type,
										 @ApiParam(name = "patientName", value = "patientName")
										 @RequestParam(value = "patientName",required = false) String patientName,
										 @ApiParam(name = "idcard", value = "idcard")
										 @RequestParam(value = "idcard",required = false) String idcard)throws Exception {
		List<Map<String,Object>> list = imService.findRecordCountByDoctor(doctor,type,idcard,patientName);
		return ObjEnvelop.getSuccess("操作成功",list);
	}
}

+ 3 - 1
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/dict/PrivateDictEndpoint.java

@ -41,7 +41,9 @@ public class PrivateDictEndpoint extends EnvelopRestEndpoint {
    @ApiOperation("查询隐私策略")
    @PostMapping(value= BaseHospitalRequestMapping.PatientNoLogin.findPrivateDict)
    public Envelop findPrivateDict(@ApiParam(name = "dictCode", value = "隐私code")
                                    @RequestParam(value = "dictCode", required = false) String dictCode){
                                    @RequestParam(value = "dictCode", required = false) String dictCode,
                                   @ApiParam(name = "hospitalCode", value = "")
                                   @RequestParam(value = "hospitalCode", required = false) String hospitalCode){
        return success(privateDictService.findByHospitalCodeAndDictCode(dictCode));

+ 2 - 2
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/ykyy/YkyyController.java

@ -450,7 +450,7 @@ public class YkyyController extends EnvelopRestEndpoint {
        System.out.println("content======"+content);
        content = content.replace("#","%23");
        System.out.println("转换后content"+content);
        try {
        /*try {
            if (StringUtils.isNoneBlank(content)){
                String url = content.substring(content.lastIndexOf("(")+1,content.lastIndexOf(")"));
                if (StringUtils.isNoneBlank(url)){
@ -478,7 +478,7 @@ public class YkyyController extends EnvelopRestEndpoint {
        }catch (Exception e){
            e.printStackTrace();
            System.out.println("极光消息发送失败");
        }
        }*/
        //ConsultTeamDo consultModel = consultTeamDao.findByConsult(consult);
        String response = enterpriseService.sendMKMesByDoctor(enterpriseId,doctor,content);
        System.out.println("企业模板消息"+response);