sz_his_api_controller.go 59KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580
  1. package sz
  2. import (
  3. "gdyb/controllers"
  4. "gdyb/enums"
  5. "gdyb/service"
  6. "github.com/astaxie/beego"
  7. "time"
  8. )
  9. type SZHisApiController struct {
  10. controllers.BaseAuthAPIController
  11. }
  12. func SZHisManagerApiRegistRouters() {
  13. beego.Router("/sz/api/card/get", &SZHisApiController{}, "get:GetCardInfo")
  14. beego.Router("/sz/api/register/get", &SZHisApiController{}, "get:GetRegisterInfo")
  15. beego.Router("/sz/api/upload/get", &SZHisApiController{}, "get:GetUploadInfo")
  16. beego.Router("/sz/api/settle/get", &SZHisApiController{}, "get:GetSettleInfo")
  17. beego.Router("/sz/api/settle/query", &SZHisApiController{}, "get:GetSettleAccounts")
  18. }
  19. //func (c *SZHisApiController) Sscard() {
  20. // id_card_type, _ := c.GetInt64("id_card_type")
  21. // adminUser := c.GetAdminUserInfo()
  22. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  23. //
  24. // r := CardInit()
  25. // fmt.Println(r)
  26. // //if r == 0 {
  27. // switch id_card_type {
  28. // case 1:
  29. // basStr, err := GetBasBaseInfo()
  30. //
  31. // if err != nil {
  32. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  33. // return
  34. //
  35. // } else {
  36. // fmt.Println(basStr)
  37. //
  38. // bas := strings.Split(basStr, "|")
  39. //
  40. // basNumber := bas[1]
  41. //
  42. // //basNumber := bas[2]
  43. // card_sn := bas[3]
  44. //
  45. // appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
  46. //
  47. // api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + basNumber + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10) + "&card_sn=" + card_sn
  48. // resp, requestErr := http.Get(api)
  49. // if requestErr != nil {
  50. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  51. // return
  52. // }
  53. // defer resp.Body.Close()
  54. // body, ioErr := ioutil.ReadAll(resp.Body)
  55. // if ioErr != nil {
  56. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  57. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  58. // return
  59. // }
  60. // var respJSON map[string]interface{}
  61. //
  62. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  63. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  64. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  65. // return
  66. // }
  67. //
  68. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  69. // userJSONBytes, _ := json.Marshal(userJSON)
  70. // var res ResultTwo
  71. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  72. // utils.ErrorLog("解析失败:%v", err)
  73. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  74. // return
  75. // }
  76. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  77. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  78. // infoStr := string(Iinfos)
  79. // idetinfoStr := string(Idetinfos)
  80. //
  81. // if res.Infcode == 0 {
  82. // his := models.VMHisPatient{
  83. // Status: 1,
  84. // Ctime: time.Now().Unix(),
  85. // Mtime: time.Now().Unix(),
  86. // PsnNo: res.Output.Baseinfo.PsnNo,
  87. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  88. // Certno: res.Output.Baseinfo.Certno,
  89. // PsnName: res.Output.Baseinfo.PsnName,
  90. // Gend: res.Output.Baseinfo.Gend,
  91. // Naty: res.Output.Baseinfo.Naty,
  92. // Brdy: res.Output.Baseinfo.Brdy,
  93. // Age: res.Output.Baseinfo.Age,
  94. // Iinfo: infoStr,
  95. // Idetinfo: idetinfoStr,
  96. // UserOrgId: adminUser.CurrentOrgId,
  97. // IsReturn: 1,
  98. // IdCardType: id_card_type,
  99. // }
  100. //
  101. // patient, err := service.GetPatientByNumber(basNumber, adminUser.CurrentOrgId)
  102. // if err == gorm.ErrRecordNotFound {
  103. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  104. // return
  105. //
  106. // } else if err != nil {
  107. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  108. // return
  109. //
  110. // } else {
  111. // c.ServeSuccessJSON(map[string]interface{}{
  112. // "patient": patient,
  113. // "his": his,
  114. // "number": basNumber,
  115. // })
  116. // }
  117. // } else {
  118. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  119. // return
  120. // }
  121. //
  122. // }
  123. //
  124. // break
  125. // case 2:
  126. // ////SFZStr, err := GetSFZBaseInfo()
  127. // //if err != nil {
  128. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  129. // // return
  130. // //
  131. // //} else {
  132. // //
  133. // // id_card_str := strings.Split(SFZStr, "^")
  134. // // id_card_number := id_card_str[0]
  135. // //appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
  136. // //
  137. // //api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + id_card_number + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10)
  138. // //resp, requestErr := http.Get(api)
  139. // //if requestErr != nil {
  140. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  141. // // return
  142. // //}
  143. // //defer resp.Body.Close()
  144. // //body, ioErr := ioutil.ReadAll(resp.Body)
  145. // //if ioErr != nil {
  146. // // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  147. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  148. // // return
  149. // //}
  150. // //var respJSON map[string]interface{}
  151. // //
  152. // //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  153. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  154. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  155. // // return
  156. // //}
  157. // //
  158. // //userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  159. // //userJSONBytes, _ := json.Marshal(userJSON)
  160. // //var res ResultTwo
  161. // //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  162. // // utils.ErrorLog("解析失败:%v", err)
  163. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  164. // // return
  165. // //}
  166. // //Iinfos, _ := json.Marshal(res.Output.Iinfo)
  167. // //Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  168. // //infoStr := string(Iinfos)
  169. // //idetinfoStr := string(Idetinfos)
  170. // //
  171. // //if res.Infcode == 0 {
  172. // // his := models.VMHisPatient{
  173. // // Status: 1,
  174. // // Ctime: time.Now().Unix(),
  175. // // Mtime: time.Now().Unix(),
  176. // // PsnNo: res.Output.Baseinfo.PsnNo,
  177. // // PsnCertType: res.Output.Baseinfo.PsnCertType,
  178. // // Certno: res.Output.Baseinfo.Certno,
  179. // // PsnName: res.Output.Baseinfo.PsnName,
  180. // // Gend: res.Output.Baseinfo.Gend,
  181. // // Naty: res.Output.Baseinfo.Naty,
  182. // // Brdy: res.Output.Baseinfo.Brdy,
  183. // // Age: res.Output.Baseinfo.Age,
  184. // // Iinfo: infoStr,
  185. // // Idetinfo: idetinfoStr,
  186. // // UserOrgId: adminUser.CurrentOrgId,
  187. // // IsReturn: 1,
  188. // // IdCardType: id_card_type,
  189. // // }
  190. //
  191. // // patient, err := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
  192. // // if err == gorm.ErrRecordNotFound {
  193. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  194. // // return
  195. // //
  196. // // } else if err != nil {
  197. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  198. // // return
  199. // //
  200. // // } else {
  201. // // c.ServeSuccessJSON(map[string]interface{}{
  202. // // "patient": patient,
  203. // // "number": id_card_number,
  204. // // })
  205. // // }
  206. // //}
  207. // break
  208. // case 3:
  209. //
  210. // break
  211. //
  212. // }
  213. //}
  214. //func GetBasBaseInfo() (jsonStr string, err error) {
  215. //
  216. // handle, err := syscall.LoadLibrary("SSCard.dll")
  217. // if err != nil {
  218. // fmt.Printf("Error: %s\n", err)
  219. // return "", err
  220. // }
  221. // defer syscall.FreeLibrary(handle)
  222. // str := make([]byte, 256)
  223. // str1 := make([]byte, 256)
  224. // add, err := syscall.GetProcAddress(handle, "ReadCardBas")
  225. // if err != nil {
  226. // fmt.Printf("Error: %s\n", err)
  227. // return "", err
  228. // }
  229. // ret, _, _ := syscall.Syscall(add, (uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  230. // if err != nil {
  231. // fmt.Printf("Error: %s\n", err)
  232. // }
  233. // fmt.Println("> Add(4,5)的结果为:", ret)
  234. // //return nil
  235. //
  236. // //
  237. // //handle := syscall.NewLazyDLL("SSCard.dll")
  238. // //ReadCardBas := handle.NewProc("ReadCardBas")
  239. // //
  240. // //var str2 [1024]C.char
  241. // //var str3 [1024]C.char
  242. // //
  243. // //
  244. // //
  245. // ////sssssswwwww
  246. // ////a := 256
  247. // //
  248. // //r, _, _ := ReadCardBas.Call(&str2, 1024, &str3, 1024)
  249. // //fmt.Println(r)
  250. // ////p := (*byte)(unsafe.Pointer(r))
  251. // // define a slice to fill with the p string
  252. // //data := make([]byte, 0)
  253. //
  254. // // loop until find '\0'
  255. // //if *p != 0 {
  256. // //
  257. // // //data = append(data, *p) // append 1 byte
  258. // // //r += unsafe.Sizeof(byte(0)) // move r to next byte
  259. // // //p = (*byte)(unsafe.Pointer(r)) // get the byte value
  260. // //} else {
  261. // // return "", nil
  262. // //
  263. // //}
  264. //
  265. // return "", nil
  266. //
  267. //}
  268. //func GetSFZBaseInfo() (jsonStr string, err error) {
  269. // //handle := syscall.MustLoadDLL("SSCard.dll")
  270. //
  271. // str := make([]byte, 256)
  272. // str1 := make([]byte, 256)
  273. // r, _, _ := ReadIDCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  274. //
  275. // fmt.Println(r)
  276. // return string(str), nil
  277. //}
  278. //func GetQRBaseInfo() (jsonStr string, err error) {
  279. // handle := syscall.LoadDLL("SSCard.dll")
  280. // ReadCardBas := handle.FindProc("GetQRBase")
  281. //
  282. // str := make([]byte, 256)
  283. // str1 := make([]byte, 256)
  284. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  285. //
  286. // fmt.Println(string(str))
  287. // fmt.Println(r)
  288. // return string(str), nil
  289. //}
  290. //func CardInit() int {
  291. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  292. // add := DllTestDef.MustFindProc("Init")
  293. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  294. // if err != nil {
  295. // fmt.Println("SSCard的运算结果为:", ret)
  296. // }
  297. // result := int(ret)
  298. // return result
  299. //}
  300. //func CardInit() int {
  301. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  302. // if err != nil {
  303. // fmt.Println("SSCard的运算结果为:", ret)
  304. // }
  305. // fmt.Println(err)
  306. // result := int(ret)
  307. // return result
  308. //}
  309. //func IntPtr(n int) uintptr {
  310. // return uintptr(n)
  311. //}
  312. //func StrPtr(s string) uintptr {
  313. // return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  314. //}
  315. type ResultTwo struct {
  316. ErrMsg string `json:"err_msg"`
  317. InfRefmsgid string `json:"inf_refmsgid"`
  318. Infcode int64 `json:"infcode"`
  319. Output struct {
  320. Baseinfo struct {
  321. Age float64 `json:"age"`
  322. Brdy string `json:"brdy"`
  323. Certno string `json:"certno"`
  324. Gend string `json:"gend"`
  325. Naty string `json:"naty"`
  326. PsnCertType string `json:"psn_cert_type"`
  327. PsnName string `json:"psn_name"`
  328. PsnNo string `json:"psn_no"`
  329. } `json:"baseinfo"`
  330. Idetinfo []interface{} `json:"idetinfo"`
  331. Iinfo []struct {
  332. Balc int64 `json:"balc"`
  333. CvlservFlag string `json:"cvlserv_flag"`
  334. EmpName string `json:"emp_name"`
  335. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  336. Insutype string `json:"insutype"`
  337. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  338. PausInsuDate interface{} `json:"paus_insu_date"`
  339. PsnInsuDate string `json:"psn_insu_date"`
  340. PsnInsuStas string `json:"psn_insu_stas"`
  341. PsnType string `json:"psn_type"`
  342. } `json:"insuinfo"`
  343. } `json:"output"`
  344. RefmsgTime string `json:"refmsg_time"`
  345. RespondTime string `json:"respond_time"`
  346. Signtype interface{} `json:"signtype"`
  347. WarnInfo interface{} `json:"warn_info"`
  348. }
  349. type ResultThree struct {
  350. Cainfo interface{} `json:"cainfo"`
  351. ErrMsg string `json:"err_msg"`
  352. InfRefmsgid string `json:"inf_refmsgid"`
  353. Infcode int64 `json:"infcode"`
  354. Output struct {
  355. Data struct {
  356. IptOtpNo string `json:"ipt_otp_no"`
  357. MdtrtID string `json:"mdtrt_id"`
  358. PsnNo string `json:"psn_no"`
  359. } `json:"data"`
  360. } `json:"output"`
  361. RefmsgTime string `json:"refmsg_time"`
  362. RespondTime string `json:"respond_time"`
  363. Signtype interface{} `json:"signtype"`
  364. WarnMsg interface{} `json:"warn_msg"`
  365. }
  366. type ResultFour struct {
  367. Cainfo string `json:"cainfo"`
  368. ErrMsg string `json:"err_msg"`
  369. InfRefmsgid string `json:"inf_refmsgid"`
  370. Infcode int64 `json:"infcode"`
  371. Output struct {
  372. Result []struct {
  373. BasMednFlag string `json:"bas_medn_flag"`
  374. ChldMedcFlag string `json:"chld_medc_flag"`
  375. ChrgitmLv string `json:"chrgitm_lv"`
  376. Cnt float64 `json:"cnt"`
  377. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  378. DrtReimFlag string `json:"drt_reim_flag"`
  379. FeedetlSn string `json:"feedetl_sn"`
  380. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  381. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  382. InscpScpAmt float64 `json:"inscp_scp_amt"`
  383. ListSpItemFlag string `json:"list_sp_item_flag"`
  384. LmtUsedFlag string `json:"lmt_used_flag"`
  385. MedChrgitmType string `json:"med_chrgitm_type"`
  386. Memo string `json:"memo"`
  387. OverlmtAmt float64 `json:"overlmt_amt"`
  388. PreselfpayAmt float64 `json:"preselfpay_amt"`
  389. Pric float64 `json:"pric"`
  390. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  391. SelfpayProp float64 `json:"selfpay_prop"`
  392. } `json:"result"`
  393. } `json:"output"`
  394. RefmsgTime string `json:"refmsg_time"`
  395. RespondTime string `json:"respond_time"`
  396. Signtype string `json:"signtype"`
  397. WarnMsg string `json:"warn_msg"`
  398. }
  399. type ResultFive struct {
  400. Insutype string `json:"insutype"`
  401. }
  402. type ResultSix struct {
  403. Cainfo interface{} `json:"cainfo"`
  404. ErrMsg string `json:"err_msg"`
  405. InfRefmsgid string `json:"inf_refmsgid"`
  406. Infcode int64 `json:"infcode"`
  407. Output struct {
  408. } `json:"output"`
  409. RefmsgTime string `json:"refmsg_time"`
  410. RespondTime string `json:"respond_time"`
  411. Signtype interface{} `json:"signtype"`
  412. WarnMsg interface{} `json:"warn_msg"`
  413. }
  414. type ResultSeven struct {
  415. Cainfo string `json:"cainfo"`
  416. ErrMsg string `json:"err_msg"`
  417. InfRefmsgid string `json:"inf_refmsgid"`
  418. Infcode int64 `json:"infcode"`
  419. Output struct {
  420. Setldetail []interface{} `json:"setldetail"`
  421. Setlinfo struct {
  422. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  423. AcctPay float64 `json:"acct_pay"`
  424. ActPayDedc float64 `json:"act_pay_dedc"`
  425. Age float64 `json:"age"`
  426. Balc float64 `json:"balc"`
  427. Brdy string `json:"brdy"`
  428. Certno string `json:"certno"`
  429. ClrOptins string `json:"clr_optins"`
  430. ClrType string `json:"clr_type"`
  431. ClrWay string `json:"clr_way"`
  432. CvlservFlag string `json:"cvlserv_flag"`
  433. CvlservPay float64 `json:"cvlserv_pay"`
  434. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  435. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  436. Gend string `json:"gend"`
  437. HifesPay float64 `json:"hifes_pay"`
  438. HifmiPay float64 `json:"hifmi_pay"`
  439. HifpPay float64 `json:"hifp_pay"`
  440. HospPartAmt float64 `json:"hosp_part_amt"`
  441. InscpScpAmt float64 `json:"inscp_scp_amt"`
  442. Insutype string `json:"insutype"`
  443. MafPay float64 `json:"maf_pay"`
  444. MdtrtCertType string `json:"mdtrt_cert_type"`
  445. HifobPay float64 `json:"hifob_pay"`
  446. MdtrtID string `json:"mdtrt_id"`
  447. MedType string `json:"med_type"`
  448. MedfeeSumamt float64 `json:"medfee_sumamt"`
  449. MedinsSetlID string `json:"medins_setl_id"`
  450. Naty string `json:"naty"`
  451. OthPay float64 `json:"oth_pay"`
  452. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  453. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  454. PreselfpayAmt float64 `json:"preselfpay_amt"`
  455. PsnCashPay float64 `json:"psn_cash_pay"`
  456. PsnCertType string `json:"psn_cert_type"`
  457. PsnName string `json:"psn_name"`
  458. PsnNo string `json:"psn_no"`
  459. PsnPartAmt float64 `json:"psn_part_amt"`
  460. PsnType string `json:"psn_type"`
  461. SetlID string `json:"setl_id"`
  462. SetlTime string `json:"setl_time"`
  463. } `json:"setlinfo"`
  464. } `json:"output"`
  465. RefmsgTime string `json:"refmsg_time"`
  466. RespondTime string `json:"respond_time"`
  467. Signtype interface{} `json:"signtype"`
  468. WarnMsg interface{} `json:"warn_msg"`
  469. }
  470. type ResultEight struct {
  471. Cainfo string `json:"cainfo"`
  472. ErrMsg string `json:"err_msg"`
  473. InfRefmsgid string `json:"inf_refmsgid"`
  474. Infcode int64 `json:"infcode"`
  475. Output struct {
  476. Stmtinfo struct {
  477. SetlOptins string `json:"setl_optins"`
  478. StmtRslt string `json:"stmt_rslt"`
  479. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  480. } `json:"stmtinfo"`
  481. } `json:"output"`
  482. RefmsgTime string `json:"refmsg_time"`
  483. RespondTime string `json:"respond_time"`
  484. Signtype interface{} `json:"signtype"`
  485. WarnMsg interface{} `json:"warn_msg"`
  486. }
  487. type ResultNine struct {
  488. Cainfo string `json:"cainfo"`
  489. ErrMsg string `json:"err_msg"`
  490. InfRefmsgid string `json:"inf_refmsgid"`
  491. Infcode int64 `json:"infcode"`
  492. Output struct {
  493. FileQuryNo string `json:"file_qury_no"`
  494. } `json:"output"`
  495. RefmsgTime string `json:"refmsg_time"`
  496. RespondTime string `json:"respond_time"`
  497. Signtype interface{} `json:"signtype"`
  498. WarnMsg interface{} `json:"warn_msg"`
  499. }
  500. type ResultTen struct {
  501. Cainfo string `json:"cainfo"`
  502. ErrMsg string `json:"err_msg"`
  503. InfRefmsgid string `json:"inf_refmsgid"`
  504. Infcode int64 `json:"infcode"`
  505. Output struct {
  506. DldEndtime string `json:"dld_endtime"`
  507. FileQuryNo string `json:"file_qury_no"`
  508. Filename string `json:"filename"`
  509. } `json:"output"`
  510. RefmsgTime string `json:"refmsg_time"`
  511. RespondTime string `json:"respond_time"`
  512. Signtype interface{} `json:"signtype"`
  513. WarnMsg interface{} `json:"warn_msg"`
  514. }
  515. type ResultEleven struct {
  516. Cainfo string `json:"cainfo"`
  517. ErrMsg string `json:"err_msg"`
  518. InfRefmsgid string `json:"inf_refmsgid"`
  519. Infcode int64 `json:"infcode"`
  520. Output struct {
  521. Setlinfo struct {
  522. FixmedinsName string `json:"fixmedins_name"`
  523. FixmedinsCode string `json:"fixmedins_code"`
  524. PsnNo string `json:"psn_no"`
  525. PsnName string `json:"psn_name"`
  526. HifobPay float64 `json:"hifob_pay"`
  527. Gend string `json:"gend"`
  528. Brdy string `json:"brdy"`
  529. PsnCertType string `json:"psn_cert_type"`
  530. PsnType string `json:"psn_type"`
  531. EmpName string `json:"emp_name"`
  532. Certno string `json:"certno"`
  533. Insutype string `json:"insutype"`
  534. MedfeeSumamt float64 `json:"medfee_sumamt"`
  535. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  536. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  537. PreselfpayAmt float64 `json:"preselfpay_amt"`
  538. InscpScpAmt float64 `json:"inscp_scp_amt"`
  539. ActPayDedc float64 `json:"act_pay_dedc"`
  540. HifpPay float64 `json:"hifp_pay"`
  541. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  542. CvlservPay float64 `json:"cvlserv_pay"`
  543. HifesPay float64 `json:"hifes_pay"`
  544. HifmiPay float64 `json:"hifmi_pay"`
  545. MafPay float64 `json:"maf_pay"`
  546. OthPay float64 `json:"oth_pay"`
  547. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  548. PsnPay float64 `json:"psn_pay"`
  549. AcctPay float64 `json:"acct_pay"`
  550. CashPayamt float64 `json:"cash_payamt"`
  551. Balc float64 `json:"balc"`
  552. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  553. MedinsSetlId string `json:"medins_setl_id"`
  554. RefdSetlFlag string `json:"refd_setl_flag"`
  555. SetlTime string `json:"setl_time"`
  556. MedType string `json:"med_type"`
  557. HospLv string `json:"hosp_lv"`
  558. } `json:"setlinfo"`
  559. } `json:"output"`
  560. RefmsgTime string `json:"refmsg_time"`
  561. RespondTime string `json:"respond_time"`
  562. Signtype interface{} `json:"signtype"`
  563. WarnMsg interface{} `json:"warn_msg"`
  564. }
  565. type ResultTwelve struct {
  566. Cainfo string `json:"cainfo"`
  567. ErrMsg string `json:"err_msg"`
  568. InfRefmsgid string `json:"inf_refmsgid"`
  569. Infcode int64 `json:"infcode"`
  570. Output struct {
  571. MdtrtId string `json:"mdtrt_id"`
  572. ChrgBchno string `json:"chrg_bchno"`
  573. PsnNo string `json:"psn_no"`
  574. } `json:"output"`
  575. RefmsgTime string `json:"refmsg_time"`
  576. RespondTime string `json:"respond_time"`
  577. Signtype interface{} `json:"signtype"`
  578. WarnMsg interface{} `json:"warn_msg"`
  579. }
  580. type Custom struct {
  581. DetItemFeeSumamt string
  582. Cut string
  583. FeedetlSn string
  584. Price string
  585. MedListCodg string
  586. Type int64
  587. AdviceId int64
  588. ProjectId int64
  589. ItemId int64
  590. }
  591. //获取个人信息----挂号-----上传就诊信息
  592. func (c *SZHisApiController) GetRegisterInfo() {
  593. id, _ := c.GetInt64("id")
  594. record_time := c.GetString("record_time")
  595. settlementValue, _ := c.GetInt64("settlement_value")
  596. medical_insurance_card := c.GetString("medical_insurance_card")
  597. name := c.GetString("name")
  598. id_card_type, _ := c.GetInt64("id_card_type")
  599. certificates, _ := c.GetInt64("certificates")
  600. medical_care, _ := c.GetInt64("medical_care")
  601. birthday := c.GetString("birthday")
  602. age, _ := c.GetInt64("age")
  603. id_card := c.GetString("id_card")
  604. register_type, _ := c.GetInt64("register")
  605. doctor, _ := c.GetInt64("doctor")
  606. department, _ := c.GetInt64("department")
  607. gender, _ := c.GetInt64("sex")
  608. phone := c.GetString("phone")
  609. registration_fee, _ := c.GetFloat("registration_fee")
  610. medical_expenses, _ := c.GetFloat("medical_expenses")
  611. social_type, _ := c.GetInt64("social_type")
  612. admin_user_id, _ := c.GetInt64("admin_user_id")
  613. diagnosis_id, _ := c.GetInt64("diagnosis")
  614. sick_type, _ := c.GetInt64("sick_type")
  615. reg_type := c.GetString("p_type")
  616. timeLayout := "2006-01-02"
  617. loc, _ := time.LoadLocation("Local")
  618. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  619. birthUnix := birthdays.Unix()
  620. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  621. if err != nil {
  622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  623. return
  624. }
  625. recordDateTime := theTime.Unix()
  626. adminInfo := c.GetAdminUserInfo()
  627. var patient service.Patients
  628. if id == 0 {
  629. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  630. } else {
  631. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  632. }
  633. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  634. if patientPrescription.ID == 0 {
  635. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  636. }
  637. //adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
  638. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  639. //sickConfig, _ := service.FindSickById(sick_type)
  640. //miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  641. if patient.ID == 0 {
  642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  643. return
  644. }
  645. if len(patient.IdCardNo) == 0 {
  646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  647. return
  648. }
  649. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  650. if config.IsOpen == 1 {
  651. //c.ServeSuccessJSON(map[string]interface{}{
  652. // "his_info": hisPatient,
  653. //})
  654. }
  655. }
  656. //上传明细----预结算----确认订单
  657. //func (c *SZHisApiController) GetUploadInfo() {
  658. // id, _ := c.GetInt64("id")
  659. // record_time := c.GetString("record_time")
  660. // //pay_way, _ := c.GetInt64("pay_way")
  661. // //pay_price, _ := c.GetFloat("pay_price")
  662. // //pay_card_no := c.GetString("pay_card_no")
  663. // //discount_price, _ := c.GetFloat("discount_price")
  664. // //preferential_price, _ := c.GetFloat("preferential_price")
  665. // //reality_price, _ := c.GetFloat("reality_price")
  666. // //found_price, _ := c.GetFloat("found_price")
  667. // //medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  668. // //private_price, _ := c.GetFloat("private_price")
  669. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  670. // admin_user_id, _ := c.GetInt64("admin_user_id")
  671. //
  672. // timeLayout := "2006-01-02"
  673. // loc, _ := time.LoadLocation("Local")
  674. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  675. // if err != nil {
  676. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  677. // return
  678. // }
  679. // recordDateTime := theTime.Unix()
  680. // adminUser := c.GetAdminUserInfo()
  681. //
  682. // var prescriptions []*models.HisPrescription
  683. //
  684. // var start_time int64
  685. // var end_time int64
  686. //
  687. // data := make(map[string]interface{})
  688. // if settle_accounts_type == 1 { //日结
  689. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  690. // data["pre"] = prescriptions
  691. //
  692. // } else { //月结
  693. // start_time_str := c.GetString("start_time")
  694. // end_time_str := c.GetString("end_time")
  695. // timeLayout := "2006-01-02"
  696. // loc, _ := time.LoadLocation("Local")
  697. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  698. // if err != nil {
  699. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  700. // return
  701. // }
  702. // recordStartTime := theStartTime.Unix()
  703. // start_time = recordStartTime
  704. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  705. // if err != nil {
  706. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  707. // return
  708. // }
  709. // recordEndTime := theEndTime.Unix()
  710. // end_time = recordEndTime
  711. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  712. // data["pre"] = prescriptions
  713. //
  714. // }
  715. //
  716. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  717. //
  718. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  719. // timestamp := time.Now().Unix()
  720. // tempTime := time.Unix(timestamp, 0)
  721. // timeFormat := tempTime.Format("20060102150405")
  722. // chrgBchno := rand.Intn(100000) + 10000
  723. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  724. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  725. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  726. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  727. // strconv.FormatInt(his.PatientId, 10)
  728. // client := &http.Client{}
  729. // data["psn_no"] = his.PsnNo
  730. // data["mdtrt_id"] = his.Number
  731. // data["chrg_bchno"] = chrg_bchno
  732. // data["org_name"] = miConfig.OrgName
  733. // data["doctor"] = roles.UserName
  734. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  735. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  736. // data["fixmedins_code"] = miConfig.Code
  737. // data["dept_code"] = department.Number
  738. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  739. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  740. // data["secret_key"] = miConfig.SecretKey
  741. // var ids []int64
  742. //
  743. // for _, item := range prescriptions {
  744. // ids = append(ids, item.ID)
  745. // }
  746. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  747. // if config.IsOpen == 1 { //对接了医保,走医保流程
  748. // bytesData, _ := json.Marshal(data)
  749. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  750. // resp, _ := client.Do(req)
  751. // defer resp.Body.Close()
  752. // body, ioErr := ioutil.ReadAll(resp.Body)
  753. // if ioErr != nil {
  754. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  755. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  756. // return
  757. // }
  758. // var respJSON map[string]interface{}
  759. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  760. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  761. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  762. // return
  763. // }
  764. //
  765. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  766. // userJSONBytes, _ := json.Marshal(respJSON)
  767. // var res ResultFour
  768. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  769. // utils.ErrorLog("解析失败:%v", err)
  770. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  771. // return
  772. // }
  773. //
  774. // if res.Infcode == 0 {
  775. // order := &models.HisOrder{
  776. // UserOrgId: adminUser.CurrentOrgId,
  777. // HisPatientId: his.ID,
  778. // PatientId: his.PatientId,
  779. // SettleAccountsDate: recordDateTime,
  780. // Ctime: time.Now().Unix(),
  781. // Mtime: time.Now().Unix(),
  782. // Status: 1,
  783. // Number: chrg_bchno,
  784. // Infcode: res.Infcode,
  785. // WarnMsg: res.WarnMsg,
  786. // Cainfo: res.Cainfo,
  787. // ErrMsg: res.ErrMsg,
  788. // RespondTime: res.RefmsgTime,
  789. // InfRefmsgid: res.InfRefmsgid,
  790. // OrderStatus: 1,
  791. // IsMedicineInsurance: 1,
  792. // SettleType: settle_accounts_type,
  793. // SettleStartTime: start_time,
  794. // SettleEndTime: end_time,
  795. // Creator: roles.ID,
  796. // Modify: roles.ID,
  797. // }
  798. // err = service.CreateOrder(order)
  799. // if err != nil {
  800. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  801. // return
  802. // }
  803. //
  804. // for _, item := range res.Output.Result {
  805. // temp := strings.Split(item.FeedetlSn, "-")
  806. // var advice_id int64 = 0
  807. // var project_id int64 = 0
  808. // var types int64 = 0
  809. //
  810. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  811. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  812. //
  813. // if temp[1] == "1" {
  814. // advice_id = id
  815. // project_id = 0
  816. // } else if temp[1] == "2" {
  817. // advice_id = 0
  818. // project_id = id
  819. // }
  820. //
  821. // info := &models.HisOrderInfo{
  822. // OrderNumber: order.Number,
  823. // FeedetlSn: item.FeedetlSn,
  824. // UploadDate: time.Now().Unix(),
  825. // AdviceId: advice_id,
  826. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  827. // Cnt: item.Cnt,
  828. // Pric: float64(item.Pric),
  829. // PatientId: his.PatientId,
  830. // PricUplmtAmt: item.PricUplmtAmt,
  831. // SelfpayProp: item.SelfpayProp,
  832. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  833. // OverlmtAmt: item.OverlmtAmt,
  834. // PreselfpayAmt: item.PreselfpayAmt,
  835. // BasMednFlag: item.BasMednFlag,
  836. // MedChrgitmType: item.MedChrgitmType,
  837. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  838. // Status: 1,
  839. // Memo: item.Memo,
  840. // Mtime: time.Now().Unix(),
  841. // InscpScpAmt: item.InscpScpAmt,
  842. // DrtReimFlag: item.DrtReimFlag,
  843. // Ctime: time.Now().Unix(),
  844. // ListSpItemFlag: item.ListSpItemFlag,
  845. // ChldMedcFlag: item.ChldMedcFlag,
  846. // LmtUsedFlag: item.LmtUsedFlag,
  847. // ChrgitmLv: item.ChrgitmLv,
  848. // UserOrgId: adminUser.CurrentOrgId,
  849. // HisPatientId: his.ID,
  850. // OrderId: order.ID,
  851. // ProjectId: project_id,
  852. // Type: types,
  853. // }
  854. // service.CreateOrderInfo(info)
  855. //
  856. // }
  857. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  858. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  859. //
  860. // var total float64
  861. // for _, item := range prescriptions {
  862. // if item.Type == 1 { //药品
  863. // for _, subItem := range item.HisDoctorAdviceInfo {
  864. // total = total + (subItem.Price * subItem.PrescribingNumber)
  865. // }
  866. // }
  867. // if item.Type == 2 { //项目
  868. // for _, subItem := range item.HisPrescriptionProject {
  869. // total = total + (subItem.Price * float64(subItem.Count))
  870. // }
  871. // }
  872. // }
  873. //
  874. // for _, item := range prescriptions {
  875. // for _, subItem := range item.HisAdditionalCharge {
  876. // total = total + (subItem.Price * float64(subItem.Count))
  877. // }
  878. // }
  879. //
  880. // allTotal := fmt.Sprintf("%.2f", total)
  881. // if res.Infcode == 0 {
  882. // var rf []*ResultFive
  883. // json.Unmarshal([]byte(his.Iinfo), &rf)
  884. // psn_no := his.PsnNo
  885. // mdtrt_id := his.Number
  886. // chrg_bchno := chrg_bchno
  887. // cert_no := his.Certno
  888. // insutype := rf[0].Insutype
  889. //
  890. // if his.IdCardType == 1 {
  891. // cert_no = his.MedicalInsuranceNumber
  892. //
  893. // } else {
  894. //
  895. // cert_no = his.Certno
  896. //
  897. // }
  898. //
  899. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  900. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  901. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  902. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  903. // resp, requestErr := http.Get(api)
  904. // if requestErr != nil {
  905. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  906. // return
  907. // }
  908. // defer resp.Body.Close()
  909. // body, ioErr := ioutil.ReadAll(resp.Body)
  910. // if ioErr != nil {
  911. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  912. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  913. // return
  914. // }
  915. // var respJSON map[string]interface{}
  916. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  917. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  918. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  919. // return
  920. // }
  921. // fmt.Println(respJSON)
  922. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  923. // userJSONBytes, _ := json.Marshal(respJSON)
  924. // var res ResultSeven
  925. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  926. // utils.ErrorLog("解析失败:%v", err)
  927. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  928. // return
  929. // }
  930. // if res.Infcode == -1 {
  931. // errlog := &models.HisOrderError{
  932. // UserOrgId: adminUser.CurrentOrgId,
  933. // Ctime: time.Now().Unix(),
  934. // Mtime: time.Now().Unix(),
  935. // Number: chrg_bchno,
  936. // ErrMsg: res.ErrMsg,
  937. // Status: 1,
  938. // PatientId: id,
  939. // RecordTime: recordDateTime,
  940. // Stage: 7,
  941. // }
  942. // service.CreateErrMsgLog(errlog)
  943. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  944. // return
  945. // } else {
  946. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  947. // order.OrderStatus = 1
  948. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  949. // order.SetlId = res.Output.Setlinfo.SetlID
  950. // order.PsnNo = res.Output.Setlinfo.PsnNo
  951. // order.PsnName = res.Output.Setlinfo.PsnName
  952. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  953. // order.Certno = res.Output.Setlinfo.Certno
  954. // order.Gend = res.Output.Setlinfo.Gend
  955. // order.Naty = res.Output.Setlinfo.Naty
  956. // order.Age = res.Output.Setlinfo.Age
  957. // order.Insutype = res.Output.Setlinfo.Insutype
  958. // order.PsnType = res.Output.Setlinfo.PsnType
  959. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  960. // order.SetlTime = res.Output.Setlinfo.SetlTime
  961. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  962. // order.MedType = res.Output.Setlinfo.MedType
  963. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  964. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  965. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  966. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  967. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  968. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  969. // order.HifpPay = res.Output.Setlinfo.HifpPay
  970. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  971. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  972. // order.HifesPay = res.Output.Setlinfo.HifesPay
  973. // order.HifobPay = res.Output.Setlinfo.HifobPay
  974. // order.MafPay = res.Output.Setlinfo.MafPay
  975. // order.OthPay = res.Output.Setlinfo.OthPay
  976. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  977. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  978. // order.AcctPay = res.Output.Setlinfo.AcctPay
  979. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  980. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  981. // order.Balc = res.Output.Setlinfo.Balc
  982. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  983. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  984. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  985. // order.ClrWay = res.Output.Setlinfo.ClrWay
  986. // order.Creator = order.Creator
  987. // order.Modify = roles.ID
  988. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  989. // detailStr := string(setlDetail)
  990. // order.SetlDetail = detailStr
  991. //
  992. // //err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  993. // err = service.UpDateOrder(order)
  994. //
  995. // //订单确认
  996. // result := service.Gdyb6201(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, order)
  997. //
  998. // var dat map[string]interface{}
  999. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1000. // userJSONBytes, _ := json.Marshal(dat)
  1001. // var res ResultTwelve
  1002. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1003. // utils.ErrorLog("解析失败:%v", err)
  1004. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1005. // return
  1006. // }
  1007. // if res.Infcode == 0 {
  1008. // if err == nil {
  1009. // c.ServeSuccessJSON(map[string]interface{}{
  1010. // "msg": "预结算成功",
  1011. // })
  1012. // } else {
  1013. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
  1014. // return
  1015. // }
  1016. //
  1017. // } else {
  1018. // adminUser := c.GetAdminUserInfo()
  1019. // errlog := &models.HisOrderError{
  1020. // UserOrgId: adminUser.CurrentOrgId,
  1021. // Ctime: time.Now().Unix(),
  1022. // Mtime: time.Now().Unix(),
  1023. // ErrMsg: res.ErrMsg,
  1024. // Status: 1,
  1025. // PatientId: id,
  1026. // RecordTime: recordDateTime,
  1027. // Stage: 8,
  1028. // }
  1029. // service.CreateErrMsgLog(errlog)
  1030. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  1031. // }
  1032. // } else {
  1033. // fmt.Println(err)
  1034. // }
  1035. //
  1036. // }
  1037. // } else {
  1038. // adminUser := c.GetAdminUserInfo()
  1039. // errlog := &models.HisOrderError{
  1040. // UserOrgId: adminUser.CurrentOrgId,
  1041. // Ctime: time.Now().Unix(),
  1042. // Mtime: time.Now().Unix(),
  1043. // ErrMsg: res.ErrMsg,
  1044. // Status: 1,
  1045. // PatientId: id,
  1046. // RecordTime: recordDateTime,
  1047. // Stage: 4,
  1048. // }
  1049. // service.CreateErrMsgLog(errlog)
  1050. //
  1051. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  1052. // return
  1053. // }
  1054. // } else {
  1055. // adminUser := c.GetAdminUserInfo()
  1056. // errlog := &models.HisOrderError{
  1057. // UserOrgId: adminUser.CurrentOrgId,
  1058. // Ctime: time.Now().Unix(),
  1059. // Mtime: time.Now().Unix(),
  1060. // ErrMsg: res.ErrMsg,
  1061. // Status: 1,
  1062. // PatientId: id,
  1063. // RecordTime: recordDateTime,
  1064. // Stage: 4,
  1065. // }
  1066. // service.CreateErrMsgLog(errlog)
  1067. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  1068. // return
  1069. // }
  1070. //
  1071. // }
  1072. //}
  1073. //func (c *SZHisApiController) GetSettleInfo() {
  1074. // id, _ := c.GetInt64("id")
  1075. // order_id, _ := c.GetInt64("order_id")
  1076. //
  1077. // record_time := c.GetString("record_time")
  1078. // pay_way, _ := c.GetInt64("pay_way")
  1079. // pay_price, _ := c.GetFloat("pay_price")
  1080. // pay_card_no := c.GetString("pay_card_no")
  1081. // discount_price, _ := c.GetFloat("discount_price")
  1082. // preferential_price, _ := c.GetFloat("preferential_price")
  1083. // reality_price, _ := c.GetFloat("reality_price")
  1084. // found_price, _ := c.GetFloat("found_price")
  1085. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  1086. // private_price, _ := c.GetFloat("private_price")
  1087. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1088. // admin_user_id, _ := c.GetInt64("admin_user_id")
  1089. //
  1090. // timeLayout := "2006-01-02"
  1091. // loc, _ := time.LoadLocation("Local")
  1092. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1093. // if err != nil {
  1094. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1095. // return
  1096. // }
  1097. // recordDateTime := theTime.Unix()
  1098. // adminUser := c.GetAdminUserInfo()
  1099. //
  1100. // var prescriptions []*models.HisPrescription
  1101. //
  1102. // data := make(map[string]interface{})
  1103. // if settle_accounts_type == 1 { //日结
  1104. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  1105. // data["pre"] = prescriptions
  1106. //
  1107. // } else { //月结
  1108. // start_time_str := c.GetString("start_time")
  1109. // end_time_str := c.GetString("end_time")
  1110. // timeLayout := "2006-01-02"
  1111. // loc, _ := time.LoadLocation("Local")
  1112. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  1113. // if err != nil {
  1114. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1115. // return
  1116. // }
  1117. // recordStartTime := theStartTime.Unix()
  1118. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  1119. // if err != nil {
  1120. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1121. // return
  1122. // }
  1123. // recordEndTime := theEndTime.Unix()
  1124. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  1125. // data["pre"] = prescriptions
  1126. //
  1127. // }
  1128. //
  1129. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1130. //
  1131. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1132. // timestamp := time.Now().Unix()
  1133. // tempTime := time.Unix(timestamp, 0)
  1134. // timeFormat := tempTime.Format("20060102150405")
  1135. // chrgBchno := rand.Intn(100000) + 10000
  1136. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  1137. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1138. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1139. // strconv.FormatInt(his.PatientId, 10)
  1140. //
  1141. // order_src, _ := service.GetHisOrderByID(order_id)
  1142. //
  1143. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1144. // if config.IsOpen == 1 { //对接了医保,走医保流程
  1145. //
  1146. // var total float64
  1147. // for _, item := range prescriptions {
  1148. // if item.Type == 1 { //药品
  1149. // for _, subItem := range item.HisDoctorAdviceInfo {
  1150. // total = total + (subItem.Price * subItem.PrescribingNumber)
  1151. // }
  1152. // }
  1153. // if item.Type == 2 { //项目
  1154. // for _, subItem := range item.HisPrescriptionProject {
  1155. // total = total + (subItem.Price * float64(subItem.Count))
  1156. // }
  1157. // }
  1158. // }
  1159. //
  1160. // for _, item := range prescriptions {
  1161. // for _, subItem := range item.HisAdditionalCharge {
  1162. // total = total + (subItem.Price * float64(subItem.Count))
  1163. // }
  1164. // }
  1165. //
  1166. // allTotal := fmt.Sprintf("%.2f", total)
  1167. // var rf []*ResultFive
  1168. // json.Unmarshal([]byte(his.Iinfo), &rf)
  1169. // psn_no := his.PsnNo
  1170. // mdtrt_id := his.Number
  1171. // chrg_bchno := chrg_bchno
  1172. // cert_no := his.Certno
  1173. // insutype := rf[0].Insutype
  1174. //
  1175. // if his.IdCardType == 1 {
  1176. // cert_no = his.MedicalInsuranceNumber
  1177. // } else {
  1178. // cert_no = his.Certno
  1179. // }
  1180. //
  1181. // api := "http://127.0.0.1:9532/" + "gdyb/eight?cert_no=" + cert_no + "&insutype=" +
  1182. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  1183. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  1184. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10) + "&fulamt_ownpay_amt=" + strconv.FormatFloat(order_src.FulamtOwnpayAmt, 'E', -1, 64) + "&overlmt_selfpay=" + strconv.FormatFloat(order_src.OverlmtSelfPay, 'E', -1, 64) + "&preselfpay_amt=" + strconv.FormatFloat(order_src.PreselfpayAmt, 'E', -1, 64) + "&inscp_scp_amt=" + strconv.FormatFloat(order_src.InscpScpAmt, 'E', -1, 64)
  1185. // resp, requestErr := http.Get(api)
  1186. // if requestErr != nil {
  1187. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1188. // return
  1189. // }
  1190. // defer resp.Body.Close()
  1191. // body, ioErr := ioutil.ReadAll(resp.Body)
  1192. // if ioErr != nil {
  1193. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1194. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1195. // return
  1196. // }
  1197. // var respJSON map[string]interface{}
  1198. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1199. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1200. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1201. // return
  1202. // }
  1203. // fmt.Println(respJSON)
  1204. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1205. // userJSONBytes, _ := json.Marshal(respJSON)
  1206. // var res ResultSeven
  1207. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1208. // utils.ErrorLog("解析失败:%v", err)
  1209. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1210. // return
  1211. // }
  1212. // if res.Infcode == -1 {
  1213. // errlog := &models.HisOrderError{
  1214. // UserOrgId: adminUser.CurrentOrgId,
  1215. // Ctime: time.Now().Unix(),
  1216. // Mtime: time.Now().Unix(),
  1217. // Number: chrg_bchno,
  1218. // ErrMsg: res.ErrMsg,
  1219. // Status: 1,
  1220. // PatientId: id,
  1221. // RecordTime: recordDateTime,
  1222. // Stage: 6,
  1223. // }
  1224. // service.CreateErrMsgLog(errlog)
  1225. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  1226. // return
  1227. // } else {
  1228. // order_src.OrderStatus = 2
  1229. // order_src.PayWay = pay_way
  1230. // order_src.PayPrice = pay_price
  1231. // order_src.PayCardNo = pay_card_no
  1232. // order_src.DiscountPrice = discount_price
  1233. // order_src.PreferentialPrice = preferential_price
  1234. // order_src.RealityPrice = reality_price
  1235. // order_src.FoundPrice = found_price
  1236. // order_src.MedicalInsurancePrice = medical_insurance_price
  1237. // order_src.PrivatePrice = private_price
  1238. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  1239. // order_src.SetlId = res.Output.Setlinfo.SetlID
  1240. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  1241. // order_src.PsnName = res.Output.Setlinfo.PsnName
  1242. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  1243. // order_src.Certno = res.Output.Setlinfo.Certno
  1244. // order_src.Gend = res.Output.Setlinfo.Gend
  1245. // order_src.Naty = res.Output.Setlinfo.Naty
  1246. // order_src.Age = res.Output.Setlinfo.Age
  1247. // order_src.Insutype = res.Output.Setlinfo.Insutype
  1248. // order_src.PsnType = res.Output.Setlinfo.PsnType
  1249. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  1250. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  1251. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  1252. // order_src.MedType = res.Output.Setlinfo.MedType
  1253. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  1254. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  1255. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  1256. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  1257. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  1258. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  1259. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  1260. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  1261. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  1262. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  1263. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  1264. // order_src.MafPay = res.Output.Setlinfo.MafPay
  1265. // order_src.OthPay = res.Output.Setlinfo.OthPay
  1266. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  1267. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  1268. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  1269. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  1270. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  1271. // order_src.Balc = res.Output.Setlinfo.Balc
  1272. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  1273. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  1274. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  1275. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  1276. // order_src.Creator = order_src.Creator
  1277. // order_src.Modify = roles.ID
  1278. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  1279. // detailStr := string(setlDetail)
  1280. // order_src.SetlDetail = detailStr
  1281. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  1282. // err = service.UpDateOrder(order_src)
  1283. //
  1284. // if err == nil {
  1285. // c.ServeSuccessJSON(map[string]interface{}{
  1286. // "msg": "结算成功",
  1287. // })
  1288. // } else {
  1289. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  1290. // return
  1291. // }
  1292. // }
  1293. // }
  1294. //}
  1295. //退款
  1296. //func (c *SZHisApiController) Refund() {
  1297. // order_id, _ := c.GetInt64("order_id")
  1298. // number := c.GetString("number")
  1299. // record_time := c.GetString("record_time")
  1300. // patient_id, _ := c.GetInt64("patient_id")
  1301. // timeLayout := "2006-01-02"
  1302. // loc, _ := time.LoadLocation("Local")
  1303. // adminUser := c.GetAdminUserInfo()
  1304. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1305. // fmt.Println(err)
  1306. // if err != nil {
  1307. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1308. // return
  1309. // }
  1310. // recordDateTime := theTime.Unix()
  1311. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1312. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1313. // var order models.HisOrder
  1314. // order, _ = service.GetHisOrderByID(order_id)
  1315. //
  1316. // if order.ID == 0 {
  1317. // order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  1318. //
  1319. // }
  1320. //
  1321. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1322. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1323. //
  1324. // if config.IsOpen == 1 { //对接了医保,走医保流程
  1325. // api := "http://127.0.0.1:9532/" + "gdyb/nine?psn_no=" + his.PsnNo +
  1326. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&setl_id=" + order.SetlId + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  1327. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  1328. // resp, requestErr := http.Get(api)
  1329. // if requestErr != nil {
  1330. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1331. // return
  1332. // }
  1333. // body, ioErr := ioutil.ReadAll(resp.Body)
  1334. // if ioErr != nil {
  1335. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1336. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1337. // return
  1338. // }
  1339. // var respJSON map[string]interface{}
  1340. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1341. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1342. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1343. // return
  1344. // }
  1345. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1346. // userJSONBytes, _ := json.Marshal(respJSON)
  1347. // fmt.Println(respJSON)
  1348. // fmt.Println(userJSONBytes)
  1349. //
  1350. // api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  1351. // "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  1352. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  1353. // resp2, requestErr2 := http.Get(api2)
  1354. // if requestErr2 != nil {
  1355. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1356. // return
  1357. // }
  1358. //
  1359. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1360. // if ioErr2 != nil {
  1361. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1362. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1363. // return
  1364. // }
  1365. // var respJSON2 map[string]interface{}
  1366. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  1367. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1368. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1369. // return
  1370. // }
  1371. //
  1372. // //api3 := "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  1373. // // "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  1374. // // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  1375. // //resp3, requestErr3 := http.Get(api3)
  1376. // //if requestErr3 != nil {
  1377. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1378. // // return
  1379. // //}
  1380. // //
  1381. // //body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  1382. // //if ioErr3 != nil {
  1383. // // utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  1384. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1385. // // return
  1386. // //}
  1387. // //var respJSON3 map[string]interface{}
  1388. // //if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  1389. // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1390. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1391. // // return
  1392. // //}
  1393. // err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  1394. // //service.UpdataRegStatus(patient_id, recordDateTime, adminUser.CurrentOrgId)
  1395. //
  1396. // if err == nil {
  1397. // c.ServeSuccessJSON(map[string]interface{}{
  1398. // "msg": "退费成功",
  1399. // })
  1400. // } else {
  1401. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1402. // return
  1403. // }
  1404. // } else {
  1405. // err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  1406. // if err == nil {
  1407. // c.ServeSuccessJSON(map[string]interface{}{
  1408. // "msg": "退费成功",
  1409. // })
  1410. // } else {
  1411. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1412. // return
  1413. // }
  1414. // }
  1415. //}
  1416. //func (c *SZHisApiController) RefundNumber() {
  1417. // record_time := c.GetString("record_time")
  1418. // patient_id, _ := c.GetInt64("patient_id")
  1419. // timeLayout := "2006-01-02"
  1420. // loc, _ := time.LoadLocation("Local")
  1421. // adminUser := c.GetAdminUserInfo()
  1422. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1423. // fmt.Println(err)
  1424. // if err != nil {
  1425. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1426. // return
  1427. // }
  1428. // recordDateTime := theTime.Unix()
  1429. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1430. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1431. // //order, _ := service.GetHisOrderByID(order_id)
  1432. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1433. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1434. //
  1435. // if config.IsOpen == 1 { //对接了医保,走医保流程
  1436. //
  1437. // api3 := "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  1438. // "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  1439. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  1440. // resp3, requestErr3 := http.Get(api3)
  1441. // if requestErr3 != nil {
  1442. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1443. // return
  1444. // }
  1445. //
  1446. // body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  1447. // if ioErr3 != nil {
  1448. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  1449. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1450. // return
  1451. // }
  1452. // var respJSON3 map[string]interface{}
  1453. // if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  1454. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1455. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1456. // return
  1457. // }
  1458. //
  1459. // //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  1460. // service.UpdataRegStatus(patient_id, recordDateTime, adminUser.CurrentOrgId)
  1461. //
  1462. // if err == nil {
  1463. // c.ServeSuccessJSON(map[string]interface{}{
  1464. // "msg": "退费成功",
  1465. // })
  1466. // } else {
  1467. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1468. // return
  1469. // }
  1470. // } else {
  1471. // //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  1472. // //if err == nil {
  1473. // // c.ServeSuccessJSON(map[string]interface{}{
  1474. // // "msg": "退费成功",
  1475. // // })
  1476. // //} else {
  1477. // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1478. // // return
  1479. // //}
  1480. // }
  1481. //}
  1482. //func (c *SZHisApiController) RefundDetail() {
  1483. // order_id, _ := c.GetInt64("order_id")
  1484. // number := c.GetString("number")
  1485. // record_time := c.GetString("record_time")
  1486. // patient_id, _ := c.GetInt64("patient_id")
  1487. // timeLayout := "2006-01-02"
  1488. // loc, _ := time.LoadLocation("Local")
  1489. // adminUser := c.GetAdminUserInfo()
  1490. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1491. // fmt.Println(err)
  1492. // if err != nil {
  1493. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1494. // return
  1495. // }
  1496. // recordDateTime := theTime.Unix()
  1497. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1498. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1499. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1500. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1501. //
  1502. // var order models.HisOrder
  1503. // order, _ = service.GetHisOrderByID(order_id)
  1504. //
  1505. // if order.ID == 0 {
  1506. // order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  1507. //
  1508. // }
  1509. //
  1510. // if config.IsOpen == 1 { //对接了医保,走医保流程
  1511. // api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  1512. // "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  1513. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  1514. // resp2, requestErr2 := http.Get(api2)
  1515. // if requestErr2 != nil {
  1516. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1517. // return
  1518. // }
  1519. //
  1520. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1521. // if ioErr2 != nil {
  1522. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1523. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1524. // return
  1525. // }
  1526. // var respJSON2 map[string]interface{}
  1527. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  1528. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1529. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1530. // return
  1531. // }
  1532. //
  1533. // err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  1534. // if err == nil {
  1535. // c.ServeSuccessJSON(map[string]interface{}{
  1536. // "msg": "退费成功",
  1537. // })
  1538. // } else {
  1539. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1540. // return
  1541. // }
  1542. // } else {
  1543. // err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  1544. // if err == nil {
  1545. // c.ServeSuccessJSON(map[string]interface{}{
  1546. // "msg": "退费成功",
  1547. // })
  1548. // } else {
  1549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1550. // return
  1551. // }
  1552. // }
  1553. //}