Browse Source

代码修改

LAPTOP-KB9HII50\70708 3 years ago
parent
commit
7efe025218

+ 128 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/prescription/BaseCarePrescriptionDO.java

@ -0,0 +1,128 @@
package com.yihu.jw.entity.care.prescription;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
/**
 * Created by yeshijie on 2021/10/11.
 */
@Entity
@Table(name="base_care_prescription")
public class BaseCarePrescriptionDO extends UuidIdentityEntityWithCreateTime {
    private String patient;//
    private String patientName;//
    private Integer status;//状态1待处理 2已处理
    private String doctor;//处理医生
    private String doctorName;//
    private String applyImgs;//申请附件
    private String applyContent;//申请内容
    private String dealImgs;//处理附件
    private String dealContent;//处理内容
    private String sex;
    private String age;
    @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 = "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 = "apply_imgs")
    public String getApplyImgs() {
        return applyImgs;
    }
    public void setApplyImgs(String applyImgs) {
        this.applyImgs = applyImgs;
    }
    @Column(name = "apply_content")
    public String getApplyContent() {
        return applyContent;
    }
    public void setApplyContent(String applyContent) {
        this.applyContent = applyContent;
    }
    @Column(name = "deal_imgs")
    public String getDealImgs() {
        return dealImgs;
    }
    public void setDealImgs(String dealImgs) {
        this.dealImgs = dealImgs;
    }
    @Column(name = "deal_content")
    public String getDealContent() {
        return dealContent;
    }
    public void setDealContent(String dealContent) {
        this.dealContent = dealContent;
    }
    @Transient
    public String getSex() {
        return sex;
    }
    public void setSex(String sex) {
        this.sex = sex;
    }
    @Transient
    public String getAge() {
        return age;
    }
    public void setAge(String age) {
        this.age = age;
    }
}

+ 12 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/prescription/BaseCarePrescriptionDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.care.dao.prescription;
import com.yihu.jw.entity.care.message.OrgNoticeDO;
import com.yihu.jw.entity.care.prescription.BaseCarePrescriptionDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by yeshijie on 2021/10/11.
 */
public interface BaseCarePrescriptionDao  extends PagingAndSortingRepository<BaseCarePrescriptionDO,String>, JpaSpecificationExecutor<BaseCarePrescriptionDO> {
}

+ 113 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/prescription/PrescriptionEndpoint.java

@ -0,0 +1,113 @@
package com.yihu.jw.care.endpoint.prescription;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.aop.ObserverRequired;
import com.yihu.jw.care.service.prescription.BaseCarePrescriptionService;
import com.yihu.jw.entity.care.prescription.BaseCarePrescriptionDO;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.common.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
 * Created by yeshijie on 2021/10/11.
 */
@RestController
@RequestMapping("prescription" )
@Api(tags = "续方信息", description = "续方信息")
public class PrescriptionEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private BaseCarePrescriptionService prescriptionService;
    @GetMapping(value = "queryPatientList")
    @ApiOperation(value = "居民查询工单列表")
    public PageEnvelop queryPatientList(
            @ApiParam(name = "patientId", value = "居民id") @RequestParam(value = "patientId", required = true) String patientId,
            @ApiParam(name = "status", value = "工单状态") @RequestParam(value = "status", required = false) Integer status,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1") @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15") @RequestParam(value = "size") int size) {
        try{
            JSONObject result = prescriptionService.queryPatientList(patientId, status, page, size);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return PageEnvelop.getError(result.getString(ResponseContant.resultMsg));
            }
            Long count = result.getLongValue(ResponseContant.count);
            return PageEnvelop.getSuccessListWithPage("查询成功",(List<BaseCarePrescriptionDO>)result.get(ResponseContant.resultMsg),page,size,count);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "queryDoctorList")
    @ApiOperation(value = "医生端列表查询")
    public PageEnvelop queryDoctorList(
            @ApiParam(name = "doctorCode", value = "医生id") @RequestParam(value = "doctorCode", required = true) String doctorCode,
            @ApiParam(name = "status", value = "工单状态") @RequestParam(value = "status", required = false) Integer status,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1") @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15") @RequestParam(value = "size") int size) {
        try{
            JSONObject result = prescriptionService.queryDoctorList(doctorCode, status, page, size);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return PageEnvelop.getError(result.getString(ResponseContant.resultMsg));
            }
            Long count = result.getLongValue(ResponseContant.count);
            return PageEnvelop.getSuccessListWithPage("查询成功",(List<BaseCarePrescriptionDO>)result.get(ResponseContant.resultMsg),page,size,count);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
    @PostMapping(value = "applyPrescription")
    @ApiOperation(value = "申请续方")
    public ObjEnvelop applyPrescription(@ApiParam(name = "applyImgs", value = "申请图片")
                             @RequestParam(value = "applyImgs", required = false)String applyImgs,
                                        @ApiParam(name = "applyContent", value = "附加说明")
                             @RequestParam(value = "applyContent", required = false)String applyContent,
                                        @ApiParam(name = "patientId", value = "居民id")
                                            @RequestParam(value = "patientId", required = true)String patientId){
        try{
            return success(prescriptionService.applyPrescription(patientId,applyImgs,applyContent));
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @PostMapping(value = "dealPrescription")
    @ApiOperation(value = "处理续方")
    @ObserverRequired
    public Envelop dealPrescription(@ApiParam(name = "dealImgs", value = "处理图片")
                                    @RequestParam(value = "dealImgs", required = false)String dealImgs,
                                    @ApiParam(name = "dealContent", value = "续方说明")
                                    @RequestParam(value = "dealContent", required = false)String dealContent,
                                    @ApiParam(name = "id", value = "居民id")
                                    @RequestParam(value = "id", required = true)String id,
                                    @ApiParam(name = "doctorId", value = "医生id")
                                    @RequestParam(value = "doctorId", required = true)String doctorId){
        try{
            String result = prescriptionService.dealPrescription(id,dealImgs,dealContent,doctorId);
            if(StringUtils.isBlank(result)){
                return success("处理成功");
            }else {
                return failed(result,-1);
            }
        }catch (Exception e){
            return failedException2(e);
        }
    }
}

+ 190 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/prescription/BaseCarePrescriptionService.java

@ -0,0 +1,190 @@
package com.yihu.jw.care.service.prescription;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.prescription.BaseCarePrescriptionDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.prescription.BaseCarePrescriptionDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * Created by yeshijie on 2021/10/11.
 */
@Service
public class BaseCarePrescriptionService {
    @Autowired
    private BaseCarePrescriptionDao carePrescriptionDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 医生端列表查询
     * @param doctorCode
     * @param status
     * @param page
     * @param size
     * @return
     */
    public JSONObject queryDoctorList(String doctorCode, Integer status, int page, int size) {
        JSONObject result = new JSONObject();
        List<BaseCarePrescriptionDO> sqlResultlist;
        String sql = "select distinct a.*," +
                "     case p.sex " +
                "     when 1 then '男'  " +
                "     when 2 then '女' " +
                "     end AS sex, " +
                "     TIMESTAMPDIFF(year,p.birthday,NOW()) AS age  ";
        String filters = "from base_care_prescription a" +
                " LEFT JOIN base_patient p ON a.patient = p.id," +
                "         base_service_package_sign_record sr,base_service_package_record r,base_service_package pack," +
                "         base_team_member m " +
                "         WHERE  sr.id = r.sign_id and sr.patient = a.patient and r.service_package_id = pack.id " +
                "         and m.team_code = r.team_code  and m.doctor_code = '"+doctorCode+"' ";
        if(status != null){
            filters += " and a.status = "+status;
        }
        int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? 15 : size;
        String limit = " order by a.create_time desc limit "+start+","+end;
        String countSql = "SELECT count(distinct a.id) ";
        try {
            sqlResultlist = jdbcTemplate.query(sql+filters+limit,new BeanPropertyRowMapper(BaseCarePrescriptionDO.class));
        } catch (Exception e) {
            e.printStackTrace();
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, "从数据库查询列表信息失败");
            return result;
        }
        Long count;
        try {
            count = jdbcTemplate.queryForObject(countSql+filters, Long.class);
        } catch (Exception e) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, "从数据库统计数量失败" );
            return result;
        }
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, sqlResultlist);
        JSONObject countItem = new JSONObject();
        countItem.put("count", count);
        result.putAll(countItem);
        return result;
    }
    /**
     * 居民端列表查询
     * @param patientId
     * @param status
     * @param page
     * @param size
     * @return
     */
    public JSONObject queryPatientList(String patientId, Integer status, int page, int size) {
        JSONObject result = new JSONObject();
        List<BaseCarePrescriptionDO> sqlResultlist;
        String sql = "select * from base_care_prescription  ";
        String filters = " where patient = '"+patientId+"' ";
        if(status != null){
            filters += " and status = "+status;
        }
        int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? 15 : size;
        String limit = " order by create_time desc limit "+start+","+end;
        String countSql = "SELECT count(id) from base_care_prescription ";
        try {
            sqlResultlist = jdbcTemplate.query(sql+filters+limit,new BeanPropertyRowMapper(BaseCarePrescriptionDO.class));
        } catch (Exception e) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, "从数据库查询列表信息失败");
            return result;
        }
        Long count;
        try {
            count = jdbcTemplate.queryForObject(countSql+filters, Long.class);
        } catch (Exception e) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, "从数据库统计数量失败" );
            return result;
        }
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, sqlResultlist);
        JSONObject countItem = new JSONObject();
        countItem.put("count", count);
        result.putAll(countItem);
        return result;
    }
    /**
     * 申请续方
     * @param patient
     * @param applyImgs
     * @param applyContent
     */
    public BaseCarePrescriptionDO applyPrescription(String patient,String applyImgs,String applyContent){
        BaseCarePrescriptionDO prescriptionDO = new BaseCarePrescriptionDO();
        prescriptionDO.setApplyImgs(applyImgs);
        prescriptionDO.setApplyContent(applyContent);
        BasePatientDO patientDO = patientDao.findById(patient);
        prescriptionDO.setPatient(patient);
        prescriptionDO.setPatientName(patientDO.getName());
        prescriptionDO.setStatus(1);
        carePrescriptionDao.save(prescriptionDO);
        return prescriptionDO;
    }
    /**
     * 医生处理续方
     * @param id
     * @param dealImgs
     * @param dealContent
     */
    public String dealPrescription(String id,String dealImgs,String dealContent,String doctor){
        String result = "";
        BaseCarePrescriptionDO prescriptionDO = carePrescriptionDao.findOne(id);
        if(2 == prescriptionDO.getStatus()){
            return "请勿重复处理";
        }
        prescriptionDO.setDealContent(dealContent);
        prescriptionDO.setDealImgs(dealImgs);
        prescriptionDO.setStatus(2);
        prescriptionDO.setDoctor(doctor);
        BaseDoctorDO doctorDO = doctorDao.findById(doctor);
        prescriptionDO.setDoctorName(doctorDO.getName());
        carePrescriptionDao.save(prescriptionDO);
        return result;
    }
}