zh_his_api_controller.go 69KB

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