ソースを参照

添加药品字典相关功能

humingfen 3 年 前
コミット
1cba7a24e2

+ 14 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/BaseNationalDrugDictDao.java

@ -0,0 +1,14 @@
package com.yihu.jw.hospital.prescription.dao;
import com.yihu.jw.entity.hospital.prescription.BaseNationalDrugDictDO;
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;
public interface BaseNationalDrugDictDao extends PagingAndSortingRepository<BaseNationalDrugDictDO, Integer>, JpaSpecificationExecutor<BaseNationalDrugDictDO> {
    @Query("update BaseNationalDrugDictDO b set b.status = ?2 where b.id = ?1")
    @Modifying
    void updateStatusById(Integer id, Integer status);
}

+ 85 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/NationalDrugDictService.java

@ -0,0 +1,85 @@
package com.yihu.jw.hospital.prescription.service;
import com.yihu.jw.entity.hospital.prescription.BaseNationalDrugDictDO;
import com.yihu.jw.hospital.prescription.dao.BaseNationalDrugDictDao;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.util.common.ConvertToSpellUtils;
import com.yihu.jw.util.common.PingyinUtils;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import static com.yihu.jw.util.common.BeanUtils.getNullPropertyNames;
@Service
@Transactional
public class NationalDrugDictService extends BaseJpaService<BaseNationalDrugDictDO, BaseNationalDrugDictDao> {
    @Autowired
    private BaseNationalDrugDictDao nationalDrugDictDao;
    public BaseNationalDrugDictDO saveNationalDrug(BaseNationalDrugDictDO nationalDrugDictDO) {
        nationalDrugDictDO.setPyName(ConvertToSpellUtils.changeToTonePinYin(nationalDrugDictDO.getName()));
        nationalDrugDictDO.setPyCommonName(ConvertToSpellUtils.changeToTonePinYin(nationalDrugDictDO.getCommonName()));
        //判断新增或编辑
        if (nationalDrugDictDO.getId() == null) {
            nationalDrugDictDO.setCreateTime(new Date());
            nationalDrugDictDO.setStatus(1);
            nationalDrugDictDO.setUpdateTime(new Date());
            return nationalDrugDictDao.save(nationalDrugDictDO);
        }else {
            BaseNationalDrugDictDO oldDurgDictDO =  nationalDrugDictDao.findOne(nationalDrugDictDO.getId());
            BeanUtils.copyProperties(nationalDrugDictDO, oldDurgDictDO, getNullPropertyNames(nationalDrugDictDO));
            oldDurgDictDO.setUpdateTime(new Date());
            return nationalDrugDictDao.save(oldDurgDictDO);
        }
    }
    /**
     * 获取药品列表
     *
     * @param name
     * @param number
     * @param hospital
     * @param status
     * @param page
     * @param pageSize
     * @return
     * @throws ParseException
     */
    public MixEnvelop getNationalDrugList(String name, String number, String hospital, Integer status, Integer page, Integer pageSize) throws ParseException {
        MixEnvelop mixEnvelop = new MixEnvelop();
        String filters = "";
        if (StringUtils.isNotBlank(name)) {
            filters += "name?" + name + ";";
        }
        if (StringUtils.isNotBlank(number)) {
            filters += "number?" + number + ";";
        }
        if (StringUtils.isNotBlank(hospital)) {
            filters += "hospital=" + hospital + ";";
        }
        if (status != null) {
            filters += "status=" + status + ";";
        }
        Integer count = this.search(null, filters, null).size();
        List<BaseNationalDrugDictDO> list = this.search(null, filters, null, page, pageSize);
        mixEnvelop.setMessage("获取成功!");
        mixEnvelop.setCurrPage(page);
        mixEnvelop.setPageSize(pageSize);
        mixEnvelop.setTotalCount(count);
        mixEnvelop.setDetailModelList(list);
        return mixEnvelop;
    }
    public void updateNationalDrugStatus(Integer id, Integer status) {
         nationalDrugDictDao.updateStatusById(id, status);
    }
}

+ 429 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/prescription/BaseNationalDrugDictDO.java

@ -0,0 +1,429 @@
package com.yihu.jw.entity.hospital.prescription;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.util.Date;
@Entity
@Table(name = "base_national_drug_dict")
@SequenceGenerator(name="id_generated", sequenceName="BASE_NATIONAL_DRUG_DICT_SEQ")
public class BaseNationalDrugDictDO extends IntegerIdentityEntity {
    private String number;//国家编码
    private String name;//国家药品通用名
    private String pyName;//国家药品通用名称拼音码
    private String subjectClass;//科目类别id
    private String subjectClassName;//科目类别名称
    private String commonName;//药品通用名
    private String pyCommonName;//药品通用名称拼音码
    private String hospital;//机构id
    private String hospitalName;//机构名称
    private String relationCode;//国家药品编码saasId(机构药品时该字段才有值)
    private String gyzz;//国药准字
    private String unit;//包装单位
    private String packingSpecifications;//包装规格
    private Integer isSplit;//是否可拆(1是 0否)
    private String drugSpecifications;//药品规格
    private String dosageForm;//剂型
    private String drugCode;//药品类别
    private String drugName;//药品类别名称
    private String minDose;//最小剂量
    private String doseUnit;//剂量单位
    private String doseUnitName;//剂量单位名称
    private String manageClass;//管理类别id
    private BigDecimal retailPrice;//零售价格
    private String medicareSpecifications;//医保规格
    private String medicareUnit;//医保单位
    private String toxicology;//毒理分类
    private String toxicology_name;//毒理分类名称
    private String prescription;//处方用药
    private String gmp;//gmp药品
    private String antimicrobial;//抗菌药分类id
    private String antimicrobialName;//抗菌药分类名称
    private String supplier;//供应商
    private String manufacturer;//厂商
    private String remark;//备注
    private String volumeUnit;//体积单位
    private String weightUnit;//重量单位
    private String drugDose;//用药剂量
    private Integer amount;//用药总量
    private String amountUnit;//总量单位
    private String amountUnitName;//总量单位名称
    private Integer days;//用药天数
    private String frenquency;//用药频次
    private String method;//用药方法
    private Integer status;//状态(1生效 0失效)
    private Date createTime;//创建时间
    private Date updateTime;//更新时间
    public String getNumber() {
        return number;
    }
    public void setNumber(String number) {
        this.number = number;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getPyName() {
        return pyName;
    }
    public void setPyName(String pyName) {
        this.pyName = pyName;
    }
    public String getSubjectClass() {
        return subjectClass;
    }
    public void setSubjectClass(String subjectClass) {
        this.subjectClass = subjectClass;
    }
    public String getSubjectClassName() {
        return subjectClassName;
    }
    public void setSubjectClassName(String subjectClassName) {
        this.subjectClassName = subjectClassName;
    }
    public String getCommonName() {
        return commonName;
    }
    public void setCommonName(String commonName) {
        this.commonName = commonName;
    }
    public String getPyCommonName() {
        return pyCommonName;
    }
    public void setPyCommonName(String pyCommonName) {
        this.pyCommonName = pyCommonName;
    }
    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 getRelationCode() {
        return relationCode;
    }
    public void setRelationCode(String relationCode) {
        this.relationCode = relationCode;
    }
    public String getGyzz() {
        return gyzz;
    }
    public void setGyzz(String gyzz) {
        this.gyzz = gyzz;
    }
    public String getUnit() {
        return unit;
    }
    public void setUnit(String unit) {
        this.unit = unit;
    }
    public String getPackingSpecifications() {
        return packingSpecifications;
    }
    public void setPackingSpecifications(String packingSpecifications) {
        this.packingSpecifications = packingSpecifications;
    }
    public Integer getIsSplit() {
        return isSplit;
    }
    public void setIsSplit(Integer isSplit) {
        this.isSplit = isSplit;
    }
    public String getDrugSpecifications() {
        return drugSpecifications;
    }
    public void setDrugSpecifications(String drugSpecifications) {
        this.drugSpecifications = drugSpecifications;
    }
    public String getDosageForm() {
        return dosageForm;
    }
    public void setDosageForm(String dosageForm) {
        this.dosageForm = dosageForm;
    }
    public String getDrugCode() {
        return drugCode;
    }
    public void setDrugCode(String drugCode) {
        this.drugCode = drugCode;
    }
    public String getDrugName() {
        return drugName;
    }
    public void setDrugName(String drugName) {
        this.drugName = drugName;
    }
    public String getMinDose() {
        return minDose;
    }
    public void setMinDose(String minDose) {
        this.minDose = minDose;
    }
    public String getDoseUnit() {
        return doseUnit;
    }
    public void setDoseUnit(String doseUnit) {
        this.doseUnit = doseUnit;
    }
    public String getDoseUnitName() {
        return doseUnitName;
    }
    public void setDoseUnitName(String doseUnitName) {
        this.doseUnitName = doseUnitName;
    }
    public String getManageClass() {
        return manageClass;
    }
    public void setManageClass(String manageClass) {
        this.manageClass = manageClass;
    }
    public BigDecimal getRetailPrice() {
        return retailPrice;
    }
    public void setRetailPrice(BigDecimal retailPrice) {
        this.retailPrice = retailPrice;
    }
    public String getMedicareSpecifications() {
        return medicareSpecifications;
    }
    public void setMedicareSpecifications(String medicareSpecifications) {
        this.medicareSpecifications = medicareSpecifications;
    }
    public String getMedicareUnit() {
        return medicareUnit;
    }
    public void setMedicareUnit(String medicareUnit) {
        this.medicareUnit = medicareUnit;
    }
    public String getToxicology() {
        return toxicology;
    }
    public void setToxicology(String toxicology) {
        this.toxicology = toxicology;
    }
    public String getToxicology_name() {
        return toxicology_name;
    }
    public void setToxicology_name(String toxicology_name) {
        this.toxicology_name = toxicology_name;
    }
    public String getPrescription() {
        return prescription;
    }
    public void setPrescription(String prescription) {
        this.prescription = prescription;
    }
    public String getGmp() {
        return gmp;
    }
    public void setGmp(String gmp) {
        this.gmp = gmp;
    }
    public String getAntimicrobial() {
        return antimicrobial;
    }
    public void setAntimicrobial(String antimicrobial) {
        this.antimicrobial = antimicrobial;
    }
    public String getAntimicrobialName() {
        return antimicrobialName;
    }
    public void setAntimicrobialName(String antimicrobialName) {
        this.antimicrobialName = antimicrobialName;
    }
    public String getSupplier() {
        return supplier;
    }
    public void setSupplier(String supplier) {
        this.supplier = supplier;
    }
    public String getManufacturer() {
        return manufacturer;
    }
    public void setManufacturer(String manufacturer) {
        this.manufacturer = manufacturer;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public String getVolumeUnit() {
        return volumeUnit;
    }
    public void setVolumeUnit(String volumeUnit) {
        this.volumeUnit = volumeUnit;
    }
    public String getWeightUnit() {
        return weightUnit;
    }
    public void setWeightUnit(String weightUnit) {
        this.weightUnit = weightUnit;
    }
    public String getDrugDose() {
        return drugDose;
    }
    public void setDrugDose(String drugDose) {
        this.drugDose = drugDose;
    }
    public Integer getAmount() {
        return amount;
    }
    public void setAmount(Integer amount) {
        this.amount = amount;
    }
    public String getAmountUnit() {
        return amountUnit;
    }
    public void setAmountUnit(String amountUnit) {
        this.amountUnit = amountUnit;
    }
    public String getAmountUnitName() {
        return amountUnitName;
    }
    public void setAmountUnitName(String amountUnitName) {
        this.amountUnitName = amountUnitName;
    }
    public Integer getDays() {
        return days;
    }
    public void setDays(Integer days) {
        this.days = days;
    }
    public String getFrenquency() {
        return frenquency;
    }
    public void setFrenquency(String frenquency) {
        this.frenquency = frenquency;
    }
    public String getMethod() {
        return method;
    }
    public void setMethod(String method) {
        this.method = method;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}

+ 3 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -548,6 +548,9 @@ public class BaseHospitalRequestMapping {
        public static final String appletSign= "/appletSign";
        public static final String doorServiceTest= "/doorServiceTest";
        public static final String saveNationalDrug = "/saveNationalDrug";//保存药品字典
        public static final String getNationalDrugList = "/getNationalDrugList";//获取药品字典
        public static final String updateNationalDrugStatus = "/updateNationalDrugStatus";//更新药品字典状态
    }
    public static class YkyyPrescription extends BaseHospitalRequestMapping.Basic {

+ 70 - 0
common/common-util/src/main/java/com/yihu/jw/util/common/PingyinUtils.java

@ -0,0 +1,70 @@
package com.yihu.jw.util.common;
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
/**
 * create by hmf on 2021/2/8
 */
public class PingyinUtils {
    /**
     * 汉字转换为汉语拼音首字母,英文字符不变
     * @param chines 汉字
     * @return 拼音
     */
    public static String converterToFirstSpell(String chines){
        String pinyinName = "";
        //转化为字符
        char[] nameChar = chines.toCharArray();
        //汉语拼音格式输出类
        HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
        //输出设置,大小写,音标方式等
        defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
        defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
        for (int i = 0; i < nameChar.length; i++) {
            //如果是中文
            if (nameChar[i] > 128) {
                try {
                    pinyinName +=
                            PinyinHelper.toHanyuPinyinStringArray(nameChar[i], defaultFormat)[0].charAt(0);
                } catch (BadHanyuPinyinOutputFormatCombination e) {
                    e.printStackTrace();
                }
            }else{//为英文字符
                pinyinName += nameChar[i];
            }
        }
        return pinyinName;
    }
    /**
     * 汉字转换位汉语拼音,英文字符不变
     * @param chines 汉字
     * @return 拼音
     */
    public static String converterToSpell(String chines){
        String pinyinName = "";
        char[] nameChar = chines.toCharArray();
        HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
        defaultFormat.setCaseType(HanyuPinyinCaseType.UPPERCASE);
        defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
        for (int i = 0; i < nameChar.length; i++) {
            if (nameChar[i] > 128) {
                try {
                    pinyinName += PinyinHelper.toHanyuPinyinStringArray(nameChar[i], defaultFormat)[0];
                } catch (BadHanyuPinyinOutputFormatCombination e) {
                    e.printStackTrace();
                }
            }else{
                pinyinName += nameChar[i];
            }
        }
        return pinyinName;
    }
}

+ 62 - 0
svr/svr-internet-hospital/src/main/java/com/yihu/jw/hospital/endpoint/prescription/NationalDrugDictEndpoint.java

@ -0,0 +1,62 @@
package com.yihu.jw.hospital.endpoint.prescription;
import com.yihu.jw.entity.hospital.prescription.BaseNationalDrugDictDO;
import com.yihu.jw.hospital.prescription.service.NationalDrugDictService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping(value = BaseHospitalRequestMapping.Prescription.PREFIX)
@Api(value = "药品字段维护", description = "药品字段维护", tags = {"药品字段维护"})
public class NationalDrugDictEndpoint extends EnvelopRestEndpoint {
    private static final Logger logger = LoggerFactory.getLogger(NationalDrugDictEndpoint.class);
    @Autowired
    private NationalDrugDictService nationalDrugDictService;
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.saveNationalDrug)
    @ApiOperation(value = "保存药品字典接口")
    public ObjEnvelop saveNationalDrug(@ApiParam(name = "jsonData", value = "药品json串")
                                       @RequestParam(name = "jsonData", required = true) String jsonData) throws Exception {
        BaseNationalDrugDictDO nationalDrugDictDO = objectMapper.readValue(jsonData, BaseNationalDrugDictDO.class);
        return success(nationalDrugDictService.saveNationalDrug(nationalDrugDictDO));
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.getNationalDrugList)
    @ApiOperation(value = "获取药品字典接口")
    public MixEnvelop getNationalDrugList(@ApiParam(name = "name", value = "药品名称")
                                          @RequestParam(name = "name", required = false) String name,
                                          @ApiParam(name = "number", value = "药品编码")
                                          @RequestParam(name = "number", required = false) String number,
                                          @ApiParam(name = "hospital", value = "所属机构")
                                          @RequestParam(name = "hospital", required = false) String hospital,
                                          @ApiParam(name = "status", value = "状态")
                                          @RequestParam(name = "status", required = false) Integer status,
                                          @ApiParam(name = "page", value = "当前页")
                                          @RequestParam(name = "page", required = false) Integer page,
                                          @ApiParam(name = "pageSize", value = "页面大小")
                                          @RequestParam(name = "pageSize", required = false) Integer pageSize) throws Exception {
        return nationalDrugDictService.getNationalDrugList(name, number, hospital, status, page, pageSize);
    }
    @PostMapping(value = BaseHospitalRequestMapping.Prescription.updateNationalDrugStatus)
    @ApiOperation(value = "更新药品字典状态")
    public Envelop updateNationalDrugStatus(@ApiParam(name = "id", value = "药品id")
                                       @RequestParam(name = "id", required = true) Integer id,
                                            @ApiParam(name = "status", value = "状态")
                                               @RequestParam(name = "status", required = false) Integer status){
        nationalDrugDictService.updateNationalDrugStatus(id,status);
        return success();
    }
}