coordinate_service.go 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. package service
  2. import (
  3. "XT_New/models"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "github.com/jinzhu/gorm"
  8. "io/ioutil"
  9. "net/http"
  10. )
  11. func SavePatientMessageInfo() (string, string) {
  12. //input := make(map[string]interface{})
  13. inputData := make(map[string]interface{})
  14. inputData["patType"] = "1" // 就诊凭证编号
  15. inputData["patIdNo"] = "440510199211080038" // 开始时间
  16. inputData["patName"] = "测试患者4 " // 人员姓名
  17. inputData["patMobile"] = "13535547902" // 人员姓名
  18. inputData["patSex"] = "M" // 人员姓名
  19. inputData["patMarriage"] = "1" // 人员姓名
  20. inputData["birthday"] = "1992-10-23" // 人员姓名
  21. inputData["patAddress"] = "11111" // 人员姓名
  22. inputData["thirdPartyID"] = "6936" // 人员姓名
  23. inputData["patAge"] = "30" // 人员姓名
  24. //input["req"] = inputData
  25. var inputLog string
  26. bytesData, err := json.Marshal(inputData)
  27. inputLog = string(bytesData)
  28. fmt.Println(string(bytesData))
  29. if err != nil {
  30. fmt.Println(err.Error())
  31. return err.Error(), ""
  32. }
  33. reader := bytes.NewReader(bytesData)
  34. var url string
  35. gdyb_url := "http://218.104.146.179:9091/esb/listener/savePatientMessageInfo"
  36. url = gdyb_url
  37. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  38. request, err := http.NewRequest("GET", url, reader)
  39. if err != nil {
  40. fmt.Println(err.Error())
  41. return err.Error(), ""
  42. }
  43. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  44. request.Header.Set("code", "Xmrjyy")
  45. client := http.Client{}
  46. resp, err := client.Do(request)
  47. if err != nil {
  48. fmt.Println(err.Error())
  49. return err.Error(), ""
  50. }
  51. respBytes, err := ioutil.ReadAll(resp.Body)
  52. if err != nil {
  53. fmt.Println(err.Error())
  54. return err.Error(), ""
  55. }
  56. fmt.Println(string(respBytes))
  57. str := string(respBytes)
  58. return str, inputLog
  59. }
  60. func SaveReg(reg models.Reg) (string, string) {
  61. //input := make(map[string]interface{})
  62. inputData := make(map[string]interface{})
  63. inputData["deptId"] = reg.DeptId
  64. inputData["clinicUnitId"] = ""
  65. inputData["healthCardNo"] = ""
  66. fmt.Println(reg.PatientId)
  67. inputData["patientId"] = reg.PatientId
  68. inputData["patientName"] = reg.PatientName
  69. inputData["idCardNo"] = reg.IdCardNo
  70. inputData["phone"] = ""
  71. inputData["doctorId"] = ""
  72. inputData["doctorLevelCode"] = ""
  73. inputData["regDate"] = reg.RegDate
  74. inputData["shiftCode"] = ""
  75. inputData["startTime"] = ""
  76. inputData["endTime"] = ""
  77. inputData["scheduleId"] = ""
  78. inputData["periodId"] = ""
  79. inputData["svObjectId"] = ""
  80. inputData["diseaseId"] = ""
  81. inputData["regFee"] = reg.RegFee
  82. inputData["treatFee"] = reg.TreatFee
  83. inputData["operatorId"] = reg.OperatorId
  84. inputData["remark"] = "血透"
  85. inputData["orderType"] = "0"
  86. inputData["clinicCode"] = ""
  87. inputData["infoSeq"] = ""
  88. //input["Request"] = inputData
  89. var inputLog string
  90. bytesData, err := json.Marshal(inputData)
  91. inputLog = string(bytesData)
  92. fmt.Println(string(bytesData))
  93. if err != nil {
  94. fmt.Println(err.Error())
  95. return err.Error(), ""
  96. }
  97. reader := bytes.NewReader(bytesData)
  98. var url string
  99. gdyb_url := "http://218.104.146.179:9091/esb/listener/saveReg"
  100. url = gdyb_url
  101. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  102. request, err := http.NewRequest("POST", url, reader)
  103. if err != nil {
  104. fmt.Println(err.Error())
  105. return err.Error(), ""
  106. }
  107. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  108. request.Header.Set("code", "Xmrjyy")
  109. client := http.Client{}
  110. resp, err := client.Do(request)
  111. if err != nil {
  112. fmt.Println(err.Error())
  113. return err.Error(), ""
  114. }
  115. respBytes, err := ioutil.ReadAll(resp.Body)
  116. if err != nil {
  117. fmt.Println(err.Error())
  118. return err.Error(), ""
  119. }
  120. fmt.Println(string(respBytes))
  121. str := string(respBytes)
  122. return str, inputLog
  123. }
  124. func GetWaitPayDetail() (string, string) {
  125. //input := make(map[string]interface{})
  126. inputData := make(map[string]interface{})
  127. inputData["clinicSeq"] = "30445" // 就诊凭证编号
  128. inputData["prescriptionId"] = "" // 开始时间
  129. inputData["patientId"] = "701822660170096645" // 人员姓名
  130. var inputLog string
  131. bytesData, err := json.Marshal(inputData)
  132. inputLog = string(bytesData)
  133. fmt.Println(string(bytesData))
  134. if err != nil {
  135. fmt.Println(err.Error())
  136. return err.Error(), ""
  137. }
  138. reader := bytes.NewReader(bytesData)
  139. var url string
  140. gdyb_url := "http://218.104.146.179:9091/esb/listener/getWaitPayDetail"
  141. url = gdyb_url
  142. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  143. request, err := http.NewRequest("POST", url, reader)
  144. if err != nil {
  145. fmt.Println(err.Error())
  146. return err.Error(), ""
  147. }
  148. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  149. request.Header.Set("code", "Xmrjyy")
  150. client := http.Client{}
  151. resp, err := client.Do(request)
  152. if err != nil {
  153. fmt.Println(err.Error())
  154. return err.Error(), ""
  155. }
  156. respBytes, err := ioutil.ReadAll(resp.Body)
  157. if err != nil {
  158. fmt.Println(err.Error())
  159. return err.Error(), ""
  160. }
  161. fmt.Println(string(respBytes))
  162. str := string(respBytes)
  163. return str, inputLog
  164. }
  165. func OpKeepAccounts(number string, cus []*models.NewCustomTwo) (string, string) {
  166. inputData := make(map[string]interface{})
  167. feedetail := make([]map[string]interface{}, 0)
  168. for _, item := range cus {
  169. feedetailInfo := make(map[string]interface{})
  170. feedetailInfo["itemCode"] = item.MedListCodg
  171. feedetailInfo["num"] = item.Cut
  172. feedetail = append(feedetail, feedetailInfo)
  173. }
  174. inputData["item"] = feedetail
  175. inputData["clinicSeq"] = number // 就诊凭证编号
  176. var inputLog string
  177. bytesData, err := json.Marshal(inputData)
  178. inputLog = string(bytesData)
  179. fmt.Println(string(bytesData))
  180. if err != nil {
  181. fmt.Println(err.Error())
  182. return err.Error(), ""
  183. }
  184. reader := bytes.NewReader(bytesData)
  185. var url string
  186. gdyb_url := "http://218.104.146.179:9091/esb/listener/opKeepAccounts"
  187. url = gdyb_url
  188. request, err := http.NewRequest("POST", url, reader)
  189. if err != nil {
  190. fmt.Println(err.Error())
  191. return err.Error(), ""
  192. }
  193. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  194. request.Header.Set("code", "Xmrjyy")
  195. client := http.Client{}
  196. resp, err := client.Do(request)
  197. if err != nil {
  198. fmt.Println(err.Error())
  199. return err.Error(), ""
  200. }
  201. respBytes, err := ioutil.ReadAll(resp.Body)
  202. if err != nil {
  203. fmt.Println(err.Error())
  204. return err.Error(), ""
  205. }
  206. fmt.Println(string(respBytes))
  207. str := string(respBytes)
  208. return str, inputLog
  209. }
  210. func OpCancelKeepAccounts(setl_id string, op_name string, op_code string) (string, string) {
  211. inputData := make(map[string]interface{})
  212. inputData["docId"] = setl_id
  213. inputData["operCode"] = "111"
  214. inputData["operName"] = "2222"
  215. var inputLog string
  216. bytesData, err := json.Marshal(inputData)
  217. inputLog = string(bytesData)
  218. fmt.Println(string(bytesData))
  219. if err != nil {
  220. fmt.Println(err.Error())
  221. return err.Error(), ""
  222. }
  223. reader := bytes.NewReader(bytesData)
  224. var url string
  225. gdyb_url := "http://218.104.146.179:9091/esb/listener/opCancelKeepAccounts"
  226. url = gdyb_url
  227. request, err := http.NewRequest("POST", url, reader)
  228. if err != nil {
  229. fmt.Println(err.Error())
  230. return err.Error(), ""
  231. }
  232. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  233. request.Header.Set("code", "Xmrjyy")
  234. client := http.Client{}
  235. resp, err := client.Do(request)
  236. if err != nil {
  237. fmt.Println(err.Error())
  238. return err.Error(), ""
  239. }
  240. respBytes, err := ioutil.ReadAll(resp.Body)
  241. if err != nil {
  242. fmt.Println(err.Error())
  243. return err.Error(), ""
  244. }
  245. fmt.Println(string(respBytes))
  246. str := string(respBytes)
  247. return str, inputLog
  248. }
  249. func UpdateHisPatientStatus(his *models.VMHisPatient) {
  250. writeDb.Save(&his)
  251. }
  252. func GetUnSettleHisPrescriptionFive(org_id int64, patient_id int64, record_date int64, p_type int64) (prescription []*models.HisPrescription, err error) {
  253. err = readDb.Model(&models.HisPrescription{}).
  254. Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
  255. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
  256. }).
  257. Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
  258. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisOrderInfo", "status = 1").Preload("Drug", "status=1")
  259. }).
  260. Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
  261. 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")
  262. }).Preload("TempHisOrder", func(db *gorm.DB) *gorm.DB {
  263. return db.Where("status = 1 AND user_org_id = ? AND order_status <> 3 AND order_status <> 2 ", org_id)
  264. }).
  265. 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).
  266. Find(&prescription).Error
  267. return
  268. }
  269. func GetUnSettleMonthHisPrescription(org_id int64, patient_id int64, start_date int64, end_date int64) (prescription []*models.HisPrescription, err error) {
  270. err = readDb.Model(&models.HisPrescription{}).
  271. Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
  272. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
  273. }).
  274. Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
  275. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
  276. }).
  277. Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
  278. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1").Preload("XtHisProjectTeam", "status = 1")
  279. }).
  280. 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).
  281. Find(&prescription).Error
  282. return
  283. }
  284. func GetHisOrderFour(patient_id string, infoSeq string, docId string) (order models.HisOrder, err error) {
  285. if len(docId) > 0 {
  286. err = readDb.Model(&models.HisOrder{}).Where("mdtrt_id = ? AND psn_no = ? AND setl_id = ? AND status = 1", infoSeq, patient_id, docId).First(&order).Error
  287. } else {
  288. err = readDb.Model(&models.HisOrder{}).Where("mdtrt_id = ? AND psn_no = ? AND status = 1 ", infoSeq, patient_id).First(&order).Error
  289. }
  290. return
  291. }