微信后端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

136 lines
6.3 KiB

package com.ynxbd.common.action.xk;
import com.alibaba.fastjson.JSONObject;
import com.ynxbd.common.action.base.BaseAction;
import com.ynxbd.common.bean.his.HisTreat;
import com.ynxbd.common.config.interceptor.AesDecode;
import com.ynxbd.common.dao.his.HisTreatDao;
import com.ynxbd.common.dao.his.HisXKDao;
import com.ynxbd.common.result.JsonResult;
import com.ynxbd.common.result.Result;
import com.ynxbd.common.result.ResultEnum;
import com.ynxbd.wx.wxfactory.AesWxHelper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Namespace("/xk")
public class XKAction extends BaseAction {
@Action("getRxDict")
public Result getRxDict(String callNo, String type, String key, String yfCode) {
if (!"xbd2026".equals(callNo)) {
return Result.error(ResultEnum.PARAM_IS_INVALID);
}
log.info("[开方]字典查询 type={}, yfCode={}", type, yfCode);
if (type == null) {
return Result.error(ResultEnum.PARAM_IS_DEFECT);
}
List<?> dataList = new HisXKDao().queryHisRxDict(type, key, yfCode);
return Result.success(dataList);
}
@Action("createHisRx")
public Result createHisRx() {
try {
JSONObject body = getBody();
if (body == null) {
return Result.error(ResultEnum.PARAM_IS_DEFECT);
}
String doctCode = body.getString("doctCode");
String treatNum = body.getString("treatNum");
String rxDrugType = body.getString("rxDrugType"); // 处方药品类型
String rxTypeCode = body.getString("rxTypeCode");
String rxDiagnose = body.getString("rxDiagnose");
String weight = body.getString("weight");
String note = body.getString("note");
String ybAttrib = body.getString("ybAttrib");
String bzCode = body.getString("bzCode");
String bzName = body.getString("bzName");
String items = body.getString("items");
// 中药=============================================
String tcmTtName = body.getString("tcmTtName");
String tcmUseName = body.getString("tcmUseName");
String tcmCFCount = body.getString("tcmCFCount");
String tcmCFUseCount = body.getString("tcmCFUseCount");
String tcmUseCountForDay = body.getString("tcmUseCountForDay");
log.info("[处方开立]doctCode={}, treatNum={}, rxDrugType={}, weight={}, items={}", doctCode, treatNum, rxDrugType, weight, items);
if (ObjectUtils.isEmpty(doctCode) || ObjectUtils.isEmpty(treatNum) || ObjectUtils.isEmpty(rxDrugType) || ObjectUtils.isEmpty(weight) || ObjectUtils.isEmpty(items)) {
return Result.error(ResultEnum.PARAM_IS_DEFECT);
}
JsonResult resp = new HisXKDao().createHisRx(items, doctCode, treatNum, rxDrugType, rxTypeCode, rxDiagnose, weight, note, ybAttrib, bzCode, bzName,
tcmTtName, tcmUseName, tcmCFCount, tcmCFUseCount, tcmUseCountForDay);
if (!resp.success()) {
return Result.error(resp.getMessage());
}
String rxCode = resp.getDataMapString("CFNum");
String amount = resp.getDataMapString("Amount");
if (ObjectUtils.isEmpty(rxCode) || ObjectUtils.isEmpty(amount)) {
return Result.error("处方开立未返回处方号或金额");
}
Map<String, Object> data = new HashMap<>();
data.put("rxCode", rxCode);
data.put("enRxCode", AesWxHelper.encode(rxCode));
data.put("enAmount", AesWxHelper.encode(amount));
return Result.success(data);
} catch (Exception e) {
return Result.error(e);
}
}
@Action("updateHisTreat")
public Result updateHisTreat(@AesDecode String openId, @AesDecode String treatNum, String symptom, String subjComplaint, String disDescription, String treatMeas,
String tcmDdCode, String tcmDdName, String tcmSdCode, String tcmSdName, String mdDisCode, String mdDisName,
String pastHist, String presentHist, String alleHist, String disCode1, String disName1, String disCode2, String disName2) {
try {
log.info("[HIS更新就诊记录] openId={}, treatNum={}, symptom={}, subjComplaint={}, disDescription={}, treatMeas={}, tcmDdCode={}, tcmDdName={}, tcmSdCode={}, tcmSdName={}, mdDisCode={}, mdDisName={}",
openId, treatNum, symptom, subjComplaint, disDescription, treatMeas, tcmDdCode, tcmDdName, tcmSdCode, tcmSdName, mdDisCode, mdDisName);
if (ObjectUtils.isEmpty(openId) || ObjectUtils.isEmpty(treatNum)) {
return Result.error(ResultEnum.PARAM_IS_INVALID);
}
if (ObjectUtils.isEmpty(subjComplaint) || ObjectUtils.isEmpty(disDescription) || ObjectUtils.isEmpty(treatMeas)) {
return Result.error(ResultEnum.PARAM_IS_DEFECT);
}
if (ObjectUtils.isEmpty(tcmDdCode) && ObjectUtils.isEmpty(mdDisCode)) {
return Result.error("请选择中医或西医诊断");
}
if (!ObjectUtils.isEmpty(tcmDdCode)) {
if (ObjectUtils.isEmpty(tcmSdName)) {
return Result.error("中医诊断名称[tcmSdName]缺失");
}
if (ObjectUtils.isEmpty(tcmSdCode) || ObjectUtils.isEmpty(tcmSdName)) {
return Result.error("中医证侯诊断[tcmSdCode]缺失");
}
}
if (!ObjectUtils.isEmpty(mdDisCode) && ObjectUtils.isEmpty(mdDisName)) {
return Result.error("西医诊断名称[mdDisName]缺失");
}
HisTreat data = new HisTreatDao().updateHisTreat(treatNum, symptom, subjComplaint, disDescription, treatMeas, tcmDdCode, tcmDdName, tcmSdCode, tcmSdName, mdDisCode, mdDisName, pastHist, presentHist, alleHist, disCode1, disName1, disCode2, disName2);
if (data == null) {
return Result.error();
}
return Result.success(data);
} catch (Exception e) {
return Result.error(e);
}
}
}