zh_his_api_controller.go 53KB

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