Forráskód Böngészése

修改处方接口

吴树波 4 hónapja
szülő
commit
d8f0d2f14a

+ 2 - 0
fs-common/src/main/java/com/fs/common/config/FSSysConfig.java

@@ -29,6 +29,8 @@ public class FSSysConfig
     String actId;
     String appId;
     String manuId;
+    String accessKeyID;
+    String accessKeySecret;
     String callbackUrl;
     //erp接口
     Integer erpOpen;//是否开启ERP

+ 23 - 0
fs-service-system/src/main/java/com/fs/store/bean/DrugV2.java

@@ -0,0 +1,23 @@
+package com.fs.store.bean;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class DrugV2 implements Serializable {
+    Long drugCode;//药品名称
+    String drugCommonName;//药品名称
+    String drugSpecification;//药品规格
+    String usageMethod;//使⽤⽅法
+    String frequencyUnit;//药品频次
+    String frequencyNum;//频次数量,例:1 等
+    String dosaNum;//每次⽤药数量
+    String dosaUnit;//每次⽤药单位
+    String usageDays;//天数
+    String saleAmount;//药品数量
+    String saleUnit;//药品数量单位
+    String instructions;//药品说明书
+    String approvalNumber;//药品产品批准⽂号⽤药单位
+
+}

+ 46 - 0
fs-service-system/src/main/java/com/fs/store/bean/PrescribeV2.java

@@ -0,0 +1,46 @@
+package com.fs.store.bean;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+@Data
+public class PrescribeV2 implements Serializable {
+    String drugType;//药品类型:01⻄药 02中药
+    String onlyId;//处⽅单ID(唯⼀ID)
+    String drugstoreName;//药店名称
+    String chiefComplaint;//病情描述(主诉)
+    String nowIllness;//现病史
+    String historyIllness;//既往史
+    Integer patientAge;//患者年龄
+    String patientName;//患者姓名
+    Integer weight;//体重
+    String icdName = "暂无";//对应icd名称
+    Integer patientAllergy;//是否有过敏史(传值:是/否)
+    String patientAllergyDesc;
+    Integer liverUnusual;//肝功能是否异常(传值:是/否)
+    Integer renalUnusual;//肾功能是否异常(传值:是/否)
+    Integer lactationFlag;//是否是备孕/怀孕/哺乳期(传值:是/否)
+    String patientMobile;//患者⼿机号(通过订单号去订单中⼼查)
+    Integer patientSex;//患者性别(传数字,1男 2⼥)
+    String[] recordPic;//复诊凭证
+    String createTime;//处⽅开具时间(来互联⽹医院开⽅的时间)
+    String pictureType;//处⽅⽂件格式(传值:png/jpg)
+    String pharmacistId;//药师ID
+    String pharmacistName;//药师名称
+    String pharmacistAutograph;//药师签名地址
+    String dispensingPharmacistId;//发药药师ID
+    String dispensingPharmacistName;//发药药师名称
+    String dispensingPharmacistAutograph;//发药药师签名地址
+    String deploymentPharmacistId;//配药药师ID
+    String deploymentPharmacistName;//配药药师名称
+    String deploymentPharmacistAutograph;//配药药师签名地址
+    Integer isPharmacistAudit;//是否提供药师审核,0-不使⽤⼀线平台的药师审核,1-使⽤⼀线平台的药师审核
+    String callbackUrl;//回调地址,如果填写,审核完处⽅后⾃动回调到第三⽅药房服务接⼝
+    String takingUsage;//服用方法(中药)
+    String takingRequire;//服用要求(中药
+    String takingNum;//服用付数(中药)(中药处方必传字段,西药、中成药非必传)
+    String hospitalCode;//开方医院标识(同步给平台方)
+    List<DrugV2> drugList;
+}

+ 20 - 0
fs-service-system/src/main/java/com/fs/store/param/PrescribeV2Param.java

@@ -0,0 +1,20 @@
+package com.fs.store.param;
+
+import com.fs.store.bean.PrescribeV2;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class PrescribeV2Param implements Serializable {
+    String accessKeyID;//操作编码uporder表示上传订单,getorder表示回传处⽅信息
+    String accessKeySecret;//为对接⼚商提供的编码,Y001表示
+    String timestamp;//调⽤接⼝时的时间戳
+    String sig;//输⼊参数计算后的签名结果
+    PrescribeV2 data;
+
+
+
+
+
+}

+ 2 - 0
fs-service-system/src/main/java/com/fs/store/service/IPrescribeService.java

@@ -2,6 +2,7 @@ package com.fs.store.service;
 
 import com.fs.common.core.domain.R;
 import com.fs.store.param.PrescribeParam;
+import com.fs.store.param.PrescribeV2Param;
 
 /**
  * 处方接口
@@ -9,4 +10,5 @@ import com.fs.store.param.PrescribeParam;
 public interface IPrescribeService
 {
     R doPrescribe(PrescribeParam param);
+    R doPrescribeV2(PrescribeV2Param param);
 }

+ 35 - 38
fs-service-system/src/main/java/com/fs/store/service/impl/FsPrescribeServiceImpl.java

@@ -12,12 +12,11 @@ import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.OrderUtils;
 import com.fs.common.utils.StringUtils;
 import com.fs.store.bean.Drug;
+import com.fs.store.bean.DrugV2;
 import com.fs.store.bean.Prescribe;
+import com.fs.store.bean.PrescribeV2;
 import com.fs.store.domain.*;
-import com.fs.store.param.FsPrescribeParam;
-import com.fs.store.param.FsPrescribeQueryParam;
-import com.fs.store.param.FsPrescribeVOParam;
-import com.fs.store.param.PrescribeParam;
+import com.fs.store.param.*;
 import com.fs.store.service.*;
 import com.fs.store.vo.FsPrescribeVO;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -143,49 +142,47 @@ public class FsPrescribeServiceImpl implements IFsPrescribeService
         String rpId=OrderUtils.getOrderNo();
         FsPatient patient=patientService.selectFsPatientById(param.getPatientId());
         FsUser user=userService.selectFsUserById(userId);
-        PrescribeParam prescribeParam=new PrescribeParam();
-        List<Prescribe> data=new ArrayList<>();
-        Prescribe prescribe=new Prescribe();
-        prescribe.setRp_type("01");
-        prescribe.setRp_id(rpId);
-        prescribe.setPharmacy_code("00001");
-        prescribe.setPharmacy_name("零利润药房");
-        prescribe.setPatient_name(patient.getPatientName());
-        prescribe.setPatient_age(DateUtils.getAge(patient.getBirthday()));
-        prescribe.setPatient_tel(user.getPhone());
-        prescribe.setPatient_gender(patient.getGender().toString());
-        prescribe.setIs_history_allergic(param.getIsAllergic()?"是":"否");
-        prescribe.setLiver_unusual(param.getIsLiver()?"是":"否");
-        prescribe.setRenal_unusual(param.getIsRenal()?"是":"否");
-        prescribe.setLactation_flag(param.getIsLactation()?"是":"否");
-        prescribe.setChief_complaint(param.getChiefComplaint());
-        prescribe.setNow_illness(param.getNowIllness());
-        prescribe.setHistory_illness(param.getHistoryIllness());
+        PrescribeV2Param prescribeParam=new PrescribeV2Param();
+        PrescribeV2 prescribe=new PrescribeV2();
+        prescribe.setDrugType("01");
+        prescribe.setOnlyId(rpId);
+        prescribe.setDrugstoreName("零利润药房");
+        prescribe.setPatientName(patient.getPatientName());
+        prescribe.setPatientAge(DateUtils.getAge(patient.getBirthday()));
+//        prescribe.setPatientTel(user.getPhone());
+        prescribe.setPatientSex(patient.getGender());
+        prescribe.setPatientAllergy(param.getIsAllergic()?1:0);
+        prescribe.setLiverUnusual(param.getIsLiver()?1:0);
+        prescribe.setRenalUnusual(param.getIsRenal()?1:0);
+        prescribe.setLactationFlag(param.getIsLactation()?1:0);
+        prescribe.setChiefComplaint(param.getChiefComplaint());
+        prescribe.setNowIllness(param.getNowIllness());
+        prescribe.setHistoryIllness(param.getHistoryIllness());
         if(StringUtils.isNotEmpty(param.getRecordPic())){
-            prescribe.setRecord_pic(param.getRecordPic().split(","));
+            prescribe.setRecordPic(param.getRecordPic().split(","));
         }
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         Date now = new Date();
-        prescribe.setRp_create_time(sdf.format(now));
-        prescribe.setRp_url_type("png");
-        prescribe.setLactation_flag("否");
-        prescribe.setCallback_url(fsSysConfig.getCallbackUrl());
-        data.add(prescribe);
+        prescribe.setCreateTime(sdf.format(now));
+        prescribe.setPictureType("png");
+//        prescribe.setLactationFlag("否");
+        prescribe.setCallbackUrl(fsSysConfig.getCallbackUrl());
 
-        List<Drug> drug_list=new ArrayList<>();
+        List<DrugV2> drug_list=new ArrayList<>();
         for(FsStoreOrderItem item:items){
             FsStoreProduct product=productService.selectFsStoreProductById(item.getProductId());
-            Drug drug=new Drug();
-            drug.setDrug_common_name(product.getPrescribeName());
-            drug.setDrug_specification(product.getPrescribeSpec());
-            drug.setSale_amount(item.getNum().toString());
-            drug.setSale_unit(product.getUnitName());
-            drug.setApproval_number(product.getPrescribeCode());
+            DrugV2 drug=new DrugV2();
+            drug.setDrugCommonName(product.getPrescribeName());
+            drug.setDrugSpecification(product.getPrescribeSpec());
+            drug.setSaleAmount(item.getNum().toString());
+            drug.setSaleUnit(product.getUnitName());
+            drug.setApprovalNumber(product.getPrescribeCode());
+            drug.setDrugCode(product.getProductId());
             drug_list.add(drug);
-            prescribe.setDrug_list(drug_list);
-            prescribeParam.setData(data);
+            prescribe.setDrugList(drug_list);
+            prescribeParam.setData(prescribe);
         }
-        R response=prescribeService.doPrescribe(prescribeParam);
+        R response=prescribeService.doPrescribeV2(prescribeParam);
         if(response.get("code").equals(200)){
             FsPrescribe fsPrescribe=new FsPrescribe();
             fsPrescribe.setRpId(rpId);

+ 30 - 0
fs-service-system/src/main/java/com/fs/store/service/impl/PrescribeServiceImpl.java

@@ -1,12 +1,16 @@
 package com.fs.store.service.impl;
 
 import cn.hutool.http.HttpRequest;
+import cn.hutool.http.HttpResponse;
+import cn.hutool.http.HttpUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.fs.common.config.FSSysConfig;
 import com.fs.common.core.domain.R;
 import com.fs.common.utils.sign.Md5Utils;
 import com.fs.store.param.PrescribeParam;
+import com.fs.store.param.PrescribeV2Param;
 import com.fs.store.service.IPrescribeService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -49,4 +53,30 @@ public class PrescribeServiceImpl implements IPrescribeService
             return R.error(msg);
         }
     }
+
+    @Override
+    public R doPrescribeV2(PrescribeV2Param param) {
+        param.setAccessKeyID(fsSysConfig.getAccessKeyID());
+        param.setAccessKeySecret(fsSysConfig.getAccessKeySecret());
+        param.setTimestamp(String.valueOf(new Date().getTime()));
+        //计算签名,计算法为 md5(act_id&manu_id&app_id&timestamp),把⼊参act_id、
+        //manu_id、app_id、timestamp四个参数通过&拼接起来,返回MD5加密⼤写字符串
+        param.setSig(Md5Utils.hash(param.getAccessKeyID()+"&"+param.getAccessKeySecret()+"&"+param.getTimestamp()).toUpperCase(Locale.ROOT));
+
+        HttpRequest request = HttpUtil.createPost(fsSysConfig.getPrescribeUrl()).body(JSON.toJSONString(param.getData()));
+        request.header("Content-Type", "application/json;charset=utf-8");
+        request.header("accessKeyID", param.getAccessKeyID());
+        request.header("accessKeySecret", param.getAccessKeySecret());
+        request.header("timestamp", param.getTimestamp());
+        request.header("sig", param.getSig());
+        HttpResponse execute = request.execute();
+        JSONObject json = JSON.parseObject(execute.body());
+        String code=json.getString("code");
+        String msg=json.getString("msg");
+        if(code.equals("1000")){
+            return R.ok("提交成功");
+        }else{
+            return R.error(msg);
+        }
+    }
 }

+ 13 - 0
fs-service-system/src/main/java/com/fs/store/vo/DrugDataV2VO.java

@@ -0,0 +1,13 @@
+package com.fs.store.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class DrugDataV2VO implements Serializable {
+    String drugName;//药品名称
+    String saleAmount;//药品数量
+    String prescriptionUrl;//药品规格
+
+}

+ 24 - 0
fs-service-system/src/main/java/com/fs/store/vo/PrescribeDataV2VO.java

@@ -0,0 +1,24 @@
+package com.fs.store.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+@Data
+public class PrescribeDataV2VO implements Serializable {
+    String onlyId;//处⽅单ID(唯⼀ID)
+    String departName;//科室名称
+    String doctorName;//医生名字
+    String pharmacistName;//对应药师的名称
+    String prescriptionUrl;//处方图片地址
+    Date createDate;//处方开具时间
+    String diagnose;//诊断
+    String status;//处方状态:已开方、待开方、开方中、已拒绝、已驳回
+    String auditReason;//医生拒方原因
+    String pharmacyCode;//药店code
+    String pharmacyName;//药店名称
+    String hospitalName;//医院名称
+    List<DrugDataV2VO> drugInfo;
+}

+ 13 - 0
fs-service-system/src/main/java/com/fs/store/vo/PrescribeV2VO.java

@@ -0,0 +1,13 @@
+package com.fs.store.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class PrescribeV2VO implements Serializable {
+    String msg;
+    String code;//1000成功
+    PrescribeDataV2VO data;
+
+}

+ 10 - 8
fs-service-system/src/main/resources/application-config.yml

@@ -23,18 +23,20 @@ fsConfig:
   # 腾讯云IM
   sdkAppId: 1400693126
   sdkAppKey: 9afa6e63db943293680e37b3ba032e52cdb238112750806e82e58e9240604b70
-  # 处方接口Test
-#  prescribeUrl: https://yixian-new-test.yixianmedical.com/platform-shenfang/nethosp/webservice/jsonapi
-#  actId:  uporder
-#  appId: 1646204278
-#  manuId:  3981112bfcc64bf68f7744ffec7e3ca7
-#  callbackUrl:  https://api.hospital.ifeiyu100.com/app/prescribe/presribeNotify
-  # 处方接口g
-  prescribeUrl: https://app3.nxk520.com/platform-shenfang/nethosp/webservice/jsonapi
+  # 处方接口 TEST
+  prescribeUrl: https://sf-open-test.minzhongyl.com/api/open/api/cloud-prescription/send-order
   actId: uporder
   appId: 1661496555
   manuId: 0212af1e742b41b09089afeec98f8276
+  accessKeyID: 1734402449
+  accessKeySecret: 5e946b3986944bd6aae69167ee1f75e6
   callbackUrl: https://api.yjf.runtzh.com/app/prescribe/presribeNotify
+  # 处方接口g
+#  prescribeUrl: https://app3.nxk520.com/platform-shenfang/nethosp/webservice/jsonapi
+#  actId: uporder
+#  appId: 1661496555
+#  manuId: 0212af1e742b41b09089afeec98f8276
+#  callbackUrl: https://api.yjf.runtzh.com/app/prescribe/presribeNotify
 logging:
   level:
     org.springframework.web: INFO

+ 15 - 12
fs-user-app/src/main/java/com/fs/app/controller/PrescribeController.java

@@ -3,6 +3,7 @@ import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.fs.app.annotation.Login;
+import com.fs.store.vo.PrescribeV2VO;
 import com.fs.common.core.domain.R;
 import com.fs.common.event.TemplateBean;
 import com.fs.common.event.TemplateEvent;
@@ -16,12 +17,12 @@ import com.fs.store.service.IFsPrescribeService;
 import com.fs.store.service.IFsStoreOrderItemService;
 import com.fs.store.service.IFsStoreOrderService;
 import com.fs.store.vo.FsPrescribeVO;
-import com.fs.store.vo.PrescribeVO;
 import com.github.binarywang.wxpay.service.WxPayService;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationEventPublisher;
 import org.springframework.validation.annotation.Validated;
@@ -32,6 +33,7 @@ import java.util.Date;
 import java.util.List;
 
 
+@Slf4j
 @Api("处方接口")
 @RestController
 @RequestMapping(value="/app/prescribe")
@@ -81,18 +83,19 @@ public class PrescribeController extends  AppBaseController {
     {
         // 封装JSON请求
         //{"msg":"成功","code":1000,"data":{"rp_id":"202203151003300001","order_id":null,"depart_name":"内科","doctor_name":"测试账号","pharmacist_name":null,"rp_url":"https://asset.nxk520.com/202203-go/C2203151057038646.png","diagnose":"眼睑带状疱疹","rp_msg":"已开方","audit_reason":null,"drugInfo":[{"drug_name":"维力青 恩替卡韦分散片 0.5mg*7片","sale_amount":1,"drug_specification":"0.5mg*7片"}],"create_date":"2022-03-15 10:03:30","pharmacy_code":"00001","pharmacy_name":"测试门店","doctor_id":"383"}}
+        log.info("处方回调数据:{}",jsonBody);
         JSONObject json = JSON.parseObject(jsonBody);
-        PrescribeVO vo= JSONUtil.toBean(jsonBody, PrescribeVO.class);
+        PrescribeV2VO vo= JSONUtil.toBean(jsonBody, PrescribeV2VO.class);
         if(vo.getCode().equals("1000")){
-            if(vo.getData().getRp_msg().equals("已开方")){
-                FsPrescribe fsPrescribe=prescribeService.selectFsPrescribeByRpId(vo.getData().getRp_id());
-                fsPrescribe.setRpUrl(vo.getData().getRp_url());
+            if(vo.getData().getStatus().equals("已开方")){
+                FsPrescribe fsPrescribe=prescribeService.selectFsPrescribeByRpId(vo.getData().getOnlyId());
+                fsPrescribe.setRpUrl(vo.getData().getPrescriptionUrl());
                 fsPrescribe.setRpCreateTime(new Date());
-                fsPrescribe.setDoctorName(vo.getData().getDoctor_name());
+                fsPrescribe.setDoctorName(vo.getData().getDoctorName());
                 fsPrescribe.setDiagnose(vo.getData().getDiagnose());
                 fsPrescribe.setDrugs(JSONUtil.toJsonStr(vo.getData().getDrugInfo()));
                 fsPrescribe.setStatus(1);
-                fsPrescribe.setAuditReason(vo.getData().getAudit_reason());
+                fsPrescribe.setAuditReason(vo.getData().getAuditReason());
                 prescribeService.updateFsPrescribe(fsPrescribe);
                 //创建OMS订单
                 FsStoreOrder order= orderService.selectFsStoreOrderById(fsPrescribe.getOrderId());
@@ -110,15 +113,15 @@ public class PrescribeController extends  AppBaseController {
                 publisher.publishEvent(new TemplateEvent(this, templateBean));
 
             }
-            else if(vo.getData().getRp_msg().equals("已拒绝")){
-                FsPrescribe fsPrescribe=prescribeService.selectFsPrescribeByRpId(vo.getData().getRp_id());
-                fsPrescribe.setRpUrl(vo.getData().getRp_url());
+            else if(vo.getData().getStatus().equals("已拒绝")){
+                FsPrescribe fsPrescribe=prescribeService.selectFsPrescribeByRpId(vo.getData().getOnlyId());
+                fsPrescribe.setRpUrl(vo.getData().getPrescriptionUrl());
                 fsPrescribe.setRpCreateTime(new Date());
-                fsPrescribe.setDoctorName(vo.getData().getDoctor_name());
+                fsPrescribe.setDoctorName(vo.getData().getDoctorName());
                 fsPrescribe.setDiagnose(vo.getData().getDiagnose());
                 fsPrescribe.setDrugs(JSONUtil.toJsonStr(vo.getData().getDrugInfo()));
                 fsPrescribe.setStatus(2);
-                fsPrescribe.setAuditReason(vo.getData().getAudit_reason());
+                fsPrescribe.setAuditReason(vo.getData().getAuditReason());
                 prescribeService.updateFsPrescribe(fsPrescribe);
                 //自动退款
                 orderService.refundPrescribeOrder(fsPrescribe.getOrderId());