新增系统商品
This commit is contained in:
@@ -56,37 +56,37 @@ type ReportPreRequest struct {
|
||||
|
||||
// PresRequest 上报处方请求值-处方数据
|
||||
type PresRequest struct {
|
||||
PrescriptionNo string `json:"prescriptionNo"` // 处方编号
|
||||
PrescriptionSubType int `json:"prescriptionSubType"` // 处方类型 0:无类型 1:普通处方 2:儿科处方
|
||||
PatientName string `json:"patientName"` // 就诊人姓名
|
||||
PatientPhone string `json:"patientPhone"` // 就诊人联系方式
|
||||
IdCard string `json:"idCard"` // 身份证号
|
||||
Advice string `json:"advice"` // 医嘱
|
||||
DiagnosisName string `json:"diagnosisName"` // 诊断
|
||||
ThirdDoctorName string `json:"thirdDoctorName"` // 开方医生姓名
|
||||
ThirdDeptName string `json:"thirdDeptName"` // 开方科室名称
|
||||
ThirdDoctorNameImg string `json:"thirdDoctorNameImg"` // 开方医生签名链接
|
||||
PrescriptionTime string `json:"prescriptionTime"` // 开方时间
|
||||
ThirdFirstPharmacist string `json:"thirdFirstPharmacist"` // 初审药师姓名
|
||||
ThirdFirstPharmacistImg string `json:"thirdFirstPharmacistImg"` // 初审药师签名链接
|
||||
ThirdFirstTime string `json:"thirdFirstTime"` // 初审时间
|
||||
ThirdLastPharmacist string `json:"thirdLastPharmacist"` // 终审药师姓名
|
||||
ThirdLastPharmacistImg string `json:"thirdLastPharmacistImg"` // 终审药师签名链接
|
||||
ThirdLastTime string `json:"ThirdLastTime"` // 终审时间
|
||||
ThirdSignImg string `json:"thirdSignImg"` // 处方签章链接
|
||||
ReferenceCharge float64 `json:"referenceCharge"` // 处方费用(不包含运费)
|
||||
ChiefComplaint string `json:"chiefComplaint"` // 主诉
|
||||
HistoryPresent string `json:"historyPresent"` // 现病史
|
||||
PastHistory string `json:"pastHistory"` // 既往史
|
||||
PhysicalExamination string `json:"physicalExamination"` // 体格检查
|
||||
SupplementaryExamination string `json:"supplementaryExamination"` // 辅助检查
|
||||
AllergicHistory string `json:"allergicHistory"` // 过敏史
|
||||
DrugList []DrugRequest `json:"drugList"` // 药品列表
|
||||
OrderDrugList []OrderDrugRequest `json:"orderDrugList"` // 订单药品列表
|
||||
PrescriptionNo string `json:"prescriptionNo"` // 处方编号
|
||||
PrescriptionSubType int `json:"prescriptionSubType"` // 处方类型 0:无类型 1:普通处方 2:儿科处方
|
||||
PatientName string `json:"patientName"` // 就诊人姓名
|
||||
PatientPhone string `json:"patientPhone"` // 就诊人联系方式
|
||||
IdCard string `json:"idCard"` // 身份证号
|
||||
Advice string `json:"advice"` // 医嘱
|
||||
DiagnosisName string `json:"diagnosisName"` // 诊断
|
||||
ThirdDoctorName string `json:"thirdDoctorName"` // 开方医生姓名
|
||||
ThirdDeptName string `json:"thirdDeptName"` // 开方科室名称
|
||||
ThirdDoctorNameImg string `json:"thirdDoctorNameImg"` // 开方医生签名链接
|
||||
PrescriptionTime string `json:"prescriptionTime"` // 开方时间
|
||||
ThirdFirstPharmacist string `json:"thirdFirstPharmacist"` // 初审药师姓名
|
||||
ThirdFirstPharmacistImg string `json:"thirdFirstPharmacistImg"` // 初审药师签名链接
|
||||
ThirdFirstTime string `json:"thirdFirstTime"` // 初审时间
|
||||
ThirdLastPharmacist string `json:"thirdLastPharmacist"` // 终审药师姓名
|
||||
ThirdLastPharmacistImg string `json:"thirdLastPharmacistImg"` // 终审药师签名链接
|
||||
ThirdLastTime string `json:"ThirdLastTime"` // 终审时间
|
||||
ThirdSignImg string `json:"thirdSignImg"` // 处方签章链接
|
||||
ReferenceCharge float64 `json:"referenceCharge"` // 处方费用(不包含运费)
|
||||
ChiefComplaint string `json:"chiefComplaint"` // 主诉
|
||||
HistoryPresent string `json:"historyPresent"` // 现病史
|
||||
PastHistory string `json:"pastHistory"` // 既往史
|
||||
PhysicalExamination string `json:"physicalExamination"` // 体格检查
|
||||
SupplementaryExamination string `json:"supplementaryExamination"` // 辅助检查
|
||||
AllergicHistory string `json:"allergicHistory"` // 过敏史
|
||||
DrugList []DrugListRequest `json:"drugList"` // 药品列表
|
||||
OrderDrugList []OrderDrugListRequest `json:"orderDrugList"` // 订单药品列表
|
||||
}
|
||||
|
||||
// DrugRequest 上报处方请求值-药品数据1
|
||||
type DrugRequest struct {
|
||||
// DrugListRequest 上报处方请求值-药品数据1
|
||||
type DrugListRequest struct {
|
||||
DrugCode string `json:"drugCode"` // 药品编码
|
||||
ApprovalNumber string `json:"approvalNumber"` // 批准文号
|
||||
DrugName string `json:"drugName"` // 药品名称
|
||||
@@ -102,8 +102,8 @@ type DrugRequest struct {
|
||||
UseDays int `json:"useDays"` // 使用天数
|
||||
}
|
||||
|
||||
// OrderDrugRequest 上报处方请求值-药品数据2
|
||||
type OrderDrugRequest struct {
|
||||
// OrderDrugListRequest 上报处方请求值-药品数据2
|
||||
type OrderDrugListRequest struct {
|
||||
DrugCode string `json:"drugCode"` // 药品编码
|
||||
ApprovalNumber string `json:"approvalNumber"` // 批准文号
|
||||
DrugName string `json:"drugName"` // 药品名称
|
||||
@@ -113,12 +113,30 @@ type OrderDrugRequest struct {
|
||||
PackingUnit string `json:"packingUnit"` // 药品单位
|
||||
}
|
||||
|
||||
// GetProdStockRequest 获取商品库存请求值
|
||||
type GetProdStockRequest struct {
|
||||
PharmacyCode string `json:"pharmacyCode"` // 药房编码
|
||||
DrugCode string `json:"drugCode"` // 三方药房药品编码
|
||||
}
|
||||
|
||||
// 上报处方返回数据
|
||||
type reportPreResponse struct {
|
||||
ResultCode string `json:"resultCode"` // 操作编码
|
||||
ResultDesc string `json:"resultDesc"` // 描述
|
||||
}
|
||||
|
||||
// 获取商品库存返回数据
|
||||
type getProdStockResponse struct {
|
||||
ResultCode string `json:"resultCode"` // 操作编码
|
||||
ResultDesc string `json:"resultDesc"` // 描述
|
||||
Data GetProdStockDataResponse `json:"data"` // 具体内容
|
||||
}
|
||||
|
||||
type GetProdStockDataResponse struct {
|
||||
Quantity string `json:"quantity"` // 库存
|
||||
Threshold string `json:"threshold"` // 库存阈值
|
||||
}
|
||||
|
||||
// GetToken 获取token
|
||||
func GetToken() (string, error) {
|
||||
// 准备要发送的 JSON 数据
|
||||
@@ -328,3 +346,68 @@ func (r ReportPreRequest) ReportPre() (bool, error) {
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// GetProdStock 获取商品库存
|
||||
func (r GetProdStockRequest) GetProdStock() (*GetProdStockDataResponse, error) {
|
||||
r.PharmacyCode = config.C.Pre.PrePlatPharmacyCode
|
||||
jsonData, err := json.Marshal(r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 准备请求体
|
||||
requestBody := bytes.NewBuffer(jsonData)
|
||||
|
||||
// 设置请求 URL
|
||||
url := config.C.Pre.PrePlatAppUrl + "v1/pharmacy/pharmacyInventory"
|
||||
|
||||
// 创建 POST 请求
|
||||
req, err := http.NewRequest("POST", url, requestBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 设置请求头,指定 Content-Type 为 application/json
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
token, _ := global.Redis.Get(context.Background(), "prescription_token").Result()
|
||||
if token == "" {
|
||||
token, err = GetToken()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
req.Header.Set("Authorization", "Bearer "+token)
|
||||
|
||||
// 发送请求
|
||||
client := &http.Client{}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer func(Body io.ReadCloser) {
|
||||
_ = Body.Close()
|
||||
}(resp.Body)
|
||||
|
||||
// 检查响应状态码
|
||||
if resp.StatusCode != 200 {
|
||||
return nil, errors.New("返回数据错误")
|
||||
}
|
||||
|
||||
var response getProdStockResponse
|
||||
err = json.NewDecoder(resp.Body).Decode(&response)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if response.ResultCode != "1000" {
|
||||
if response.ResultDesc != "" {
|
||||
return nil, errors.New(response.ResultDesc)
|
||||
}
|
||||
return nil, errors.New("获取商品库存失败")
|
||||
}
|
||||
|
||||
return &response.Data, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user