test_user 6 days ago
parent
commit
52858b51d6
3 changed files with 71 additions and 30 deletions
  1. 28 17
      controllers/sg/his_api_controller.go
  2. 42 12
      service/ah_dianzichufang.go
  3. 1 1
      service/his_service.go

+ 28 - 17
controllers/sg/his_api_controller.go View File

34
 	"syscall"
34
 	"syscall"
35
 	"time"
35
 	"time"
36
 	"unsafe"
36
 	"unsafe"
37
+	"github.com/go-ole/go-ole"
38
+
37
 )
39
 )
38
 
40
 
39
 type HisApiController struct {
41
 type HisApiController struct {
8004
 	patient_id, _ := c.GetInt64("patient_id")
8006
 	patient_id, _ := c.GetInt64("patient_id")
8005
 	his_patient_id, _ := c.GetInt64("his_patient_id")
8007
 	his_patient_id, _ := c.GetInt64("his_patient_id")
8006
 	record_time := c.GetString("record_time")
8008
 	record_time := c.GetString("record_time")
8007
-	admin_user_id = 3626
8008
 	his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
8009
 	his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
8009
 	psn, _ := service.GetPsnByPatientId(patient_id)
8010
 	psn, _ := service.GetPsnByPatientId(patient_id)
8010
 	curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
8011
 	curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
8067
 			}
8068
 			}
8068
 		}
8069
 		}
8069
 		cFYLJG001.RxDrugCnt = count
8070
 		cFYLJG001.RxDrugCnt = count
8070
-		cFYLJG001.ValiDays = "5"
8071
+		cFYLJG001.ValiDays = "2"
8071
 		ts := time.Unix(item.PreTime, 0)
8072
 		ts := time.Unix(item.PreTime, 0)
8072
-		record_time2 := ts.AddDate(0, 0, int(5)).Unix()
8073
+		record_time2 := ts.AddDate(0, 0, int(2)).Unix()
8073
 		tempTime3 := time.Unix(record_time2, 0)
8074
 		tempTime3 := time.Unix(record_time2, 0)
8074
 		timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
8075
 		timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
8075
 		cFYLJG001.ValiEndTime = timeFormat3
8076
 		cFYLJG001.ValiEndTime = timeFormat3
8147
 		tempTime6 := time.Unix(tempTime2, 0)
8148
 		tempTime6 := time.Unix(tempTime2, 0)
8148
 		timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
8149
 		timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
8149
 		cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
8150
 		cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
8150
-		cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
8151
+		cFYLJG001.Mdtrtinfo.DiseCodg = ""
8151
 		cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
8152
 		cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
8152
-		cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
8153
-		cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
8153
+		cFYLJG001.Mdtrtinfo.MaindiagCode = "I10.x00x002"
8154
+		cFYLJG001.Mdtrtinfo.MaindiagName = "高血压"
8154
 
8155
 
8155
 		diagnosis_ids := strings.Split(info.Diagnosis, ",")
8156
 		diagnosis_ids := strings.Split(info.Diagnosis, ",")
8156
 		var config []*models.HisXtDiagnoseConfig
8157
 		var config []*models.HisXtDiagnoseConfig
8193
 		if miConfig.MdtrtareaAdmvs == "340699" {
8194
 		if miConfig.MdtrtareaAdmvs == "340699" {
8194
 			result, request := service.GetAHCFYLJG001("http://10.66.149.64:8080/epc/api", cFYLJG001, his.Insutype)
8195
 			result, request := service.GetAHCFYLJG001("http://10.66.149.64:8080/epc/api", cFYLJG001, his.Insutype)
8195
 			saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
8196
 			saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
8196
-			var res ResultCFYLJG001
8197
+			var res ResultCFYLJG001AH
8197
 			var respJSON2 map[string]interface{}
8198
 			var respJSON2 map[string]interface{}
8198
 			if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
8199
 			if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
8199
 				utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
8200
 				utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
8206
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
8207
 				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
8207
 				return
8208
 				return
8208
 			}
8209
 			}
8209
-			if res.Infcode == -1 {
8210
-				c.ServeSuccessJSON(map[string]interface{}{
8211
-					"failed_code": -10,
8212
-					"msg":         res.ErrMsg,
8213
-				})
8214
-				return
8215
 
8210
 
8216
-			} else {
8217
 				var flow models.HisPrescriptionFlow
8211
 				var flow models.HisPrescriptionFlow
8218
 				flow.Ctime = time.Now().Unix()
8212
 				flow.Ctime = time.Now().Unix()
8219
 				flow.SignDigest = ""
8213
 				flow.SignDigest = ""
8220
-				flow.RxTraceCode = res.Output.RxTraceCode
8221
-				flow.HiRxno = res.Output.HiRxno
8214
+				flow.RxTraceCode = res.RxTraceCode
8215
+				flow.HiRxno = res.HiRxno
8222
 				flow.MID = his.Number
8216
 				flow.MID = his.Number
8223
 				flow.Status = 1
8217
 				flow.Status = 1
8224
 				flow.DCode = doctor_info.DoctorNumber
8218
 				flow.DCode = doctor_info.DoctorNumber
8233
 				c.ServeSuccessJSON(map[string]interface{}{
8227
 				c.ServeSuccessJSON(map[string]interface{}{
8234
 					"msg": "上传成功",
8228
 					"msg": "上传成功",
8235
 				})
8229
 				})
8236
-			}
8230
+
8237
 
8231
 
8238
 		} else {
8232
 		} else {
8239
 			result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
8233
 			result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
25398
 	WarnInfo    interface{} `json:"warn_info"`
25392
 	WarnInfo    interface{} `json:"warn_info"`
25399
 }
25393
 }
25400
 
25394
 
25395
+type ResultCFYLJG001AH struct {
25396
+		RxTraceCode string `json:"rxTraceCode"`
25397
+		HiRxno      string `json:"hiRxno"`
25398
+
25399
+}
25400
+
25401
 type ResultCFYLJG007 struct {
25401
 type ResultCFYLJG007 struct {
25402
 	ErrMsg      string `json:"err_msg"`
25402
 	ErrMsg      string `json:"err_msg"`
25403
 	InfRefmsgid string `json:"inf_refmsgid"`
25403
 	InfRefmsgid string `json:"inf_refmsgid"`
32231
 				data["sick_code"] = sickConfig.CountryCode
32231
 				data["sick_code"] = sickConfig.CountryCode
32232
 				data["sick_name"] = sickConfig.ClassName
32232
 				data["sick_name"] = sickConfig.ClassName
32233
 			}
32233
 			}
32234
+			if reg_type == 11 {
32235
+				med_type = "11"
32236
+				data["sick_code"] = sickConfig.CountryCode
32237
+				data["sick_name"] = sickConfig.ClassName
32238
+			}
32234
 		} else if his.Insutype == "310" {
32239
 		} else if his.Insutype == "310" {
32235
 			if reg_type == 992102 {
32240
 			if reg_type == 992102 {
32236
 				med_type = "992102"
32241
 				med_type = "992102"
32253
 				data["sick_code"] = sickConfig.CountryCode
32258
 				data["sick_code"] = sickConfig.CountryCode
32254
 				data["sick_name"] = sickConfig.ClassName
32259
 				data["sick_name"] = sickConfig.ClassName
32255
 			}
32260
 			}
32261
+
32262
+			if reg_type == 11 {
32263
+				med_type = "11"
32264
+				data["sick_code"] = sickConfig.CountryCode
32265
+				data["sick_name"] = sickConfig.ClassName
32266
+			}
32256
 		}
32267
 		}
32257
 
32268
 
32258
 		data["med_type"] = med_type
32269
 		data["med_type"] = med_type

+ 42 - 12
service/ah_dianzichufang.go View File

8
 	"io/ioutil"
8
 	"io/ioutil"
9
 	"net/http"
9
 	"net/http"
10
 	"os/exec"
10
 	"os/exec"
11
+	"strings"
11
 )
12
 )
12
 
13
 
13
 func GetAHCFYLJG001(url string, cFYLJG001 models.CFYLJG001, isu string) (string, string) {
14
 func GetAHCFYLJG001(url string, cFYLJG001 models.CFYLJG001, isu string) (string, string) {
161
 	var inputLog string
162
 	var inputLog string
162
 	bytesData, err := json.Marshal(inputData)
163
 	bytesData, err := json.Marshal(inputData)
163
 	inputLog = string(bytesData)
164
 	inputLog = string(bytesData)
164
-	cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "19D43125C3E64BB784601F7B19A8D785", "6014F1F2CA6247F8960AF61A306B5DCC", "Ns0K7Gsxk1WSfxYYyBcCL3J4Q/2Tvp1bMe8JbakA9Fg=", inputLog)
165
+	fmt.Println(inputLog)
166
+
167
+	cmd := exec.Command("java", "-jar", "encrypt-utils-all.jar", "encrypt", "19D43125C3E64BB784601F7B19A8D785", "6014F1F2CA6247F8960AF61A306B5DCC", "Ns0K7Gsxk1WSfxYYyBcCL3J4Q/2Tvp1bMe8JbakA9Fg=", inputLog)
168
+
165
 	out, err := cmd.Output()
169
 	out, err := cmd.Output()
166
-	fmt.Println(string(out))
167
-	if err != nil {
168
-		fmt.Println("error:", err.Error())
169
-		return err.Error(), ""
170
-	}
171
-	reader := bytes.NewReader(out)
170
+
171
+	aa := strings.Split(string(out),"======")
172
+	fmt.Println(aa[1])
173
+
174
+	reader := bytes.NewReader([]byte(aa[1]))
172
 	url = url + "/fixmedins/uploadChk"
175
 	url = url + "/fixmedins/uploadChk"
176
+	fmt.Println(url)
177
+
173
 	request, err := http.NewRequest("POST", url, reader)
178
 	request, err := http.NewRequest("POST", url, reader)
179
+
174
 	if err != nil {
180
 	if err != nil {
175
 		fmt.Println(err.Error())
181
 		fmt.Println(err.Error())
176
 		return err.Error(), ""
182
 		return err.Error(), ""
178
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
184
 	request.Header.Set("Content-Type", "application/json;charset=UTF-8")
179
 	client := http.Client{}
185
 	client := http.Client{}
180
 	resp, err := client.Do(request)
186
 	resp, err := client.Do(request)
187
+
188
+
181
 	if err != nil {
189
 	if err != nil {
182
 		fmt.Println(err.Error())
190
 		fmt.Println(err.Error())
183
 		return err.Error(), ""
191
 		return err.Error(), ""
184
 	}
192
 	}
185
 	respBytes, err := ioutil.ReadAll(resp.Body)
193
 	respBytes, err := ioutil.ReadAll(resp.Body)
194
+
186
 	if err != nil {
195
 	if err != nil {
187
 		fmt.Println(err.Error())
196
 		fmt.Println(err.Error())
188
 		return err.Error(), ""
197
 		return err.Error(), ""
189
 	}
198
 	}
190
 	str := string(respBytes)
199
 	str := string(respBytes)
191
-	return str, inputLog
200
+
201
+	var data2 map[string]interface{}
202
+
203
+	// 解析 JSON 字符串到 map
204
+	 json.Unmarshal([]byte(str), &data2)
205
+
206
+	// 检查 code 字段是否存在,并将其转换为字符串
207
+	if val, ok := data2["code"]; ok {
208
+		data2["code"] = fmt.Sprintf("%v", val) // 将 code 转换为字符串
209
+	}
210
+
211
+	// 将处理后的数据重新转换为 JSON 字符串
212
+	updatedJSON2, _ := json.Marshal(data2)
213
+
214
+
215
+	fmt.Println(string(updatedJSON2))
216
+	cmd2 := exec.Command("java", "-jar", "encrypt-utils-all.jar", "decrypt", "19D43125C3E64BB784601F7B19A8D785", "6014F1F2CA6247F8960AF61A306B5DCC", "BDoCErhDkP7KEG/BqNpjKIG5a3CapA8wbhXMNemzu+/fQD2kiW9rIDVLHxOEpAwnCuftjdZqf4Bz3x2gFShyk/8=", string(updatedJSON2))
217
+	out2, _ := cmd2.Output()
218
+	fmt.Println(string(out2))
219
+	bb := strings.Split(string(out2),"======")
220
+	fmt.Println(bb[1])
221
+	return bb[1], inputLog
192
 }
222
 }
193
 
223
 
194
 func GetAHCFYLJG002(fixmedins_code string, url string, original_value string, original_rx_file string, extras string) (string, string) {
224
 func GetAHCFYLJG002(fixmedins_code string, url string, original_value string, original_rx_file string, extras string) (string, string) {
207
 		fmt.Println(err.Error())
237
 		fmt.Println(err.Error())
208
 		return err.Error(), ""
238
 		return err.Error(), ""
209
 	}
239
 	}
210
-	cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "19D43125C3E64BB784601F7B19A8D785", "6014F1F2CA6247F8960AF61A306B5DCC", "Ns0K7Gsxk1WSfxYYyBcCL3J4Q/2Tvp1bMe8JbakA9Fg=", inputLog)
240
+	cmd := exec.Command("java", "-jar", "encrypt-utils-all.jar", "encrypt",  "19D43125C3E64BB784601F7B19A8D785", "6014F1F2CA6247F8960AF61A306B5DCC", "Ns0K7Gsxk1WSfxYYyBcCL3J4Q/2Tvp1bMe8JbakA9Fg=", inputLog)
211
 	out, err := cmd.Output()
241
 	out, err := cmd.Output()
212
 	fmt.Println(string(out))
242
 	fmt.Println(string(out))
213
 	reader := bytes.NewReader(out)
243
 	reader := bytes.NewReader(out)
263
 	var inputLog string
293
 	var inputLog string
264
 	bytesData, err := json.Marshal(inputData)
294
 	bytesData, err := json.Marshal(inputData)
265
 	inputLog = string(bytesData)
295
 	inputLog = string(bytesData)
266
-	cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "19D43125C3E64BB784601F7B19A8D785", "6014F1F2CA6247F8960AF61A306B5DCC", "Ns0K7Gsxk1WSfxYYyBcCL3J4Q/2Tvp1bMe8JbakA9Fg=", inputLog)
296
+	cmd := exec.Command("java", "-jar", "encrypt-utils-all.jar", "encrypt",  "19D43125C3E64BB784601F7B19A8D785", "6014F1F2CA6247F8960AF61A306B5DCC", "Ns0K7Gsxk1WSfxYYyBcCL3J4Q/2Tvp1bMe8JbakA9Fg=", inputLog)
267
 	out, err := cmd.Output()
297
 	out, err := cmd.Output()
268
 	fmt.Println(string(out))
298
 	fmt.Println(string(out))
269
-
299
+	aa := strings.Split(string(out),"======")
270
 	if err != nil {
300
 	if err != nil {
271
 		fmt.Println(err.Error())
301
 		fmt.Println(err.Error())
272
 		return err.Error(), ""
302
 		return err.Error(), ""
273
 	}
303
 	}
274
-	reader := bytes.NewReader(bytesData)
304
+	reader := bytes.NewReader([]byte(aa[1]))
275
 	url = url + "/fixmedins/rxFileUpld"
305
 	url = url + "/fixmedins/rxFileUpld"
276
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
306
 	//url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
277
 	request, err := http.NewRequest("POST", url, reader)
307
 	request, err := http.NewRequest("POST", url, reader)

+ 1 - 1
service/his_service.go View File

1679
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1679
 		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
1680
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
1680
 			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
1681
 		}).
1681
 		}).
1682
-		Where("(user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND p_type <> 1 and med_type = 148801) or (user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND p_type <> 1 and med_type = 118801)", org_id, record_date, patient_id, org_id, record_date, patient_id).
1682
+		Where("(user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND p_type <> 1 ) or (user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND p_type <> 1 )", org_id, record_date, patient_id, org_id, record_date, patient_id).
1683
 		Find(&prescription).Error
1683
 		Find(&prescription).Error
1684
 	return
1684
 	return
1685
 }
1685
 }