|
@@ -6,31 +6,39 @@ import java.math.RoundingMode;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
-import java.util.logging.Logger;
|
|
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fs.common.BeanCopyUtils;
|
|
import com.fs.common.BeanCopyUtils;
|
|
|
-import com.fs.common.annotation.Log;
|
|
|
|
|
import com.fs.common.utils.DateUtils;
|
|
import com.fs.common.utils.DateUtils;
|
|
|
|
|
+import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.his.config.FsSysConfig;
|
|
import com.fs.his.config.FsSysConfig;
|
|
|
import com.fs.his.domain.*;
|
|
import com.fs.his.domain.*;
|
|
|
import com.fs.his.dto.FsPrescribeUsageDTO;
|
|
import com.fs.his.dto.FsPrescribeUsageDTO;
|
|
|
import com.fs.his.dto.FsStoreOrderItemDTO;
|
|
import com.fs.his.dto.FsStoreOrderItemDTO;
|
|
|
|
|
+import com.fs.his.enums.hsyy.AdministrationRoute;
|
|
|
|
|
+import com.fs.his.enums.hsyy.EducationLevel;
|
|
|
|
|
+import com.fs.his.enums.hsyy.Gender;
|
|
|
|
|
+import com.fs.his.enums.hsyy.ProfessionalTitle;
|
|
|
import com.fs.his.mapper.*;
|
|
import com.fs.his.mapper.*;
|
|
|
import com.fs.his.param.FsStoreOrderParam;
|
|
import com.fs.his.param.FsStoreOrderParam;
|
|
|
import com.fs.his.param.FsSubOrderDrugListParam;
|
|
import com.fs.his.param.FsSubOrderDrugListParam;
|
|
|
|
|
+import com.fs.his.param.FsSubOrderHsyyParam;
|
|
|
import com.fs.his.param.FsSubOrderParam;
|
|
import com.fs.his.param.FsSubOrderParam;
|
|
|
import com.fs.his.utils.ConfigUtil;
|
|
import com.fs.his.utils.ConfigUtil;
|
|
|
|
|
+import com.fs.his.utils.HsyyPushApiClientUtil;
|
|
|
|
|
+import com.fs.his.utils.PhoneUtil;
|
|
|
import com.fs.his.vo.FsStoreProductAttrVO;
|
|
import com.fs.his.vo.FsStoreProductAttrVO;
|
|
|
import com.fs.his.vo.FsStoreSubOrderListVO;
|
|
import com.fs.his.vo.FsStoreSubOrderListVO;
|
|
|
import com.fs.his.vo.FsStoreSubOrderVO;
|
|
import com.fs.his.vo.FsStoreSubOrderVO;
|
|
|
import com.fs.his.vo.FsSubOrderResultVO;
|
|
import com.fs.his.vo.FsSubOrderResultVO;
|
|
|
-import com.qcloud.cos.transfer.Copy;
|
|
|
|
|
import org.apache.http.HttpEntity;
|
|
import org.apache.http.HttpEntity;
|
|
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
|
import org.apache.http.util.EntityUtils;
|
|
import org.apache.http.util.EntityUtils;
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -69,7 +77,13 @@ public class FsStoreSubOrderServiceImpl implements IFsStoreSubOrderService
|
|
|
FsStoreProductMapper fsStoreProductMapper;
|
|
FsStoreProductMapper fsStoreProductMapper;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
ConfigUtil configUtil;
|
|
ConfigUtil configUtil;
|
|
|
- org.slf4j.Logger logger= LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
|
+ Logger logger= LoggerFactory.getLogger(getClass());
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FsDepartmentMapper fsDepartmentMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FsInquiryOrderMapper fsInquiryOrderMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FsHospitalMapper fsHospitalMapper;
|
|
|
/**
|
|
/**
|
|
|
* 查询订单
|
|
* 查询订单
|
|
|
*
|
|
*
|
|
@@ -649,4 +663,407 @@ public class FsStoreSubOrderServiceImpl implements IFsStoreSubOrderService
|
|
|
return fsStoreSubOrderMapper.selectFsStoreSubOrderListCount(fsStoreSubOrder);
|
|
return fsStoreSubOrderMapper.selectFsStoreSubOrderListCount(fsStoreSubOrder);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<FsStoreSubOrder> selectFsStoreSubOrderListByCreateTime(String yesterdayStartStr, String todayStartStr) {
|
|
|
|
|
+ return fsStoreSubOrderMapper.selectFsStoreSubOrderListByCreateTime(yesterdayStartStr, todayStartStr);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 推送河山医院数据
|
|
|
|
|
+ * @param list 订单列表
|
|
|
|
|
+ */
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void pushHsyy(List<FsStoreSubOrder> list) {
|
|
|
|
|
+ SimpleDateFormat ymd = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
+ SimpleDateFormat ymdhms = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
+ HsyyPushApiClientUtil hsyyPushApiClientUtil = new HsyyPushApiClientUtil();
|
|
|
|
|
+
|
|
|
|
|
+ for (FsStoreSubOrder order : list) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ FsSubOrderHsyyParam param = processSingleOrder(order, ymd, ymdhms);
|
|
|
|
|
+ if (param == null) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ String result = hsyyPushApiClientUtil.callApi(param);
|
|
|
|
|
+ handleApiResponse(order, result, param);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ logger.error("处理订单推送异常,订单ID: {}", order.getSubOrderId(), e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 处理API响应
|
|
|
|
|
+ */
|
|
|
|
|
+ private void handleApiResponse(FsStoreSubOrder order, String result,FsSubOrderHsyyParam param) {
|
|
|
|
|
+ if (StringUtils.isEmpty(result)) {
|
|
|
|
|
+ logger.warn("订单 {} 推送返回结果为空", order.getSubOrderId());
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ result = JSON.parseObject(result, String.class);
|
|
|
|
|
+ // 解析响应结果
|
|
|
|
|
+ logger.info("订单 {} 推送响应: {}", order.getSubOrderId(), result);
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
|
|
+ Integer code = jsonObject.getInteger("code");
|
|
|
|
|
+ if (code != null && code == 0) {
|
|
|
|
|
+ logger.info("订单 {} 推送成功", order.getSubOrderId());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ String errorMsg = jsonObject.getString("msg");
|
|
|
|
|
+ logger.warn("订单 {} 推送失败: {},推送数据: {}",
|
|
|
|
|
+ order.getSubOrderId(),
|
|
|
|
|
+ errorMsg,
|
|
|
|
|
+ JSONObject.toJSONString(param));
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ logger.error("解析订单 {} 推送响应异常: {}", order.getSubOrderId(), e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ private FsSubOrderHsyyParam processSingleOrder(FsStoreSubOrder order, SimpleDateFormat ymd, SimpleDateFormat ymdhms) {
|
|
|
|
|
+ // 验证订单必要数据
|
|
|
|
|
+ HsyyValidationResult hsyyValidationResult = validateOrderData(order);
|
|
|
|
|
+ if (!hsyyValidationResult.isValid()) {
|
|
|
|
|
+ logger.warn("订单 {} 验证失败: {}", order.getSubOrderId(), hsyyValidationResult.getMessage());
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 构建参数对象
|
|
|
|
|
+ return buildHsyyParam(order, hsyyValidationResult, ymd, ymdhms);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 构建河山医院参数对象
|
|
|
|
|
+ */
|
|
|
|
|
+ private FsSubOrderHsyyParam buildHsyyParam(FsStoreSubOrder order, HsyyValidationResult validation,SimpleDateFormat ymd, SimpleDateFormat ymdhms) {
|
|
|
|
|
+ FsSubOrderHsyyParam param = new FsSubOrderHsyyParam();
|
|
|
|
|
+ param.setOrderNo(order.getSubOrderId() + "");
|
|
|
|
|
+
|
|
|
|
|
+ // 设置各个部分的数据
|
|
|
|
|
+ param.setUserinfo(buildUserinfo(order, validation.getPatient(), ymd, ymdhms));
|
|
|
|
|
+ param.setDepartment(buildDepartment(validation.getDepartment()));
|
|
|
|
|
+ param.setDoctor(buildDoctor(validation.getDoctor(), ymd));
|
|
|
|
|
+ param.setMedicine(buildMedicines(order, validation.getPrescribeDrugs(),
|
|
|
|
|
+ validation.getStore().getStoreId() + "", validation.getStore().getStoreName()));
|
|
|
|
|
+ param.setOffline(buildOffline(ymd, validation.getDoctor(), validation.getDepartment(),
|
|
|
|
|
+ order.getSubOrderId() + "", validation.getInquiryOrder()));
|
|
|
|
|
+ param.setRecipe(buildRecipe(ymdhms, validation.getDoctor(), validation.getDepartment(),
|
|
|
|
|
+ order.getSubOrderId(), validation.getPrescribe(),
|
|
|
|
|
+ validation.getStore().getStoreName(), validation.getHospital().getHospitalName()));
|
|
|
|
|
+ param.setSign(buildSigns(order, ymdhms, validation.getDoctor(), validation.getDrugDoctor()));
|
|
|
|
|
+
|
|
|
|
|
+ return param;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private FsSubOrderHsyyParam.UserinfoType buildUserinfo(FsStoreSubOrder order,FsPatient patient, SimpleDateFormat ymd,SimpleDateFormat ymdhms) {
|
|
|
|
|
+ return FsSubOrderHsyyParam.UserinfoType.builder()
|
|
|
|
|
+ .name(StringUtils.isNotEmpty(order.getPatientName())?order.getPatientName():"无")
|
|
|
|
|
+ .numcard(StringUtils.isNotEmpty(patient.getIdCard())?patient.getIdCard():"无")
|
|
|
|
|
+ .birthday(patient.getBirthday() != null ? ymd.format(patient.getBirthday()) : "无")
|
|
|
|
|
+ .sex(patient.getSex() == 1 ? Gender.MALE.getCode() + "" : Gender.FEMALE.getCode() + "")
|
|
|
|
|
+ .datetime(patient.getBirthday() != null ? ymd.format(patient.getBirthday()) : "")
|
|
|
|
|
+ .age(patient.getAge())
|
|
|
|
|
+ .tel(StringUtils.isNotEmpty(patient.getMobile()) ? PhoneUtil.decryptPhone(patient.getMobile()) : "无")
|
|
|
|
|
+ .present_illness_history("无")
|
|
|
|
|
+ .past_history("无")
|
|
|
|
|
+ .personal_history(StringUtils.isNotEmpty(patient.getSelfMedHistory())?patient.getSelfMedHistory():"无")
|
|
|
|
|
+ .family_history(StringUtils.isNotEmpty(patient.getFamilyMedHistory())?patient.getFamilyMedHistory():"无")
|
|
|
|
|
+ .allergy(StringUtils.isNotEmpty(patient.getHistoryAllergic())?patient.getHistoryAllergic():"无")
|
|
|
|
|
+ .tijian("无")
|
|
|
|
|
+ .usertime(patient.getCreateTime() != null ? ymdhms.format(patient.getCreateTime()):"")
|
|
|
|
|
+ .build();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private FsSubOrderHsyyParam.DepartmentType buildDepartment(FsDepartment department) {
|
|
|
|
|
+ return FsSubOrderHsyyParam.DepartmentType.builder()
|
|
|
|
|
+ .dep_name(StringUtils.isNotEmpty(department.getDeptName())?department.getDeptName():"无")
|
|
|
|
|
+ .dep_id(department.getDeptId() != null ? Integer.parseInt(department.getDeptId() + "") : 0)
|
|
|
|
|
+ .dep_code(StringUtils.isNotEmpty(department.getDeptCode())?department.getDeptCode():"0")
|
|
|
|
|
+ .build();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private FsSubOrderHsyyParam.DoctorType buildDoctor(FsDoctor doctor,SimpleDateFormat ymd) {
|
|
|
|
|
+ return FsSubOrderHsyyParam.DoctorType.builder()
|
|
|
|
|
+ .doc_name(StringUtils.isNotEmpty(doctor.getDoctorName())?doctor.getDoctorName():"无")
|
|
|
|
|
+ .doc_numcard(StringUtils.isNotEmpty(doctor.getIdCard())?doctor.getIdCard():"无")
|
|
|
|
|
+ .doc_sex(doctor.getSex() == 1 ? Gender.MALE.getCode() :
|
|
|
|
|
+ Gender.FEMALE.getCode())
|
|
|
|
|
+ .doc_tel(StringUtils.isNotEmpty(doctor.getMobile()) ?
|
|
|
|
|
+ doctor.getMobile() : "无")
|
|
|
|
|
+ .doc_zhicheng(StringUtils.isNotEmpty(doctor.getPosition()) ?
|
|
|
|
|
+ ProfessionalTitle.getCodeByDescription(doctor.getPosition()) + "" : ProfessionalTitle.PHYSICIAN.getCode() +"")
|
|
|
|
|
+ .doc_code(doctor.getDoctorId() != null ?doctor.getDoctorId() + "" : "0")
|
|
|
|
|
+ .doc_type(doctor.getDoctorType() != null ?
|
|
|
|
|
+ (doctor.getDoctorType() == 1 ? "1" : "3") : "1")
|
|
|
|
|
+ .doc_license_no(StringUtils.isNotEmpty(doctor.getCertificateCode())?doctor.getCertificateCode():"")
|
|
|
|
|
+ //--------虚拟数据堆begin------------
|
|
|
|
|
+ .doc_rank("高级")
|
|
|
|
|
+ .doc_license_date(doctor.getCreateTime() != null ? ymd.format(doctor.getCreateTime()) : "")
|
|
|
|
|
+ .doc_practice_no("")
|
|
|
|
|
+ .doc_practice_address("")
|
|
|
|
|
+ .doc_practice_category("")
|
|
|
|
|
+ .doc_practice_scope("")
|
|
|
|
|
+ .doc_first_date(doctor.getCreateTime() != null ? ymd.format(doctor.getCreateTime()) : "")
|
|
|
|
|
+ .doc_current_date(doctor.getCreateTime() != null ? ymd.format(doctor.getCreateTime()) : "")
|
|
|
|
|
+ .doc_valid_date("2099-01-01")
|
|
|
|
|
+ .doc_politics_status("1")
|
|
|
|
|
+ .doc_starting_work_date(doctor.getCreateTime() != null ? ymd.format(doctor.getCreateTime()) : "")
|
|
|
|
|
+ .doc_independent_work_date(doctor.getCreateTime() != null ? ymd.format(doctor.getCreateTime()) : "")
|
|
|
|
|
+ .doc_fullTime_degree(EducationLevel.BACHELOR.getCode() + "")
|
|
|
|
|
+ .doc_full_time_degree_year("2099")
|
|
|
|
|
+ //--------虚拟数据堆end------------
|
|
|
|
|
+ .build();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private List<FsSubOrderHsyyParam.MedicineType> buildMedicines(FsStoreSubOrder order,List<FsPrescribeDrug> prescribeDrugs,String storeId,String storeName) {
|
|
|
|
|
+ List<FsSubOrderHsyyParam.MedicineType> medicines = new ArrayList<>();
|
|
|
|
|
+ for (FsPrescribeDrug drug : prescribeDrugs) {
|
|
|
|
|
+ medicines.add(FsSubOrderHsyyParam.MedicineType.builder()
|
|
|
|
|
+ .bm(drug.getProductId() != null?drug.getProductId() + "":"XA10BAE021A010011401021")
|
|
|
|
|
+ .store_id(storeId)
|
|
|
|
|
+ .store_name(storeName)
|
|
|
|
|
+ .sname(StringUtils.isNotEmpty(drug.getDrugName()) ? drug.getDrugName() : "")
|
|
|
|
|
+ .tname(StringUtils.isNotEmpty(drug.getDrugName())?drug.getDrugName():"")
|
|
|
|
|
+ .price(drug.getDrugPrice() != null ? drug.getDrugPrice().multiply(BigDecimal.valueOf(100)).intValue()+"" : "0")
|
|
|
|
|
+ .guige(StringUtils.isNotEmpty(drug.getDrugSpec())?drug.getDrugSpec():"无")
|
|
|
|
|
+ .use(StringUtils.isNotEmpty(drug.getUsageMethod())?drug.getUsageMethod():"无")
|
|
|
|
|
+ .dosage(StringUtils.isNotEmpty(drug.getUsagePerUseCount())?drug.getUsagePerUseCount():"1")
|
|
|
|
|
+ .frequency(StringUtils.isNotEmpty(drug.getUsageFrequencyUnit())?drug.getUsageFrequencyUnit():"无")
|
|
|
|
|
+ .unit(StringUtils.isNotEmpty(drug.getUsagePerUseUnit())?drug.getUsagePerUseUnit():"盒")
|
|
|
|
|
+ .count(drug.getDrugNum() != null ? Integer.parseInt(drug.getDrugNum()+""): 0)
|
|
|
|
|
+ .amount(order.getPayMoney() != null ?order.getPayMoney().multiply(BigDecimal.valueOf(100)).intValue() : 0)
|
|
|
|
|
+ //--------虚拟数据堆begin------------
|
|
|
|
|
+ .doc_num("国药准字H20050349")
|
|
|
|
|
+ .component("")
|
|
|
|
|
+ .character("")
|
|
|
|
|
+ .adapt("")
|
|
|
|
|
+ .adverse_reactions("")
|
|
|
|
|
+ .dosageform("10")
|
|
|
|
|
+ .package_spec(StringUtils.isNotEmpty(drug.getDrugSpec())?drug.getDrugSpec():"")
|
|
|
|
|
+ .health_care_code("XA10BAE021A010011401021")
|
|
|
|
|
+ .health_care_type("1")
|
|
|
|
|
+ .is_base("0")
|
|
|
|
|
+ .manufacturer("重庆科瑞南海制药有限责任公司")
|
|
|
|
|
+ .has_prescription("0")
|
|
|
|
|
+ .supplier("重庆科瑞南海制药有限责任公司")
|
|
|
|
|
+ .medication_route(AdministrationRoute.ORAL.getCode() + "")
|
|
|
|
|
+ .getType(3)
|
|
|
|
|
+ .checker_name("")
|
|
|
|
|
+ .dispenser_name("")
|
|
|
|
|
+ //--------虚拟数据堆end------------
|
|
|
|
|
+ .build());
|
|
|
|
|
+ }
|
|
|
|
|
+ return medicines;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private FsSubOrderHsyyParam.OfflineType buildOffline(SimpleDateFormat ymd,FsDoctor doctor,FsDepartment dept,String hisId,FsInquiryOrder inquiryOrder) {
|
|
|
|
|
+ String doctorDeptCode = doctor.getDoctorId() + "";
|
|
|
|
|
+ String doctorDeptName = StringUtils.isNotEmpty(dept.getDeptName())?dept.getDeptName():"";
|
|
|
|
|
+ String doctorCode = StringUtils.isNotEmpty(dept.getDeptCode())?dept.getDeptCode():"";
|
|
|
|
|
+
|
|
|
|
|
+ return FsSubOrderHsyyParam.OfflineType.builder()
|
|
|
|
|
+ .medical_record_no(hisId)
|
|
|
|
|
+ .visit_no(StringUtils.isNotEmpty(inquiryOrder.getOrderSn())?Long.parseLong(inquiryOrder.getOrderSn()):0L)
|
|
|
|
|
+ .visit_date(inquiryOrder.getCreateTime() != null ?
|
|
|
|
|
+ ymd.format(inquiryOrder.getCreateTime()) : "")
|
|
|
|
|
+ .offline_dept_code(doctorDeptCode)
|
|
|
|
|
+ .offline_dept_name(doctorDeptName)
|
|
|
|
|
+ .offline_doctor_code(doctorCode)
|
|
|
|
|
+ //--------虚拟数据堆begin------------
|
|
|
|
|
+ .offline_diagnosis("高血压")
|
|
|
|
|
+ //--------虚拟数据堆end------------
|
|
|
|
|
+ .build();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private FsSubOrderHsyyParam.RecipeType buildRecipe(SimpleDateFormat ymdhms,FsDoctor doctor,FsDepartment dept,Long hisId,FsPrescribe prescribe,String storeName,String hospitalName) {
|
|
|
|
|
+ List<FsSubOrderHsyyParam.ProcessType> process = new ArrayList<>();
|
|
|
|
|
+ String doctorName = doctor.getDoctorName(), doctorCode = doctor.getDoctorId() + "",
|
|
|
|
|
+ doctorDeptCode = dept.getDeptCode(),doctorDeptName=dept.getDeptName();
|
|
|
|
|
+
|
|
|
|
|
+ process.add(FsSubOrderHsyyParam.ProcessType
|
|
|
|
|
+ .builder()
|
|
|
|
|
+ .process_time(ymdhms.format(prescribe.getCreateTime()))
|
|
|
|
|
+ .role("2")
|
|
|
|
|
+ .content(StringUtils.isNotEmpty(prescribe.getDiagnose())?prescribe.getDiagnose():"无")
|
|
|
|
|
+ .build());
|
|
|
|
|
+ process.add(FsSubOrderHsyyParam.ProcessType
|
|
|
|
|
+ .builder()
|
|
|
|
|
+ .process_time(ymdhms.format(prescribe.getCreateTime()))
|
|
|
|
|
+ .role("1")
|
|
|
|
|
+ .content(StringUtils.isNotEmpty(prescribe.getPatientDescs())?prescribe.getPatientDescs():"无")
|
|
|
|
|
+ .build());
|
|
|
|
|
+
|
|
|
|
|
+ return FsSubOrderHsyyParam.RecipeType.builder()
|
|
|
|
|
+ .recipe_id(hisId)
|
|
|
|
|
+ .serial_no(StringUtils.isNotEmpty(prescribe.getPrescribeCode())?prescribe.getPrescribeCode():"")
|
|
|
|
|
+ .create_time(prescribe.getCreateTime() != null ? ymdhms.format(prescribe.getCreateTime()) : "")
|
|
|
|
|
+ .status("已开方")
|
|
|
|
|
+ .hospital_name(hospitalName)
|
|
|
|
|
+ .dept_code(doctorDeptCode)
|
|
|
|
|
+ .dept_name(doctorDeptName)
|
|
|
|
|
+ .doc_code(doctorCode)
|
|
|
|
|
+ .doc_name(doctorName)
|
|
|
|
|
+ .zhusu(StringUtils.isNotEmpty(prescribe.getPatientDescs())?prescribe.getPatientDescs():"无")
|
|
|
|
|
+ .diagnose(StringUtils.isNotEmpty(prescribe.getDiagnose())? prescribe.getDiagnose() : "无")
|
|
|
|
|
+ .Recipe_img(StringUtils.isNotEmpty(prescribe.getPrescribeImgUrl())?prescribe.getPrescribeImgUrl():"")
|
|
|
|
|
+ .Pharmacy(storeName)
|
|
|
|
|
+ .process(process)
|
|
|
|
|
+ //--------虚拟数据堆begin------------
|
|
|
|
|
+ .Consultationtype("视频")
|
|
|
|
|
+ .Ybtype("230128")
|
|
|
|
|
+ .advice("无")
|
|
|
|
|
+ .yijian("无")
|
|
|
|
|
+ .diagnose_code("M01603")
|
|
|
|
|
+ .recipe_type("1")
|
|
|
|
|
+ .getType(3)
|
|
|
|
|
+ .Patienttype("慢病处方")
|
|
|
|
|
+ //--------虚拟数据堆end------------
|
|
|
|
|
+ .build();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private List<FsSubOrderHsyyParam.SignType> buildSigns(FsStoreSubOrder order, SimpleDateFormat ymdhms, FsDoctor doctor,FsDoctor drugDoctor) {
|
|
|
|
|
+ List<FsSubOrderHsyyParam.SignType> signs = new ArrayList<>();
|
|
|
|
|
+ String doctorName = doctor.getDoctorName();
|
|
|
|
|
+ String doctorCode = doctor.getDoctorId() + "";
|
|
|
|
|
+ signs.add(FsSubOrderHsyyParam.SignType.builder()
|
|
|
|
|
+ .role("处方医生")
|
|
|
|
|
+ .executor(doctorName)
|
|
|
|
|
+ .person_code(doctorCode)
|
|
|
|
|
+ .exe_time(order.getCreateTime() != null ?ymdhms.format(order.getCreateTime()) : "")
|
|
|
|
|
+ .build());
|
|
|
|
|
+ signs.add(FsSubOrderHsyyParam.SignType.builder()
|
|
|
|
|
+ .role("药师")
|
|
|
|
|
+ .executor(drugDoctor.getDoctorName())
|
|
|
|
|
+ .person_code(drugDoctor.getDoctorId() + "")
|
|
|
|
|
+ .exe_time(order.getCreateTime() != null ?ymdhms.format(order.getCreateTime()) : "")
|
|
|
|
|
+ .build());
|
|
|
|
|
+ return signs;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 验证订单数据
|
|
|
|
|
+ */
|
|
|
|
|
+ private HsyyValidationResult validateOrderData(FsStoreSubOrder order) {
|
|
|
|
|
+ HsyyValidationResult result = new HsyyValidationResult();
|
|
|
|
|
+
|
|
|
|
|
+ // 验证患者信息
|
|
|
|
|
+ if (order.getPatientId() == null) {
|
|
|
|
|
+ result.setValid(false);
|
|
|
|
|
+ result.setMessage("缺少患者信息");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ result.setPatient(fsPatientMapper.selectFsPatientByPatientId(order.getPatientId()));
|
|
|
|
|
+ if (result.getPatient() == null) {
|
|
|
|
|
+ result.setValid(false);
|
|
|
|
|
+ result.setMessage("患者信息不存在");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 验证医生信息
|
|
|
|
|
+ if (order.getDoctorId() == null) {
|
|
|
|
|
+ result.setValid(false);
|
|
|
|
|
+ result.setMessage("缺少医生信息");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ result.setDoctor(fsDoctorMapper.selectFsDoctorByDoctorId(order.getDoctorId()));
|
|
|
|
|
+ if (result.getDoctor() == null) {
|
|
|
|
|
+ result.setValid(false);
|
|
|
|
|
+ result.setMessage("医生信息不存在");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 验证科室信息
|
|
|
|
|
+ result.setDepartment(fsDepartmentMapper.selectFsDepartmentByDeptId(result.getDoctor().getDeptId()));
|
|
|
|
|
+ if (result.getDepartment() == null) {
|
|
|
|
|
+ result.setValid(false);
|
|
|
|
|
+ result.setMessage("科室信息不存在");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 验证线下初诊信息
|
|
|
|
|
+ if (order.getInquiryOrderId() == null) {
|
|
|
|
|
+ result.setValid(false);
|
|
|
|
|
+ result.setMessage("缺少线下初诊信息");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ result.setInquiryOrder(fsInquiryOrderMapper.selectFsInquiryOrderByOrderId(order.getInquiryOrderId()));
|
|
|
|
|
+ if (result.getInquiryOrder() == null) {
|
|
|
|
|
+ result.setValid(false);
|
|
|
|
|
+ result.setMessage("线下初诊信息不存在");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 验处方信息
|
|
|
|
|
+ if (StringUtils.isEmpty(order.getPrescribeJson())) {
|
|
|
|
|
+ result.setValid(false);
|
|
|
|
|
+ result.setMessage("缺少处方信息");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ result.setPrescribe(JSON.parseObject(order.getPrescribeJson(), FsPrescribe.class));
|
|
|
|
|
+ if (result.getPrescribe() == null) {
|
|
|
|
|
+ result.setValid(false);
|
|
|
|
|
+ result.setMessage("处方信息解析失败");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 验证药品信息
|
|
|
|
|
+ if (StringUtils.isEmpty(order.getPrescribeDrugJson())) {
|
|
|
|
|
+ result.setValid(false);
|
|
|
|
|
+ result.setMessage("缺少药品信息");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ result.setPrescribeDrugs(JSON.parseArray(order.getPrescribeDrugJson(), FsPrescribeDrug.class));
|
|
|
|
|
+ if (CollectionUtil.isEmpty(result.getPrescribeDrugs())) {
|
|
|
|
|
+ result.setValid(false);
|
|
|
|
|
+ result.setMessage("药品信息解析失败");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 验证医院信息
|
|
|
|
|
+ if (result.getDoctor().getHospitalId() == null) {
|
|
|
|
|
+ result.setValid(false);
|
|
|
|
|
+ result.setMessage("医生缺少医院信息");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ result.setHospital(fsHospitalMapper.selectFsHospitalByHospitalId(result.getDoctor().getHospitalId()));
|
|
|
|
|
+ if (result.getHospital() == null) {
|
|
|
|
|
+ result.setValid(false);
|
|
|
|
|
+ result.setMessage("医院信息不存在");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 验证签名药师信息
|
|
|
|
|
+ if (order.getDrugDoctorId() == null) {
|
|
|
|
|
+ result.setValid(false);
|
|
|
|
|
+ result.setMessage("缺少签名药师信息");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (result.getPrescribe().getDrugDoctorId() == null) {
|
|
|
|
|
+ result.setValid(false);
|
|
|
|
|
+ result.setMessage("处方缺少签名药师信息");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ result.setDrugDoctor(fsDoctorMapper.selectFsDoctorByDoctorId(result.getPrescribe().getDrugDoctorId()));
|
|
|
|
|
+ if (result.getDrugDoctor() == null) {
|
|
|
|
|
+ result.setValid(false);
|
|
|
|
|
+ result.setMessage("签名药师信息不存在");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 验证门店信息
|
|
|
|
|
+ if (order.getStoreId() == null) {
|
|
|
|
|
+ result.setValid(false);
|
|
|
|
|
+ result.setMessage("缺少门店信息");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ result.setStore(fsStoreMapper.selectFsStoreByStoreId(order.getStoreId()));
|
|
|
|
|
+ if (result.getStore() == null) {
|
|
|
|
|
+ result.setValid(false);
|
|
|
|
|
+ result.setMessage("门店信息不存在");
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|