zh_his_api_controller.go 67KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027
  1. package zh
  2. import (
  3. "bytes"
  4. "encoding/json"
  5. "fmt"
  6. "gdyb/controllers"
  7. "gdyb/enums"
  8. "gdyb/models"
  9. "gdyb/service"
  10. "gdyb/utils"
  11. "github.com/astaxie/beego"
  12. "io/ioutil"
  13. "math"
  14. "math/rand"
  15. "net/http"
  16. "strconv"
  17. "strings"
  18. "time"
  19. )
  20. type ZHHisApiController struct {
  21. controllers.BaseAuthAPIController
  22. }
  23. type ResultTwo struct {
  24. ErrMsg string `json:"err_msg"`
  25. InfRefmsgid string `json:"inf_refmsgid"`
  26. Infcode int64 `json:"infcode"`
  27. Output struct {
  28. Baseinfo struct {
  29. Age float64 `json:"age"`
  30. Brdy string `json:"brdy"`
  31. Certno string `json:"certno"`
  32. Gend string `json:"gend"`
  33. Naty string `json:"naty"`
  34. PsnCertType string `json:"psn_cert_type"`
  35. PsnName string `json:"psn_name"`
  36. PsnNo string `json:"psn_no"`
  37. } `json:"baseinfo"`
  38. Idetinfo []interface{} `json:"idetinfo"`
  39. Iinfo []struct {
  40. Balc float64 `json:"balc"`
  41. CvlservFlag string `json:"cvlserv_flag"`
  42. EmpName string `json:"emp_name"`
  43. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  44. Insutype string `json:"insutype"`
  45. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  46. PausInsuDate string `json:"paus_insu_date"`
  47. PsnInsuDate string `json:"psn_insu_date"`
  48. PsnInsuStas string `json:"psn_insu_stas"`
  49. PsnType string `json:"psn_type"`
  50. } `json:"insuinfo"`
  51. } `json:"output"`
  52. RefmsgTime string `json:"refmsg_time"`
  53. RespondTime string `json:"respond_time"`
  54. Signtype interface{} `json:"signtype"`
  55. WarnInfo interface{} `json:"warn_info"`
  56. }
  57. type ResultTwo10265 struct {
  58. ErrMsg string `json:"err_msg"`
  59. InfRefmsgid string `json:"inf_refmsgid"`
  60. Infcode string `json:"infcode"`
  61. Output struct {
  62. Baseinfo struct {
  63. Age float64 `json:"age"`
  64. Brdy string `json:"brdy"`
  65. Certno string `json:"certno"`
  66. Gend string `json:"gend"`
  67. Naty string `json:"naty"`
  68. PsnCertType string `json:"psn_cert_type"`
  69. PsnName string `json:"psn_name"`
  70. PsnNo string `json:"psn_no"`
  71. } `json:"baseinfo"`
  72. Idetinfo []interface{} `json:"idetinfo"`
  73. Iinfo []struct {
  74. Balc float64 `json:"balc"`
  75. CvlservFlag string `json:"cvlserv_flag"`
  76. EmpName string `json:"emp_name"`
  77. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  78. Insutype string `json:"insutype"`
  79. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  80. PausInsuDate string `json:"paus_insu_date"`
  81. PsnInsuDate string `json:"psn_insu_date"`
  82. PsnInsuStas string `json:"psn_insu_stas"`
  83. PsnType string `json:"psn_type"`
  84. } `json:"insuinfo"`
  85. } `json:"output"`
  86. RefmsgTime string `json:"refmsg_time"`
  87. RespondTime string `json:"respond_time"`
  88. Signtype interface{} `json:"signtype"`
  89. WarnInfo interface{} `json:"warn_info"`
  90. }
  91. type ResultThree struct {
  92. Cainfo interface{} `json:"cainfo"`
  93. ErrMsg string `json:"err_msg"`
  94. InfRefmsgid string `json:"inf_refmsgid"`
  95. Infcode int64 `json:"infcode"`
  96. Output struct {
  97. Result struct {
  98. MdtrtID string `json:"mdtrt_id"`
  99. } `json:"result"`
  100. } `json:"output"`
  101. RefmsgTime string `json:"refmsg_time"`
  102. RespondTime string `json:"respond_time"`
  103. Signtype interface{} `json:"signtype"`
  104. WarnMsg interface{} `json:"warn_msg"`
  105. }
  106. type ResultThree10265 struct {
  107. Cainfo interface{} `json:"cainfo"`
  108. ErrMsg string `json:"err_msg"`
  109. InfRefmsgid string `json:"inf_refmsgid"`
  110. Infcode string `json:"infcode"`
  111. Output struct {
  112. Result struct {
  113. MdtrtID string `json:"mdtrt_id"`
  114. } `json:"result"`
  115. } `json:"output"`
  116. RefmsgTime string `json:"refmsg_time"`
  117. RespondTime string `json:"respond_time"`
  118. Signtype interface{} `json:"signtype"`
  119. WarnMsg interface{} `json:"warn_msg"`
  120. }
  121. type ResultFour struct {
  122. Cainfo string `json:"cainfo"`
  123. ErrMsg string `json:"err_msg"`
  124. InfRefmsgid string `json:"inf_refmsgid"`
  125. Infcode int64 `json:"infcode"`
  126. Output struct {
  127. Result []struct {
  128. BasMednFlag string `json:"bas_medn_flag"`
  129. ChldMedcFlag string `json:"chld_medc_flag"`
  130. ChrgitmLv string `json:"chrgitm_lv"`
  131. Cnt float64 `json:"cnt"`
  132. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  133. DrtReimFlag string `json:"drt_reim_flag"`
  134. FeedetlSn string `json:"feedetl_sn"`
  135. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  136. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  137. InscpScpAmt float64 `json:"inscp_scp_amt"`
  138. ListSpItemFlag string `json:"list_sp_item_flag"`
  139. LmtUsedFlag string `json:"lmt_used_flag"`
  140. MedChrgitmType string `json:"med_chrgitm_type"`
  141. Memo string `json:"memo"`
  142. OverlmtAmt float64 `json:"overlmt_amt"`
  143. PreselfpayAmt float64 `json:"preselfpay_amt"`
  144. Pric float64 `json:"pric"`
  145. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  146. SelfpayProp float64 `json:"selfpay_prop"`
  147. } `json:"result"`
  148. } `json:"output"`
  149. RefmsgTime string `json:"refmsg_time"`
  150. RespondTime string `json:"respond_time"`
  151. Signtype string `json:"signtype"`
  152. WarnMsg string `json:"warn_msg"`
  153. }
  154. type ResultFour10265 struct {
  155. Cainfo string `json:"cainfo"`
  156. ErrMsg string `json:"err_msg"`
  157. InfRefmsgid string `json:"inf_refmsgid"`
  158. Infcode string `json:"infcode"`
  159. Output struct {
  160. Result []struct {
  161. BasMednFlag string `json:"bas_medn_flag"`
  162. ChldMedcFlag string `json:"chld_medc_flag"`
  163. ChrgitmLv string `json:"chrgitm_lv"`
  164. Cnt float64 `json:"cnt"`
  165. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  166. DrtReimFlag string `json:"drt_reim_flag"`
  167. FeedetlSn string `json:"feedetl_sn"`
  168. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  169. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  170. InscpScpAmt float64 `json:"inscp_scp_amt"`
  171. ListSpItemFlag string `json:"list_sp_item_flag"`
  172. LmtUsedFlag string `json:"lmt_used_flag"`
  173. MedChrgitmType string `json:"med_chrgitm_type"`
  174. Memo string `json:"memo"`
  175. OverlmtAmt float64 `json:"overlmt_amt"`
  176. PreselfpayAmt float64 `json:"preselfpay_amt"`
  177. Pric float64 `json:"pric"`
  178. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  179. SelfpayProp float64 `json:"selfpay_prop"`
  180. } `json:"result"`
  181. } `json:"output"`
  182. RefmsgTime string `json:"refmsg_time"`
  183. RespondTime string `json:"respond_time"`
  184. Signtype string `json:"signtype"`
  185. WarnMsg string `json:"warn_msg"`
  186. }
  187. type ResultFive struct {
  188. Balc float64 `json:"balc"`
  189. CvlservFlag string `json:"cvlserv_flag"`
  190. EmpName string `json:"emp_name"`
  191. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  192. Insutype string `json:"insutype"`
  193. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  194. PausInsuDate string `json:"paus_insu_date"`
  195. PsnInsuDate string `json:"psn_insu_date"`
  196. PsnInsuStas string `json:"psn_insu_stas"`
  197. PsnType string `json:"psn_type"`
  198. }
  199. type ResultSeven struct {
  200. Cainfo string `json:"cainfo"`
  201. ErrMsg string `json:"err_msg"`
  202. InfRefmsgid string `json:"inf_refmsgid"`
  203. Infcode int64 `json:"infcode"`
  204. Output struct {
  205. Setldetail []interface{} `json:"setldetail"`
  206. Setlinfo struct {
  207. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  208. AcctPay float64 `json:"acct_pay"`
  209. ActPayDedc float64 `json:"act_pay_dedc"`
  210. Age float64 `json:"age"`
  211. Balc float64 `json:"balc"`
  212. Brdy string `json:"brdy"`
  213. Certno string `json:"certno"`
  214. ClrOptins string `json:"clr_optins"`
  215. ClrType string `json:"clr_type"`
  216. ClrWay string `json:"clr_way"`
  217. CvlservFlag string `json:"cvlserv_flag"`
  218. CvlservPay float64 `json:"cvlserv_pay"`
  219. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  220. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  221. Gend string `json:"gend"`
  222. HifesPay float64 `json:"hifes_pay"`
  223. HifmiPay float64 `json:"hifmi_pay"`
  224. HifpPay float64 `json:"hifp_pay"`
  225. HospPartAmt float64 `json:"hosp_part_amt"`
  226. InscpScpAmt float64 `json:"inscp_scp_amt"`
  227. Insutype string `json:"insutype"`
  228. MafPay float64 `json:"maf_pay"`
  229. MdtrtCertType string `json:"mdtrt_cert_type"`
  230. HifobPay float64 `json:"hifob_pay"`
  231. MdtrtID string `json:"mdtrt_id"`
  232. MedType string `json:"med_type"`
  233. MedfeeSumamt float64 `json:"medfee_sumamt"`
  234. MedinsSetlID string `json:"medins_setl_id"`
  235. Naty string `json:"naty"`
  236. OthPay float64 `json:"oth_pay"`
  237. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  238. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  239. PreselfpayAmt float64 `json:"preselfpay_amt"`
  240. PsnCashPay float64 `json:"psn_cash_pay"`
  241. PsnCertType string `json:"psn_cert_type"`
  242. PsnName string `json:"psn_name"`
  243. PsnNo string `json:"psn_no"`
  244. PsnPartAmt float64 `json:"psn_part_amt"`
  245. PsnType string `json:"psn_type"`
  246. SetlID string `json:"setl_id"`
  247. SetlTime string `json:"setl_time"`
  248. } `json:"setlinfo"`
  249. } `json:"output"`
  250. RefmsgTime string `json:"refmsg_time"`
  251. RespondTime string `json:"respond_time"`
  252. Signtype interface{} `json:"signtype"`
  253. WarnMsg interface{} `json:"warn_msg"`
  254. }
  255. type ResultSeven10265 struct {
  256. Cainfo string `json:"cainfo"`
  257. ErrMsg string `json:"err_msg"`
  258. InfRefmsgid string `json:"inf_refmsgid"`
  259. Infcode string `json:"infcode"`
  260. Output struct {
  261. Setldetail []interface{} `json:"setldetail"`
  262. Setlinfo struct {
  263. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  264. AcctPay float64 `json:"acct_pay"`
  265. ActPayDedc float64 `json:"act_pay_dedc"`
  266. Age float64 `json:"age"`
  267. Balc float64 `json:"balc"`
  268. Brdy string `json:"brdy"`
  269. Certno string `json:"certno"`
  270. ClrOptins string `json:"clr_optins"`
  271. ClrType string `json:"clr_type"`
  272. ClrWay string `json:"clr_way"`
  273. CvlservFlag string `json:"cvlserv_flag"`
  274. CvlservPay float64 `json:"cvlserv_pay"`
  275. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  276. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  277. Gend string `json:"gend"`
  278. HifesPay float64 `json:"hifes_pay"`
  279. HifmiPay float64 `json:"hifmi_pay"`
  280. HifpPay float64 `json:"hifp_pay"`
  281. HospPartAmt float64 `json:"hosp_part_amt"`
  282. InscpScpAmt float64 `json:"inscp_scp_amt"`
  283. Insutype string `json:"insutype"`
  284. MafPay float64 `json:"maf_pay"`
  285. MdtrtCertType string `json:"mdtrt_cert_type"`
  286. HifobPay float64 `json:"hifob_pay"`
  287. MdtrtID string `json:"mdtrt_id"`
  288. MedType string `json:"med_type"`
  289. MedfeeSumamt float64 `json:"medfee_sumamt"`
  290. MedinsSetlID string `json:"medins_setl_id"`
  291. Naty string `json:"naty"`
  292. OthPay float64 `json:"oth_pay"`
  293. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  294. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  295. PreselfpayAmt float64 `json:"preselfpay_amt"`
  296. PsnCashPay float64 `json:"psn_cash_pay"`
  297. PsnCertType string `json:"psn_cert_type"`
  298. PsnName string `json:"psn_name"`
  299. PsnNo string `json:"psn_no"`
  300. PsnPartAmt float64 `json:"psn_part_amt"`
  301. PsnType string `json:"psn_type"`
  302. SetlID string `json:"setl_id"`
  303. SetlTime string `json:"setl_time"`
  304. } `json:"setlinfo"`
  305. } `json:"output"`
  306. RefmsgTime string `json:"refmsg_time"`
  307. RespondTime string `json:"respond_time"`
  308. Signtype interface{} `json:"signtype"`
  309. WarnMsg interface{} `json:"warn_msg"`
  310. }
  311. type ResultSixteen struct {
  312. Cainfo string `json:"cainfo"`
  313. ErrMsg string `json:"err_msg"`
  314. InfRefmsgid string `json:"inf_refmsgid"`
  315. Infcode int64 `json:"infcode"`
  316. Output struct {
  317. Setldetail []interface{} `json:"setldetail"`
  318. Setlinfo struct {
  319. MdtrtID string `json:"mdtrt_id"`
  320. SetlID string `json:"setl_id"`
  321. ClrOptins string `json:"clr_optins"`
  322. SetlTime string `json:"setl_time"`
  323. MedfeeSumamt float64 `json:"medfee_sumamt"`
  324. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  325. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  326. PreselfpayAmt float64 `json:"preselfpay_amt"`
  327. InscpScpAmt float64 `json:"inscp_scp_amt"`
  328. ActPayDedc float64 `json:"act_pay_dedc"`
  329. HifpPay float64 `json:"hifp_pay"`
  330. PoolPropSe float64 `json:"pool_prop_selfpay"`
  331. Lfpay float64 `json:"selfpay"`
  332. CvlservPay float64 `json:"cvlserv_pay"`
  333. HifesPay float64 `json:"hifes_pay"`
  334. HifmiPay float64 `json:"hifmi_pay"`
  335. HifobPay float64 `json:"hifob_pay"`
  336. MafPay float64 `json:"maf_pay"`
  337. OthPay float64 `json:"oth_pay"`
  338. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  339. PsnPartAmt float64 `json:"psn_part_amt"`
  340. AcctPay float64 `json:"acct_pay"`
  341. Balc float64 `json:"balc"`
  342. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  343. HospPartAmt float64 `json:"hosp_part_amt"`
  344. MedinsSetlID string `json:"medins_setl_id"`
  345. PdnCashPay string `json:"pdn_cash_pay"`
  346. } `json:"setlinfo"`
  347. } `json:"output"`
  348. RefmsgTime string `json:"refmsg_time"`
  349. RespondTime string `json:"respond_time"`
  350. Signtype interface{} `json:"signtype"`
  351. WarnMsg interface{} `json:"warn_msg"`
  352. }
  353. type ResultSixteen10265 struct {
  354. Cainfo string `json:"cainfo"`
  355. ErrMsg string `json:"err_msg"`
  356. InfRefmsgid string `json:"inf_refmsgid"`
  357. Infcode string `json:"infcode"`
  358. Output struct {
  359. Setldetail []interface{} `json:"setldetail"`
  360. Setlinfo struct {
  361. MdtrtID string `json:"mdtrt_id"`
  362. SetlID string `json:"setl_id"`
  363. ClrOptins string `json:"clr_optins"`
  364. SetlTime string `json:"setl_time"`
  365. MedfeeSumamt float64 `json:"medfee_sumamt"`
  366. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  367. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  368. PreselfpayAmt float64 `json:"preselfpay_amt"`
  369. InscpScpAmt float64 `json:"inscp_scp_amt"`
  370. ActPayDedc float64 `json:"act_pay_dedc"`
  371. HifpPay float64 `json:"hifp_pay"`
  372. PoolPropSe float64 `json:"pool_prop_selfpay"`
  373. Lfpay float64 `json:"selfpay"`
  374. CvlservPay float64 `json:"cvlserv_pay"`
  375. HifesPay float64 `json:"hifes_pay"`
  376. HifmiPay float64 `json:"hifmi_pay"`
  377. HifobPay float64 `json:"hifob_pay"`
  378. MafPay float64 `json:"maf_pay"`
  379. OthPay float64 `json:"oth_pay"`
  380. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  381. PsnPartAmt float64 `json:"psn_part_amt"`
  382. AcctPay float64 `json:"acct_pay"`
  383. Balc float64 `json:"balc"`
  384. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  385. HospPartAmt float64 `json:"hosp_part_amt"`
  386. MedinsSetlID string `json:"medins_setl_id"`
  387. PdnCashPay string `json:"pdn_cash_pay"`
  388. } `json:"setlinfo"`
  389. } `json:"output"`
  390. RefmsgTime string `json:"refmsg_time"`
  391. RespondTime string `json:"respond_time"`
  392. Signtype interface{} `json:"signtype"`
  393. WarnMsg interface{} `json:"warn_msg"`
  394. }
  395. type Custom struct {
  396. DetItemFeeSumamt string
  397. Cut string
  398. FeedetlSn string
  399. Price string
  400. MedListCodg string
  401. Type int64
  402. AdviceId int64
  403. ProjectId int64
  404. ItemId int64
  405. }
  406. type ResultEmpty struct {
  407. Cainfo interface{} `json:"cainfo"`
  408. ErrMsg string `json:"err_msg"`
  409. InfRefmsgid string `json:"inf_refmsgid"`
  410. Infcode int64 `json:"infcode"`
  411. Output struct {
  412. } `json:"output"`
  413. RefmsgTime string `json:"refmsg_time"`
  414. RespondTime string `json:"respond_time"`
  415. Signtype interface{} `json:"signtype"`
  416. WarnMsg interface{} `json:"warn_msg"`
  417. }
  418. type ResultEmpty10265 struct {
  419. Cainfo interface{} `json:"cainfo"`
  420. ErrMsg string `json:"err_msg"`
  421. InfRefmsgid string `json:"inf_refmsgid"`
  422. Infcode string `json:"infcode"`
  423. Output struct {
  424. } `json:"output"`
  425. RefmsgTime string `json:"refmsg_time"`
  426. RespondTime string `json:"respond_time"`
  427. Signtype interface{} `json:"signtype"`
  428. WarnMsg interface{} `json:"warn_msg"`
  429. }
  430. type CustomResult struct {
  431. BasMednFlag string `json:"bas_medn_flag"`
  432. ChldMedcFlag string `json:"chld_medc_flag"`
  433. ChrgitmLv string `json:"chrgitm_lv"`
  434. Cnt float64 `json:"cnt"`
  435. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  436. DrtReimFlag string `json:"drt_reim_flag"`
  437. FeedetlSn string `json:"feedetl_sn"`
  438. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  439. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  440. InscpScpAmt float64 `json:"inscp_scp_amt"`
  441. ListSpItemFlag string `json:"list_sp_item_flag"`
  442. LmtUsedFlag string `json:"lmt_used_flag"`
  443. MedChrgitmType string `json:"med_chrgitm_type"`
  444. Memo string `json:"memo"`
  445. OverlmtAmt float64 `json:"overlmt_amt"`
  446. PreselfpayAmt float64 `json:"preselfpay_amt"`
  447. Pric float64 `json:"pric"`
  448. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  449. SelfpayProp float64 `json:"selfpay_prop"`
  450. }
  451. func ZHHisManagerApiRegistRouters() {
  452. beego.Router("/zh/api/inhopitalcheck/get", &ZHHisApiController{}, "get:GetZHInHospitalCheck")
  453. beego.Router("/zh/api/outhopitalcheck/get", &ZHHisApiController{}, "get:GetZHOutHospitalCheck")
  454. beego.Router("/zh/api/uploadinfo/get", &ZHHisApiController{}, "get:GetUploadInfo")
  455. beego.Router("/zh/api/settle/get", &ZHHisApiController{}, "get:GetSettleInfo")
  456. beego.Router("/zh/api/inthopitaluncheck/get", &ZHHisApiController{}, "get:GetZHInHospitalUnCheck")
  457. beego.Router("/zh/api/outhopitaluncheck/get", &ZHHisApiController{}, "get:GetZHOutHospitalUnCheck")
  458. beego.Router("/zh/api/refund", &ZHHisApiController{}, "get:ZHRefund")
  459. beego.Router("/zh/api/refunddetail", &ZHHisApiController{}, "get:ZHRefundDetail")
  460. beego.Router("/zh/api/patient/info", &ZHHisApiController{}, "get:GetZHPatientInfo")
  461. }
  462. func (c *ZHHisApiController) GetZHPatientInfo() {
  463. id_card_no := c.GetString("id_card_no")
  464. admin_user_id, _ := c.GetInt64("admin_user_id")
  465. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  466. if patient.ID == 0 {
  467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  468. return
  469. }
  470. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  471. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  472. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  473. if config.IsOpen == 1 {
  474. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  475. var dat map[string]interface{}
  476. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  477. fmt.Println(dat)
  478. } else {
  479. fmt.Println(err)
  480. }
  481. userJSONBytes, _ := json.Marshal(dat)
  482. var res ResultTwo
  483. var resTwo10265 ResultTwo10265
  484. if miConfig.Code == "H15049901371" {
  485. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  486. utils.ErrorLog("解析失败:%v", err)
  487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  488. return
  489. }
  490. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  491. res.Infcode = Infcode
  492. res.ErrMsg = resTwo10265.ErrMsg
  493. res.Output = resTwo10265.Output
  494. res.InfRefmsgid = resTwo10265.InfRefmsgid
  495. res.RespondTime = resTwo10265.RespondTime
  496. res.WarnInfo = resTwo10265.WarnInfo
  497. } else {
  498. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  499. utils.ErrorLog("解析失败:%v", err)
  500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  501. return
  502. }
  503. }
  504. var insutypes []string
  505. var insutype string
  506. var is390 int = 0
  507. var is310 int = 0
  508. for _, item := range res.Output.Iinfo {
  509. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  510. insutypes = append(insutypes, item.Insutype)
  511. }
  512. }
  513. if len(insutypes) == 1 {
  514. insutype = insutypes[0]
  515. } else {
  516. for _, i := range insutypes {
  517. if i == "390" {
  518. is390 = 1
  519. }
  520. if i == "310" {
  521. is310 = 1
  522. }
  523. }
  524. }
  525. if is390 == 1 {
  526. insutype = "390"
  527. }
  528. if is310 == 1 {
  529. insutype = "310"
  530. }
  531. if len(insutypes) == 0 {
  532. insutype = "310"
  533. }
  534. if res.Infcode != 0 {
  535. c.ServeSuccessJSON(map[string]interface{}{
  536. "failed_code": -10,
  537. "msg": res.ErrMsg,
  538. })
  539. } else {
  540. c.ServeSuccessJSON(map[string]interface{}{
  541. "failed_code": 0,
  542. "info": res,
  543. "insutype": insutype,
  544. })
  545. }
  546. }
  547. }
  548. func (c *ZHHisApiController) GetZHInHospitalCheck() {
  549. id, _ := c.GetInt64("id")
  550. record_time := c.GetString("record_time")
  551. name := c.GetString("name")
  552. phone := c.GetString("phone")
  553. id_card_type, _ := c.GetInt64("id_card_type")
  554. certificates, _ := c.GetInt64("certificates")
  555. id_card_no := c.GetString("id_card_no")
  556. doctor, _ := c.GetInt64("doctor")
  557. admin_user_id, _ := c.GetInt64("admin_user_id")
  558. department, _ := c.GetInt64("department")
  559. adm_bed, _ := c.GetInt64("adm_bed")
  560. diagnosis_ids := c.GetString("diagnosis")
  561. sick_type, _ := c.GetInt64("sick_type")
  562. start_time := c.GetString("start_time")
  563. balance_accounts_type, _ := c.GetInt64("balance_accounts_type")
  564. social_type, _ := c.GetInt64("social_type")
  565. psn_type, _ := c.GetInt64("psn_type")
  566. //reg_type, _ := c.GetInt64("p_type")
  567. med_type, _ := c.GetInt64("med_type")
  568. diagnosis_ids_arr := strings.Split(diagnosis_ids, "-")
  569. timeLayout := "2006-01-02"
  570. loc, _ := time.LoadLocation("Local")
  571. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  572. if err != nil {
  573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  574. return
  575. }
  576. recordDateTime := theTime.Unix()
  577. adminInfo := c.GetAdminUserInfo()
  578. record, _ := service.GetLastHospitalRecord(id, adminInfo.CurrentOrgId)
  579. if record.ID != 0 {
  580. if record.InHospitalStatus == 1 && record.OutHospitalStatus != 1 {
  581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalExistDataException)
  582. return
  583. }
  584. }
  585. var patient service.Patients
  586. if id == 0 {
  587. patient, _ = service.GetPatientByIDCard(id_card_no, adminInfo.CurrentOrgId)
  588. } else {
  589. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  590. }
  591. diagnosisConfig, _ := service.FindDiagnoseByIds(diagnosis_ids_arr)
  592. sickConfig, _ := service.FindSickById(sick_type)
  593. departmentInfo, _ := service.GetDepartMentDetail(department)
  594. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  595. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  596. result := service.ZHGdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", certificates, name)
  597. doctorInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  598. deviceNumber, _ := service.GetDeviceNumberByID(adm_bed, adminInfo.CurrentOrgId)
  599. var dat map[string]interface{}
  600. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  601. fmt.Println(dat)
  602. } else {
  603. fmt.Println(err)
  604. }
  605. userJSONBytes, _ := json.Marshal(dat)
  606. //
  607. //var res2 ResultTwo
  608. //if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  609. // utils.ErrorLog("解析失败:%v", err)
  610. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  611. // return
  612. //}
  613. var res2 ResultTwo
  614. var resTwo10265 ResultTwo10265
  615. if miConfig.Code == "H15049901371" {
  616. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  617. utils.ErrorLog("解析失败:%v", err)
  618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  619. return
  620. }
  621. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  622. res2.Infcode = Infcode
  623. res2.ErrMsg = resTwo10265.ErrMsg
  624. res2.Output = resTwo10265.Output
  625. res2.InfRefmsgid = resTwo10265.InfRefmsgid
  626. res2.RespondTime = resTwo10265.RespondTime
  627. res2.WarnInfo = resTwo10265.WarnInfo
  628. } else {
  629. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  630. utils.ErrorLog("解析失败:%v", err)
  631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  632. return
  633. }
  634. }
  635. //InsuplcAdmdvs = res2.Output.
  636. if social_type != 0 {
  637. } else {
  638. }
  639. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  640. infoStr := string(Iinfos)
  641. var rf []*ResultFive
  642. json.Unmarshal([]byte(infoStr), &rf)
  643. var insutypes []*ResultFive
  644. var insutype string
  645. var insuplc_admdvs string
  646. var is390 int = 0
  647. var is310 int = 0
  648. for _, item := range rf {
  649. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  650. insutypes = append(insutypes, item)
  651. }
  652. }
  653. if len(insutypes) == 1 {
  654. insutype = insutypes[0].Insutype
  655. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  656. } else {
  657. for _, i := range insutypes {
  658. if i.Insutype == "390" {
  659. is390 = 1
  660. }
  661. if i.Insutype == "310" {
  662. is310 = 1
  663. }
  664. }
  665. }
  666. if is390 == 1 {
  667. insutype = "390"
  668. }
  669. if is310 == 1 {
  670. insutype = "310"
  671. }
  672. if len(insutypes) == 0 {
  673. insutype = "310"
  674. }
  675. if len(insutypes) == 2 {
  676. insutype = strconv.FormatInt(social_type, 10)
  677. }
  678. for _, item := range rf {
  679. if item.Insutype == insutype {
  680. insuplc_admdvs = item.InsuplcAdmdvs
  681. }
  682. }
  683. if res2.Infcode == 0 {
  684. //var insutypes []string
  685. //
  686. //var insutype string
  687. //var is390 int = 0
  688. //var is310 int = 0
  689. //for _, item := range res2.Output.Iinfo {
  690. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  691. // insutypes = append(insutypes, item.Insutype)
  692. // }
  693. //}
  694. //if len(insutypes) == 1 {
  695. // insutype = insutypes[0]
  696. //} else {
  697. // for _, i := range insutypes {
  698. // if i == "390" {
  699. // is390 = 1
  700. // }
  701. //
  702. // if i == "310" {
  703. // is310 = 1
  704. // }
  705. // }
  706. //}
  707. //if is390 == 1 {
  708. // insutype = "390"
  709. //}
  710. //if is310 == 1 {
  711. // insutype = "310"
  712. //}
  713. //
  714. //if len(insutypes) == 0 {
  715. // insutype = "310"
  716. //}
  717. timestamp := time.Now().Unix()
  718. tempTime := time.Unix(timestamp, 0)
  719. timeFormat := tempTime.Format("20060102150405")
  720. chrgBchno := rand.Intn(100000) + 10000
  721. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(id, 10)
  722. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  723. var struct2401 service.Struct2401
  724. struct2401.PsnNo = res2.Output.Baseinfo.PsnNo
  725. struct2401.Insutype = insutype
  726. struct2401.MdtrtCertType = "02"
  727. struct2401.MdtrtCertNo = res2.Output.Baseinfo.Certno
  728. if miConfig.Code == "H15049901371" {
  729. if med_type == 14 {
  730. struct2401.MedType = "990502"
  731. } else if med_type == 11 {
  732. struct2401.MedType = "11"
  733. }
  734. } else {
  735. struct2401.MedType = strconv.FormatInt(int64(med_type), 10)
  736. }
  737. struct2401.IptNo = ipt_otp_no
  738. struct2401.AtddrNo = strconv.FormatInt(int64(doctorInfo.AdminUserId), 10)
  739. struct2401.ChfpdrName = doctorInfo.UserName
  740. struct2401.AdmDiagDscr = diagnosisConfig[0].ClassName
  741. struct2401.AdmDeptCodg = strconv.FormatInt(int64(departmentInfo.ID), 10)
  742. struct2401.AdmDeptName = departmentInfo.Name
  743. struct2401.AdmBed = deviceNumber.Number
  744. struct2401.AdmBed = "待定"
  745. struct2401.DscgMaindiagName = diagnosisConfig[0].ClassName
  746. struct2401.DscgMaindiagCode = diagnosisConfig[0].CountryCode
  747. struct2401.Begntime = start_time
  748. struct2401.DiseCodg = sickConfig.CountryCode
  749. struct2401.DiseName = sickConfig.ClassName
  750. var dises []service.DiseinfoStruct
  751. for index, item := range diagnosisConfig {
  752. var dise service.DiseinfoStruct
  753. dise.PsnNo = res2.Output.Baseinfo.PsnNo
  754. dise.DiagType = "1"
  755. if index == 0 {
  756. dise.MaindiagFlag = "1"
  757. } else {
  758. dise.MaindiagFlag = "2"
  759. }
  760. dise.DiagSrtNo = strconv.FormatInt(int64(index), 10)
  761. dise.DiseDorName = doctorInfo.UserName
  762. dise.DiagCode = item.CountryCode
  763. dise.DiagName = item.ClassName
  764. dise.DiagDept = departmentInfo.Name
  765. dise.DiseDorNo = strconv.FormatInt(int64(doctorInfo.AdminUserId), 10)
  766. dise.DiagTime = timeFormatOne
  767. dises = append(dises, dise)
  768. }
  769. struct2401.Diseinfo = dises
  770. result := service.ZHGdyb2401(struct2401, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, insuplc_admdvs, miConfig.MdtrtareaAdmvs)
  771. var dat map[string]interface{}
  772. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  773. fmt.Println(dat)
  774. } else {
  775. fmt.Println(err)
  776. }
  777. userJSONBytes, _ := json.Marshal(dat)
  778. var res ResultThree
  779. var resThree10265 ResultThree10265
  780. if miConfig.Code == "H15049901371" {
  781. if err := json.Unmarshal(userJSONBytes, &resThree10265); err != nil {
  782. utils.ErrorLog("解析失败:%v", err)
  783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  784. return
  785. }
  786. Infcode, _ := strconv.ParseInt(resThree10265.Infcode, 10, 64)
  787. res.Infcode = Infcode
  788. res.ErrMsg = resThree10265.ErrMsg
  789. res.Output = resThree10265.Output
  790. res.InfRefmsgid = resThree10265.InfRefmsgid
  791. res.RespondTime = resThree10265.RespondTime
  792. } else {
  793. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  794. utils.ErrorLog("解析失败:%v", err)
  795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  796. return
  797. }
  798. }
  799. if res.Infcode == 0 {
  800. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  801. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  802. infoStr := string(Iinfos)
  803. idetinfoStr := string(Idetinfos)
  804. inHospital := &models.HisHospitalCheckRecord{
  805. PatientId: id,
  806. Name: name,
  807. MedicalTreatmentType: med_type,
  808. RecordDate: recordDateTime,
  809. IdCardNo: id_card_no,
  810. AdminUserId: admin_user_id,
  811. Departments: department,
  812. UserOrgId: adminInfo.CurrentOrgId,
  813. Status: 1,
  814. Ctime: time.Now().Unix(),
  815. Mtime: time.Now().Unix(),
  816. Number: res.Output.Result.MdtrtID,
  817. Doctor: doctor,
  818. PsnNo: res2.Output.Baseinfo.PsnNo,
  819. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  820. Certno: res2.Output.Baseinfo.Certno,
  821. PsnName: res2.Output.Baseinfo.PsnName,
  822. Gend: res2.Output.Baseinfo.Gend,
  823. Naty: res2.Output.Baseinfo.Naty,
  824. MedType: med_type,
  825. InsutypeType: insutype,
  826. Brdy: res2.Output.Baseinfo.Brdy,
  827. Iinfo: infoStr,
  828. Idetinfo: idetinfoStr,
  829. IptOtpNo: ipt_otp_no,
  830. AdmBed: adm_bed,
  831. IdCardType: id_card_type,
  832. Diagnosis: diagnosis_ids,
  833. SickType: sick_type,
  834. MdtrtCertType: "02",
  835. InHosptialTime: start_time,
  836. OutHosptialTime: "",
  837. InHospitalStatus: 1,
  838. Certificates: certificates,
  839. Phone: phone,
  840. BalanceAccountsType: balance_accounts_type,
  841. PsnType: psn_type,
  842. InsuplcAdmdvs: insuplc_admdvs,
  843. }
  844. service.CreateHospitalRecord(inHospital)
  845. c.ServeSuccessJSON(map[string]interface{}{
  846. "msg": "办理入院成功",
  847. "info": inHospital,
  848. })
  849. } else {
  850. c.ServeSuccessJSON(map[string]interface{}{
  851. "failed_code": -10,
  852. "msg": res.ErrMsg,
  853. })
  854. }
  855. } else {
  856. c.ServeSuccessJSON(map[string]interface{}{
  857. "failed_code": -10,
  858. "msg": res2.ErrMsg,
  859. })
  860. return
  861. }
  862. }
  863. func (this *ZHHisApiController) GetZHOutHospitalCheck() {
  864. id, _ := this.GetInt64("id")
  865. patient_id, _ := this.GetInt64("patient_id")
  866. admin_user_id, _ := this.GetInt64("admin_user_id")
  867. record_time := this.GetString("record_time")
  868. adminInfo := this.GetAdminUserInfo()
  869. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  870. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  871. record, _ := service.GetInHospitalRecord(id)
  872. if record.ID == 0 {
  873. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
  874. return
  875. }
  876. timeLayout := "2006-01-02"
  877. loc, _ := time.LoadLocation("Local")
  878. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  879. if err != nil {
  880. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  881. return
  882. }
  883. recordDateTime := theTime.Unix()
  884. var patient service.Patients
  885. if patient_id == 0 {
  886. patient, _ = service.GetPatientByIDCard(record.IdCardNo, adminInfo.CurrentOrgId)
  887. } else {
  888. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  889. }
  890. fmt.Println(patient)
  891. diagnosis_ids_arr := strings.Split(record.Diagnosis, "-")
  892. diagnosisConfig, _ := service.FindDiagnoseByIds(diagnosis_ids_arr)
  893. departmentInfo, _ := service.GetDepartMentDetail(record.Departments)
  894. doctorInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, record.Doctor)
  895. //deviceNumber, _ := service.GetDeviceNumberByID(record.AdmBed, adminInfo.CurrentOrgId)
  896. sickConfig, _ := service.FindSickById(record.SickType)
  897. var struct2402 service.Struct2402
  898. timestamp := time.Now().Unix()
  899. tempTime := time.Unix(timestamp, 0)
  900. //timeFormat := tempTime.Format("20060102150405")
  901. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  902. struct2402.PsnNo = record.PsnNo
  903. struct2402.Insutype = record.InsutypeType
  904. struct2402.DscgWay = "1"
  905. struct2402.Endtime = timeFormatOne
  906. struct2402.DscgDeptName = departmentInfo.Number
  907. struct2402.DscgDeptCodg = strconv.FormatInt(int64(departmentInfo.ID), 10)
  908. struct2402.MdtrtId = record.Number
  909. var dises []service.Diseinfo2402Struct
  910. for index, item := range diagnosisConfig {
  911. var dise service.Diseinfo2402Struct
  912. dise.PsnNo = record.PsnNo
  913. dise.DiagType = "1"
  914. if index == 0 {
  915. dise.MaindiagFlag = "1"
  916. } else {
  917. dise.MaindiagFlag = "2"
  918. }
  919. dise.MdtrtId = record.Number
  920. dise.DiagSrtNo = strconv.FormatInt(int64(item.ID), 10)
  921. dise.DiseDorName = doctorInfo.UserName
  922. dise.DiagCode = item.CountryCode
  923. dise.DiagName = item.ClassName
  924. dise.DiagDept = departmentInfo.Name
  925. dise.DiseDorNo = strconv.FormatInt(int64(doctorInfo.AdminUserId), 10)
  926. dise.DiagTime = timeFormatOne
  927. dises = append(dises, dise)
  928. }
  929. struct2402.Diseinfo = dises
  930. struct2402.DiseName = sickConfig.ClassName
  931. struct2402.DiseCode = sickConfig.CountryCode
  932. result := service.ZHGdyb2402(struct2402, miConfig.OrgName, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  933. var dat map[string]interface{}
  934. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  935. fmt.Println(dat)
  936. } else {
  937. fmt.Println(err)
  938. }
  939. userJSONBytes, _ := json.Marshal(dat)
  940. var res ResultEmpty
  941. var resEmpty10265 ResultEmpty10265
  942. if miConfig.Code == "H15049901371" {
  943. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  944. utils.ErrorLog("解析失败:%v", err)
  945. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  946. return
  947. }
  948. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  949. res.Infcode = Infcode
  950. res.RespondTime = resEmpty10265.RespondTime
  951. res.ErrMsg = resEmpty10265.ErrMsg
  952. res.Output = resEmpty10265.Output
  953. res.WarnMsg = resEmpty10265.WarnMsg
  954. } else {
  955. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  956. utils.ErrorLog("解析失败:%v", err)
  957. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  958. return
  959. }
  960. }
  961. if res.Infcode == 0 {
  962. record.OutHospitalStatus = 1
  963. record.OutHosptialTime = struct2402.Endtime
  964. record.OutWay = 1
  965. service.CreateHospitalRecord(&record)
  966. orders, _ := service.GetHisOrderInfoByNumberFour(record.Number)
  967. var total float64
  968. for _, item := range orders {
  969. total = total + item.DetItemFeeSumamt
  970. }
  971. order := &models.HisOrder{
  972. UserOrgId: adminInfo.CurrentOrgId,
  973. HisPatientId: record.ID,
  974. PatientId: record.PatientId,
  975. SettleAccountsDate: recordDateTime,
  976. Ctime: time.Now().Unix(),
  977. Mtime: time.Now().Unix(),
  978. Status: 1,
  979. Number: record.Number,
  980. Infcode: 0,
  981. WarnMsg: "",
  982. Cainfo: "",
  983. ErrMsg: "",
  984. RespondTime: "",
  985. InfRefmsgid: "",
  986. OrderStatus: 1,
  987. MdtrtId: record.Number,
  988. IsMedicineInsurance: 1,
  989. PType: 1,
  990. MedfeeSumamt: total,
  991. }
  992. err = service.CreateOrder(order)
  993. if err != nil {
  994. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  995. return
  996. }
  997. this.ServeSuccessJSON(map[string]interface{}{
  998. "msg": "出院成功",
  999. })
  1000. } else {
  1001. this.ServeSuccessJSON(map[string]interface{}{
  1002. "failed_code": -10,
  1003. "msg": res.ErrMsg,
  1004. })
  1005. }
  1006. }
  1007. func (c *ZHHisApiController) GetSettleInfo() {
  1008. order_id, _ := c.GetInt64("order_id")
  1009. patient_id, _ := c.GetInt64("patient_id")
  1010. in_hospital_id, _ := c.GetInt64("in_hospital_id")
  1011. admin_user_id, _ := c.GetInt64("admin_user_id")
  1012. pay_way, _ := c.GetInt64("pay_way")
  1013. pay_price, _ := c.GetFloat("pay_price")
  1014. pay_card_no := c.GetString("pay_card_no")
  1015. discount_price, _ := c.GetFloat("discount_price")
  1016. preferential_price, _ := c.GetFloat("preferential_price")
  1017. reality_price, _ := c.GetFloat("reality_price")
  1018. found_price, _ := c.GetFloat("found_price")
  1019. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  1020. private_price, _ := c.GetFloat("private_price")
  1021. fapiao_code := c.GetString("fapiao_code")
  1022. fapiao_number := c.GetString("fapiao_number")
  1023. record, _ := service.GetInHospitalRecord(in_hospital_id)
  1024. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1025. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1026. order, _ := service.GetHisOrderByID(order_id)
  1027. allTotal := fmt.Sprintf("%.4f", order.MedfeeSumamt)
  1028. var rf []*ResultFive
  1029. json.Unmarshal([]byte(record.Iinfo), &rf)
  1030. chrg_bchno := order.Number
  1031. cert_no := record.Certno
  1032. if record.ID == 0 {
  1033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1034. return
  1035. }
  1036. if record.InHospitalStatus == 1 && record.OutHospitalStatus == 0 {
  1037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalNoExistDataException)
  1038. return
  1039. }
  1040. if record.IdCardType == 1 {
  1041. } else {
  1042. cert_no = record.Certno
  1043. }
  1044. var result string
  1045. var src_resquest string
  1046. result, src_resquest = service.ZHGdyb2304(record.PsnNo, record.Number, chrg_bchno, cert_no, record.InsutypeType, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "0", record.IdCardType, 0, 0, 0, 0, record.Certificates)
  1047. var dat map[string]interface{}
  1048. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1049. fmt.Println(dat)
  1050. } else {
  1051. fmt.Println(err)
  1052. }
  1053. userJSONBytes, _ := json.Marshal(dat)
  1054. var res ResultSeven
  1055. var resSeven10265 ResultSeven10265
  1056. if miConfig.Code == "H15049901371" {
  1057. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  1058. utils.ErrorLog("解析失败:%v", err)
  1059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1060. return
  1061. }
  1062. Infcode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  1063. res.Infcode = Infcode
  1064. res.InfRefmsgid = resSeven10265.InfRefmsgid
  1065. res.RespondTime = resSeven10265.RespondTime
  1066. res.ErrMsg = resSeven10265.ErrMsg
  1067. res.Output = resSeven10265.Output
  1068. res.WarnMsg = resSeven10265.WarnMsg
  1069. res.Cainfo = resSeven10265.Cainfo
  1070. } else {
  1071. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1072. utils.ErrorLog("解析失败:%v", err)
  1073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1074. return
  1075. }
  1076. }
  1077. if res.Infcode != 0 {
  1078. errlog := &models.HisOrderError{
  1079. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1080. Ctime: time.Now().Unix(),
  1081. Mtime: time.Now().Unix(),
  1082. Number: chrg_bchno,
  1083. ErrMsg: res.ErrMsg,
  1084. Status: 1,
  1085. PatientId: patient_id,
  1086. RecordTime: time.Now().Unix(),
  1087. Stage: 6,
  1088. }
  1089. service.CreateErrMsgLog(errlog)
  1090. c.ServeSuccessJSON(map[string]interface{}{
  1091. "failed_code": -10,
  1092. "msg": res.ErrMsg,
  1093. })
  1094. return
  1095. } else {
  1096. //order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  1097. order.OrderStatus = 2
  1098. order.DiscountPrice = discount_price
  1099. order.MedicalInsurancePrice = medical_insurance_price
  1100. order.FaPiaoNumber = fapiao_number
  1101. order.FaPiaoCode = fapiao_code
  1102. order.PayWay = pay_way
  1103. order.PayPrice = pay_price
  1104. order.PayCardNo = pay_card_no
  1105. order.PreferentialPrice = preferential_price
  1106. order.RealityPrice = reality_price
  1107. order.FoundPrice = found_price
  1108. order.PrivatePrice = private_price
  1109. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  1110. order.SetlId = res.Output.Setlinfo.SetlID
  1111. order.PsnNo = res.Output.Setlinfo.PsnNo
  1112. order.PsnName = res.Output.Setlinfo.PsnName
  1113. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  1114. order.Certno = res.Output.Setlinfo.Certno
  1115. order.Gend = res.Output.Setlinfo.Gend
  1116. order.Naty = res.Output.Setlinfo.Naty
  1117. order.Age = res.Output.Setlinfo.Age
  1118. order.Insutype = res.Output.Setlinfo.Insutype
  1119. order.PsnType = res.Output.Setlinfo.PsnType
  1120. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  1121. order.SetlTime = res.Output.Setlinfo.SetlTime
  1122. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  1123. order.MedType = res.Output.Setlinfo.MedType
  1124. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  1125. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  1126. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  1127. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  1128. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  1129. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  1130. order.HifpPay = res.Output.Setlinfo.HifpPay
  1131. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  1132. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  1133. order.HifesPay = res.Output.Setlinfo.HifesPay
  1134. order.HifobPay = res.Output.Setlinfo.HifobPay
  1135. order.MafPay = res.Output.Setlinfo.MafPay
  1136. order.OthPay = res.Output.Setlinfo.OthPay
  1137. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  1138. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  1139. order.AcctPay = res.Output.Setlinfo.AcctPay
  1140. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  1141. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  1142. order.Balc = res.Output.Setlinfo.Balc
  1143. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  1144. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  1145. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  1146. order.ClrWay = res.Output.Setlinfo.ClrWay
  1147. order.Creator = order.Creator
  1148. order.Modify = roles.AdminUserId
  1149. order.RequestLog = src_resquest
  1150. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  1151. detailStr := string(setlDetail)
  1152. order.SetlDetail = detailStr
  1153. err := service.UpdataOrderStatusTwo(chrg_bchno, c.GetAdminUserInfo().CurrentOrgId)
  1154. err = service.UpDateOrder(order)
  1155. if err == nil {
  1156. c.ServeSuccessJSON(map[string]interface{}{
  1157. "msg": "结算成功",
  1158. })
  1159. } else {
  1160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  1161. return
  1162. }
  1163. }
  1164. }
  1165. func (c *ZHHisApiController) GetUploadInfo() {
  1166. id, _ := c.GetInt64("id")
  1167. record_time := c.GetString("record_time")
  1168. in_hospital_id, _ := c.GetInt64("in_hospital_id")
  1169. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1170. admin_user_id, _ := c.GetInt64("admin_user_id")
  1171. timeLayout := "2006-01-02"
  1172. loc, _ := time.LoadLocation("Local")
  1173. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1174. if err != nil {
  1175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1176. return
  1177. }
  1178. recordDateTime := theTime.Unix()
  1179. adminUser := c.GetAdminUserInfo()
  1180. var prescriptions []*models.HisPrescription
  1181. data := make(map[string]interface{})
  1182. if settle_accounts_type == 1 { //日结
  1183. prescriptions, _ = service.GetZHHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  1184. } else { //月结
  1185. start_time_str := c.GetString("start_time")
  1186. end_time_str := c.GetString("end_time")
  1187. timeLayout := "2006-01-02"
  1188. loc, _ := time.LoadLocation("Local")
  1189. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  1190. if err != nil {
  1191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1192. return
  1193. }
  1194. recordStartTime := theStartTime.Unix()
  1195. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  1196. if err != nil {
  1197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1198. return
  1199. }
  1200. recordEndTime := theEndTime.Unix()
  1201. prescriptions, _ = service.GetZHMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  1202. }
  1203. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1204. record, _ := service.GetInHospitalRecord(in_hospital_id)
  1205. if record.ID == 0 {
  1206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1207. return
  1208. }
  1209. //if record.InHospitalStatus == 1 && record.OutHospitalStatus == 0 {
  1210. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalNoExistDataException)
  1211. // return
  1212. //}
  1213. timestamp := time.Now().Unix()
  1214. tempTime := time.Unix(timestamp, 0)
  1215. timeFormat := tempTime.Format("20060102150405")
  1216. chrgBchno := rand.Intn(100000) + 10000
  1217. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(record.PatientId, 10)
  1218. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1219. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1220. department, _ := service.GetDepartMentDetail(record.Departments)
  1221. strconv.FormatInt(record.PatientId, 10)
  1222. client := &http.Client{}
  1223. data["psn_no"] = record.PsnNo
  1224. data["mdtrt_id"] = record.Number
  1225. data["chrg_bchno"] = chrg_bchno
  1226. data["org_name"] = miConfig.OrgName
  1227. data["doctor"] = roles.UserName
  1228. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  1229. data["dept"] = strconv.FormatInt(department.ID, 10)
  1230. data["fixmedins_code"] = miConfig.Code
  1231. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  1232. data["dept_code"] = "15"
  1233. } else {
  1234. data["dept_code"] = department.Number
  1235. }
  1236. if miConfig.Code == "H15049901371" {
  1237. if record.MedType == 14 {
  1238. data["med_type"] = "990502"
  1239. } else if record.MedType == 11 {
  1240. data["med_type"] = strconv.FormatInt(record.MedType, 10)
  1241. }
  1242. } else {
  1243. data["med_type"] = strconv.FormatInt(record.MedType, 10)
  1244. }
  1245. data["insuplc_admdvs"] = record.InsuplcAdmdvs
  1246. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1247. data["secret_key"] = miConfig.SecretKey
  1248. var ids []int64
  1249. fmt.Println(data)
  1250. for _, item := range prescriptions {
  1251. ids = append(ids, item.ID)
  1252. }
  1253. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1254. if config.IsOpen == 1 { //对接了医保,走医保流程
  1255. var pagesize int = 100
  1256. var start int = 1
  1257. var stop int
  1258. var pagecount int
  1259. var curpage int
  1260. var isSuccess bool = true
  1261. var customs []*models.NewCustom
  1262. for _, item := range prescriptions {
  1263. if item.Type == 1 { //药品
  1264. for _, subItem := range item.HisDoctorAdviceInfo {
  1265. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  1266. //var randNum int
  1267. //randNum = rand.Intn(10000) + 1000
  1268. cus := &models.NewCustom{
  1269. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  1270. Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  1271. FeedetlSn: subItem.FeedetlSn,
  1272. Price: fmt.Sprintf("%.4f", subItem.Price),
  1273. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  1274. HospApprFlag: subItem.BaseDrugLib.HospApprFlag,
  1275. }
  1276. customs = append(customs, cus)
  1277. }
  1278. }
  1279. }
  1280. if item.Type == 2 { //项目
  1281. for _, subItem := range item.HisPrescriptionProject {
  1282. //var randNum int
  1283. //randNum = rand.Intn(10000) + 1000
  1284. if subItem.Type == 2 {
  1285. if len(subItem.HisProject.MedicalCode) > 0 {
  1286. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1287. cus := &models.NewCustom{
  1288. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1289. Cut: fmt.Sprintf("%.4f", cnt),
  1290. FeedetlSn: subItem.FeedetlSn,
  1291. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1292. MedListCodg: subItem.HisProject.MedicalCode,
  1293. HospApprFlag: -1,
  1294. }
  1295. customs = append(customs, cus)
  1296. }
  1297. } else if subItem.Type == 3 {
  1298. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  1299. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1300. cus := &models.NewCustom{
  1301. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1302. Cut: fmt.Sprintf("%.4f", cnt),
  1303. FeedetlSn: subItem.FeedetlSn,
  1304. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1305. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  1306. HospApprFlag: -1,
  1307. }
  1308. customs = append(customs, cus)
  1309. }
  1310. }
  1311. }
  1312. }
  1313. for _, subItem := range item.HisAdditionalCharge {
  1314. if len(subItem.XtHisAddtionConfig.Code) > 0 {
  1315. cus := &models.NewCustom{
  1316. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)),
  1317. Cut: fmt.Sprintf("%.4f", float64(subItem.Count)),
  1318. FeedetlSn: subItem.FeedetlSn,
  1319. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1320. MedListCodg: subItem.XtHisAddtionConfig.Code,
  1321. HospApprFlag: -1,
  1322. }
  1323. customs = append(customs, cus)
  1324. }
  1325. }
  1326. }
  1327. //总页数,向上取整,注意除之前要先转换类型为float64
  1328. pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  1329. var ress []*ResultFour
  1330. for curpage = 1; curpage <= pagecount; curpage++ {
  1331. if curpage == 1 {
  1332. start = 1
  1333. } else {
  1334. start = (curpage-1)*pagesize + 1
  1335. }
  1336. stop = curpage * pagesize
  1337. if stop > len(customs) {
  1338. stop = len(customs)
  1339. }
  1340. data["pre"] = customs[start-1 : stop]
  1341. bytesData, _ := json.Marshal(data)
  1342. req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/zh/five", bytes.NewReader(bytesData))
  1343. resp, _ := client.Do(req)
  1344. defer resp.Body.Close()
  1345. body, ioErr := ioutil.ReadAll(resp.Body)
  1346. if ioErr != nil {
  1347. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1349. return
  1350. }
  1351. var respJSON map[string]interface{}
  1352. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1353. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1355. return
  1356. }
  1357. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1358. userJSONBytes, _ := json.Marshal(respJSON)
  1359. var res ResultFour
  1360. var resFour10265 ResultFour10265
  1361. if miConfig.Code == "H15049901371" {
  1362. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  1363. utils.ErrorLog("解析失败:%v", err)
  1364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1365. return
  1366. }
  1367. res.WarnMsg = resFour10265.WarnMsg
  1368. res.Output = resFour10265.Output
  1369. res.ErrMsg = resFour10265.ErrMsg
  1370. res.RespondTime = resFour10265.RespondTime
  1371. res.InfRefmsgid = resFour10265.InfRefmsgid
  1372. Infcode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  1373. res.Infcode = Infcode
  1374. } else {
  1375. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1376. utils.ErrorLog("解析失败:%v", err)
  1377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1378. return
  1379. }
  1380. }
  1381. if res.Infcode == 0 {
  1382. ress = append(ress, &res)
  1383. } else {
  1384. isSuccess = false
  1385. errlog := &models.HisOrderError{
  1386. UserOrgId: adminUser.CurrentOrgId,
  1387. Ctime: time.Now().Unix(),
  1388. Mtime: time.Now().Unix(),
  1389. Number: chrg_bchno,
  1390. ErrMsg: "",
  1391. Status: 1,
  1392. PatientId: id,
  1393. RecordTime: recordDateTime,
  1394. Stage: 4,
  1395. }
  1396. service.CreateErrMsgLog(errlog)
  1397. c.ServeSuccessJSON(map[string]interface{}{
  1398. "failed_code": -10,
  1399. "msg": "上传明细错误,请联系his厂商",
  1400. })
  1401. return
  1402. }
  1403. }
  1404. if isSuccess == true {
  1405. if settle_accounts_type == 1 {
  1406. for _, subItem := range ress {
  1407. for _, item := range subItem.Output.Result {
  1408. temp := strings.Split(item.FeedetlSn, "-")
  1409. var advice_id int64 = 0
  1410. var project_id int64 = 0
  1411. var types int64 = 0
  1412. id, _ := strconv.ParseInt(temp[2], 10, 64)
  1413. types, _ = strconv.ParseInt(temp[1], 10, 64)
  1414. if temp[1] == "1" {
  1415. advice_id = id
  1416. project_id = 0
  1417. } else if temp[1] == "2" {
  1418. advice_id = 0
  1419. project_id = id
  1420. }
  1421. info := &models.HisOrderInfo{
  1422. OrderNumber: record.Number,
  1423. FeedetlSn: item.FeedetlSn,
  1424. UploadDate: time.Now().Unix(),
  1425. AdviceId: advice_id,
  1426. DetItemFeeSumamt: item.DetItemFeeSumamt,
  1427. Cnt: item.Cnt,
  1428. Pric: float64(item.Pric),
  1429. PatientId: record.PatientId,
  1430. PricUplmtAmt: item.PricUplmtAmt,
  1431. SelfpayProp: item.SelfpayProp,
  1432. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  1433. OverlmtAmt: item.OverlmtAmt,
  1434. PreselfpayAmt: item.PreselfpayAmt,
  1435. BasMednFlag: item.BasMednFlag,
  1436. MedChrgitmType: item.MedChrgitmType,
  1437. HiNegoDrugFlag: item.HiNegoDrugFlag,
  1438. Status: 1,
  1439. Memo: item.Memo,
  1440. Mtime: time.Now().Unix(),
  1441. InscpScpAmt: item.InscpScpAmt,
  1442. DrtReimFlag: item.DrtReimFlag,
  1443. Ctime: time.Now().Unix(),
  1444. ListSpItemFlag: item.ListSpItemFlag,
  1445. ChldMedcFlag: item.ChldMedcFlag,
  1446. LmtUsedFlag: item.LmtUsedFlag,
  1447. ChrgitmLv: item.ChrgitmLv,
  1448. UserOrgId: adminUser.CurrentOrgId,
  1449. HisPatientId: record.ID,
  1450. OrderId: 0,
  1451. ProjectId: project_id,
  1452. Type: types,
  1453. SettleType: settle_accounts_type,
  1454. }
  1455. service.CreateOrderInfo(info)
  1456. }
  1457. }
  1458. err := service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
  1459. if err == nil {
  1460. c.ServeSuccessJSON(map[string]interface{}{
  1461. "msg": "上传费用明细成功",
  1462. })
  1463. return
  1464. } else {
  1465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1466. return
  1467. }
  1468. } else {
  1469. for _, subItem := range ress {
  1470. for _, item := range subItem.Output.Result {
  1471. temp := strings.Split(item.FeedetlSn, "-")
  1472. var advice_id int64 = 0
  1473. var project_id int64 = 0
  1474. var types int64 = 0
  1475. id, _ := strconv.ParseInt(temp[2], 10, 64)
  1476. types, _ = strconv.ParseInt(temp[1], 10, 64)
  1477. if temp[1] == "1" {
  1478. advice_id = id
  1479. project_id = 0
  1480. } else if temp[1] == "2" {
  1481. advice_id = 0
  1482. project_id = id
  1483. }
  1484. info := &models.HisOrderInfo{
  1485. OrderNumber: record.Number,
  1486. FeedetlSn: item.FeedetlSn,
  1487. UploadDate: time.Now().Unix(),
  1488. AdviceId: advice_id,
  1489. DetItemFeeSumamt: item.DetItemFeeSumamt,
  1490. Cnt: item.Cnt,
  1491. Pric: float64(item.Pric),
  1492. PatientId: record.PatientId,
  1493. PricUplmtAmt: item.PricUplmtAmt,
  1494. SelfpayProp: item.SelfpayProp,
  1495. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  1496. OverlmtAmt: item.OverlmtAmt,
  1497. PreselfpayAmt: item.PreselfpayAmt,
  1498. BasMednFlag: item.BasMednFlag,
  1499. MedChrgitmType: item.MedChrgitmType,
  1500. HiNegoDrugFlag: item.HiNegoDrugFlag,
  1501. Status: 1,
  1502. Memo: item.Memo,
  1503. Mtime: time.Now().Unix(),
  1504. InscpScpAmt: item.InscpScpAmt,
  1505. DrtReimFlag: item.DrtReimFlag,
  1506. Ctime: time.Now().Unix(),
  1507. ListSpItemFlag: item.ListSpItemFlag,
  1508. ChldMedcFlag: item.ChldMedcFlag,
  1509. LmtUsedFlag: item.LmtUsedFlag,
  1510. ChrgitmLv: item.ChrgitmLv,
  1511. UserOrgId: adminUser.CurrentOrgId,
  1512. HisPatientId: record.ID,
  1513. ProjectId: project_id,
  1514. Type: types,
  1515. SettleType: settle_accounts_type,
  1516. }
  1517. service.CreateOrderInfo(info)
  1518. }
  1519. }
  1520. service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
  1521. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
  1522. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, record.Number, recordDateTime)
  1523. c.ServeSuccessJSON(map[string]interface{}{
  1524. "msg": "上传费用明细成功",
  1525. })
  1526. }
  1527. }
  1528. }
  1529. }
  1530. func (c *ZHHisApiController) ZHRefund() {
  1531. order_id, _ := c.GetInt64("order_id")
  1532. admin_user_id, _ := c.GetInt64("admin_user_id")
  1533. adminUser := c.GetAdminUserInfo()
  1534. var order models.HisOrder
  1535. order, _ = service.GetHisOrderByID(order_id)
  1536. record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1537. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1538. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1539. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1540. if config.IsOpen == 1 { //对接了医保,走医保流程
  1541. result, src_resquest := service.Gdyb2305(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  1542. var dat map[string]interface{}
  1543. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1544. fmt.Println(dat)
  1545. } else {
  1546. fmt.Println(err)
  1547. }
  1548. userJSONBytes, _ := json.Marshal(dat)
  1549. var res ResultSixteen
  1550. var resSixteen ResultSixteen10265
  1551. if miConfig.Code == "H15049901371" {
  1552. if err := json.Unmarshal(userJSONBytes, &resSixteen); err != nil {
  1553. utils.ErrorLog("解析失败:%v", err)
  1554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1555. return
  1556. }
  1557. res.Cainfo = resSixteen.Cainfo
  1558. res.WarnMsg = resSixteen.WarnMsg
  1559. res.Output = resSixteen.Output
  1560. res.ErrMsg = resSixteen.ErrMsg
  1561. res.RespondTime = resSixteen.RespondTime
  1562. Infcode, _ := strconv.ParseInt(resSixteen.Infcode, 10, 64)
  1563. res.Infcode = Infcode
  1564. } else {
  1565. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1566. utils.ErrorLog("解析失败:%v", err)
  1567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1568. return
  1569. }
  1570. }
  1571. if res.Infcode == 0 {
  1572. err := service.UpdataOrderStatusThree(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  1573. if err == nil {
  1574. c.ServeSuccessJSON(map[string]interface{}{
  1575. "msg": "退费成功",
  1576. })
  1577. } else {
  1578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1579. return
  1580. }
  1581. } else {
  1582. c.ServeSuccessJSON(map[string]interface{}{
  1583. "code": -10,
  1584. "msg": res.ErrMsg,
  1585. })
  1586. }
  1587. } else {
  1588. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", "")
  1589. if err == nil {
  1590. c.ServeSuccessJSON(map[string]interface{}{
  1591. "msg": "退费成功",
  1592. })
  1593. } else {
  1594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1595. return
  1596. }
  1597. }
  1598. }
  1599. func (c *ZHHisApiController) ZHRefundDetail() {
  1600. patient_id, _ := c.GetInt64("patient_id")
  1601. his_patient_id, _ := c.GetInt64("his_patient_id")
  1602. record_time := c.GetString("record_time")
  1603. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1604. order_id, _ := c.GetInt64("order_id")
  1605. admin_user_id, _ := c.GetInt64("admin_user_id")
  1606. timeLayout := "2006-01-02"
  1607. loc, _ := time.LoadLocation("Local")
  1608. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1609. if err != nil {
  1610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1611. return
  1612. }
  1613. recordDateTime := theTime.Unix()
  1614. adminUser := c.GetAdminUserInfo()
  1615. theTimeTwo, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 23:59:59", loc)
  1616. if err != nil {
  1617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1618. return
  1619. }
  1620. recordDateTimeTwo := theTimeTwo.Unix()
  1621. //var prescriptions []*models.HisPrescription
  1622. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1623. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1624. if settle_accounts_type == 1 { //日结
  1625. infos, _ := service.GetZHHisUploadOrderInfo(adminUser.CurrentOrgId, patient_id, recordDateTime, recordDateTimeTwo)
  1626. record, _ := service.GetInHospitalRecord(his_patient_id)
  1627. var isSuccess bool = true
  1628. for _, item := range infos {
  1629. result := service.Gdyb2302(record.PsnNo, record.Number, miConfig.OrgName, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, item.FeedetlSn, 1)
  1630. var dat map[string]interface{}
  1631. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1632. fmt.Println(dat)
  1633. } else {
  1634. fmt.Println(err)
  1635. }
  1636. userJSONBytes, _ := json.Marshal(dat)
  1637. var res2 ResultEmpty
  1638. var resEmpty10265 ResultEmpty10265
  1639. if miConfig.Code == "H15049901371" {
  1640. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  1641. utils.ErrorLog("解析失败:%v", err)
  1642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1643. return
  1644. }
  1645. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  1646. res2.Infcode = Infcode
  1647. res2.RespondTime = resEmpty10265.RespondTime
  1648. res2.ErrMsg = resEmpty10265.ErrMsg
  1649. res2.Output = resEmpty10265.Output
  1650. res2.WarnMsg = resEmpty10265.WarnMsg
  1651. } else {
  1652. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  1653. utils.ErrorLog("解析失败:%v", err)
  1654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1655. return
  1656. }
  1657. }
  1658. if res2.Infcode == -1 {
  1659. isSuccess = false
  1660. }
  1661. }
  1662. if isSuccess {
  1663. err := service.UpDateOrderInfoStatus(patient_id, recordDateTime, adminUser.CurrentOrgId, recordDateTimeTwo)
  1664. if err != nil {
  1665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1666. return
  1667. }
  1668. err1 := service.UpDatePrescriptionOrderStatusTwo(patient_id, recordDateTime, adminUser.CurrentOrgId)
  1669. if err1 != nil {
  1670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1671. return
  1672. }
  1673. c.ServeSuccessJSON(map[string]interface{}{
  1674. "msg": "撤销明细成功",
  1675. })
  1676. }
  1677. } else {
  1678. //prescriptions, _ = service.GetZHMonthHisUploadPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1679. //var order models.HisOrder
  1680. //order, _ = service.GetHisOrderByID(order_id)
  1681. //record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1682. record, _ := service.GetInHospitalRecord(his_patient_id)
  1683. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1684. if config.IsOpen == 1 { //对接了医保,走医保流程
  1685. result := service.Gdyb2302(record.PsnNo, record.Number, miConfig.OrgName, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, "0000", 0)
  1686. var dat map[string]interface{}
  1687. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1688. fmt.Println(dat)
  1689. } else {
  1690. fmt.Println(err)
  1691. }
  1692. userJSONBytes, _ := json.Marshal(dat)
  1693. var res2 ResultEmpty
  1694. var resEmpty10265 ResultEmpty10265
  1695. if miConfig.Code == "H15049901371" {
  1696. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  1697. utils.ErrorLog("解析失败:%v", err)
  1698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1699. return
  1700. }
  1701. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  1702. res2.Infcode = Infcode
  1703. res2.RespondTime = resEmpty10265.RespondTime
  1704. res2.ErrMsg = resEmpty10265.ErrMsg
  1705. res2.Output = resEmpty10265.Output
  1706. res2.WarnMsg = resEmpty10265.WarnMsg
  1707. } else {
  1708. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  1709. utils.ErrorLog("解析失败:%v", err)
  1710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1711. return
  1712. }
  1713. }
  1714. if res2.Infcode == 0 {
  1715. err := service.UpdataOrderStatus(order_id, record.Number, adminUser.CurrentOrgId, "", result)
  1716. if err == nil {
  1717. c.ServeSuccessJSON(map[string]interface{}{
  1718. "msg": "退费成功",
  1719. })
  1720. } else {
  1721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1722. return
  1723. }
  1724. } else {
  1725. c.ServeSuccessJSON(map[string]interface{}{
  1726. "code": -10,
  1727. "msg": res2.ErrMsg,
  1728. })
  1729. }
  1730. } else {
  1731. err := service.UpdataOrderStatus(order_id, record.Number, adminUser.CurrentOrgId, "", "")
  1732. if err == nil {
  1733. c.ServeSuccessJSON(map[string]interface{}{
  1734. "msg": "退费成功",
  1735. })
  1736. } else {
  1737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1738. return
  1739. }
  1740. }
  1741. }
  1742. }
  1743. func (this *ZHHisApiController) GetZHOutHospitalUnCheck() {
  1744. id, _ := this.GetInt64("id")
  1745. admin_user_id, _ := this.GetInt64("admin_user_id")
  1746. adminInfo := this.GetAdminUserInfo()
  1747. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1748. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  1749. record, _ := service.GetInHospitalRecord(id)
  1750. if record.ID == 0 {
  1751. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
  1752. return
  1753. }
  1754. result := service.ZHGdyb2405(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  1755. var dat map[string]interface{}
  1756. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1757. fmt.Println(dat)
  1758. } else {
  1759. fmt.Println(err)
  1760. }
  1761. userJSONBytes, _ := json.Marshal(dat)
  1762. var res ResultEmpty
  1763. var resEmpty10265 ResultEmpty10265
  1764. if miConfig.Code == "H15049901371" {
  1765. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  1766. utils.ErrorLog("解析失败:%v", err)
  1767. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1768. return
  1769. }
  1770. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  1771. res.Infcode = Infcode
  1772. res.RespondTime = resEmpty10265.RespondTime
  1773. res.ErrMsg = resEmpty10265.ErrMsg
  1774. res.Output = resEmpty10265.Output
  1775. res.WarnMsg = resEmpty10265.WarnMsg
  1776. } else {
  1777. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1778. utils.ErrorLog("解析失败:%v", err)
  1779. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1780. return
  1781. }
  1782. }
  1783. if res.Infcode == 0 {
  1784. record.OutHospitalStatus = 0
  1785. service.CreateHospitalRecord(&record)
  1786. this.ServeSuccessJSON(map[string]interface{}{
  1787. "msg": "撤销出院成功",
  1788. })
  1789. } else {
  1790. this.ServeSuccessJSON(map[string]interface{}{
  1791. "failed_code": -10,
  1792. "msg": res.ErrMsg,
  1793. })
  1794. }
  1795. }
  1796. func (this *ZHHisApiController) GetZHInHospitalUnCheck() {
  1797. id, _ := this.GetInt64("id")
  1798. admin_user_id, _ := this.GetInt64("admin_user_id")
  1799. adminInfo := this.GetAdminUserInfo()
  1800. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1801. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  1802. record, _ := service.GetInHospitalRecord(id)
  1803. if record.ID == 0 {
  1804. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
  1805. return
  1806. }
  1807. result := service.ZHGdyb2404(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  1808. var dat map[string]interface{}
  1809. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1810. fmt.Println(dat)
  1811. } else {
  1812. fmt.Println(err)
  1813. }
  1814. userJSONBytes, _ := json.Marshal(dat)
  1815. var res ResultEmpty
  1816. var resEmpty10265 ResultEmpty10265
  1817. if miConfig.Code == "H15049901371" {
  1818. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  1819. utils.ErrorLog("解析失败:%v", err)
  1820. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1821. return
  1822. }
  1823. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  1824. res.Infcode = Infcode
  1825. res.RespondTime = resEmpty10265.RespondTime
  1826. res.ErrMsg = resEmpty10265.ErrMsg
  1827. res.Output = resEmpty10265.Output
  1828. res.WarnMsg = resEmpty10265.WarnMsg
  1829. } else {
  1830. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1831. utils.ErrorLog("解析失败:%v", err)
  1832. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1833. return
  1834. }
  1835. }
  1836. if res.Infcode == 0 {
  1837. record.Status = 0
  1838. service.CreateHospitalRecord(&record)
  1839. this.ServeSuccessJSON(map[string]interface{}{
  1840. "msg": "撤销入院成功",
  1841. })
  1842. } else {
  1843. this.ServeSuccessJSON(map[string]interface{}{
  1844. "failed_code": -10,
  1845. "msg": res.ErrMsg,
  1846. })
  1847. }
  1848. }