coordinate_service.go 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. package service
  2. import (
  3. "bytes"
  4. "encoding/json"
  5. "fmt"
  6. "gdyb/models"
  7. "github.com/jinzhu/gorm"
  8. "io/ioutil"
  9. "net/http"
  10. "time"
  11. )
  12. func SavePatientMessageInfo() (string, string) {
  13. //input := make(map[string]interface{})
  14. inputData := make(map[string]interface{})
  15. inputData["patType"] = "1" // 就诊凭证编号
  16. inputData["patIdNo"] = "440510199211080038" // 开始时间
  17. inputData["patName"] = "测试患者4 " // 人员姓名
  18. inputData["patMobile"] = "13535547902" // 人员姓名
  19. inputData["patSex"] = "M" // 人员姓名
  20. inputData["patMarriage"] = "1" // 人员姓名
  21. inputData["birthday"] = "1992-10-23" // 人员姓名
  22. inputData["patAddress"] = "11111" // 人员姓名
  23. inputData["thirdPartyID"] = "6936" // 人员姓名
  24. inputData["patAge"] = "30" // 人员姓名
  25. //input["req"] = inputData
  26. var inputLog string
  27. bytesData, err := json.Marshal(inputData)
  28. inputLog = string(bytesData)
  29. fmt.Println(string(bytesData))
  30. if err != nil {
  31. fmt.Println(err.Error())
  32. return err.Error(), ""
  33. }
  34. reader := bytes.NewReader(bytesData)
  35. var url string
  36. gdyb_url := "http://218.104.146.179:9091/esb/listener/savePatientMessageInfo"
  37. url = gdyb_url
  38. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  39. request, err := http.NewRequest("GET", url, reader)
  40. if err != nil {
  41. fmt.Println(err.Error())
  42. return err.Error(), ""
  43. }
  44. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  45. request.Header.Set("code", "Xmrjyy")
  46. client := http.Client{}
  47. resp, err := client.Do(request)
  48. if err != nil {
  49. fmt.Println(err.Error())
  50. return err.Error(), ""
  51. }
  52. respBytes, err := ioutil.ReadAll(resp.Body)
  53. if err != nil {
  54. fmt.Println(err.Error())
  55. return err.Error(), ""
  56. }
  57. fmt.Println(string(respBytes))
  58. str := string(respBytes)
  59. return str, inputLog
  60. }
  61. func SaveReg(reg models.Reg) (string, string) {
  62. //input := make(map[string]interface{})
  63. inputData := make(map[string]interface{})
  64. inputData["deptId"] = reg.DeptId
  65. inputData["clinicUnitId"] = ""
  66. inputData["healthCardNo"] = ""
  67. fmt.Println(reg.PatientId)
  68. inputData["patientId"] = reg.PatientId
  69. inputData["patientName"] = reg.PatientName
  70. inputData["idCardNo"] = reg.IdCardNo
  71. inputData["phone"] = ""
  72. inputData["doctorId"] = ""
  73. inputData["doctorLevelCode"] = ""
  74. inputData["regDate"] = reg.RegDate
  75. inputData["shiftCode"] = ""
  76. inputData["startTime"] = ""
  77. inputData["endTime"] = ""
  78. inputData["scheduleId"] = ""
  79. inputData["periodId"] = ""
  80. inputData["svObjectId"] = ""
  81. inputData["diseaseId"] = ""
  82. inputData["regFee"] = reg.RegFee
  83. inputData["treatFee"] = reg.TreatFee
  84. inputData["operatorId"] = reg.OperatorId
  85. inputData["remark"] = "血透"
  86. inputData["orderType"] = "0"
  87. inputData["clinicCode"] = ""
  88. inputData["infoSeq"] = ""
  89. //input["Request"] = inputData
  90. var inputLog string
  91. bytesData, err := json.Marshal(inputData)
  92. inputLog = string(bytesData)
  93. fmt.Println(string(bytesData))
  94. if err != nil {
  95. fmt.Println(err.Error())
  96. return err.Error(), ""
  97. }
  98. reader := bytes.NewReader(bytesData)
  99. var url string
  100. gdyb_url := "http://218.104.146.179:9091/esb/listener/saveReg"
  101. url = gdyb_url
  102. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  103. request, err := http.NewRequest("POST", url, reader)
  104. if err != nil {
  105. fmt.Println(err.Error())
  106. return err.Error(), ""
  107. }
  108. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  109. request.Header.Set("code", "Xmrjyy")
  110. client := http.Client{}
  111. resp, err := client.Do(request)
  112. if err != nil {
  113. fmt.Println(err.Error())
  114. return err.Error(), ""
  115. }
  116. respBytes, err := ioutil.ReadAll(resp.Body)
  117. if err != nil {
  118. fmt.Println(err.Error())
  119. return err.Error(), ""
  120. }
  121. fmt.Println(string(respBytes))
  122. str := string(respBytes)
  123. return str, inputLog
  124. }
  125. func GetWaitPayDetail() (string, string) {
  126. //input := make(map[string]interface{})
  127. inputData := make(map[string]interface{})
  128. inputData["clinicSeq"] = "30445" // 就诊凭证编号
  129. inputData["prescriptionId"] = "" // 开始时间
  130. inputData["patientId"] = "701822660170096645" // 人员姓名
  131. var inputLog string
  132. bytesData, err := json.Marshal(inputData)
  133. inputLog = string(bytesData)
  134. fmt.Println(string(bytesData))
  135. if err != nil {
  136. fmt.Println(err.Error())
  137. return err.Error(), ""
  138. }
  139. reader := bytes.NewReader(bytesData)
  140. var url string
  141. gdyb_url := "http://218.104.146.179:9091/esb/listener/getWaitPayDetail"
  142. url = gdyb_url
  143. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  144. request, err := http.NewRequest("POST", url, reader)
  145. if err != nil {
  146. fmt.Println(err.Error())
  147. return err.Error(), ""
  148. }
  149. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  150. request.Header.Set("code", "Xmrjyy")
  151. client := http.Client{}
  152. resp, err := client.Do(request)
  153. if err != nil {
  154. fmt.Println(err.Error())
  155. return err.Error(), ""
  156. }
  157. respBytes, err := ioutil.ReadAll(resp.Body)
  158. if err != nil {
  159. fmt.Println(err.Error())
  160. return err.Error(), ""
  161. }
  162. fmt.Println(string(respBytes))
  163. str := string(respBytes)
  164. return str, inputLog
  165. }
  166. func OpKeepAccounts(number string, cus []*models.NewCustomTwo) (string, string) {
  167. inputData := make(map[string]interface{})
  168. feedetail := make([]map[string]interface{}, 0)
  169. for _, item := range cus {
  170. feedetailInfo := make(map[string]interface{})
  171. feedetailInfo["itemCode"] = item.MedListCodg
  172. feedetailInfo["num"] = item.Cut
  173. feedetail = append(feedetail, feedetailInfo)
  174. }
  175. inputData["item"] = feedetail
  176. inputData["clinicSeq"] = number // 就诊凭证编号
  177. var inputLog string
  178. bytesData, err := json.Marshal(inputData)
  179. inputLog = string(bytesData)
  180. fmt.Println(string(bytesData))
  181. if err != nil {
  182. fmt.Println(err.Error())
  183. return err.Error(), ""
  184. }
  185. reader := bytes.NewReader(bytesData)
  186. var url string
  187. gdyb_url := "http://218.104.146.179:9091/esb/listener/opKeepAccounts"
  188. url = gdyb_url
  189. request, err := http.NewRequest("POST", url, reader)
  190. if err != nil {
  191. fmt.Println(err.Error())
  192. return err.Error(), ""
  193. }
  194. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  195. request.Header.Set("code", "Xmrjyy")
  196. client := http.Client{}
  197. resp, err := client.Do(request)
  198. if err != nil {
  199. fmt.Println(err.Error())
  200. return err.Error(), ""
  201. }
  202. respBytes, err := ioutil.ReadAll(resp.Body)
  203. if err != nil {
  204. fmt.Println(err.Error())
  205. return err.Error(), ""
  206. }
  207. fmt.Println(string(respBytes))
  208. str := string(respBytes)
  209. return str, inputLog
  210. }
  211. func OpCancelKeepAccounts(setl_id string, op_name string, op_code string) (string, string) {
  212. inputData := make(map[string]interface{})
  213. inputData["docId"] = setl_id
  214. inputData["operCode"] = "111"
  215. inputData["operName"] = "2222"
  216. var inputLog string
  217. bytesData, err := json.Marshal(inputData)
  218. inputLog = string(bytesData)
  219. fmt.Println(string(bytesData))
  220. if err != nil {
  221. fmt.Println(err.Error())
  222. return err.Error(), ""
  223. }
  224. reader := bytes.NewReader(bytesData)
  225. var url string
  226. gdyb_url := "http://218.104.146.179:9091/esb/listener/opCancelKeepAccounts"
  227. url = gdyb_url
  228. request, err := http.NewRequest("POST", url, reader)
  229. if err != nil {
  230. fmt.Println(err.Error())
  231. return err.Error(), ""
  232. }
  233. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  234. request.Header.Set("code", "Xmrjyy")
  235. client := http.Client{}
  236. resp, err := client.Do(request)
  237. if err != nil {
  238. fmt.Println(err.Error())
  239. return err.Error(), ""
  240. }
  241. respBytes, err := ioutil.ReadAll(resp.Body)
  242. if err != nil {
  243. fmt.Println(err.Error())
  244. return err.Error(), ""
  245. }
  246. fmt.Println(string(respBytes))
  247. str := string(respBytes)
  248. return str, inputLog
  249. }
  250. func UpdateHisPatientStatusten(his *models.VMHisPatient) {
  251. writeDb.Save(&his)
  252. }
  253. func GetUnSettleHisPrescriptionFive(org_id int64, patient_id int64, record_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
  254. err = readDb.Model(&models.HisPrescription{}).
  255. Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
  256. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
  257. }).
  258. Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
  259. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("Drug", "status=1")
  260. }).
  261. Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
  262. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
  263. }).Preload("TempHisOrder", func(db *gorm.DB) *gorm.DB {
  264. return db.Where("status = 1 AND user_org_id = ? AND order_status <> 3 AND order_status <> 2 ", org_id)
  265. }).
  266. Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND order_status <> 3 and order_status <> 5 AND p_type = ?", org_id, record_date, patient_id, p_type).
  267. Find(&prescription).Error
  268. return
  269. }
  270. func GetUnSettleMonthHisPrescription(org_id int64, patient_id int64, start_date int64, end_date int64) (prescription []*models.HisPrescription, err error) {
  271. err = readDb.Model(&models.HisPrescription{}).
  272. Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
  273. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
  274. }).
  275. Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
  276. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
  277. }).
  278. Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
  279. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
  280. }).
  281. Where("user_org_id = ? AND status = 1 AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 AND order_status <> 5 AND p_type <> 1", org_id, start_date, end_date, patient_id).
  282. Find(&prescription).Error
  283. return
  284. }
  285. func GetHisOrderFour(patient_id string, infoSeq string, docId string) (order models.HisOrder, err error) {
  286. if len(docId) > 0 {
  287. err = readDb.Model(&models.HisOrder{}).Where("mdtrt_id = ? AND psn_no = ? AND setl_id = ? AND status = 1", infoSeq, patient_id, docId).First(&order).Error
  288. } else {
  289. err = readDb.Model(&models.HisOrder{}).Where("mdtrt_id = ? AND psn_no = ? AND status = 1 ", infoSeq, patient_id).First(&order).Error
  290. }
  291. return
  292. }
  293. func GetHisPatientForCoordinate(id_card_no string) (string, string) {
  294. //input := make(map[string]interface{})
  295. inputData := make(map[string]interface{})
  296. inputData["idcard"] = id_card_no // 就诊凭证编号
  297. var inputLog string
  298. bytesData, err := json.Marshal(inputData)
  299. inputLog = string(bytesData)
  300. fmt.Println(string(bytesData))
  301. if err != nil {
  302. fmt.Println(err.Error())
  303. return err.Error(), ""
  304. }
  305. reader := bytes.NewReader(bytesData)
  306. var url string
  307. gdyb_url := "http://218.104.146.179:9091/esb/listener/getPatientType"
  308. url = gdyb_url
  309. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  310. request, err := http.NewRequest("GET", url, reader)
  311. if err != nil {
  312. fmt.Println(err.Error())
  313. return err.Error(), ""
  314. }
  315. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  316. request.Header.Set("code", "Xmrjyy")
  317. client := http.Client{}
  318. resp, err := client.Do(request)
  319. if err != nil {
  320. fmt.Println(err.Error())
  321. return err.Error(), ""
  322. }
  323. respBytes, err := ioutil.ReadAll(resp.Body)
  324. if err != nil {
  325. fmt.Println(err.Error())
  326. return err.Error(), ""
  327. }
  328. fmt.Println(string(respBytes))
  329. str := string(respBytes)
  330. return str, inputLog
  331. }
  332. func UploadPrescriptionForCoordinate(info models.UploadInfo) (string, string) {
  333. //input := make(map[string]interface{})
  334. inputData := make(map[string]interface{})
  335. diags := make([]map[string]interface{}, 0)
  336. //diags := make([]map[string]interface{}, 0)
  337. presInfos := make([]map[string]interface{}, 0)
  338. for _, item := range info.Diag {
  339. inputDataDiag := make(map[string]interface{})
  340. inputDataDiag["vao06"] = item.Vao06
  341. inputDataDiag["bak02"] = item.Bak02
  342. diags = append(diags, inputDataDiag)
  343. }
  344. for _, item := range info.PresInfo {
  345. inputDataPresInfo := make(map[string]interface{})
  346. inputDataPresInfo["cbm06"] = item.Cbm06
  347. inputDataPresInfo["cbm07"] = item.Cbm06
  348. inputDataPresInfo["cbmid"] = item.Cbmid
  349. presDetails := make([]map[string]interface{}, 0)
  350. for _, subItem := range item.PresDetail {
  351. inputDataPresDetail := make(map[string]interface{})
  352. inputDataPresDetail["vaf59"] = subItem.Vaf59
  353. Items := make([]map[string]interface{}, 0)
  354. for _, subSubItem := range subItem.Item {
  355. inputDataItem := make(map[string]interface{})
  356. inputDataItem["bbx01"] = subSubItem.Bbx01
  357. inputDataItem["bda01"] = subSubItem.Bda01
  358. inputDataItem["bby01"] = subSubItem.Bby01
  359. inputDataItem["bck01b"] = subSubItem.Bck01b
  360. inputDataItem["bck01d"] = subSubItem.Bck01d
  361. inputDataItem["bdi01"] = subSubItem.Bdi01
  362. inputDataItem["rownr"] = subSubItem.Rownr
  363. inputDataItem["vaf11"] = subSubItem.Vaf11
  364. inputDataItem["vaf14"] = subSubItem.Vaf14
  365. inputDataItem["vaf15"] = subSubItem.Vaf15
  366. inputDataItem["vaf17"] = subSubItem.Vaf17
  367. inputDataItem["vaf18"] = subSubItem.Vaf18
  368. inputDataItem["vaf19"] = subSubItem.Vaf19
  369. inputDataItem["vaf20"] = subSubItem.Vaf20
  370. inputDataItem["vaf21"] = subSubItem.Vaf21
  371. inputDataItem["vaf22"] = subSubItem.Vaf22
  372. inputDataItem["vaf32"] = subSubItem.Vaf32
  373. inputDataItem["vaf35"] = subSubItem.Vaf35
  374. inputDataItem["vaf36"] = subSubItem.Vaf36
  375. inputDataItem["vaf58"] = subSubItem.Vaf58
  376. inputDataItem["vaf61"] = subSubItem.Vaf61
  377. Items = append(Items, inputDataItem)
  378. }
  379. inputDataPresDetail["item"] = Items
  380. presDetails = append(presDetails, inputDataPresDetail)
  381. }
  382. inputDataPresInfo["presDetail"] = presDetails
  383. presInfos = append(presInfos, inputDataPresInfo)
  384. }
  385. inputData["vaa01"] = info.Vaa01 // 就诊凭证编号
  386. inputData["Fasong"] = info.Fasong // 就诊凭证编号
  387. inputData["vaa07"] = info.Vaa07 // 就诊凭证编号
  388. inputData["bck01c"] = info.Bck01c // 就诊凭证编号
  389. inputData["bce02a"] = "1001" // 就诊凭证编号
  390. inputData["diag"] = diags // 就诊凭证编号
  391. inputData["presInfo"] = presInfos // 就诊凭证编号
  392. var inputLog string
  393. bytesData, err := json.Marshal(inputData)
  394. inputLog = string(bytesData)
  395. fmt.Println(string(bytesData))
  396. if err != nil {
  397. fmt.Println(err.Error())
  398. return err.Error(), ""
  399. }
  400. reader := bytes.NewReader(bytesData)
  401. var url string
  402. gdyb_url := "http://218.104.146.179:9091/esb/listener/sendPretreat"
  403. url = gdyb_url
  404. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  405. request, err := http.NewRequest("POST", url, reader)
  406. if err != nil {
  407. fmt.Println(err.Error())
  408. return err.Error(), ""
  409. }
  410. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  411. request.Header.Set("code", "Xmrjyy")
  412. client := http.Client{}
  413. resp, err := client.Do(request)
  414. if err != nil {
  415. fmt.Println(err.Error())
  416. return err.Error(), ""
  417. }
  418. respBytes, err := ioutil.ReadAll(resp.Body)
  419. if err != nil {
  420. fmt.Println(err.Error())
  421. return err.Error(), ""
  422. }
  423. fmt.Println(string(respBytes))
  424. str := string(respBytes)
  425. return str, inputLog
  426. }
  427. func UploadPrescriptionForCoordinateHospital(info models.UploadInfo) (string, string) {
  428. //input := make(map[string]interface{})
  429. inputData := make(map[string]interface{})
  430. diags := make([]map[string]interface{}, 0)
  431. //diags := make([]map[string]interface{}, 0)
  432. presInfos := make([]map[string]interface{}, 0)
  433. for _, item := range info.Diag {
  434. inputDataDiag := make(map[string]interface{})
  435. inputDataDiag["vao06"] = item.Vao06
  436. inputDataDiag["bak02"] = item.Bak02
  437. diags = append(diags, inputDataDiag)
  438. }
  439. for _, item := range info.PresInfo {
  440. inputDataPresInfo := make(map[string]interface{})
  441. inputDataPresInfo["cbm06"] = item.Cbm06
  442. inputDataPresInfo["cbm07"] = item.Cbm06
  443. inputDataPresInfo["cbmid"] = item.Cbmid
  444. presDetails := make([]map[string]interface{}, 0)
  445. for _, subItem := range item.PresDetail {
  446. inputDataPresDetail := make(map[string]interface{})
  447. inputDataPresDetail["vaf59"] = subItem.Vaf59
  448. Items := make([]map[string]interface{}, 0)
  449. for _, subSubItem := range subItem.Item {
  450. inputDataItem := make(map[string]interface{})
  451. inputDataItem["bbx01"] = subSubItem.Bbx01
  452. inputDataItem["bda01"] = subSubItem.Bda01
  453. inputDataItem["bby01"] = subSubItem.Bby01
  454. inputDataItem["bck01b"] = subSubItem.Bck01b
  455. inputDataItem["bck01d"] = subSubItem.Bck01d
  456. inputDataItem["bdi01"] = subSubItem.Bdi01
  457. inputDataItem["rownr"] = subSubItem.Rownr
  458. inputDataItem["vaf11"] = subSubItem.Vaf11
  459. inputDataItem["vaf14"] = subSubItem.Vaf14
  460. inputDataItem["vaf15"] = subSubItem.Vaf15
  461. inputDataItem["vaf17"] = subSubItem.Vaf17
  462. inputDataItem["vaf18"] = subSubItem.Vaf18
  463. inputDataItem["vaf19"] = subSubItem.Vaf19
  464. inputDataItem["vaf20"] = subSubItem.Vaf20
  465. inputDataItem["vaf21"] = subSubItem.Vaf21
  466. inputDataItem["vaf22"] = subSubItem.Vaf22
  467. inputDataItem["vaf32"] = subSubItem.Vaf32
  468. inputDataItem["vaf35"] = subSubItem.Vaf35
  469. inputDataItem["vaf36"] = subSubItem.Vaf36
  470. inputDataItem["vaf58"] = subSubItem.Vaf58
  471. inputDataItem["vaf61"] = subSubItem.Vaf61
  472. Items = append(Items, inputDataItem)
  473. }
  474. inputDataPresDetail["item"] = Items
  475. presDetails = append(presDetails, inputDataPresDetail)
  476. }
  477. inputDataPresInfo["presDetail"] = presDetails
  478. presInfos = append(presInfos, inputDataPresInfo)
  479. }
  480. inputData["vaa01"] = info.Vaa01 // 就诊凭证编号
  481. inputData["Fasong"] = info.Fasong // 就诊凭证编号
  482. inputData["vaa07"] = info.Vaa07 // 就诊凭证编号
  483. inputData["bck01c"] = info.Bck01c // 就诊凭证编号
  484. inputData["bce02a"] = "1001" // 就诊凭证编号
  485. inputData["diag"] = diags // 就诊凭证编号
  486. inputData["presInfo"] = presInfos // 就诊凭证编号
  487. var inputLog string
  488. bytesData, err := json.Marshal(inputData)
  489. inputLog = string(bytesData)
  490. fmt.Println(string(bytesData))
  491. if err != nil {
  492. fmt.Println(err.Error())
  493. return err.Error(), ""
  494. }
  495. reader := bytes.NewReader(bytesData)
  496. var url string
  497. gdyb_url := "http://218.104.146.179:9091/esb/listener/saveOrdInfoIp"
  498. url = gdyb_url
  499. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  500. request, err := http.NewRequest("POST", url, reader)
  501. if err != nil {
  502. fmt.Println(err.Error())
  503. return err.Error(), ""
  504. }
  505. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  506. request.Header.Set("code", "Xmrjyy")
  507. client := http.Client{}
  508. resp, err := client.Do(request)
  509. if err != nil {
  510. fmt.Println(err.Error())
  511. return err.Error(), ""
  512. }
  513. respBytes, err := ioutil.ReadAll(resp.Body)
  514. if err != nil {
  515. fmt.Println(err.Error())
  516. return err.Error(), ""
  517. }
  518. fmt.Println(string(respBytes))
  519. str := string(respBytes)
  520. return str, inputLog
  521. }
  522. func UpDatePrescriptionNumberForCoordinate(user_org_id int64, ids []int64, number string) (err error) {
  523. err = writeDb.Model(&models.HisPrescription{}).Where("user_org_id = ? AND status = 1 AND id in (?)", user_org_id, ids).Updates(map[string]interface{}{"batch_number": number, "mtime": time.Now().Unix(), "order_status": 6}).Error
  524. return
  525. }
  526. func FindPatientPrescriptionInfoTwo(org_id int64, patient_id int64, record_date int64, p_type int64) (info models.HisPrescriptionInfo, err error) {
  527. err = readDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND p_type = ? ", org_id, record_date, patient_id, p_type).First(&info).Error
  528. return
  529. }
  530. func GetExecutionFrequencyByName(name string, org_id int64) (ef models.ExecutionFrequencyDic, err error) {
  531. err = readDb.Model(&models.ExecutionFrequencyDic{}).Where("org_id = ? AND name = ?", org_id, name).First(&ef).Error
  532. return
  533. }
  534. func UpdataHisPateintTwo(his *models.VMHisPatient) {
  535. writeDb.Save(&his)
  536. }
  537. func UpdataHisPateintThree(his *models.HisPatient) {
  538. writeDb.Save(&his)
  539. }
  540. func UpDateHisPrescriptionInfoNumbertwo(user_org_id int64, id int64, number string, record_time int64, his_patient_id int64) (err error) {
  541. err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("user_org_id = ? AND status = 1 AND his_patient_id = ? AND record_date = ?", user_org_id, his_patient_id, record_time).Updates(map[string]interface{}{"batch_number": number, "prescription_status": 3, "mtime": time.Now().Unix()}).Error
  542. return
  543. }
  544. func UpdataOrderStatusThreef(number string, user_org_id int64) (err error) {
  545. err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 5, "mtime": time.Now().Unix()}).Error
  546. err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 5, "mtime": time.Now().Unix()}).Error
  547. return
  548. }
  549. func UpdataOrderStatustwo(id int64, number string, user_org_id int64) (err error) {
  550. err = writeDb.Model(&models.HisOrder{}).Where("status = 1 AND id = ? AND user_org_id = ?", id, user_org_id).Updates(map[string]interface{}{"order_status": 3, "mtime": time.Now().Unix(), "status": 0}).Error
  551. err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 1, "mtime": time.Now().Unix()}).Error
  552. err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 1, "mtime": time.Now().Unix()}).Error
  553. return
  554. }
  555. func GetHisPatientByIdThree(id int64) (models.HisPatient, error) {
  556. patient := models.HisPatient{}
  557. err := XTReadDB().Model(&patient).Where("id = ? and status = 1", id).First(&patient).Error
  558. return patient, err
  559. }