sz_his_api_controller.go 65KB

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