Browse Source

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

Conflicts:
	patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java
chenweida 7 years ago
parent
commit
e6c8dbc004

+ 95 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/DoctorMapping.java

@ -0,0 +1,95 @@
package com.yihu.wlyy.entity.doctor;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * 机构映射表
 * @author hzp
 */
@Entity
@Table(name = "wlyy_doctor_mapping")
public class DoctorMapping extends IdEntity {
    // 基卫医生代码
    private String jwDoctor;
    // 基卫医生名称
    private String jwDoctorName;
    // 基卫医生性别
    private String jwDocotrSex;
    // 基卫医生身份证
    private String jwDocotrIdcard;
    // 基卫医生医院
    private String jwDoctorHospital;
    // 基卫医生医院名称
    private String jwDoctorHospiatlName;
    // 医生代码
    private String doctorCode;
    @Column(name="jw_doctor")
    public String getJwDoctor() {
        return jwDoctor;
    }
    public void setJwDoctor(String jwDoctor) {
        this.jwDoctor = jwDoctor;
    }
    @Column(name="jw_doctor_name")
    public String getJwDoctorName() {
        return jwDoctorName;
    }
    public void setJwDoctorName(String jwDoctorName) {
        this.jwDoctorName = jwDoctorName;
    }
    @Column(name="jw_doctor_sex")
    public String getJwDocotrSex() {
        return jwDocotrSex;
    }
    public void setJwDocotrSex(String jwDocotrSex) {
        this.jwDocotrSex = jwDocotrSex;
    }
    @Column(name="jw_doctor_idcard")
    public String getJwDocotrIdcard() {
        return jwDocotrIdcard;
    }
    public void setJwDocotrIdcard(String jwDocotrIdcard) {
        this.jwDocotrIdcard = jwDocotrIdcard;
    }
    @Column(name="jw_doctor_hospital")
    public String getJwDoctorHospital() {
        return jwDoctorHospital;
    }
    public void setJwDoctorHospital(String jwDoctorHospital) {
        this.jwDoctorHospital = jwDoctorHospital;
    }
    @Column(name="jw_doctor_hospital_name")
    public String getJwDoctorHospiatlName() {
        return jwDoctorHospiatlName;
    }
    public void setJwDoctorHospiatlName(String jwDoctorHospiatlName) {
        this.jwDoctorHospiatlName = jwDoctorHospiatlName;
    }
    @Column(name="doctor_code")
    public String getDoctorCode() {
        return doctorCode;
    }
    public void setDoctorCode(String doctorCode) {
        this.doctorCode = doctorCode;
    }
}

File diff suppressed because it is too large
+ 98 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/adapter/PresModeAdapter.java


+ 28 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctorMappingDao.java

@ -0,0 +1,28 @@
package com.yihu.wlyy.repository.doctor;
import com.yihu.wlyy.entity.doctor.DoctorMapping;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 医生映射接口
 **/
public interface DoctorMappingDao extends PagingAndSortingRepository<DoctorMapping, Long>,JpaSpecificationExecutor<DoctorMapping> {
    @Query("select a.jwDoctor from DoctorMapping a where a.doctorCode = ?1 and a.jwDoctorHospital = ?2")
    String findByDocotrCodeAndJwDoctorHospital(String docotrCode,String jwDoctorHospital);
    DoctorMapping findByJwDoctorHospitalAndJwDoctor(String jwDoctorHospital,String jwDoctor);
    @Query("select a from Doctor a,DoctorMapping b where a.code = b.doctorCode and b.jwDoctorHospital = ?1 and b.jwDoctor = ?2")
    Doctor getDoctorByJw(String jwDoctorHospital, String jwDoctor);
    @Query("select a from Doctor a,DoctorMapping b where a.code = b.doctorCode and a.code = ?1 and b.jwDoctorHospital = ?2")
    Doctor getDoctor(String docotrCode,String jwDoctorHospital);
    @Query("from DoctorMapping a where a.jwDoctorHospital = ?1 and a.doctorCode = ?2")
    DoctorMapping findByJwDoctorHospitalAndDoctorCode(String jwDoctorHospital,String doctorCode);
}

+ 4 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/prescription/PrescriptionDao.java

@ -26,4 +26,8 @@ public interface PrescriptionDao extends PagingAndSortingRepository<Prescription
    //根据处方code得到患者信息
    @Query("select p from Prescription pt,Patient p where p.code=pt.patient  and pt.code=?1")
    Patient findPatientByPrescriptionCode(String prescriptionCode);
    @Query("from Prescription p where p.visitNo=?1")
    Prescription findByVisitNo(String visitNo);
}

+ 46 - 14
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java

@ -4,12 +4,14 @@ import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.prescription.*;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.prescription.*;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.DateUtil;
@ -66,6 +68,8 @@ public class PrescriptionInfoService extends BaseService {
    private MessageDao messageDao;
    @Autowired
    private PrescriptionExpressageDao prescriptionExpressageDao;
    @Autowired
    private SignFamilyDao signFamilyDao;
    private static final Logger logger = LoggerFactory.getLogger(HttpUtil.class);
@ -224,20 +228,40 @@ public class PrescriptionInfoService extends BaseService {
        return null;
    }
    public JSONObject  getPrescriptionProcess(String code){
    public com.alibaba.fastjson.JSONObject  getPrescriptionProcess(String code){
        Prescription prescription = prescriptionDao.findByCode(code);
        List<PrescriptionInfo> prescriptionInfos = prescriptionInfoDao.findByPrescriptionCode(code);
        PrescriptionReviewed reviewed =  prescriptionReviewedDao.findByPrescriptionCode(code);
        List<PrescriptionAdjust> prescriptionAdjusts = prescriptionAdjustDao.findByPrescriptionCode(code);
        JSONObject rs = new JSONObject();
        com.alibaba.fastjson.JSONObject rs = new  com.alibaba.fastjson.JSONObject();
        if(prescription!=null&&StringUtils.isNotBlank(prescription.getPatient())){
            Patient p = patientDao.findByCode(prescription.getPatient());
            rs.put("patient",p);
            Map<String,Object> pp =new HashedMap();
            pp.put("code",p.getCode());
            pp.put("name",p.getName());
            pp.put("idcard",p.getIdcard());
            pp.put("ssc",p.getSsc());
            pp.put("mobile",p.getMobile());
            rs.put("patient",pp);
            SignFamily signFamily = signFamilyDao.findByIdcard(p.getIdcard());
            Map<String,Object> sf =new HashedMap();
            sf.put("doctor",signFamily.getDoctor());
            sf.put("hospital",signFamily.getHospital());
            sf.put("doctorName",signFamily.getDoctorName());
            sf.put("hospitalName",signFamily.getHospitalName());
            rs.put("signFamily",sf);
        }else{
            rs.put("patient","");
            rs.put("signFamily","");
        }
        if(prescription.getStatus()==10){
        if(prescription!=null&&prescription.getStatus()==10){
            Long s = (prescription.getCreateTime().getTime()-new Date().getTime())/1000;
            //rs.put("time",s);
            if(s>172800){
@ -313,15 +337,13 @@ public class PrescriptionInfoService extends BaseService {
            //疾病类型不为空,关联查询疾病类型表
            pre_sql.append(" ,wlyy_prescription_diagnosis s " +
                    " WHERE s.prescription_code = pr.code " +
                    " AND pr.admin_team_id =? AND s.code = ?");
            params.add(teamCode);
                    " AND s.code = ?");
            params.add(diseases);
            setSQL(pre_sql,params,state,startDate,endDate,nameKeyword,patient,page,size);
            setSQL(pre_sql,params,teamCode,state,startDate,endDate,nameKeyword,patient,page,size);
        }else{
            //查询所有疾病类型表
            pre_sql.append(" WHERE pr.admin_team_id =?");
            params.add(teamCode);
            setSQL(pre_sql,params,state,startDate,endDate,nameKeyword,patient,page,size);
            pre_sql.append(" WHERE 1=1 ");
            setSQL(pre_sql,params,teamCode,state,startDate,endDate,nameKeyword,patient,page,size);
        }
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(pre_sql.toString(),params.toArray());
@ -334,7 +356,11 @@ public class PrescriptionInfoService extends BaseService {
        return new JSONArray(rs);
    }
    public void setSQL(StringBuffer pre_sql,List<Object> params,String state,String startDate,String endDate,String nameKeyword,String patient,Integer page,Integer size){
    public void setSQL(StringBuffer pre_sql,List<Object> params,Integer teamCode,String state,String startDate,String endDate,String nameKeyword,String patient,Integer page,Integer size){
        if(teamCode!=null&&teamCode>0){
            pre_sql.append(" AND pr.admin_team_id =?");
        }   params.add(teamCode);
        if(StringUtils.isNotBlank(state)){
            pre_sql.append(" AND pr.status IN ("+state+") ");
        }
@ -605,7 +631,7 @@ public class PrescriptionInfoService extends BaseService {
        }
        if(StringUtils.isNotBlank(endDate)){
            pre_sql.append(" AND pr.create_time <= ? ");
            param.add(startDate+" 23:59:59");
            param.add(endDate+" 23:59:59");
        }
        if(StringUtils.isNotBlank(hospital)){
            pre_sql.append(" AND e.hospital_code = ? ");
@ -764,7 +790,7 @@ public class PrescriptionInfoService extends BaseService {
                " LEFT JOIN wlyy_patient p ON pr.patient = p.`code` " +
                " JOIN wlyy_prescription_expressage e ON pr.code = e.prescription_code " +
                " JOIN wlyy_prescription_reviewed r ON pr.code = r.prescription_code " +
                " WHERE 1=1 " );
                " WHERE r.status=1 " );
        List<Object> params = new ArrayList<>();
        setDoctorExpressageSql(pre_sql,params, teamCode,  nameKey, startDate, endDate, hospital, state,dispensaryType,AllocationType, page, size);
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(pre_sql.toString(),params.toArray());
@ -792,7 +818,7 @@ public class PrescriptionInfoService extends BaseService {
        }
        if(StringUtils.isNotBlank(endDate)){
            pre_sql.append(" AND pr.create_time <= ? ");
            param.add(startDate+" 23:59:59");
            param.add(endDate+" 23:59:59");
        }
        if(StringUtils.isNotBlank(hospital)){
            pre_sql.append(" AND e.hospital_code = ? ");
@ -900,4 +926,10 @@ public class PrescriptionInfoService extends BaseService {
        }
        return 0;
    }
    public JSONArray getIcd10Info(String nameKey){
        StringBuffer stringBuffer = new StringBuffer(" SELECT t.code,t.name FROM icd10_dict t WHERE t.name LIKE ?");
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(stringBuffer.toString(),new Object[]{"%"+nameKey+"%"});
        return new JSONArray(rs);
    }
}

+ 89 - 52
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionService.java

@ -1,15 +1,20 @@
package com.yihu.wlyy.service.app.prescription;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.doctor.DoctorMapping;
import com.yihu.wlyy.entity.message.Message;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionDiagnosis;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressage;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.repository.doctor.DoctorMappingDao;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDiagnosisDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDispensaryCodeDao;
import com.yihu.wlyy.repository.prescription.PrescriptionExpressageDao;
import com.yihu.wlyy.service.BaseService;
@ -24,6 +29,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
 * Created by chenweida on 2017/7/27.
@ -47,11 +53,16 @@ public class PrescriptionService extends BaseService {
    private PatientDao patientDao;
    @Autowired
    private JwPrescriptionService jwPrescriptionService;
    @Autowired
    private DoctorMappingDao doctorMappingDao;
    @Autowired
    private PrescriptionDiagnosisDao prescriptionDiagnosisDao;
    @Value("${wechat.wechat_base_url}")
    private String wechat_base_url;
    @Autowired
    private PrescriptionDispensaryCodeDao prescriptionDispensaryCodeDao;
    /**
     *  获取处方信息
     * @param prescriptionCode 处方code
@ -123,68 +134,94 @@ public class PrescriptionService extends BaseService {
     */
    public JSONObject getPayInfo(String cardNo,String visitNo) throws Exception {
        //根据医保卡号和挂号号从基卫获取待结算明细
        String result = jwPrescriptionService.getDispUnSettleFeeInfoList(cardNo,visitNo);
        //根据挂号号获取处方明细
        Prescription prescription = prescriptionDao.findByVisitNo(visitNo);
        //根据机构名称,医生编码获取基卫医生详细信息
        DoctorMapping doctorMapping = doctorMappingDao.findByJwDoctorHospitalAndDoctorCode(prescription.getHospitalName(),prescription.getDoctor());
        JSONObject json = new JSONObject();
        //处方主信息{"yyksbm":"医生科室编号","bcsfcs":"本次收费次数","yszjhm":"医生证件号码","ysxm00":"医生姓名","mzlb00":"门诊类别","sfydgh":"是否药店挂号",
        // "bcghcs":"本次挂号次数","ghksmc":"挂号科室名称","cfxms0":"明细上传数量","mzlsh0":"医保挂号流水号 如果为空,将自动医保挂号并收费","ghfy00":"挂号费用",
        // "yszjdj":"医师诊金级别","bqbm00":"病情编码","sfygwd":"是否医改网点"}
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("yyksbm","医生科室编号");//医生科室编号
        jsonObject.put("bcsfcs",1+"");//本次收费次数
        jsonObject.put("yszjhm","医生证件号码");//医生证件号码
        jsonObject.put("ysxm00","医生姓名");//医生姓名
        jsonObject.put("mzlb00","门诊类别");//门诊类别
        jsonObject.put("sfydgh",1+"");//是否药店挂号
        jsonObject.put("bcghcs",1+"");//本次挂号次数
        jsonObject.put("ghksmc","挂号科室名称");//挂号科室名称
        jsonObject.put("cfxms0",1+"");//明细上传数量
        jsonObject.put("mzlsh0","医保挂号流水号");//医保挂号流水号
        jsonObject.put("ghfy00",10+"");//挂号费用
        jsonObject.put("yszjdj","医师诊金级别");//医师诊金级别
        jsonObject.put("bqbm00","病情编码");//病情编码
        jsonObject.put("sfygwd",1+"");//是否医改网点
        jsonObject.put("yyksbm","医生科室编号");//医生科室编号-------------------------待处理
        jsonObject.put("bcsfcs",1);//本次收费次数
        jsonObject.put("yszjhm",doctorMapping.getJwDocotrIdcard());//医生证件号码
        jsonObject.put("ysxm00",doctorMapping.getJwDoctorName());//医生姓名
        jsonObject.put("mzlb00",101);//门诊类别---普通门诊默认为101
        jsonObject.put("sfydgh","N");//是否药店挂号,默认为N,不是药店挂号
        jsonObject.put("bcghcs",1);//本次挂号次数
        jsonObject.put("ghksmc","挂号科室名称");//挂号科室名称--------------------------待处理
        jsonObject.put("mzlsh0","");//医保挂号流水号
        jsonObject.put("ghfy00",0);//挂号费用
        jsonObject.put("yszjdj","医师诊金级别");//医师诊金级别--------------------------待处理
        jsonObject.put("bqbm00","");//病情编码---可为空,不传递
        jsonObject.put("sfygwd","N");//是否医改网点--默认为否
        json.put("recipeContent",jsonObject);
        List<PrescriptionDiagnosis> pds = prescriptionDiagnosisDao.findByPrescriptionCode(prescription.getCode());
        //诊断明细        {"zdms00":"诊断或症状描述","zdbh00":"诊断或症状编码"}
        JSONArray zdInfo = new JSONArray();
        JSONObject j1 = new JSONObject();
        j1.put("zdms00","诊断或症状描述");//诊断或症状描述
        j1.put("zdbh00","诊断或症状编码");//诊断或症状编码
        zdInfo.add(j1);
        json.put("zdlist",zdInfo);
        //处方明细        {"xmgg00":"项目规格","cfhao0":"处方号","sfybxm":"是否医保项目","dcyydw":"单次用药单位","xmje00":"项目金额","xmbh00":"项目编号",
        // "ysxm00":"医生姓名","yppl00":"药品频率","gytj00":"给药途径","ypts00":"药品天数","xmdj00":"项目单价","qyzl00":"取药总量","ylts00":"药量天数",
        // "sptxbm":"商品条形编码","xmmc00":"项目名称","fpxmbh":"发票项目编号","xmsl00":"项目数量","ypyl00":"药品用量","qyzldw":"取药单位","xmdw00":"项目单位",
        // "jx0000":"剂型"}
        JSONArray cfInfo = new JSONArray();
        JSONObject j2 = new JSONObject();
        j2.put("xmgg00","项目规格");//项目规格
        j2.put("cfhao0","处方号");//处方号
        j2.put("sfybxm",1+"");//是否医保项目
        j2.put("dcyydw","单次用药单位");//单次用药单位
        j2.put("xmje00",111+"");//项目金额
        j2.put("xmje00","项目规格");//项目金额
        j2.put("xmbh00","项目编号");//项目编号
        j2.put("ysxm00","医生姓名");//医生姓名
        j2.put("yppl00","药品频率");//药品频率
        j2.put("gytj00","给药途径");//给药途径
        j2.put("ypts00",3+"");//药品天数
        j2.put("xmdj00",35+"");//项目单价
        j2.put("qyzl00",4+"");//取药总量
        j2.put("ylts00",3+"");//药量天数
        j2.put("sptxbm","商品条形编码");//商品条形编码
        j2.put("xmmc00","项目名称");//项目名称
        j2.put("fpxmbh","发票项目编号");//发票项目编号
        j2.put("xmsl00","项目数量");//项目数量
        j2.put("ypyl00","药品用量");//药品用量
        j2.put("qyzldw","取药单位");//取药单位
        j2.put("qyzl00","药品频率");//取药总量
        j2.put("xmdw00","项目单位");//项目单位
        j2.put("jx0000","剂型");//剂型
        cfInfo.add(j2);
        json.put("mxlist",cfInfo);
        if (!pds.isEmpty()){
            for (PrescriptionDiagnosis pd : pds) {
                JSONArray zdInfo = new JSONArray();
                JSONObject j1 = new JSONObject();
                j1.put("zdms00",pd.getName());//诊断或症状描述
                j1.put("zdbh00",pd.getCode());//诊断或症状编码
                zdInfo.add(j1);
                json.put("zdlist",zdInfo);
            }
        }
        if(StringUtils.isNotBlank(result)){
            JSONObject zyCfinfo =  JSON.parseObject(result);
            Integer code = zyCfinfo.getInteger("CODE");
            if( 1 == code){
                JSONArray zyCfinfoListReturnData = zyCfinfo.getJSONArray("returnData");
                JSONArray zyCfinfoList = zyCfinfoListReturnData.getJSONArray(0);
                jsonObject.put("cfxms0",zyCfinfoList.size());//明细上传数量
                //收费明细       {"xmgg00":"项目规格","cfhao0":"处方号","sfybxm":"是否医保项目","dcyydw":"单次用药单位","xmje00":"项目金额","xmbh00":"项目编号",
                // "ysxm00":"医生姓名","yppl00":"药品频率","gytj00":"给药途径","ypts00":"药品天数","xmdj00":"项目单价","qyzl00":"取药总量","ylts00":"药量天数",
                // "sptxbm":"商品条形编码","xmmc00":"项目名称","fpxmbh":"发票项目编号","xmsl00":"项目数量","ypyl00":"药品用量","qyzldw":"取药单位","xmdw00":"项目单位",
                // "jx0000":"剂型"}
                JSONArray cfInfo = new JSONArray();
                for (int i = 0; i < zyCfinfoList.size(); i++) {
                    JSONObject zyCfinfoObj = zyCfinfoList.getJSONObject(i);
                    JSONObject j2 = new JSONObject();
                    j2.put("xmbh00",zyCfinfoObj.getString("INSUR_ITEM_CODE"));//项目编号
                    j2.put("xmmc00",zyCfinfoObj.getString("INSUR_ITEM_NAME"));//项目名称
                    j2.put("fpxmbh","");//发票项目编号
                    j2.put("sfybxm",zyCfinfoObj.getString("INSUR_FLAG"));//是否医保项目
                    j2.put("xmdj00",zyCfinfoObj.getString("INSUR_ITEM_PRICE"));//项目单价
                    j2.put("xmdw00",zyCfinfoObj.getString("INSUR_ITEM_UNIT_NAME"));//项目单位
                    j2.put("xmgg00",zyCfinfoObj.getString("INSUR_ITEM_SPEC"));//项目规格(医保)
                    j2.put("xmsl00",zyCfinfoObj.getString("ITEM_QUANTITY"));//项目数量
                    j2.put("xmje00",zyCfinfoObj.getString("COST"));//项目金额
                    j2.put("ysxm00",doctorMapping.getJwDoctorName());//医生姓名
                    j2.put("sptxbm","");//商品条形编码
                    j2.put("yppl00",zyCfinfoObj.getString("FREQUENCY"));//药品频率
                    j2.put("ypyl00",zyCfinfoObj.getString("PHYSIC_DOSE"));//药品用量
                    j2.put("cfhao0",zyCfinfoObj.getString("VISIT_NO"));//处方号
                    j2.put("jx0000",zyCfinfoObj.getString("PHYSIC_FORM"));//剂型
                    j2.put("dcyydw",zyCfinfoObj.getString("PHYSIC_DOSE_UNIT"));//单次用药单位
                    j2.put("qyzl00",zyCfinfoObj.getString("PHYSIC_AMOUNT"));//取药总量
                    j2.put("qyzldw",zyCfinfoObj.getString("PHYSIC_AMOUNT_UNIT"));//取药单位
                    j2.put("gytj00",zyCfinfoObj.getString("PHYSIC_USAGE"));//给药途径
                    j2.put("ypts00",zyCfinfoObj.getString("DAY_COUNT"));//药品天数
                    cfInfo.add(j2);
                }
                json.put("mxlist",cfInfo);
            }else{
                String errormessage = zyCfinfo.getString("MESSAGE");
                throw new Exception(errormessage);
            }
        }
        return json;
    }

+ 113 - 94
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java

@ -1,17 +1,26 @@
package com.yihu.wlyy.web.doctor.prescription;
import com.yihu.wlyy.adapter.PresModeAdapter;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.patient.prescription.*;
import com.yihu.wlyy.service.app.prescription.*;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionExpressage;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionPay;
import com.yihu.wlyy.service.app.prescription.PrescriptionExpressageService;
import com.yihu.wlyy.service.app.prescription.PrescriptionInfoService;
import com.yihu.wlyy.service.app.prescription.PrescriptionPayService;
import com.yihu.wlyy.service.app.prescription.PrescriptionService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.service.third.jw.JwSignService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@ -21,7 +30,7 @@ import java.util.List;
@RestController
@RequestMapping(value = "/doctor/prescriptionInfo")
@Api(description = "医生端-长处方接口")
public class PrescriptionInfoController extends BaseController {
public class PrescriptionInfoController extends BaseController{
    @Autowired
    private PrescriptionInfoService prescriptionInfoService;
@ -34,14 +43,14 @@ public class PrescriptionInfoController extends BaseController {
    @Autowired
    private JwPrescriptionService jwPrescriptionService;
    @Autowired
    private PrescriptionExpressageLogService prescriptionExpressageLogService;
    private PresModeAdapter adapter;
    @RequestMapping(value = "/getPrescriptionFilter", method = RequestMethod.GET)
    @ApiOperation(value = "获取过滤规则信息列表")
    public String getPrescriptionFilter() {
    public String getPrescriptionFilter(){
        try {
            return write(200, "查询成功!", "data", prescriptionInfoService.getPrescriptionFilter());
            return write(200, "查询成功!", "data",prescriptionInfoService.getPrescriptionFilter());
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -50,17 +59,17 @@ public class PrescriptionInfoController extends BaseController {
    @RequestMapping(value = "/getDoctorPrescription", method = RequestMethod.GET)
    @ApiOperation(value = "获取全科医生/建管师续方列表/搜索")
    public String getDoctorPrescription(@RequestParam(required = true) @ApiParam(value = "团队code", name = "teamCode") Integer teamCode,
                                        @RequestParam(required = false) @ApiParam(value = "续方状态", name = "state") String state,
                                        @RequestParam(required = false) @ApiParam(value = "所有诊断:1 糖尿病 2高血压", name = "dispensary") String diseases,
                                        @RequestParam(required = false) @ApiParam(name = "startDate", value = "开始时间") String startDate,
                                        @RequestParam(required = false) @ApiParam(name = "endDate", value = "结束时间") String endDate,
                                        @RequestParam(required = false) @ApiParam(name = "nameKeyword", value = "患者姓名模糊匹配") String nameKeyword,
                                        @RequestParam(required = false) @ApiParam(name = "patient", value = "患者Code") String patient,
                                        @RequestParam(required = false) @ApiParam(name = "page", value = "起始页") Integer page,
                                        @RequestParam(required = false) @ApiParam(name = "size", value = "每页条数") Integer size) {
    public String getDoctorPrescription(@RequestParam(required = false)@ApiParam(value = "团队code", name = "teamCode") Integer teamCode,
                                        @RequestParam(required = false)@ApiParam(value = "续方状态", name = "state") String state,
                                        @RequestParam(required = false)@ApiParam(value = "所有诊断:1 糖尿病 2高血压", name = "dispensary") String diseases,
                                        @RequestParam(required = false)@ApiParam(name="startDate",value="开始时间")String startDate,
                                        @RequestParam(required = false)@ApiParam(name="endDate",value="结束时间")String endDate,
                                        @RequestParam(required = false)@ApiParam(name="nameKeyword",value="患者姓名模糊匹配")String nameKeyword,
                                        @RequestParam(required = false)@ApiParam(name="patient",value="患者Code")String patient,
                                        @RequestParam(required = false)@ApiParam(name="page",value="起始页")Integer page,
                                        @RequestParam(required = false)@ApiParam(name="size",value="每页条数")Integer size){
        try {
            return write(200, "查询成功!", "data", prescriptionInfoService.getDoctorPrescription(teamCode, state, diseases, startDate, endDate, nameKeyword, patient, page, size));
            return write(200, "查询成功!", "data",prescriptionInfoService.getDoctorPrescription(teamCode,state,diseases,startDate,endDate,nameKeyword,patient,page,size));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -69,10 +78,10 @@ public class PrescriptionInfoController extends BaseController {
    @RequestMapping(value = "/getContinuedPrescriptionAsDoctor", method = RequestMethod.GET)
    @ApiOperation(value = "续方详情")
    public String getContinuedPrescriptionAsDoctor(@RequestParam(required = true) @ApiParam(value = "续方CODE", name = "code") String code,
                                                   @RequestParam(required = true) @ApiParam(value = "团队长标识:1:是;2否", name = "type") String type) {
    public String getContinuedPrescriptionAsDoctor(@RequestParam(required = true)@ApiParam(value = "续方CODE", name = "code") String code,
                                                   @RequestParam(required = true)@ApiParam(value = "团队长标识:1:是;2否", name = "type") String type){
        try {
            return write(200, "查询成功!", "data", prescriptionInfoService.getContinuedPrescriptionAsDoctor(code));
            return write(200, "查询成功!", "data",prescriptionInfoService.getContinuedPrescriptionAsDoctor(code));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -81,11 +90,11 @@ public class PrescriptionInfoController extends BaseController {
    @RequestMapping(value = "/reviewPrescription", method = RequestMethod.POST)
    @ApiOperation(value = "续方审核")
    public String reviewPrescription(@RequestParam(required = true) @ApiParam(value = "续方CODE", name = "code") String code,
                                     @RequestParam(required = false) @ApiParam(value = "不同意原因", name = "reason") String reason,
                                     @RequestParam(required = false) @ApiParam(value = "1同意,2不同意", name = "state") String state) {
    public String reviewPrescription(@RequestParam(required = true)@ApiParam(value = "续方CODE", name = "code") String code,
                                     @RequestParam(required = false)@ApiParam(value = "不同意原因", name = "reason") String reason,
                                     @RequestParam(required = false)@ApiParam(value = "1同意,2不同意", name = "state") String state){
        try {
            return write(200, "查询成功!", "data", prescriptionInfoService.reviewPrescription(code, reason, state));
            return write(200, "查询成功!", "data",prescriptionInfoService.reviewPrescription(code,reason,state));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -95,12 +104,12 @@ public class PrescriptionInfoController extends BaseController {
    @RequestMapping(value = "/updatePresInfo", method = RequestMethod.POST)
    @ApiOperation(value = "调整处方")
    @ObserverRequired
    public String updatePresInfo(@RequestParam(required = true) @ApiParam(value = "续方CODE", name = "code") String code,
                                 @RequestParam(required = true) @ApiParam(value = "续方药品JSON", name = "infos") String infos,
                                 @RequestParam(required = false) @ApiParam(value = "疾病JSON", name = "diagnosis") String diagnosis,
                                 @RequestParam(required = false) @ApiParam(value = "调整原因", name = "reason") String reason) {
    public String updatePresInfo(@RequestParam(required = true)@ApiParam(value = "续方CODE", name = "code") String code,
                                 @RequestParam(required = true)@ApiParam(value = "续方药品JSON", name = "infos") String infos,
                                 @RequestParam(required = false)@ApiParam(value = "疾病JSON", name = "diagnosis") String diagnosis,
                                 @RequestParam(required = false)@ApiParam(value = "调整原因", name = "reason") String reason ){
        try {
            return write(200, "操作成功!", "data", prescriptionInfoService.updatePresInfo(code, infos, diagnosis, reason));
            return write(200, "操作成功!", "data",prescriptionInfoService.updatePresInfo(code,infos,diagnosis,reason));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -109,9 +118,9 @@ public class PrescriptionInfoController extends BaseController {
    @RequestMapping(value = "/getInfoTitle", method = RequestMethod.POST)
    @ApiOperation(value = "调整处方-药品分类及种类数目")
    public String getInfoTitle() {
    public String getInfoTitle(){
        try {
            return write(200, "操作成功!", "data", "");
            return write(200, "操作成功!", "data","");
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -120,9 +129,9 @@ public class PrescriptionInfoController extends BaseController {
    @RequestMapping(value = "/getInfoListByParentCode", method = RequestMethod.POST)
    @ApiOperation(value = "药品类别获取药品")
    private String getInfoListByParentCode(@RequestParam(required = true) @ApiParam(value = "药品类别Code", name = "code") String code) {
    private String getInfoListByParentCode(@RequestParam(required = true)@ApiParam(value = "药品类别Code", name = "code") String code){
        try {
            return write(200, "操作成功!", "data", "");
            return write(200, "操作成功!", "data","");
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -150,24 +159,14 @@ public class PrescriptionInfoController extends BaseController {
            PrescriptionPay prescriptionPay = prescriptionPayService.findByPrescriptionCode(prescriptionCode);
            //获取配送信息
            PrescriptionExpressage prescriptionExpressage = prescriptionExpressageService.findByPrescriptionCode(prescriptionCode);
            //获取配送流程
            List<PrescriptionExpressageLog> prescriptionExpressageLogs = prescriptionExpressageLogService.findByPrescriptionCode(prescriptionCode);
            jo.put("prescriptionExpressage", prescriptionExpressage);
            if (prescriptionInfos != null && prescriptionInfos.size() > 0) {
                jo.put("prescriptionInfos", prescriptionInfos);
            }
            if (prescriptionPay != null) {
                jo.put("prescriptionPay", prescriptionPay);
            }
            if (prescriptionExpressageLogs != null && prescriptionExpressageLogs.size() > 0) {
                jo.put("prescriptionExpressageLogs", prescriptionExpressageLogs);
            }
            jo.put("prescriptionInfos", prescriptionInfos);
            jo.put("prescriptionPay", prescriptionPay);
            jo.put("prescriptionHospital", prescription.getHospitalName());//出药机构
            jo.put("dispensaryDispensaryType", prescription.getType());//处方配送方式
            jo.put("dispensaryDispensaryTypeName", prescription.getTypeName());//处方配送方式
            jo.put("prescriptionStatus", prescription.getStatus());//处方状态
            jo.put("prescriptionStatusName", prescription.getStatusName(prescription.getStatus(), ""));//处方状态名称
            jo.put("prescriptionStatusName", prescription.getStatusName(prescription.getStatus(),""));//处方状态名称
            return write(200, "查询成功", "data", jo);
        } catch (Exception e) {
@ -178,9 +177,9 @@ public class PrescriptionInfoController extends BaseController {
    @RequestMapping(value = "/getDrugTimes", method = RequestMethod.GET)
    @ApiOperation(value = "药品品使用频次字典")
    public String getDrugTimes() {
    public String getDrugTimes(){
        try {
            return write(200, "操作成功!", "data", prescriptionInfoService.getDrugTimes());
            return write(200, "操作成功!", "data",prescriptionInfoService.getDrugTimes());
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -189,17 +188,17 @@ public class PrescriptionInfoController extends BaseController {
    @RequestMapping(value = "/getHDoctorPrescriptionExpressage", method = RequestMethod.GET)
    @ApiOperation(value = "获取健康管理师续方订单列表")
    public String getHDoctorPrescriptionExpressage(@RequestParam(required = false) @ApiParam(value = "团队Code", name = "teamCode") String teamCode,
                                                   @RequestParam(required = false) @ApiParam(value = "1:需跟踪;2:已接收", name = "type") String type,
                                                   @RequestParam(required = false) @ApiParam(value = "患者姓名关键字", name = "nameKey") String nameKey,
                                                   @RequestParam(required = false) @ApiParam(value = "开始时间", name = "startDate") String startDate,
                                                   @RequestParam(required = false) @ApiParam(value = "结束时间", name = "endDate") String endDate,
                                                   @RequestParam(required = false) @ApiParam(value = "服务站", name = "hospital") String hospital,
                                                   @RequestParam(required = false) @ApiParam(value = "配送状态", name = "state") String state,
                                                   @RequestParam(required = false) @ApiParam(value = "页数", name = "page") Integer page,
                                                   @RequestParam(required = false) @ApiParam(value = "每页大小", name = "size") Integer size) {
    public String getHDoctorPrescriptionExpressage(@RequestParam(required = false) @ApiParam(value = "团队Code", name = "teamCode")String teamCode,
                                                  @RequestParam(required = false) @ApiParam(value = "1:需跟踪;2:已接收", name = "type")  String type,
                                                  @RequestParam(required = false) @ApiParam(value = "患者姓名关键字", name = "nameKey")String nameKey,
                                                  @RequestParam(required = false) @ApiParam(value = "开始时间", name = "startDate")String startDate,
                                                  @RequestParam(required = false) @ApiParam(value = "结束时间", name = "endDate")String endDate,
                                                  @RequestParam(required = false) @ApiParam(value = "服务站", name = "hospital")String hospital,
                                                  @RequestParam(required = false) @ApiParam(value = "配送状态", name = "state")String state,
                                                  @RequestParam(required = false) @ApiParam(value = "页数", name = "page")Integer page,
                                                  @RequestParam(required = false) @ApiParam(value = "每页大小", name = "size")Integer size){
        try {
            return write(200, "操作成功!", "data", prescriptionInfoService.getHDoctorPrescriptionExpressage(teamCode, type, getUID(), nameKey, startDate, endDate, hospital, state, page, size));
            return write(200, "操作成功!", "data",prescriptionInfoService.getHDoctorPrescriptionExpressage(teamCode,type,getUID(),nameKey,startDate,endDate,hospital,state,page,size));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -208,20 +207,19 @@ public class PrescriptionInfoController extends BaseController {
    @RequestMapping(value = "/getPrescriptionExpressageFilter", method = RequestMethod.GET)
    @ApiOperation(value = "获取健康管理师续方订单列表过滤条件")
    public String getPrescriptionExpressageFilter() {
    public String getPrescriptionExpressageFilter(){
        try {
            return write(200, "操作成功!", "data", prescriptionInfoService.getPrescriptionExpressageFilter(getUID()));
            return write(200, "操作成功!", "data",prescriptionInfoService.getPrescriptionExpressageFilter(getUID()));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/getPrescriptionExpressageAsdoctorFilter", method = RequestMethod.GET)
    @ApiOperation(value = "获取全科医生续方订单列表过滤条件")
    public String getPrescriptionExpressageAsdoctorFilter() {
    public String getPrescriptionExpressageAsdoctorFilter(){
        try {
            return write(200, "操作成功!", "data", prescriptionInfoService.getPrescriptionExpressageAsdoctorFilter());
            return write(200, "操作成功!", "data",prescriptionInfoService.getPrescriptionExpressageAsdoctorFilter());
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -230,20 +228,20 @@ public class PrescriptionInfoController extends BaseController {
    @RequestMapping(value = "/getDoctorPrescriptionExpressage", method = RequestMethod.GET)
    @ApiOperation(value = "获取全科医生续方订单列表")
    public String getDoctorPrescriptionExpressage(@RequestParam(required = false) @ApiParam(value = "团队Code", name = "teamCode") String teamCode,
                                                  @RequestParam(required = false) @ApiParam(value = "居民搜素关键字", name = "nameKey") String nameKey,
                                                  @RequestParam(required = false) @ApiParam(value = "开始时间", name = "startDate") String startDate,
                                                  @RequestParam(required = false) @ApiParam(value = "结束时间", name = "endDate") String endDate,
                                                  @RequestParam(required = false) @ApiParam(value = "机构", name = "hospital") String hospital,
                                                  @RequestParam(required = false) @ApiParam(value = "配送状态", name = "state") String state,
                                                  @RequestParam(required = false) @ApiParam(value = "配送方式:1 自取 2快递配送 3健管师配送", name = "dispensaryType") String dispensaryType,
                                                  @RequestParam(required = false) @ApiParam(value = "传1为未分配健管师", name = "AllocationType") String AllocationType,
                                                  @RequestParam(required = false) @ApiParam(value = "起始页", name = "page") Integer page,
                                                  @RequestParam(required = false) @ApiParam(value = "每页大小", name = "size") Integer size) {
    public String getDoctorPrescriptionExpressage(@RequestParam(required = false) @ApiParam(value = "团队Code", name = "teamCode")String teamCode,
                                                  @RequestParam(required = false) @ApiParam(value = "居民搜素关键字", name = "nameKey")String nameKey,
                                                  @RequestParam(required = false) @ApiParam(value = "开始时间", name = "startDate")String startDate,
                                                  @RequestParam(required = false) @ApiParam(value = "结束时间", name = "endDate")String endDate,
                                                  @RequestParam(required = false) @ApiParam(value = "机构", name = "hospital")String hospital,
                                                  @RequestParam(required = false) @ApiParam(value = "配送状态", name = "state")String state,
                                                  @RequestParam(required = false) @ApiParam(value = "配送方式:1 自取 2快递配送 3健管师配送", name = "dispensaryType")String dispensaryType,
                                                  @RequestParam(required = false) @ApiParam(value = "传1为未分配健管师", name = "AllocationType")String AllocationType,
                                                  @RequestParam(required = false) @ApiParam(value = "起始页", name = "page")Integer page,
                                                  @RequestParam(required = false) @ApiParam(value = "每页大小", name = "size")Integer size){
        try {
            return write(200, "操作成功!", "data",
                    prescriptionInfoService.
                            getDoctorPrescriptionExpressage(teamCode, nameKey, startDate, endDate, hospital, state, dispensaryType, AllocationType, page, size));
                            getDoctorPrescriptionExpressage(teamCode, nameKey, startDate, endDate, hospital, state, dispensaryType,AllocationType, page, size));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
@ -252,7 +250,7 @@ public class PrescriptionInfoController extends BaseController {
    @RequestMapping(value = "/getCountExpressage", method = RequestMethod.GET)
    @ApiOperation(value = "获取指定团队未分配建管师订单数目")
    public String getCountExpressage(@RequestParam(required = true) @ApiParam(value = "团队Code", name = "teamCode") String teamCode) {
    public String getCountExpressage(@RequestParam(required = true) @ApiParam(value = "团队Code", name = "teamCode")String teamCode){
        try {
            return write(200, "操作成功!", "data", prescriptionInfoService.getCountExpressage(teamCode));
        } catch (Exception e) {
@ -263,7 +261,7 @@ public class PrescriptionInfoController extends BaseController {
    @RequestMapping(value = "/getHospitalListTitle", method = RequestMethod.GET)
    @ApiOperation(value = "获取服务站列表")
    public String getHospitalListTitle(@RequestParam(required = true) @ApiParam(value = "团队Code", name = "teamCode") String teamCode) {
    public String getHospitalListTitle(@RequestParam(required = true) @ApiParam(value = "团队Code", name = "teamCode")String teamCode){
        try {
            return write(200, "操作成功!", "data", prescriptionInfoService.getHospitalListTitle(teamCode));
        } catch (Exception e) {
@ -274,7 +272,7 @@ public class PrescriptionInfoController extends BaseController {
    @RequestMapping(value = "/getTeamHealthDoctorCount", method = RequestMethod.GET)
    @ApiOperation(value = "获取医生同社区底下所有团队建管师数目")
    public String getTeamHealthDoctorCount() {
    public String getTeamHealthDoctorCount(){
        try {
            return write(200, "操作成功!", "data", prescriptionInfoService.getTeamHealthDoctorCount(getUID()));
        } catch (Exception e) {
@ -282,27 +280,48 @@ public class PrescriptionInfoController extends BaseController {
            return error(-1, "查询失败!");
        }
    }
//
//    @RequestMapping(value = "/getPrescriptionDurgDict", method = RequestMethod.GET)
//    @ApiOperation(value = "获取基卫的药品字典")
//    public String getPrescriptionDurgDict(
//            @RequestParam(required = true,name = "dictName") @ApiParam(value = "字典名称", name = "dictName",required = true)  String dictName,
//            @RequestParam(required = true,name = "hospital") @ApiParam(value = "医院code", name = "hospital",required = true)  String hospital
//    ){
//        try {
//            return write(200, "操作成功!", "data",jwPrescriptionService.getDictForI(dictName,hospital));
//        } catch (Exception e) {
//            error(e);
//            return error(-1, "查询失败!");
//        }
//    }
    @RequestMapping(value = "/getPrescriptionDurgDict", method = RequestMethod.GET)
    @ApiOperation(value = "获取基卫的药品字典")
    public String getPrescriptionDurgDict(
            @RequestParam(required = true,name = "dictName") @ApiParam(value = "字典名称", name = "dictName",required = true)  String dictName
    ){
        try {
            return write(200, "操作成功!", "data",jwPrescriptionService.getDictForI(dictName));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/distributionHealthDoctor", method = RequestMethod.POST)
    @ApiOperation(value = "配置建管师")
    public String distributionHealthDoctor(@RequestParam(required = true) @ApiParam(value = "续方Code字符串用','分割", name = "codes") String codes,
                                           @RequestParam(required = true) @ApiParam(value = "健康管理师Code", name = "healthDoctor") String healthDoctor) {
                                           @RequestParam(required = true) @ApiParam(value = "健康管理师Code", name = "healthDoctor")String healthDoctor){
        try {
            return write(200, "操作成功!", "data",prescriptionInfoService.distributionHealthDoctor( codes, healthDoctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/testAdapter", method = RequestMethod.POST)
    @ApiOperation(value = "测试适配器")
    public String testAdapter(@RequestParam(required = true) @ApiParam(value = "字符串", name = "json") String json){
        try {
            return write(200, "操作成功!", "data",adapter.modeTopresInfo(json));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
    @RequestMapping(value = "/getIcd10Info", method = RequestMethod.GET)
    @ApiOperation(value = "获取诊断结果")
    public String getIcd10Info(@RequestParam(required = true) @ApiParam(value = "诊断结果关键字", name = "nameKey") String nameKey){
        try {
            return write(200, "操作成功!", "data", prescriptionInfoService.distributionHealthDoctor(codes, healthDoctor));
            return write(200, "操作成功!", "data",prescriptionInfoService.getIcd10Info(nameKey));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");