zh_his_api_controller.go 69KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087
  1. package zh
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "gdyb/controllers"
  6. "gdyb/enums"
  7. "gdyb/models"
  8. "gdyb/service"
  9. "gdyb/utils"
  10. "github.com/astaxie/beego"
  11. "math/rand"
  12. "net/http"
  13. "strconv"
  14. "strings"
  15. "time"
  16. )
  17. type ZHHisApiController struct {
  18. controllers.BaseAuthAPIController
  19. }
  20. type ResultTwo struct {
  21. ErrMsg string `json:"err_msg"`
  22. InfRefmsgid string `json:"inf_refmsgid"`
  23. Infcode int64 `json:"infcode"`
  24. Output struct {
  25. Baseinfo struct {
  26. Age float64 `json:"age"`
  27. Brdy string `json:"brdy"`
  28. Certno string `json:"certno"`
  29. Gend string `json:"gend"`
  30. Naty string `json:"naty"`
  31. PsnCertType string `json:"psn_cert_type"`
  32. PsnName string `json:"psn_name"`
  33. PsnNo string `json:"psn_no"`
  34. } `json:"baseinfo"`
  35. Idetinfo []interface{} `json:"idetinfo"`
  36. Iinfo []struct {
  37. Balc float64 `json:"balc"`
  38. CvlservFlag string `json:"cvlserv_flag"`
  39. EmpName string `json:"emp_name"`
  40. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  41. Insutype string `json:"insutype"`
  42. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  43. PausInsuDate string `json:"paus_insu_date"`
  44. PsnInsuDate string `json:"psn_insu_date"`
  45. PsnInsuStas string `json:"psn_insu_stas"`
  46. PsnType string `json:"psn_type"`
  47. } `json:"insuinfo"`
  48. } `json:"output"`
  49. RefmsgTime string `json:"refmsg_time"`
  50. RespondTime string `json:"respond_time"`
  51. Signtype interface{} `json:"signtype"`
  52. WarnInfo interface{} `json:"warn_info"`
  53. }
  54. type ResultTwo10265 struct {
  55. ErrMsg string `json:"err_msg"`
  56. InfRefmsgid string `json:"inf_refmsgid"`
  57. Infcode string `json:"infcode"`
  58. Output struct {
  59. Baseinfo struct {
  60. Age float64 `json:"age"`
  61. Brdy string `json:"brdy"`
  62. Certno string `json:"certno"`
  63. Gend string `json:"gend"`
  64. Naty string `json:"naty"`
  65. PsnCertType string `json:"psn_cert_type"`
  66. PsnName string `json:"psn_name"`
  67. PsnNo string `json:"psn_no"`
  68. } `json:"baseinfo"`
  69. Idetinfo []interface{} `json:"idetinfo"`
  70. Iinfo []struct {
  71. Balc float64 `json:"balc"`
  72. CvlservFlag string `json:"cvlserv_flag"`
  73. EmpName string `json:"emp_name"`
  74. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  75. Insutype string `json:"insutype"`
  76. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  77. PausInsuDate string `json:"paus_insu_date"`
  78. PsnInsuDate string `json:"psn_insu_date"`
  79. PsnInsuStas string `json:"psn_insu_stas"`
  80. PsnType string `json:"psn_type"`
  81. } `json:"insuinfo"`
  82. } `json:"output"`
  83. RefmsgTime string `json:"refmsg_time"`
  84. RespondTime string `json:"respond_time"`
  85. Signtype interface{} `json:"signtype"`
  86. WarnInfo interface{} `json:"warn_info"`
  87. }
  88. type ResultThree struct {
  89. Cainfo interface{} `json:"cainfo"`
  90. ErrMsg string `json:"err_msg"`
  91. InfRefmsgid string `json:"inf_refmsgid"`
  92. Infcode int64 `json:"infcode"`
  93. Output struct {
  94. Result struct {
  95. MdtrtID string `json:"mdtrt_id"`
  96. } `json:"result"`
  97. } `json:"output"`
  98. RefmsgTime string `json:"refmsg_time"`
  99. RespondTime string `json:"respond_time"`
  100. Signtype interface{} `json:"signtype"`
  101. WarnMsg interface{} `json:"warn_msg"`
  102. }
  103. type ResultThree10265 struct {
  104. Cainfo interface{} `json:"cainfo"`
  105. ErrMsg string `json:"err_msg"`
  106. InfRefmsgid string `json:"inf_refmsgid"`
  107. Infcode string `json:"infcode"`
  108. Output struct {
  109. Result struct {
  110. MdtrtID string `json:"mdtrt_id"`
  111. } `json:"result"`
  112. } `json:"output"`
  113. RefmsgTime string `json:"refmsg_time"`
  114. RespondTime string `json:"respond_time"`
  115. Signtype interface{} `json:"signtype"`
  116. WarnMsg interface{} `json:"warn_msg"`
  117. }
  118. type ResultFour struct {
  119. Cainfo string `json:"cainfo"`
  120. ErrMsg string `json:"err_msg"`
  121. InfRefmsgid string `json:"inf_refmsgid"`
  122. Infcode int64 `json:"infcode"`
  123. Output struct {
  124. Result []struct {
  125. BasMednFlag string `json:"bas_medn_flag"`
  126. ChldMedcFlag string `json:"chld_medc_flag"`
  127. ChrgitmLv string `json:"chrgitm_lv"`
  128. Cnt float64 `json:"cnt"`
  129. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  130. DrtReimFlag string `json:"drt_reim_flag"`
  131. FeedetlSn string `json:"feedetl_sn"`
  132. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  133. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  134. InscpScpAmt float64 `json:"inscp_scp_amt"`
  135. ListSpItemFlag string `json:"list_sp_item_flag"`
  136. LmtUsedFlag string `json:"lmt_used_flag"`
  137. MedChrgitmType string `json:"med_chrgitm_type"`
  138. Memo string `json:"memo"`
  139. OverlmtAmt float64 `json:"overlmt_amt"`
  140. PreselfpayAmt float64 `json:"preselfpay_amt"`
  141. Pric float64 `json:"pric"`
  142. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  143. SelfpayProp float64 `json:"selfpay_prop"`
  144. } `json:"result"`
  145. } `json:"output"`
  146. RefmsgTime string `json:"refmsg_time"`
  147. RespondTime string `json:"respond_time"`
  148. Signtype string `json:"signtype"`
  149. WarnMsg string `json:"warn_msg"`
  150. }
  151. type ResultFour10265 struct {
  152. Cainfo string `json:"cainfo"`
  153. ErrMsg string `json:"err_msg"`
  154. InfRefmsgid string `json:"inf_refmsgid"`
  155. Infcode string `json:"infcode"`
  156. Output struct {
  157. Result []struct {
  158. BasMednFlag string `json:"bas_medn_flag"`
  159. ChldMedcFlag string `json:"chld_medc_flag"`
  160. ChrgitmLv string `json:"chrgitm_lv"`
  161. Cnt float64 `json:"cnt"`
  162. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  163. DrtReimFlag string `json:"drt_reim_flag"`
  164. FeedetlSn string `json:"feedetl_sn"`
  165. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  166. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  167. InscpScpAmt float64 `json:"inscp_scp_amt"`
  168. ListSpItemFlag string `json:"list_sp_item_flag"`
  169. LmtUsedFlag string `json:"lmt_used_flag"`
  170. MedChrgitmType string `json:"med_chrgitm_type"`
  171. Memo string `json:"memo"`
  172. OverlmtAmt float64 `json:"overlmt_amt"`
  173. PreselfpayAmt float64 `json:"preselfpay_amt"`
  174. Pric float64 `json:"pric"`
  175. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  176. SelfpayProp float64 `json:"selfpay_prop"`
  177. } `json:"result"`
  178. } `json:"output"`
  179. RefmsgTime string `json:"refmsg_time"`
  180. RespondTime string `json:"respond_time"`
  181. Signtype string `json:"signtype"`
  182. WarnMsg string `json:"warn_msg"`
  183. }
  184. type ResultFive struct {
  185. Balc float64 `json:"balc"`
  186. CvlservFlag string `json:"cvlserv_flag"`
  187. EmpName string `json:"emp_name"`
  188. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  189. Insutype string `json:"insutype"`
  190. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  191. PausInsuDate string `json:"paus_insu_date"`
  192. PsnInsuDate string `json:"psn_insu_date"`
  193. PsnInsuStas string `json:"psn_insu_stas"`
  194. PsnType string `json:"psn_type"`
  195. }
  196. type ResultSeven struct {
  197. Cainfo string `json:"cainfo"`
  198. ErrMsg string `json:"err_msg"`
  199. InfRefmsgid string `json:"inf_refmsgid"`
  200. Infcode int64 `json:"infcode"`
  201. Output struct {
  202. Setldetail []interface{} `json:"setldetail"`
  203. Setlinfo struct {
  204. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  205. AcctPay float64 `json:"acct_pay"`
  206. ActPayDedc float64 `json:"act_pay_dedc"`
  207. Age float64 `json:"age"`
  208. Balc float64 `json:"balc"`
  209. Brdy string `json:"brdy"`
  210. Certno string `json:"certno"`
  211. ClrOptins string `json:"clr_optins"`
  212. ClrType string `json:"clr_type"`
  213. ClrWay string `json:"clr_way"`
  214. CvlservFlag string `json:"cvlserv_flag"`
  215. CvlservPay float64 `json:"cvlserv_pay"`
  216. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  217. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  218. Gend string `json:"gend"`
  219. HifesPay float64 `json:"hifes_pay"`
  220. HifmiPay float64 `json:"hifmi_pay"`
  221. HifpPay float64 `json:"hifp_pay"`
  222. HospPartAmt float64 `json:"hosp_part_amt"`
  223. InscpScpAmt float64 `json:"inscp_scp_amt"`
  224. Insutype string `json:"insutype"`
  225. MafPay float64 `json:"maf_pay"`
  226. MdtrtCertType string `json:"mdtrt_cert_type"`
  227. HifobPay float64 `json:"hifob_pay"`
  228. MdtrtID string `json:"mdtrt_id"`
  229. MedType string `json:"med_type"`
  230. MedfeeSumamt float64 `json:"medfee_sumamt"`
  231. MedinsSetlID string `json:"medins_setl_id"`
  232. Naty string `json:"naty"`
  233. OthPay float64 `json:"oth_pay"`
  234. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  235. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  236. PreselfpayAmt float64 `json:"preselfpay_amt"`
  237. PsnCashPay float64 `json:"psn_cash_pay"`
  238. PsnCertType string `json:"psn_cert_type"`
  239. PsnName string `json:"psn_name"`
  240. PsnNo string `json:"psn_no"`
  241. PsnPartAmt float64 `json:"psn_part_amt"`
  242. PsnType string `json:"psn_type"`
  243. SetlID string `json:"setl_id"`
  244. SetlTime string `json:"setl_time"`
  245. } `json:"setlinfo"`
  246. } `json:"output"`
  247. RefmsgTime string `json:"refmsg_time"`
  248. RespondTime string `json:"respond_time"`
  249. Signtype interface{} `json:"signtype"`
  250. WarnMsg interface{} `json:"warn_msg"`
  251. }
  252. type ResultSeven10265 struct {
  253. Cainfo string `json:"cainfo"`
  254. ErrMsg string `json:"err_msg"`
  255. InfRefmsgid string `json:"inf_refmsgid"`
  256. Infcode string `json:"infcode"`
  257. Output struct {
  258. Setldetail []interface{} `json:"setldetail"`
  259. Setlinfo struct {
  260. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  261. AcctPay float64 `json:"acct_pay"`
  262. ActPayDedc float64 `json:"act_pay_dedc"`
  263. Age float64 `json:"age"`
  264. Balc float64 `json:"balc"`
  265. Brdy string `json:"brdy"`
  266. Certno string `json:"certno"`
  267. ClrOptins string `json:"clr_optins"`
  268. ClrType string `json:"clr_type"`
  269. ClrWay string `json:"clr_way"`
  270. CvlservFlag string `json:"cvlserv_flag"`
  271. CvlservPay float64 `json:"cvlserv_pay"`
  272. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  273. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  274. Gend string `json:"gend"`
  275. HifesPay float64 `json:"hifes_pay"`
  276. HifmiPay float64 `json:"hifmi_pay"`
  277. HifpPay float64 `json:"hifp_pay"`
  278. HospPartAmt float64 `json:"hosp_part_amt"`
  279. InscpScpAmt float64 `json:"inscp_scp_amt"`
  280. Insutype string `json:"insutype"`
  281. MafPay float64 `json:"maf_pay"`
  282. MdtrtCertType string `json:"mdtrt_cert_type"`
  283. HifobPay float64 `json:"hifob_pay"`
  284. MdtrtID string `json:"mdtrt_id"`
  285. MedType string `json:"med_type"`
  286. MedfeeSumamt float64 `json:"medfee_sumamt"`
  287. MedinsSetlID string `json:"medins_setl_id"`
  288. Naty string `json:"naty"`
  289. OthPay float64 `json:"oth_pay"`
  290. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  291. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  292. PreselfpayAmt float64 `json:"preselfpay_amt"`
  293. PsnCashPay float64 `json:"psn_cash_pay"`
  294. PsnCertType string `json:"psn_cert_type"`
  295. PsnName string `json:"psn_name"`
  296. PsnNo string `json:"psn_no"`
  297. PsnPartAmt float64 `json:"psn_part_amt"`
  298. PsnType string `json:"psn_type"`
  299. SetlID string `json:"setl_id"`
  300. SetlTime string `json:"setl_time"`
  301. } `json:"setlinfo"`
  302. } `json:"output"`
  303. RefmsgTime string `json:"refmsg_time"`
  304. RespondTime string `json:"respond_time"`
  305. Signtype interface{} `json:"signtype"`
  306. WarnMsg interface{} `json:"warn_msg"`
  307. }
  308. type ResultSixteen struct {
  309. Cainfo string `json:"cainfo"`
  310. ErrMsg string `json:"err_msg"`
  311. InfRefmsgid string `json:"inf_refmsgid"`
  312. Infcode int64 `json:"infcode"`
  313. Output struct {
  314. Setldetail []interface{} `json:"setldetail"`
  315. Setlinfo struct {
  316. MdtrtID string `json:"mdtrt_id"`
  317. SetlID string `json:"setl_id"`
  318. ClrOptins string `json:"clr_optins"`
  319. SetlTime string `json:"setl_time"`
  320. MedfeeSumamt float64 `json:"medfee_sumamt"`
  321. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  322. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  323. PreselfpayAmt float64 `json:"preselfpay_amt"`
  324. InscpScpAmt float64 `json:"inscp_scp_amt"`
  325. ActPayDedc float64 `json:"act_pay_dedc"`
  326. HifpPay float64 `json:"hifp_pay"`
  327. PoolPropSe float64 `json:"pool_prop_selfpay"`
  328. Lfpay float64 `json:"selfpay"`
  329. CvlservPay float64 `json:"cvlserv_pay"`
  330. HifesPay float64 `json:"hifes_pay"`
  331. HifmiPay float64 `json:"hifmi_pay"`
  332. HifobPay float64 `json:"hifob_pay"`
  333. MafPay float64 `json:"maf_pay"`
  334. OthPay float64 `json:"oth_pay"`
  335. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  336. PsnPartAmt float64 `json:"psn_part_amt"`
  337. AcctPay float64 `json:"acct_pay"`
  338. Balc float64 `json:"balc"`
  339. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  340. HospPartAmt float64 `json:"hosp_part_amt"`
  341. MedinsSetlID string `json:"medins_setl_id"`
  342. PdnCashPay string `json:"pdn_cash_pay"`
  343. } `json:"setlinfo"`
  344. } `json:"output"`
  345. RefmsgTime string `json:"refmsg_time"`
  346. RespondTime string `json:"respond_time"`
  347. Signtype interface{} `json:"signtype"`
  348. WarnMsg interface{} `json:"warn_msg"`
  349. }
  350. type ResultSixteen10265 struct {
  351. Cainfo string `json:"cainfo"`
  352. ErrMsg string `json:"err_msg"`
  353. InfRefmsgid string `json:"inf_refmsgid"`
  354. Infcode string `json:"infcode"`
  355. Output struct {
  356. Setldetail []interface{} `json:"setldetail"`
  357. Setlinfo struct {
  358. MdtrtID string `json:"mdtrt_id"`
  359. SetlID string `json:"setl_id"`
  360. ClrOptins string `json:"clr_optins"`
  361. SetlTime string `json:"setl_time"`
  362. MedfeeSumamt float64 `json:"medfee_sumamt"`
  363. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  364. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  365. PreselfpayAmt float64 `json:"preselfpay_amt"`
  366. InscpScpAmt float64 `json:"inscp_scp_amt"`
  367. ActPayDedc float64 `json:"act_pay_dedc"`
  368. HifpPay float64 `json:"hifp_pay"`
  369. PoolPropSe float64 `json:"pool_prop_selfpay"`
  370. Lfpay float64 `json:"selfpay"`
  371. CvlservPay float64 `json:"cvlserv_pay"`
  372. HifesPay float64 `json:"hifes_pay"`
  373. HifmiPay float64 `json:"hifmi_pay"`
  374. HifobPay float64 `json:"hifob_pay"`
  375. MafPay float64 `json:"maf_pay"`
  376. OthPay float64 `json:"oth_pay"`
  377. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  378. PsnPartAmt float64 `json:"psn_part_amt"`
  379. AcctPay float64 `json:"acct_pay"`
  380. Balc float64 `json:"balc"`
  381. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  382. HospPartAmt float64 `json:"hosp_part_amt"`
  383. MedinsSetlID string `json:"medins_setl_id"`
  384. PdnCashPay string `json:"pdn_cash_pay"`
  385. } `json:"setlinfo"`
  386. } `json:"output"`
  387. RefmsgTime string `json:"refmsg_time"`
  388. RespondTime string `json:"respond_time"`
  389. Signtype interface{} `json:"signtype"`
  390. WarnMsg interface{} `json:"warn_msg"`
  391. }
  392. type Custom struct {
  393. DetItemFeeSumamt string
  394. Cut string
  395. FeedetlSn string
  396. Price string
  397. MedListCodg string
  398. Type int64
  399. AdviceId int64
  400. ProjectId int64
  401. ItemId int64
  402. }
  403. type ResultEmpty struct {
  404. Cainfo interface{} `json:"cainfo"`
  405. ErrMsg string `json:"err_msg"`
  406. InfRefmsgid string `json:"inf_refmsgid"`
  407. Infcode int64 `json:"infcode"`
  408. Output struct {
  409. } `json:"output"`
  410. RefmsgTime string `json:"refmsg_time"`
  411. RespondTime string `json:"respond_time"`
  412. Signtype interface{} `json:"signtype"`
  413. WarnMsg interface{} `json:"warn_msg"`
  414. }
  415. type ResultEmpty10265 struct {
  416. Cainfo interface{} `json:"cainfo"`
  417. ErrMsg string `json:"err_msg"`
  418. InfRefmsgid string `json:"inf_refmsgid"`
  419. Infcode string `json:"infcode"`
  420. Output struct {
  421. } `json:"output"`
  422. RefmsgTime string `json:"refmsg_time"`
  423. RespondTime string `json:"respond_time"`
  424. Signtype interface{} `json:"signtype"`
  425. WarnMsg interface{} `json:"warn_msg"`
  426. }
  427. type CustomResult struct {
  428. BasMednFlag string `json:"bas_medn_flag"`
  429. ChldMedcFlag string `json:"chld_medc_flag"`
  430. ChrgitmLv string `json:"chrgitm_lv"`
  431. Cnt float64 `json:"cnt"`
  432. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  433. DrtReimFlag string `json:"drt_reim_flag"`
  434. FeedetlSn string `json:"feedetl_sn"`
  435. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  436. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  437. InscpScpAmt float64 `json:"inscp_scp_amt"`
  438. ListSpItemFlag string `json:"list_sp_item_flag"`
  439. LmtUsedFlag string `json:"lmt_used_flag"`
  440. MedChrgitmType string `json:"med_chrgitm_type"`
  441. Memo string `json:"memo"`
  442. OverlmtAmt float64 `json:"overlmt_amt"`
  443. PreselfpayAmt float64 `json:"preselfpay_amt"`
  444. Pric float64 `json:"pric"`
  445. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  446. SelfpayProp float64 `json:"selfpay_prop"`
  447. }
  448. func ZHHisManagerApiRegistRouters() {
  449. beego.Router("/zh/api/inhopitalcheck/get", &ZHHisApiController{}, "get:GetZHInHospitalCheck")
  450. beego.Router("/zh/api/outhopitalcheck/get", &ZHHisApiController{}, "get:GetZHOutHospitalCheck")
  451. beego.Router("/zh/api/uploadinfo/get", &ZHHisApiController{}, "get:GetUploadInfo")
  452. beego.Router("/zh/api/settle/get", &ZHHisApiController{}, "get:GetSettleInfo")
  453. beego.Router("/zh/api/inthopitaluncheck/get", &ZHHisApiController{}, "get:GetZHInHospitalUnCheck")
  454. beego.Router("/zh/api/outhopitaluncheck/get", &ZHHisApiController{}, "get:GetZHOutHospitalUnCheck")
  455. beego.Router("/zh/api/refund", &ZHHisApiController{}, "get:ZHRefund")
  456. beego.Router("/zh/api/refunddetail", &ZHHisApiController{}, "get:ZHRefundDetail")
  457. beego.Router("/zh/api/patient/info", &ZHHisApiController{}, "get:GetZHPatientInfo")
  458. }
  459. func (c *ZHHisApiController) GetZHPatientInfo() {
  460. id_card_no := c.GetString("id_card_no")
  461. admin_user_id, _ := c.GetInt64("admin_user_id")
  462. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  463. if patient.ID == 0 {
  464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  465. return
  466. }
  467. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  468. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  469. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  470. if config.IsOpen == 1 {
  471. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  472. var dat map[string]interface{}
  473. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  474. fmt.Println(dat)
  475. } else {
  476. fmt.Println(err)
  477. }
  478. userJSONBytes, _ := json.Marshal(dat)
  479. var res ResultTwo
  480. var resTwo10265 ResultTwo10265
  481. if miConfig.Code == "H15049901371" {
  482. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  483. utils.ErrorLog("解析失败:%v", err)
  484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  485. return
  486. }
  487. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  488. res.Infcode = Infcode
  489. res.ErrMsg = resTwo10265.ErrMsg
  490. res.Output = resTwo10265.Output
  491. res.InfRefmsgid = resTwo10265.InfRefmsgid
  492. res.RespondTime = resTwo10265.RespondTime
  493. res.WarnInfo = resTwo10265.WarnInfo
  494. } else {
  495. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  496. utils.ErrorLog("解析失败:%v", err)
  497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  498. return
  499. }
  500. }
  501. var insutypes []string
  502. var insutype string
  503. var is390 int = 0
  504. var is310 int = 0
  505. for _, item := range res.Output.Iinfo {
  506. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  507. insutypes = append(insutypes, item.Insutype)
  508. }
  509. }
  510. if len(insutypes) == 1 {
  511. insutype = insutypes[0]
  512. } else {
  513. for _, i := range insutypes {
  514. if i == "390" {
  515. is390 = 1
  516. }
  517. if i == "310" {
  518. is310 = 1
  519. }
  520. }
  521. }
  522. if is390 == 1 {
  523. insutype = "390"
  524. }
  525. if is310 == 1 {
  526. insutype = "310"
  527. }
  528. if len(insutypes) == 0 {
  529. insutype = "310"
  530. }
  531. if res.Infcode != 0 {
  532. c.ServeSuccessJSON(map[string]interface{}{
  533. "failed_code": -10,
  534. "msg": res.ErrMsg,
  535. })
  536. } else {
  537. c.ServeSuccessJSON(map[string]interface{}{
  538. "failed_code": 0,
  539. "info": res,
  540. "insutype": insutype,
  541. })
  542. }
  543. }
  544. }
  545. func (c *ZHHisApiController) GetZHInHospitalCheck() {
  546. id, _ := c.GetInt64("id")
  547. record_time := c.GetString("record_time")
  548. name := c.GetString("name")
  549. phone := c.GetString("phone")
  550. id_card_type, _ := c.GetInt64("id_card_type")
  551. certificates, _ := c.GetInt64("certificates")
  552. id_card_no := c.GetString("id_card_no")
  553. doctor, _ := c.GetInt64("doctor")
  554. admin_user_id, _ := c.GetInt64("admin_user_id")
  555. department, _ := c.GetInt64("department")
  556. adm_bed, _ := c.GetInt64("adm_bed")
  557. diagnosis_ids := c.GetString("diagnosis")
  558. sick_type, _ := c.GetInt64("sick_type")
  559. start_time := c.GetString("start_time")
  560. balance_accounts_type, _ := c.GetInt64("balance_accounts_type")
  561. social_type, _ := c.GetInt64("social_type")
  562. psn_type, _ := c.GetInt64("psn_type")
  563. //reg_type, _ := c.GetInt64("p_type")
  564. med_type, _ := c.GetInt64("med_type")
  565. diagnosis_ids_arr := strings.Split(diagnosis_ids, "-")
  566. timeLayout := "2006-01-02"
  567. loc, _ := time.LoadLocation("Local")
  568. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  569. if err != nil {
  570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  571. return
  572. }
  573. recordDateTime := theTime.Unix()
  574. adminInfo := c.GetAdminUserInfo()
  575. record, _ := service.GetLastHospitalRecord(id, adminInfo.CurrentOrgId)
  576. if record.ID != 0 {
  577. if record.InHospitalStatus == 1 && record.OutHospitalStatus != 1 {
  578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalExistDataException)
  579. return
  580. }
  581. }
  582. var patient service.Patients
  583. if id == 0 {
  584. patient, _ = service.GetPatientByIDCard(id_card_no, adminInfo.CurrentOrgId)
  585. } else {
  586. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  587. }
  588. diagnosisConfig, _ := service.FindDiagnoseByIds(diagnosis_ids_arr)
  589. sickConfig, _ := service.FindSickById(sick_type)
  590. departmentInfo, _ := service.GetDepartMentDetail(department)
  591. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  592. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  593. result := service.ZHGdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", certificates, name)
  594. doctorInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  595. deviceNumber, _ := service.GetDeviceNumberByID(adm_bed, adminInfo.CurrentOrgId)
  596. var dat map[string]interface{}
  597. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  598. fmt.Println(dat)
  599. } else {
  600. fmt.Println(err)
  601. }
  602. userJSONBytes, _ := json.Marshal(dat)
  603. //
  604. //var res2 ResultTwo
  605. //if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  606. // utils.ErrorLog("解析失败:%v", err)
  607. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  608. // return
  609. //}
  610. var res2 ResultTwo
  611. var resTwo10265 ResultTwo10265
  612. if miConfig.Code == "H15049901371" {
  613. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  614. utils.ErrorLog("解析失败:%v", err)
  615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  616. return
  617. }
  618. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  619. res2.Infcode = Infcode
  620. res2.ErrMsg = resTwo10265.ErrMsg
  621. res2.Output = resTwo10265.Output
  622. res2.InfRefmsgid = resTwo10265.InfRefmsgid
  623. res2.RespondTime = resTwo10265.RespondTime
  624. res2.WarnInfo = resTwo10265.WarnInfo
  625. } else {
  626. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  627. utils.ErrorLog("解析失败:%v", err)
  628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  629. return
  630. }
  631. }
  632. //InsuplcAdmdvs = res2.Output.
  633. if social_type != 0 {
  634. } else {
  635. }
  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 = insutype
  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(index), 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: insutype,
  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. //
  1339. // data["pre"] = customs[start-1 : stop]
  1340. // bytesData, _ := json.Marshal(data)
  1341. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/zh/five", bytes.NewReader(bytesData))
  1342. // resp, _ := client.Do(req)
  1343. // defer resp.Body.Close()
  1344. // body, ioErr := ioutil.ReadAll(resp.Body)
  1345. // if ioErr != nil {
  1346. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1347. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1348. // return
  1349. // }
  1350. // var respJSON map[string]interface{}
  1351. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1352. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1353. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1354. // return
  1355. // }
  1356. //
  1357. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1358. // userJSONBytes, _ := json.Marshal(respJSON)
  1359. // var res ResultFour
  1360. // var resFour10265 ResultFour10265
  1361. // if miConfig.Code == "H15049901371" {
  1362. // if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  1363. // utils.ErrorLog("解析失败:%v", err)
  1364. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1365. // return
  1366. // }
  1367. // res.WarnMsg = resFour10265.WarnMsg
  1368. // res.Output = resFour10265.Output
  1369. // res.ErrMsg = resFour10265.ErrMsg
  1370. // res.RespondTime = resFour10265.RespondTime
  1371. // res.InfRefmsgid = resFour10265.InfRefmsgid
  1372. // Infcode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  1373. // res.Infcode = Infcode
  1374. //
  1375. // } else {
  1376. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1377. // utils.ErrorLog("解析失败:%v", err)
  1378. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1379. // return
  1380. // }
  1381. // }
  1382. //
  1383. // if res.Infcode == 0 {
  1384. // ress = append(ress, &res)
  1385. // } else {
  1386. // isSuccess = false
  1387. // errlog := &models.HisOrderError{
  1388. // UserOrgId: adminUser.CurrentOrgId,
  1389. // Ctime: time.Now().Unix(),
  1390. // Mtime: time.Now().Unix(),
  1391. // Number: chrg_bchno,
  1392. // ErrMsg: "",
  1393. // Status: 1,
  1394. // PatientId: id,
  1395. // RecordTime: recordDateTime,
  1396. // Stage: 4,
  1397. // }
  1398. // service.CreateErrMsgLog(errlog)
  1399. // c.ServeSuccessJSON(map[string]interface{}{
  1400. // "failed_code": -10,
  1401. // "msg": "上传明细错误,请联系his厂商",
  1402. // })
  1403. // return
  1404. // }
  1405. //}
  1406. //
  1407. //if isSuccess == true {
  1408. // if settle_accounts_type == 1 {
  1409. // for _, subItem := range ress {
  1410. // for _, item := range subItem.Output.Result {
  1411. // temp := strings.Split(item.FeedetlSn, "-")
  1412. // var advice_id int64 = 0
  1413. // var project_id int64 = 0
  1414. // var types int64 = 0
  1415. //
  1416. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  1417. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  1418. //
  1419. // if temp[1] == "1" {
  1420. // advice_id = id
  1421. // project_id = 0
  1422. // } else if temp[1] == "2" {
  1423. // advice_id = 0
  1424. // project_id = id
  1425. // }
  1426. // info := &models.HisOrderInfo{
  1427. // OrderNumber: record.Number,
  1428. // FeedetlSn: item.FeedetlSn,
  1429. // UploadDate: time.Now().Unix(),
  1430. // AdviceId: advice_id,
  1431. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  1432. // Cnt: item.Cnt,
  1433. // Pric: float64(item.Pric),
  1434. // PatientId: record.PatientId,
  1435. // PricUplmtAmt: item.PricUplmtAmt,
  1436. // SelfpayProp: item.SelfpayProp,
  1437. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  1438. // OverlmtAmt: item.OverlmtAmt,
  1439. // PreselfpayAmt: item.PreselfpayAmt,
  1440. // BasMednFlag: item.BasMednFlag,
  1441. // MedChrgitmType: item.MedChrgitmType,
  1442. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  1443. // Status: 1,
  1444. // Memo: item.Memo,
  1445. // Mtime: time.Now().Unix(),
  1446. // InscpScpAmt: item.InscpScpAmt,
  1447. // DrtReimFlag: item.DrtReimFlag,
  1448. // Ctime: time.Now().Unix(),
  1449. // ListSpItemFlag: item.ListSpItemFlag,
  1450. // ChldMedcFlag: item.ChldMedcFlag,
  1451. // LmtUsedFlag: item.LmtUsedFlag,
  1452. // ChrgitmLv: item.ChrgitmLv,
  1453. // UserOrgId: adminUser.CurrentOrgId,
  1454. // HisPatientId: record.ID,
  1455. // OrderId: 0,
  1456. // ProjectId: project_id,
  1457. // Type: types,
  1458. // SettleType: settle_accounts_type,
  1459. // }
  1460. // service.CreateOrderInfo(info)
  1461. // }
  1462. // }
  1463. // err := service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
  1464. // if err == nil {
  1465. // c.ServeSuccessJSON(map[string]interface{}{
  1466. // "msg": "上传费用明细成功",
  1467. // })
  1468. // return
  1469. // } else {
  1470. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1471. // return
  1472. // }
  1473. //
  1474. // } else {
  1475. // var total float64
  1476. // for _, item := range prescriptions {
  1477. // if item.Type == 1 { //药品
  1478. // for _, subItem := range item.HisDoctorAdviceInfo {
  1479. // total = total + (subItem.Price * subItem.PrescribingNumber)
  1480. // }
  1481. // }
  1482. // if item.Type == 2 { //项目
  1483. // for _, subItem := range item.HisPrescriptionProject {
  1484. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1485. // total = total + (subItem.Price * cnt)
  1486. // }
  1487. // }
  1488. // }
  1489. // for _, item := range prescriptions {
  1490. // for _, subItem := range item.HisAdditionalCharge {
  1491. // total = total + (subItem.Price * float64(subItem.Count))
  1492. // }
  1493. // }
  1494. // allTotal := fmt.Sprintf("%.2f", total)
  1495. // totals, _ := strconv.ParseFloat(allTotal, 64)
  1496. //
  1497. // order := &models.HisOrder{
  1498. // UserOrgId: adminUser.CurrentOrgId,
  1499. // HisPatientId: record.ID,
  1500. // PatientId: record.PatientId,
  1501. // SettleAccountsDate: recordDateTime,
  1502. // Ctime: time.Now().Unix(),
  1503. // Mtime: time.Now().Unix(),
  1504. // Status: 1,
  1505. // Number: record.Number,
  1506. // Infcode: 0,
  1507. // WarnMsg: "",
  1508. // Cainfo: "",
  1509. // ErrMsg: "",
  1510. // RespondTime: "",
  1511. // InfRefmsgid: "",
  1512. // OrderStatus: 1,
  1513. // MdtrtId: record.Number,
  1514. // IsMedicineInsurance: 1,
  1515. // SettleType: settle_accounts_type,
  1516. // SettleStartTime: start_time,
  1517. // SettleEndTime: end_time,
  1518. // Creator: roles.AdminUserId,
  1519. // Modify: roles.AdminUserId,
  1520. // PType: 1,
  1521. // MedfeeSumamt: totals,
  1522. // }
  1523. // err = service.CreateOrder(order)
  1524. // if err != nil {
  1525. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  1526. // return
  1527. // }
  1528. // for _, subItem := range ress {
  1529. // for _, item := range subItem.Output.Result {
  1530. // temp := strings.Split(item.FeedetlSn, "-")
  1531. // var advice_id int64 = 0
  1532. // var project_id int64 = 0
  1533. // var types int64 = 0
  1534. //
  1535. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  1536. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  1537. //
  1538. // if temp[1] == "1" {
  1539. // advice_id = id
  1540. // project_id = 0
  1541. // } else if temp[1] == "2" {
  1542. // advice_id = 0
  1543. // project_id = id
  1544. // }
  1545. // info := &models.HisOrderInfo{
  1546. // OrderNumber: order.Number,
  1547. // FeedetlSn: item.FeedetlSn,
  1548. // UploadDate: time.Now().Unix(),
  1549. // AdviceId: advice_id,
  1550. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  1551. // Cnt: item.Cnt,
  1552. // Pric: float64(item.Pric),
  1553. // PatientId: record.PatientId,
  1554. // PricUplmtAmt: item.PricUplmtAmt,
  1555. // SelfpayProp: item.SelfpayProp,
  1556. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  1557. // OverlmtAmt: item.OverlmtAmt,
  1558. // PreselfpayAmt: item.PreselfpayAmt,
  1559. // BasMednFlag: item.BasMednFlag,
  1560. // MedChrgitmType: item.MedChrgitmType,
  1561. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  1562. // Status: 1,
  1563. // Memo: item.Memo,
  1564. // Mtime: time.Now().Unix(),
  1565. // InscpScpAmt: item.InscpScpAmt,
  1566. // DrtReimFlag: item.DrtReimFlag,
  1567. // Ctime: time.Now().Unix(),
  1568. // ListSpItemFlag: item.ListSpItemFlag,
  1569. // ChldMedcFlag: item.ChldMedcFlag,
  1570. // LmtUsedFlag: item.LmtUsedFlag,
  1571. // ChrgitmLv: item.ChrgitmLv,
  1572. // UserOrgId: adminUser.CurrentOrgId,
  1573. // HisPatientId: record.ID,
  1574. // OrderId: order.ID,
  1575. // ProjectId: project_id,
  1576. // Type: types,
  1577. // SettleType: settle_accounts_type,
  1578. // }
  1579. // service.CreateOrderInfo(info)
  1580. // }
  1581. // }
  1582. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
  1583. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, record.Number, recordDateTime)
  1584. // c.ServeSuccessJSON(map[string]interface{}{
  1585. // "msg": "上传费用明细成功",
  1586. // })
  1587. //
  1588. // }
  1589. //
  1590. //}
  1591. }
  1592. }
  1593. func (c *ZHHisApiController) ZHRefund() {
  1594. order_id, _ := c.GetInt64("order_id")
  1595. admin_user_id, _ := c.GetInt64("admin_user_id")
  1596. adminUser := c.GetAdminUserInfo()
  1597. var order models.HisOrder
  1598. order, _ = service.GetHisOrderByID(order_id)
  1599. record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1600. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1601. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1602. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1603. if config.IsOpen == 1 { //对接了医保,走医保流程
  1604. result, src_resquest := service.Gdyb2305(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  1605. var dat map[string]interface{}
  1606. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1607. fmt.Println(dat)
  1608. } else {
  1609. fmt.Println(err)
  1610. }
  1611. userJSONBytes, _ := json.Marshal(dat)
  1612. var res ResultSixteen
  1613. var resSixteen ResultSixteen10265
  1614. if miConfig.Code == "H15049901371" {
  1615. if err := json.Unmarshal(userJSONBytes, &resSixteen); err != nil {
  1616. utils.ErrorLog("解析失败:%v", err)
  1617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1618. return
  1619. }
  1620. res.Cainfo = resSixteen.Cainfo
  1621. res.WarnMsg = resSixteen.WarnMsg
  1622. res.Output = resSixteen.Output
  1623. res.ErrMsg = resSixteen.ErrMsg
  1624. res.RespondTime = resSixteen.RespondTime
  1625. Infcode, _ := strconv.ParseInt(resSixteen.Infcode, 10, 64)
  1626. res.Infcode = Infcode
  1627. } else {
  1628. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1629. utils.ErrorLog("解析失败:%v", err)
  1630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1631. return
  1632. }
  1633. }
  1634. if res.Infcode == 0 {
  1635. err := service.UpdataOrderStatusThree(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  1636. if err == nil {
  1637. c.ServeSuccessJSON(map[string]interface{}{
  1638. "msg": "退费成功",
  1639. })
  1640. } else {
  1641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1642. return
  1643. }
  1644. } else {
  1645. c.ServeSuccessJSON(map[string]interface{}{
  1646. "code": -10,
  1647. "msg": res.ErrMsg,
  1648. })
  1649. }
  1650. } else {
  1651. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", "")
  1652. if err == nil {
  1653. c.ServeSuccessJSON(map[string]interface{}{
  1654. "msg": "退费成功",
  1655. })
  1656. } else {
  1657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1658. return
  1659. }
  1660. }
  1661. }
  1662. func (c *ZHHisApiController) ZHRefundDetail() {
  1663. patient_id, _ := c.GetInt64("patient_id")
  1664. his_patient_id, _ := c.GetInt64("his_patient_id")
  1665. record_time := c.GetString("record_time")
  1666. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1667. order_id, _ := c.GetInt64("order_id")
  1668. admin_user_id, _ := c.GetInt64("admin_user_id")
  1669. timeLayout := "2006-01-02"
  1670. loc, _ := time.LoadLocation("Local")
  1671. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1672. if err != nil {
  1673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1674. return
  1675. }
  1676. recordDateTime := theTime.Unix()
  1677. adminUser := c.GetAdminUserInfo()
  1678. //var prescriptions []*models.HisPrescription
  1679. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1680. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1681. if settle_accounts_type == 1 { //日结
  1682. infos, _ := service.GetZHHisUploadOrderInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1683. record, _ := service.GetInHospitalRecord(his_patient_id)
  1684. var isSuccess bool = true
  1685. for _, item := range infos {
  1686. result := service.Gdyb2302(record.PsnNo, record.Number, miConfig.OrgName, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, item.FeedetlSn, 1)
  1687. var dat map[string]interface{}
  1688. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1689. fmt.Println(dat)
  1690. } else {
  1691. fmt.Println(err)
  1692. }
  1693. userJSONBytes, _ := json.Marshal(dat)
  1694. var res2 ResultEmpty
  1695. var resEmpty10265 ResultEmpty10265
  1696. if miConfig.Code == "H15049901371" {
  1697. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  1698. utils.ErrorLog("解析失败:%v", err)
  1699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1700. return
  1701. }
  1702. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  1703. res2.Infcode = Infcode
  1704. res2.RespondTime = resEmpty10265.RespondTime
  1705. res2.ErrMsg = resEmpty10265.ErrMsg
  1706. res2.Output = resEmpty10265.Output
  1707. res2.WarnMsg = resEmpty10265.WarnMsg
  1708. } else {
  1709. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  1710. utils.ErrorLog("解析失败:%v", err)
  1711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1712. return
  1713. }
  1714. }
  1715. if res2.Infcode == -1 {
  1716. isSuccess = false
  1717. }
  1718. }
  1719. if isSuccess {
  1720. err := service.UpDateOrderInfoStatus(patient_id, recordDateTime, adminUser.CurrentOrgId)
  1721. if err != nil {
  1722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1723. return
  1724. }
  1725. err1 := service.UpDatePrescriptionOrderStatusTwo(patient_id, recordDateTime, adminUser.CurrentOrgId)
  1726. if err1 != nil {
  1727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1728. return
  1729. }
  1730. c.ServeSuccessJSON(map[string]interface{}{
  1731. "msg": "撤销明细成功",
  1732. })
  1733. }
  1734. } else {
  1735. //prescriptions, _ = service.GetZHMonthHisUploadPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1736. var order models.HisOrder
  1737. order, _ = service.GetHisOrderByID(order_id)
  1738. record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1739. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1740. if config.IsOpen == 1 { //对接了医保,走医保流程
  1741. result := service.Gdyb2302(order.PsnNo, order.MdtrtId, miConfig.OrgName, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, "0000", 0)
  1742. var dat map[string]interface{}
  1743. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1744. fmt.Println(dat)
  1745. } else {
  1746. fmt.Println(err)
  1747. }
  1748. userJSONBytes, _ := json.Marshal(dat)
  1749. var res2 ResultEmpty
  1750. var resEmpty10265 ResultEmpty10265
  1751. if miConfig.Code == "H15049901371" {
  1752. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  1753. utils.ErrorLog("解析失败:%v", err)
  1754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1755. return
  1756. }
  1757. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  1758. res2.Infcode = Infcode
  1759. res2.RespondTime = resEmpty10265.RespondTime
  1760. res2.ErrMsg = resEmpty10265.ErrMsg
  1761. res2.Output = resEmpty10265.Output
  1762. res2.WarnMsg = resEmpty10265.WarnMsg
  1763. } else {
  1764. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  1765. utils.ErrorLog("解析失败:%v", err)
  1766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1767. return
  1768. }
  1769. }
  1770. if res2.Infcode == 0 {
  1771. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", result)
  1772. if err == nil {
  1773. c.ServeSuccessJSON(map[string]interface{}{
  1774. "msg": "退费成功",
  1775. })
  1776. } else {
  1777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1778. return
  1779. }
  1780. } else {
  1781. c.ServeSuccessJSON(map[string]interface{}{
  1782. "code": -10,
  1783. "msg": res2.ErrMsg,
  1784. })
  1785. }
  1786. } else {
  1787. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", "")
  1788. if err == nil {
  1789. c.ServeSuccessJSON(map[string]interface{}{
  1790. "msg": "退费成功",
  1791. })
  1792. } else {
  1793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1794. return
  1795. }
  1796. }
  1797. }
  1798. }
  1799. func (this *ZHHisApiController) GetZHOutHospitalUnCheck() {
  1800. id, _ := this.GetInt64("id")
  1801. admin_user_id, _ := this.GetInt64("admin_user_id")
  1802. adminInfo := this.GetAdminUserInfo()
  1803. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1804. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  1805. record, _ := service.GetInHospitalRecord(id)
  1806. if record.ID == 0 {
  1807. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
  1808. return
  1809. }
  1810. result := service.ZHGdyb2405(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  1811. var dat map[string]interface{}
  1812. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1813. fmt.Println(dat)
  1814. } else {
  1815. fmt.Println(err)
  1816. }
  1817. userJSONBytes, _ := json.Marshal(dat)
  1818. var res ResultEmpty
  1819. var resEmpty10265 ResultEmpty10265
  1820. if miConfig.Code == "H15049901371" {
  1821. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  1822. utils.ErrorLog("解析失败:%v", err)
  1823. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1824. return
  1825. }
  1826. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  1827. res.Infcode = Infcode
  1828. res.RespondTime = resEmpty10265.RespondTime
  1829. res.ErrMsg = resEmpty10265.ErrMsg
  1830. res.Output = resEmpty10265.Output
  1831. res.WarnMsg = resEmpty10265.WarnMsg
  1832. } else {
  1833. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1834. utils.ErrorLog("解析失败:%v", err)
  1835. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1836. return
  1837. }
  1838. }
  1839. if res.Infcode == 0 {
  1840. record.OutHospitalStatus = 0
  1841. service.CreateHospitalRecord(&record)
  1842. this.ServeSuccessJSON(map[string]interface{}{
  1843. "msg": "撤销出院成功",
  1844. })
  1845. } else {
  1846. this.ServeSuccessJSON(map[string]interface{}{
  1847. "failed_code": -10,
  1848. "msg": res.ErrMsg,
  1849. })
  1850. }
  1851. }
  1852. func (this *ZHHisApiController) GetZHInHospitalUnCheck() {
  1853. id, _ := this.GetInt64("id")
  1854. admin_user_id, _ := this.GetInt64("admin_user_id")
  1855. adminInfo := this.GetAdminUserInfo()
  1856. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1857. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  1858. record, _ := service.GetInHospitalRecord(id)
  1859. if record.ID == 0 {
  1860. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
  1861. return
  1862. }
  1863. result := service.ZHGdyb2404(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  1864. var dat map[string]interface{}
  1865. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1866. fmt.Println(dat)
  1867. } else {
  1868. fmt.Println(err)
  1869. }
  1870. userJSONBytes, _ := json.Marshal(dat)
  1871. var res ResultEmpty
  1872. var resEmpty10265 ResultEmpty10265
  1873. if miConfig.Code == "H15049901371" {
  1874. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  1875. utils.ErrorLog("解析失败:%v", err)
  1876. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1877. return
  1878. }
  1879. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  1880. res.Infcode = Infcode
  1881. res.RespondTime = resEmpty10265.RespondTime
  1882. res.ErrMsg = resEmpty10265.ErrMsg
  1883. res.Output = resEmpty10265.Output
  1884. res.WarnMsg = resEmpty10265.WarnMsg
  1885. } else {
  1886. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1887. utils.ErrorLog("解析失败:%v", err)
  1888. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1889. return
  1890. }
  1891. }
  1892. if res.Infcode == 0 {
  1893. record.Status = 0
  1894. service.CreateHospitalRecord(&record)
  1895. this.ServeSuccessJSON(map[string]interface{}{
  1896. "msg": "撤销入院成功",
  1897. })
  1898. } else {
  1899. this.ServeSuccessJSON(map[string]interface{}{
  1900. "failed_code": -10,
  1901. "msg": res.ErrMsg,
  1902. })
  1903. }
  1904. }