Browse Source

代码修改

yeshijie 7 years ago
parent
commit
8726b4a284
24 changed files with 2836 additions and 1 deletions
  1. 17 0
      patient-co-service/wlyy_service/pom.xml
  2. 84 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/PrescriptionController.java
  3. 13 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/ZyPushLogDao.java
  4. 12 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prescription/PrescriptionAdjustDao.java
  5. 24 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prescription/PrescriptionDao.java
  6. 17 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prescription/PrescriptionDiagnosisDao.java
  7. 24 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prescription/PrescriptionDispensaryCodeDao.java
  8. 16 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prescription/PrescriptionInfoDao.java
  9. 17 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prescription/PrescriptionLogDao.java
  10. 14 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prescription/PrescriptionPayDao.java
  11. 15 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prescription/PrescriptionReviewedDao.java
  12. 107 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/ZyPushLog.java
  13. 426 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/Prescription.java
  14. 81 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/PrescriptionAdjust.java
  15. 63 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/PrescriptionDiagnosis.java
  16. 77 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/PrescriptionDispensaryCode.java
  17. 305 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/PrescriptionInfo.java
  18. 230 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/PrescriptionLog.java
  19. 99 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/PrescriptionPay.java
  20. 167 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/PrescriptionReviewed.java
  21. 313 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/ZysoftBaseService.java
  22. 373 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/ZysoftMaternalService.java
  23. 328 0
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/prescription/PrescriptionService.java
  24. 14 1
      patient-co-service/wlyy_service/src/main/resources/application.yml

+ 17 - 0
patient-co-service/wlyy_service/pom.xml

@ -91,6 +91,23 @@
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
        <!--redis-->
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-redis</artifactId>
            <version>1.7.2.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>4.1.8.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>2.8.1</version>
        </dependency>
        <!--Swagger-->
        <dependency>
            <groupId>io.springfox</groupId>

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

@ -2,9 +2,11 @@ package com.yihu.wlyy.service.controller;
import com.yihu.wlyy.service.common.model.Result;
import com.yihu.wlyy.service.service.prescription.PrescriptionCAService;
import com.yihu.wlyy.service.service.prescription.PrescriptionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@ -25,6 +27,88 @@ public class PrescriptionController {
	@Autowired
	PrescriptionCAService caService;
	@Autowired
	PrescriptionService prescriptionService;
	/**************************************提供智业调用的接口 start******************************************************/
	@RequestMapping(value = "prescriptionAdjustCompleted",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("接收线下处方调整完成消息")
	public Result prescriptionAdjustCompleted(@ApiParam(name="data",value="json串",defaultValue = "{}")
											  @RequestParam(value = "data",required = true) String data){
		try {
			return prescriptionService.prescriptionAdjustCompleted(data);
		}catch (Exception e){
			e.printStackTrace();
			return Result.error(e.getMessage());
		}
	}
	@RequestMapping(value = "prePayCompletion",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("接收预结算完成消息")
	public Result prePayCompletion(@ApiParam(name="data",value="json串",defaultValue = "{}")
								   @RequestParam(value = "data",required = true) String data){
		try {
			return prescriptionService.prePayCompletion(data);
		}catch (Exception e){
			e.printStackTrace();
			return Result.error(e.getMessage());
		}
	}
	@RequestMapping(value = "dispensingComplete",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("接收配药完成消息")
	public Result dispensingComplete(@ApiParam(name="data",value="json串",defaultValue = "{}")
									 @RequestParam(value = "data",required = true) String data){
		try {
			return prescriptionService.dispensingComplete(data);
		}catch (Exception e){
			e.printStackTrace();
			return Result.error(e.getMessage());
		}
	}
	@RequestMapping(value = "pharmacistPrescriptionCompletion",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("接收药师审方完成及结果消息")
	public Result pharmacistPrescriptionCompletion(@ApiParam(name="data",value="json串",defaultValue = "{}")
												   @RequestParam(value = "data",required = true) String data){
		try {
			return prescriptionService.pharmacistPrescriptionCompletion(data);
		}catch (Exception e){
			e.printStackTrace();
			return Result.error(e.getMessage());
		}
	}
	@RequestMapping(value = "pharmacistPrescriptionCompletion",method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation("提供在线问诊消息调阅")
	public String readNewsOnline(@ApiParam(name="data",value="json串",defaultValue = "{}")
								 @RequestParam(value = "data",required = true) String data){
		JSONObject jsonObject = new JSONObject();
		try {
			jsonObject.put("status",200);
			jsonObject.put("msg","success");
			jsonObject.put("url","http://www.yihu.com/");
		}catch (Exception e){
			e.printStackTrace();
			jsonObject.put("msg",e.getMessage());
		}
		return jsonObject.toString();
	}
	/**************************************提供智业调用的接口 end*******************************************************/
	/************************************ CA认证 ************************************************************/
	@RequestMapping(value = "RequestRealNameSoftCertAndSign",method = RequestMethod.POST)
	@ResponseBody

+ 13 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/ZyPushLogDao.java

@ -0,0 +1,13 @@
package com.yihu.wlyy.service.dao;
import com.yihu.wlyy.service.entity.ZyPushLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by yeshijie on 2017/8/5.
 */
public interface ZyPushLogDao extends PagingAndSortingRepository<ZyPushLog, Long>, JpaSpecificationExecutor<ZyPushLog> {
}

+ 12 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prescription/PrescriptionAdjustDao.java

@ -0,0 +1,12 @@
package com.yihu.wlyy.service.dao.prescription;
import com.yihu.wlyy.service.entity.prescription.PrescriptionAdjust;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2017/8/2.
 */
public interface PrescriptionAdjustDao extends PagingAndSortingRepository<PrescriptionAdjust, Long>,JpaSpecificationExecutor<PrescriptionAdjust> {
}

+ 24 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prescription/PrescriptionDao.java

@ -0,0 +1,24 @@
package com.yihu.wlyy.service.dao.prescription;
import com.yihu.wlyy.service.entity.prescription.Prescription;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by chenweida on 2017/7/27.
 */
public interface PrescriptionDao extends PagingAndSortingRepository<Prescription, Long>, JpaSpecificationExecutor<Prescription> {
    @Query("from Prescription p where p.code=?1")
    Prescription findByCode(String prescriptionCode);
    @Modifying
    @Query("update Prescription p set p.status=?2 where p.code=?1")
    void updateStatus(String prescriptionCode, Integer status);
    @Query("select p from Prescription p where p.jwCode=?1 and p.status=?2 ")
    List<Prescription> fingdByJwCodeAndStatus(String jwcode, Integer status);
}

+ 17 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prescription/PrescriptionDiagnosisDao.java

@ -0,0 +1,17 @@
package com.yihu.wlyy.service.dao.prescription;
import com.yihu.wlyy.service.entity.prescription.PrescriptionDiagnosis;
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 yeshijie on 2017/7/28.
 */
public interface PrescriptionDiagnosisDao extends PagingAndSortingRepository<PrescriptionDiagnosis, Long>, JpaSpecificationExecutor<PrescriptionDiagnosis> {
    @Query("select p from PrescriptionDiagnosis p where p.prescriptionCode=?1 ")
    List<PrescriptionDiagnosis> findByPrescriptionCode(String prescriptionCode);
}

+ 24 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prescription/PrescriptionDispensaryCodeDao.java

@ -0,0 +1,24 @@
package com.yihu.wlyy.service.dao.prescription;
import com.yihu.wlyy.service.entity.prescription.PrescriptionDispensaryCode;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Administrator on 2017/7/21.
 * 处方取码
 */
public interface PrescriptionDispensaryCodeDao extends PagingAndSortingRepository<PrescriptionDispensaryCode, Long>, JpaSpecificationExecutor<PrescriptionDispensaryCode> {
    @Query("from PrescriptionDispensaryCode where code=?1")
    PrescriptionDispensaryCode finByCode(String code);
//    @Query("select  count(1) from wlyy_prescription_dispensary_code p1 \n" +
//            "LEFT JOIN wlyy_prescription p2 on p1.prescription_Code = p2.code where p2.status in(21,20,100) and p2.patient =?1 ")
//    int dispensaryCodeCount(String patientCode);
    @Query("select count(1) from PrescriptionDispensaryCode a where a.code= ?1 and a.isUse =0")
    Integer getResidentQRCodeCount(String code);
//    @Query("select p1 from PrescriptionInfo p1 left join Prescription p2 on p1.prescriptionCode=p2.code where p1.prescriptionCode = ?1")
//    List<PrescriptionInfo> getPrescriptionInfo(String prescriptionCode);
}

+ 16 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prescription/PrescriptionInfoDao.java

@ -0,0 +1,16 @@
package com.yihu.wlyy.service.dao.prescription;
import com.yihu.wlyy.service.entity.prescription.PrescriptionInfo;
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 chenweida on 2017/7/27.
 */
public interface PrescriptionInfoDao extends PagingAndSortingRepository<PrescriptionInfo, Long>, JpaSpecificationExecutor<PrescriptionInfo> {
    @Query("from PrescriptionInfo p where p.prescriptionCode=?1 and p.del=1")
    List<PrescriptionInfo> findByPrescriptionCode(String prescriptionCode);
}

+ 17 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prescription/PrescriptionLogDao.java

@ -0,0 +1,17 @@
package com.yihu.wlyy.service.dao.prescription;
import com.yihu.wlyy.service.entity.prescription.PrescriptionLog;
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 chenweida on 2017/7/27.
 */
public interface PrescriptionLogDao extends PagingAndSortingRepository<PrescriptionLog, Long>, JpaSpecificationExecutor<PrescriptionLog> {
    @Query("select l.status,l.createTime from PrescriptionLog l where l.prescriptionCode=?1 and l.type in ?2 order by createTime desc")
    List<PrescriptionLog> findPrescriptionLogsByPrescriptionCode(String prescriptionCode, Integer[] types);
}

+ 14 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prescription/PrescriptionPayDao.java

@ -0,0 +1,14 @@
package com.yihu.wlyy.service.dao.prescription;
import com.yihu.wlyy.service.entity.prescription.PrescriptionPay;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by chenweida on 2017/7/27.
 */
public interface PrescriptionPayDao extends PagingAndSortingRepository<PrescriptionPay, Long>, JpaSpecificationExecutor<PrescriptionPay> {
    @Query("from PrescriptionPay p where p.prescriptionCode=?1 and p.status=1")
    PrescriptionPay findByPrescriptionPay(String prescriptionCode);
}

+ 15 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/dao/prescription/PrescriptionReviewedDao.java

@ -0,0 +1,15 @@
package com.yihu.wlyy.service.dao.prescription;
import com.yihu.wlyy.service.entity.prescription.PrescriptionReviewed;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2017/8/4.
 */
public interface PrescriptionReviewedDao extends PagingAndSortingRepository<PrescriptionReviewed, Long>, JpaSpecificationExecutor<PrescriptionReviewed> {
    @Query("select p from PrescriptionReviewed p where p.prescriptionCode=?1")
    PrescriptionReviewed findByPrescriptionCode(String prescriptionCode);
}

+ 107 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/ZyPushLog.java

@ -0,0 +1,107 @@
package com.yihu.wlyy.service.entity;
import com.yihu.wlyy.service.common.model.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 *  保存智业推送日志
 * Created by yeshijie on 2017/8/5.
 */
@Entity
@Table(name = "wlyy_zy_push_log")
public class ZyPushLog extends IdEntity {
    private String type;//'接口类型 1(推送续方)',
    private String content;//'业务内容',
    private String api;//'调用接口',
    private String method;//'调用方式',
    private String response;//'返回结果',
    private String request;//'请求数据',
    private String error;//'报错信息',
    private String status;//'状态 0失败 1成功 2已重试',
    private Integer retryTimes;//'重试次数',
    private Date createTime;// '创建时间',
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public String getApi() {
        return api;
    }
    public void setApi(String api) {
        this.api = api;
    }
    public String getMethod() {
        return method;
    }
    public void setMethod(String method) {
        this.method = method;
    }
    public String getResponse() {
        return response;
    }
    public void setResponse(String response) {
        this.response = response;
    }
    public String getRequest() {
        return request;
    }
    public void setRequest(String request) {
        this.request = request;
    }
    public String getError() {
        return error;
    }
    public void setError(String error) {
        this.error = error;
    }
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    public Integer getRetryTimes() {
        return retryTimes;
    }
    public void setRetryTimes(Integer retryTimes) {
        this.retryTimes = retryTimes;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 426 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/Prescription.java

@ -0,0 +1,426 @@
package com.yihu.wlyy.service.entity.prescription;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.service.common.model.IdEntity;
import org.springframework.util.StringUtils;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
/**
 * Created by Administrator on 2017/7/21.
 * 处方
 */
@Entity
@Table(name = "wlyy_prescription")
public class Prescription extends IdEntity {
    private String code;                    //业务主键
    private String jwCode;                  //基卫的处方code
    private String parentCode;             //如果是续方 那就是处方的code
    private Date createTime;               //处方创建时间
    private Date reviewedTime;             //审核时间
    private Date payTime;                   //支付时间
    private Date dosageTime;                //配药完成时间
    private Date dispatchingTime;          //配送员领药时间
    private Date finishTime;                //配送员确认送达或居民确认取药的时间
    private String patient;                  //关联 wlyy_patient code
    private String patientName;             //患者名称
    private Integer type;                    //1 处方 2 续方
    private Integer status;                  //状态 (-3 支付过期 -2 患者自己取消 -1 审核不通过 , 0 待审核, 2调整中,3调整成功,4调整失败 10 审核通过/开方中  , 20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 , 40配药成功/待配送  41配送失败  42配送中   43配送到服务站  100配送到患者手中/已完成)
    private String doctor;                   //开处方的医生code 关联 wlyy_doctor
    private String doctorName;               //医生名称
    private Long adminTeamId;             //患者签约的行政团队
    private String hospital;                  //医院 关联 dm_hospital code
    private String hospitalName;              //医院 关联 dm_hospital name
    private String dept;                       //科室code
    private String deptName;                   //科室名称
    private String diagnosisCode;             //诊断的病种code
    private String diagnosis;                  //诊断名称
    private String consult;                    //咨询id 1对1
    //    private String dispensary_code;           //取药编码  关联wlyy_prescription_dispensary_code  code
//    private String dispensaryAddress;         //取药地址
    private Integer dispensaryType;            //取药类型:1 自取 2快递配送 3健管师配送
    private String caCertData;                  //ca加密信息
    //    private String expressNum;                  //快递单号
//    private String expressCompanyName;         //快递公司名称
    private String caMessage;                   //ca指纹信息
    private String remark;                     //处方备注
    private String reason;                      //续方原因
    //    private Double ybCost;                      //医保费用
//    private Double myCost;                      //自己付费
    private Integer prescriptionType;          //处方类型:1、门诊处方,2、住院处方
    private String statusName; //
    @Column(name = "code", unique = true, nullable = false)
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "parent_code")
    public String getParentCode() {
        return parentCode;
    }
    public void setParentCode(String parentCode) {
        this.parentCode = parentCode;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "reviewed_time")
    public Date getReviewedTime() {
        return reviewedTime;
    }
    public void setReviewedTime(Date reviewedTime) {
        this.reviewedTime = reviewedTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "pay_time")
    public Date getPayTime() {
        return payTime;
    }
    public void setPayTime(Date payTime) {
        this.payTime = payTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "dosage_time")
    public Date getDosageTime() {
        return dosageTime;
    }
    public void setDosageTime(Date dosageTime) {
        this.dosageTime = dosageTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "dispatching_time")
    public Date getDispatchingTime() {
        return dispatchingTime;
    }
    public void setDispatchingTime(Date dispatchingTime) {
        this.dispatchingTime = dispatchingTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "finish_time")
    public Date getFinishTime() {
        return finishTime;
    }
    public void setFinishTime(Date finishTime) {
        this.finishTime = finishTime;
    }
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "patient_name")
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    @Column(name = "type")
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    @Column(name = "status")
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    @Column(name = "doctor")
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    @Column(name = "doctor_name")
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    @Column(name = "admin_team_id")
    public Long getAdminTeamId() {
        return adminTeamId;
    }
    public void setAdminTeamId(Long adminTeamId) {
        this.adminTeamId = adminTeamId;
    }
    @Column(name = "hospital")
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    @Column(name = "hospital_name")
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    @Column(name = "dept")
    public String getDept() {
        return dept;
    }
    public void setDept(String dept) {
        this.dept = dept;
    }
    @Column(name = "dept_name")
    public String getDeptName() {
        return deptName;
    }
    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }
    @Column(name = "diagnosis_code")
    public String getDiagnosisCode() {
        return diagnosisCode;
    }
    public void setDiagnosisCode(String diagnosisCode) {
        this.diagnosisCode = diagnosisCode;
    }
    @Column(name = "diagnosis")
    public String getDiagnosis() {
        return diagnosis;
    }
    public void setDiagnosis(String diagnosis) {
        this.diagnosis = diagnosis;
    }
    @Column(name = "consult")
    public String getConsult() {
        return consult;
    }
    public void setConsult(String consult) {
        this.consult = consult;
    }
    @Column(name = "remark")
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    @Column(name = "dispensary_type")
    public Integer getDispensaryType() {
        return dispensaryType;
    }
    public void setDispensaryType(Integer dispensaryType) {
        this.dispensaryType = dispensaryType;
    }
    @Column(name = "ca_message")
    public String getCaMessage() {
        return caMessage;
    }
    public void setCaMessage(String caMessage) {
        this.caMessage = caMessage;
    }
    public String getJwCode() {
        return jwCode;
    }
    public void setJwCode(String jwCode) {
        this.jwCode = jwCode;
    }
    public String getReason() {
        return reason;
    }
    public void setReason(String reason) {
        this.reason = reason;
    }
    public String getCaCertData() {
        return caCertData;
    }
    public void setCaCertData(String caCertData) {
        this.caCertData = caCertData;
    }
    public Integer getPrescriptionType() {
        return prescriptionType;
    }
    public void setPrescriptionType(Integer prescriptionType) {
        this.prescriptionType = prescriptionType;
    }
    @Transient
    public String getTypeName() {
        switch (type) {
            case 1: {
                return "自取";
            }
            case 2: {
                return "快递配送";
            }
            case 3: {
                return "健管师配送";
            }
        }
        return "";
    }
    @Transient
    public String getStatusName() {
        return statusName;
    }
    public void setStatusName(String statusName) {
        this.statusName = getStatusName(status,null);
    }
    @Transient
    public static String getStatusName(Integer status, String hospitalName) {
        /**
         *  no_reviewed("审核不通过", -1),
         revieweding("待审核", 0),
         changeing("调整中",2),
         reviewed_success("审核通过/开方中", 10),
         wait_pay("开方完成/待支付", 20),
         pay_error("支付失败", 21),
         pay_success("支付成功/待配药", 30),
         wait_expressage("配药成功/待配送", 40),
         expressageing_error("配送失败", 41),
         expressageJGS("分配健管师", 42),
         expressageing("配送中", 45),
         expressage2hospital("配送到服务站", 49),
         finish("配送到患者手中/已完成", 100);
         */
        //-1 审核不通过 , 0 审核中, 10 审核通过/待支付 ,21支付失败  20 配药中/支付成功, 21 等待领药 ,30 配送中 ,100配送成功/已完成
        switch (status) {
            case -3: {
                return "支付超时";
            }
            case -2: {
                return "患者自己取消";
            }
            case -1: {
                return "审核不通过";
            }
            case 0: {
                return "待审核";
            }
            case 2: {
                return "调整处方中";
            }
            case 10: {
                return "开方中";
            }
            case 20: {
                return "开方完成";
            }
            case 21: {
                return "支付失败";
            }
            case 30: {
                return "订单已支付";
            }
            case 40: {
                return "配药完成";
            }
            case 41: {
                return "配送失败";
            }
            case 42: {
                return "分配健管师配送";
            }
            case 45: {
                return "配送中";
            }
            case 49: {
                if (StringUtils.isEmpty(hospitalName)) {
                    return "配送到服务站";
                }
                {
                    return "配送到" + hospitalName;
                }
            }
            case 100: {
                return "续方完成";
            }
        }
        return "未知";
    }
}

+ 81 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/PrescriptionAdjust.java

@ -0,0 +1,81 @@
package com.yihu.wlyy.service.entity.prescription;
import com.yihu.wlyy.service.common.model.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Administrator on 2017/7/21.
 * 处方调整记录表
 */
@Entity
@Table(name = "wlyy_prescription_adjust")
public class PrescriptionAdjust extends IdEntity {
    private String code;                    //业务主键
    private String prescriptionCode;// 处方code
    private Date createTime;               //调整时间
    private String reason;                      //调整原因
    private String userCode;    //调整用户code
    private String userName;    //调整用户名称
    private String userType;// 1医生 2患者
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getPrescriptionCode() {
        return prescriptionCode;
    }
    public void setPrescriptionCode(String prescriptionCode) {
        this.prescriptionCode = prescriptionCode;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getReason() {
        return reason;
    }
    public void setReason(String reason) {
        this.reason = reason;
    }
    public String getUserCode() {
        return userCode;
    }
    public void setUserCode(String userCode) {
        this.userCode = userCode;
    }
    public String getUserName() {
        return userName;
    }
    public void setUserName(String userName) {
        this.userName = userName;
    }
    public String getUserType() {
        return userType;
    }
    public void setUserType(String userType) {
        this.userType = userType;
    }
}

+ 63 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/PrescriptionDiagnosis.java

@ -0,0 +1,63 @@
package com.yihu.wlyy.service.entity.prescription;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.service.common.model.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Trick on 2017/7/28.
 * 处方诊断表
 */
@Entity
@Table(name = "wlyy_prescription_diagnosis")
public class PrescriptionDiagnosis  extends IdEntity {
    private String code;
    private String prescriptionCode;
    private String name;
    private Date createTime;
    private Date updateTime;
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getPrescriptionCode() {
        return prescriptionCode;
    }
    public void setPrescriptionCode(String prescriptionCode) {
        this.prescriptionCode = prescriptionCode;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}

+ 77 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/PrescriptionDispensaryCode.java

@ -0,0 +1,77 @@
package com.yihu.wlyy.service.entity.prescription;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.service.common.model.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Administrator on 2017/7/21.
 * 处方编码表
 */
@Entity
@Table(name = "wlyy_prescription_dispensary_code")
public class PrescriptionDispensaryCode extends IdEntity {
    private String code;                    //年月日8位数字+6位随机数字
    private String prescriptionCode;      //处方code  关联表wlyy_prescription code
    private Date createTime;               //创建时间
    private Integer type;                   //编码类型:1 居民取药码 2 配送员(健管师)取药码 3 配送员(健管师)配送码
    private String imgUrl;                  //图片存在FastFDS的路径
    private Integer isUse;//是否使用 1是 0否
    @Column(name = "code", unique = true , nullable=false)
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "prescription_code")
    public String getPrescriptionCode() {
        return prescriptionCode;
    }
    public void setPrescriptionCode(String prescriptionCode) {
        this.prescriptionCode = prescriptionCode;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    public String getImgUrl() {
        return imgUrl;
    }
    public void setImgUrl(String imgUrl) {
        this.imgUrl = imgUrl;
    }
    public Integer getIsUse() {
        return isUse;
    }
    public void setIsUse(Integer isUse) {
        this.isUse = isUse;
    }
}

+ 305 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/PrescriptionInfo.java

@ -0,0 +1,305 @@
package com.yihu.wlyy.service.entity.prescription;
import com.yihu.wlyy.service.common.model.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by Administrator on 2017/7/21.
 * 处方详细
 */
@Entity
@Table(name = "wlyy_prescription_info")
public class PrescriptionInfo extends IdEntity {
    private String code;                    //业务主键
    private String prescriptionCode;      //处方code 关联表wlyy_prescription code
    private String drugCode;               //药品code
    private String drugName;               //药品名称
    private String drugRate;               //吃药频率
    private String drugFormat;             //药品规格
    private Integer num;                    //药品数目
    private Integer isRefrigerate;         //是否冷藏 1是 0否
    private String direction;               //药品用法
    private Integer price;                    //药品单价 单位是分
    private Integer del;               //1可用 0删除 不填数据库默认是1
    private String jwSubCode;//智业子处方号
    private String drugNumUnit;//数量单位编码
    private String drugNumUnitName;//数量单位名称
    private Integer cost;//金额 单位是分
    private Integer charge;//自付 单位是分
    private String bindFlag;//成组标志, 0.非成组,1.成组
    private Integer dayCount;//用药天数
    private String drugUsage;//用药方法编码
    private String usageName;//用药方法名称
    private String physicDose;//用药剂量
    private String physicDoseUnit;//剂量单位编码
    private String physicDoseUnitName;//剂量单位名称
    private String physicAmount;//用药总量
    private String physicAmountUnit;//总量单位编码
    private String physicAmountUnitName;//总量单位名称
    private String physicInjectPlace;//注射地点编码
    private String physicInjectPlaceName;//注射地点名称
    private String physicSkinTest;//注射地点名称
    private String physicSkinTestName;//皮试类型名称
    private String remark;//备注
    @Column(name = "code",unique = true , nullable=false)
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "prescription_code")
    public String getPrescriptionCode() {
        return prescriptionCode;
    }
    public void setPrescriptionCode(String prescriptionCode) {
        this.prescriptionCode = prescriptionCode;
    }
    @Column(name = "drug_code")
    public String getDrugCode() {
        return drugCode;
    }
    public void setDrugCode(String drugCode) {
        this.drugCode = drugCode;
    }
    @Column(name = "drug_name")
    public String getDrugName() {
        return drugName;
    }
    public void setDrugName(String drugName) {
        this.drugName = drugName;
    }
    public String getDrugRate() {
        return drugRate;
    }
    public void setDrugRate(String drugRate) {
        this.drugRate = drugRate;
    }
    public String getDrugFormat() {
        return drugFormat;
    }
    public void setDrugFormat(String drugFormat) {
        this.drugFormat = drugFormat;
    }
    public Integer getNum() {
        return num;
    }
    public void setNum(Integer num) {
        this.num = num;
    }
    public Integer getIsRefrigerate() {
        return isRefrigerate;
    }
    public void setIsRefrigerate(Integer isRefrigerate) {
        this.isRefrigerate = isRefrigerate;
    }
    public String getDirection() {
        return direction;
    }
    public void setDirection(String direction) {
        this.direction = direction;
    }
    public Integer getPrice() {
        return price;
    }
    public void setPrice(Integer price) {
        this.price = price;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    public String getJwSubCode() {
        return jwSubCode;
    }
    public void setJwSubCode(String jwSubCode) {
        this.jwSubCode = jwSubCode;
    }
    public String getDrugNumUnit() {
        return drugNumUnit;
    }
    public void setDrugNumUnit(String drugNumUnit) {
        this.drugNumUnit = drugNumUnit;
    }
    public String getDrugNumUnitName() {
        return drugNumUnitName;
    }
    public void setDrugNumUnitName(String drugNumUnitName) {
        this.drugNumUnitName = drugNumUnitName;
    }
    public Integer getCost() {
        return cost;
    }
    public void setCost(Integer cost) {
        this.cost = cost;
    }
    public Integer getCharge() {
        return charge;
    }
    public void setCharge(Integer charge) {
        this.charge = charge;
    }
    @Column(name = "bind_flag")
    public String getBindFlag() {
        return bindFlag;
    }
    public void setBindFlag(String bindFlag) {
        this.bindFlag = bindFlag;
    }
    @Column(name = "day_count")
    public Integer getDayCount() {
        return dayCount;
    }
    public void setDayCount(Integer dayCount) {
        this.dayCount = dayCount;
    }
    public String getDrugUsage() {
        return drugUsage;
    }
    public void setDrugUsage(String drugUsage) {
        this.drugUsage = drugUsage;
    }
    @Column(name = "usage_name")
    public String getUsageName() {
        return usageName;
    }
    public void setUsageName(String usageName) {
        this.usageName = usageName;
    }
    @Column(name = "physic_dose")
    public String getPhysicDose() {
        return physicDose;
    }
    public void setPhysicDose(String physicDose) {
        this.physicDose = physicDose;
    }
    public String getPhysicDoseUnit() {
        return physicDoseUnit;
    }
    public void setPhysicDoseUnit(String physicDoseUnit) {
        this.physicDoseUnit = physicDoseUnit;
    }
    public String getPhysicDoseUnitName() {
        return physicDoseUnitName;
    }
    public void setPhysicDoseUnitName(String physicDoseUnitName) {
        this.physicDoseUnitName = physicDoseUnitName;
    }
    public String getPhysicAmount() {
        return physicAmount;
    }
    public void setPhysicAmount(String physicAmount) {
        this.physicAmount = physicAmount;
    }
    public String getPhysicAmountUnit() {
        return physicAmountUnit;
    }
    public void setPhysicAmountUnit(String physicAmountUnit) {
        this.physicAmountUnit = physicAmountUnit;
    }
    public String getPhysicAmountUnitName() {
        return physicAmountUnitName;
    }
    public void setPhysicAmountUnitName(String physicAmountUnitName) {
        this.physicAmountUnitName = physicAmountUnitName;
    }
    public String getPhysicInjectPlace() {
        return physicInjectPlace;
    }
    public void setPhysicInjectPlace(String physicInjectPlace) {
        this.physicInjectPlace = physicInjectPlace;
    }
    public String getPhysicInjectPlaceName() {
        return physicInjectPlaceName;
    }
    public void setPhysicInjectPlaceName(String physicInjectPlaceName) {
        this.physicInjectPlaceName = physicInjectPlaceName;
    }
    public String getPhysicSkinTest() {
        return physicSkinTest;
    }
    public void setPhysicSkinTest(String physicSkinTest) {
        this.physicSkinTest = physicSkinTest;
    }
    public String getPhysicSkinTestName() {
        return physicSkinTestName;
    }
    public void setPhysicSkinTestName(String physicSkinTestName) {
        this.physicSkinTestName = physicSkinTestName;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
}

+ 230 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/PrescriptionLog.java

@ -0,0 +1,230 @@
package com.yihu.wlyy.service.entity.prescription;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.service.common.model.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
/**
 * Created by Administrator on 2017/7/21.
 * 处方日志
 */
@Entity
@Table(name = "wlyy_prescription_log")
public class PrescriptionLog extends IdEntity {
    public enum PrescriptionLogType {
        zy("智业对接", 1),
        ylz("易联众对接", 2),
        create("创建处方", 3),
        reviewed("审核", 4),
        pay("支付", 5),
        expressage("配送", 6),
        finish("已完成", 7),
        sf("顺丰对接", 8);
        private String name;
        private int value;
        PrescriptionLogType(String name, int value) {
            this.name = name;
            this.value = value;
        }
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
        public int getValue() {
            return value;
        }
        public void setValue(int value) {
            this.value = value;
        }
    }
    //状态枚举
    public enum PrescriptionLogStatus {
        pay_outtime("支付超时", -3),
        patient_canel("患者自己取消", -2),
        no_reviewed("审核不通过", -1),
        revieweding("待审核", 0),
        changeing("调整中", 2),
        reviewed_success("审核通过/开方中", 10),
        wait_pay("开方完成/待支付", 20),
        pay_error("支付失败", 21),
        pay_success("支付成功/待配药", 30),
        wait_expressage("配药成功/待配送", 40),
        expressageing_error("配送失败", 41),
        expressageJGS("分配健管师", 42),
        expressageing("配送中", 45),
        expressage2hospital("配送到服务站", 49),
        finish("配送到患者手中/已完成", 100);
        private String name;
        private int value;
        PrescriptionLogStatus(String name, int value) {
            this.name = name;
            this.value = value;
        }
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
        public int getValue() {
            return value;
        }
        public void setValue(int value) {
            this.value = value;
        }
    }
    private String code;                    //业务流程
    private String prescriptionCode;      //处方code 关联表wlyy_prescription code
    private Date createTime;               //处方创建时间
    private Integer status;                 //状态 (-3 支付过期 -2 患者自己取消 -1 审核不通过 , 0 待审核, 2调整中,3调整成功,4调整失败 10 审核通过/开方中  , 20开方完成/待支付, 21 支付失败 , 30 支付成功/待配药 , 40配药成功/待配送  41配送失败 42分配健管师 45配送中   49配送到服务站  100配送到患者手中/已完成)
    private Integer type;                   //类型: 1智业对接 2易联众对接  3创建处方 4 审核  5付款 6 配送 7完成
    private String userCode;                  //医生或者患者code
    private String userName;                  //医生或者患者name
    private Integer userType;                 //1 患者 2医生
    private Integer flag;                      //操作是否成功 1成功 0失败
    private String remark;                     //备注信息
    private String hospital;                //医院code
    private String hospitalName;            //医院名称
    private String statusName;  //状态名称
    @Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name = "prescription_code")
    public String getPrescriptionCode() {
        return prescriptionCode;
    }
    public void setPrescriptionCode(String prescriptionCode) {
        this.prescriptionCode = prescriptionCode;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @Column(name = "type")
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    @Column(name = "user_code")
    public String getUserCode() {
        return userCode;
    }
    public void setUserCode(String userCode) {
        this.userCode = userCode;
    }
    @Column(name = "user_name")
    public String getUserName() {
        return userName;
    }
    public void setUserName(String userName) {
        this.userName = userName;
    }
    @Column(name = "user_type")
    public Integer getUserType() {
        return userType;
    }
    public void setUserType(Integer userType) {
        this.userType = userType;
    }
    @Column(name = "flag")
    public Integer getFlag() {
        return flag;
    }
    public void setFlag(Integer flag) {
        this.flag = flag;
    }
    @Column(name = "remark")
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    @Transient
    public String getStatusName() {
        return statusName;
    }
    public void setStatusName(String statusName) {
        this.statusName = Prescription.getStatusName(this.status,hospitalName);
    }
}

+ 99 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/PrescriptionPay.java

@ -0,0 +1,99 @@
package com.yihu.wlyy.service.entity.prescription;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.service.common.model.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by chenweida on 2017/7/26.
 * 处方支付表
 */
@Entity
@Table(name = "wlyy_prescription_pay")
public class PrescriptionPay extends IdEntity {
    private String code;//业务code
    private String payNum;//支付流水号
    private String prescriptionCode;//续方code
    private Date createTime;//创建时间
    private String ybCard;//医保卡号
    private Integer type;// 1 医保支付
    private Integer status;//状态  成功1 失败0
    private Integer ybCost;//统筹金额  单位分
    private Integer myCost;//自费金额  单位分
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getPayNum() {
        return payNum;
    }
    public void setPayNum(String payNum) {
        this.payNum = payNum;
    }
    public String getPrescriptionCode() {
        return prescriptionCode;
    }
    public void setPrescriptionCode(String prescriptionCode) {
        this.prescriptionCode = prescriptionCode;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getYbCard() {
        return ybCard;
    }
    public void setYbCard(String ybCard) {
        this.ybCard = ybCard;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public Integer getYbCost() {
        return ybCost;
    }
    public void setYbCost(Integer ybCost) {
        this.ybCost = ybCost;
    }
    public Integer getMyCost() {
        return myCost;
    }
    public void setMyCost(Integer myCost) {
        this.myCost = myCost;
    }
}

+ 167 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/entity/prescription/PrescriptionReviewed.java

@ -0,0 +1,167 @@
package com.yihu.wlyy.service.entity.prescription;
import com.yihu.wlyy.service.common.model.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Administrator on 2017/7/21.
 * 处方日志
 */
@Entity
@Table(name = "wlyy_prescription_reviewed")
public class PrescriptionReviewed extends IdEntity {
    //状态枚举
    public enum PrescriptionReviewedStatus {
        del("删除", -2),
        reviewed_fail("审核失败", -1),
        reviewed_wait("待审核", 0),
        reviewed_success("审核成功", 1);
        private String name;
        private int value;
        PrescriptionReviewedStatus(String name, int value) {
            this.name = name;
            this.value = value;
        }
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
        public int getValue() {
            return value;
        }
        public void setValue(int value) {
            this.value = value;
        }
    }
    private String code;                    //业务流程
    private String prescriptionCode;      //处方code 关联表wlyy_prescription code
    private Date createTime;               //审核时间
    private String hospital;                  //医院 关联 dm_hospital code
    private String hospitalName;              //医院 关联 dm_hospital name
    private String dept;                       //科室code
    private String deptName;                   //科室名称
    private String doctor;                  //审核医生
    private String doctorName;                  //审核医生名称
    private Integer status;               //  1审核通过1 0待审核  -1  审核通过   -2无效审核
    private String reason;                  //审核不通过原因
    private String remark;                  //备注
    private Date reviewedTime;           //审核时间
    public Date getReviewedTime() {
        return reviewedTime;
    }
    public void setReviewedTime(Date reviewedTime) {
        this.reviewedTime = reviewedTime;
    }
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getPrescriptionCode() {
        return prescriptionCode;
    }
    public void setPrescriptionCode(String prescriptionCode) {
        this.prescriptionCode = prescriptionCode;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    public String getDept() {
        return dept;
    }
    public void setDept(String dept) {
        this.dept = dept;
    }
    public String getDeptName() {
        return deptName;
    }
    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getReason() {
        return reason;
    }
    public void setReason(String reason) {
        this.reason = reason;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
}

+ 313 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/ZysoftBaseService.java

@ -0,0 +1,313 @@
package com.yihu.wlyy.service.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.service.common.SystemConfig;
import com.yihu.wlyy.service.common.http.HttpApiException;
import com.yihu.wlyy.service.common.model.Result;
import com.yihu.wlyy.service.common.util.StringUtil;
import com.yihu.wlyy.service.dao.HospitalMappingDao;
import com.yihu.wlyy.service.dao.ZyPushLogDao;
import com.yihu.wlyy.service.entity.HospitalMapping;
import com.yihu.wlyy.service.entity.ZyPushLog;
import com.zoe.phip.ssp.sdk.ApiException;
import net.sf.json.JSONObject;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.*;
/**
 * 智业接口--基本方法
 * Created by yeshijie on 2017/7/17.
 */
@Service
public class ZysoftBaseService {
    private org.slf4j.Logger logger= LoggerFactory.getLogger(ZysoftBaseService.class);
    @Autowired
    private LogService logService;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private HospitalMappingDao hospitalMappingDao;
    @Autowired
    private ZyPushLogDao zyPushLogDao;
    //默认重复次数
    private int retryTimes = 3;
    @Value("${zysoftApi.internet}")
    private String internet;
    @Value("${zysoftApi.base}")
    private String base;
    public String getCode() {
        return UUID.randomUUID().toString().replaceAll("-", "");
    }
    /**
     * 保存智业推送日志
     * @param request
     * @param api
     * @param content
     * @param error
     * @param method
     * @param status
     * @param type
     */
    public Result addZyPushLog(String request, String api, String content, String error, String method, String status, String type,String errMsg){
        Result re = null;
        if(errMsg==null){
            re = Result.success("接收线下处方调整完成消息成功");
        }else {
            re = Result.error(-1,errMsg);
        }
        ZyPushLog log = new ZyPushLog();
        log.setCreateTime(new Date());
        log.setApi(api);
        log.setContent(content);
        log.setError(error);
        log.setMethod(method);
        log.setRequest(request);
        log.setResponse(JSONObject.fromObject(re).toString());
        log.setRetryTimes(0);
        log.setStatus(status);
        log.setType(type);
        zyPushLogDao.save(log);
        return re;
    }
    /**
     * 获取基础路径
     * @param apiType
     * @return
     */
    private String getBaseApi(Integer apiType){
        String baseApi = "";
        switch (apiType){
            case 1:
                baseApi = base;
                break;
            case 2:
                baseApi = internet;
                break;
            default:
                baseApi = base;
                break;
        }
        return baseApi;
    }
    /**
     * 基卫二次封装Get接口
     */
    public String getSecond(String api, String content, Map<String,String> params, Map<String,String> headers, boolean needRetry,Integer apiType) throws Exception
    {
        String re = "";
        headers.put("INTERFACE",api);
        Map<String,String> paramsList = new HashMap<>();
        String msgBody = JSONObject.fromObject(params).toString();
        String msgHeader = JSONObject.fromObject(headers).toString();
        paramsList.put("msgHeader",msgHeader);
        paramsList.put("msgBody",msgBody);
        logger.info("msgHeader:"+msgHeader+"\r\n");
        logger.info("msgBody:"+msgBody+"\r\n");
        //新增日志
        String method = "GET";
        Boolean isSuccess = true;
        String error = "";
        String baseApi = getBaseApi(apiType);
        int times = 0;
        try {
            re = ZysoftApi.getSingleton().get(baseApi, paramsList, null,true);
            if(needRetry)
            {
                while(retryTimes>0 && re.contains("接口调用传入的参数[msgHeader]格式不正确"))    //基卫bug预防,重调接口
                {
                    re = ZysoftApi.getSingleton().post(baseApi, paramsList, null,true);
                    retryTimes --;
                    times++;
                }
            }
            Map<String,String> map = objectMapper.readValue(re,Map.class);
            String code = map.get("CODE");
            String message = map.get("MESSAGE");
            if(!code.equals("1"))
            {
                throw new HttpApiException(Integer.valueOf(code),message);
            }
            //保存http日志
            logService.saveHttpLog(isSuccess,api,content,method,msgHeader,msgBody,re,error);
        }
        catch (Exception ex)
        {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            ex.printStackTrace(pw);
            error = sw.toString();
            isSuccess = false;
            //保存http日志
            logService.saveHttpLog(isSuccess,api,content,method,msgHeader,msgBody,re,error);
            if(ex instanceof ApiException)
            {
                ApiException apiEx = (ApiException) ex;
                throw new HttpApiException(apiEx.errorCode(),ex.getMessage());
            }
            else{
                throw new HttpApiException(-1,ex.getMessage());
            }
        }
        return re;
    }
    /**
     * 基卫二次封装Post接口
     */
    public String postSecond(String api,String content, Map<String,String> params,JSONObject jsonParams, Map<String,String> headers,boolean needRetry,Integer apiType) throws Exception
    {
        String re = "";
        headers.put("INTERFACE",api);
        Map<String,String> paramsList = new HashMap<>();
        String msgBody = params==null?jsonParams.toString():JSONObject.fromObject(params).toString();
        String msgHeader = JSONObject.fromObject(headers).toString();
        paramsList.put("msgHeader",msgHeader);
        paramsList.put("msgBody",msgBody);
        logger.info("msgHeader:"+msgHeader+"\r\n");
        logger.info("msgBody:"+msgBody+"\r\n");
        //新增日志
        String method = "POST";
        Boolean isSuccess = true;
        String error = "";
        String baseApi = getBaseApi(apiType);
        int times = 0;
        try {
            re = ZysoftApi.getSingleton().post(baseApi, paramsList, null,true);
            if(needRetry)
            {
                int maxTimes = retryTimes;
                while(maxTimes>0 && re.contains("接口调用传入的参数[msgHeader]格式不正确"))    //基卫bug预防,重调接口
                {
                    re = ZysoftApi.getSingleton().post(baseApi, paramsList, null,true);
                    maxTimes --;
                    times++;
                }
            }
            Map<String,String> map = objectMapper.readValue(re,Map.class);
            String code = map.get("CODE");
            if(!code.equals("1"))
            {
                throw new HttpApiException(Integer.valueOf(code),map.get("MESSAGE"));
            }
            //保存http日志
            logService.saveHttpLog(isSuccess,api,content,method,msgHeader,msgBody,re,error);
        }
        catch (Exception ex)
        {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            ex.printStackTrace(pw);
            error = sw.toString();
            //保存http日志
            logService.saveHttpLog(isSuccess,api,content,method,msgHeader,msgBody,re,error);
            if(ex instanceof ApiException)
            {
                ApiException apiEx = (ApiException) ex;
                throw new HttpApiException(apiEx.errorCode(),ex.getMessage());
            }
            else{
                throw new HttpApiException(-1,ex.getMessage());
            }
        }
        return re;
    }
    /**
     * 获取机构映射
     */
    public String[] getHospitalMapping(String hospital) throws Exception
    {
        if(StringUtil.isEmpty(hospital)) //使用默认医院
        {
            String mappingCode = SystemConfig.getInstance().getJwHospital();
            String licence = SystemConfig.getInstance().getJwLicence();
            return new String[]{mappingCode,licence};
        }
        else {
            HospitalMapping hm = hospitalMappingDao.getMappingCode(hospital, "1");  //转换成基卫机构代码
            String licence = "";
            if (hm != null && !StringUtil.isEmpty(hm.getMappingCode()) && !StringUtil.isEmpty(hm.getLicence())) {
                hospital = hm.getMappingCode();
                licence = hm.getLicence();
            } else {
                throw new Exception("机构【" + hospital + "】映射配置未完善!");
            }
            return new String[]{hospital, licence};
        }
    }
    /*************************** 格式转换 *******************************************************/
    /**
     * 获取单对象
     */
    public Map<String,String> getJwOne(String response) throws Exception
    {
        Map<String,String> re = new HashMap<>();
        Map<String,Object> map = objectMapper.readValue(response,Map.class);
        String code = String.valueOf(map.get("CODE"));
        if(code.equals("1")) {
            List<Map<String, String>> list = (List<Map<String, String>>) map.get("DATA");
            if (list != null && list.size() > 0) {
                re = list.get(0);
            }
        }
        else{
            re.put("MESSAGE",String.valueOf(map.get("MESSAGE")));
        }
        return re;
    }
    /**
     * 获取单对象列表
     **/
    public List<Map<String,String>> getJwList(String response) throws Exception
    {
        Map<String,Object> map = objectMapper.readValue(response,Map.class);
        List<Map<String,String>> list = (List<Map<String,String>>)map.get("DATA");
        return list;
    }
}

+ 373 - 0
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/ZysoftMaternalService.java

@ -0,0 +1,373 @@
package com.yihu.wlyy.service.service;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
 * 智业接口--产检模块
 * Created by yeshijie on 2017/7/17.
 * 方法注释中7.32等为智业接口文档的编号
 */
@Service
public class ZysoftMaternalService extends ZysoftBaseService{
    /**
     * 7.32获取孕妇建卡信息(妇幼保健)
     */
    public String getEhrMaternalFirstExamRecord(String idcard,String searchTime,String hospital,String licence) throws Exception
    {
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("SEARCH_TIME",searchTime);
        String response = postSecond("getEhrMaternalFirstExamRecord","获取孕妇建卡信息",params,null,header,false,1);
        return response;
    }
    /**
     * 7.33 获取非第一次产检记录
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @return
     * @throws Exception
     */
    public String getEhrMaternalReExamRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("SEARCH_TIME",searchTime);
        String response = postSecond("getEhrMaternalReExamRecord","获取非第一次产检记录",params,null,header,false,1);
        return response;
    }
    /**
     * 7.34 获取产床预约信息
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @return
     * @throws Exception
     */
    public String getEhrMaternalBedPrecontractRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("SEARCH_TIME",searchTime);
        String response = postSecond("getEhrMaternalBedPrecontractRecord","获取产床预约信息",params,null,header,false,1);
        return response;
    }
    /**
     * 7.35 获取高危产妇信息
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @return
     * @throws Exception
     */
    public String getEhrMaternalPregnancyHighRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("SEARCH_TIME",searchTime);
        String response = postSecond("getEhrMaternalPregnancyHighRecord","获取高危产妇信息",params,null,header,false,1);
        return response;
    }
    /**
     * 7.36 获取孕妇分娩信息
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @return
     * @throws Exception
     */
    public String getEhrMaternalDeliveryRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("SEARCH_TIME",searchTime);
        String response = postSecond("getEhrMaternalDeliveryRecord","获取孕妇分娩信息",params,null,header,false,1);
        return response;
    }
    /**
     * 7.37 获取新生儿基本信息
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @return
     * @throws Exception
     */
    public String getEhrMaternalDeliveryChildRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("SEARCH_TIME",searchTime);
        String response = postSecond("getEhrMaternalDeliveryChildRecord","获取新生儿基本信息",params,null,header,false,1);
        return response;
    }
    /**
     * 7.38 获取儿童健康体检0-6岁记录
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @return
     * @throws Exception
     */
    public String getEhrMaternalChildMedicalRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("SEARCH_TIME",searchTime);
        String response = postSecond("getEhrMaternalChildMedicalRecord","获取儿童健康体检0-6岁记录",params,null,header,false,1);
        return response;
    }
    /**
     * 7.39 获取新生儿访视信息
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @return
     * @throws Exception
     */
    public String getEhrMaternalHomeVisitRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("SEARCH_TIME",searchTime);
        String response = postSecond("getEhrMaternalHomeVisitRecord","获取新生儿访视信息",params,null,header,false,1);
        return response;
    }
    /**
     * 7.40 获取新生儿免疫记录
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @return
     * @throws Exception
     */
    public String getEhrMaternalChildImmuneRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("SEARCH_TIME",searchTime);
        String response = postSecond("getEhrMaternalChildImmuneRecord","获取新生儿免疫记录",params,null,header,false,1);
        return response;
    }
    /**
     * 7.41 获取孕妇预建卡信息
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @return
     * @throws Exception
     */
    public String getEhrMaternalPreFirstExamRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("SEARCH_TIME",searchTime);
        String response = postSecond("getEhrMaternalPreFirstExamRecord","获取孕妇预建卡信息",params,null,header,false,1);
        return response;
    }
    /**
     * 7.42 上传孕妇预建卡信息
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @return
     * @throws Exception
     */
    public String SaveEhrMaternalPreFirstExamRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("SEARCH_TIME",searchTime);
        String response = postSecond("SaveEhrMaternalPreFirstExamRecord","上传孕妇预建卡信息",params,null,header,false,1);
        return response;
    }
    /**
     * 7.43 上传新生儿访视信息
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @return
     * @throws Exception
     */
    public String SaveEhrMaternalHomeVisitRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("IDENTITY_CARD_NO",idcard);
        params.put("SEARCH_TIME",searchTime);
        String response = postSecond("SaveEhrMaternalHomeVisitRecord","上传新生儿访视信息",params,null,header,false,1);
        return response;
    }
    /**
     * 7.44 获取待产记录
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @return
     * @throws Exception
     */
    public String getEhrMaternalZSPreDeliveryRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("PUERPERA_ID_NUMBER",idcard);
        params.put("TPP_RECORD_DATE_TIME",searchTime);
        String response = postSecond("getEhrMaternalZSPreDeliveryRecord","获取待产记录",params,null,header,false,1);
        return response;
    }
    /**
     * 7.45 获取阴道分娩记录
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @return
     * @throws Exception
     */
    public String getEhrMaternalZSDeliveryRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("PUERPERA_ID_NUMBER",idcard);
        params.put("CREATE_TIME",searchTime);
        String response = postSecond("getEhrMaternalZSDeliveryRecord","获取阴道分娩记录",params,null,header,false,1);
        return response;
    }
    /**
     * 7.46 获取剖宫产记录
     * @param idcard
     * @param searchTime
     * @param hospital
     * @param licence
     * @return
     * @throws Exception
     */
    public String getEhrMaternalZSCaesareanBirthRecord(String idcard,String searchTime,String hospital,String licence) throws Exception{
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("ORG_CODE",hospital);
        params.put("PUERPERA_ID_NUMBER",idcard);
        params.put("CREATE_TIME",searchTime);
        String response = postSecond("getEhrMaternalZSCaesareanBirthRecord","获取剖宫产记录",params,null,header,false,1);
        return response;
    }
}

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

@ -0,0 +1,328 @@
package com.yihu.wlyy.service.service.prescription;
import com.yihu.wlyy.service.common.model.Result;
import com.yihu.wlyy.service.dao.prescription.PrescriptionDao;
import com.yihu.wlyy.service.dao.prescription.PrescriptionLogDao;
import com.yihu.wlyy.service.entity.prescription.Prescription;
import com.yihu.wlyy.service.entity.prescription.PrescriptionLog;
import com.yihu.wlyy.service.service.ZysoftBaseService;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
 * 长处方接口
 * Created by yeshijie on 2017/8/3.
 */
@Service
public class PrescriptionService extends ZysoftBaseService{
    private static Logger logger = LoggerFactory.getLogger(PrescriptionService.class);
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired
    private PrescriptionLogDao prescriptionLogDao;
    @Autowired
    private StringRedisTemplate redisTemplate;
    private static final String channelTopic = "prescription";
    /**
     * 新增续方日志
     * @param prescription
     */
    public void addPrescriptionLog(Prescription prescription){
        PrescriptionLog log = new PrescriptionLog();
        log.setStatus(prescription.getStatus());
        log.setPrescriptionCode(prescription.getCode());
        log.setCode(getCode());
        log.setCreateTime(new Date());
        log.setType(1);
        log.setFlag(1);
        log.setHospital(prescription.getHospital());
        log.setHospitalName(prescription.getHospitalName());
        log.setRemark("接收线下处方调整完成消息");
        log.setUserCode(prescription.getDoctor());
        log.setUserName(prescription.getDoctorName());
        log.setUserType(2);
        prescriptionLogDao.save(log);
    }
    /********************************************智业推送数据处理 start**************************************************/
    /**
     * 接收线下处方调整完成消息
     */
    public Result prescriptionAdjustCompleted(String jsonObject){
        String error = null;
        String status = "1";
        String errMsg = null;
        try{
            JSONObject json = JSONObject.fromObject(jsonObject);
            Integer state= json.getInt("CODE");
            String code = json.getString("RECIPE_NO");
            Prescription prescription = prescriptionDao.findByCode(code);
            if(prescription.getStatus()==2){
                if(state==1){
                    prescription.setStatus(3);
                    // redis 的发布
                    redisTemplate.convertAndSend(channelTopic,JSONObject.fromObject(prescription).toString());
                }else {
                    //调整失败
                    prescription.setStatus(4);
                }
                prescriptionDao.save(prescription);
                //新增续方日志
                addPrescriptionLog(prescription);
            }
        }catch (Exception e){
            e.printStackTrace();
            error = e.getMessage();
            status = "0";
        }
        //添加日志
        return addZyPushLog(jsonObject,"prescriptionAdjustCompleted","接收线下处方调整完成消息",error,"POST",status,"1",errMsg);
    }
    /**
     * 接收预结算完成消息
     */
    public Result prePayCompletion(String jsonObject){
        String error = null;
        String status = "1";
        String errMsg = null;
        try{
        }catch (Exception e){
            e.printStackTrace();
            error = e.getMessage();
            status = "0";
        }
        //添加日志
        return addZyPushLog(jsonObject,"prePayCompletion","接收预结算完成消息",error,"POST",status,"1",errMsg);
    }
    /**
     * 接收配药完成消息
     */
    public Result dispensingComplete(String jsonObject){
        String error = null;
        String status = "1";
        String errMsg = null;
        try{
        }catch (Exception e){
            e.printStackTrace();
            error = e.getMessage();
            status = "0";
        }
        //添加日志
        return addZyPushLog(jsonObject,"dispensingComplete","接收配药完成消息",error,"POST",status,"1",errMsg);
    }
    /**
     * 接收药师审方完成及结果消息
     */
    public Result pharmacistPrescriptionCompletion(String jsonObject){
        String error = null;
        String status = "1";
        String errMsg = null;
        try{
        }catch (Exception e){
            e.printStackTrace();
            error = e.getMessage();
            status = "0";
        }
        //添加日志
        return addZyPushLog(jsonObject,"pharmacistPrescriptionCompletion","接收药师审方完成及结果消息",error,"POST",status,"1",errMsg);
    }
    /********************************************智业推送数据处理 end**************************************************/
    /*********************************************请求智业接口数据 start**************************************************/
    /**
     * 7.1字典获取接口
     * @param dictName 字典名称
     * @param hospital
     * @param licence
     * @return
     * @throws Exception
     */
    public String getDictForI(String dictName,String hospital,String licence)  throws Exception
    {
        if(hospital==null){
            String[] hospitalMapping = getHospitalMapping(null); //获取机构映射
            hospital = hospitalMapping[0];
            licence = hospitalMapping[1];
        }
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("dictName",dictName);
        String response = postSecond("getDictForI","字典获取接口",params,null,header,false,2);
        return response;
    }
    /**
     * 7.2 处方模板获取接口
     * @param staffCode 员工编码
     * @param deptCode 部门编码
     * @param hospital
     * @param licence
     * @return
     * @throws Exception
     */
    public String getRecipeTemplate(String staffCode,String deptCode,String hospital,String licence)  throws Exception
    {
        if(hospital==null){
            String[] hospitalMapping = getHospitalMapping(null); //获取机构映射
            hospital = hospitalMapping[0];
            licence = hospitalMapping[1];
        }
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("staffCode",staffCode);
        params.put("deptCode",deptCode);
        String response = postSecond("getRecipeTemplate","处方模板获取接口",params,null,header,false,2);
        return response;
    }
    /**
     * 调阅历史处方接口
     * @param cardNo 卡号
     * @param recipeNo 医嘱号
     * @param hospital
     * @param licence
     * @return
     * @throws Exception
     */
    public String getLastRecipe(String cardNo,String recipeNo,String hospital,String licence)  throws Exception
    {
        if(hospital==null){
            String[] hospitalMapping = getHospitalMapping(null); //获取机构映射
            hospital = hospitalMapping[0];
            licence = hospitalMapping[1];
        }
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("cardNo",cardNo);
        params.put("recipeNo",recipeNo);
        String response = postSecond("getLastRecipe","调阅历史处方接口",params,null,header,false,2);
        return response;
    }
    /**
     * 7.4 挂号开处方接口
     * @param json
     * @param hospital
     * @param licence
     * @return
     * @throws Exception
     */
    public String saveRecipe(JSONObject json, String hospital, String licence)  throws Exception
    {
        if(hospital==null){
            String[] hospitalMapping = getHospitalMapping(null); //获取机构映射
            hospital = hospitalMapping[0];
            licence = hospitalMapping[1];
        }
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        String response = postSecond("saveRecipe","挂号开处方接口",null,json,header,false,2);
        return response;
    }
    /**
     * 7.5 查询处方结算结果列表
     * @param cardNo
     * @param hospital
     * @param licence
     * @return
     * @throws Exception
     */
    public String getDispUnSettleFeeList(String cardNo, String hospital, String licence)  throws Exception
    {
        if(hospital==null){
            String[] hospitalMapping = getHospitalMapping(null); //获取机构映射
            hospital = hospitalMapping[0];
            licence = hospitalMapping[1];
        }
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("cardNo",cardNo);
        String response = postSecond("getDispUnSettleFeeList","查询处方结算结果列表",params,null,header,false,2);
        return response;
    }
    /**
     * 7.6 院内结算确认接口
     * @param json
     * @param hospital
     * @param licence
     * @return
     * @throws Exception
     */
    public String executeSickSettle(JSONObject json, String hospital, String licence)  throws Exception
    {
        if(hospital==null){
            String[] hospitalMapping = getHospitalMapping(null); //获取机构映射
            hospital = hospitalMapping[0];
            licence = hospitalMapping[1];
        }
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        String response = postSecond("executeSickSettle","院内结算确认接口",null,json,header,false,2);
        return response;
    }
    /*********************************************请求智业接口数据 end**************************************************/
}

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

@ -59,6 +59,11 @@ spring:
    maxTotal: 500
    maxIdle: 30
  redis:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
#    password: jkzl_ehr
---
spring:
  profiles: test
@ -70,7 +75,10 @@ spring:
    maxTotal: 500
    maxIdle: 30
  redis:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
#    password: jkzl_ehr
---
spring:
  profiles: production
@ -81,3 +89,8 @@ spring:
    driverClassName: com.mysql.jdbc.Driver
    maxTotal: 500
    maxIdle: 30
  redis:
    host: 120.41.253.95 # Redis server host.
    port: 6380 # Redis server port.
    password: jkzl_ehr