|
@@ -39,10 +39,11 @@ public class DTPService {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public List<PageData> findForList(final PageData pd) throws Exception {
|
|
|
+
|
|
|
return (List<PageData>) daoSupport.findForList("DTPCFDJMapper.selectPrescriptionRegistration", pd);
|
|
|
}
|
|
|
/**
|
|
|
- * 处方列表
|
|
|
+ * 处方/药品列表
|
|
|
*
|
|
|
* @param pd
|
|
|
* @return
|
|
@@ -54,7 +55,7 @@ public class DTPService {
|
|
|
if(StringUtils.isNotNull(pdObj)){
|
|
|
pd3.put("recipe",pdObj);
|
|
|
PageData pd2=new PageData();
|
|
|
- pd2.put("prescriptionNumber",pdObj.get("prescriptionNumber"));
|
|
|
+ pd2.put("drugsLinkId",pdObj.get("drugsLinkId"));
|
|
|
List<PageData> pdObjList= (List<PageData>) daoSupport.findForList("DTPCFDJMapper.selectListRecordByPrescriptionNumber", pd2);
|
|
|
if(pdObjList.size()>0){
|
|
|
pd3.put("recipeList", pdObjList);
|
|
@@ -69,7 +70,7 @@ public class DTPService {
|
|
|
if(StringUtils.isNotNull(pdObj)){
|
|
|
pd3.put("recipe",pdObj);
|
|
|
PageData pd2=new PageData();
|
|
|
- pd2.put("prescriptionNumber",pdObj.get("prescriptionNumber"));
|
|
|
+ pd2.put("drugsLinkId",pdObj.get("drugsLinkId"));
|
|
|
List<PageData> pdObjList= (List<PageData>) daoSupport.findForList("DTPCFDJMapper.selectListRecordByPrescriptionNumber", pd2);
|
|
|
if(pdObjList.size()>0){
|
|
|
pd3.put("recipeList", pdObjList);
|
|
@@ -77,6 +78,21 @@ public class DTPService {
|
|
|
}
|
|
|
return pd3;
|
|
|
}
|
|
|
+ public PageData getLastRecipeInfoSales(final PageData pd) throws Exception {
|
|
|
+ PageData pd3= new PageData();
|
|
|
+ PageData pdObj= (PageData) daoSupport.findForObject("DTPCFDJMapper.selectOneById", pd);
|
|
|
+ if(StringUtils.isNotNull(pdObj)){
|
|
|
+ pd3.put("recipe",pdObj);
|
|
|
+ PageData pd2=new PageData();
|
|
|
+ pd2.put("drugsLinkId",pdObj.get("drugsLinkId"));
|
|
|
+ List<PageData> pdObjList= (List<PageData>) daoSupport.findForList("DTPCFDJMapper.selectListRecordByPrescriptionNumber", pd2);
|
|
|
+ if(pdObjList.size()>0){
|
|
|
+ pd3.put("recipeList", pdObjList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return pd3;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 处方信息
|
|
|
*
|
|
@@ -92,7 +108,92 @@ public class DTPService {
|
|
|
return daoSupport.update("DTPMapper.BangdingRecipe", pd);
|
|
|
}
|
|
|
/**
|
|
|
- * 处方登记 添加
|
|
|
+ * 先销售后登记的订单数据录入
|
|
|
+ *
|
|
|
+ * @param pd
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public PageData saveSales(final PageData pd) throws Exception {
|
|
|
+ PageData returnPageData = new PageData();
|
|
|
+ Object drugList = pd.get("drugData");//获取药品信息列表
|
|
|
+ Integer salesOrderNumber = IdUtils.get10randomNumber();//订单号 模拟生成销售单号 实际会从销售系统带过来
|
|
|
+ // Integer prescriptionNumber = IdUtils.get10randomNumber();//订单号 模拟生成销售单号 实际会从销售系统带过来
|
|
|
+ Integer drugsLinkId = IdUtils.get10randomNumber();//处方关联药品唯一标识
|
|
|
+
|
|
|
+ List<PageData> addList = new ArrayList<>();
|
|
|
+ int resultDrug=0;
|
|
|
+ int drugQuantity=0;
|
|
|
+
|
|
|
+ try {
|
|
|
+ if (StringUtils.isNotNull(drugList)) {
|
|
|
+ // 将 JSON 字符串转换为 List<Map<String, Object>>
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ List<Map<String, Object>> rowsdrugList = objectMapper.readValue(drugList.toString(), List.class);
|
|
|
+ drugQuantity = rowsdrugList.size();//处方取药数量
|
|
|
+ // 遍历列表并调用插入数据接口
|
|
|
+ if (rowsdrugList.size() > 0) {
|
|
|
+ for (Map<String, Object> lxr : rowsdrugList) {
|
|
|
+ PageData pageData = new PageData();
|
|
|
+ // 设置固定或默认值
|
|
|
+ pageData.put("createdTime", DateUtils.getTime());
|
|
|
+ // 从 lxr 获取数据并映射到数据库字段
|
|
|
+ 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("manufacturerShortName", lxr.get("manufacturerShortName"));
|
|
|
+ pageData.put("administrationMethod", lxr.get("administrationMethod"));
|
|
|
+ pageData.put("drug_batch_number", lxr.get("drug_batch_number"));//药品批号
|
|
|
+ pageData.put("pharmacyName", lxr.get("pharmacyName"));
|
|
|
+ // 添加其他可能需要的字段(如果有的话)
|
|
|
+ pageData.put("medicationRoute", lxr.get("medicationRoute"));
|
|
|
+ pageData.put("sales", lxr.get("sales"));
|
|
|
+ // pageData.put("prescriptionNumber", prescriptionNumber);
|
|
|
+ pageData.put("drugsLinkId", drugsLinkId);
|
|
|
+ pageData.put("salesOrderNumber", salesOrderNumber);
|
|
|
+ pageData.put("prescriptionDate", DateUtils.getTime());
|
|
|
+ pageData.put("hospital", lxr.get("hospital"));
|
|
|
+ pageData.put("prescribingDoctor", lxr.get("prescribingDoctor"));
|
|
|
+ pageData.put("department", lxr.get("department"));
|
|
|
+ pageData.put("attendingPhysician", lxr.get("attendingPhysician"));
|
|
|
+ pageData.put("clinicalDiagnosis", lxr.get("clinicalDiagnosis"));
|
|
|
+ addList.add(pageData);
|
|
|
+ resultDrug = dao.executeBatch("DTPCFDJMapper.batchAddDrugPurchaseRecordNew", pageData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 从表单数据填充
|
|
|
+ // pd.put("prescriptionNumber", prescriptionNumber); // 处方单表id主键,Id 应该是某个方式生成的唯一标识符
|
|
|
+ pd.put("salesOrderNumber", salesOrderNumber); // 处方单表id主键,Id 应该是某个方式生成的唯一标识符
|
|
|
+ pd.put("drugsLinkId", drugsLinkId);
|
|
|
+ pd.put("status", 4);//先销售 处方状态就是 待处方登记4
|
|
|
+ pd.put("createdBy", getSysUser().getUserId());
|
|
|
+ pd.put("createTime", DateUtils.getTime());
|
|
|
+ pd.put("drugQuantity", drugQuantity);
|
|
|
+ int result = daoSupport.save("DTPCFDJMapper.insertPrescriptionRegistration", pd);
|
|
|
+ if(resultDrug>0 && result>0){
|
|
|
+ returnPageData.put("code", 200);
|
|
|
+ // returnPageData.put("prescriptionNumber", prescriptionNumber);
|
|
|
+ returnPageData.put("drugsLinkId", drugsLinkId);
|
|
|
+ returnPageData.put("status", 4);//先销售 处方状态就是 待处方登记4
|
|
|
+ returnPageData.put("salesOrderNumber", salesOrderNumber);
|
|
|
+ return returnPageData;
|
|
|
+ }else {
|
|
|
+ returnPageData.put("msg", "天添加败");
|
|
|
+ returnPageData.put("code", 300);
|
|
|
+ return returnPageData;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 处方登记 添加此接口暂时废弃 不用
|
|
|
*
|
|
|
* @param pd
|
|
|
* @return
|
|
@@ -107,7 +208,7 @@ public class DTPService {
|
|
|
if (StringUtils.isEmpty(prescriptionNumber.toString())) {
|
|
|
pd.put("prescriptionNumber", IdUtils.get10randomNumber());//处方表 处方单号 如果没有就自动生成
|
|
|
if( StringUtils.isEmpty(prescriptionImg.toString())){
|
|
|
- pd.put("status",5);//待上传处方
|
|
|
+ pd.put("status",4);//待上传处方
|
|
|
}
|
|
|
if( StringUtils.isNotEmpty(prescriptionImg)){
|
|
|
pd.put("status",6);//待绑定患者6
|
|
@@ -237,14 +338,12 @@ public class DTPService {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public PageData saveCFDJ(final PageData pd) throws Exception {
|
|
|
PageData returnPageData = new PageData();
|
|
|
-
|
|
|
Object drugList = pd.get("drugData");//获取药品信息列表
|
|
|
- Integer Id = IdUtils.get10randomNumber();//生成处方单号
|
|
|
+ Integer drugsLinkId = IdUtils.get10randomNumber();//生成处方与药品关联的编号
|
|
|
+ Integer prescriptionNumber = IdUtils.get10randomNumber();//生成处方单号
|
|
|
List<PageData> addList = new ArrayList<>();
|
|
|
int resultDrug=0;
|
|
|
int drugQuantity=0;
|
|
|
-
|
|
|
-
|
|
|
try {
|
|
|
if (StringUtils.isNotNull(drugList)) {
|
|
|
// 将 JSON 字符串转换为 List<Map<String, Object>>
|
|
@@ -279,11 +378,11 @@ public class DTPService {
|
|
|
pageData.put("dvalueDays", 0);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// 添加其他可能需要的字段(如果有的话)
|
|
|
pageData.put("medicationRoute", lxr.get("medicationRoute"));
|
|
|
//pageData.put("sales", lxr.get("sales"));
|
|
|
- pageData.put("prescriptionNumber", Id);
|
|
|
+ pageData.put("prescriptionNumber", prescriptionNumber);
|
|
|
+ pageData.put("drugsLinkId", drugsLinkId);
|
|
|
pageData.put("prescriptionDate", DateUtils.getTime());
|
|
|
pageData.put("hospital", lxr.get("hospital"));
|
|
|
pageData.put("prescribingDoctor", lxr.get("prescribingDoctor"));
|
|
@@ -306,20 +405,20 @@ public class DTPService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
// 从表单数据填充
|
|
|
- pd.put("prescriptionNumber", Id); // 处方单表id主键,Id 应该是某个方式生成的唯一标识符
|
|
|
+ pd.put("drugsLinkId", drugsLinkId); // 处方与药品关联的唯一编码
|
|
|
pd.put("storeId", getSysUser().getDeptId());
|
|
|
pd.put("storeName", getSysUser().getDeptId()); // 假设 getDeptName() 可以获取部门名称
|
|
|
pd.put("createdBy", getSysUser().getUserId());
|
|
|
pd.put("createTime", DateUtils.getTime());
|
|
|
-
|
|
|
+ pd.put("status", 5);//5待订单销售
|
|
|
pd.put("registrationDate", DateUtils.getTime());
|
|
|
pd.put("drugQuantity", drugQuantity);
|
|
|
int result = daoSupport.save("DTPCFDJMapper.insertPrescriptionRegistration", pd);
|
|
|
if(resultDrug>0 && result>0){
|
|
|
returnPageData.put("code", 200);
|
|
|
- returnPageData.put("prescriptionNumber", Id);
|
|
|
+ returnPageData.put("prescriptionNumber", prescriptionNumber);
|
|
|
+ returnPageData.put("drugsLinkId", drugsLinkId);
|
|
|
return returnPageData;
|
|
|
}else {
|
|
|
returnPageData.put("msg", "天添加败");
|
|
@@ -540,14 +639,39 @@ public class DTPService {
|
|
|
}
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public int updateCFDJ(final PageData pd) throws Exception {
|
|
|
+ PageData pd3=new PageData();
|
|
|
+ try {
|
|
|
+ pd3.put("id",pd.get("id"));
|
|
|
+ PageData pd1= (PageData) daoSupport.findForObject("DTPCFDJMapper.selectOneById", pd3);
|
|
|
+ String status = (String) pd.get("status");
|
|
|
+ boolean flag = false; // 标志变量
|
|
|
+ Integer onlyId=null;
|
|
|
+ String prescriptionImageUrl = (String) pd.get("prescriptionImageUrl");
|
|
|
+
|
|
|
+ if (status.equals("4")) {//4待处方登记
|
|
|
+ onlyId = IdUtils.get10randomNumber();//如果是先销售后登记来做的修改处方信息 生成处方单号
|
|
|
+ flag=true;
|
|
|
+ if (StringUtils.isEmpty(prescriptionImageUrl)) {//3待确认信息
|
|
|
+ status="2";//待上传处方
|
|
|
+ }else {
|
|
|
+ status="3";//待确认信息
|
|
|
+ }
|
|
|
+
|
|
|
+ }else{
|
|
|
+ if (StringUtils.isEmpty(prescriptionImageUrl)) {//3待确认信息
|
|
|
+ status="2";//待上传处方
|
|
|
+ }else {
|
|
|
+ status="3";//待确认信息
|
|
|
+ }
|
|
|
+ }
|
|
|
Object drugList = pd.get("drugData");//获取药品信息列表
|
|
|
- Integer Id = IdUtils.get10randomNumber();//生成处方单号
|
|
|
+
|
|
|
List<PageData> addList = new ArrayList<>();
|
|
|
int resultDrug=0;
|
|
|
int drugQuantity=0;
|
|
|
|
|
|
if (StringUtils.isNotNull(drugList)) {
|
|
|
- try {
|
|
|
+
|
|
|
// 将 JSON 字符串转换为 List<Map<String, Object>>
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
List<Map<String, Object>> rowsdrugList = objectMapper.readValue(drugList.toString(), List.class);
|
|
@@ -581,7 +705,20 @@ public class DTPService {
|
|
|
pageData.put("dvalueDays", 0);
|
|
|
}
|
|
|
pageData.put("medicationRoute", lxr.get("medicationRoute"));
|
|
|
- pageData.put("prescriptionNumber", pd.get("prescriptionNumber"));
|
|
|
+
|
|
|
+ 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"));//销售门店名称
|
|
|
+ pageData.put("drug_batch_number", pd1.get("drug_batch_number"));//药品批号
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ //pageData.put("salesOrderNumber", pd.get("salesOrderNumber"));
|
|
|
+ pageData.put("prescriptionNumber", pd.get("prescriptionNumber"));
|
|
|
+ }
|
|
|
+ pageData.put("drugsLinkId", pd.get("drugsLinkId"));
|
|
|
pageData.put("prescriptionDate", DateUtils.getTime());
|
|
|
pageData.put("hospital", lxr.get("hospital"));
|
|
|
pageData.put("prescribingDoctor", lxr.get("prescribingDoctor"));
|
|
@@ -598,25 +735,36 @@ public class DTPService {
|
|
|
pd.put("storeName", getSysUser().getDeptId()); // 假设 getDeptName() 可以获取部门名称
|
|
|
pd.put("createdBy", getSysUser().getUserId());
|
|
|
pd.put("createTime", DateUtils.getTime());
|
|
|
-
|
|
|
- pd.put("registrationDate", DateUtils.getTime());
|
|
|
+ pd.put("status",Integer.parseInt(status));
|
|
|
+ if(flag){
|
|
|
+ pd.put("prescriptionNumber", onlyId);
|
|
|
+ pd.put("registrationDate", DateUtils.getTime());
|
|
|
+ if(StringUtils.isNotNull(pd1)){
|
|
|
+
|
|
|
+ pd.put("saleDate", pd1.get("saleDate"));//销售日期
|
|
|
+ pd.put("ales_storeName", pd1.get("ales_storeName"));//销售门店名称
|
|
|
+ pd.put("sales_storeCode", pd1.get("sales_storeCode"));//销售门店编码
|
|
|
+ pd.put("drug_batch_number", pd1.get("drug_batch_number"));//药品批号
|
|
|
+ }
|
|
|
+ }
|
|
|
pd.put("drugQuantity", drugQuantity);
|
|
|
// 患者信息
|
|
|
if (StringUtils.isNotNull(pd.get("gender"))){
|
|
|
String gender = pd.get("gender").toString();
|
|
|
if (gender.equals("男")){
|
|
|
- pd.put("gender", "1");
|
|
|
- }else if(gender.equals("女")){
|
|
|
pd.put("gender", "0");
|
|
|
+ }else if(gender.equals("女")){
|
|
|
+ pd.put("gender", "1");
|
|
|
}else {
|
|
|
pd.put("gender", "3");
|
|
|
}
|
|
|
}
|
|
|
return daoSupport.save("DTPCFDJMapper.updatePrescriptionRegistration", pd);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
return 0;
|
|
|
}
|