hbyb_controller.go 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. package hb
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "gdyb/controllers"
  6. "gdyb/models"
  7. "gdyb/service"
  8. "gdyb/utils"
  9. "github.com/astaxie/beego"
  10. "io/ioutil"
  11. )
  12. type HBybController struct {
  13. controllers.BaseAuthAPIController
  14. }
  15. func HbybRegistRouters() {
  16. beego.Router("/hbyb/1101", &HBybController{}, "get:PostOne")
  17. beego.Router("/hbyb/2201", &HBybController{}, "get:PostTwo")
  18. beego.Router("/hbyb/2202", &HBybController{}, "get:PostThree")
  19. beego.Router("/hbyb/2203", &HBybController{}, "get:PostFour")
  20. beego.Router("/hbyb/2204", &HBybController{}, "post:PostFive")
  21. beego.Router("/hbyb/2205", &HBybController{}, "get:PostSix")
  22. beego.Router("/hbyb/2206", &HBybController{}, "get:PostSeven")
  23. beego.Router("/hbyb/2207", &HBybController{}, "get:PostEight")
  24. beego.Router("/hbyb/2208", &HBybController{}, "get:PostNine")
  25. beego.Router("/hbyb/5203", &HBybController{}, "get:PostTen")
  26. }
  27. func (c *HBybController) PostOne() {
  28. certNo := c.GetString("cert_no")
  29. org_name := c.GetString("org_name")
  30. doctor := c.GetString("doctor")
  31. fixmedins_code := c.GetString("fixmedins_code")
  32. insuplc_admdvs := c.GetString("insuplc_admdvs")
  33. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  34. secret_key := c.GetString("secret_key")
  35. id_card_type, _ := c.GetInt64("id_card_type")
  36. card_sn := c.GetString("card_sn")
  37. certificates := c.GetString("certificates")
  38. result, inputLog := service.Hbyb1101(certNo, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type, card_sn, certificates)
  39. var dat map[string]interface{}
  40. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  41. } else {
  42. }
  43. var dat2 map[string]interface{}
  44. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  45. } else {
  46. }
  47. c.ServeSuccessJSON(map[string]interface{}{
  48. "pre": dat,
  49. "log": dat2,
  50. })
  51. }
  52. func (c *HBybController) PostTwo() {
  53. psnNo := c.GetString("psn_no")
  54. insutype := c.GetString("insutype")
  55. certNo := c.GetString("cert_no")
  56. org_name := c.GetString("org_name")
  57. doctor := c.GetString("doctor")
  58. ipt_otp_no := c.GetString("ipt_otp_no")
  59. dept := c.GetString("dept")
  60. fixmedins_code := c.GetString("fixmedins_code")
  61. dept_code := c.GetString("dept_code")
  62. doctor_id := c.GetString("doctor_id")
  63. insuplc_admdvs := c.GetString("insuplc_admdvs")
  64. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  65. secret_key := c.GetString("secret_key")
  66. id_card_type, _ := c.GetInt64("id_card_type")
  67. result, _ := service.Hbyb2201(psnNo, insutype, certNo, org_name, doctor, ipt_otp_no, dept, fixmedins_code, dept_code, doctor_id, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type)
  68. var dat map[string]interface{}
  69. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  70. //fmt.Println(dat["status"])
  71. } else {
  72. }
  73. c.ServeSuccessJSON(map[string]interface{}{
  74. "pre": dat,
  75. })
  76. }
  77. func (c *HBybController) PostThree() {
  78. psnNo := c.GetString("psn_no")
  79. mdtrtId := c.GetString("mdtrt_id")
  80. iptOtpNo := c.GetString("ipt_otp_no")
  81. org_name := c.GetString("org_name")
  82. doctor := c.GetString("doctor")
  83. insuplc_admdvs := c.GetString("insuplc_admdvs")
  84. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  85. secret_key := c.GetString("secret_key")
  86. fixmedins_code := c.GetString("fixmedins_code")
  87. result, requestLog := service.Hbyb2202(psnNo, mdtrtId, iptOtpNo, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code)
  88. var dat map[string]interface{}
  89. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  90. } else {
  91. }
  92. c.ServeSuccessJSON(map[string]interface{}{
  93. "pre": dat,
  94. "request_log": requestLog,
  95. })
  96. }
  97. func (c *HBybController) PostFour() {
  98. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  99. var respJSON map[string]interface{}
  100. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  102. return
  103. }
  104. userJSONBytes, _ := json.Marshal(respJSON["config"])
  105. var config []*models.HisXtDiagnoseConfig
  106. if err := json.Unmarshal(userJSONBytes, &config); err != nil {
  107. utils.ErrorLog("解析失败:%v", err)
  108. return
  109. }
  110. fmt.Println(respJSON["psn_no"].(string))
  111. fmt.Println(respJSON["mdtrt_id"].(string))
  112. psnNo := respJSON["psn_no"].(string)
  113. mdtrtId := respJSON["mdtrt_id"].(string)
  114. doctor := respJSON["doctor"].(string)
  115. department := respJSON["department"].(string)
  116. org_name := respJSON["org_name"].(string)
  117. med_type := respJSON["med_type"].(string)
  118. doctor_id := respJSON["doctor_id"].(string)
  119. fixmedins_code := respJSON["fixmedins_code"].(string)
  120. sick_code := respJSON["sick_code"].(string)
  121. sick_name := respJSON["sick_name"].(string)
  122. dept := respJSON["dept"].(string)
  123. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  124. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  125. secret_key := respJSON["secret_key"].(string)
  126. result, request_log := service.Hbyb2203(psnNo, mdtrtId, doctor, department, org_name, med_type, doctor_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, sick_code, sick_name, dept, config)
  127. fmt.Println(request_log)
  128. var dat map[string]interface{}
  129. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  130. } else {
  131. }
  132. c.ServeSuccessJSON(map[string]interface{}{
  133. "pre": dat,
  134. })
  135. }
  136. type All struct {
  137. HisPrescription HisPrescription
  138. mdtrt_id string
  139. psn_no string
  140. }
  141. type HisPrescription struct {
  142. ID int64 `gorm:"column:id" json:"id" form:"id"`
  143. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  144. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  145. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  146. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  147. Status int64 `gorm:"column:status" json:"status" form:"status"`
  148. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  149. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  150. Number string `gorm:"column:number" json:"number" form:"number"`
  151. Type int64 `gorm:"column:type" json:"type" form:"type"`
  152. Doctor int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
  153. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  154. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  155. HisDoctorAdviceInfo []*models.HisDoctorAdviceInfo `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"advices"`
  156. HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"project"`
  157. }
  158. func (c *HBybController) PostFive() {
  159. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  160. var respJSON map[string]interface{}
  161. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  162. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  163. return
  164. }
  165. userJSONBytes, _ := json.Marshal(respJSON["pre"])
  166. var hp []*models.HisPrescription
  167. if err := json.Unmarshal(userJSONBytes, &hp); err != nil {
  168. utils.ErrorLog("解析失败:%v", err)
  169. return
  170. }
  171. fmt.Println(respJSON["psn_no"].(string))
  172. fmt.Println(respJSON["mdtrt_id"].(string))
  173. fmt.Println(respJSON["chrg_bchno"].(string))
  174. fmt.Println(respJSON["org_name"].(string))
  175. fmt.Println(respJSON["doctor"].(string))
  176. fmt.Println(respJSON["dept"].(string))
  177. fmt.Println(respJSON["fixmedins_code"].(string))
  178. fmt.Println(respJSON["dept_code"].(string))
  179. fmt.Println(respJSON["doctor_id"].(string))
  180. fmt.Println(respJSON["insuplc_admdvs"].(string))
  181. fmt.Println(respJSON["mdtrtarea_admvs"].(string))
  182. fmt.Println(respJSON["secret_key"].(string))
  183. result, requestLog := service.Hbyb2204(respJSON["psn_no"].(string), respJSON["mdtrt_id"].(string), hp, respJSON["chrg_bchno"].(string), respJSON["org_name"].(string),
  184. respJSON["doctor"].(string), respJSON["dept"].(string), respJSON["fixmedins_code"].(string), respJSON["dept_code"].(string), respJSON["doctor_id"].(string), respJSON["insuplc_admdvs"].(string), respJSON["mdtrtarea_admvs"].(string), respJSON["secret_key"].(string), respJSON["balance_accounts_type"].(string))
  185. var dat map[string]interface{}
  186. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  187. fmt.Println(dat)
  188. } else {
  189. fmt.Println(err)
  190. }
  191. var dat2 map[string]interface{}
  192. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  193. fmt.Println(dat2)
  194. } else {
  195. fmt.Println(err)
  196. }
  197. c.ServeSuccessJSON(map[string]interface{}{
  198. "pre": dat,
  199. "request_log": requestLog,
  200. })
  201. }
  202. func (c *HBybController) PostSix() {
  203. psnNo := c.GetString("psn_no")
  204. mdtrtId := c.GetString("mdtrt_id")
  205. chrgBchno := c.GetString("chrg_bchno")
  206. org_name := c.GetString("org_name")
  207. doctor := c.GetString("doctor")
  208. insuplc_admdvs := c.GetString("insuplc_admdvs")
  209. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  210. secret_key := c.GetString("secret_key")
  211. fixmedins_code := c.GetString("fixmedins_code")
  212. result, requestlog := service.Hbyb2205(psnNo, mdtrtId, chrgBchno, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code)
  213. fmt.Println(requestlog)
  214. var dat map[string]interface{}
  215. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  216. fmt.Println(dat)
  217. } else {
  218. fmt.Println(err)
  219. }
  220. c.ServeSuccessJSON(map[string]interface{}{
  221. "pre": result,
  222. })
  223. }
  224. func (c *HBybController) PostSeven() {
  225. psnNo := c.GetString("psn_no")
  226. mdtrtId := c.GetString("mdtrt_id")
  227. chrgBchno := c.GetString("chrg_bchno")
  228. certNo := c.GetString("cert_no")
  229. insutype := c.GetString("insutype")
  230. total := c.GetString("total")
  231. org_name := c.GetString("org_name")
  232. doctor := c.GetString("doctor")
  233. fixmedins_code := c.GetString("fixmedins_code")
  234. insuplc_admdvs := c.GetString("insuplc_admdvs")
  235. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  236. secret_key := c.GetString("secret_key")
  237. med_type := c.GetString("med_type")
  238. id_card_type, _ := c.GetInt64("id_card_type")
  239. certificates, _ := c.GetInt64("certificates")
  240. result, requestlog := service.Hbyb2206(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type, id_card_type, 0, 0, 0, 0, certificates)
  241. fmt.Println(requestlog)
  242. var dat map[string]interface{}
  243. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  244. fmt.Println(dat)
  245. } else {
  246. fmt.Println(err)
  247. }
  248. c.ServeSuccessJSON(map[string]interface{}{
  249. "pre": dat,
  250. })
  251. }
  252. func (c *HBybController) PostEight() {
  253. psnNo := c.GetString("psn_no")
  254. mdtrtId := c.GetString("mdtrt_id")
  255. chrgBchno := c.GetString("chrg_bchno")
  256. certNo := c.GetString("cert_no")
  257. insutype := c.GetString("insutype")
  258. total := c.GetString("total")
  259. org_name := c.GetString("org_name")
  260. doctor := c.GetString("doctor")
  261. fixmedins_code := c.GetString("fixmedins_code")
  262. insuplc_admdvs := c.GetString("insuplc_admdvs")
  263. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  264. secret_key := c.GetString("secret_key")
  265. med_type := c.GetString("med_type")
  266. id_card_type, _ := c.GetInt64("id_card_type")
  267. certificates, _ := c.GetInt64("certificates")
  268. fulamt_ownpay_amt, _ := c.GetFloat("fulamt_ownpay_amt")
  269. overlmt_selfpay, _ := c.GetFloat("overlmt_selfpay")
  270. preselfpay_amt, _ := c.GetFloat("preselfpay_amt")
  271. inscp_scp_amt, _ := c.GetFloat("inscp_scp_amt")
  272. result, srcRequest := service.Hbyb2207(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type, id_card_type, fulamt_ownpay_amt, overlmt_selfpay, preselfpay_amt, inscp_scp_amt, certificates)
  273. var dat map[string]interface{}
  274. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  275. fmt.Println(dat)
  276. } else {
  277. fmt.Println(err)
  278. }
  279. var dat2 map[string]interface{}
  280. if err := json.Unmarshal([]byte(srcRequest), &dat2); err == nil {
  281. fmt.Println(dat2)
  282. } else {
  283. fmt.Println(err)
  284. }
  285. c.ServeSuccessJSON(map[string]interface{}{
  286. "pre": dat,
  287. "pre2": dat2,
  288. })
  289. }
  290. func (c *HBybController) PostNine() {
  291. psnNo := c.GetString("psn_no")
  292. mdtrtId := c.GetString("mdtrt_id")
  293. setlId := c.GetString("setl_id")
  294. org_name := c.GetString("org_name")
  295. doctor := c.GetString("doctor")
  296. secret_key := c.GetString("secret_key")
  297. fixmedins_code := c.GetString("fixmedins_code")
  298. insuplc_admdvs := c.GetString("insuplc_admdvs")
  299. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  300. result, src_request := service.Hbyb2208(psnNo, mdtrtId, setlId, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  301. fmt.Println(src_request)
  302. var dat map[string]interface{}
  303. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  304. fmt.Println(dat)
  305. } else {
  306. fmt.Println(err)
  307. }
  308. c.ServeSuccessJSON(map[string]interface{}{
  309. "pre": dat,
  310. })
  311. }
  312. func (c *HBybController) PostTen() {
  313. psnNo := c.GetString("psn_no")
  314. mdtrtId := c.GetString("mdtrt_id")
  315. setlId := c.GetString("setl_id")
  316. org_name := c.GetString("org_name")
  317. doctor := c.GetString("doctor")
  318. secret_key := c.GetString("secret_key")
  319. fixmedins_code := c.GetString("fixmedins_code")
  320. insuplc_admdvs := c.GetString("insuplc_admdvs")
  321. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  322. baseParams := models.BaseParams{
  323. SecretKey: secret_key,
  324. FixmedinsCode: fixmedins_code,
  325. InsuplcAdmdvs: insuplc_admdvs,
  326. MdtrtareaAdmvs: mdtrtarea_admvs,
  327. OrgName: org_name,
  328. Doctor: doctor,
  329. }
  330. businessParams := models.BusinessParams{
  331. PsnNo: psnNo,
  332. MdtrtId: mdtrtId,
  333. SetlId: setlId,
  334. }
  335. result := service.Hbyb5203(baseParams, businessParams)
  336. var dat map[string]interface{}
  337. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  338. fmt.Println(dat)
  339. } else {
  340. fmt.Println(err)
  341. }
  342. c.ServeSuccessJSON(map[string]interface{}{
  343. "pre": dat,
  344. })
  345. }