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)
  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)
  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. if res2.Infcode == 0 {
  636. //var insutypes []string
  637. //
  638. //var insutype string
  639. //var is390 int = 0
  640. //var is310 int = 0
  641. //for _, item := range res2.Output.Iinfo {
  642. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  643. // insutypes = append(insutypes, item.Insutype)
  644. // }
  645. //}
  646. //if len(insutypes) == 1 {
  647. // insutype = insutypes[0]
  648. //} else {
  649. // for _, i := range insutypes {
  650. // if i == "390" {
  651. // is390 = 1
  652. // }
  653. //
  654. // if i == "310" {
  655. // is310 = 1
  656. // }
  657. // }
  658. //}
  659. //if is390 == 1 {
  660. // insutype = "390"
  661. //}
  662. //if is310 == 1 {
  663. // insutype = "310"
  664. //}
  665. //
  666. //if len(insutypes) == 0 {
  667. // insutype = "310"
  668. //}
  669. timestamp := time.Now().Unix()
  670. tempTime := time.Unix(timestamp, 0)
  671. timeFormat := tempTime.Format("20060102150405")
  672. chrgBchno := rand.Intn(100000) + 10000
  673. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(id, 10)
  674. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  675. var struct2401 service.Struct2401
  676. struct2401.PsnNo = res2.Output.Baseinfo.PsnNo
  677. struct2401.Insutype = strconv.FormatInt(int64(social_type), 10)
  678. struct2401.MdtrtCertType = "02"
  679. struct2401.MdtrtCertNo = res2.Output.Baseinfo.Certno
  680. if miConfig.Code == "H15049901371" {
  681. if med_type == 14 {
  682. struct2401.MedType = "990502"
  683. } else if med_type == 11 {
  684. struct2401.MedType = "11"
  685. }
  686. } else {
  687. struct2401.MedType = strconv.FormatInt(int64(med_type), 10)
  688. }
  689. struct2401.IptNo = ipt_otp_no
  690. struct2401.AtddrNo = strconv.FormatInt(int64(doctorInfo.AdminUserId), 10)
  691. struct2401.ChfpdrName = doctorInfo.UserName
  692. struct2401.AdmDiagDscr = diagnosisConfig[0].ClassName
  693. struct2401.AdmDeptCodg = strconv.FormatInt(int64(departmentInfo.ID), 10)
  694. struct2401.AdmDeptName = departmentInfo.Name
  695. struct2401.AdmBed = deviceNumber.Number
  696. struct2401.AdmBed = "待定"
  697. struct2401.DscgMaindiagName = diagnosisConfig[0].ClassName
  698. struct2401.DscgMaindiagCode = diagnosisConfig[0].CountryCode
  699. struct2401.Begntime = start_time
  700. struct2401.DiseCodg = sickConfig.CountryCode
  701. struct2401.DiseName = sickConfig.ClassName
  702. var dises []service.DiseinfoStruct
  703. for index, item := range diagnosisConfig {
  704. var dise service.DiseinfoStruct
  705. dise.PsnNo = res2.Output.Baseinfo.PsnNo
  706. dise.DiagType = "1"
  707. if index == 0 {
  708. dise.MaindiagFlag = "1"
  709. } else {
  710. dise.MaindiagFlag = "2"
  711. }
  712. dise.DiagSrtNo = strconv.FormatInt(int64(item.ID), 10)
  713. dise.DiseDorName = doctorInfo.UserName
  714. dise.DiagCode = item.CountryCode
  715. dise.DiagName = item.ClassName
  716. dise.DiagDept = departmentInfo.Name
  717. dise.DiseDorNo = strconv.FormatInt(int64(doctorInfo.AdminUserId), 10)
  718. dise.DiagTime = timeFormatOne
  719. dises = append(dises, dise)
  720. }
  721. struct2401.Diseinfo = dises
  722. result := service.ZHGdyb2401(struct2401, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  723. var dat map[string]interface{}
  724. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  725. fmt.Println(dat)
  726. } else {
  727. fmt.Println(err)
  728. }
  729. userJSONBytes, _ := json.Marshal(dat)
  730. var res ResultThree
  731. var resThree10265 ResultThree10265
  732. if miConfig.Code == "H15049901371" {
  733. if err := json.Unmarshal(userJSONBytes, &resThree10265); err != nil {
  734. utils.ErrorLog("解析失败:%v", err)
  735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  736. return
  737. }
  738. Infcode, _ := strconv.ParseInt(resThree10265.Infcode, 10, 64)
  739. res.Infcode = Infcode
  740. res.ErrMsg = resThree10265.ErrMsg
  741. res.Output = resThree10265.Output
  742. res.InfRefmsgid = resThree10265.InfRefmsgid
  743. res.RespondTime = resThree10265.RespondTime
  744. } else {
  745. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  746. utils.ErrorLog("解析失败:%v", err)
  747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  748. return
  749. }
  750. }
  751. if res.Infcode == 0 {
  752. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  753. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  754. infoStr := string(Iinfos)
  755. idetinfoStr := string(Idetinfos)
  756. inHospital := &models.HisHospitalCheckRecord{
  757. PatientId: id,
  758. Name: name,
  759. MedicalTreatmentType: med_type,
  760. RecordDate: recordDateTime,
  761. IdCardNo: id_card_no,
  762. AdminUserId: admin_user_id,
  763. Departments: department,
  764. UserOrgId: adminInfo.CurrentOrgId,
  765. Status: 1,
  766. Ctime: time.Now().Unix(),
  767. Mtime: time.Now().Unix(),
  768. Number: res.Output.Result.MdtrtID,
  769. Doctor: doctor,
  770. PsnNo: res2.Output.Baseinfo.PsnNo,
  771. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  772. Certno: res2.Output.Baseinfo.Certno,
  773. PsnName: res2.Output.Baseinfo.PsnName,
  774. Gend: res2.Output.Baseinfo.Gend,
  775. Naty: res2.Output.Baseinfo.Naty,
  776. MedType: med_type,
  777. InsutypeType: strconv.FormatInt(int64(social_type), 10),
  778. Brdy: res2.Output.Baseinfo.Brdy,
  779. Iinfo: infoStr,
  780. Idetinfo: idetinfoStr,
  781. IptOtpNo: ipt_otp_no,
  782. AdmBed: adm_bed,
  783. IdCardType: id_card_type,
  784. Diagnosis: diagnosis_ids,
  785. SickType: sick_type,
  786. MdtrtCertType: "02",
  787. InHosptialTime: start_time,
  788. OutHosptialTime: "",
  789. InHospitalStatus: 1,
  790. Certificates: certificates,
  791. Phone: phone,
  792. BalanceAccountsType: balance_accounts_type,
  793. PsnType: psn_type,
  794. }
  795. service.CreateHospitalRecord(inHospital)
  796. c.ServeSuccessJSON(map[string]interface{}{
  797. "msg": "办理入院成功",
  798. "info": inHospital,
  799. })
  800. } else {
  801. c.ServeSuccessJSON(map[string]interface{}{
  802. "failed_code": -10,
  803. "msg": res.ErrMsg,
  804. })
  805. }
  806. } else {
  807. c.ServeSuccessJSON(map[string]interface{}{
  808. "failed_code": -10,
  809. "msg": res2.ErrMsg,
  810. })
  811. return
  812. }
  813. }
  814. func (this *ZHHisApiController) GetZHOutHospitalCheck() {
  815. id, _ := this.GetInt64("id")
  816. patient_id, _ := this.GetInt64("patient_id")
  817. admin_user_id, _ := this.GetInt64("admin_user_id")
  818. //record_time := this.GetString("record_time")
  819. adminInfo := this.GetAdminUserInfo()
  820. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  821. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  822. record, _ := service.GetInHospitalRecord(id)
  823. if record.ID == 0 {
  824. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
  825. return
  826. }
  827. //timeLayout := "2006-01-02"
  828. //loc, _ := time.LoadLocation("Local")
  829. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  830. //if err != nil {
  831. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  832. // return
  833. //}
  834. //recordDateTime := theTime.Unix()
  835. var patient service.Patients
  836. if patient_id == 0 {
  837. patient, _ = service.GetPatientByIDCard(record.IdCardNo, adminInfo.CurrentOrgId)
  838. } else {
  839. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  840. }
  841. fmt.Println(patient)
  842. diagnosis_ids_arr := strings.Split(record.Diagnosis, "-")
  843. diagnosisConfig, _ := service.FindDiagnoseByIds(diagnosis_ids_arr)
  844. departmentInfo, _ := service.GetDepartMentDetail(record.Departments)
  845. doctorInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, record.Doctor)
  846. //deviceNumber, _ := service.GetDeviceNumberByID(record.AdmBed, adminInfo.CurrentOrgId)
  847. sickConfig, _ := service.FindSickById(record.SickType)
  848. var struct2402 service.Struct2402
  849. timestamp := time.Now().Unix()
  850. tempTime := time.Unix(timestamp, 0)
  851. //timeFormat := tempTime.Format("20060102150405")
  852. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  853. struct2402.PsnNo = record.PsnNo
  854. struct2402.Insutype = record.InsutypeType
  855. struct2402.DscgWay = "1"
  856. struct2402.Endtime = timeFormatOne
  857. struct2402.DscgDeptName = departmentInfo.Number
  858. struct2402.DscgDeptCodg = strconv.FormatInt(int64(departmentInfo.ID), 10)
  859. struct2402.MdtrtId = record.Number
  860. var dises []service.Diseinfo2402Struct
  861. for index, item := range diagnosisConfig {
  862. var dise service.Diseinfo2402Struct
  863. dise.PsnNo = record.PsnNo
  864. dise.DiagType = "1"
  865. if index == 0 {
  866. dise.MaindiagFlag = "1"
  867. } else {
  868. dise.MaindiagFlag = "2"
  869. }
  870. dise.MdtrtId = record.Number
  871. dise.DiagSrtNo = strconv.FormatInt(int64(item.ID), 10)
  872. dise.DiseDorName = doctorInfo.UserName
  873. dise.DiagCode = item.CountryCode
  874. dise.DiagName = item.ClassName
  875. dise.DiagDept = departmentInfo.Name
  876. dise.DiseDorNo = strconv.FormatInt(int64(doctorInfo.AdminUserId), 10)
  877. dise.DiagTime = timeFormatOne
  878. dises = append(dises, dise)
  879. }
  880. struct2402.Diseinfo = dises
  881. struct2402.DiseName = sickConfig.ClassName
  882. struct2402.DiseCode = sickConfig.CountryCode
  883. result := service.ZHGdyb2402(struct2402, miConfig.OrgName, role.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  884. var dat map[string]interface{}
  885. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  886. fmt.Println(dat)
  887. } else {
  888. fmt.Println(err)
  889. }
  890. userJSONBytes, _ := json.Marshal(dat)
  891. var res ResultEmpty
  892. var resEmpty10265 ResultEmpty10265
  893. if miConfig.Code == "H15049901371" {
  894. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  895. utils.ErrorLog("解析失败:%v", err)
  896. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  897. return
  898. }
  899. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  900. res.Infcode = Infcode
  901. res.RespondTime = resEmpty10265.RespondTime
  902. res.ErrMsg = resEmpty10265.ErrMsg
  903. res.Output = resEmpty10265.Output
  904. res.WarnMsg = resEmpty10265.WarnMsg
  905. } else {
  906. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  907. utils.ErrorLog("解析失败:%v", err)
  908. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  909. return
  910. }
  911. }
  912. if res.Infcode == 0 {
  913. record.OutHospitalStatus = 1
  914. record.OutHosptialTime = struct2402.Endtime
  915. record.OutWay = 1
  916. service.CreateHospitalRecord(&record)
  917. this.ServeSuccessJSON(map[string]interface{}{
  918. "msg": "出院成功",
  919. })
  920. } else {
  921. this.ServeSuccessJSON(map[string]interface{}{
  922. "failed_code": -10,
  923. "msg": res.ErrMsg,
  924. })
  925. }
  926. }
  927. func (c *ZHHisApiController) GetSettleInfo() {
  928. order_id, _ := c.GetInt64("order_id")
  929. patient_id, _ := c.GetInt64("patient_id")
  930. in_hospital_id, _ := c.GetInt64("in_hospital_id")
  931. admin_user_id, _ := c.GetInt64("admin_user_id")
  932. pay_way, _ := c.GetInt64("pay_way")
  933. pay_price, _ := c.GetFloat("pay_price")
  934. pay_card_no := c.GetString("pay_card_no")
  935. discount_price, _ := c.GetFloat("discount_price")
  936. preferential_price, _ := c.GetFloat("preferential_price")
  937. reality_price, _ := c.GetFloat("reality_price")
  938. found_price, _ := c.GetFloat("found_price")
  939. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  940. private_price, _ := c.GetFloat("private_price")
  941. fapiao_code := c.GetString("fapiao_code")
  942. fapiao_number := c.GetString("fapiao_number")
  943. order, _ := service.GetHisOrderByID(order_id)
  944. record, _ := service.GetInHospitalRecord(in_hospital_id)
  945. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  946. allTotal := fmt.Sprintf("%.2f", order.MedfeeSumamt)
  947. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  948. var rf []*ResultFive
  949. json.Unmarshal([]byte(record.Iinfo), &rf)
  950. chrg_bchno := order.Number
  951. cert_no := record.Certno
  952. var insutypes []string
  953. var insutype string
  954. var is390 int = 0
  955. var is310 int = 0
  956. if record.ID == 0 {
  957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  958. return
  959. }
  960. if record.InHospitalStatus == 1 && record.OutHospitalStatus == 0 {
  961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalNoExistDataException)
  962. return
  963. }
  964. for _, item := range rf {
  965. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  966. insutypes = append(insutypes, item.Insutype)
  967. }
  968. }
  969. if len(insutypes) == 1 {
  970. insutype = insutypes[0]
  971. } else {
  972. for _, i := range insutypes {
  973. if i == "390" {
  974. is390 = 1
  975. }
  976. if i == "310" {
  977. is310 = 1
  978. }
  979. }
  980. }
  981. if is390 == 1 {
  982. insutype = "390"
  983. }
  984. if is310 == 1 {
  985. insutype = "310"
  986. }
  987. if len(insutypes) == 0 {
  988. insutype = "310"
  989. }
  990. if record.IdCardType == 1 {
  991. } else {
  992. cert_no = record.Certno
  993. }
  994. result, src_resquest := service.ZHGdyb2304(record.PsnNo, record.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "0", record.IdCardType, 0, 0, 0, 0, record.Certificates)
  995. var dat map[string]interface{}
  996. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  997. fmt.Println(dat)
  998. } else {
  999. fmt.Println(err)
  1000. }
  1001. userJSONBytes, _ := json.Marshal(dat)
  1002. var res ResultSeven
  1003. var resSeven10265 ResultSeven10265
  1004. if miConfig.Code == "H15049901371" {
  1005. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  1006. utils.ErrorLog("解析失败:%v", err)
  1007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1008. return
  1009. }
  1010. Infcode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  1011. res.Infcode = Infcode
  1012. res.InfRefmsgid = resSeven10265.InfRefmsgid
  1013. res.RespondTime = resSeven10265.RespondTime
  1014. res.ErrMsg = resSeven10265.ErrMsg
  1015. res.Output = resSeven10265.Output
  1016. res.WarnMsg = resSeven10265.WarnMsg
  1017. res.Cainfo = resSeven10265.Cainfo
  1018. } else {
  1019. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1020. utils.ErrorLog("解析失败:%v", err)
  1021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1022. return
  1023. }
  1024. }
  1025. if res.Infcode != 0 {
  1026. errlog := &models.HisOrderError{
  1027. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1028. Ctime: time.Now().Unix(),
  1029. Mtime: time.Now().Unix(),
  1030. Number: chrg_bchno,
  1031. ErrMsg: res.ErrMsg,
  1032. Status: 1,
  1033. PatientId: patient_id,
  1034. RecordTime: time.Now().Unix(),
  1035. Stage: 6,
  1036. }
  1037. service.CreateErrMsgLog(errlog)
  1038. c.ServeSuccessJSON(map[string]interface{}{
  1039. "failed_code": -10,
  1040. "msg": res.ErrMsg,
  1041. })
  1042. return
  1043. } else {
  1044. //order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  1045. order.OrderStatus = 2
  1046. order.DiscountPrice = discount_price
  1047. order.MedicalInsurancePrice = medical_insurance_price
  1048. order.FaPiaoNumber = fapiao_number
  1049. order.FaPiaoCode = fapiao_code
  1050. order.PayWay = pay_way
  1051. order.PayPrice = pay_price
  1052. order.PayCardNo = pay_card_no
  1053. order.PreferentialPrice = preferential_price
  1054. order.RealityPrice = reality_price
  1055. order.FoundPrice = found_price
  1056. order.PrivatePrice = private_price
  1057. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  1058. order.SetlId = res.Output.Setlinfo.SetlID
  1059. order.PsnNo = res.Output.Setlinfo.PsnNo
  1060. order.PsnName = res.Output.Setlinfo.PsnName
  1061. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  1062. order.Certno = res.Output.Setlinfo.Certno
  1063. order.Gend = res.Output.Setlinfo.Gend
  1064. order.Naty = res.Output.Setlinfo.Naty
  1065. order.Age = res.Output.Setlinfo.Age
  1066. order.Insutype = res.Output.Setlinfo.Insutype
  1067. order.PsnType = res.Output.Setlinfo.PsnType
  1068. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  1069. order.SetlTime = res.Output.Setlinfo.SetlTime
  1070. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  1071. order.MedType = res.Output.Setlinfo.MedType
  1072. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  1073. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  1074. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  1075. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  1076. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  1077. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  1078. order.HifpPay = res.Output.Setlinfo.HifpPay
  1079. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  1080. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  1081. order.HifesPay = res.Output.Setlinfo.HifesPay
  1082. order.HifobPay = res.Output.Setlinfo.HifobPay
  1083. order.MafPay = res.Output.Setlinfo.MafPay
  1084. order.OthPay = res.Output.Setlinfo.OthPay
  1085. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  1086. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  1087. order.AcctPay = res.Output.Setlinfo.AcctPay
  1088. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  1089. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  1090. order.Balc = res.Output.Setlinfo.Balc
  1091. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  1092. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  1093. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  1094. order.ClrWay = res.Output.Setlinfo.ClrWay
  1095. order.Creator = order.Creator
  1096. order.Modify = roles.AdminUserId
  1097. order.RequestLog = src_resquest
  1098. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  1099. detailStr := string(setlDetail)
  1100. order.SetlDetail = detailStr
  1101. err := service.UpdataOrderStatusTwo(chrg_bchno, c.GetAdminUserInfo().CurrentOrgId)
  1102. err = service.UpDateOrder(order)
  1103. if err == nil {
  1104. c.ServeSuccessJSON(map[string]interface{}{
  1105. "msg": "结算成功",
  1106. })
  1107. } else {
  1108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  1109. return
  1110. }
  1111. }
  1112. }
  1113. func (c *ZHHisApiController) GetUploadInfo() {
  1114. id, _ := c.GetInt64("id")
  1115. record_time := c.GetString("record_time")
  1116. in_hospital_id, _ := c.GetInt64("in_hospital_id")
  1117. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1118. admin_user_id, _ := c.GetInt64("admin_user_id")
  1119. timeLayout := "2006-01-02"
  1120. loc, _ := time.LoadLocation("Local")
  1121. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1122. if err != nil {
  1123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1124. return
  1125. }
  1126. recordDateTime := theTime.Unix()
  1127. adminUser := c.GetAdminUserInfo()
  1128. var prescriptions []*models.HisPrescription
  1129. var start_time int64
  1130. var end_time int64
  1131. data := make(map[string]interface{})
  1132. if settle_accounts_type == 1 { //日结
  1133. prescriptions, _ = service.GetZHHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  1134. } else { //月结
  1135. start_time_str := c.GetString("start_time")
  1136. end_time_str := c.GetString("end_time")
  1137. timeLayout := "2006-01-02"
  1138. loc, _ := time.LoadLocation("Local")
  1139. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  1140. if err != nil {
  1141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1142. return
  1143. }
  1144. recordStartTime := theStartTime.Unix()
  1145. start_time = recordStartTime
  1146. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  1147. if err != nil {
  1148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1149. return
  1150. }
  1151. recordEndTime := theEndTime.Unix()
  1152. end_time = recordEndTime
  1153. prescriptions, _ = service.GetZHMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  1154. }
  1155. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1156. record, _ := service.GetInHospitalRecord(in_hospital_id)
  1157. if record.ID == 0 {
  1158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1159. return
  1160. }
  1161. //if record.InHospitalStatus == 1 && record.OutHospitalStatus == 0 {
  1162. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalNoExistDataException)
  1163. // return
  1164. //}
  1165. timestamp := time.Now().Unix()
  1166. tempTime := time.Unix(timestamp, 0)
  1167. timeFormat := tempTime.Format("20060102150405")
  1168. chrgBchno := rand.Intn(100000) + 10000
  1169. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(record.PatientId, 10)
  1170. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1171. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1172. department, _ := service.GetDepartMentDetail(record.Departments)
  1173. strconv.FormatInt(record.PatientId, 10)
  1174. client := &http.Client{}
  1175. data["psn_no"] = record.PsnNo
  1176. data["mdtrt_id"] = record.Number
  1177. data["chrg_bchno"] = chrg_bchno
  1178. data["org_name"] = miConfig.OrgName
  1179. data["doctor"] = roles.UserName
  1180. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  1181. data["dept"] = strconv.FormatInt(department.ID, 10)
  1182. data["fixmedins_code"] = miConfig.Code
  1183. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  1184. data["dept_code"] = "15"
  1185. } else {
  1186. data["dept_code"] = department.Number
  1187. }
  1188. if miConfig.Code == "H15049901371" {
  1189. if record.MedType == 14 {
  1190. data["med_type"] = "990502"
  1191. } else if record.MedType == 11 {
  1192. data["med_type"] = strconv.FormatInt(record.MedType, 10)
  1193. }
  1194. } else {
  1195. data["med_type"] = strconv.FormatInt(record.MedType, 10)
  1196. }
  1197. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1198. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1199. data["secret_key"] = miConfig.SecretKey
  1200. var ids []int64
  1201. fmt.Println(data)
  1202. for _, item := range prescriptions {
  1203. ids = append(ids, item.ID)
  1204. }
  1205. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1206. if config.IsOpen == 1 { //对接了医保,走医保流程
  1207. var pagesize int = 100
  1208. var start int = 1
  1209. var stop int
  1210. var pagecount int
  1211. var curpage int
  1212. var isSuccess bool = true
  1213. var customs []*models.NewCustom
  1214. for _, item := range prescriptions {
  1215. if item.Type == 1 { //药品
  1216. for _, subItem := range item.HisDoctorAdviceInfo {
  1217. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  1218. //var randNum int
  1219. //randNum = rand.Intn(10000) + 1000
  1220. cus := &models.NewCustom{
  1221. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  1222. Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  1223. FeedetlSn: subItem.FeedetlSn,
  1224. Price: fmt.Sprintf("%.2f", subItem.Price),
  1225. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  1226. HospApprFlag: subItem.BaseDrugLib.HospApprFlag,
  1227. }
  1228. customs = append(customs, cus)
  1229. }
  1230. }
  1231. }
  1232. if item.Type == 2 { //项目
  1233. for _, subItem := range item.HisPrescriptionProject {
  1234. //var randNum int
  1235. //randNum = rand.Intn(10000) + 1000
  1236. if subItem.Type == 2 {
  1237. if len(subItem.HisProject.MedicalCode) > 0 {
  1238. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1239. cus := &models.NewCustom{
  1240. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*cnt),
  1241. Cut: fmt.Sprintf("%.2f", cnt),
  1242. FeedetlSn: subItem.FeedetlSn,
  1243. Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  1244. MedListCodg: subItem.HisProject.MedicalCode,
  1245. HospApprFlag: -1,
  1246. }
  1247. customs = append(customs, cus)
  1248. }
  1249. } else if subItem.Type == 3 {
  1250. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  1251. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1252. cus := &models.NewCustom{
  1253. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*cnt),
  1254. Cut: fmt.Sprintf("%.2f", cnt),
  1255. FeedetlSn: subItem.FeedetlSn,
  1256. Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  1257. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  1258. HospApprFlag: -1,
  1259. }
  1260. customs = append(customs, cus)
  1261. }
  1262. }
  1263. }
  1264. }
  1265. for _, subItem := range item.HisAdditionalCharge {
  1266. if len(subItem.XtHisAddtionConfig.Code) > 0 {
  1267. cus := &models.NewCustom{
  1268. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  1269. Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  1270. FeedetlSn: subItem.FeedetlSn,
  1271. Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  1272. MedListCodg: subItem.XtHisAddtionConfig.Code,
  1273. HospApprFlag: -1,
  1274. }
  1275. customs = append(customs, cus)
  1276. }
  1277. }
  1278. }
  1279. //总页数,向上取整,注意除之前要先转换类型为float64
  1280. pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  1281. var ress []*ResultFour
  1282. for curpage = 1; curpage <= pagecount; curpage++ {
  1283. if curpage == 1 {
  1284. start = 1
  1285. } else {
  1286. start = (curpage-1)*pagesize + 1
  1287. }
  1288. stop = curpage * pagesize
  1289. if stop > len(customs) {
  1290. stop = len(customs)
  1291. }
  1292. data["pre"] = customs[start-1 : stop]
  1293. bytesData, _ := json.Marshal(data)
  1294. req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/zh/five", bytes.NewReader(bytesData))
  1295. resp, _ := client.Do(req)
  1296. defer resp.Body.Close()
  1297. body, ioErr := ioutil.ReadAll(resp.Body)
  1298. if ioErr != nil {
  1299. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1301. return
  1302. }
  1303. var respJSON map[string]interface{}
  1304. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1307. return
  1308. }
  1309. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1310. userJSONBytes, _ := json.Marshal(respJSON)
  1311. var res ResultFour
  1312. var resFour10265 ResultFour10265
  1313. if miConfig.Code == "H15049901371" {
  1314. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  1315. utils.ErrorLog("解析失败:%v", err)
  1316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1317. return
  1318. }
  1319. res.WarnMsg = resFour10265.WarnMsg
  1320. res.Output = resFour10265.Output
  1321. res.ErrMsg = resFour10265.ErrMsg
  1322. res.RespondTime = resFour10265.RespondTime
  1323. res.InfRefmsgid = resFour10265.InfRefmsgid
  1324. Infcode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  1325. res.Infcode = Infcode
  1326. } else {
  1327. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1328. utils.ErrorLog("解析失败:%v", err)
  1329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1330. return
  1331. }
  1332. }
  1333. if res.Infcode == 0 {
  1334. ress = append(ress, &res)
  1335. } else {
  1336. isSuccess = false
  1337. errlog := &models.HisOrderError{
  1338. UserOrgId: adminUser.CurrentOrgId,
  1339. Ctime: time.Now().Unix(),
  1340. Mtime: time.Now().Unix(),
  1341. Number: chrg_bchno,
  1342. ErrMsg: "",
  1343. Status: 1,
  1344. PatientId: id,
  1345. RecordTime: recordDateTime,
  1346. Stage: 4,
  1347. }
  1348. service.CreateErrMsgLog(errlog)
  1349. c.ServeSuccessJSON(map[string]interface{}{
  1350. "failed_code": -10,
  1351. "msg": "上传明细错误,请联系his厂商",
  1352. })
  1353. return
  1354. }
  1355. }
  1356. if isSuccess == true {
  1357. if settle_accounts_type == 1 {
  1358. for _, subItem := range ress {
  1359. for _, item := range subItem.Output.Result {
  1360. temp := strings.Split(item.FeedetlSn, "-")
  1361. var advice_id int64 = 0
  1362. var project_id int64 = 0
  1363. var types int64 = 0
  1364. id, _ := strconv.ParseInt(temp[2], 10, 64)
  1365. types, _ = strconv.ParseInt(temp[1], 10, 64)
  1366. if temp[1] == "1" {
  1367. advice_id = id
  1368. project_id = 0
  1369. } else if temp[1] == "2" {
  1370. advice_id = 0
  1371. project_id = id
  1372. }
  1373. info := &models.HisOrderInfo{
  1374. OrderNumber: record.Number,
  1375. FeedetlSn: item.FeedetlSn,
  1376. UploadDate: time.Now().Unix(),
  1377. AdviceId: advice_id,
  1378. DetItemFeeSumamt: item.DetItemFeeSumamt,
  1379. Cnt: item.Cnt,
  1380. Pric: float64(item.Pric),
  1381. PatientId: record.PatientId,
  1382. PricUplmtAmt: item.PricUplmtAmt,
  1383. SelfpayProp: item.SelfpayProp,
  1384. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  1385. OverlmtAmt: item.OverlmtAmt,
  1386. PreselfpayAmt: item.PreselfpayAmt,
  1387. BasMednFlag: item.BasMednFlag,
  1388. MedChrgitmType: item.MedChrgitmType,
  1389. HiNegoDrugFlag: item.HiNegoDrugFlag,
  1390. Status: 1,
  1391. Memo: item.Memo,
  1392. Mtime: time.Now().Unix(),
  1393. InscpScpAmt: item.InscpScpAmt,
  1394. DrtReimFlag: item.DrtReimFlag,
  1395. Ctime: time.Now().Unix(),
  1396. ListSpItemFlag: item.ListSpItemFlag,
  1397. ChldMedcFlag: item.ChldMedcFlag,
  1398. LmtUsedFlag: item.LmtUsedFlag,
  1399. ChrgitmLv: item.ChrgitmLv,
  1400. UserOrgId: adminUser.CurrentOrgId,
  1401. HisPatientId: record.ID,
  1402. OrderId: 0,
  1403. ProjectId: project_id,
  1404. Type: types,
  1405. SettleType: settle_accounts_type,
  1406. }
  1407. service.CreateOrderInfo(info)
  1408. }
  1409. }
  1410. err := service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
  1411. if err == nil {
  1412. c.ServeSuccessJSON(map[string]interface{}{
  1413. "msg": "上传费用明细成功",
  1414. })
  1415. return
  1416. } else {
  1417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1418. return
  1419. }
  1420. } else {
  1421. var total float64
  1422. for _, item := range prescriptions {
  1423. if item.Type == 1 { //药品
  1424. for _, subItem := range item.HisDoctorAdviceInfo {
  1425. total = total + (subItem.Price * subItem.PrescribingNumber)
  1426. }
  1427. }
  1428. if item.Type == 2 { //项目
  1429. for _, subItem := range item.HisPrescriptionProject {
  1430. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1431. total = total + (subItem.Price * cnt)
  1432. }
  1433. }
  1434. }
  1435. for _, item := range prescriptions {
  1436. for _, subItem := range item.HisAdditionalCharge {
  1437. total = total + (subItem.Price * float64(subItem.Count))
  1438. }
  1439. }
  1440. allTotal := fmt.Sprintf("%.2f", total)
  1441. totals, _ := strconv.ParseFloat(allTotal, 64)
  1442. order := &models.HisOrder{
  1443. UserOrgId: adminUser.CurrentOrgId,
  1444. HisPatientId: record.ID,
  1445. PatientId: record.PatientId,
  1446. SettleAccountsDate: recordDateTime,
  1447. Ctime: time.Now().Unix(),
  1448. Mtime: time.Now().Unix(),
  1449. Status: 1,
  1450. Number: record.Number,
  1451. Infcode: 0,
  1452. WarnMsg: "",
  1453. Cainfo: "",
  1454. ErrMsg: "",
  1455. RespondTime: "",
  1456. InfRefmsgid: "",
  1457. OrderStatus: 1,
  1458. MdtrtId: record.Number,
  1459. IsMedicineInsurance: 1,
  1460. SettleType: settle_accounts_type,
  1461. SettleStartTime: start_time,
  1462. SettleEndTime: end_time,
  1463. Creator: roles.AdminUserId,
  1464. Modify: roles.AdminUserId,
  1465. PType: 1,
  1466. MedfeeSumamt: totals,
  1467. }
  1468. err = service.CreateOrder(order)
  1469. if err != nil {
  1470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  1471. return
  1472. }
  1473. for _, subItem := range ress {
  1474. for _, item := range subItem.Output.Result {
  1475. temp := strings.Split(item.FeedetlSn, "-")
  1476. var advice_id int64 = 0
  1477. var project_id int64 = 0
  1478. var types int64 = 0
  1479. id, _ := strconv.ParseInt(temp[2], 10, 64)
  1480. types, _ = strconv.ParseInt(temp[1], 10, 64)
  1481. if temp[1] == "1" {
  1482. advice_id = id
  1483. project_id = 0
  1484. } else if temp[1] == "2" {
  1485. advice_id = 0
  1486. project_id = id
  1487. }
  1488. info := &models.HisOrderInfo{
  1489. OrderNumber: order.Number,
  1490. FeedetlSn: item.FeedetlSn,
  1491. UploadDate: time.Now().Unix(),
  1492. AdviceId: advice_id,
  1493. DetItemFeeSumamt: item.DetItemFeeSumamt,
  1494. Cnt: item.Cnt,
  1495. Pric: float64(item.Pric),
  1496. PatientId: record.PatientId,
  1497. PricUplmtAmt: item.PricUplmtAmt,
  1498. SelfpayProp: item.SelfpayProp,
  1499. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  1500. OverlmtAmt: item.OverlmtAmt,
  1501. PreselfpayAmt: item.PreselfpayAmt,
  1502. BasMednFlag: item.BasMednFlag,
  1503. MedChrgitmType: item.MedChrgitmType,
  1504. HiNegoDrugFlag: item.HiNegoDrugFlag,
  1505. Status: 1,
  1506. Memo: item.Memo,
  1507. Mtime: time.Now().Unix(),
  1508. InscpScpAmt: item.InscpScpAmt,
  1509. DrtReimFlag: item.DrtReimFlag,
  1510. Ctime: time.Now().Unix(),
  1511. ListSpItemFlag: item.ListSpItemFlag,
  1512. ChldMedcFlag: item.ChldMedcFlag,
  1513. LmtUsedFlag: item.LmtUsedFlag,
  1514. ChrgitmLv: item.ChrgitmLv,
  1515. UserOrgId: adminUser.CurrentOrgId,
  1516. HisPatientId: record.ID,
  1517. OrderId: order.ID,
  1518. ProjectId: project_id,
  1519. Type: types,
  1520. SettleType: settle_accounts_type,
  1521. }
  1522. service.CreateOrderInfo(info)
  1523. }
  1524. }
  1525. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
  1526. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, record.Number, recordDateTime)
  1527. c.ServeSuccessJSON(map[string]interface{}{
  1528. "msg": "上传费用明细成功",
  1529. })
  1530. }
  1531. }
  1532. }
  1533. }
  1534. func (c *ZHHisApiController) ZHRefund() {
  1535. order_id, _ := c.GetInt64("order_id")
  1536. admin_user_id, _ := c.GetInt64("admin_user_id")
  1537. adminUser := c.GetAdminUserInfo()
  1538. var order models.HisOrder
  1539. order, _ = service.GetHisOrderByID(order_id)
  1540. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1541. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1542. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1543. if config.IsOpen == 1 { //对接了医保,走医保流程
  1544. result, src_resquest := service.Gdyb2305(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  1545. var dat map[string]interface{}
  1546. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1547. fmt.Println(dat)
  1548. } else {
  1549. fmt.Println(err)
  1550. }
  1551. userJSONBytes, _ := json.Marshal(dat)
  1552. var res ResultSixteen
  1553. var resSixteen ResultSixteen10265
  1554. if miConfig.Code == "H15049901371" {
  1555. if err := json.Unmarshal(userJSONBytes, &resSixteen); err != nil {
  1556. utils.ErrorLog("解析失败:%v", err)
  1557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1558. return
  1559. }
  1560. res.Cainfo = resSixteen.Cainfo
  1561. res.WarnMsg = resSixteen.WarnMsg
  1562. res.Output = resSixteen.Output
  1563. res.ErrMsg = resSixteen.ErrMsg
  1564. res.RespondTime = resSixteen.RespondTime
  1565. Infcode, _ := strconv.ParseInt(resSixteen.Infcode, 10, 64)
  1566. res.Infcode = Infcode
  1567. } else {
  1568. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1569. utils.ErrorLog("解析失败:%v", err)
  1570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1571. return
  1572. }
  1573. }
  1574. if res.Infcode == 0 {
  1575. err := service.UpdataOrderStatusThree(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  1576. if err == nil {
  1577. c.ServeSuccessJSON(map[string]interface{}{
  1578. "msg": "退费成功",
  1579. })
  1580. } else {
  1581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1582. return
  1583. }
  1584. } else {
  1585. c.ServeSuccessJSON(map[string]interface{}{
  1586. "code": -10,
  1587. "msg": res.ErrMsg,
  1588. })
  1589. }
  1590. } else {
  1591. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", "")
  1592. if err == nil {
  1593. c.ServeSuccessJSON(map[string]interface{}{
  1594. "msg": "退费成功",
  1595. })
  1596. } else {
  1597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1598. return
  1599. }
  1600. }
  1601. }
  1602. func (c *ZHHisApiController) ZHRefundDetail() {
  1603. patient_id, _ := c.GetInt64("patient_id")
  1604. his_patient_id, _ := c.GetInt64("his_patient_id")
  1605. record_time := c.GetString("record_time")
  1606. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1607. order_id, _ := c.GetInt64("order_id")
  1608. admin_user_id, _ := c.GetInt64("admin_user_id")
  1609. timeLayout := "2006-01-02"
  1610. loc, _ := time.LoadLocation("Local")
  1611. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1612. if err != nil {
  1613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1614. return
  1615. }
  1616. recordDateTime := theTime.Unix()
  1617. adminUser := c.GetAdminUserInfo()
  1618. //var prescriptions []*models.HisPrescription
  1619. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1620. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1621. if settle_accounts_type == 1 { //日结
  1622. infos, _ := service.GetZHHisUploadOrderInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1623. record, _ := service.GetInHospitalRecord(his_patient_id)
  1624. var isSuccess bool = true
  1625. for _, item := range infos {
  1626. result := service.Gdyb2302(record.PsnNo, record.Number, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, item.FeedetlSn, 1)
  1627. var dat map[string]interface{}
  1628. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1629. fmt.Println(dat)
  1630. } else {
  1631. fmt.Println(err)
  1632. }
  1633. userJSONBytes, _ := json.Marshal(dat)
  1634. var res2 ResultEmpty
  1635. var resEmpty10265 ResultEmpty10265
  1636. if miConfig.Code == "H15049901371" {
  1637. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  1638. utils.ErrorLog("解析失败:%v", err)
  1639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1640. return
  1641. }
  1642. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  1643. res2.Infcode = Infcode
  1644. res2.RespondTime = resEmpty10265.RespondTime
  1645. res2.ErrMsg = resEmpty10265.ErrMsg
  1646. res2.Output = resEmpty10265.Output
  1647. res2.WarnMsg = resEmpty10265.WarnMsg
  1648. } else {
  1649. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  1650. utils.ErrorLog("解析失败:%v", err)
  1651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1652. return
  1653. }
  1654. }
  1655. if res2.Infcode == -1 {
  1656. isSuccess = false
  1657. }
  1658. }
  1659. if isSuccess {
  1660. err := service.UpDateOrderInfoStatus(patient_id, recordDateTime, adminUser.CurrentOrgId)
  1661. if err != nil {
  1662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1663. return
  1664. }
  1665. err1 := service.UpDatePrescriptionOrderStatusTwo(patient_id, recordDateTime, adminUser.CurrentOrgId)
  1666. if err1 != nil {
  1667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1668. return
  1669. }
  1670. c.ServeSuccessJSON(map[string]interface{}{
  1671. "msg": "撤销明细成功",
  1672. })
  1673. }
  1674. } else {
  1675. //prescriptions, _ = service.GetZHMonthHisUploadPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1676. var order models.HisOrder
  1677. order, _ = service.GetHisOrderByID(order_id)
  1678. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1679. if config.IsOpen == 1 { //对接了医保,走医保流程
  1680. result := service.Gdyb2302(order.PsnNo, order.MdtrtId, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, "0000", 0)
  1681. var dat map[string]interface{}
  1682. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1683. fmt.Println(dat)
  1684. } else {
  1685. fmt.Println(err)
  1686. }
  1687. userJSONBytes, _ := json.Marshal(dat)
  1688. var res2 ResultEmpty
  1689. var resEmpty10265 ResultEmpty10265
  1690. if miConfig.Code == "H15049901371" {
  1691. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  1692. utils.ErrorLog("解析失败:%v", err)
  1693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1694. return
  1695. }
  1696. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  1697. res2.Infcode = Infcode
  1698. res2.RespondTime = resEmpty10265.RespondTime
  1699. res2.ErrMsg = resEmpty10265.ErrMsg
  1700. res2.Output = resEmpty10265.Output
  1701. res2.WarnMsg = resEmpty10265.WarnMsg
  1702. } else {
  1703. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  1704. utils.ErrorLog("解析失败:%v", err)
  1705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1706. return
  1707. }
  1708. }
  1709. if res2.Infcode == 0 {
  1710. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", result)
  1711. if err == nil {
  1712. c.ServeSuccessJSON(map[string]interface{}{
  1713. "msg": "退费成功",
  1714. })
  1715. } else {
  1716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1717. return
  1718. }
  1719. } else {
  1720. c.ServeSuccessJSON(map[string]interface{}{
  1721. "code": -10,
  1722. "msg": res2.ErrMsg,
  1723. })
  1724. }
  1725. } else {
  1726. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", "")
  1727. if err == nil {
  1728. c.ServeSuccessJSON(map[string]interface{}{
  1729. "msg": "退费成功",
  1730. })
  1731. } else {
  1732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1733. return
  1734. }
  1735. }
  1736. }
  1737. }
  1738. func (this *ZHHisApiController) GetZHOutHospitalUnCheck() {
  1739. id, _ := this.GetInt64("id")
  1740. admin_user_id, _ := this.GetInt64("admin_user_id")
  1741. adminInfo := this.GetAdminUserInfo()
  1742. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1743. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  1744. record, _ := service.GetInHospitalRecord(id)
  1745. if record.ID == 0 {
  1746. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
  1747. return
  1748. }
  1749. result := service.ZHGdyb2405(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  1750. var dat map[string]interface{}
  1751. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1752. fmt.Println(dat)
  1753. } else {
  1754. fmt.Println(err)
  1755. }
  1756. userJSONBytes, _ := json.Marshal(dat)
  1757. var res ResultEmpty
  1758. var resEmpty10265 ResultEmpty10265
  1759. if miConfig.Code == "H15049901371" {
  1760. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  1761. utils.ErrorLog("解析失败:%v", err)
  1762. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1763. return
  1764. }
  1765. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  1766. res.Infcode = Infcode
  1767. res.RespondTime = resEmpty10265.RespondTime
  1768. res.ErrMsg = resEmpty10265.ErrMsg
  1769. res.Output = resEmpty10265.Output
  1770. res.WarnMsg = resEmpty10265.WarnMsg
  1771. } else {
  1772. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1773. utils.ErrorLog("解析失败:%v", err)
  1774. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1775. return
  1776. }
  1777. }
  1778. if res.Infcode == 0 {
  1779. record.OutHospitalStatus = 0
  1780. service.CreateHospitalRecord(&record)
  1781. this.ServeSuccessJSON(map[string]interface{}{
  1782. "msg": "撤销出院成功",
  1783. })
  1784. } else {
  1785. this.ServeSuccessJSON(map[string]interface{}{
  1786. "failed_code": -10,
  1787. "msg": res.ErrMsg,
  1788. })
  1789. }
  1790. }
  1791. func (this *ZHHisApiController) GetZHInHospitalUnCheck() {
  1792. id, _ := this.GetInt64("id")
  1793. admin_user_id, _ := this.GetInt64("admin_user_id")
  1794. adminInfo := this.GetAdminUserInfo()
  1795. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1796. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  1797. record, _ := service.GetInHospitalRecord(id)
  1798. if record.ID == 0 {
  1799. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
  1800. return
  1801. }
  1802. result := service.ZHGdyb2404(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  1803. var dat map[string]interface{}
  1804. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1805. fmt.Println(dat)
  1806. } else {
  1807. fmt.Println(err)
  1808. }
  1809. userJSONBytes, _ := json.Marshal(dat)
  1810. var res ResultEmpty
  1811. var resEmpty10265 ResultEmpty10265
  1812. if miConfig.Code == "H15049901371" {
  1813. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  1814. utils.ErrorLog("解析失败:%v", err)
  1815. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1816. return
  1817. }
  1818. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  1819. res.Infcode = Infcode
  1820. res.RespondTime = resEmpty10265.RespondTime
  1821. res.ErrMsg = resEmpty10265.ErrMsg
  1822. res.Output = resEmpty10265.Output
  1823. res.WarnMsg = resEmpty10265.WarnMsg
  1824. } else {
  1825. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1826. utils.ErrorLog("解析失败:%v", err)
  1827. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1828. return
  1829. }
  1830. }
  1831. if res.Infcode == 0 {
  1832. record.Status = 0
  1833. service.CreateHospitalRecord(&record)
  1834. this.ServeSuccessJSON(map[string]interface{}{
  1835. "msg": "撤销入院成功",
  1836. })
  1837. } else {
  1838. this.ServeSuccessJSON(map[string]interface{}{
  1839. "failed_code": -10,
  1840. "msg": res.ErrMsg,
  1841. })
  1842. }
  1843. }