Browse Source

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

huangwenjie 7 years ago
parent
commit
546fbc7ab7
17 changed files with 278 additions and 59 deletions
  1. 1 1
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/controller/medicine/PhysicalExaminationController.java
  2. 10 4
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/service/PatientService.java
  3. 10 6
      patient-co-customization/patient-co-modern-medicine/src/main/resources/application.yml
  4. 19 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/SignFamily.java
  5. 2 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/SignFamilyDao.java
  6. 1 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/account/CustomerService.java
  7. 2 2
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/family/FamilyMemberService.java
  8. 19 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/sign/FamilyContractService.java
  9. 21 2
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/common/util/CommonUtil.java
  10. 21 15
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionService.java
  11. 2 2
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/redis/RedisThread.java
  12. 14 14
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java
  13. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/adapter/PresModeAdapter.java
  14. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java
  15. 105 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionAdjustService.java
  16. 11 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java
  17. 37 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionAdjustController.java

+ 1 - 1
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/controller/medicine/PhysicalExaminationController.java

@ -67,7 +67,7 @@ public class PhysicalExaminationController extends BaseController {
        Patient patient = patientService.findByCode(patientCode);
        int isSignJM = patientService.isSignJM(patientCode);
        if(isSignJM==3){
        if(isSignJM==2){
            String insertslip = physicalExaminationService.insertslip(patient);
            JSONObject jsonQuestion = new JSONObject(insertslip);
            if(physicalExaminationService.getSuccess(jsonQuestion)){

+ 10 - 4
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/service/PatientService.java

@ -42,21 +42,27 @@ public class PatientService {
     */
    public int isSignJM(String patientCode){
        SignFamily signFamily = familyContractService.findSignByPatient(patientCode);
        //未签约
        if(signFamily==null){
            Patient patient = findByCode(patientCode);
            //未签约判断是否在前门
            String city = patient.getCity();
            if("350200".equals(city)){
                return 1;
                return 1;//未签约  厦门居民
            }
            return 0;
            return 0;//未签约  非厦门居民
        }
        //签约
        String hospitalCode = signFamily.getHospital();
        Hospital hospital = hospitalService.findByCode(hospitalCode);
        String town = hospital.getTown();
        if("350211".equals(town)){
            return 2;
            return 2;  //签约  签约在集美
        }
        return 3;
        return 3;  //签约 但签约不在集美
    }
}

+ 10 - 6
patient-co-customization/patient-co-modern-medicine/src/main/resources/application.yml

@ -2,7 +2,7 @@ server:
  port: 8080
examCode: 84        #越人试卷编号
yuerenApi: http://192.168.131.123:8180/wlyy_admin/yueren       #越人api调用地址
yuerenApi: http://172.19.103.88:9099/wlyy-manage/yueren       #越人api调用地址
security:
  basic:
@ -69,6 +69,15 @@ logging:
spring:
  profiles: test
  datasource:
      medicine:
        url: jdbc:mysql://172.19.103.77/medicine?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
        username: root
        password: 123456
      wlyy:
        url: jdbc:mysql://172.19.103.77/wlyy?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
        username: root
        password: 123456
---
@ -99,8 +108,3 @@ yueren:
server:
  server_url: http://weixin.xmtyw.cn/wlyy-dev/
---
##开发连测试用这个版本的配置
spring:
  profiles: dev_test

+ 19 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/entity/SignFamily.java

@ -52,6 +52,7 @@ public class SignFamily extends IdEntity {
    private String familyCode;//签约code
    private Double expenses;//签约费用
    private String expensesStatus;//扣费状态【0未扣费 1已扣费 2已退费】
    private String expensesStatusName;
    private String signSource;// 签约来源【1 社区签约 2 移动签约】
    private String signDoctorCode;//簽約人code
    private String signDoctorName;//簽約人銘
@ -512,4 +513,22 @@ public class SignFamily extends IdEntity {
    public void setStatusName(String statusName) {
        this.statusName = statusName;
    }
    @Transient
    public String getExpensesStatusName() {      //扣费状态【0未扣费 1已扣费 2已退费】
        if("2".equals(expensesStatus)){
            this.expensesStatusName = "已退费";
        }else if("1".equals(expensesStatus)){
            this.expensesStatusName = "已扣费";
        }else if("0".equals(expensesStatus)){
            this.expensesStatusName = "未扣费";
        }else{
            this.expensesStatusName = "";
        }
        return expensesStatusName;
    }
    public void setExpensesStatusName(String expensesStatusName) {
        this.expensesStatusName = expensesStatusName;
    }
}

+ 2 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/repository/SignFamilyDao.java

@ -37,4 +37,6 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
    @Query("select a from SignFamily a where a.patient = ?1 and a.status > 0 and expensesStatus=1")
    SignFamily findSignByPatient(String patient);
    @Query("select a from SignFamily a where a.patient = ?1 and a.status > 0 order by a.czrq desc")
    List<SignFamily> findSignInfo(String patient);
}

+ 1 - 1
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/account/CustomerService.java

@ -33,7 +33,7 @@ public class CustomerService{
		resp.put("family",familyMembers);
		//查询签约信息
		SignFamily signInfo = contractService.findSignByPatient(patient.getCode());
		SignFamily signInfo = contractService.findSignInfo(patient.getCode());
		if(signInfo!=null){
			signInfo.setStatusName("已签约");
		}

+ 2 - 2
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/family/FamilyMemberService.java

@ -83,7 +83,7 @@ public class FamilyMemberService extends BaseService {
            JSONArray tem = new JSONArray();//存储其他
            for (Map<String, Object> map : result) {
                Map<String,Object> map1 = new HashMap();
                SignFamily sign = contractService.findSignByPatient(map.get("code").toString());
                SignFamily sign = contractService.findSignInfo(map.get("code").toString());
                boolean ssSign = false;
                boolean jtSign = false;
                map.put("statusName","未签约");
@ -132,7 +132,7 @@ public class FamilyMemberService extends BaseService {
        //查询签约信息
        Map map = new HashMap<String,Object>();
        SignFamily sign = contractService.findSignByPatient(p.getCode());
        SignFamily sign = contractService.findSignInfo(p.getCode());
        boolean ssSign = false;
        boolean jtSign = false;
        map.put("statusName","未签约");

+ 19 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/sign/FamilyContractService.java

@ -38,4 +38,23 @@ public class FamilyContractService extends BaseService {
    public SignFamily findSignByPatient(String patient){
        return signFamilyDao.findSignByPatient(patient);
    }
    /**
     * 查询已签约,已缴费的签约信息
     * 若没有已缴费的--->>返回已签约的最新一条信息,否则返回null
     *
     * @param patient
     * @return
     */
    public SignFamily findSignInfo(String patient){
        SignFamily signFamily = findSignByPatient(patient);
        if(signFamily==null){
            List<SignFamily> signFamilies = signFamilyDao.findSignInfo(patient);
            if(signFamilies!=null && signFamilies.size()>0){
                return signFamilies.get(0);
            }
        }
        return signFamily;
    }
}

+ 21 - 2
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/common/util/CommonUtil.java

@ -65,7 +65,8 @@ public class CommonUtil {
    }
    /**
     * double*100转int
     * double转字符串,在转int
     * double*100转int 有bug 34.3会会变成3429
     * @param d
     * @return
     */
@ -73,7 +74,25 @@ public class CommonUtil {
        if(d==null){
            return 0;
        }
        return new Double(d*100).intValue();
        String currency = String.valueOf(d);
        int index = currency.indexOf(".");
        int length = currency.length();
        Integer amLong = 0;
        if(index == -1){
            amLong = Integer.valueOf(currency+"00");
        }else if(length - index >= 3){
            amLong = Integer.valueOf((currency.substring(0, index+3)).replace(".", ""));
            if(length-index>3){
                if(Integer.valueOf(currency.substring(index+3,index+4))>=5){
                    amLong++;
                }
            }
        }else if(length - index == 2){
            amLong = Integer.valueOf((currency.substring(0, index+2)).replace(".", "")+0);
        }else{
            amLong = Integer.valueOf((currency.substring(0, index+1)).replace(".", "")+"00");
        }
        return amLong;
    }
    /**

+ 21 - 15
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionService.java

@ -26,10 +26,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * 长处方接口
@ -122,10 +119,10 @@ public class PrescriptionService extends ZysoftBaseService{
                    //调整续方的药品信息
                    JSONArray prescription_detail = pre.getJSONArray("PRESCRIPTION_DETAIL");
                    List<PrescriptionInfo> infoList = new ArrayList<>();
                    for(int i =0;i<prescription_detail.size();i++){
                        JSONObject info = prescription_detail.getJSONObject(i);
                        String infoCode = info.getString("SUB_NO");
                        PrescriptionInfo prescriptionInfo = prescriptionInfoDao.findByCode(infoCode);
                        PrescriptionInfo prescriptionInfo = new PrescriptionInfo();
                        prescriptionInfo.setRemark(info.getString("REMARK"));
                        prescriptionInfo.setBindFlag(info.getString("BIND_FLAG"));
                        prescriptionInfo.setDirection(info.getString("USAGE_NAME"));//药品用法
@ -134,9 +131,9 @@ public class PrescriptionService extends ZysoftBaseService{
                        prescriptionInfo.setDrugRate(info.getString("FREQUENCY"));//吃药频率 FREQUENCY
                        prescriptionInfo.setDrugRateName(info.getString("FREQUENCY_NAME"));
                        prescriptionInfo.setDrugFormat(info.getString("ITEM_SPEC"));//药品规格
                        prescriptionInfo.setPrice(info.getInteger("ITEM_PRICE"));//药品单价
                        prescriptionInfo.setPrice(CommonUtil.doubleToInt(info.getDouble("ITEM_PRICE")));//药品单价
                        prescriptionInfo.setNum(info.getInteger("ITEM_QUANTITY"));//药品数目
                        prescriptionInfo.setJwSubCode("");//智业子处方号
                        prescriptionInfo.setJwSubCode(info.getString("SUB_NO"));//智业子处方号
                        prescriptionInfo.setDrugNumUnit(info.getString("ITEM_UNIT"));//数量单位编码
                        prescriptionInfo.setDrugNumUnitName(info.getString("ITEM_UNIT_NAME"));//数量单位名称
                        prescriptionInfo.setCost(CommonUtil.doubleToInt(info.getDouble("COST")));//金额
@ -151,13 +148,20 @@ public class PrescriptionService extends ZysoftBaseService{
                        prescriptionInfo.setPhysicAmount(info.getString("PHYSIC_AMOUNT"));//用药总量
                        prescriptionInfo.setPhysicAmountUnit(info.getString("PHYSIC_AMOUNT_UNIT"));//总量单位编码
                        prescriptionInfo.setPhysicAmountUnitName(info.getString("PHYSIC_AMOUNT_UNIT_NAME"));//总量单位名称
                        prescriptionInfo.setPhysicInjectPlace("");//注射地点编码
                        prescriptionInfo.setPhysicInjectPlaceName("");//注射地点名称
                        prescriptionInfo.setPhysicInjectPlace(info.getString("PHYSIC_INJECT_PLACE"));//注射地点编码
                        prescriptionInfo.setPhysicInjectPlaceName(info.getString("PHYSIC_INJECT_PLACE_NAME"));//注射地点名称
                        prescriptionInfo.setPhysicSkinTest(info.getString("PHYSIC_SKIN_TEST"));//皮试类型名称
                        prescriptionInfo.setPhysicSkinTestName(info.getString("PHYSIC_SKIN_TEST_NAME"));//皮试类型名称
                        prescriptionInfoDao.save(prescriptionInfo);
                        prescriptionInfo.setPrescriptionCode(prescription.getCode());
                        infoList.add(prescriptionInfo);
                    }
                    //删除所有药品
                    StringBuffer sql = new StringBuffer("UPDATE wlyy_prescription_info SET del = 0 WHERE prescription_code = '" + prescription.getCode() + "'");
                    jdbcTemplate.execute(sql.toString());
                    //保存新的药品
                    prescriptionInfoDao.save(infoList);
                    // redis 的发布 {tilte:redisAddPrescription   state: 1 ,//1:成功,2.失败 mes:'开方成功' prescription : "0001" //续方CODE  }
                    JSONObject message = new JSONObject();
                    message.put("title","adjustPrescription");
@ -288,9 +292,9 @@ public class PrescriptionService extends ZysoftBaseService{
                message.put("prescription",prescription.getCode());
                message.put("mes","success");
//                redisTemplate.convertAndSend(channelTopic,message.toString());
                redisTemplate.watch(channelTopic);
//                redisTemplate.watch(channelTopic);
                redisTemplate.opsForList().leftPush(channelTopic,message.toString());
                redisTemplate.unwatch();
//                redisTemplate.unwatch();
            }
        }catch (JSONException ex){
@ -564,7 +568,8 @@ public class PrescriptionService extends ZysoftBaseService{
            json.put("DIAGNOSE_SUB_CODE",prescriptionDiagnosisList.get(1).getCode());//"DIAGNOSE_CODE": "次诊断编码",
        }
        if(prescription.getCaCertData()!=null){
            json.put("ORIGINAL_DATA",prescription.getStrOriginalData());//原文
//            json.put("ORIGINAL_DATA",prescription.getStrOriginalData());//原文
            json.put("ORIGINAL_DATA",null);
            json.put("ORIGINAL_DATA_MD5",prescription.getOriginalDataAbstract());//原文的MD5摘要
            json.put("CA_SIGN_DATA",prescription.getCaMessage());//签名值
            json.put("CA_CERTMAIN_DATA",prescription.getCaCertData());//签名证书主体数据
@ -791,7 +796,8 @@ public class PrescriptionService extends ZysoftBaseService{
        JSONObject json = new JSONObject();
        json.put("recipeNo",prescription.getRecipeNo());// "recipeNo": "医嘱号",
        if(prescription.getCaCertData()!=null){
            json.put("ORIGINAL_DATA",prescription.getStrOriginalData());//原文
//            json.put("ORIGINAL_DATA",prescription.getStrOriginalData());//原文
            json.put("ORIGINAL_DATA",null);
            json.put("ORIGINAL_DATA_MD5",prescription.getOriginalDataAbstract());//原文的MD5摘要
            json.put("CA_SIGN_DATA",prescription.getCaMessage());//签名值
            json.put("CA_CERTMAIN_DATA",prescription.getCaCertData());//签名证书主体数据

+ 2 - 2
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/redis/RedisThread.java

@ -25,9 +25,9 @@ public class RedisThread implements Runnable {
    public void run() {
        String key = SystemConf.getInstance().getSystemProperties().getProperty("redis_prescription_title");
        while (true){
            redisTemplate.watch(key);
//            redisTemplate.watch(key);
            String message = redisTemplate.opsForList().rightPop(key);
            redisTemplate.unwatch();
//            redisTemplate.unwatch();
            if(StringUtils.isEmpty(message)){
                try{
                    Thread.sleep(1000L);//如果没有读取到记录,等待1秒

+ 14 - 14
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java

@ -152,19 +152,19 @@ public class MessageService extends BaseService {
        }
        //获取续方消息
        List<Message> prescriptionMessage = messageDao.getSysTemMessageByTypeAndRead(doctor,1,6);
        JSONObject prescriptionJson = new JSONObject();
        if (prescriptionMessage != null && prescriptionMessage.size() > 0) {
            prescriptionJson.put("amount", prescriptionMessage.size());
            JSONObject msgJson = new JSONObject();
            msgJson.put("title", systemMessage.get(0).getTitle());
            msgJson.put("type", systemMessage.get(0).getType());
            msgJson.put("msg", systemMessage.get(0).getContent());
            msgJson.put("msgTime", DateUtil.dateToStrLong(systemMessage.get(0).getCreateTime()));
            prescriptionJson.put("lastMessage", msgJson);
        } else {
            prescriptionJson.put("amount", 0);
        }
//        List<Message> prescriptionMessage = messageDao.getSysTemMessageByTypeAndRead(doctor,1,6);
//        JSONObject prescriptionJson = new JSONObject();
//        if (prescriptionMessage != null && prescriptionMessage.size() > 0) {
//            prescriptionJson.put("amount", prescriptionMessage.size());
//            JSONObject msgJson = new JSONObject();
//            msgJson.put("title", systemMessage.get(0).getTitle());
//            msgJson.put("type", systemMessage.get(0).getType());
//            msgJson.put("msg", systemMessage.get(0).getContent());
//            msgJson.put("msgTime", DateUtil.dateToStrLong(systemMessage.get(0).getCreateTime()));
//            prescriptionJson.put("lastMessage", msgJson);
//        } else {
//            prescriptionJson.put("amount", 0);
//        }
        JSONObject json = new JSONObject();
@ -172,7 +172,7 @@ public class MessageService extends BaseService {
        json.put("sign", signJson);//签约数
        json.put("healthIndex", indexJson);//健康指标
        json.put("system", systemJson);//系统消息
        json.put("prescription", prescriptionJson);//续方消息
//        json.put("prescription", prescriptionJson);//续方消息
        return json;
    }

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/adapter/PresModeAdapter.java

@ -177,7 +177,7 @@ public class PresModeAdapter {
                            prescriptionInfo.setDrugRate(info.getString("FREQUENCY"));//吃药频率 FREQUENCY
                            prescriptionInfo.setDrugRateName(info.getString("FREQUENCY_NAME"));
                            prescriptionInfo.setDrugFormat(info.getString("ITEM_SPEC"));//药品规格
                            prescriptionInfo.setPrice(info.getInteger("ITEM_PRICE"));//药品单价
                            prescriptionInfo.setPrice(CommonUtil.doubleToInt(info.getDouble("ITEM_PRICE")));//药品单价
                            prescriptionInfo.setNum(info.getInteger("ITEM_QUANTITY"));//药品数目
                            prescriptionInfo.setJwSubCode(info.getString("RECIPE_SUB_NO"));//智业子处方号
                            prescriptionInfo.setDrugNumUnit(info.getString("ITEM_UNIT"));//数量单位编码
@ -278,7 +278,7 @@ public class PresModeAdapter {
                    prescriptionInfo.put("drugRate",info.getString("FREQUENCY"));//吃药频率 FREQUENCY
                    prescriptionInfo.put("drugRateName",info.getString("FREQUENCY_NAME"));
                    prescriptionInfo.put("drugFormat",info.getString("ITEM_SPEC"));//药品规格
                    prescriptionInfo.put("price",info.getInteger("ITEM_PRICE"));//药品单价
                    prescriptionInfo.put("price",info.getDouble("ITEM_PRICE"));//药品单价
                    prescriptionInfo.put("num",info.getInteger("ITEM_QUANTITY"));//药品数目
                    prescriptionInfo.put("jwSubCode",info.getString("RECIPE_SUB_NO"));//智业子处方号
                    prescriptionInfo.put("drugNumUnit",info.getString("ITEM_UNIT"));//数量单位编码

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/consult/ConsultTeamService.java

@ -1131,7 +1131,7 @@ public class ConsultTeamService extends ConsultService {
            prescriptionInfo.setDrugName(info.getString("drugName"));//药品名称
            prescriptionInfo.setDrugRate(info.getString("drugRate"));//吃药频率
            prescriptionInfo.setDrugFormat(info.getString("drugFormat"));//药品规格
            prescriptionInfo.setNum(CommonUtil.doubleToInt(info.getDouble("num")));//药品数目
            prescriptionInfo.setNum(info.getInteger("num"));//药品数目
            prescriptionInfo.setPrice(CommonUtil.doubleToInt(info.getDouble("price")));//药品单价
            prescriptionInfo.setIsRefrigerate(0);//是否冷藏 1是 0否
            prescriptionInfo.setJwSubCode(info.getString("jwSubCode"));//智业子处方号

+ 105 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionAdjustService.java

@ -4,11 +4,19 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionReviewed;
import com.yihu.wlyy.repository.message.MessageDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.repository.prescription.PrescriptionReviewedDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ImUtill;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
/**
 * 线下调整处方
@ -23,16 +31,28 @@ public class PrescriptionAdjustService extends BaseService {
    private PrescriptionDao prescriptionDao;
    @Autowired
    private PrescriptionLogService prescriptionLogService;
    @Autowired
    private PrescriptionService prescriptionService;
    @Autowired
    private MessageDao messageDao;
    @Autowired
    private PrescriptionReviewedDao prescriptionReviewedDao;
    @Autowired
    private PrescriptionInfoService prescriptionInfoService;
    @Autowired
    private ImUtill imUtill;
    /**
     * 线下调整处方
     * @param code
     */
    public void adjustPrescription(String code){
    @Transactional
    public JSONObject adjustPrescription(String code){
        JSONObject re = new JSONObject();
        Prescription prescription = prescriptionDao.findByCode(code);
        if(prescription.getStatus()== PrescriptionLog.PrescriptionLogStatus.revieweding.getValue()){
        if(prescription.getStatus()== PrescriptionLog.PrescriptionLogStatus.revieweding.getValue()||
                prescription.getStatus()== PrescriptionLog.PrescriptionLogStatus.change_error.getValue()){
            //待审核状态才可以线下调整处方
            String response = jwPrescriptionService.saveRecipe(code,prescription.getJwGisterTypeCode(),prescription.getJwDeptCode());
            JSONObject json = JSONObject.parseObject(response);
            if(json.getInteger("status")==200){
@ -49,27 +69,107 @@ public class PrescriptionAdjustService extends BaseService {
                        prescription.setRecipeNo(recipeNo);
                        prescriptionDao.save(prescription);
                        //发送Im消息
                        JSONObject content = new JSONObject();
                        content.put("title", "我已经审核您" + DateUtil.dateToStr(prescription.getCreateTime(), "yyyy-MM-dd") + "发起的续方申请");
                        content.put("result", "审核通过");
                        content.put("reason", "");
                        content.put("url", "");
                        imUtill.sendTopicIM(prescription.getDoctor(), prescription.getDoctorName(), prescription.getConsult(), "15", content.toString(), null);
                        //添加日志
                        prescriptionLogService.addLog(prescription,PrescriptionLog.PrescriptionLogType.zy.getValue(),1,2);
                        re.put("status",200);
                    }else {
                        //请求失败
                        prescriptionLogService.addLog(prescription,PrescriptionLog.PrescriptionLogType.zy.getValue(),0,2);
                        JSONArray byRefParaData = data.getJSONArray("byRefParaData");
                        re.put("status",-1);
                        re.put("msg",byRefParaData.getJSONObject(0).getString("errorMsg"));
                    }
                }else {
                    //调整请求失败
                    prescriptionLogService.addLog(prescription,PrescriptionLog.PrescriptionLogType.zy.getValue(),0,2);
                    re.put("status",-1);
                    re.put("msg",data.getString("MESSAGE"));
                }
            }else{
                //请求报错
                prescriptionLogService.addLog(prescription,PrescriptionLog.PrescriptionLogType.zy.getValue(),0,2);
                re.put("status",-1);
                re.put("msg","请求调整失败");
            }
        }else {
            re.put("status",-1);
            re.put("msg","只有待审核和调整失败的续方可以转线下调整");
        }
        return  re;
    }
    /**
     * 上传ca认证信息
     * @param code
     */
    public JSONObject uploadCaDigital(String code){
        JSONObject re = new JSONObject();
        Prescription prescription = prescriptionDao.findByCode(code);
        if(prescription.getStatus()==PrescriptionLog.PrescriptionLogStatus.change_success.getValue()){
            String response = jwPrescriptionService.affirmCARecipe(code);
            JSONObject json = JSONObject.parseObject(response);
            if(json.getInteger("status")==200){
                JSONObject data = json.getJSONObject("data");
                String zyCode = data.getString("CODE");
                if("1".equals(zyCode)){
                    JSONArray returnData = data.getJSONArray("returnData");
                    if(returnData.size()>0){
                        JSONObject pre = returnData.getJSONArray(0).getJSONObject(0);
                        //认证成功-审核完成
                        prescription.setStatus(PrescriptionLog.PrescriptionLogStatus.wait_pay.getValue());
                        //设置审核通过
                        PrescriptionReviewed reviewed = prescriptionReviewedDao.findByPrescriptionCode(code);
                        reviewed.setStatus(1);
                        reviewed.setReviewedTime(new Date());
                        prescriptionDao.save(prescription);
                        //审核通过模板消息
                        prescriptionInfoService.sendRMess(prescription.getCode(), 1);
        }
                        //修改系统的续方消息的审核状态
                        messageDao.updatePreScriptionMessage(prescription.getConsult(), "1", 6);
                        //获取智业待结算接口,更新药品金额
                        prescriptionService.getPerscriptionInfoCostFromPayInfo(prescription.getCode());
                        //添加日志
                        prescriptionLogService.addLog(prescription,PrescriptionLog.PrescriptionLogType.zy.getValue(),1,2);
                        re.put("status",200);
                    }else {
                        //请求失败
                        prescriptionLogService.addLog(prescription,PrescriptionLog.PrescriptionLogType.zy.getValue(),0,2);
                        JSONArray byRefParaData = data.getJSONArray("byRefParaData");
                        re.put("status",-1);
                        re.put("msg",byRefParaData.getJSONObject(0).getString("errorMsg"));
                    }
                }else {
                    //调整请求失败
                    prescriptionLogService.addLog(prescription,PrescriptionLog.PrescriptionLogType.zy.getValue(),0,2);
                    re.put("status",-1);
                    re.put("msg",data.getString("MESSAGE"));
                }
            }else{
                //请求报错
                prescriptionLogService.addLog(prescription,PrescriptionLog.PrescriptionLogType.zy.getValue(),0,2);
                re.put("status",-1);
                re.put("msg","请求调整失败");
            }
        }else {
            re.put("status",-1);
            re.put("msg","只有调整成功的续方才可上传ca认证信息");
        }
        return  re;
    }
}

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

@ -400,6 +400,15 @@ public class PrescriptionInfoService extends BaseService {
                //获取智业待结算接口,更新药品金额
                prescriptionService.getPerscriptionInfoCostFromPayInfo(p.getCode());
                //发送Im消息
                JSONObject content = new JSONObject();
                content.put("title", "我已经审核您" + DateUtil.dateToStr(p.getCreateTime(), "yyyy-MM-dd") + "发起的续方申请");
                content.put("result", "审核通过");
                content.put("reason", "");
                content.put("url", "");
                imUtill.sendTopicIM(p.getDoctor(), p.getDoctorName(), p.getConsult(), "15", content.toString(), null);
                return 1;
            } else {
                p.setStatus(PrescriptionLog.PrescriptionLogStatus.add_error.getValue());
@ -409,7 +418,7 @@ public class PrescriptionInfoService extends BaseService {
                return 0;
            }
        }
        return 0;
        return 1;
    }
    public JSONArray getDoctorPrescription(Integer teamCode, String state, String diseases, String startDate, String endDate, String nameKeyword, String patient, Integer page, Integer size) {
@ -691,6 +700,7 @@ public class PrescriptionInfoService extends BaseService {
                " LEFT(pr.create_time,19) AS createTime, " +
                " pr.doctor, " +
                " pr.dispensary_type AS dispensaryType " +
                " e.expressage_name AS expressageName" +
                " FROM " +
                " wlyy_prescription pr " +
                " LEFT JOIN wlyy_patient p ON pr.patient = p.`code` " +

+ 37 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionAdjustController.java

@ -1,13 +1,16 @@
package com.yihu.wlyy.web.doctor.prescription;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.service.app.prescription.PrescriptionAdjustService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
 * Created by yeshijie on 2017/8/17.
@ -24,8 +27,39 @@ public class PrescriptionAdjustController extends BaseController {
    @Autowired
    private PrescriptionAdjustService prescriptionAdjustService;
    @RequestMapping(value = "adjustPrescription",method = RequestMethod.POST)
    @ObserverRequired
    @ApiOperation("线下调整处方")
    public String adjustPrescription(@ApiParam(name = "code", value = "续方code", defaultValue = "10")
                                     @RequestParam(value = "code", required = true) String code){
        try{
            JSONObject json = prescriptionAdjustService.adjustPrescription(code);
            if(json.getInteger("status")==-1){
                return error(-1,json.getString("msg"));
            }
            return write(200,"请求调整成功");
        }catch (Exception e){
            error(e);
            return error(-1,"调整失败");
        }
    }
    @RequestMapping(value = "uploadCaDigital",method = RequestMethod.POST)
    @ObserverRequired
    @ApiOperation("上传基位ca认证信息")
    public String uploadCaDigital(@ApiParam(name = "code", value = "续方code", defaultValue = "10")
                                  @RequestParam(value = "code", required = true) String code){
        try{
            JSONObject json = prescriptionAdjustService.uploadCaDigital(code);
            if(json.getInteger("status")==-1){
                return error(-1,json.getString("msg"));
            }
            return write(200,"请求调整成功");
        }catch (Exception e){
            error(e);
            return error(-1,"调整失败");
        }
    }