gdyb_controller.go 8.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. package controllers
  2. import (
  3. "XT_New/models"
  4. "XT_New/service"
  5. "XT_New/utils"
  6. "encoding/json"
  7. "fmt"
  8. "github.com/astaxie/beego"
  9. "io/ioutil"
  10. )
  11. type GdybController struct {
  12. BaseAuthAPIController
  13. }
  14. func GdybRegistRouters() {
  15. beego.Router("/gdyb/one", &GdybController{}, "get:PostOne")
  16. beego.Router("/gdyb/two", &GdybController{}, "get:PostTwo")
  17. beego.Router("/gdyb/three", &GdybController{}, "get:PostThree")
  18. beego.Router("/gdyb/four", &GdybController{}, "get:PostFour")
  19. beego.Router("/gdyb/five", &GdybController{}, "post:PostFive")
  20. beego.Router("/gdyb/six", &GdybController{}, "get:PostSix")
  21. beego.Router("/gdyb/seven", &GdybController{}, "get:PostSeven")
  22. beego.Router("/gdyb/eight", &GdybController{}, "get:PostEight")
  23. beego.Router("/gdyb/nine", &GdybController{}, "get:PostNine")
  24. beego.Router("/gdyb/tem", &GdybController{}, "get:PostTen")
  25. }
  26. //provinces, _ := service.GetDistrictsByUpid(0)21
  27. type Result struct {
  28. ErrMsg interface{} `json:"err_msg"`
  29. InfRefmsgid string `json:"inf_refmsgid"`
  30. Infcode int64 `json:"infcode"`
  31. Output struct {
  32. Baseinfo struct {
  33. Age float64 `json:"age"`
  34. Brdy string `json:"brdy"`
  35. Certno string `json:"certno"`
  36. Gend string `json:"gend"`
  37. Naty string `json:"naty"`
  38. PsnCertType string `json:"psn_cert_type"`
  39. PsnName string `json:"psn_name"`
  40. PsnNo string `json:"psn_no"`
  41. } `json:"baseinfo"`
  42. Idetinfo []interface{} `json:"idetinfo"`
  43. Iinfo []struct {
  44. Balc int64 `json:"balc"`
  45. CvlservFlag string `json:"cvlserv_flag"`
  46. EmpName string `json:"emp_name"`
  47. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  48. Insutype string `json:"insutype"`
  49. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  50. PausInsuDate interface{} `json:"paus_insu_date"`
  51. PsnInsuDate string `json:"psn_insu_date"`
  52. PsnInsuStas string `json:"psn_insu_stas"`
  53. PsnType string `json:"psn_type"`
  54. } `json:"iinfo"`
  55. } `json:"output"`
  56. RefmsgTime string `json:"refmsg_time"`
  57. RespondTime string `json:"respond_time"`
  58. Signtype interface{} `json:"signtype"`
  59. WarnInfo interface{} `json:"warn_info"`
  60. }
  61. func (c *GdybController) PostOne() {
  62. certNo := c.GetString("cert_no")
  63. result := service.Gdyb1101(certNo)
  64. var dat map[string]interface{}
  65. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  66. fmt.Println("11111")
  67. fmt.Println(dat)
  68. //fmt.Println(dat["status"])
  69. } else {
  70. fmt.Println(err)
  71. }
  72. c.ServeSuccessJSON(map[string]interface{}{
  73. "pre": dat,
  74. })
  75. }
  76. func (c *GdybController) PostTwo() {
  77. psnNo := c.GetString("psn_no")
  78. insutype := c.GetString("insutype")
  79. certNo := c.GetString("cert_no")
  80. result := service.Gdyb2201(psnNo, insutype, certNo)
  81. var dat map[string]interface{}
  82. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  83. fmt.Println("22222222")
  84. fmt.Println(dat)
  85. //fmt.Println(dat["status"])
  86. } else {
  87. fmt.Println(err)
  88. }
  89. c.ServeSuccessJSON(map[string]interface{}{
  90. "pre": dat,
  91. })
  92. }
  93. func (c *GdybController) PostThree() {
  94. psnNo := c.GetString("psn_no")
  95. mdtrtId := c.GetString("mdtrt_id")
  96. result := service.Gdyb2202(psnNo, mdtrtId)
  97. c.ServeSuccessJSON(map[string]interface{}{
  98. "pre": result,
  99. })
  100. }
  101. func (c *GdybController) PostFour() {
  102. psnNo := c.GetString("psn_no")
  103. mdtrtId := c.GetString("mdtrt_id")
  104. result := service.Gdyb2203(psnNo, mdtrtId)
  105. c.ServeSuccessJSON(map[string]interface{}{
  106. "pre": result,
  107. })
  108. }
  109. type All struct {
  110. HisPrescription HisPrescription
  111. mdtrt_id string
  112. psn_no string
  113. }
  114. type HisPrescription struct {
  115. ID int64 `gorm:"column:id" json:"id" form:"id"`
  116. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  117. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  118. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  119. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  120. Status int64 `gorm:"column:status" json:"status" form:"status"`
  121. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  122. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  123. Number string `gorm:"column:number" json:"number" form:"number"`
  124. Type int64 `gorm:"column:type" json:"type" form:"type"`
  125. Doctor int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
  126. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  127. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  128. HisDoctorAdviceInfo []*models.HisDoctorAdviceInfo `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"advices"`
  129. HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"project"`
  130. }
  131. func (c *GdybController) PostFive() {
  132. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  133. var respJSON map[string]interface{}
  134. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  135. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  136. return
  137. }
  138. userJSONBytes, _ := json.Marshal(respJSON["pre"])
  139. var hp []*models.HisPrescription
  140. if err := json.Unmarshal(userJSONBytes, &hp); err != nil {
  141. utils.ErrorLog("解析失败:%v", err)
  142. return
  143. }
  144. result := service.Gdyb2204(respJSON["psn_no"].(string), respJSON["mdtrt_id"].(string), hp, respJSON["chrg_bchno"].(string))
  145. var dat map[string]interface{}
  146. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  147. fmt.Println(dat)
  148. } else {
  149. fmt.Println(err)
  150. }
  151. c.ServeSuccessJSON(map[string]interface{}{
  152. "pre": dat,
  153. })
  154. }
  155. func (c *GdybController) PostSix() {
  156. psnNo := c.GetString("psn_no")
  157. mdtrtId := c.GetString("mdtrt_id")
  158. chrgBchno := c.GetString("chrg_bchno")
  159. result := service.Gdyb2205(psnNo, mdtrtId, chrgBchno)
  160. c.ServeSuccessJSON(map[string]interface{}{
  161. "pre": result,
  162. })
  163. }
  164. func (c *GdybController) PostSeven() {
  165. psnNo := c.GetString("psn_no")
  166. mdtrtId := c.GetString("mdtrt_id")
  167. chrgBchno := c.GetString("chrg_bchno")
  168. certNo := c.GetString("cert_no")
  169. insutype := c.GetString("insutype")
  170. total := c.GetString("total")
  171. result := service.Gdyb2206(psnNo, mdtrtId, chrgBchno, certNo, insutype, total)
  172. var dat map[string]interface{}
  173. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  174. fmt.Println(dat)
  175. } else {
  176. fmt.Println(err)
  177. }
  178. c.ServeSuccessJSON(map[string]interface{}{
  179. "pre": dat,
  180. })
  181. }
  182. func (c *GdybController) PostEight() {
  183. psnNo := c.GetString("psn_no")
  184. mdtrtId := c.GetString("mdtrt_id")
  185. chrgBchno := c.GetString("chrg_bchno")
  186. certNo := c.GetString("cert_no")
  187. insutype := c.GetString("insutype")
  188. total := c.GetString("total")
  189. result := service.Gdyb2207(psnNo, mdtrtId, chrgBchno, certNo, insutype, total)
  190. var dat map[string]interface{}
  191. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  192. fmt.Println(dat)
  193. } else {
  194. fmt.Println(err)
  195. }
  196. c.ServeSuccessJSON(map[string]interface{}{
  197. "pre": dat,
  198. })
  199. }
  200. func (c *GdybController) PostNine() {
  201. psnNo := c.GetString("psn_no")
  202. mdtrtId := c.GetString("mdtrt_id")
  203. setlId := c.GetString("setl_id")
  204. result := service.Gdyb2208(psnNo, mdtrtId, setlId)
  205. c.ServeSuccessJSON(map[string]interface{}{
  206. "pre": result,
  207. })
  208. }
  209. func (c *GdybController) PostTen() {
  210. fixmedins_type := c.GetString("fixmedins_type")
  211. result := service.Gdyb1201(fixmedins_type)
  212. c.ServeSuccessJSON(map[string]interface{}{
  213. "pre": result,
  214. })
  215. }