Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/dev' into dev

wangxingwang 7 gadi atpakaļ
vecāks
revīzija
3986f758c0
31 mainītis faili ar 1227 papildinājumiem un 655 dzēšanām
  1. 85 0
      common/common-entity/src/main/java/com/yihu/mm/entity/patient/ExamReport.java
  2. 11 0
      common/common-entity/src/main/java/com/yihu/mm/entity/patient/PatientExam.java
  3. 9 0
      common/common-entity/src/main/java/com/yihu/mm/entity/questionnaire/MedicineAnswerLog.java
  4. 1 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/Prescription.java
  5. 0 22
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/controller/BaseController.java
  6. 88 41
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/controller/medicine/PhysicalExaminationController.java
  7. 17 0
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/repository/mm/exam/MedicineAnswerLogDao.java
  8. 2 2
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/repository/mm/patient/PatientExamDao.java
  9. 36 0
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/service/MedicineAnswerLogService.java
  10. 15 12
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/service/PhysicalExaminationService.java
  11. 46 0
      patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/util/JSONUtil.java
  12. 12 9
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/yueren/YueRenController.java
  13. 7 6
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/medicine/entity/WlyyMedicineKey.java
  14. 7 0
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/medicine/repository/WlyyMedicineKeyDao.java
  15. 4 1
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/family/FamilyMemberService.java
  16. 32 2
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/medicine/WlyyMedicineKeyService.java
  17. 4 4
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/util/HttpClientUtil.java
  18. 14 1
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/PrescriptionController.java
  19. 34 1
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionService.java
  20. 1 16
      patient-co-service/wlyy_service/src/main/resources/application.yml
  21. 234 217
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/adapter/PresModeAdapter.java
  22. 378 294
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/ZyDictDataService.java
  23. 28 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionDispensaryCodeService.java
  24. 2 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionExpressageService.java
  25. 36 11
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionInfoService.java
  26. 51 9
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java
  27. 11 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/prescription/PrescriptionInfoController.java
  28. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java
  29. 20 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionController.java
  30. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionInfoController.java
  31. 40 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/ZyDictController.java

+ 85 - 0
common/common-entity/src/main/java/com/yihu/mm/entity/patient/ExamReport.java

@ -0,0 +1,85 @@
package com.yihu.mm.entity.patient;
import com.yihu.mm.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
@Entity
@Table(name = "exam_report")
public class ExamReport extends IdEntity implements Serializable {
    @Column(name="patient")
    private String patient;//居民code
    @Column(name="cc_id")
    private String ccId;//咨询结论编号
    @Column(name="ct_id")
    private String ctId;//咨询编号
    @Column(name="cl_id")
    private String clId;//结论编号
    @Column(name="cc_last")
    private String ccLast;//最终结论
    @Column(name="cl_template")
    private String clTemplate;//显示模板
    @Column(name="cl_sort")
    private String clSort;//结论排序权重
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getCcId() {
        return ccId;
    }
    public void setCcId(String ccId) {
        this.ccId = ccId;
    }
    public String getCtId() {
        return ctId;
    }
    public void setCtId(String ctId) {
        this.ctId = ctId;
    }
    public String getClId() {
        return clId;
    }
    public void setClId(String clId) {
        this.clId = clId;
    }
    public String getCcLast() {
        return ccLast;
    }
    public void setCcLast(String ccLast) {
        this.ccLast = ccLast;
    }
    public String getClTemplate() {
        return clTemplate;
    }
    public void setClTemplate(String clTemplate) {
        this.clTemplate = clTemplate;
    }
    public String getClSort() {
        return clSort;
    }
    public void setClSort(String clSort) {
        this.clSort = clSort;
    }
}

+ 11 - 0
common/common-entity/src/main/java/com/yihu/mm/entity/patient/PatientExam.java

@ -18,6 +18,9 @@ public class PatientExam extends IdEntity implements Serializable {
    @Column(name="tp_id")
    private String tpId;
    @Column(name="tp_name")
    private String tpName;
    @Column(name="ct_id")
    private String ctId;
@ -55,4 +58,12 @@ public class PatientExam extends IdEntity implements Serializable {
    public void setIsComplete(Integer isComplete) {
        this.isComplete = isComplete;
    }
    public String getTpName() {
        return tpName;
    }
    public void setTpName(String tpName) {
        this.tpName = tpName;
    }
}

+ 9 - 0
common/common-entity/src/main/java/com/yihu/mm/entity/questionnaire/MedicineAnswerLog.java

@ -18,6 +18,7 @@ public class MedicineAnswerLog extends IdEntity {
    private String tpId;    //试卷编号
    private String tpName; //试卷名称
    private String pbType;  //问卷类型
    private String pbId;//试题编号
    private Date createTime;    //创建时间
    private String problems;    //问题的集合
@ -69,4 +70,12 @@ public class MedicineAnswerLog extends IdEntity {
    public void setPbType(String pbType) {
        this.pbType = pbType;
    }
    public String getPbId() {
        return pbId;
    }
    public void setPbId(String pbId) {
        this.pbId = pbId;
    }
}

+ 1 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/prescription/Prescription.java

@ -638,6 +638,7 @@ public class Prescription extends IdEntity {
        this.prescribeReason = prescribeReason;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getPrescribeTime() {
        return prescribeTime;
    }

+ 0 - 22
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/controller/BaseController.java

@ -1,7 +1,6 @@
package com.yihu.mm.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.IdEntity;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -389,27 +388,6 @@ public class BaseController {
		}
	}
	/**
	* 返回接口处理结果
	*
	*
	* @param code 结果码,成功为200
	* @param msg 结果提示信息
	* @return
	*/
	public String write(int code, String msg, String key, IdEntity entity) {
		try {
			Map<Object, Object> map = new HashMap<Object, Object>();
			ObjectMapper mapper = new ObjectMapper();
			map.put("status", code);
			map.put("msg", msg);
			map.put(key, entity);
			return mapper.writeValueAsString(map);
		} catch (Exception e) {
			error(e);
			return error(-1, "服务器异常,请稍候再试!");
		}
	}
	/**
	 * 返回接口处理结果

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

@ -2,10 +2,13 @@ package com.yihu.mm.controller.medicine;
import com.yihu.mm.controller.BaseController;
import com.yihu.mm.entity.patient.PatientExam;
import com.yihu.mm.entity.questionnaire.MedicineAnswerLog;
import com.yihu.mm.service.MedicineAnswerLogService;
import com.yihu.mm.service.PatientExamService;
import com.yihu.mm.service.PatientService;
import com.yihu.mm.service.PhysicalExaminationService;
import com.yihu.mm.util.HttpClientUtil;
import com.yihu.wlyy.entity.patient.Patient;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
@ -19,6 +22,8 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Date;
@RestController
@RequestMapping(value = "/medicine/physicalExamination")
@ -35,6 +40,8 @@ public class PhysicalExaminationController extends BaseController {
    @Autowired
    private PhysicalExaminationService physicalExaminationService;
    @Autowired
    private MedicineAnswerLogService medicineAnswerLogService;
    @Autowired
    private PatientExamService patientExamService;
@ -47,22 +54,33 @@ public class PhysicalExaminationController extends BaseController {
                             HttpServletRequest req
                             ) {
        HttpSession session = req.getSession();
        String key = (String) session.getAttribute("key");
        if(StringUtils.isBlank(key)){
            //通过接口查询key
            String result = HttpClientUtil.postBody(yuerenApi + "/phonekey", new JSONObject());
            JSONObject jsonObject = new JSONObject(result);
            String status = jsonObject.get("status").toString();
            if ("200".equals(status)) {
                JSONObject recordset = jsonObject.getJSONObject("recordset");
                key = recordset.getString("key");
            }else{
                return result;
            }
            session.setMaxInactiveInterval(60*60*4);
            session.setAttribute("key",key);
            String key = (String) session.getAttribute("key");
            if(StringUtils.isBlank(key)){
                //通过接口查询key
                String result = HttpClientUtil.postBody(yuerenApi + "/phonekey", new JSONObject());
                JSONObject jsonObject = new JSONObject(result);
                String status = jsonObject.get("status").toString();
                if ("200".equals(status)) {
                    JSONObject recordset = jsonObject.getJSONObject("recordset");
                    key = recordset.getString("key");
                }else{
                    return result;
                }
                session.setMaxInactiveInterval(60*60*4);
                session.setAttribute("key",key);
        }
        return physicalExaminationService.findExames(key,tp_type, examCode);
        String exames = physicalExaminationService.findExames(tp_type, examCode);
        //if(StringUtils.isNotBlank(examCode)){
        //    JSONObject examJson = new JSONObject(exames);
        //    String exam_status = examJson.get("status").toString();
        //    if ("200".equals(exam_status)) {
        //        JSONObject recordset = examJson.getJSONObject("recordset");
        //        key = recordset.getString("key");
        //    }else{
        //        return result;
        //    }
        //}
        return exames;
    }
    @ApiOperation(value = "新增预约单/获取咨询编号等信息")
@ -70,9 +88,8 @@ public class PhysicalExaminationController extends BaseController {
    @ResponseBody
    public String insertslip(@ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode, HttpServletRequest req){
        String key = (String) req.getSession().getAttribute("key");
        //Patient patient = patientService.findByCode(patientCode);
        //return physicalExaminationService.insertslip(key,patient);
        return null;
        Patient patient = patientService.findByCode(patientCode);
        return physicalExaminationService.insertslip(patient);
    }
@ -82,31 +99,42 @@ public class PhysicalExaminationController extends BaseController {
    public String findQuestion(@ApiParam(name = "tp_id", value = "试卷id", required = true)@RequestParam(required = true, name = "tp_id") String tp_id,
                               @ApiParam(name = "pb_id", value = "问卷编号,第一题为0", required = true)@RequestParam(required = true, name = "pb_id") String pb_id,
                               @ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode,
                               HttpServletRequest req){
        HttpSession session = req.getSession();
        String key = (String) session.getAttribute("key");
                               HttpServletRequest req) throws IOException {
        String ct_id="";
        PatientExam patientExam = patientExamService.findByPatientAndTpId(patientCode, tp_id);
        if(patientExam==null){
            //Patient patient = patientService.findByCode(patientCode);
            //String result = physicalExaminationService.insertslip(key, patient);
            //JSONObject jsonObject = new JSONObject(result);
            //String status = jsonObject.get("status").toString();
            //if ("200".equals(status)) {
            //    JSONObject recordset = jsonObject.getJSONObject("recordset");
            //    ct_id = recordset.getString("ct_id");
            //    patientExam = new PatientExam();
            //    patientExam.setCtId(ct_id);
            //    patientExam.setPatient(patientCode);
            //    patientExam.setIsComplete(0);
            //    patientExam.setTpId(tp_id);
            //    patientExamService.save(patientExam);
            //}else{
            //    return result;
            //}
            Patient patient = patientService.findByCode(patientCode);
            String result = physicalExaminationService.insertslip(patient);
            JSONObject jsonObject = new JSONObject(result);
            String status = jsonObject.get("status").toString();
            if ("200".equals(status)) {
                JSONObject recordset = jsonObject.getJSONObject("recordset");
                ct_id = recordset.get("ct_id").toString();
                patientExam = new PatientExam();
                patientExam.setCtId(ct_id);
                patientExam.setPatient(patientCode);
                patientExam.setIsComplete(0);
                patientExam.setTpId(tp_id);
                patientExamService.save(patientExam);
            }else{
                return result;
            }
        }else{
            ct_id = patientExam.getCtId();
        }
        String question = physicalExaminationService.findQuestion(tp_id, pb_id, ct_id);
        JSONObject jsonQuestion = new JSONObject(question);
        jsonQuestion.put("answer","");
        //查找居民是否已经答过该试题
        MedicineAnswerLog answer = medicineAnswerLogService.findAnswer(patientCode, tp_id, pb_id);
        if(answer!=null){
            jsonQuestion.put("answer",answer);
        }
        String question = physicalExaminationService.findQuestion(key, tp_id, pb_id, ct_id);
        //Map<String, Object> resp = customerService.findServerInfo(patient);
        //resp.put("patient",patient);
        //return write(1,"查询成功","data",resp);
        return question;
    }
@ -115,14 +143,30 @@ public class PhysicalExaminationController extends BaseController {
    @ResponseBody
    public String handleExam(@ApiParam(name = "tp_id", value = "试卷id", required = true)@RequestParam(required = true, name = "tp_id") String tp_id,
                               @ApiParam(name = "pb_id", value = "问卷编号,第一题为0", required = true)@RequestParam(required = true, name = "pb_id") String pb_id,
                                @ApiParam(name = "i_multiselect", value = "试题类型(0单选 ,1多选)", required = true)@RequestParam(required = true, name = "i_multiselect") String i_multiselect,
                               @ApiParam(name = "dc_answer", value = "问题答案", required = true)@RequestParam(required = true, name = "dc_answer") String dc_answer,
                             @ApiParam(name = "patientCode", value = "居民code", required = true)@RequestParam(required = true, name = "patientCode") String patientCode,
                             @ApiParam(name = "isLast", value = "是否是最后一题(0否 ,1是)", required = true)@RequestParam(required = true, name = "isLast") String isLast,
                            HttpServletRequest req){
        String key = (String) req.getSession().getAttribute("key");
        PatientExam patientExam = patientExamService.findByPatientAndTpId(patientCode, tp_id);
        String tpName = patientExam.getTpName();
        String ct_id = patientExam.getCtId();
        String result = physicalExaminationService.handleExam(key, tp_id, pb_id, dc_answer, ct_id);
        String result = physicalExaminationService.handleExam(tp_id, pb_id, dc_answer, ct_id);
        //将答案保存到自己数据库
        MedicineAnswerLog medicineAnswerLog = new MedicineAnswerLog();
        medicineAnswerLog.setPatientCode(patientCode);
        medicineAnswerLog.setTpId(tp_id);
        medicineAnswerLog.setTpName(tpName);
        medicineAnswerLog.setPbType(String.valueOf(i_multiselect));
        medicineAnswerLog.setCreateTime(new Date());
        medicineAnswerLog.setProblems(dc_answer);
        medicineAnswerLogService.save(medicineAnswerLog);
        //最后一题
        if("1".equals(isLast)){
        }
        return result;
    }
@ -142,6 +186,9 @@ public class PhysicalExaminationController extends BaseController {
    @RequestMapping(value = "/findconconhealth",produces="application/json;charset=UTF-8")
    @ResponseBody
    public String findconconhealth(@ApiParam(name = "ct_id", value = "咨询编号", required = true)@RequestParam(required = true, name = "ct_id") String ct_id){
        String result = physicalExaminationService.findconconhealth(ct_id);
        return null;
    }

+ 17 - 0
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/repository/mm/exam/MedicineAnswerLogDao.java

@ -0,0 +1,17 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.mm.repository.mm.exam;
import com.yihu.mm.entity.questionnaire.MedicineAnswerLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface MedicineAnswerLogDao extends PagingAndSortingRepository<MedicineAnswerLog, String>,JpaSpecificationExecutor<MedicineAnswerLog> {
	@Query("select m from MedicineAnswerLog m where m.patientCode=?1 and m.tpId=?2 and m.pbId=?3")
    MedicineAnswerLog findAnswer(String patientCode, String tp_id, String pb_id);
}

+ 2 - 2
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/repository/mm/patient/PatientExamDao.java

@ -13,7 +13,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
public interface PatientExamDao extends PagingAndSortingRepository<PatientExam, String>,JpaSpecificationExecutor<PatientExam> {
	// 查询患者code和试卷编号查询
	@Query("select p from PatientExam p where p.id=?1 and p.tpId=?2")
	PatientExam findByPatientAndTpId(String id, String tpId);
	@Query("select p from PatientExam p where p.patient=?1 and p.tpId=?2")
	PatientExam findByPatientAndTpId(String patientCode, String tpId);
}

+ 36 - 0
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/service/MedicineAnswerLogService.java

@ -0,0 +1,36 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.mm.service;
import com.yihu.mm.entity.questionnaire.MedicineAnswerLog;
import com.yihu.mm.repository.mm.exam.MedicineAnswerLogDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.persistence.Transient;
/**
 * 患者基本信息类.
 *
 * @author George
 */
@Service
public class MedicineAnswerLogService {
    @Autowired
    private MedicineAnswerLogDao medicineAnswerLogDao;
    @Transient
    public void save(MedicineAnswerLog medicineAnswerLog){
        medicineAnswerLogDao.save(medicineAnswerLog);
    }
    public MedicineAnswerLog findAnswer(String patientCode,String tp_id,String pb_id){
        return  medicineAnswerLogDao.findAnswer(patientCode,tp_id,pb_id);
    }
}

+ 15 - 12
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/service/PhysicalExaminationService.java

@ -15,21 +15,19 @@ public class PhysicalExaminationService {
    @Value(("${yuerenApi}"))
    private String yuerenApi;
    public String findExames(String key,String type, String examCode) {
    public String findExames(String type, String examCode) {
        //先获取key值
        JSONObject params = new JSONObject();
        params.put("key",key);
        params.put("tp_type", type);
        params.put("sh_id", examCode);
        return HttpClientUtil.postBody(yuerenApi + "/findtest", params);
    }
    public String insertslip(String key,Patient patient) {
    public String insertslip(Patient patient) {
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        JSONObject params = new JSONObject();
        params.put("key", key);
        params.put("sl_date", sdf.format(date));
        params.put("sl_state", "未签到");
        params.put("u_tel", patient.getMobile());
@ -44,7 +42,7 @@ public class PhysicalExaminationService {
        params.put("u_sex",sexStr );
        //todo    sh_id 需要从数据库获取   wlyy_medicine_strores_no
        params.put("sh_id", "");
        params.put("sh_id", "52");
        params.put("u_idnum", patient.getIdcard());
        //params.put("u_native", u_native);//籍贯
        params.put("u_birthday", patient.getBirthday());
@ -53,27 +51,32 @@ public class PhysicalExaminationService {
        params.put("u_area", patient.getTownName());
        params.put("u_address", patient.getAddress());
        //params.put("sl_pass", );//报告单是否审核通过
        return HttpClientUtil.postBody(yuerenApi + "/findtest", params);
        return HttpClientUtil.postBody(yuerenApi + "/insertslip", params);
    }
    public String findQuestion(String key, String tp_id, String pb_id, String ct_id) {
    public String findQuestion(String tp_id, String pb_id, String ct_id) {
        JSONObject params = new JSONObject();
        params.put("key", key);
        params.put("ct_id", ct_id);
        params.put("tp_id", tp_id);
        params.put("pb_id", pb_id);
        String postStr = HttpClientUtil.postBody("/yueren/giveproblem", params);
        String postStr = HttpClientUtil.postBody(yuerenApi+"/giveproblem", params);
        return postStr;
    }
    public String handleExam(String key, String tp_id, String pb_id, String dc_answer, String ct_id) {
    public String handleExam(String tp_id, String pb_id, String dc_answer, String ct_id) {
        JSONObject params = new JSONObject();
        params.put("key", key);
        params.put("ct_id", ct_id);
        params.put("tp_id", tp_id);
        params.put("pb_id", pb_id);
        params.put("dc_answer", dc_answer);
        return HttpClientUtil.postBody("/yueren/handleproblem", params);
        return HttpClientUtil.postBody(yuerenApi+"/handleproblem", params);
    }
    public String findconconhealth(String ct_id) {
        JSONObject params = new JSONObject();
        params.put("ct_id", ct_id);
        params.put("reqtype", 1);
        return HttpClientUtil.postBody(yuerenApi+"/findconconhealth", params);
    }
}

+ 46 - 0
patient-co-customization/patient-co-modern-medicine/src/main/java/com/yihu/mm/util/JSONUtil.java

@ -0,0 +1,46 @@
package com.yihu.mm.util;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
public class JSONUtil {
    /**
     * 将json转化为实体POJO
     * @param jsonStr
     * @param obj
     * @return
     */
    public static<T> Object JSONToObj(String jsonStr,Class<T> obj) {
        T t = null;
        try {
            ObjectMapper objectMapper = new ObjectMapper();
            t = objectMapper.readValue(jsonStr,
                    obj);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return t;
    }
    /**
     * 将实体POJO转化为JSON
     * @param obj
     * @return
     * @throws JSONException
     * @throws IOException
     */
    public static<T> JSONObject objectToJson(T obj) throws JSONException, IOException {
        ObjectMapper mapper = new ObjectMapper();
        // Convert object to JSON string
        String jsonStr = "";
        try {
            jsonStr =  mapper.writeValueAsString(obj);
        } catch (IOException e) {
            throw e;
        }
        return new JSONObject(jsonStr);
    }
}

+ 12 - 9
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/yueren/YueRenController.java

@ -35,15 +35,8 @@ public class YueRenController extends BaseController {
    @RequestMapping(value = "/phonekey", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String getPhoneKey() {
        String postStr = remoteCall("/yueren/phonekey", new JSONObject());
        JSONObject jsonObject = new JSONObject(postStr);
        String status = jsonObject.get("status").toString();
        if ("200".equals(status)) {
            JSONObject recordset = jsonObject.getJSONObject("recordset");
            String key = recordset.getString("key");
            this.saveKey(key);
        }
        return postStr;
        String key =wlyyMedicineKeyService.getKey();
        return  write(200,"查询成功","key",key);
    }
    /**
@ -55,6 +48,7 @@ public class YueRenController extends BaseController {
    @ResponseBody
    public String insertSlip(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/insertslip", params);
        return postStr;
    }
@ -83,6 +77,7 @@ public class YueRenController extends BaseController {
    @ResponseBody
    public String inserTemp(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/dillphoneimgdata", params);
        return postStr;
    }
@ -98,6 +93,7 @@ public class YueRenController extends BaseController {
    @ResponseBody
    public String findTest(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/findtest", params);
        return postStr;
    }
@ -111,6 +107,7 @@ public class YueRenController extends BaseController {
    @ResponseBody
    public String giveproblem(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/giveproblem", params);
        return postStr;
    }
@ -124,6 +121,7 @@ public class YueRenController extends BaseController {
    @ResponseBody
    public String handleproblem(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/handleproblem", params);
        return postStr;
    }
@ -137,6 +135,7 @@ public class YueRenController extends BaseController {
    @ResponseBody
    public String centralizedproblem(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/centralizedproblem", params);
        return postStr;
    }
@ -150,6 +149,7 @@ public class YueRenController extends BaseController {
    @ResponseBody
    public String conclusionFactor(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/conclusionfactor", params);
        return postStr;
    }
@ -165,6 +165,7 @@ public class YueRenController extends BaseController {
    @ResponseBody
    public String insertConsultConclusionHealth(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/insertconconhealth", params);
        return postStr;
    }
@ -178,6 +179,7 @@ public class YueRenController extends BaseController {
    @ResponseBody
    public String insertConsultConclusion(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/findconconhealth", params);
        return postStr;
    }
@ -191,6 +193,7 @@ public class YueRenController extends BaseController {
    @ResponseBody
    public String findIntegral(@RequestBody String jsonString) {
        JSONObject params = new JSONObject(jsonString);
        params.put("key",wlyyMedicineKeyService.getKey());
        String postStr = remoteCall("/yueren/findintegral", params);
        return postStr;
    }

+ 7 - 6
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/medicine/entity/WlyyMedicineKey.java

@ -1,7 +1,7 @@
package com.yihu.wlyy.medicine.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.io.Serializable;
@ -13,20 +13,21 @@ import java.util.Date;
@Entity
@Table(name = "wlyy_medicine_key", schema = "", catalog = "medicine")
public class WlyyMedicineKey implements Serializable {
    private Long id;
    private String id;
    private String accessKey;
    private Long addTimestamp;
    private Long expiresIn;
    private Date creataTime;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", unique = true, nullable = false)
    public Long getId() {
    @GeneratedValue(generator = "uuid")
    @GenericGenerator(name = "uuid", strategy = "uuid")
    public String getId() {
        return id;
    }
    public void setId(Long id) {
    public void setId(String id) {
        this.id = id;
    }

+ 7 - 0
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/medicine/repository/WlyyMedicineKeyDao.java

@ -2,10 +2,17 @@ package com.yihu.wlyy.medicine.repository;
import com.yihu.wlyy.medicine.entity.WlyyMedicineKey;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Administrator on 2017/8/14.
 */
public interface WlyyMedicineKeyDao extends PagingAndSortingRepository<WlyyMedicineKey, Long>, JpaSpecificationExecutor<WlyyMedicineKey> {
    @Query("select w from WlyyMedicineKey w order by w.addTimestamp desc")
    List<WlyyMedicineKey> findAll();
}

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

@ -39,6 +39,7 @@ public class FamilyMemberService extends BaseService {
    @Autowired
    FamilyContractService contractService;
    @Autowired
    private HosDoctorService hosDoctorService;
    Map<Integer, String> relations = new HashMap<>();
@ -126,7 +127,7 @@ public class FamilyMemberService extends BaseService {
        return list;
    }
    public Map getPatient(String patient){
    public Map getPatient(String patient) throws Exception {
        Patient p = patientDao.findByCode(patient);
        //查询签约信息
@ -144,6 +145,8 @@ public class FamilyMemberService extends BaseService {
        }
        map.put("doctor",doctor);
        map.put("doctorName",doctorName);
        Doctor _doctor = hosDoctorService.getDoctorByCode(doctor);
        map.put("doctorMobile",_doctor.getMobile());
        map.put("code", p.getCode());
        map.put("name", p.getName());
        map.put("sex", p.getSex());

+ 32 - 2
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/medicine/WlyyMedicineKeyService.java

@ -2,19 +2,25 @@ package com.yihu.wlyy.service.manager.medicine;
import com.yihu.wlyy.medicine.entity.WlyyMedicineKey;
import com.yihu.wlyy.medicine.repository.WlyyMedicineKeyDao;
import com.yihu.wlyy.util.query.BaseJpaService;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.query.BasemedicineJpaService;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springside.modules.utils.Clock;
import javax.annotation.Resource;
import java.util.List;
/**
 * Created by Administrator on 2017/8/14.
 */
@Service
public class WlyyMedicineKeyService extends BasemedicineJpaService<WlyyMedicineKey, WlyyMedicineKeyDao> {
    @Value("${yueren.api}")
    private String api;
    @Autowired
    private WlyyMedicineKeyDao wlyyMedicineKeyDao;
@ -28,4 +34,28 @@ public class WlyyMedicineKeyService extends BasemedicineJpaService<WlyyMedicineK
        medicineKey.setCreataTime(clock.getCurrentDate());
        wlyyMedicineKeyDao.save(medicineKey);
    }
    public String getKey() {
        String key="";
        List<WlyyMedicineKey> wlyyMedicineKeys = wlyyMedicineKeyDao.findAll();
        if(wlyyMedicineKeys!=null && wlyyMedicineKeys.size()>0){
            for (WlyyMedicineKey wlyyMedicineKey : wlyyMedicineKeys) {
                if ((System.currentTimeMillis() - wlyyMedicineKey.getAddTimestamp()) < (wlyyMedicineKey.getExpiresIn() * 1000)) {
                    return wlyyMedicineKey.getAccessKey();
                } else {
                    wlyyMedicineKeyDao.delete(wlyyMedicineKey);
                }
            }
        }
        String postStr = HttpClientUtil.postBody(api + "/yueren/phonekey", new JSONObject());
        JSONObject jsonObject = new JSONObject(postStr);
        String status = jsonObject.get("status").toString();
        if ("200".equals(status)) {
            JSONObject recordset = jsonObject.getJSONObject("recordset");
            key = recordset.getString("key");
            this.saveKey(key);
        }
        return key;
    }
}

+ 4 - 4
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/util/HttpClientUtil.java

@ -1,9 +1,5 @@
package com.yihu.wlyy.util;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.ParseException;
@ -20,6 +16,10 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.web.client.RestTemplate;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.List;
public class HttpClientUtil {
	/**

+ 14 - 1
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/PrescriptionController.java

@ -42,7 +42,7 @@ public class PrescriptionController extends BaseController{
	}
	@RequestMapping(value = "prePayCompletion",method = RequestMethod.POST)
	@ApiOperation("接收预结算完成消息")
	@ApiOperation("接收预结算完成消息(废弃)")
	public Result prePayCompletion(@ApiParam(name="data",value="json串",defaultValue = "{\"CODE\":1,\"RECIPE_NO\":\"0\",\"ORDER_NO\":\"DB0537136\"}")
								   @RequestParam(value = "data",required = true) String data){
		try {
@ -230,6 +230,19 @@ public class PrescriptionController extends BaseController{
		}
	}
	@RequestMapping(value = "affirmCARecipe",method = RequestMethod.POST)
	@ApiOperation("CA认证通过接口")
	public Result affirmCARecipe(@ApiParam(name="code",value="续方code",defaultValue = "")
								 @RequestParam(value = "code",required = true) String code){
		try {
			String re = prescriptionService.affirmCARecipe(code);
			return Result.success("CA认证通过接口!",re);
		} catch (Exception ex) {
			ex.printStackTrace();
			return Result.error(ex.getMessage());
		}
	}
	/************************************ CA认证 ************************************************************/
	@RequestMapping(value = "RequestRealNameSoftCertAndSign",method = RequestMethod.POST)
	@ResponseBody

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

@ -542,7 +542,7 @@ public class PrescriptionService extends ZysoftBaseService{
        if(prescriptionDiagnosisList.size()>1){
            json.put("DIAGNOSE_SUB_CODE",prescriptionDiagnosisList.get(1).getCode());//"DIAGNOSE_CODE": "次诊断编码",
        }
        if(prescription.getCaCertData()==null){
        if(prescription.getCaCertData()!=null){
            json.put("ORIGINAL_DATA",prescription.getStrOriginalData());//原文
            json.put("ORIGINAL_DATA_MD5",prescription.getOriginalDataAbstract());//原文的MD5摘要
            json.put("CA_SIGN_DATA",prescription.getCaMessage());//签名值
@ -743,6 +743,39 @@ public class PrescriptionService extends ZysoftBaseService{
        return response;
    }
    /**
     * CA认证通过接口
     * @param code
     * @return
     */
    public String affirmCARecipe(String code) throws Exception{
        Prescription prescription = prescriptionDao.findByCode(code);
        String[] hospitalMapping = getHospitalMapping(prescription.getHospital()); //获取机构映射
        String hospital = hospitalMapping[0];
        String licence = hospitalMapping[1];
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        //拼接开方参数
        JSONObject json = new JSONObject();
        json.put("recipeNo",prescription.getRecipeNo());// "recipeNo": "医嘱号",
        if(prescription.getCaCertData()!=null){
            json.put("ORIGINAL_DATA",prescription.getStrOriginalData());//原文
            json.put("ORIGINAL_DATA_MD5",prescription.getOriginalDataAbstract());//原文的MD5摘要
            json.put("CA_SIGN_DATA",prescription.getCaMessage());//签名值
            json.put("CA_CERTMAIN_DATA",prescription.getCaCertData());//签名证书主体数据
            json.put("CA_DIGITAL_SIGN_STREAM_NO_UUID",prescription.getDigitalSignNo());//CA数字签名唯一流水号
        }else {
            throw new Exception("未找到ca认证数据");
        }
        String response = postSecond("affirmCARecipe","CA认证通过接口",null,json,header,false,2);
        return response;
    }
    /*********************************************请求智业接口数据 end**************************************************/

+ 1 - 16
patient-co-service/wlyy_service/src/main/resources/application.yml

@ -57,7 +57,7 @@ redisChannel:
---
spring:
  profiles: dev1
  profiles: dev
  datasource:
    url: jdbc:mysql://172.19.103.77:3306/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
    username: root
@ -71,21 +71,6 @@ spring:
    port: 6379 # Redis server port.
#    password: jkzl_ehr
---
spring:
  profiles: dev
  datasource:
    url: jdbc:mysql://172.19.103.85:3306/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
    username: linzhou
    password: linzhou
    driverClassName: com.mysql.jdbc.Driver
    maxTotal: 500
    maxIdle: 30
  redis:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
#    password: jkzl_ehr
---
spring:
  profiles: test

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

@ -8,6 +8,8 @@ import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.service.system.Icd10DictServcie;
import com.yihu.wlyy.service.third.jw.ZyDictService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -21,6 +23,7 @@ import java.util.List;
@Component
public class PresModeAdapter {
    private static Logger logger = LoggerFactory.getLogger(PresModeAdapter.class);
    @Autowired
    private Icd10DictServcie icd10DictServcie;
    @Autowired
@ -33,64 +36,69 @@ public class PresModeAdapter {
     * @throws Exception
     */
    public JSONArray modeTopresInfo(String json) throws Exception{
        JSONObject oldJson = JSONObject.parseObject(json);
        String dataStr = oldJson.getString("data");
        JSONObject data = JSONObject.parseObject(dataStr);
        JSONArray returnData = data.getJSONArray("returnData");
        String code = data.getString("CODE");
        if(StringUtils.isNotBlank(code)&&"1".equals(code)){
            JSONArray rs = new JSONArray();
            Iterator iterator = returnData.iterator();
            while (iterator.hasNext()){
                JSONArray modeArray = (JSONArray) iterator.next();
                for(int i=0;i<modeArray.size();i++){
                    JSONObject mode = (JSONObject) modeArray.get(i);
                    JSONObject m = new JSONObject();
                    m.put("templateNo",mode.getInteger("TEMPLATE_NO"));
                    m.put("templateName",mode.getString("TEMPLATE_NAME"));
                    //m.put("templateExplain",mode.getInt("TEMPLATE_EXPLAIN"));
                    JSONArray infos = mode.getJSONArray("TEMPLATE_DETAIL");
                    Iterator infoIt = infos.iterator();
                    JSONArray is = new JSONArray();
                    while (infoIt.hasNext()){
                        JSONObject info = (JSONObject) infoIt.next();
                        PrescriptionInfo prescriptionInfo = new PrescriptionInfo();
                        prescriptionInfo.setRemark(info.getString("REMARK"));
                        prescriptionInfo.setBindFlag(info.getString("BIND_FLAG"));
                        prescriptionInfo.setDirection(info.getString("USAGE_NAME"));//药品用法
                        prescriptionInfo.setDrugCode(info.getString("ITEM_CODE"));//药品code
                        prescriptionInfo.setDrugName(info.getString("ITEM_NAME"));//药品名称
                        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.setNum(info.getInteger("ITEM_QUANTITY"));//药品数目
                        prescriptionInfo.setJwSubCode("");//智业子处方号
                        prescriptionInfo.setDrugNumUnit(info.getString("ITEM_UNIT"));//数量单位编码
                        prescriptionInfo.setDrugNumUnitName(info.getString("ITEM_UNIT_NAME"));//数量单位名称
                        prescriptionInfo.setCost(1);//金额
                        prescriptionInfo.setCharge(0);//自付
                        prescriptionInfo.setBindFlag("0");//成组标志, 0.非成组,1.成组
                        prescriptionInfo.setDayCount(info.getInteger("DAY_COUNT"));//用药天数
                        prescriptionInfo.setDrugUsage(info.getString("USAGE"));//用药方法编码
                        prescriptionInfo.setUsageName(info.getString("USAGE_NAME"));//用药方法名称
                        prescriptionInfo.setPhysicDose(info.getString("PHYSIC_DOSE"));//用药剂量
                        prescriptionInfo.setPhysicDoseUnit(info.getString("PHYSIC_DOSE_UNIT"));//剂量单位编码
                        prescriptionInfo.setPhysicDoseUnitName(info.getString("PHYSIC_DOSE_UNIT_NAME"));//剂量单位名称
                        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.setPhysicSkinTest(info.getString("PHYSIC_SKIN_TEST"));//皮试类型名称
                        prescriptionInfo.setPhysicSkinTestName(info.getString("PHYSIC_SKIN_TEST_NAME"));//皮试类型名称
                        is.add(prescriptionInfo);
        try{
            JSONObject oldJson = JSONObject.parseObject(json);
            String dataStr = oldJson.getString("data");
            JSONObject data = JSONObject.parseObject(dataStr);
            JSONArray returnData = data.getJSONArray("returnData");
            String code = data.getString("CODE");
            if(StringUtils.isNotBlank(code)&&"1".equals(code)){
                JSONArray rs = new JSONArray();
                Iterator iterator = returnData.iterator();
                while (iterator.hasNext()){
                    JSONArray modeArray = (JSONArray) iterator.next();
                    for(int i=0;i<modeArray.size();i++){
                        JSONObject mode = (JSONObject) modeArray.get(i);
                        JSONObject m = new JSONObject();
                        m.put("templateNo",mode.getInteger("TEMPLATE_NO"));
                        m.put("templateName",mode.getString("TEMPLATE_NAME"));
                        //m.put("templateExplain",mode.getInt("TEMPLATE_EXPLAIN"));
                        JSONArray infos = mode.getJSONArray("TEMPLATE_DETAIL");
                        Iterator infoIt = infos.iterator();
                        JSONArray is = new JSONArray();
                        while (infoIt.hasNext()){
                            JSONObject info = (JSONObject) infoIt.next();
                            PrescriptionInfo prescriptionInfo = new PrescriptionInfo();
                            prescriptionInfo.setRemark(info.getString("REMARK"));
                            prescriptionInfo.setBindFlag(info.getString("BIND_FLAG"));
                            prescriptionInfo.setDirection(info.getString("USAGE_NAME"));//药品用法
                            prescriptionInfo.setDrugCode(info.getString("ITEM_CODE"));//药品code
                            prescriptionInfo.setDrugName(info.getString("ITEM_NAME"));//药品名称
                            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.setNum(info.getInteger("ITEM_QUANTITY"));//药品数目
                            prescriptionInfo.setJwSubCode("");//智业子处方号
                            prescriptionInfo.setDrugNumUnit(info.getString("ITEM_UNIT"));//数量单位编码
                            prescriptionInfo.setDrugNumUnitName(info.getString("ITEM_UNIT_NAME"));//数量单位名称
                            prescriptionInfo.setCost(1);//金额
                            prescriptionInfo.setCharge(0);//自付
                            prescriptionInfo.setBindFlag("0");//成组标志, 0.非成组,1.成组
                            prescriptionInfo.setDayCount(info.getInteger("DAY_COUNT"));//用药天数
                            prescriptionInfo.setDrugUsage(info.getString("USAGE"));//用药方法编码
                            prescriptionInfo.setUsageName(info.getString("USAGE_NAME"));//用药方法名称
                            prescriptionInfo.setPhysicDose(info.getString("PHYSIC_DOSE"));//用药剂量
                            prescriptionInfo.setPhysicDoseUnit(info.getString("PHYSIC_DOSE_UNIT"));//剂量单位编码
                            prescriptionInfo.setPhysicDoseUnitName(info.getString("PHYSIC_DOSE_UNIT_NAME"));//剂量单位名称
                            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.setPhysicSkinTest(info.getString("PHYSIC_SKIN_TEST"));//皮试类型名称
                            prescriptionInfo.setPhysicSkinTestName(info.getString("PHYSIC_SKIN_TEST_NAME"));//皮试类型名称
                            is.add(prescriptionInfo);
                        }
                        m.put("prescriptionInfo",is);
                        rs.add(m);
                    }
                    m.put("prescriptionInfo",is);
                    rs.add(m);
                }
                return rs;
            }
            return rs;
        }catch (Exception e){
            logger.info("PresModeAdapter:modeTopresInfo:Json:"+json);
            throw e;
        }
        return null;
    }
@ -102,98 +110,103 @@ public class PresModeAdapter {
     * @throws Exception
     */
    public JSONArray modeToPrescription(String json)throws Exception{
        JSONObject oldJson = JSONObject.parseObject(json);
        JSONObject data = oldJson.getJSONObject("data");
        JSONArray returnData = data.getJSONArray("returnData");
        String code = data.getString("CODE");
        if(StringUtils.isNotBlank(code)&&"1".equals(code)){
            JSONArray rs = new JSONArray();
            Iterator iterator = returnData.iterator();
            while (iterator.hasNext()){
                JSONArray modeArray = (JSONArray) iterator.next();
                for(int i=0;i<modeArray.size();i++){
                    JSONObject mode = (JSONObject) modeArray.get(i);
                    JSONObject p  = new JSONObject();
                    p.put("code",mode.getInteger("RECIPE_NO")+"");
                    p.put("createTime",mode.getString("APPLY_TIME"));
        try{
            JSONObject oldJson = JSONObject.parseObject(json);
            JSONObject data = oldJson.getJSONObject("data");
            JSONArray returnData = data.getJSONArray("returnData");
            String code = data.getString("CODE");
            if(StringUtils.isNotBlank(code)&&"1".equals(code)){
                JSONArray rs = new JSONArray();
                Iterator iterator = returnData.iterator();
                while (iterator.hasNext()){
                    JSONArray modeArray = (JSONArray) iterator.next();
                    for(int i=0;i<modeArray.size();i++){
                        JSONObject mode = (JSONObject) modeArray.get(i);
                        JSONObject p  = new JSONObject();
                        p.put("code",mode.getInteger("RECIPE_NO")+"");
                        p.put("createTime",mode.getString("APPLY_TIME"));
                    Doctor doctor =  zyDictService.getDoctByJw(mode.getString("APPLY_OPERATOR"),mode.getString("HEALTH_ORG_CODE"));
                    // "APPLY_OPERATOR_NAME": 开单医生姓名","HEALTH_ORG_CODE": "开单机构编码",
                    if(doctor!=null){
                        p.put("doctor",doctor.getCode());
                        p.put("doctorName",doctor.getName());
                        p.put("hospitalName",doctor.getHospitalName());
                        p.put("hospital",doctor.getHospital());
                    }else{
                        p.put("doctor",mode.getString("APPLY_OPERATOR"));
                        p.put("doctorName",mode.getString("APPLY_OPERATOR_NAME"));
                        p.put("hospitalName",mode.getString("HEALTH_ORG_CODE"));
                        p.put("hospital",mode.getString("HEALTH_ORG_CODE"));
                    }
                        Doctor doctor =  zyDictService.getDoctByJw(mode.getString("APPLY_OPERATOR"),mode.getString("HEALTH_ORG_CODE"));
                        // "APPLY_OPERATOR_NAME": 开单医生姓名","HEALTH_ORG_CODE": "开单机构编码",
                        if(doctor!=null){
                            p.put("doctor",doctor.getCode());
                            p.put("doctorName",doctor.getName());
                            p.put("hospitalName",doctor.getHospitalName());
                            p.put("hospital",doctor.getHospital());
                        }else{
                            p.put("doctor",mode.getString("APPLY_OPERATOR"));
                            p.put("doctorName",mode.getString("APPLY_OPERATOR_NAME"));
                            p.put("hospitalName",mode.getString("HEALTH_ORG_CODE"));
                            p.put("hospital",mode.getString("HEALTH_ORG_CODE"));
                        }
                    PrescriptionDiagnosis diagnosis = new PrescriptionDiagnosis();
                    String diagnoseCode = mode.getString("DIAGNOSE_CODE");
                    String diagnoseName = mode.getString("DIAGNOSE_NAME");
                        PrescriptionDiagnosis diagnosis = new PrescriptionDiagnosis();
                        String diagnoseCode = mode.getString("DIAGNOSE_CODE");
                        String diagnoseName = mode.getString("DIAGNOSE_NAME");
//                    String diagnoseCode = "E10.100";
//                    String diagnoseName = "1型糖尿病性酮症";
                    diagnosis.setCode(diagnoseCode);//诊断代码
                    diagnosis.setName(diagnoseName);//诊断名称
                    String icd10 = icd10DictServcie.getHealthProblemsByIcd10Code(diagnoseCode);
                    if(!StringUtils.isEmpty(icd10)){
                        JSONObject icd = JSONObject.parseObject(icd10);
                        diagnosis.setHealthProblemName(icd.getString("value"));//诊断名称
                        diagnosis.setHealthProblem(icd.getString("key"));//诊断代码
                    }else{
                        diagnosis.setHealthProblemName(diagnoseName);//诊断名称
                        diagnosis.setHealthProblem(diagnoseCode);//诊断代码
                    }
                    JSONArray jsonArrayDt = new JSONArray();
                    jsonArrayDt.add(diagnosis);
                    p.put("prescriptionDt",jsonArrayDt);
                        diagnosis.setCode(diagnoseCode);//诊断代码
                        diagnosis.setName(diagnoseName);//诊断名称
                        String icd10 = icd10DictServcie.getHealthProblemsByIcd10Code(diagnoseCode);
                        if(!StringUtils.isEmpty(icd10)){
                            JSONObject icd = JSONObject.parseObject(icd10);
                            diagnosis.setHealthProblemName(icd.getString("value"));//诊断名称
                            diagnosis.setHealthProblem(icd.getString("key"));//诊断代码
                        }else{
                            diagnosis.setHealthProblemName(diagnoseName);//诊断名称
                            diagnosis.setHealthProblem(diagnoseCode);//诊断代码
                        }
                        JSONArray jsonArrayDt = new JSONArray();
                        jsonArrayDt.add(diagnosis);
                        p.put("prescriptionDt",jsonArrayDt);
                    JSONArray infos = mode.getJSONArray("RECIPE_DETAIL");
                    Iterator infoIt = infos.iterator();
                    List<PrescriptionInfo> prescriptionInfos = new ArrayList<>();
                    while (infoIt.hasNext()){
                        JSONObject info = (JSONObject) infoIt.next();
                        PrescriptionInfo prescriptionInfo = new PrescriptionInfo();
                        prescriptionInfo.setRemark(info.getString("REMARK"));
                        prescriptionInfo.setBindFlag(info.getString("BIND_FLAG"));
                        prescriptionInfo.setDirection(info.getString("USAGE_NAME"));//药品用法
                        prescriptionInfo.setDrugCode(info.getString("ITEM_CODE"));//药品code
                        prescriptionInfo.setDrugName(info.getString("ITEM_NAME"));//药品名称
                        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.setNum(info.getInteger("ITEM_QUANTITY"));//药品数目
                        prescriptionInfo.setJwSubCode("");//智业子处方号
                        prescriptionInfo.setDrugNumUnit(info.getString("ITEM_UNIT"));//数量单位编码
                        prescriptionInfo.setDrugNumUnitName(info.getString("ITEM_UNIT_NAME"));//数量单位名称
                        prescriptionInfo.setCost(1);//金额
                        prescriptionInfo.setCharge(0);//自付
                        prescriptionInfo.setBindFlag("0");//成组标志, 0.非成组,1.成组
                        prescriptionInfo.setDayCount(info.getInteger("DAY_COUNT"));//用药天数
                        prescriptionInfo.setDrugUsage(info.getString("USAGE"));//用药方法编码
                        prescriptionInfo.setUsageName(info.getString("USAGE_NAME"));//用药方法名称
                        prescriptionInfo.setPhysicDose(info.getString("PHYSIC_DOSE"));//用药剂量
                        prescriptionInfo.setPhysicDoseUnit(info.getString("PHYSIC_DOSE_UNIT"));//剂量单位编码
                        prescriptionInfo.setPhysicDoseUnitName(info.getString("PHYSIC_DOSE_UNIT_NAME"));//剂量单位名称
                        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.setPhysicSkinTest(info.getString("PHYSIC_SKIN_TEST"));//皮试类型名称
                        prescriptionInfo.setPhysicSkinTestName(info.getString("PHYSIC_SKIN_TEST_NAME"));//皮试类型名称
                        prescriptionInfos.add(prescriptionInfo);
                        JSONArray infos = mode.getJSONArray("RECIPE_DETAIL");
                        Iterator infoIt = infos.iterator();
                        List<PrescriptionInfo> prescriptionInfos = new ArrayList<>();
                        while (infoIt.hasNext()){
                            JSONObject info = (JSONObject) infoIt.next();
                            PrescriptionInfo prescriptionInfo = new PrescriptionInfo();
                            prescriptionInfo.setRemark(info.getString("REMARK"));
                            prescriptionInfo.setBindFlag(info.getString("BIND_FLAG"));
                            prescriptionInfo.setDirection(info.getString("USAGE_NAME"));//药品用法
                            prescriptionInfo.setDrugCode(info.getString("ITEM_CODE"));//药品code
                            prescriptionInfo.setDrugName(info.getString("ITEM_NAME"));//药品名称
                            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.setNum(info.getInteger("ITEM_QUANTITY"));//药品数目
                            prescriptionInfo.setJwSubCode("");//智业子处方号
                            prescriptionInfo.setDrugNumUnit(info.getString("ITEM_UNIT"));//数量单位编码
                            prescriptionInfo.setDrugNumUnitName(info.getString("ITEM_UNIT_NAME"));//数量单位名称
                            prescriptionInfo.setCost(1);//金额
                            prescriptionInfo.setCharge(0);//自付
                            prescriptionInfo.setBindFlag("0");//成组标志, 0.非成组,1.成组
                            prescriptionInfo.setDayCount(info.getInteger("DAY_COUNT"));//用药天数
                            prescriptionInfo.setDrugUsage(info.getString("USAGE"));//用药方法编码
                            prescriptionInfo.setUsageName(info.getString("USAGE_NAME"));//用药方法名称
                            prescriptionInfo.setPhysicDose(info.getString("PHYSIC_DOSE"));//用药剂量
                            prescriptionInfo.setPhysicDoseUnit(info.getString("PHYSIC_DOSE_UNIT"));//剂量单位编码
                            prescriptionInfo.setPhysicDoseUnitName(info.getString("PHYSIC_DOSE_UNIT_NAME"));//剂量单位名称
                            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.setPhysicSkinTest(info.getString("PHYSIC_SKIN_TEST"));//皮试类型名称
                            prescriptionInfo.setPhysicSkinTestName(info.getString("PHYSIC_SKIN_TEST_NAME"));//皮试类型名称
                            prescriptionInfos.add(prescriptionInfo);
                        }
                        p.put("prescriptionInfo",prescriptionInfos);
                        rs.add(p);
                    }
                    p.put("prescriptionInfo",prescriptionInfos);
                    rs.add(p);
                }
                return rs;
            }
            return rs;
        }catch (Exception e){
            logger.info("PresModeAdapter:modeToPrescription:Json:"+json);
            throw e;
        }
        return null;
    }
@ -204,90 +217,94 @@ public class PresModeAdapter {
     * @return
     */
    public JSONObject modelToSinglePrescription(String json){
        JSONObject oldJson = JSONObject.parseObject(json);
        JSONObject data = oldJson.getJSONObject("data");
        JSONArray returnData = data.getJSONArray("returnData");
        String code = data.getString("CODE");
        if(StringUtils.isNotBlank(code)&&"1".equals(code)){
            JSONArray modeArray = returnData.getJSONArray(0);
            JSONObject mode = (JSONObject) modeArray.get(0);
            JSONObject p  = new JSONObject();
            p.put("code",mode.getInteger("RECIPE_NO")+"");
            p.put("createTime",mode.getString("APPLY_TIME"));
            Doctor doctor =  zyDictService.getDoctByJw(mode.getString("APPLY_OPERATOR"),mode.getString("HEALTH_ORG_CODE"));
            // "APPLY_OPERATOR_NAME": 开单医生姓名","HEALTH_ORG_CODE": "开单机构编码",
            if(doctor!=null){
                p.put("doctor",doctor.getCode());
                p.put("doctorName",doctor.getName());
                p.put("hospitalName",doctor.getHospitalName());
                p.put("hospital",doctor.getHospital());
            }else{
                p.put("doctor",mode.getString("APPLY_OPERATOR"));
                p.put("doctorName",mode.getString("APPLY_OPERATOR_NAME"));
                p.put("hospitalName",mode.getString("HEALTH_ORG_CODE"));
                p.put("hospital",mode.getString("HEALTH_ORG_CODE"));
            }
        try{
            JSONObject oldJson = JSONObject.parseObject(json);
            JSONObject data = oldJson.getJSONObject("data");
            JSONArray returnData = data.getJSONArray("returnData");
            String code = data.getString("CODE");
            if(StringUtils.isNotBlank(code)&&"1".equals(code)){
                JSONArray modeArray = returnData.getJSONArray(0);
                JSONObject mode = (JSONObject) modeArray.get(0);
                JSONObject p  = new JSONObject();
                p.put("code",mode.getInteger("RECIPE_NO")+"");
                p.put("createTime",mode.getString("APPLY_TIME"));
            JSONObject diagnosis = new JSONObject();
                Doctor doctor =  zyDictService.getDoctByJw(mode.getString("APPLY_OPERATOR"),mode.getString("HEALTH_ORG_CODE"));
                // "APPLY_OPERATOR_NAME": 开单医生姓名","HEALTH_ORG_CODE": "开单机构编码",
                if(doctor!=null){
                    p.put("doctor",doctor.getCode());
                    p.put("doctorName",doctor.getName());
                    p.put("hospitalName",doctor.getHospitalName());
                    p.put("hospital",doctor.getHospital());
                }else{
                    p.put("doctor",mode.getString("APPLY_OPERATOR"));
                    p.put("doctorName",mode.getString("APPLY_OPERATOR_NAME"));
                    p.put("hospitalName",mode.getString("HEALTH_ORG_CODE"));
                    p.put("hospital",mode.getString("HEALTH_ORG_CODE"));
                }
                JSONObject diagnosis = new JSONObject();
//                String diagnoseCode = mode.getString("DIAGNOSE_CODE");
//                String diagnoseName = mode.getString("DIAGNOSE_NAME");
            String diagnoseCode = "E10.100";
            String diagnoseName = "1型糖尿病性酮症";
            diagnosis.put("code",diagnoseCode);//诊断代码
            diagnosis.put("name",diagnoseName);//诊断名称
            String icd10 = icd10DictServcie.getHealthProblemsByIcd10Code(diagnoseCode);
            if(!StringUtils.isEmpty(icd10)){
                JSONObject icd = JSONObject.parseObject(icd10);
                diagnosis.put("healthProblemName",icd.getString("value"));//诊断名称
                diagnosis.put("healthProblem",icd.getString("key"));//诊断代码
            }else{
                diagnosis.put("healthProblemName",diagnoseName);//诊断名称
                diagnosis.put("healthProblem",diagnoseCode);//诊断代码
            }
            JSONArray jsonArrayDt = new JSONArray();
            jsonArrayDt.add(diagnosis);
            p.put("prescriptionDt",jsonArrayDt);
                String diagnoseCode = "E10.100";
                String diagnoseName = "1型糖尿病性酮症";
                diagnosis.put("code",diagnoseCode);//诊断代码
                diagnosis.put("name",diagnoseName);//诊断名称
                String icd10 = icd10DictServcie.getHealthProblemsByIcd10Code(diagnoseCode);
                if(!StringUtils.isEmpty(icd10)){
                    JSONObject icd = JSONObject.parseObject(icd10);
                    diagnosis.put("healthProblemName",icd.getString("value"));//诊断名称
                    diagnosis.put("healthProblem",icd.getString("key"));//诊断代码
                }else{
                    diagnosis.put("healthProblemName",diagnoseName);//诊断名称
                    diagnosis.put("healthProblem",diagnoseCode);//诊断代码
                }
                JSONArray jsonArrayDt = new JSONArray();
                jsonArrayDt.add(diagnosis);
                p.put("prescriptionDt",jsonArrayDt);
            JSONArray infos = mode.getJSONArray("RECIPE_DETAIL");
            Iterator infoIt = infos.iterator();
            JSONArray prescriptionInfos = new JSONArray();
            while (infoIt.hasNext()){
                JSONObject info = (JSONObject) infoIt.next();
                JSONObject prescriptionInfo = new JSONObject();
                prescriptionInfo.put("Remark",info.getString("REMARK"));
                prescriptionInfo.put("BindFlag",info.getString("BIND_FLAG"));
                prescriptionInfo.put("direction",info.getString("USAGE_NAME"));//药品用法
                prescriptionInfo.put("drugCode",info.getString("ITEM_CODE"));//药品code
                prescriptionInfo.put("drugName",info.getString("ITEM_NAME"));//药品名称
                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("num",info.getInteger("ITEM_QUANTITY"));//药品数目
                prescriptionInfo.put("jwSubCode","");//智业子处方号
                prescriptionInfo.put("drugNumUnit",info.getString("ITEM_UNIT"));//数量单位编码
                prescriptionInfo.put("drugNumUnitName",info.getString("ITEM_UNIT_NAME"));//数量单位名称
                prescriptionInfo.put("cost",1);//金额
                prescriptionInfo.put("charge",0);//自付
                prescriptionInfo.put("bindFlag","0");//成组标志, 0.非成组,1.成组
                prescriptionInfo.put("dayCount",info.getInteger("DAY_COUNT"));//用药天数
                prescriptionInfo.put("drugUsage",info.getString("USAGE"));//用药方法编码
                prescriptionInfo.put("usageName",info.getString("USAGE_NAME"));//用药方法名称
                prescriptionInfo.put("physicDose",info.getString("PHYSIC_DOSE"));//用药剂量
                prescriptionInfo.put("physicDoseUnit",info.getString("PHYSIC_DOSE_UNIT"));//剂量单位编码
                prescriptionInfo.put("physicDoseUnitName",info.getString("PHYSIC_DOSE_UNIT_NAME"));//剂量单位名称
                prescriptionInfo.put("physicAmount",info.getString("PHYSIC_AMOUNT"));//用药总量
                prescriptionInfo.put("physicAmountUnit",info.getString("PHYSIC_AMOUNT_UNIT"));//总量单位编码
                prescriptionInfo.put("physicAmountUnitName",info.getString("PHYSIC_AMOUNT_UNIT_NAME"));//总量单位名称
                prescriptionInfo.put("physicInjectPlace","");//注射地点编码
                prescriptionInfo.put("physicInjectPlaceName","");//注射地点名称
                prescriptionInfo.put("physicSkinTest",info.getString("PHYSIC_SKIN_TEST"));//皮试类型名称
                prescriptionInfo.put("physicSkinTestName",info.getString("PHYSIC_SKIN_TEST_NAME"));//皮试类型名称
                prescriptionInfos.add(prescriptionInfo);
                JSONArray infos = mode.getJSONArray("RECIPE_DETAIL");
                Iterator infoIt = infos.iterator();
                JSONArray prescriptionInfos = new JSONArray();
                while (infoIt.hasNext()){
                    JSONObject info = (JSONObject) infoIt.next();
                    JSONObject prescriptionInfo = new JSONObject();
                    prescriptionInfo.put("Remark",info.getString("REMARK"));
                    prescriptionInfo.put("BindFlag",info.getString("BIND_FLAG"));
                    prescriptionInfo.put("direction",info.getString("USAGE_NAME"));//药品用法
                    prescriptionInfo.put("drugCode",info.getString("ITEM_CODE"));//药品code
                    prescriptionInfo.put("drugName",info.getString("ITEM_NAME"));//药品名称
                    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("num",info.getInteger("ITEM_QUANTITY"));//药品数目
                    prescriptionInfo.put("jwSubCode","");//智业子处方号
                    prescriptionInfo.put("drugNumUnit",info.getString("ITEM_UNIT"));//数量单位编码
                    prescriptionInfo.put("drugNumUnitName",info.getString("ITEM_UNIT_NAME"));//数量单位名称
                    prescriptionInfo.put("cost",1);//金额
                    prescriptionInfo.put("charge",0);//自付
                    prescriptionInfo.put("bindFlag","0");//成组标志, 0.非成组,1.成组
                    prescriptionInfo.put("dayCount",info.getInteger("DAY_COUNT"));//用药天数
                    prescriptionInfo.put("drugUsage",info.getString("USAGE"));//用药方法编码
                    prescriptionInfo.put("usageName",info.getString("USAGE_NAME"));//用药方法名称
                    prescriptionInfo.put("physicDose",info.getString("PHYSIC_DOSE"));//用药剂量
                    prescriptionInfo.put("physicDoseUnit",info.getString("PHYSIC_DOSE_UNIT"));//剂量单位编码
                    prescriptionInfo.put("physicDoseUnitName",info.getString("PHYSIC_DOSE_UNIT_NAME"));//剂量单位名称
                    prescriptionInfo.put("physicAmount",info.getString("PHYSIC_AMOUNT"));//用药总量
                    prescriptionInfo.put("physicAmountUnit",info.getString("PHYSIC_AMOUNT_UNIT"));//总量单位编码
                    prescriptionInfo.put("physicAmountUnitName",info.getString("PHYSIC_AMOUNT_UNIT_NAME"));//总量单位名称
                    prescriptionInfo.put("physicInjectPlace","");//注射地点编码
                    prescriptionInfo.put("physicInjectPlaceName","");//注射地点名称
                    prescriptionInfo.put("physicSkinTest",info.getString("PHYSIC_SKIN_TEST"));//皮试类型名称
                    prescriptionInfo.put("physicSkinTestName",info.getString("PHYSIC_SKIN_TEST_NAME"));//皮试类型名称
                    prescriptionInfos.add(prescriptionInfo);
                }
                p.put("prescriptionInfo",prescriptionInfos);
                return p;
            }
            p.put("prescriptionInfo",prescriptionInfos);
            return p;
        }catch (Exception e){
            logger.info("PresModeAdapter:modelToSinglePrescription:Json:"+json);
            throw e;
        }
        return null;
    }

+ 378 - 294
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/ZyDictDataService.java

@ -1,351 +1,391 @@
package com.yihu.wlyy.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.entity.zydict.*;
import com.yihu.wlyy.repository.zydict.*;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
 * Created by chenweida on 2017/8/10.
 * 每天1点同步 智业的字典数据
 * 智业的字典数据
 */
@Service
public class ZyDictDataService extends BaseService {
    private Logger logger = LoggerFactory.getLogger(ZyDictDataService.class);
    @Autowired
    private JwPrescriptionService jwPrescriptionService;
    @Autowired
    private HospitalDao hospitalDao;
    private ZyCommonDictDao zyCommonDictDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public void synchronizeZy_iv_subject_class_dict() {
        try{
            String re = jwPrescriptionService.getDictForI(IV_SUBJECT_CLASS_DICT);
            JSONObject jsonObject = JSONObject.parseObject(re);
            if(jsonObject.getInteger("status")==200){
                JSONObject data = jsonObject.getJSONObject("data");
                if("1".equals(data.getString("CODE"))){
                    JSONArray returnData = data.getJSONArray("returnData");
                    System.out.println("returnData="+returnData.toString());
                    if(returnData.size()==0){
                        return;
                    }
                    JSONArray dictArray = returnData.getJSONArray(0);
                    for(int i=0;i<dictArray.size();i++){
                        JSONObject dict = dictArray.getJSONObject(i);
                        StringBuffer sql = new StringBuffer("insert into ");
                        sql.append(TableName.zy_iv_subject_class_dict.getDict()).append(" (class_code,class_name,upper_class,spell_code,wbzx_code) " );
                        sql.append("values('").append(dict.getString("CLASS_CODE")).append("','");
                        sql.append(dict.getString("CLASS_NAME")).append("','");
                        sql.append(dict.getString("UPPER_CLASS")).append("','");
                        sql.append(dict.getString("SPELL_CODE")).append("','");
                        sql.append(dict.getString("WBZX_CODE")).append("')");
                        System.out.println("sql="+sql.toString());
                        jdbcTemplate.execute(sql.toString());
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
    private ZyIvDeptDictDao zyIvDeptDictDao;
    @Autowired
    private ZyIvDeptStaffAllotDictDao zyIvDeptStaffAllotDictDao;
    @Autowired
    private ZyIvDiagnoseClassDictDao zyIvDiagnoseClassDictDao;
    @Autowired
    private ZyIvDiagnoseDictDao zyIvDiagnoseDictDao;
    @Autowired
    private ZyIvOrgPhysicAllotDictDao zyIvOrgPhysicAllotDictDao;
    @Autowired
    private ZyIvPhysicDictDao zyIvPhysicDictDao;
    @Autowired
    private ZyIvStaffDictDao zyIvStaffDictDao;
    @Autowired
    private ZyIvStaffRegTypeAllotDictDao zyIvStaffRegTypeAllotDictDao;
    @Autowired
    private ZyIvSubjectClassDictDao zyIvSubjectClassDictDao;
    /**
     * 根据字典名称下载字典
     * @param dictName
     */
    public void dictByDictName(String dictName){
        switch (dictName){
            case IV_SUBJECT_CLASS_DICT:
                synchronizeZy_iv_subject_class_dict();
                break;
            case IV_STAFF_REG_TYPE_ALLOT_DICT:
                synchronizeZy_iv_staff_reg_type_allot_dict();
                break;
            case IV_STAFF_DICT:
                synchronizeZy_iv_staff_dict();
                break;
            case IV_PHYSIC_DICT:
                synchronizeZy_iv_physic_dict();
                break;
            case IV_ORG_PHYSIC_ALLOT_DICT:
                synchronizeZy_iv_org_physic_allot_dict();
                break;
            case IV_DIAGNOSE_CLASS_DICT:
                synchronizeZy_iv_diagnose_class_dict();
                break;
            case IV_DEPT_STAFF_ALLOT_DICT:
                synchronizeZy_iv_dept_staff_allot_dict();
                break;
            case "commonDict":
                synchronizeZyCommonDict();
                break;
            case IV_DEPT_DICT:
                synchronizeZy_iv_dept_dict();
                break;
            default:break;
        }
    }
    public void synchronizeZy_iv_staff_reg_type_allot_dict() {
        try{
            String re = jwPrescriptionService.getDictForI(IV_STAFF_REG_TYPE_ALLOT_DICT);
            JSONObject jsonObject = JSONObject.parseObject(re);
            if(jsonObject.getInteger("status")==200){
                JSONObject data = jsonObject.getJSONObject("data");
                if("1".equals(data.getString("CODE"))){
                    JSONArray returnData = data.getJSONArray("returnData");
                    System.out.println("returnData="+returnData.toString());
                    if(returnData.size()==0){
                        return;
                    }
                    JSONArray dictArray = returnData.getJSONArray(0);
                    for(int i=0;i<dictArray.size();i++){
                        JSONObject dict = dictArray.getJSONObject(i);
                        StringBuffer sql = new StringBuffer("insert into ");
                        sql.append(TableName.zy_iv_staff_reg_type_allot_dict.getDict()).append(" (org_code,staff_code,register_type,register_type_name,register_fee) " );
                        sql.append("values('").append(dict.getString("ORG_CODE")).append("','");
                        sql.append(dict.getString("STAFF_CODE")).append("','");
                        sql.append(dict.getString("REGISTER_TYPE")).append("','");
                        sql.append(dict.getString("REGISTER_TYPE_NAME")).append("','");
                        sql.append(dict.getString("REGISTER_FEE")).append("')");
                        System.out.println("sql="+sql.toString());
                        jdbcTemplate.execute(sql.toString());
                    }
                }
            }
        }catch (Exception e){
    public void allDict() {
        try {
            //同步 zy_common_dict
            synchronizeZyCommonDict();
            //同步 zy_iv_dept_dict
            synchronizeZy_iv_dept_dict();
            //同步 zy_iv_dept_staff_allot_dict
            synchronizeZy_iv_dept_staff_allot_dict();
            //同步 zy_iv_diagnose_dict
            synchronizeZy_iv_diagnose_dict();
            //同步 zy_iv_diagnose_class_dict
            synchronizeZy_iv_diagnose_class_dict();
            //同步 zy_iv_org_physic_allot_dict
            synchronizeZy_iv_org_physic_allot_dict();
            //同步 zy_iv_physic_dict
            synchronizeZy_iv_physic_dict();
            //同步 zy_iv_staff_dict
            synchronizeZy_iv_staff_dict();  //birthday    Date(529084800000+0800) 无法解析
            //同步 zy_iv_staff_reg_type_allot_dict
            synchronizeZy_iv_staff_reg_type_allot_dict();
            //同步 zy_iv_subject_class_dict
            synchronizeZy_iv_subject_class_dict();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public void synchronizeZ_iv_staff_dict() {
        try{
            String re = jwPrescriptionService.getDictForI(IV_STAFF_DICT);
            JSONObject jsonObject = JSONObject.parseObject(re);
            if(jsonObject.getInteger("status")==200){
                JSONObject data = jsonObject.getJSONObject("data");
                if("1".equals(data.getString("CODE"))){
                    JSONArray returnData = data.getJSONArray("returnData");
                    System.out.println("returnData="+returnData.toString());
                    if(returnData.size()==0){
                        return;
                    }
                    JSONArray dictArray = returnData.getJSONArray(0);
                    for(int i=0;i<dictArray.size();i++){
                        JSONObject dict = dictArray.getJSONObject(i);
                        StringBuffer sql = new StringBuffer("insert into ");
                        sql.append(TableName.zy_iv_staff_dict.getDict()).append(" (org_code,staff_code,staff_name,work_code,birthday,sex,spell_code,wbzx_code,identity_no,certificate_no) " );
                        sql.append("values('").append(dict.getString("ORG_CODE")).append("','");
                        sql.append(dict.getString("STAFF_CODE")).append("','");
                        sql.append(dict.getString("STAFF_NAME")).append("','");
                        sql.append(dict.getString("WORK_CODE")).append("','");
                        sql.append(dict.getString("BIRTHDAY")).append("','");
                        sql.append(dict.getString("SEX")).append("','");
                        sql.append(dict.getString("SPELL_CODE")).append("','");
                        sql.append(dict.getString("WBZX_CODE")).append("','");
                        sql.append(dict.getString("IDENTITY_NO")).append("','");
                        sql.append(dict.getString("CERTIFICATE_NO")).append("')");
                        System.out.println("sql="+sql.toString());
                        jdbcTemplate.execute(sql.toString());
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
    private void synchronizeZy_iv_diagnose_dict() {
        logger.info("synchronized zy_iv_diagnose_dict start");
        String dictName = this.IV_DIAGNOSE_DICT;
        List<ZyIvDiagnoseDict> zyIvDiagnoseDicts = new ArrayList<>();
        //得到list
        zyIvDiagnoseDicts = commonGetOneDict(ZyIvDiagnoseDict.class, dictName);
        if (zyIvDiagnoseDicts != null && zyIvDiagnoseDicts.size() > 0) {
            //清空表
            zyIvDiagnoseDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_diagnose_dict  ,size:" + zyIvDiagnoseDicts.size());
            zyIvDiagnoseDictDao.save(zyIvDiagnoseDicts);
        }
        logger.info("synchronized zy_iv_diagnose_dict end");
    }
    private String changDate(String date){
        String str=date.replace("/Date(","").replace(")/","");
        String time = str.substring(0,str.length()-5);
        Date data = new Date(Long.parseLong(time));
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return format.format(data);
    @Transactional
    private void synchronizeZy_iv_subject_class_dict() {
        logger.info("synchronized zy_iv_subject_class_dict start");
        String dictName = this.IV_SUBJECT_CLASS_DICT;
        List<ZyIvSubjectClassDict> zyIvSubjectClassDicts = new ArrayList<>();
        //得到list
        zyIvSubjectClassDicts = commonGetOneDict(ZyIvSubjectClassDict.class, dictName);
        if (zyIvSubjectClassDicts.size() > 0) {
            //清空表
            zyIvSubjectClassDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_subject_class_dict  ,size:" + zyIvSubjectClassDicts.size());
            zyIvSubjectClassDictDao.save(zyIvSubjectClassDicts);
            logger.info("synchronized zy_iv_subject_class_dict end");
        }
    }
    public void synchronizeZy_iv_physic_dict() {
        try{
            String re = jwPrescriptionService.getDictForI(IV_PHYSIC_DICT);
            JSONObject jsonObject = JSONObject.parseObject(re);
            if(jsonObject.getInteger("status")==200){
                JSONObject data = jsonObject.getJSONObject("data");
                if("1".equals(data.getString("CODE"))){
                    JSONArray returnData = data.getJSONArray("returnData");
                    System.out.println("returnData="+returnData.toString());
                    if(returnData.size()==0){
                        return;
                    }
                    JSONArray dictArray = returnData.getJSONArray(0);
                    for(int i=0;i<dictArray.size();i++){
                        JSONObject dict = dictArray.getJSONObject(i);
                        StringBuffer sql = new StringBuffer("insert into ");
                        sql.append(TableName.zy_iv_physic_dict.getDict()).append(" (physic_code,physic_name,physic_spec,subject_class,dose_unit,quantity_unit,pack_unit,min_dose,pack_spec, " );
                        sql.append("retail_price,physic_from,toxicology_type,basic_flag,valid_flag,spell_code,wbzx_code,sequence)");
                        sql.append("values('").append(dict.getString("PHYSIC_CODE")).append("','");//药品代码
                        sql.append(dict.getString("PHYSIC_NAME")).append("','");//'药品名称'
                        sql.append(dict.getString("PHYSIC_SPEC")).append("','");//'药品规格'
                        sql.append(dict.getString("SUBJECT_CLASS")).append("','");//'药品科目  科目类别字典中定义'
                        sql.append(dict.getString("DOSE_UNIT")).append("','");//'剂量单位 计量单位字典中定义'
                        sql.append(dict.getString("QUANTITY_UNIT")).append("','");///'数量单位  计量单位字典中定义'
                        sql.append(dict.getString("PACK_UNIT")).append("',");//'包装单位   计量单位字典中定义'
                        sql.append(dict.getDouble("MIN_DOSE")).append(",");//'最小剂量'
                        sql.append(dict.getDouble("PACK_SPEC")).append(",");//
                        sql.append(dict.getDouble("RETAIL_PRICE")).append(",'");//'零售价'
                        sql.append(dict.getString("PHYSIC_FROM")).append("','");//'药品剂型  药品剂型字典中定义'
                        sql.append(dict.getString("TOXICOLOGY_TYPE")).append("','");//'毒理分类  药品毒理分类字典中定义'
                        sql.append(dict.getString("BASIC_FLAG")).append("','");//'基本药物标志  0:否;1:是'
                        sql.append(dict.getString("VALID_FLAG")).append("','");//'有效标志 0:无效;1:有效'
                        sql.append(dict.getString("SPELL_CODE")).append("','");//'拼音首码'
                        sql.append(dict.getString("WBZX_CODE")).append("',");//'五笔首码'
                        if(dict.getInteger("SEQUENCE")==null){
                            sql.append(dict.getInteger("SEQUENCE")).append(")");//'排序号'
                        }else {
                            sql.append(dict.getString("SEQUENCE")).append(")");//'排序号'
                        }
                        System.out.println("sql="+sql.toString());
                        jdbcTemplate.execute(sql.toString());
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
    @Transactional
    private void synchronizeZy_iv_staff_reg_type_allot_dict() {
        logger.info("synchronized zy_iv_staff_reg_type_allot_dict start");
        String dictName = this.IV_STAFF_REG_TYPE_ALLOT_DICT;
        List<ZyIvStaffRegTypeAllotDict> zyIvStaffRegTypeAllotDicts = new ArrayList<>();
        //得到list
        zyIvStaffRegTypeAllotDicts = commonGetOneDict(ZyIvStaffRegTypeAllotDict.class, dictName);
        if (zyIvStaffRegTypeAllotDicts != null && zyIvStaffRegTypeAllotDicts.size() > 0) {
            //清空表
            zyIvStaffRegTypeAllotDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_staff_reg_type_allot_dict  ,size:" + zyIvStaffRegTypeAllotDicts.size());
            zyIvStaffRegTypeAllotDictDao.save(zyIvStaffRegTypeAllotDicts);
            logger.info("synchronized zy_iv_staff_reg_type_allot_dict end");
        }
    }
    public void synchronizeZy_iv_org_physic_allot_dict() {
        try{
            String re = jwPrescriptionService.getDictForI(IV_ORG_PHYSIC_ALLOT_DICT);
            JSONObject jsonObject = JSONObject.parseObject(re);
            if(jsonObject.getInteger("status")==200){
                JSONObject data = jsonObject.getJSONObject("data");
                if("1".equals(data.getString("CODE"))){
                    JSONArray returnData = data.getJSONArray("returnData");
                    System.out.println("returnData="+returnData.toString());
                    if(returnData.size()==0){
                        return;
                    }
                    JSONArray dictArray = returnData.getJSONArray(0);
                    for(int i=0;i<dictArray.size();i++){
                        JSONObject dict = dictArray.getJSONObject(i);
                        StringBuffer sql = new StringBuffer("insert into ");
                        sql.append(TableName.zy_iv_org_physic_allot_dict.getDict()).append(" (org_code,physic_code) " );
                        sql.append("values('").append(dict.getString("ORG_CODE")).append("','");//'机构编码'
                        sql.append(dict.getString("PHYSIC_CODE")).append("')");//'药品代码'
                        System.out.println("sql="+sql.toString());
                        jdbcTemplate.execute(sql.toString());
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
    @Transactional
    private void synchronizeZy_iv_staff_dict() {
        logger.info("synchronized zy_iv_staff_dict start");
        String dictName = this.IV_STAFF_DICT;
        List<ZyIvStaffDict> zyIvStaffDicts = new ArrayList<>();
        //得到list
        zyIvStaffDicts = commonGetOneDict(ZyIvStaffDict.class, dictName);
        //清空表
        if (zyIvStaffDicts != null && zyIvStaffDicts.size() > 0) {
            zyIvStaffDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_staff_dict  ,size:" + zyIvStaffDicts.size());
            zyIvStaffDictDao.save(zyIvStaffDicts);
            logger.info("synchronized zy_iv_staff_dict end");
        }
    }
    public void synchronizeZy_iv_diagnose_class_dict() {
        try{
            String re = jwPrescriptionService.getDictForI(IV_DIAGNOSE_CLASS_DICT);
            JSONObject jsonObject = JSONObject.parseObject(re);
            if(jsonObject.getInteger("status")==200){
                JSONObject data = jsonObject.getJSONObject("data");
                if("1".equals(data.getString("CODE"))){
                    JSONArray returnData = data.getJSONArray("returnData");
                    System.out.println("returnData="+returnData.toString());
                    if(returnData.size()==0){
                        return;
                    }
                    JSONArray dictArray = returnData.getJSONArray(0);
                    for(int i=0;i<dictArray.size();i++){
                        JSONObject dict = dictArray.getJSONObject(i);
                        StringBuffer sql = new StringBuffer("insert into ");
                        sql.append(TableName.zy_iv_diagnose_class_dict.getDict()).append(" (class_sub_no,class_code,class_name,upper_class,valid_flag,spell_code,wbzx_code) " );
                        sql.append("values('").append(dict.getString("CLASS_SUB_NO")).append("','");//''类别子序号''
                        sql.append(dict.getString("CLASS_CODE")).append("','");//'类别代码'
                        sql.append(dict.getString("CLASS_NAME")).append("','");//'类别名称'
                        sql.append(dict.getString("UPPER_CLASS")).append("','");//'上级类别'
                        sql.append(dict.getString("VALID_FLAG")).append("','");//'有效标志  0 :无效;1:有效'
                        sql.append(dict.getString("SPELL_CODE")).append("','");//'拼音首码'
                        sql.append(dict.getString("WBZX_CODE")).append("')");//''五笔首码''
                        System.out.println("sql="+sql.toString());
                        jdbcTemplate.execute(sql.toString());
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
    @Transactional
    private void synchronizeZy_iv_physic_dict() {
        logger.info("synchronized zy_iv_physic_dict start");
        String dictName = this.IV_PHYSIC_DICT;
        List<ZyIvPhysicDict> zyIvPhysicDicts = new ArrayList<>();
        //得到list
        zyIvPhysicDicts = commonGetOneDict(ZyIvPhysicDict.class, dictName);
        if (zyIvPhysicDicts != null && zyIvPhysicDicts.size() > 0) {
            //清空表
            zyIvPhysicDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_physic_dict  ,size:" + zyIvPhysicDicts.size());
            zyIvPhysicDictDao.save(zyIvPhysicDicts);
            logger.info("synchronized zy_iv_physic_dict end");
        }
    }
    public void synchronizeZy_iv_dept_staff_allot_dict() {
        try{
            String re = jwPrescriptionService.getDictForI(IV_DEPT_STAFF_ALLOT_DICT);
            JSONObject jsonObject = JSONObject.parseObject(re);
            if(jsonObject.getInteger("status")==200){
                JSONObject data = jsonObject.getJSONObject("data");
                if("1".equals(data.getString("CODE"))){
                    JSONArray returnData = data.getJSONArray("returnData");
                    System.out.println("returnData="+returnData.toString());
                    if(returnData.size()==0){
                        return;
                    }
                    JSONArray dictArray = returnData.getJSONArray(0);
                    for(int i=0;i<dictArray.size();i++){
                        JSONObject dict = dictArray.getJSONObject(i);
                        StringBuffer sql = new StringBuffer("insert into ");
                        sql.append(TableName.zy_iv_dept_staff_allot_dict.getDict()).append(" (org_code,dept_code,staff_code) " );
                        sql.append("values('").append(dict.getString("ORG_CODE")).append("','");//'''机构编码'''
                        sql.append(dict.getString("DEPT_CODE")).append("','");//''科室编码''
                        sql.append(dict.getString("STAFF_CODE")).append("')");//'''员工编码'''
                        System.out.println("sql="+sql.toString());
                        jdbcTemplate.execute(sql.toString());
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
    @Transactional
    private void synchronizeZy_iv_org_physic_allot_dict() {
        logger.info("synchronized zy_iv_org_physic_allot_dict start");
        String dictName = this.IV_ORG_PHYSIC_ALLOT_DICT;
        List<ZyIvOrgPhysicAllotDict> zyIvOrgPhysicAllotDicts = new ArrayList<>();
        //得到list
        zyIvOrgPhysicAllotDicts = commonGetOneDict(ZyIvOrgPhysicAllotDict.class, dictName);
        if (zyIvOrgPhysicAllotDicts != null && zyIvOrgPhysicAllotDicts.size() > 0) {
            //清空表
            zyIvOrgPhysicAllotDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_org_physic_allot_dict  ,size:" + zyIvOrgPhysicAllotDicts.size());
            zyIvOrgPhysicAllotDictDao.save(zyIvOrgPhysicAllotDicts);
        }
        logger.info("synchronized zy_iv_org_physic_allot_dict end");
    }
    @Transactional
    private void synchronizeZy_iv_diagnose_class_dict() {
        logger.info("synchronized zy_iv_diagnose_class_dict start");
        String dictName = this.IV_DIAGNOSE_CLASS_DICT;
        List<ZyIvDiagnoseClassDict> zIvDiagnoseClassDicts = new ArrayList<>();
        //得到list
        zIvDiagnoseClassDicts = commonGetOneDict(ZyIvDiagnoseClassDict.class, dictName);
        if (zIvDiagnoseClassDicts != null && zIvDiagnoseClassDicts.size() > 0) {
            //清空表
            zyIvDiagnoseClassDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_diagnose_class_dict  ,size:" + zIvDiagnoseClassDicts.size());
            zyIvDiagnoseClassDictDao.save(zIvDiagnoseClassDicts);
        }
        logger.info("synchronized zy_iv_diagnose_class_dict end");
    }
    @Transactional
    private void synchronizeZy_iv_dept_staff_allot_dict() {
        logger.info("synchronized zy_iv_dept_staff_allot_dict start");
        String dictName = this.IV_DEPT_STAFF_ALLOT_DICT;
        List<ZyIvDeptStaffAllotDict> syIvDeptStaffAllotDictz = new ArrayList<>();
        //得到list
        syIvDeptStaffAllotDictz = commonGetOneDict(ZyIvDeptStaffAllotDict.class, dictName);
        if (syIvDeptStaffAllotDictz != null && syIvDeptStaffAllotDictz.size() > 0) {
            //清空表
            zyIvDeptStaffAllotDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_dept_staff_allot_dict  ,size:" + syIvDeptStaffAllotDictz.size());
            zyIvDeptStaffAllotDictDao.save(syIvDeptStaffAllotDictz);
        }
        logger.info("synchronized zy_iv_dept_staff_allot_dict end");
    }
    public void synchronizeZyCommonDict() {
    @Transactional
    private void synchronizeZyCommonDict() {
        logger.info("synchronized zy_common_dict start");
        String[] dictNames = new String[]{
                this.IV_PHYSIC_FORM_DICT, this.IV_PHYSIC_INJECT_PLACE_DICT, this.IV_PHYSIC_SKIN_TEST_DICT,
                this.IV_RATE_TYPE_DICT, this.IV_RECIPE_FREQUENCY_DICT, this.IV_RECIPE_USAGE_DICT,
                this.IV_SEX_DICT, this.IV_PHYSIC_TOXICOLOGY_TYPE_DICT, this.IV_MEASURE_UNIT_DICT,
                this.IV_DEPT_TYPE_DICT};
        try{
            for (String dictName : dictNames) {
                String re = jwPrescriptionService.getDictForI(dictName);
                JSONObject jsonObject = JSONObject.parseObject(re);
                if(jsonObject.getInteger("status")==200){
                    JSONObject data = jsonObject.getJSONObject("data");
                    if("1".equals(data.getString("CODE"))){
                        JSONArray returnData = data.getJSONArray("returnData");
                        System.out.println("returnData="+returnData.toString());
                        if(returnData.size()==0){
                            continue;
                        }
                        JSONArray dictArray = returnData.getJSONArray(0);
                        for(int i=0;i<dictArray.size();i++){
                            JSONObject dict = dictArray.getJSONObject(i);
                            StringBuffer sql = new StringBuffer("insert into ");
                            sql.append(TableName.zy_common_dict.getDict()).append(" (dict_name,code,name) " );
                            sql.append("values('").append(dict.getString("DICT_NAME")).append("','");
                            sql.append(dict.getString("CODE")).append("','");
                            sql.append(dict.getString("NAME")).append("')");
                            System.out.println("sql="+sql.toString());
                            jdbcTemplate.execute(sql.toString());
                        }
        List<ZyCommonDict> zyCommonDictz = new ArrayList<>();
        Boolean isFlush = true;
        for (String dictName : dictNames) {
            String json = null;
            try {
                //调用智业的接口得到字典
                json = jwPrescriptionService.getDictForI(dictName);
                JSONObject returnJson = JSONObject.fromObject(json);
                if (returnJson.getInt("status") != 200) {
                    throw new Exception("zy dict error status not 200");
                }
                if (returnJson.containsKey("data")) {
                    String dataString = returnJson.getString("data");
                    JSONArray dataJSONArray = JSONObject.fromObject(dataString).getJSONArray("returnData");
                    if (dataJSONArray.size() == 0) {
                        logger.info("zy dict data size " + dataJSONArray.size() + ",dictname:" + dictName);
                        continue;
                    }
                    //下划线转驼峰
                    JSONArray newJA = new JSONArray();
                    JSONArray jsonArrayTemp = dataJSONArray.getJSONArray(0);
                    logger.info("zy dict data size " + jsonArrayTemp.size() + ",dictname:" + dictName);
                    for (int i = 0; i < jsonArrayTemp.size(); i++) {
                        JSONObject jo = jsonArrayTemp.getJSONObject(i);
                        JSONObject newJO = new JSONObject();
                        jo.keySet().stream().forEach(key -> {
                            Object value = jo.get(key);
                            String newKey = Tool.lineToHump(key.toString());
                            newJO.put(newKey, value);
                        });
                        newJA.add(newJO);
                    }
                    ZyCommonDict[] zyCommonDictArrays = (ZyCommonDict[]) JSONArray.toArray(newJA, ZyCommonDict.class);
                    zyCommonDictz.addAll(Arrays.asList(zyCommonDictArrays));
                } else {
                    throw new Exception("zy dict error no contain data");
                }
            } catch (Exception e) {
                e.printStackTrace();
                isFlush = false; //设置状态不能更新
                logger.error("dictName:" + dictName);
                logger.error("returnJson:" + json);
                logger.error(e.getMessage());
            }
        }
        //判断是否可以更新
        if (isFlush) {
            // 判断返回的数据是否大于0
            if (zyCommonDictz.size() > 0) {
                //清空表
                zyCommonDictDao.deleteAll();
                //新增数据
                logger.info("save table zy_common_dict  ,size:" + zyCommonDictz.size());
                zyCommonDictDao.save(zyCommonDictz);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        logger.info("synchronized zy_common_dict end");
    }
    public void synchronizeZy_iv_dept_dict() {
        try{
            String re = jwPrescriptionService.getDictForI(IV_DEPT_DICT);
            JSONObject jsonObject = JSONObject.parseObject(re);
            if(jsonObject.getInteger("status")==200){
                JSONObject data = jsonObject.getJSONObject("data");
                if("1".equals(data.getString("CODE"))){
                    JSONArray returnData = data.getJSONArray("returnData");
                    System.out.println("returnData="+returnData.toString());
                    if(returnData.size()==0){
                        return;
                    }
                    JSONArray dictArray = returnData.getJSONArray(0);
                    for(int i=0;i<dictArray.size();i++){
                        JSONObject dict = dictArray.getJSONObject(i);
                        StringBuffer sql = new StringBuffer("insert into ");
                        sql.append(TableName.zy_iv_dept_dict.getDict()).append(" (org_code,dept_code,dept_name,dept_type,upper_dept) " );
                        sql.append("values('").append(dict.getString("ORG_CODE")).append("','");//机构编码
                        sql.append(dict.getString("DEPT_CODE")).append("','");//'科室编码
                        sql.append(dict.getString("DEPT_NAME")).append("','");//'科室名称
                        sql.append(dict.getString("DEPT_TYPE")).append("','");//'科室类型  详见科室类型字典中定义
                        sql.append(dict.getString("UPPER_DEPT")).append("')");//'上级科室
                        System.out.println("sql="+sql.toString());
                        jdbcTemplate.execute(sql.toString());
                    }
    @Transactional
    private void synchronizeZy_iv_dept_dict() {
        logger.info("synchronized zy_iv_dept_dict start");
        String dictName = this.IV_DEPT_DICT;
        List<ZyIvDeptDict> zyIvDeptDicts = new ArrayList<>();
        //得到list
        zyIvDeptDicts = commonGetOneDict(ZyIvDeptDict.class, dictName);
        if (zyIvDeptDicts != null && zyIvDeptDicts.size() > 0) {
            //清空表
            zyIvDeptDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_dept_dict  ,size:" + zyIvDeptDicts.size());
            zyIvDeptDictDao.save(zyIvDeptDicts);
        }
        logger.info("synchronized zy_iv_dept_dict end");
    }
    /**
     * 得到单个字典
     *
     * @param clazz    class
     * @param dictName 字典名称
     */
    private List commonGetOneDict(Class clazz, String dictName) {
        String json = null;
        try {
            //调用智业的接口得到字典
            json = jwPrescriptionService.getDictForI(dictName);
            JSONObject returnJson = JSONObject.fromObject(json);
            if (returnJson.getInt("status") != 200) {
                throw new Exception("zy dict error status not 200");
            }
            if (returnJson.containsKey("data")) {
                String dataJSONStr = returnJson.getString("data");
                JSONObject joTemp = JSONObject.fromObject(dataJSONStr);
                JSONArray dataJSONArray = joTemp.getJSONArray("returnData");
                if (dataJSONArray.size() == 0) {
                    logger.info("zy dict data size " + dataJSONArray.size() + ",dictname:" + dictName);
                    return null;
                } else {
                    dataJSONArray = dataJSONArray.getJSONArray(0);
                }
                logger.info("zy dict data size " + dataJSONArray.size() + ",dictname:" + dictName);
                //下划线转驼峰
                JSONArray newJA = new JSONArray();
                for (int i = 0; i < dataJSONArray.size(); i++) {
                    JSONObject jo = dataJSONArray.getJSONObject(i);
                    JSONObject newJO = new JSONObject();
                    jo.keySet().stream().forEach(key -> {
                        Object value = jo.get(key);
                        String newKey = Tool.lineToHump(key.toString());
                        newJO.put(newKey, value);
                    });
                    newJA.add(newJO);
                }
                return (List) JSONArray.toCollection(newJA, clazz);
            } else {
                throw new Exception("zy dict error no contain data");
            }
        }catch (Exception e){
            e.printStackTrace();
        } catch (Exception e) {
            logger.error("dictName:" + dictName);
            logger.error("returnJson:" + json);
            logger.error(e.getMessage());
        }
        return null;
    }
    /**
@ -371,7 +411,9 @@ public class ZyDictDataService extends BaseService {
    public static final String IV_STAFF_REG_TYPE_ALLOT_DICT = "IV_STAFF_REG_TYPE_ALLOT_DICT";//("员工挂号类型配置字典", "IV_STAFF_REG_TYPE_ALLOT_DICT"),
    public static final String IV_DEPT_STAFF_ALLOT_DICT = "IV_DEPT_STAFF_ALLOT_DICT";//("科室员工配置字典", "IV_DEPT_STAFF_ALLOT_DICT");
    /**
     * 字典表的枚举类
     */
    public enum TableName {
        zy_common_dict("通用字典", "zy_common_dict"),
@ -408,6 +450,7 @@ public class ZyDictDataService extends BaseService {
        public void setDict(String dict) {
            this.dict = dict;
        }
    }
    /**
@ -479,4 +522,45 @@ public class ZyDictDataService extends BaseService {
        }
        return "";
    }
    public static class Tool {
        private static Pattern linePattern = Pattern.compile("_(\\w)");
        /**
         * 下划线转驼峰
         */
        public static String lineToHump(String str) {
            str = str.toLowerCase();
            Matcher matcher = linePattern.matcher(str);
            StringBuffer sb = new StringBuffer();
            while (matcher.find()) {
                matcher.appendReplacement(sb, matcher.group(1).toUpperCase());
            }
            matcher.appendTail(sb);
            return sb.toString();
        }
        /**
         * 驼峰转下划线(简单写法,效率低于{@link #humpToLine2(String)})
         */
        public static String humpToLine(String str) {
            return str.replaceAll("[A-Z]", "_$0").toLowerCase();
        }
        private static Pattern humpPattern = Pattern.compile("[A-Z]");
        /**
         * 驼峰转下划线,效率比上面高
         */
        public static String humpToLine2(String str) {
            Matcher matcher = humpPattern.matcher(str);
            StringBuffer sb = new StringBuffer();
            while (matcher.find()) {
                matcher.appendReplacement(sb, "_" + matcher.group(0).toLowerCase());
            }
            matcher.appendTail(sb);
            return sb.toString();
        }
    }
}

+ 28 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionDispensaryCodeService.java

@ -2,9 +2,11 @@ package com.yihu.wlyy.service.app.prescription;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionDispensaryCode;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionInfo;
import com.yihu.wlyy.entity.patient.prescription.PrescriptionLog;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDispensaryCodeDao;
import com.yihu.wlyy.repository.prescription.PrescriptionInfoDao;
import com.yihu.wlyy.service.BaseService;
@ -51,6 +53,8 @@ public class PrescriptionDispensaryCodeService extends BaseService {
    private PrescriptionInfoDao prescriptionInfoDao;
    @Autowired
    private HttpUtil httpUtil;
    @Autowired
    private PrescriptionDao prescriptionDao;
    private static Object obj = new Object();
    private static Object obj2 = new Object();
@ -116,6 +120,30 @@ public class PrescriptionDispensaryCodeService extends BaseService {
        return false;
    }
    public boolean saveQRCode(String token,String prescriptionCode) throws Exception {
        Prescription prescription = prescriptionDao.findByCode(prescriptionCode);
        //取药类型:1 自取 2快递配送 3健管师配送
        Integer type = prescription.getDispensaryType();
        PrescriptionDispensaryCode prescriptionDispensaryCode = savePatientQRCode(token,prescriptionCode);
        if(type==3){
            if(prescriptionDispensaryCode!=null){
                prescriptionDispensaryCode = saveQRCode(prescriptionDispensaryCode.getCode(),token,prescriptionCode,2);
                if(prescriptionDispensaryCode!=null){
                    prescriptionDispensaryCode = saveQRCode(prescriptionDispensaryCode.getCode(),token,prescriptionCode,3);
                    if(prescriptionDispensaryCode==null){
                        return false;
                    }
                }else{
                    return false;
                }
            }else{
                return false;
            }
        }
        return true;
    }
    //生成居民端取药码
    @Transactional
    public PrescriptionDispensaryCode savePatientQRCode(String token,String prescriptionCode) throws Exception {

+ 2 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prescription/PrescriptionExpressageService.java

@ -8,12 +8,14 @@ import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.prescription.*;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.SystemConf;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ExecutionException;

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

@ -327,7 +327,7 @@ public class PrescriptionInfoService extends BaseService {
     * @param code
     * @return
     */
    public int cancelPrescriotion(String code,String reason){
    public int cancelPrescriotion(String code,String reason)throws Exception{
        Prescription p = prescriptionDao.findByCode(code);
        p.setStatus(PrescriptionLog.PrescriptionLogStatus.patient_canel.getValue());
        p.setCancelReason(reason);
@ -349,7 +349,7 @@ public class PrescriptionInfoService extends BaseService {
        prescriptionLogDao.save(log);
        //同步智业接口
        //upLoadPrescriotionState();
        jwPrescriptionService.fadeRecipe(code);
        return 1;
    }
@ -370,13 +370,23 @@ public class PrescriptionInfoService extends BaseService {
                com.alibaba.fastjson.JSONObject returnData = (com.alibaba.fastjson.JSONObject)reData.get(0);
                p.setVisitNo(returnData.getString("VISIT_NO"));
                p.setRecipeNo(returnData.getString("RECIPE_NO"));
                //设置状态为待支付
                p.setStatus(PrescriptionLog.PrescriptionLogStatus.wait_pay.getValue());
                //设置审核通过
                reviewed.setStatus(1);
                reviewed.setReviewedTime(new Date());
                prescriptionDao.save(p);
                //审核通过模板消息
                sendRMess(code,1);
                return 1;
            }else{
                p.setStatus(PrescriptionLog.PrescriptionLogStatus.add_error.getValue());
                p.setPrescribeReason(byRefParaData.getJSONObject(0).getString("errorMsg"));
                p.setPrescribeTime(new Date());
                prescriptionDao.save(p);
                //审核不通过模板消息
                sendRMess(code,0);
                return 0;
            }
        }
@ -764,16 +774,25 @@ public class PrescriptionInfoService extends BaseService {
            JSONObject json = new JSONObject(mes);
            Integer state = json.getInt("state");
            String code = json.getString("prescription");
            return sendRMess(code ,state);
        }catch (Exception e){
            logger.error("报文解析失败!",e);
        }
        return 0;
    }
    public int  sendRMess(String code ,Integer state){
        try {
            Prescription prescription = prescriptionDao.findByCode(code);
            Patient p = patientDao.findByCode(prescription.getPatient());
            if(state!=null&&state==1){
                prescriptionNoticesService.sendMessages(prescription.getPatient(),prescription.getDoctorName(),null,1,1,"prescription/html/re-prescription_info.html?openid=" + p.getOpenid() + "&toUser=" + p.getCode()+ "&toName=" + p.getName() +"&code="+prescription.getCode());
            }else{
                prescriptionNoticesService.sendMessages(prescription.getPatient(),prescription.getDoctorName(),null,1,2,"prescription/html/re-prescription_info.html?openid=" + p.getOpenid() + "&toUser=" + p.getCode()+ "&toName=" + p.getName() +"&code="+prescription.getCode());
            if (state != null && state == 1) {
                prescriptionNoticesService.sendMessages(prescription.getPatient(), prescription.getDoctorName(), null, 1, 1, "prescription/html/re-prescription_info.html?openid=" + p.getOpenid() + "&toUser=" + p.getCode() + "&toName=" + p.getName() + "&code=" + prescription.getCode());
            } else {
                prescriptionNoticesService.sendMessages(prescription.getPatient(), prescription.getDoctorName(), null, 1, 2, "prescription/html/re-prescription_info.html?openid=" + p.getOpenid() + "&toUser=" + p.getCode() + "&toName=" + p.getName() + "&code=" + prescription.getCode());
            }
            return 1;
        }catch (Exception e){
            logger.error("续方消息发送失败!",e);
        } catch (Exception e) {
            logger.error("续方消息发送失败!", e);
        }
        return 0;
    }
@ -902,7 +921,7 @@ public class PrescriptionInfoService extends BaseService {
        if(StringUtils.isNotBlank(AllocationType)){
            //1为未分配建管师列表
            if("1".equals(AllocationType)){
                pre_sql.append(" AND pr.expressage_code IS NULL ");
                pre_sql.append(" AND e.expressage_code IS NULL ");
            }
        }
@ -1032,7 +1051,7 @@ public class PrescriptionInfoService extends BaseService {
     * @return 0 审核中,1为处理完成
     */
    public String presCheckState(String code){
        StringBuffer sql = new StringBuffer(" SELECT pr.code FROM wlyy_prescription pr JOIN wlyy_prescription_reviewed r ON pr.code = r.prescription_code WHERE pr.parent_code = ? AND r.status = 0");
        StringBuffer sql = new StringBuffer(" SELECT pr.code FROM wlyy_prescription pr JOIN wlyy_prescription_reviewed r ON pr.code = r.prescription_code WHERE pr.parent_code = ? AND pr.status >= "+PrescriptionLog.PrescriptionLogStatus.revieweding+" AND pr.status < "+PrescriptionLog.PrescriptionLogStatus.wait_pay);
        List<Map<String,Object>> mp = jdbcTemplate.queryForList(sql.toString(),code);
        if(mp!=null&&mp.size()>0){
            return "0";
@ -1042,7 +1061,7 @@ public class PrescriptionInfoService extends BaseService {
    }
    public String presCheckStateObj(String code){
        StringBuffer sql = new StringBuffer(" SELECT pr.code FROM wlyy_prescription pr JOIN wlyy_prescription_reviewed r ON pr.code = r.prescription_code WHERE pr.parent_code = ? AND r.status = 0");
        StringBuffer sql = new StringBuffer(" SELECT pr.code FROM wlyy_prescription pr JOIN wlyy_prescription_reviewed r ON pr.code = r.prescription_code WHERE pr.parent_code = ? AND pr.status >= "+PrescriptionLog.PrescriptionLogStatus.revieweding+" AND pr.status < "+PrescriptionLog.PrescriptionLogStatus.wait_pay);
        List<Map<String,Object>> mp = jdbcTemplate.queryForList(sql.toString(),code);
        if(mp!=null&&mp.size()>0){
            return (String)((mp.get(0)).get("code"));
@ -1109,4 +1128,10 @@ public class PrescriptionInfoService extends BaseService {
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql.toString(),new Object[]{jwHospital,jwDoctorCode});
        return new JSONArray(rs);
    }
    public JSONArray getUsageDict(){
        StringBuffer sql = new StringBuffer("SELECT t.code,t.`name` FROM zy_common_dict t WHERE t.dict_name='IV_RECIPE_USAGE_DICT'");
        List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql.toString());
        return new JSONArray(rs);
    }
}

+ 51 - 9
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java

@ -1,9 +1,15 @@
package com.yihu.wlyy.service.third.jw;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.util.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
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.jdbc.core.JdbcTemplate;
@ -20,6 +26,7 @@ import java.util.Map;
@Service
public class JwPrescriptionService {
    private static final Logger logger = LoggerFactory.getLogger(JwPrescriptionService.class);
    //基卫服务地址
    @Value("${sign.check_upload}")
    private String jwUrl;
@ -27,6 +34,8 @@ public class JwPrescriptionService {
    private HttpClientUtil httpClientUtil;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PrescriptionDao prescriptionDao;
    /**
     * 获取字典列表
@ -115,6 +124,11 @@ public class JwPrescriptionService {
     * @throws Exception
     */
    public String saveRecipe(String prescriptionCode) throws Exception{
        try {
        }catch (Exception e){
        }
        String url = jwUrl + "/third/prescription/saveRecipe";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("prescriptionCode", prescriptionCode));
@ -158,21 +172,49 @@ public class JwPrescriptionService {
    /**
     * 挂号作废处方接口
     * @param visitNo 挂号号
     * @param fadeDept 作废科室编码
     * @param fadeOperator 作废人员编码
     * @param prescriptionCode 续方号码
     * @return
     * @throws Exception
     */
    public String fadeRecipe(String visitNo,String fadeDept,String fadeOperator)throws Exception{
        String url = jwUrl + "/third/prescription/fadeRecipe";
    public String fadeRecipe(String prescriptionCode)throws Exception{
        Prescription prescription = prescriptionDao.findByCode(prescriptionCode);
        if(StringUtils.isNotBlank(prescription.getVisitNo())){
            String url = jwUrl + "/third/prescription/fadeRecipe";
            List<NameValuePair> params = new ArrayList<>();
            params.add(new BasicNameValuePair("visitNo", prescription.getVisitNo()));//挂号号
            params.add(new BasicNameValuePair("fadeDept", prescription.getJwDeptCode()));//作废科室编码
            params.add(new BasicNameValuePair("fadeOperator", prescription.getJwDoctorCode()));//作废人员编码
            String response = httpClientUtil.post(url, params, "UTF-8");
            if(StringUtils.isNotBlank(response)){
                JSONObject reobj =  JSON.parseObject(response);
                Integer status = reobj.getInteger("status");
                String errmsg = reobj.getString("msg");
                if(-1 == status){
                    throw new Exception("基卫接口(挂号作废)请求失败,"+errmsg);
                }
            }else{
                throw new Exception("基卫接口(挂号作废)请求失败,无数据返回!");
            }
            return response;
        }
        return "";
    }
    /**
     * ca认证接口
     * @param code 续方code
     * @return
     */
    public String affirmCARecipe(String code){
        String url = jwUrl + "/third/prescription/affirmCARecipe";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("visitNo", visitNo));//挂号号
        params.add(new BasicNameValuePair("fadeDept", fadeDept));//作废科室编码
        params.add(new BasicNameValuePair("fadeOperator", fadeOperator));//作废人员编码
        params.add(new BasicNameValuePair("code", code));//续方code
        String response = httpClientUtil.post(url, params, "UTF-8");
        return response;
    }
}

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

@ -428,4 +428,15 @@ public class PrescriptionInfoController extends BaseController{
        }
    }
    @RequestMapping(value = "/getUsageDict" ,method = RequestMethod.GET)
    @ApiOperation(value = "获取药品用法列表")
    public String getUsageDict(){
        try {
            return write(200, "查询成功!", "data", prescriptionInfoService.getUsageDict());
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/consult/ConsultController.java

@ -993,7 +993,7 @@ public class ConsultController extends WeixinBaseController {
            consult.setType(8);//续方咨询
            consult.setAdminTeamId(adminTeamId);
            // 保存到数据库
//            int res = consultTeamService.addPrescriptionConsult(jwCode, "37c0657335f94ed38eeced22dbed8011","37c0657335f94ed38eeced22dbed8011",doctor,consult,reason,type);
//            int res = consultTeamService.addPrescriptionConsult(jwCode, "b02f132bfbfc45d287bcde18ad342522","b02f132bfbfc45d287bcde18ad342522",doctor,consult,reason,type);
            int res = consultTeamService.addPrescriptionConsult(jwCode, getRepUID(),getUID(),doctor,consult,reason,type);
            if (res == -1) {
                return error(-1, "该处方存在未审核的续方,无法进行续方咨询!");

+ 20 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionController.java

@ -43,7 +43,27 @@ public class PatientPrescriptionController extends WeixinBaseController {
    @Autowired
    private PrescriptionExpressageService prescriptionExpressageService;
    /**
     * 生成取药码
     */
    @RequestMapping(value = "/dispensaryCode/saveQRCode",method = RequestMethod.POST)
    @ResponseBody
    @ObserverRequired
    public String saveQRCode2(
            @ApiParam(required = true ,name = "prescriptionCode",value = "处方code")@RequestParam(value = "prescriptionCode",required = true) String prescriptionCode){
        try {
           boolean b = prescriptionDispensaryCodeService.saveQRCode(getAccessToken(),prescriptionCode);
           if(b){
               return write(200, "生成二维码成功!");
           }else{
               return error(-1, "生成二维码失败!");
           }
        }catch (Exception e) {
            error(e);
            return error(-1, "生成二维码失败!");
        }
    }
    /**
     *生成居民取药码

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prescription/PatientPrescriptionInfoController.java

@ -99,7 +99,7 @@ public class PatientPrescriptionInfoController extends BaseController {
            return write(200, "查询成功!", "data", prescriptionInfoService.cancelPrescriotion(code,reason));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
            return error(-1, "取消失败!");
        }
    }

+ 40 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/ZyDictController.java

@ -1,6 +1,6 @@
package com.yihu.wlyy.web.third;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.service.ZyDictDataService;
import com.yihu.wlyy.service.third.jw.ZyDictService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.ApiOperation;
@ -8,9 +8,6 @@ import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
 * Created by chenweida on 2017/8/10.
 * 智业字典同步接口
@ -20,11 +17,12 @@ import java.util.Map;
public class ZyDictController extends BaseController {
    @Autowired
    private ZyDictService zyDictService;
    @Autowired
    private ZyDictDataService zyDictDataService;
    @ApiOperation("同步智业字典")
    @RequestMapping(value = "/synchronousDict", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    @ResponseBody
    public String synchronousDict(
            @ApiParam(name = "dictName", value = "字典名称", defaultValue = "")
            @RequestParam(value = "dictName", required = true) String dictName) {
@ -36,4 +34,41 @@ public class ZyDictController extends BaseController {
        }
    }
    @ApiOperation("下载智业所有字典")
    @RequestMapping(value = "/downLoadAllDict", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    public String downLoadAllDict(){
        try {
            zyDictDataService.allDict();
            return write(200, "下载智业所有字典!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "下载智业所有字典");
        }
    }
    /**
     * IV_SUBJECT_CLASS_DICT
     * IV_STAFF_REG_TYPE_ALLOT_DICT
     * IV_STAFF_DICT
     * IV_PHYSIC_DICT
     * IV_ORG_PHYSIC_ALLOT_DICT
     * IV_DIAGNOSE_CLASS_DICT
     * IV_DEPT_STAFF_ALLOT_DICT
     * "commonDict"
     * IV_DEPT_DICT
     * @param dictName
     * @return
     */
    @ApiOperation("下载智业字典")
    @RequestMapping(value = "/downLoadDict", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
    public String downLoadDict(@ApiParam(name = "dictName", value = "字典名称", defaultValue = "commonDict")
                               @RequestParam(value = "dictName", required = true) String dictName){
        try {
            zyDictDataService.dictByDictName(dictName);
            return write(200, "下载智业所有字典!");
        } catch (Exception e) {
            return invalidUserException(e, -1, "下载智业所有字典");
        }
    }
}