|
@@ -7,6 +7,7 @@ import com.bzd.common.core.domain.entity.DtpDeliveryPrint;
|
|
|
import com.bzd.common.utils.DateUtils;
|
|
|
import com.bzd.common.utils.StringUtils;
|
|
|
import com.bzd.common.utils.uuid.IdUtils;
|
|
|
+import com.bzd.system.service.dtp.SDtpYypzFollowUpSopService;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -31,6 +32,8 @@ public class DTPService {
|
|
|
@Resource(name = "daoSupport")
|
|
|
private DaoSupport daoSupport;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SDtpYypzFollowUpSopService SDtpYypzFollowUpSopService;
|
|
|
/**
|
|
|
* 处方列表
|
|
|
*
|
|
@@ -593,10 +596,10 @@ public class DTPService {
|
|
|
}
|
|
|
|
|
|
// 从 lxr 获取数据并映射到数据库字段
|
|
|
- pageData.put("mdmCode", lxr.get("mdmCode"));
|
|
|
+ pageData.put("mdmCode", lxr.get("mdmCode"));//药品编码
|
|
|
pageData.put("productName", lxr.get("productName"));
|
|
|
pageData.put("genericName", lxr.get("genericName"));
|
|
|
- pageData.put("specification", lxr.get("specification"));
|
|
|
+ pageData.put("specification", lxr.get("specification"));//规格
|
|
|
pageData.put("manufacturerShortName", lxr.get("manufacturerShortName"));
|
|
|
pageData.put("administrationMethod", lxr.get("administrationMethod"));
|
|
|
pageData.put("packageQuantity", lxr.get("packageQuantity"));//处方取药数量(包装数)输入框的值
|
|
@@ -605,7 +608,7 @@ public class DTPService {
|
|
|
pageData.put("dosageFrequency", lxr.get("dosageFrequency"));//规范用药频次
|
|
|
pageData.put("dosageFrequencyDays", lxr.get("dosageFrequencyDays"));//用药频次换算使用天数 下拉带出来的 要去字典的value
|
|
|
if(lxr.get("dvalueDays")!=null){
|
|
|
- pageData.put("dvalueDays", lxr.get("dvalueDays"));
|
|
|
+ pageData.put("dvalueDays", lxr.get("dvalueDays"));//D值用药天数
|
|
|
}else {
|
|
|
pageData.put("dvalueDays", 0);
|
|
|
}
|
|
@@ -630,20 +633,20 @@ public class DTPService {
|
|
|
// pageData.put("updatedTime", lxr.get("updatedTime"));
|
|
|
// pageData.put("remarks", lxr.get("remarks"));
|
|
|
|
|
|
-
|
|
|
+ //如果药品是随访管理品 生成随访计划和任务
|
|
|
String followUpItem = (String) lxr.get("followUpItem");//是否是随访品 1是,0否
|
|
|
if( StringUtils.isNotEmpty(followUpItem) && "是".equals(followUpItem) ){
|
|
|
-
|
|
|
+ int i=0;
|
|
|
PageData pdCPB=new PageData();
|
|
|
if (StringUtils.isNotEmpty(patientId)) {
|
|
|
pdCPB.put("patientId", patientId);
|
|
|
}else {
|
|
|
- returnPageData.put("msg", "天添加败未获取患者信息");
|
|
|
+ returnPageData.put("msg", "添加败未获取患者信息");
|
|
|
returnPageData.put("code", 300);
|
|
|
return returnPageData;
|
|
|
}
|
|
|
- pdCPB.put("mdmCode", lxr.get("mdmCode"));
|
|
|
- pdCPB.put("productCode", lxr.get("productCode"));
|
|
|
+ pdCPB.put("mdmCode", lxr.get("mdmCode"));//'药品编码'
|
|
|
+ pdCPB.put("productCode", lxr.get("productCode"));//'药品编码'
|
|
|
|
|
|
List<PageData> SOPList= (List<PageData>) daoSupport.findForList("SDtpYypzFollowUpSopMapper.selectSOPTemplateByProductCode", pdCPB);
|
|
|
if(SOPList.size()>0){//说明是配置品
|
|
@@ -653,34 +656,37 @@ public class DTPService {
|
|
|
//先查询该患者购买在这个药品是否已经有计划 mdmCode patientId businessBelonging
|
|
|
//List<PageData> planList= (List<PageData>) daoSupport.findForList("followPlanMapper.selectPlanListByCPB", pdCPB);
|
|
|
PageData plan= (PageData) daoSupport.findForObject("followPlanMapper.selectPlanByCPB", pdCPB);
|
|
|
- //生成任务ID
|
|
|
- String taskId = IdUtils.fastSimpleUUID();
|
|
|
+ //生成计划
|
|
|
+ pdCPB.put("productName", lxr.get("productName"));//'药品名称'
|
|
|
+ pdCPB.put("businessBelonging", "常规随访");//业务归属 先写死 默认这个药品已经配置了业务归属为常规随访的药
|
|
|
+ pdCPB.put("specification", lxr.get("specification"));
|
|
|
+ pdCPB.put("storeId", getSysUser().getDeptId());
|
|
|
+ pdCPB.put("storeName", getSysUser().getDept().getDeptName());
|
|
|
+ pdCPB.put("templateId", "12345");//'模版ID' 先假设写死 实际是获取模板ID
|
|
|
+ pdCPB.put("planName", lxr.get("productName")+"-随访");//'计划名称' 默认用药品作为名称
|
|
|
+ // pdCPB.put("taskId", taskId);
|
|
|
+ pdCPB.put("follow_up_person", "周敏");//'随访跟进人' 先写死
|
|
|
+ pdCPB.put("follow_up_person_id", "7");//'随访跟进人id' 先写死
|
|
|
+ pdCPB.put("createdBy", "系统创建");//'创建人'
|
|
|
+ pdCPB.put("createdTime", DateUtils.getTime());//'创建时间'
|
|
|
+ pdCPB.put("updatedBy", getSysUser().getLoginName());//'创建时间'
|
|
|
+ pdCPB.put("updatedTime", DateUtils.getTime());//'创建时间'
|
|
|
+ pdCPB.put("status", 1);//'计划状态: 0关闭 1开启/进行中,2默认:2已创建待开启'
|
|
|
if(StringUtils.isNotNull(plan)){
|
|
|
pdCPB.put("planId", plan.get("planId"));
|
|
|
planId= plan.get("planId").toString();
|
|
|
}else {
|
|
|
pdCPB.put("planId", planId);
|
|
|
- pdCPB.put("productName", lxr.get("productName"));//'药品名称'
|
|
|
- pdCPB.put("businessBelonging", "常规随访");//业务归属 先写死 默认这个药品已经配置了业务归属为常规随访的药
|
|
|
- pdCPB.put("specification", lxr.get("specification"));
|
|
|
- pdCPB.put("storeId", getSysUser().getDeptId());
|
|
|
- pdCPB.put("storeName", getSysUser().getDept().getDeptName());
|
|
|
- pdCPB.put("templateId", "12345");//'模版ID' 先假设写死 实际是获取模板ID
|
|
|
- pdCPB.put("planName", lxr.get("productName")+"-随访");//'计划名称' 默认用药品作为名称
|
|
|
- // pdCPB.put("taskId", taskId);
|
|
|
- pdCPB.put("follow_up_person", "周敏");//'随访跟进人' 先写死
|
|
|
- pdCPB.put("follow_up_person_id", "7");//'随访跟进人id' 先写死
|
|
|
- pdCPB.put("createdBy", "系统创建");//'创建人'
|
|
|
- pdCPB.put("createdTime", DateUtils.getTime());//'创建时间'
|
|
|
- pdCPB.put("updatedBy", getSysUser().getLoginName());//'创建时间'
|
|
|
- pdCPB.put("updatedTime", DateUtils.getTime());//'创建时间'
|
|
|
- pdCPB.put("status", 1);//'计划状态: 0关闭 1开启/进行中,2默认:2已创建待开启'
|
|
|
+ //生成计划
|
|
|
int FollowPlan = dao.executeBatch("followPlanMapper.insertFollowPlan", pdCPB);
|
|
|
+ SDtpYypzFollowUpSopService.triggerPLan(pdCPB);
|
|
|
System.out.println("FollowPlan.size()="+FollowPlan);
|
|
|
}
|
|
|
+ //生成任务数据
|
|
|
pdCPB.put("appointmentDate", DateUtils.getTime());//'预约日期'
|
|
|
pdCPB.put("businessBelonging", "常规随访");//'业务归属:常规随访,脱落召回'
|
|
|
- pdCPB.put("taskName", "第1次任务");//'任务名称'
|
|
|
+ i++;
|
|
|
+ pdCPB.put("taskName", lxr.get("productName")+"-第"+i+"次任务");//'任务名称'
|
|
|
pdCPB.put("taskTheme", "常规随访");//'任务主题'
|
|
|
pdCPB.put("planId", planId);//'计划ID'
|
|
|
pdCPB.put("patientId", patientId);//'患者id'
|
|
@@ -691,7 +697,6 @@ public class DTPService {
|
|
|
//pdCPB.put("followUpSummaryid", lxr.get("followUpSummaryid"));//'随访小结id'
|
|
|
pdCPB.put("disease", pd.get("prescriptionDiagnosis"));//'疾病' 先用处方诊断字段代替
|
|
|
pdCPB.put("storeName", getSysUser().getDeptId());//'门店'
|
|
|
- pdCPB.put("mdmCode", lxr.get("mdmCode"));//'药品编码'
|
|
|
pdCPB.put("genericName", lxr.get("genericName"));//'药品通用名'
|
|
|
pdCPB.put("productName", lxr.get("productName"));//'商品名'
|
|
|
pdCPB.put("taskFollower", "周敏");//'任务跟进人'
|
|
@@ -702,6 +707,7 @@ public class DTPService {
|
|
|
pdCPB.put("createdAt", DateUtils.getTime());
|
|
|
pdCPB.put("updatedAt", DateUtils.getTime());
|
|
|
pdCPB.put("storeId", getSysUser().getDeptId());
|
|
|
+ //生成任务
|
|
|
int FollowTask = dao.executeBatch("followTaskMapper.insertFollowTask", pdCPB);
|
|
|
System.out.println("FollowTask.size()="+FollowTask);
|
|
|
}
|
|
@@ -727,7 +733,7 @@ public class DTPService {
|
|
|
pd.put("drugQuantity", drugQuantity);
|
|
|
|
|
|
if (StringUtils.isNull(reviewingName) && StringUtils.isEmpty(reviewStatus)){
|
|
|
- pd.put("reviewingName", "系统默认");
|
|
|
+ pd.put("reviewingName", "系统审核");
|
|
|
pd.put("reviewStatus", 1);//处方审核状态:0:审核不通过;1:审核通过;2: 待审核;默认 1: "审核通过";
|
|
|
}
|
|
|
if(StringUtils.isEmpty(remarks)){
|
|
@@ -746,7 +752,7 @@ public class DTPService {
|
|
|
returnPageData.put("drugsLinkId", drugsLinkId);
|
|
|
return returnPageData;
|
|
|
}else {
|
|
|
- returnPageData.put("msg", "天添加败");
|
|
|
+ returnPageData.put("msg", "添加败");
|
|
|
returnPageData.put("code", 300);
|
|
|
return returnPageData;
|
|
|
}
|
|
@@ -778,9 +784,13 @@ public class DTPService {
|
|
|
String status = (String) pd.get("status");
|
|
|
boolean flag = false; // 标志变量
|
|
|
Integer onlyId=null;
|
|
|
+ //生成计划ID
|
|
|
+ String planId = IdUtils.fastSimpleUUID();
|
|
|
String prescriptionImageUrl = (String) pd.get("prescriptionImageUrl");
|
|
|
-
|
|
|
- if (status.equals("4")) {//4待处方登记
|
|
|
+ if (StringUtils.isNull(pd.get("registrant"))){
|
|
|
+ pd.put("registrant", getSysUser().getLoginName());
|
|
|
+ }
|
|
|
+ if (status.equals("4")) {//4待处方登记 先销售后登记的情况
|
|
|
onlyId = IdUtils.get10randomNumber();//如果是先销售后登记来做的修改处方信息 生成处方单号
|
|
|
flag=true;//为先销售后登记
|
|
|
if (StringUtils.isEmpty(prescriptionImageUrl)) {//3待确认信息
|
|
@@ -788,7 +798,6 @@ public class DTPService {
|
|
|
}else {
|
|
|
status="3";//待确认信息
|
|
|
}
|
|
|
-
|
|
|
}else{
|
|
|
if (StringUtils.isEmpty(prescriptionImageUrl)) {//3待确认信息
|
|
|
status="2";//待上传处方
|
|
@@ -797,13 +806,10 @@ public class DTPService {
|
|
|
}
|
|
|
}
|
|
|
Object drugList = pd.get("drugData");//获取药品信息列表
|
|
|
-
|
|
|
List<PageData> addList = new ArrayList<>();
|
|
|
int resultDrug=0;
|
|
|
int drugQuantity=0;
|
|
|
-
|
|
|
if (StringUtils.isNotNull(drugList)) {
|
|
|
-
|
|
|
// 将 JSON 字符串转换为 List<Map<String, Object>>
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
List<Map<String, Object>> rowsdrugList = objectMapper.readValue(drugList.toString(), List.class);
|
|
@@ -813,7 +819,6 @@ public class DTPService {
|
|
|
dao.executeBatch("DTPCFDJMapper.batchDeleteDrugPurchaseRecord", pd); // 直接删除 所有的药品信息然后新增
|
|
|
for (Map<String, Object> lxr : rowsdrugList) {
|
|
|
PageData pageData = new PageData();
|
|
|
-
|
|
|
// 设置固定或默认值
|
|
|
pageData.put("createdBy", getSysUser().getLoginName());
|
|
|
pageData.put("createdTime", DateUtils.getTime());
|
|
@@ -843,6 +848,7 @@ public class DTPService {
|
|
|
if(flag){
|
|
|
pageData.put("salesOrderNumber", pd.get("salesOrderNumber"));
|
|
|
pageData.put("prescriptionNumber", onlyId);
|
|
|
+
|
|
|
if(StringUtils.isNotNull(pd1)){
|
|
|
pageData.put("sales", pd1.get("saleDate"));//销售日期
|
|
|
pageData.put("pharmacyName", pd1.get("ales_storeName"));//销售门店名称
|
|
@@ -859,9 +865,83 @@ public class DTPService {
|
|
|
pageData.put("department", lxr.get("department"));
|
|
|
pageData.put("attendingPhysician", lxr.get("attendingPhysician"));
|
|
|
pageData.put("clinicalDiagnosis", lxr.get("clinicalDiagnosis"));
|
|
|
- pageData.put("registrant", lxr.get("registrant"));
|
|
|
+ pageData.put("registrant", pd.get("registrant"));
|
|
|
pageData.put("registrationDate", DateUtils.getTime());
|
|
|
addList.add(pageData);
|
|
|
+
|
|
|
+ //如果药品是随访管理品 生成随访计划和任务
|
|
|
+ // String followUpItem = (String) lxr.get("followUpItem");//是否是随访品 1是,0否
|
|
|
+ PageData MdmCode= (PageData) daoSupport.findForObject("DTPCFDJMapper.isfollowUpItemByMdmCode", pageData);
|
|
|
+ if(StringUtils.isNotNull(MdmCode)){
|
|
|
+ int follow_up_item = (int) MdmCode.get("follow_up_item");//随访品 //=1说明是随访品 0不是
|
|
|
+ if(follow_up_item==1){
|
|
|
+ int i=0;
|
|
|
+ PageData pdCPB=new PageData();
|
|
|
+ if (StringUtils.isNotEmpty(patientId)) {
|
|
|
+ pdCPB.put("patientId", patientId);
|
|
|
+ }else {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ pdCPB.put("mdmCode", lxr.get("mdmCode"));
|
|
|
+ pdCPB.put("productCode", lxr.get("mdmCode"));
|
|
|
+
|
|
|
+ List<PageData> SOPList= (List<PageData>) daoSupport.findForList("SDtpYypzFollowUpSopMapper.selectSOPTemplateByProductCode", pdCPB);
|
|
|
+ if(SOPList.size()>0){//说明是配置品
|
|
|
+ String businessBelonging = (String) SOPList.get(0).get("businessBelonging");//业务归属
|
|
|
+ }
|
|
|
+ //先查询该患者购买在这个药品是否已经有计划 mdmCode patientId businessBelonging
|
|
|
+ //List<PageData> planList= (List<PageData>) daoSupport.findForList("followPlanMapper.selectPlanListByCPB", pdCPB);
|
|
|
+ PageData plan= (PageData) daoSupport.findForObject("followPlanMapper.selectPlanByCPB", pdCPB);
|
|
|
+ //生成计划
|
|
|
+ pdCPB.put("productName", lxr.get("productName"));//'药品名称'
|
|
|
+ pdCPB.put("genericName", lxr.get("genericName"));//'药品通用名'
|
|
|
+ pdCPB.put("businessBelonging", "常规随访");//业务归属 先写死 默认这个药品已经配置了业务归属为常规随访的药
|
|
|
+ pdCPB.put("specification", lxr.get("specification"));
|
|
|
+ pdCPB.put("storeId", getSysUser().getDeptId());//'门店id'
|
|
|
+ pdCPB.put("storeName", getSysUser().getDept().getDeptName());//'门店'
|
|
|
+ pdCPB.put("templateId", "12345");//'模版ID' 先假设写死 实际是获取模板ID
|
|
|
+ pdCPB.put("planName", lxr.get("productName")+"-随访");//'计划名称' 默认用药品作为名称
|
|
|
+ pdCPB.put("follow_up_person", "周敏");//'随访跟进人' 先写死
|
|
|
+ pdCPB.put("follow_up_person_id", "7");//'随访跟进人id' 先写死
|
|
|
+ pdCPB.put("createdBy", "系统创建");//'创建人'
|
|
|
+ pdCPB.put("createdTime", DateUtils.getTime());//'创建时间'
|
|
|
+ pdCPB.put("updatedBy", getSysUser().getLoginName());//'创建时间'
|
|
|
+ pdCPB.put("updatedTime", DateUtils.getTime());//'创建时间'
|
|
|
+ pdCPB.put("status", 1);//'计划状态: 0关闭 1开启/进行中,2默认:2已创建待开启'
|
|
|
+ if(StringUtils.isNotNull(plan)){
|
|
|
+ pdCPB.put("planId", plan.get("planId"));
|
|
|
+ planId= plan.get("planId").toString();
|
|
|
+ }else {
|
|
|
+ pdCPB.put("planId", planId);
|
|
|
+ int FollowPlan = dao.executeBatch("followPlanMapper.insertFollowPlan", pdCPB);
|
|
|
+ System.out.println("先销售后登记FollowPlan.size()="+FollowPlan);
|
|
|
+ }
|
|
|
+ pdCPB.put("appointmentDate", DateUtils.getTime());//'预约日期'
|
|
|
+ i++;
|
|
|
+ pdCPB.put("taskName", lxr.get("productName")+"-第"+i+"次任务");//'任务名称'
|
|
|
+ pdCPB.put("taskTheme", "常规随访");//'任务主题'
|
|
|
+ pdCPB.put("planId", planId);//'计划ID'
|
|
|
+ pdCPB.put("patientId", patientId);//'患者id'
|
|
|
+ pdCPB.put("patientName", pd.get("patientName"));//'患者姓名'
|
|
|
+ pdCPB.put("gender", pd.get("gender"));//'性别:0男,1女,2未知'
|
|
|
+ pdCPB.put("age", pd.get("age"));//'年龄'
|
|
|
+ //pdCPB.put("followUpSummary", "无");//'随访小结'
|
|
|
+ //pdCPB.put("followUpSummaryid", lxr.get("followUpSummaryid"));//'随访小结id'
|
|
|
+ pdCPB.put("disease", pd.get("prescriptionDiagnosis"));//'疾病' 先用处方诊断字段代替
|
|
|
+ pdCPB.put("storeName", getSysUser().getDeptId());//'门店'
|
|
|
+ //pdCPB.put("mdmCode", lxr.get("mdmCode"));//'药品编码'
|
|
|
+ pdCPB.put("taskFollower", "周敏");//'任务跟进人'
|
|
|
+ pdCPB.put("nutrition_evaluation_id", "11111111");//'营养测评id'
|
|
|
+ pdCPB.put("medication_record_id", "22222222");//'用药记录id'
|
|
|
+ pdCPB.put("taskStatus", "待执行");//任务状态:\r\n,0待执行,\r\n1已完成,\r\n2未完成,\r\n3已下发
|
|
|
+ pdCPB.put("operator", pd.get("registrant"));//'操作人'
|
|
|
+ pdCPB.put("createdAt", DateUtils.getTime());
|
|
|
+ pdCPB.put("updatedAt", DateUtils.getTime());
|
|
|
+ int FollowTask = dao.executeBatch("followTaskMapper.insertFollowTask", pdCPB);
|
|
|
+ System.out.println("先销售后登记FollowTask.size()="+FollowTask);
|
|
|
+ //生成任务结束
|
|
|
+ }
|
|
|
+ }
|
|
|
dao.executeBatch("DTPCFDJMapper.batchAddDrugPurchaseRecordNew", pageData);
|
|
|
}
|
|
|
}
|
|
@@ -884,7 +964,7 @@ public class DTPService {
|
|
|
pd.put("drugQuantity", drugQuantity);
|
|
|
|
|
|
if (StringUtils.isNull(reviewingName) && StringUtils.isEmpty(reviewStatus)){
|
|
|
- pd.put("reviewingName", "系统默认");
|
|
|
+ pd.put("reviewingName", "系统审核");
|
|
|
pd.put("reviewStatus", 1);//处方审核状态:0:审核不通过;1:审核通过;2: 待审核;默认 1: "审核通过";
|
|
|
}
|
|
|
if(StringUtils.isEmpty(remarks)){
|
|
@@ -912,9 +992,7 @@ public class DTPService {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- if (StringUtils.isNull(pd.get("registrant"))){
|
|
|
- pd.put("registrant", getSysUser().getLoginName());
|
|
|
- }
|
|
|
+
|
|
|
return daoSupport.save("DTPCFDJMapper.updatePrescriptionRegistration", pd);
|
|
|
|
|
|
|