zh_his_api_controller.go 71KB

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