sz_his_api_controller.go 91KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737
  1. package sz
  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. "strconv"
  15. "strings"
  16. //"strings"
  17. "syscall"
  18. "time"
  19. "unsafe"
  20. )
  21. type Result struct {
  22. Transtime string `json:"transTime"`
  23. Transtype string `json:"transType"`
  24. Transreturncode string `json:"transReturnCode"`
  25. Transreturnmessage string `json:"transReturnMessage"`
  26. Transversion string `json:"transVersion"`
  27. Serialnumber string `json:"serialNumber"`
  28. Cardarea string `json:"cardArea"`
  29. Hospitalcode string `json:"hospitalCode"`
  30. Operatorcode string `json:"operatorCode"`
  31. Operatorname string `json:"operatorName"`
  32. Operatorpass string `json:"operatorPass"`
  33. Transbody struct {
  34. Akc190 string `json:"akc190"`
  35. Listsize int `json:"listsize"`
  36. Outputlist []struct {
  37. Aae072 string `json:"aae072"`
  38. Bkc369 string `json:"bkc369"`
  39. Bkf500 string `json:"bkf500"`
  40. Aka111 string `json:"aka111"`
  41. Ake001 string `json:"ake001"`
  42. Ake002 string `json:"ake002"`
  43. Bkm017 string `json:"bkm017"`
  44. Ake005 string `json:"ake005"`
  45. Ake006 string `json:"ake006"`
  46. Akc225 float64 `json:"akc225"`
  47. Akc226 float64 `json:"akc226"`
  48. Akc264 float64 `json:"akc264"`
  49. Aka065 string `json:"aka065"`
  50. Cka319 float64 `json:"cka319"`
  51. Akc268 float64 `json:"akc268"`
  52. } `json:"outputlist"`
  53. } `json:"transBody"`
  54. Verifycode string `json:"verifyCode"`
  55. Extenddeviceid string `json:"extendDeviceId"`
  56. Transchannel string `json:"transChannel"`
  57. Extenduserid string `json:"extendUserId"`
  58. Extendserialnumber string `json:"extendSerialNumber"`
  59. Caz055 string `json:"caz055"`
  60. Aae501 string `json:"aae501"`
  61. }
  62. type ResultOne struct {
  63. Transtime string `json:"transTime"`
  64. Transtype string `json:"transType"`
  65. Transreturncode string `json:"transReturnCode"`
  66. Transreturnmessage string `json:"transReturnMessage"`
  67. Transversion string `json:"transVersion"`
  68. Serialnumber string `json:"serialNumber"`
  69. Cardarea string `json:"cardArea"`
  70. Hospitalcode string `json:"hospitalCode"`
  71. Operatorcode string `json:"operatorCode"`
  72. Operatorname string `json:"operatorName"`
  73. Operatorpass string `json:"operatorPass"`
  74. Transbody struct {
  75. Ckc618 string `json:"ckc618"`
  76. Akc264 float64 `json:"akc264"`
  77. Akb068 int `json:"akb068"`
  78. Akb066 float64 `json:"akb066"`
  79. Akb067 int `json:"akb067"`
  80. Aae240 float64 `json:"aae240"`
  81. Outputlist []struct {
  82. Aaa036 string `json:"aaa036"`
  83. Aae019 float64 `json:"aae019"`
  84. } `json:"outputlist"`
  85. Outputlist2 []interface{} `json:"outputlist2"`
  86. } `json:"transBody"`
  87. Verifycode string `json:"verifyCode"`
  88. Extenddeviceid string `json:"extendDeviceId"`
  89. Transchannel string `json:"transChannel"`
  90. Extenduserid string `json:"extendUserId"`
  91. Extendserialnumber string `json:"extendSerialNumber"`
  92. Caz055 string `json:"caz055"`
  93. Aae501 string `json:"aae501"`
  94. }
  95. type ResultTwo struct {
  96. Transtime string `json:"transTime"`
  97. Transtype string `json:"transType"`
  98. Transreturncode string `json:"transReturnCode"`
  99. Transreturnmessage string `json:"transReturnMessage"`
  100. Transversion string `json:"transVersion"`
  101. Serialnumber string `json:"serialNumber"`
  102. Cardarea string `json:"cardArea"`
  103. Hospitalcode string `json:"hospitalCode"`
  104. Operatorcode string `json:"operatorCode"`
  105. Operatorname string `json:"operatorName"`
  106. Operatorpass string `json:"operatorPass"`
  107. Transbody struct {
  108. Ckc618 string `json:"ckc618"`
  109. Akc264 float64 `json:"akc264"`
  110. Akb068 float64 `json:"akb068"`
  111. Akb066 float64 `json:"akb066"`
  112. Akb067 float64 `json:"akb067"`
  113. Aae240 float64 `json:"aae240"`
  114. Outputlist1 []struct {
  115. Aka111 string `json:"aka111"`
  116. Bka058 float64 `json:"bka058"`
  117. } `json:"outputlist1"`
  118. Outputlist2 []struct {
  119. Aaa036 string `json:"aaa036"`
  120. Aae019 float64 `json:"aae019"`
  121. } `json:"outputlist2"`
  122. Outputlist3 []interface{} `json:"outputlist3"`
  123. } `json:"transBody"`
  124. Verifycode string `json:"verifyCode"`
  125. Extenddeviceid string `json:"extendDeviceId"`
  126. Transchannel string `json:"transChannel"`
  127. Extenduserid string `json:"extendUserId"`
  128. Extendserialnumber string `json:"extendSerialNumber"`
  129. Caz055 string `json:"caz055"`
  130. Aae501 string `json:"aae501"`
  131. }
  132. type ResultThree struct {
  133. Transtime string `json:"transTime"`
  134. Transtype string `json:"transType"`
  135. Transreturncode string `json:"transReturnCode"`
  136. Transreturnmessage string `json:"transReturnMessage"`
  137. Transversion string `json:"transVersion"`
  138. Serialnumber string `json:"serialNumber"`
  139. Cardarea string `json:"cardArea"`
  140. Hospitalcode string `json:"hospitalCode"`
  141. Operatorcode string `json:"operatorCode"`
  142. Operatorname string `json:"operatorName"`
  143. Operatorpass string `json:"operatorPass"`
  144. Transbody struct {
  145. Baz700 string `json:"baz700"`
  146. Ckc618 string `json:"ckc618"`
  147. } `json:"transBody"`
  148. Verifycode string `json:"verifyCode"`
  149. Extenddeviceid string `json:"extendDeviceId"`
  150. Transchannel string `json:"transChannel"`
  151. Extenduserid string `json:"extendUserId"`
  152. Extendserialnumber string `json:"extendSerialNumber"`
  153. Caz055 string `json:"caz055"`
  154. Aae501 string `json:"aae501"`
  155. }
  156. type ResultFive struct {
  157. Transtime string `json:"transTime"`
  158. Transtype string `json:"transType"`
  159. Transreturncode string `json:"transReturnCode"`
  160. Transreturnmessage string `json:"transReturnMessage"`
  161. Transversion string `json:"transVersion"`
  162. Serialnumber string `json:"serialNumber"`
  163. Cardarea string `json:"cardArea"`
  164. Hospitalcode string `json:"hospitalCode"`
  165. Operatorcode string `json:"operatorCode"`
  166. Operatorname string `json:"operatorName"`
  167. Operatorpass string `json:"operatorPass"`
  168. Transbody struct {
  169. Akc190 string `json:"akc190"`
  170. Listsize int `json:"listsize"`
  171. Outputlist []struct {
  172. Aae072 string `json:"aae072"`
  173. Bkf500 string `json:"bkf500"`
  174. Baz700 string `json:"baz700"`
  175. Bce574 string `json:"bce574"`
  176. } `json:"outputlist"`
  177. } `json:"transBody"`
  178. Verifycode string `json:"verifyCode"`
  179. Extenddeviceid string `json:"extendDeviceId"`
  180. Transchannel string `json:"transChannel"`
  181. Extenduserid string `json:"extendUserId"`
  182. Extendserialnumber string `json:"extendSerialNumber"`
  183. Caz055 string `json:"caz055"`
  184. Aae501 string `json:"aae501"`
  185. }
  186. type ResultFour struct {
  187. Transtime string `json:"transTime"`
  188. Transtype string `json:"transType"`
  189. Transreturncode string `json:"transReturnCode"`
  190. Transreturnmessage string `json:"transReturnMessage"`
  191. Transversion string `json:"transVersion"`
  192. Serialnumber string `json:"serialNumber"`
  193. Cardarea string `json:"cardArea"`
  194. Hospitalcode string `json:"hospitalCode"`
  195. Operatorcode string `json:"operatorCode"`
  196. Operatorname string `json:"operatorName"`
  197. Operatorpass string `json:"operatorPass"`
  198. Transbody struct {
  199. Akc190 string `json:"akc190"`
  200. Akc194 int `json:"akc194"`
  201. Bae917 int64 `json:"bae917"`
  202. Aka018 string `json:"aka018"`
  203. Aka030 string `json:"aka030"`
  204. Ckc618 string `json:"ckc618"`
  205. Akc264 int `json:"akc264"`
  206. Akb068 int `json:"akb068"`
  207. Akb066 int `json:"akb066"`
  208. Akb067 int `json:"akb067"`
  209. Cke298 float64 `json:"cke298"`
  210. Aae240 float64 `json:"aae240"`
  211. Outputlist1 []struct {
  212. Aae072 string `json:"aae072"`
  213. Bkc369 string `json:"bkc369"`
  214. Bkf500 string `json:"bkf500"`
  215. Aka111 string `json:"aka111"`
  216. Ake001 string `json:"ake001"`
  217. Ake002 string `json:"ake002"`
  218. Bkm017 string `json:"bkm017"`
  219. Ake005 string `json:"ake005"`
  220. Ake006 string `json:"ake006"`
  221. Ala026 string `json:"ala026"`
  222. Aka070 string `json:"aka070"`
  223. Aka074 string `json:"aka074"`
  224. Akc226 int `json:"akc226"`
  225. Akc225 int `json:"akc225"`
  226. Akc264 int `json:"akc264"`
  227. Aka067 string `json:"aka067"`
  228. Akc271 int `json:"akc271"`
  229. Bkc320 string `json:"bkc320"`
  230. Cke400 string `json:"cke400"`
  231. Ckc618 string `json:"ckc618"`
  232. Bka069 int64 `json:"bka069"`
  233. Aka018 string `json:"aka018"`
  234. Aka030 string `json:"aka030"`
  235. Aka065 string `json:"aka065"`
  236. Cka319 int `json:"cka319"`
  237. Akc268 int `json:"akc268"`
  238. } `json:"outputlist1"`
  239. Outputlist2 []struct {
  240. Aka111 string `json:"aka111"`
  241. Bka058 int `json:"bka058"`
  242. } `json:"outputlist2"`
  243. Outputlist3 []struct {
  244. Aaa036 string `json:"aaa036"`
  245. Aae019 int `json:"aae019"`
  246. } `json:"outputlist3"`
  247. } `json:"transBody"`
  248. Verifycode string `json:"verifyCode"`
  249. Extenddeviceid string `json:"extendDeviceId"`
  250. Transchannel string `json:"transChannel"`
  251. Extenduserid string `json:"extendUserId"`
  252. Extendserialnumber string `json:"extendSerialNumber"`
  253. Caz055 string `json:"caz055"`
  254. Aae501 string `json:"aae501"`
  255. }
  256. type SZHisApiController struct {
  257. controllers.BaseAuthAPIController
  258. }
  259. func SZHisManagerApiRegistRouters() {
  260. //挂号
  261. beego.Router("/sz/api/register/get", &SZHisApiController{}, "get:GetRegisterInfo")
  262. //上传明细,预结算
  263. //beego.Router("/sz/api/upload/get", &SZHisApiController{}, "get:GetUploadInfo")
  264. //结算
  265. beego.Router("/sz/api/settle/get", &SZHisApiController{}, "get:GetSettleInfo")
  266. //退费
  267. beego.Router("/sz/api/refund/get", &SZHisApiController{}, "get:Refund")
  268. beego.Router("/sz/api/monthrefund/get", &SZHisApiController{}, "get:MonthRefund")
  269. //查询交易
  270. beego.Router("/sz/api/settle/query", &SZHisApiController{}, "get:GetSettleAccounts")
  271. //撤销明细
  272. beego.Router("/sz/api/detail/cancel", &SZHisApiController{}, "get:CancelOrderDetail")
  273. //
  274. ////机构药品目录备案
  275. //beego.Router("/sz/api/drug/get", &SZHisApiController{}, "get:GetDrugList")
  276. ////协议机构诊疗项目
  277. //beego.Router("/sz/api/treatment/get", &SZHisApiController{}, "get:GetTreatmentProject")
  278. ////协议机构目录备案撤销
  279. //beego.Router("/sz/api/revocation/get", &SZHisApiController{}, "get:GetRevocation")
  280. //
  281. ////定点机构约定信息查询
  282. ////beego.Router("/sz/api/information/query/get",&SZHisApiController{},"get:GetInformationQuery")
  283. ////-医药师信息登记
  284. //beego.Router("/sz/api/doctor/get", &SZHisApiController{}, "get:GetDoctorList")
  285. ////医药师执业状态变更
  286. //beego.Router("/sz/api/medical/get", &SZHisApiController{}, "get:GetMedicalList")
  287. ////医药师信息更新
  288. //beego.Router("/sz/api/update/medical/get", &SZHisApiController{}, "get:GetUpdateMedicalList")
  289. ////协议机构材料目录备案
  290. //
  291. //beego.Router("/sz/api/goods/get", &SZHisApiController{}, "get:GetGoodsList")
  292. }
  293. func IntPtr(n int) uintptr {
  294. return uintptr(n)
  295. }
  296. func StrPtr(s string) uintptr {
  297. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  298. }
  299. type Custom struct {
  300. DetItemFeeSumamt string
  301. Cut string
  302. FeedetlSn string
  303. Price string
  304. MedListCodg string
  305. Type int64
  306. AdviceId int64
  307. ProjectId int64
  308. ItemId int64
  309. }
  310. //获取读卡信息 -- 门诊挂号
  311. func (c *SZHisApiController) GetRegisterInfo() {
  312. adminInfo := c.GetAdminUserInfo()
  313. admin_user_id, _ := c.GetInt64("admin_user_id")
  314. patient_id, _ := c.GetInt64("id")
  315. record_time := c.GetString("record_time")
  316. settlementValue, _ := c.GetInt64("settlement_value")
  317. medical_insurance_card := c.GetString("medical_insurance_card")
  318. name := c.GetString("name")
  319. id_card_type, _ := c.GetInt64("id_card_type")
  320. certificates, _ := c.GetInt64("certificates")
  321. medical_care, _ := c.GetInt64("medical_care")
  322. birthday := c.GetString("birthday")
  323. id_card := c.GetString("id_card")
  324. register_type, _ := c.GetInt64("register")
  325. doctor, _ := c.GetInt64("doctor")
  326. department, _ := c.GetInt64("department")
  327. gender, _ := c.GetInt64("sex")
  328. registration_fee, _ := c.GetFloat("registration_fee")
  329. medical_expenses, _ := c.GetFloat("medical_expenses")
  330. social_type, _ := c.GetInt64("social_type")
  331. is_yidi, _ := c.GetInt64("is_yidi")
  332. timeLayout := "2006-01-02"
  333. loc, _ := time.LoadLocation("Local")
  334. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  335. birthUnix := birthdays.Unix()
  336. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  337. if err != nil {
  338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  339. return
  340. }
  341. var patient service.Patients
  342. if patient_id == 0 {
  343. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  344. } else {
  345. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
  346. }
  347. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  348. if patient.ID == 0 {
  349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  350. return
  351. }
  352. if len(patient.IdCardNo) == 0 {
  353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  354. return
  355. }
  356. adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  357. his, _ := service.GetHisPatientInfo(adminInfo.CurrentOrgId, patient_id, theTime.Unix())
  358. var custom_code string
  359. var custom_project_name string
  360. var allPrice float64
  361. switch register_type {
  362. case 1:
  363. custom_code = "110100002"
  364. custom_project_name = "普通门诊"
  365. allPrice = 10
  366. break
  367. case 3:
  368. custom_code = "110200002-2"
  369. custom_project_name = "主任医师"
  370. allPrice = 10
  371. break
  372. case 2:
  373. custom_code = "110200002-3"
  374. custom_project_name = "副主任医师"
  375. allPrice = 10
  376. break
  377. case 4:
  378. custom_code = "0"
  379. custom_project_name = "免受诊金"
  380. allPrice = 0
  381. break
  382. case 5:
  383. custom_code = "110200002-1"
  384. custom_project_name = "专家"
  385. allPrice = 10
  386. break
  387. }
  388. if his.ID == 0 {
  389. var doctor_name string
  390. var doctor_code string
  391. if adminRole.ID == 0 {
  392. doctor_name = "黄亦轩"
  393. doctor_code = "1001"
  394. } else {
  395. doctor_name = adminRole.UserName
  396. doctor_code = strconv.FormatInt(admin_user_id, 10)
  397. }
  398. month := time.Unix(1557042972, 0).Format("1")
  399. year := time.Now().Format("2006")
  400. month = time.Now().Format("01")
  401. day := time.Now().Format("02")
  402. //流水号
  403. //
  404. number := miConfig.Code + year + month + day +
  405. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  406. mz_number := year + month + day + strconv.FormatInt(patient_id, 10) +
  407. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000))
  408. //1.判断读卡类型
  409. //2.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
  410. yiliao_number, id_card_number, verifyCode, version_code, _, ret4 := ReadBasCardGetNumber("MZ002" + "|" + number + "|" + miConfig.Code + "|")
  411. fmt.Println(yiliao_number)
  412. fmt.Println(id_card_number)
  413. fmt.Println(verifyCode)
  414. fmt.Println(version_code)
  415. fmt.Println(ret4)
  416. dept_code := "0305"
  417. is_yidi = 1
  418. tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  419. //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  420. if tempPatient.ID == patient_id {
  421. if ret4 == 0 { //本地卡流程
  422. if is_yidi == 1 {
  423. //本地就医流程
  424. //挂号
  425. resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, dept_code, yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
  426. var dat map[string]interface{}
  427. if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  428. fmt.Println(dat)
  429. } else {
  430. fmt.Println(err)
  431. }
  432. userJSONBytes, _ := json.Marshal(dat)
  433. var res ResultOne
  434. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  435. utils.ErrorLog("解析失败:%v", err)
  436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  437. return
  438. }
  439. if res.Transreturncode == "00000000" {
  440. his := models.VMHisPatient{
  441. Name: name,
  442. Gender: gender,
  443. Birthday: birthUnix,
  444. MedicalTreatmentType: medical_care,
  445. IdType: certificates,
  446. IdCardNo: id_card,
  447. BalanceAccountsType: settlementValue,
  448. SocialType: social_type,
  449. MedicalInsuranceNumber: medical_insurance_card,
  450. RegisterType: register_type,
  451. RegisterCost: registration_fee,
  452. TreatmentCost: medical_expenses,
  453. Status: 1,
  454. Ctime: time.Now().Unix(),
  455. Mtime: time.Now().Unix(),
  456. Iinfo: resp_result,
  457. PatientId: patient.ID,
  458. RecordDate: theTime.Unix(),
  459. UserOrgId: adminInfo.CurrentOrgId,
  460. AdminUserId: admin_user_id,
  461. IsReturn: 1,
  462. IdCardType: id_card_type,
  463. Doctor: doctor,
  464. Departments: department,
  465. YiliaoNumber: yiliao_number,
  466. MzNumber: number,
  467. Number: mz_number,
  468. }
  469. service.CreateHisPatientTwo(&his)
  470. c.ServeSuccessJSON(map[string]interface{}{
  471. "msg": "挂号成功",
  472. })
  473. } else {
  474. c.ServeSuccessJSON(map[string]interface{}{
  475. "failed_code": -10,
  476. "msg": res.Transreturnmessage,
  477. })
  478. return
  479. }
  480. } else {
  481. //异地就医流程
  482. //异地走鉴权流程
  483. //authResult := CardAuth(number)
  484. //fmt.Println(authResult)
  485. //tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  486. //if tempPatient.ID == patient_id {
  487. resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
  488. var dat map[string]interface{}
  489. if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  490. fmt.Println(dat)
  491. } else {
  492. fmt.Println(err)
  493. }
  494. userJSONBytes, _ := json.Marshal(dat)
  495. var res ResultOne
  496. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  497. utils.ErrorLog("解析失败:%v", err)
  498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  499. return
  500. }
  501. if res.Transreturncode == "00000000" {
  502. his := models.VMHisPatient{
  503. Name: name,
  504. Gender: gender,
  505. Birthday: birthUnix,
  506. MedicalTreatmentType: medical_care,
  507. IdType: certificates,
  508. IdCardNo: id_card,
  509. BalanceAccountsType: settlementValue,
  510. SocialType: social_type,
  511. MedicalInsuranceNumber: medical_insurance_card,
  512. RegisterType: register_type,
  513. RegisterCost: registration_fee,
  514. TreatmentCost: medical_expenses,
  515. Status: 1,
  516. Ctime: time.Now().Unix(),
  517. Mtime: time.Now().Unix(),
  518. Iinfo: resp_result,
  519. PatientId: patient.ID,
  520. RecordDate: theTime.Unix(),
  521. UserOrgId: adminInfo.CurrentOrgId,
  522. AdminUserId: admin_user_id,
  523. IsReturn: 1,
  524. IdCardType: id_card_type,
  525. Doctor: doctor,
  526. Departments: department,
  527. YiliaoNumber: yiliao_number,
  528. MzNumber: number,
  529. Number: mz_number,
  530. }
  531. service.CreateHisPatientTwo(&his)
  532. c.ServeSuccessJSON(map[string]interface{}{
  533. "msg": "挂号成功",
  534. })
  535. } else {
  536. c.ServeSuccessJSON(map[string]interface{}{
  537. "failed_code": -10,
  538. "msg": res.Transreturnmessage,
  539. })
  540. return
  541. }
  542. }
  543. } else { //异地卡流程
  544. //readCardBasResult := ReadCardBasHSM(number)
  545. //fmt.Println(readCardBasResult)
  546. //是否异地就医,是的话走鉴权流程,不是的话走门诊挂号
  547. if is_yidi == 1 { //1本地就医
  548. resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
  549. var dat map[string]interface{}
  550. if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  551. fmt.Println(dat)
  552. } else {
  553. fmt.Println(err)
  554. }
  555. userJSONBytes, _ := json.Marshal(dat)
  556. var res ResultOne
  557. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  558. utils.ErrorLog("解析失败:%v", err)
  559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  560. return
  561. }
  562. if res.Transreturncode == "00000000" {
  563. his := models.VMHisPatient{
  564. Name: name,
  565. Gender: gender,
  566. Birthday: birthUnix,
  567. MedicalTreatmentType: medical_care,
  568. IdType: certificates,
  569. IdCardNo: id_card,
  570. BalanceAccountsType: settlementValue,
  571. SocialType: social_type,
  572. MedicalInsuranceNumber: medical_insurance_card,
  573. RegisterType: register_type,
  574. RegisterCost: registration_fee,
  575. TreatmentCost: medical_expenses,
  576. Status: 1,
  577. Ctime: time.Now().Unix(),
  578. Mtime: time.Now().Unix(),
  579. Iinfo: resp_result,
  580. PatientId: patient.ID,
  581. RecordDate: theTime.Unix(),
  582. UserOrgId: adminInfo.CurrentOrgId,
  583. AdminUserId: admin_user_id,
  584. IsReturn: 1,
  585. IdCardType: id_card_type,
  586. Doctor: doctor,
  587. Departments: department,
  588. YiliaoNumber: yiliao_number,
  589. MzNumber: number,
  590. Number: mz_number,
  591. }
  592. service.CreateHisPatientTwo(&his)
  593. c.ServeSuccessJSON(map[string]interface{}{
  594. "msg": "挂号成功",
  595. })
  596. } else {
  597. c.ServeSuccessJSON(map[string]interface{}{
  598. "failed_code": -10,
  599. "msg": res.Transreturnmessage,
  600. })
  601. return
  602. }
  603. } else { //异地就医需要走鉴权流程
  604. //authResult := CardAuth(number)
  605. //fmt.Println(authResult)
  606. resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
  607. var dat map[string]interface{}
  608. if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  609. fmt.Println(dat)
  610. } else {
  611. fmt.Println(err)
  612. }
  613. userJSONBytes, _ := json.Marshal(dat)
  614. var res ResultOne
  615. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  616. utils.ErrorLog("解析失败:%v", err)
  617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  618. return
  619. }
  620. if res.Transreturncode == "00000000" {
  621. his := models.VMHisPatient{
  622. Name: name,
  623. Gender: gender,
  624. Birthday: birthUnix,
  625. MedicalTreatmentType: medical_care,
  626. IdType: certificates,
  627. IdCardNo: id_card,
  628. BalanceAccountsType: settlementValue,
  629. SocialType: social_type,
  630. MedicalInsuranceNumber: medical_insurance_card,
  631. RegisterType: register_type,
  632. RegisterCost: registration_fee,
  633. TreatmentCost: medical_expenses,
  634. Status: 1,
  635. Ctime: time.Now().Unix(),
  636. Mtime: time.Now().Unix(),
  637. Iinfo: resp_result,
  638. PatientId: patient.ID,
  639. RecordDate: theTime.Unix(),
  640. UserOrgId: adminInfo.CurrentOrgId,
  641. AdminUserId: admin_user_id,
  642. IsReturn: 1,
  643. IdCardType: id_card_type,
  644. Doctor: doctor,
  645. Departments: department,
  646. YiliaoNumber: yiliao_number,
  647. MzNumber: number,
  648. Number: mz_number,
  649. }
  650. service.CreateHisPatientTwo(&his)
  651. c.ServeSuccessJSON(map[string]interface{}{
  652. "msg": "挂号成功",
  653. })
  654. } else {
  655. c.ServeSuccessJSON(map[string]interface{}{
  656. "failed_code": -10,
  657. "msg": res.Transreturnmessage,
  658. })
  659. return
  660. }
  661. }
  662. }
  663. } else {
  664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  665. return
  666. }
  667. } else {
  668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  669. return
  670. }
  671. }
  672. //上传明细----结算----确认订单
  673. func (c *SZHisApiController) GetSettleInfo() {
  674. pay_way, _ := c.GetInt64("pay_way")
  675. pay_price, _ := c.GetFloat("pay_price")
  676. pay_card_no := c.GetString("pay_card_no")
  677. discount_price, _ := c.GetFloat("discount_price")
  678. preferential_price, _ := c.GetFloat("preferential_price")
  679. reality_price, _ := c.GetFloat("reality_price")
  680. found_price, _ := c.GetFloat("found_price")
  681. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  682. private_price, _ := c.GetFloat("private_price")
  683. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  684. patient_id, _ := c.GetInt64("id")
  685. record_time := c.GetString("record_time")
  686. admin_user_id, _ := c.GetInt64("admin_user_id")
  687. timestamp := time.Now().Unix()
  688. tempTime := time.Unix(timestamp, 0)
  689. timeFormat := tempTime.Format("20060102150405")
  690. chrgBchno := rand.Intn(10000) + 1000
  691. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(1, 10)
  692. adminUser := c.GetAdminUserInfo()
  693. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  694. month := time.Unix(1557042972, 0).Format("1")
  695. year := time.Now().Format("2006")
  696. month = time.Now().Format("01")
  697. day := time.Now().Format("02")
  698. timeLayout := "2006-01-02"
  699. loc, _ := time.LoadLocation("Local")
  700. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  701. fmt.Println(err)
  702. if err != nil {
  703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  704. return
  705. }
  706. recordDateTime := theTime.Unix()
  707. var prescriptions []*models.HisPrescription
  708. var start_time int64
  709. var end_time int64
  710. if settle_accounts_type == 1 { //日结
  711. prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  712. } else { //月结
  713. start_time_str := c.GetString("start_time")
  714. end_time_str := c.GetString("end_time")
  715. timeLayout := "2006-01-02"
  716. loc, _ := time.LoadLocation("Local")
  717. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  718. if err != nil {
  719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  720. return
  721. }
  722. recordStartTime := theStartTime.Unix()
  723. start_time = recordStartTime
  724. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  725. if err != nil {
  726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  727. return
  728. }
  729. recordEndTime := theEndTime.Unix()
  730. end_time = recordEndTime
  731. prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  732. }
  733. var ids []int64
  734. for _, item := range prescriptions {
  735. ids = append(ids, item.ID)
  736. }
  737. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  738. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  739. adminRole, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  740. his, err := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  741. mz_number := his.Number
  742. number := miConfig.Code + year + month + day +
  743. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  744. var doctor_name string
  745. var doctor_code string
  746. var drug_doctor_code string
  747. drug_doctor_code = adminRole_two.DoctorCode
  748. drug_doctor_name := adminRole_two.UserName
  749. if adminRole.ID == 0 {
  750. doctor_name = "黄亦轩"
  751. doctor_code = "1"
  752. } else {
  753. doctor_name = adminRole.UserName
  754. doctor_code = strconv.FormatInt(admin_user_id, 10)
  755. }
  756. verifyCode, version_code := ReadCardGetCode("FY001" + "|" + number + "|" + miConfig.Code)
  757. //verifyCode := "000000|bf885fa312a7f92861d6b61542a637fa"
  758. //version_code := "V0.3"
  759. var customs []*models.CustomDetail
  760. for _, item := range prescriptions {
  761. if item.Type == 1 { //药品
  762. for _, subItem := range item.HisDoctorAdviceInfo {
  763. fmt.Println(subItem.BaseDrugLib.MedicalInsuranceNumber)
  764. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  765. _, dose_code := service.GetDoseCode(subItem.BaseDrugLib.DrugDosageForm, adminUser.CurrentOrgId)
  766. detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber), 64)
  767. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  768. temp := strings.Split(subItem.FeedetlSn, "-")
  769. newFl := fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) + "-" + temp[1] + "-" + temp[2]
  770. cus := &models.CustomDetail{
  771. PrescriptionNumber: chrg_bchno,
  772. OrderType: "1",
  773. ChargeSerialNumber: newFl,
  774. Code: subItem.BaseDrugLib.MedicalInsuranceNumber,
  775. CodeName: subItem.BaseDrugLib.DrugName,
  776. Flag: "1",
  777. Price: price,
  778. Count: subItem.PrescribingNumber,
  779. ChargeOrderDate: year + month + day,
  780. DoctorCode: doctor_code,
  781. Total: detItemFeeSumamt,
  782. DoseCode: dose_code,
  783. Spec: subItem.BaseDrugLib.DrugSpec,
  784. }
  785. customs = append(customs, cus)
  786. }
  787. }
  788. }
  789. if item.Type == 2 { //项目
  790. for _, subItem := range item.HisPrescriptionProject {
  791. if len(subItem.HisProject.MedicalCode) > 0 {
  792. detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)), 64)
  793. count, _ := strconv.ParseFloat(fmt.Sprintf("%f", subItem.Count), 64)
  794. temp := strings.Split(subItem.FeedetlSn, "-")
  795. newFl := fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) + "-" + temp[1] + "-" + temp[2]
  796. cus := &models.CustomDetail{
  797. PrescriptionNumber: chrg_bchno,
  798. OrderType: "1",
  799. ChargeSerialNumber: newFl,
  800. Code: subItem.HisProject.MedicalCode,
  801. CodeName: subItem.HisProject.ProjectName,
  802. Flag: "1",
  803. Price: subItem.Price,
  804. Count: count,
  805. ChargeOrderDate: year + month + day,
  806. DoctorCode: doctor_code,
  807. Total: detItemFeeSumamt,
  808. DoseCode: "",
  809. Spec: "",
  810. }
  811. customs = append(customs, cus)
  812. }
  813. }
  814. }
  815. //
  816. //for _, subItem := range item.HisAdditionalCharge {
  817. // if len(subItem.XtHisAddtionConfig.Code) > 0 {
  818. // detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)), 64)
  819. //
  820. // count, _ := strconv.ParseFloat(fmt.Sprintf("%f", subItem.Count), 64)
  821. // cus := &models.CustomDetail{
  822. // PrescriptionNumber: chrg_bchno,
  823. // OrderType: "1",
  824. // ChargeSerialNumber: subItem.FeedetlSn,
  825. // Code: subItem.XtHisAddtionConfig.Code,
  826. // CodeName: subItem.XtHisAddtionConfig.Name,
  827. // Flag: "1",
  828. // Price: subItem.Price,
  829. // Count: count,
  830. // ChargeOrderDate: year + month + day,
  831. // DoctorCode: doctor_code,
  832. // Total: detItemFeeSumamt,
  833. // DoseCode: "",
  834. // Spec: subItem.XtHisAddtionConfig.,
  835. // }
  836. // customs = append(customs, cus)
  837. // }
  838. //}
  839. }
  840. var pagesize int = 50
  841. var start int = 1
  842. var stop int
  843. var pagecount int
  844. var curpage int
  845. var isSuccess bool = true
  846. //总页数,向上取整,注意除之前要先转换类型为float64
  847. pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  848. var ress []*Result
  849. for curpage = 1; curpage <= pagecount; curpage++ {
  850. if curpage == 1 {
  851. start = 1
  852. } else {
  853. start = (curpage-1)*pagesize + 1
  854. }
  855. stop = curpage * pagesize
  856. if stop > len(customs) {
  857. stop = len(customs)
  858. }
  859. result := service.SzybFY001(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop], verifyCode, number, mz_number, version_code, drug_doctor_code)
  860. fmt.Println(result)
  861. var dat map[string]interface{}
  862. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  863. fmt.Println(dat)
  864. } else {
  865. fmt.Println(err)
  866. }
  867. userJSONBytes, _ := json.Marshal(dat)
  868. var res Result
  869. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  870. utils.ErrorLog("解析失败:%v", err)
  871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  872. return
  873. }
  874. if res.Transreturncode == "00000000" {
  875. ress = append(ress, &res)
  876. } else {
  877. isSuccess = false
  878. errlog := &models.HisOrderError{
  879. UserOrgId: adminUser.CurrentOrgId,
  880. Ctime: time.Now().Unix(),
  881. Mtime: time.Now().Unix(),
  882. Number: chrg_bchno,
  883. ErrMsg: res.Transreturnmessage,
  884. Status: 1,
  885. PatientId: patient_id,
  886. RecordTime: recordDateTime,
  887. Stage: 4,
  888. }
  889. service.CreateErrMsgLog(errlog)
  890. c.ServeSuccessJSON(map[string]interface{}{
  891. "failed_code": -10,
  892. "msg": res.Transreturnmessage,
  893. })
  894. return
  895. }
  896. //设置变量,根据变量的值来判断上传是否成功
  897. }
  898. if isSuccess == true {
  899. order := &models.HisOrder{
  900. UserOrgId: adminUser.CurrentOrgId,
  901. HisPatientId: 0,
  902. PatientId: patient_id,
  903. SettleAccountsDate: recordDateTime,
  904. Ctime: time.Now().Unix(),
  905. Mtime: time.Now().Unix(),
  906. Status: 1,
  907. Number: chrg_bchno,
  908. Infcode: 0,
  909. WarnMsg: "",
  910. Cainfo: "",
  911. ErrMsg: "",
  912. RespondTime: "",
  913. InfRefmsgid: "",
  914. OrderStatus: 1,
  915. IsMedicineInsurance: 1,
  916. SettleType: settle_accounts_type,
  917. SettleStartTime: start_time,
  918. SettleEndTime: end_time,
  919. Creator: admin_user_id,
  920. Modify: admin_user_id,
  921. OrgSetlNumber: number,
  922. }
  923. data, _ := json.Marshal(ress)
  924. order.DetailLog = string(data)
  925. err = service.CreateOrder(order)
  926. if err != nil {
  927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  928. return
  929. }
  930. for _, subItem := range ress {
  931. for _, item := range subItem.Transbody.Outputlist {
  932. temp := strings.Split(item.Bkf500, "-")
  933. var advice_id int64 = 0
  934. var project_id int64 = 0
  935. var types int64 = 0
  936. id, _ := strconv.ParseInt(temp[2], 10, 64)
  937. types, _ = strconv.ParseInt(temp[1], 10, 64)
  938. if temp[1] == "1" {
  939. advice_id = id
  940. project_id = 0
  941. } else if temp[1] == "2" {
  942. advice_id = 0
  943. project_id = id
  944. }
  945. info := &models.HisOrderInfo{
  946. OrderNumber: order.Number,
  947. FeedetlSn: item.Bkf500,
  948. UploadDate: time.Now().Unix(),
  949. AdviceId: advice_id,
  950. DetItemFeeSumamt: item.Akc264,
  951. Cnt: item.Akc226,
  952. Pric: float64(item.Akc225),
  953. PatientId: patient_id,
  954. Status: 1,
  955. ChrgitmLv: item.Aka065,
  956. Mtime: time.Now().Unix(),
  957. Ctime: time.Now().Unix(),
  958. UserOrgId: adminUser.CurrentOrgId,
  959. OrderId: order.ID,
  960. ProjectId: project_id,
  961. Type: types,
  962. OverPricPsnPay: item.Akc268,
  963. AllowReimburse: item.Cka319,
  964. }
  965. service.CreateOrderInfo(info)
  966. }
  967. }
  968. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  969. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patient_id, chrg_bchno, recordDateTime)
  970. var total float64
  971. for _, item := range prescriptions {
  972. if item.Type == 1 { //药品
  973. for _, subItem := range item.HisDoctorAdviceInfo {
  974. total = total + (subItem.Price * subItem.PrescribingNumber)
  975. }
  976. }
  977. if item.Type == 2 { //项目
  978. for _, subItem := range item.HisPrescriptionProject {
  979. total = total + (subItem.Price * float64(subItem.Count))
  980. }
  981. }
  982. }
  983. for _, item := range prescriptions {
  984. for _, subItem := range item.HisAdditionalCharge {
  985. total = total + (subItem.Price * float64(subItem.Count))
  986. }
  987. }
  988. yiliao_number, id_card_number, verifyCode, version_code, _, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code + "|")
  989. if ret4 == 0 {
  990. //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  991. tempPatient, _ := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
  992. if tempPatient.ID == patient_id {
  993. result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor_code, drug_doctor_name)
  994. var dat map[string]interface{}
  995. if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
  996. fmt.Println(dat)
  997. } else {
  998. fmt.Println(err)
  999. }
  1000. userJSONBytes, _ := json.Marshal(dat)
  1001. var res ResultTwo
  1002. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1003. utils.ErrorLog("解析失败:%v", err)
  1004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1005. return
  1006. }
  1007. if res.Transreturncode == "00000000" {
  1008. order.OrderStatus = 2
  1009. order.PayWay = pay_way
  1010. order.PayPrice = pay_price
  1011. order.PayCardNo = pay_card_no
  1012. order.DiscountPrice = discount_price
  1013. order.PreferentialPrice = preferential_price
  1014. order.RealityPrice = reality_price
  1015. order.FoundPrice = found_price
  1016. order.MedicalInsurancePrice = medical_insurance_price
  1017. order.PrivatePrice = private_price
  1018. order.Modify = admin_user_id
  1019. order.MedfeeSumamt = res.Transbody.Akc264
  1020. order.SetlId = res.Transbody.Ckc618
  1021. order.FundPaySumamt = res.Transbody.Akb068
  1022. order.AcctPay = res.Transbody.Akb066
  1023. order.PsnCashPay = res.Transbody.Akb067
  1024. order.PsnPartAmt = res.Transbody.Akb067
  1025. order.AccountPrice = res.Transbody.Aae240
  1026. order.MzNumber = mz_number
  1027. order.YiliaoNumber = yiliao_number
  1028. setlDetailOne, _ := json.Marshal(res.Transbody.Outputlist1)
  1029. detailStrOne := string(setlDetailOne)
  1030. order.SzChargeInfo = detailStrOne
  1031. setlDetailTwo, _ := json.Marshal(res.Transbody.Outputlist2)
  1032. detailStrTwo := string(setlDetailTwo)
  1033. order.SzProjectInfo = detailStrTwo
  1034. setlDetailThree, _ := json.Marshal(res.Transbody.Outputlist3)
  1035. detailStrThree := string(setlDetailThree)
  1036. order.SzMedicineInsuranceInfo = detailStrThree
  1037. order.Cainfo = result_three
  1038. err = service.UpdataOrderStatusTwo(order.Number, adminUser.CurrentOrgId)
  1039. err = service.UpDateOrderTwo(order)
  1040. c.ServeSuccessJSON(map[string]interface{}{
  1041. "msg": "结算成功",
  1042. })
  1043. } else {
  1044. //结算报错
  1045. errlog := &models.HisOrderError{
  1046. UserOrgId: adminUser.CurrentOrgId,
  1047. Ctime: time.Now().Unix(),
  1048. Mtime: time.Now().Unix(),
  1049. Number: chrg_bchno,
  1050. ErrMsg: res.Transreturnmessage,
  1051. Status: 1,
  1052. PatientId: patient_id,
  1053. RecordTime: recordDateTime,
  1054. Stage: 6,
  1055. }
  1056. service.CreateErrMsgLog(errlog)
  1057. c.ServeSuccessJSON(map[string]interface{}{
  1058. "failed_code": -10,
  1059. "msg": res.Transreturnmessage,
  1060. })
  1061. }
  1062. } else {
  1063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1064. return
  1065. }
  1066. } else {
  1067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1068. return
  1069. }
  1070. } else {
  1071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
  1072. return
  1073. }
  1074. }
  1075. //结算
  1076. //func (c *SZHisApiController) GetSettleInfo() {
  1077. // patient_id, _ := c.GetInt64("id")
  1078. // order_id, _ := c.GetInt64("order_id")
  1079. // record_time := c.GetString("record_time")
  1080. // pay_way, _ := c.GetInt64("pay_way")
  1081. // pay_price, _ := c.GetFloat("pay_price")
  1082. // pay_card_no := c.GetString("pay_card_no")
  1083. // discount_price, _ := c.GetFloat("discount_price")
  1084. // preferential_price, _ := c.GetFloat("preferential_price")
  1085. // reality_price, _ := c.GetFloat("reality_price")
  1086. // found_price, _ := c.GetFloat("found_price")
  1087. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  1088. // private_price, _ := c.GetFloat("private_price")
  1089. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1090. // admin_user_id, _ := c.GetInt64("admin_user_id")
  1091. //
  1092. // timeLayout := "2006-01-02"
  1093. // loc, _ := time.LoadLocation("Local")
  1094. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1095. // if err != nil {
  1096. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1097. // return
  1098. // }
  1099. // recordDateTime := theTime.Unix()
  1100. // adminUser := c.GetAdminUserInfo()
  1101. //
  1102. // var prescriptions []*models.HisPrescription
  1103. //
  1104. // data := make(map[string]interface{})
  1105. // if settle_accounts_type == 1 { //日结
  1106. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1107. // data["pre"] = prescriptions
  1108. //
  1109. // } else { //月结
  1110. // start_time_str := c.GetString("start_time")
  1111. // end_time_str := c.GetString("end_time")
  1112. // timeLayout := "2006-01-02"
  1113. // loc, _ := time.LoadLocation("Local")
  1114. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  1115. // if err != nil {
  1116. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1117. // return
  1118. // }
  1119. // recordStartTime := theStartTime.Unix()
  1120. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  1121. // if err != nil {
  1122. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1123. // return
  1124. // }
  1125. // recordEndTime := theEndTime.Unix()
  1126. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  1127. // data["pre"] = prescriptions
  1128. //
  1129. // }
  1130. //
  1131. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1132. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1133. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1134. // strconv.FormatInt(his.PatientId, 10)
  1135. //
  1136. // order_src, _ := service.GetHisOrderByID(order_id)
  1137. //
  1138. // if order_src.ID == 0 {
  1139. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1140. // return
  1141. // }
  1142. //
  1143. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1144. // if config.IsOpen == 1 { //对接了医保,走医保流程
  1145. // if order_src.OrderStatus != 2 {
  1146. // var total float64
  1147. // for _, item := range prescriptions {
  1148. // if item.Type == 1 { //药品
  1149. // for _, subItem := range item.HisDoctorAdviceInfo {
  1150. // total = total + (subItem.Price * subItem.PrescribingNumber)
  1151. // }
  1152. // }
  1153. // if item.Type == 2 { //项目
  1154. // for _, subItem := range item.HisPrescriptionProject {
  1155. // total = total + (subItem.Price * float64(subItem.Count))
  1156. // }
  1157. // }
  1158. // }
  1159. //
  1160. // for _, item := range prescriptions {
  1161. // for _, subItem := range item.HisAdditionalCharge {
  1162. // total = total + (subItem.Price * float64(subItem.Count))
  1163. // }
  1164. // }
  1165. //
  1166. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1167. //
  1168. // adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1169. //
  1170. // var drug_doctor string
  1171. // drug_doctor = adminRole_two.DoctorCode
  1172. // drug_doctor_name := adminRole_two.UserName
  1173. // //结算流程
  1174. // var doctor_name string
  1175. // var doctor_code string
  1176. // if roles.ID == 0 {
  1177. // doctor_name = "黄亦轩"
  1178. // doctor_code = "1010"
  1179. // } else {
  1180. // doctor_name = roles.UserName
  1181. // doctor_code = strconv.FormatInt(admin_user_id, 10)
  1182. // }
  1183. // number := order_src.OrgSetlNumber
  1184. // mz_number := his.Number
  1185. // verifyCode, version_code := ReadCardGetCode("FY005" + "|" + number + "|" + miConfig.Code)
  1186. //
  1187. // //verifyCode := "000000|707c35a62c2f0609d7b0a811649f3913"
  1188. // //version_code := "V0.3"
  1189. // yiliao_number, id_card_number, verifyCode, version_code, err, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code)
  1190. // yiliao_number := his.YiliaoNumber
  1191. // result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor, drug_doctor_name)
  1192. // var dat map[string]interface{}
  1193. // if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
  1194. // fmt.Println(dat)
  1195. // } else {
  1196. // fmt.Println(err)
  1197. // }
  1198. // userJSONBytes, _ := json.Marshal(dat)
  1199. // var res ResultTwo
  1200. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1201. // utils.ErrorLog("解析失败:%v", err)
  1202. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1203. // return
  1204. // }
  1205. //
  1206. // if res.Transreturncode == "00000000" {
  1207. // order_src.OrderStatus = 2
  1208. // order_src.PayWay = pay_way
  1209. // order_src.PayPrice = pay_price
  1210. // order_src.PayCardNo = pay_card_no
  1211. // order_src.DiscountPrice = discount_price
  1212. // order_src.PreferentialPrice = preferential_price
  1213. // order_src.RealityPrice = reality_price
  1214. // order_src.FoundPrice = found_price
  1215. // order_src.MedicalInsurancePrice = medical_insurance_price
  1216. // order_src.PrivatePrice = private_price
  1217. // order_src.Creator = order_src.Creator
  1218. // order_src.Modify = roles.ID
  1219. // order_src.MedfeeSumamt = res.Transbody.Akc264
  1220. // order_src.SetlId = res.Transbody.Ckc618
  1221. // order_src.FundPaySumamt = res.Transbody.Akb068
  1222. // order_src.AcctPay = res.Transbody.Akb066
  1223. // order_src.PsnCashPay = res.Transbody.Akb067
  1224. // order_src.PsnPartAmt = res.Transbody.Akb067
  1225. // order_src.AccountPrice = res.Transbody.Aae240
  1226. // order_src.MzNumber = mz_number
  1227. // order_src.YiliaoNumber = yiliao_number
  1228. // setlDetailOne, _ := json.Marshal(res.Transbody.Outputlist1)
  1229. // detailStrOne := string(setlDetailOne)
  1230. // order_src.SzChargeInfo = detailStrOne
  1231. // setlDetailTwo, _ := json.Marshal(res.Transbody.Outputlist2)
  1232. // detailStrTwo := string(setlDetailTwo)
  1233. // order_src.SzProjectInfo = detailStrTwo
  1234. // setlDetailThree, _ := json.Marshal(res.Transbody.Outputlist3)
  1235. // detailStrThree := string(setlDetailThree)
  1236. // order_src.SzMedicineInsuranceInfo = detailStrThree
  1237. // order_src.Cainfo = result_three
  1238. //
  1239. // err = service.UpdataOrderStatusTwo(order_src.Number, adminUser.CurrentOrgId)
  1240. // err = service.UpDateOrder(order_src)
  1241. //
  1242. // c.ServeSuccessJSON(map[string]interface{}{
  1243. // "msg": "结算成功",
  1244. // })
  1245. // } else {
  1246. // //version_code := "0.03"
  1247. // c.ServeSuccessJSON(map[string]interface{}{
  1248. // "failed_code": -10,
  1249. // "msg": res.Transreturnmessage,
  1250. // })
  1251. //
  1252. // }
  1253. // } else {
  1254. //
  1255. // //错误提示
  1256. //
  1257. // }
  1258. // } else {
  1259. // //错误提示
  1260. //
  1261. // }
  1262. //}
  1263. //当月退费
  1264. func (c *SZHisApiController) Refund() {
  1265. order_id, _ := c.GetInt64("order_id")
  1266. record_time := c.GetString("record_time")
  1267. patient_id, _ := c.GetInt64("patient_id")
  1268. admin_user_id, _ := c.GetInt64("admin_user_id")
  1269. timeLayout := "2006-01-02"
  1270. loc, _ := time.LoadLocation("Local")
  1271. adminUser := c.GetAdminUserInfo()
  1272. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1273. fmt.Println(err)
  1274. if err != nil {
  1275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1276. return
  1277. }
  1278. recordDateTime := theTime.Unix()
  1279. fmt.Println(recordDateTime)
  1280. var order models.HisOrder
  1281. order, _ = service.GetHisOrderByID(order_id)
  1282. if order.ID == 0 {
  1283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1284. return
  1285. }
  1286. his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, theTime.Unix())
  1287. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1288. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1289. //结算流程
  1290. var doctor_name string
  1291. var doctor_code string
  1292. if roles.ID == 0 {
  1293. doctor_name = "黄亦轩"
  1294. doctor_code = "1001"
  1295. } else {
  1296. doctor_name = roles.UserName
  1297. doctor_code = strconv.FormatInt(admin_user_id, 10)
  1298. }
  1299. month := time.Unix(1557042972, 0).Format("1")
  1300. year := time.Now().Format("2006")
  1301. month = time.Now().Format("01")
  1302. day := time.Now().Format("02")
  1303. //number := miConfig.Code + year + month + day + "1367866"
  1304. number := miConfig.Code + year + month + day +
  1305. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  1306. //number := miConfig.Code + year + month + day + "1590003"
  1307. //流水号
  1308. //number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  1309. verifyCode, version_code := ReadCardGetCode("JY002" + "|" + number + "|" + miConfig.Code)
  1310. //version_code := "V0.3"
  1311. //
  1312. //verifyCode := "000000|9972fca7ba9471c7dbe08324b2e31f70"
  1313. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1314. if config.IsOpen == 1 { //对接了医保,走医保流程
  1315. result := service.SzybJY002(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, number, version_code)
  1316. fmt.Println(result)
  1317. var dat map[string]interface{}
  1318. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1319. fmt.Println(dat)
  1320. } else {
  1321. fmt.Println(err)
  1322. }
  1323. userJSONBytes, _ := json.Marshal(dat)
  1324. var res ResultThree
  1325. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1326. utils.ErrorLog("解析失败:%v", err)
  1327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1328. return
  1329. }
  1330. if res.Transreturncode == "00000000" {
  1331. service.UpdataOrderlog(order_id, adminUser.CurrentOrgId, result)
  1332. service.UpdataOrderStatusSZ(order_id, order.Number, adminUser.CurrentOrgId, his.MzNumber, his.Number)
  1333. c.ServeSuccessJSON(map[string]interface{}{
  1334. "msg": "退费成功",
  1335. })
  1336. } else {
  1337. c.ServeSuccessJSON(map[string]interface{}{
  1338. "failed_code": -10,
  1339. "msg": res.Transreturnmessage,
  1340. })
  1341. }
  1342. }
  1343. }
  1344. //跨月退费
  1345. func (c *SZHisApiController) MonthRefund() {
  1346. order_id, _ := c.GetInt64("order_id")
  1347. record_time := c.GetString("record_time")
  1348. patient_id, _ := c.GetInt64("patient_id")
  1349. admin_user_id, _ := c.GetInt64("admin_user_id")
  1350. timeLayout := "2006-01-02"
  1351. loc, _ := time.LoadLocation("Local")
  1352. adminUser := c.GetAdminUserInfo()
  1353. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1354. fmt.Println(err)
  1355. if err != nil {
  1356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1357. return
  1358. }
  1359. recordDateTime := theTime.Unix()
  1360. var order models.HisOrder
  1361. order, _ = service.GetHisOrderByID(order_id)
  1362. if order.ID == 0 {
  1363. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  1364. }
  1365. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1366. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1367. //结算流程
  1368. var doctor_name string
  1369. var doctor_code string
  1370. if roles.ID == 0 {
  1371. doctor_name = "黄亦轩"
  1372. doctor_code = "1001"
  1373. } else {
  1374. doctor_name = roles.UserName
  1375. doctor_code = strconv.FormatInt(admin_user_id, 10)
  1376. }
  1377. month := time.Unix(1557042972, 0).Format("1")
  1378. year := time.Now().Format("2006")
  1379. month = time.Now().Format("01")
  1380. day := time.Now().Format("02")
  1381. //流水号
  1382. number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  1383. //verifyCode,version_code := ReadCardGetCode("JY002" + "|" + number_two + "|" + miConfig.Code)
  1384. version_code := "0.03"
  1385. fmt.Println(number_two)
  1386. verifyCode := "000000|0872038667cc34efdc35ce4668589a5f"
  1387. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1388. if config.IsOpen == 1 { //对接了医保,走医保流程
  1389. result := service.SzybJY003(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, version_code)
  1390. fmt.Println(result)
  1391. var dat map[string]interface{}
  1392. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1393. fmt.Println(dat)
  1394. } else {
  1395. fmt.Println(err)
  1396. }
  1397. userJSONBytes, _ := json.Marshal(dat)
  1398. var res ResultThree
  1399. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1400. utils.ErrorLog("解析失败:%v", err)
  1401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1402. return
  1403. }
  1404. if res.Transreturncode == "00000000" {
  1405. c.ServeSuccessJSON(map[string]interface{}{
  1406. "msg": "退费成功",
  1407. })
  1408. } else {
  1409. }
  1410. }
  1411. }
  1412. //查询
  1413. func (c *SZHisApiController) GetSettleAccounts() {
  1414. order_id, _ := c.GetInt64("order_id")
  1415. record_time := c.GetString("record_time")
  1416. patient_id, _ := c.GetInt64("patient_id")
  1417. admin_user_id, _ := c.GetInt64("admin_user_id")
  1418. timeLayout := "2006-01-02"
  1419. loc, _ := time.LoadLocation("Local")
  1420. adminUser := c.GetAdminUserInfo()
  1421. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1422. fmt.Println(err)
  1423. if err != nil {
  1424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1425. return
  1426. }
  1427. recordDateTime := theTime.Unix()
  1428. var order models.HisOrder
  1429. order, _ = service.GetHisOrderByID(order_id)
  1430. if order.ID == 0 {
  1431. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  1432. }
  1433. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1434. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1435. //结算流程
  1436. var doctor_name string
  1437. var doctor_code string
  1438. if roles.ID == 0 {
  1439. doctor_name = "黄亦轩"
  1440. doctor_code = "1001"
  1441. } else {
  1442. doctor_name = roles.UserName
  1443. doctor_code = strconv.FormatInt(admin_user_id, 10)
  1444. }
  1445. //month := time.Unix(1557042972, 0).Format("1")
  1446. //year := time.Now().Format("2006")
  1447. //month = time.Now().Format("01")
  1448. //day := time.Now().Format("02")
  1449. //流水号
  1450. //number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  1451. //fmt.Println(number_two)
  1452. verifyCode, version_code := ReadCardGetCode("JY001" + "|" + order.OrgSetlNumber + "|" + miConfig.Code)
  1453. //version_code := "V0.3"
  1454. //verifyCode := "000000|2c9854287e7c3cbc34439ab8e5157816"
  1455. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1456. if config.IsOpen == 1 { //对接了医保,走医保流程
  1457. result := service.SzybJY001(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, version_code)
  1458. fmt.Println(result)
  1459. var dat map[string]interface{}
  1460. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1461. fmt.Println(dat)
  1462. } else {
  1463. fmt.Println(err)
  1464. }
  1465. userJSONBytes, _ := json.Marshal(dat)
  1466. var res ResultFour
  1467. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1468. utils.ErrorLog("解析失败:%v", err)
  1469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1470. return
  1471. }
  1472. if res.Transreturncode == "00000000" {
  1473. c.ServeSuccessJSON(map[string]interface{}{
  1474. "result": res,
  1475. })
  1476. } else {
  1477. c.ServeSuccessJSON(map[string]interface{}{
  1478. "failed_code": -10,
  1479. "msg": res.Transreturnmessage,
  1480. })
  1481. }
  1482. }
  1483. }
  1484. //费用录入取消
  1485. func (c *SZHisApiController) CancelOrderDetail() {
  1486. order_id, _ := c.GetInt64("order_id")
  1487. record_time := c.GetString("record_time")
  1488. patient_id, _ := c.GetInt64("patient_id")
  1489. admin_user_id, _ := c.GetInt64("admin_user_id")
  1490. timeLayout := "2006-01-02"
  1491. loc, _ := time.LoadLocation("Local")
  1492. adminUser := c.GetAdminUserInfo()
  1493. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1494. fmt.Println(err)
  1495. if err != nil {
  1496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1497. return
  1498. }
  1499. recordDateTime := theTime.Unix()
  1500. var order models.HisOrder
  1501. order, _ = service.GetHisOrderByID(order_id)
  1502. if order.ID == 0 {
  1503. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  1504. }
  1505. order_infos, _ := service.GetHisOrderInfoByNumber(order.Number)
  1506. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1507. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1508. //结算流程
  1509. var doctor_name string
  1510. var doctor_code string
  1511. if roles.ID == 0 {
  1512. doctor_name = "黄亦轩"
  1513. doctor_code = "1001"
  1514. } else {
  1515. doctor_name = roles.UserName
  1516. doctor_code = strconv.FormatInt(admin_user_id, 10)
  1517. }
  1518. var customs []*models.CustomDetail
  1519. for _, item := range order_infos {
  1520. cus := &models.CustomDetail{
  1521. PrescriptionNumber: item.OrderNumber,
  1522. ChargeSerialNumber: item.FeedetlSn,
  1523. }
  1524. customs = append(customs, cus)
  1525. }
  1526. his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1527. verifyCode, version_code := ReadCardGetCode("FY002" + "|" + order.OrgSetlNumber + "|" + miConfig.Code)
  1528. var pagesize int = 50
  1529. var start int = 1
  1530. var stop int
  1531. var pagecount int
  1532. var curpage int
  1533. var isSuccess bool = true
  1534. var ress []*ResultFive
  1535. //总页数,向上取整,注意除之前要先转换类型为float64
  1536. pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  1537. for curpage = 1; curpage <= pagecount; curpage++ {
  1538. if curpage == 1 {
  1539. start = 1
  1540. } else {
  1541. start = (curpage-1)*pagesize + 1
  1542. }
  1543. stop = curpage * pagesize
  1544. if stop > len(customs) {
  1545. stop = len(customs)
  1546. }
  1547. result := service.SzybFY002(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop], verifyCode, order.OrgSetlNumber, his.Number, version_code)
  1548. fmt.Println(result)
  1549. var dat map[string]interface{}
  1550. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1551. fmt.Println(dat)
  1552. } else {
  1553. fmt.Println(err)
  1554. }
  1555. userJSONBytes, _ := json.Marshal(dat)
  1556. var res ResultFive
  1557. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1558. utils.ErrorLog("解析失败:%v", err)
  1559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1560. return
  1561. }
  1562. if res.Transreturncode == "00000000" {
  1563. ress = append(ress, &res)
  1564. } else {
  1565. isSuccess = false
  1566. //预结算报错
  1567. errlog := &models.HisOrderError{
  1568. UserOrgId: adminUser.CurrentOrgId,
  1569. Ctime: time.Now().Unix(),
  1570. Mtime: time.Now().Unix(),
  1571. ErrMsg: res.Transreturnmessage,
  1572. Status: 1,
  1573. PatientId: patient_id,
  1574. RecordTime: recordDateTime,
  1575. Stage: 11,
  1576. }
  1577. service.CreateErrMsgLog(errlog)
  1578. c.ServeSuccessJSON(map[string]interface{}{
  1579. "faild_code": -10,
  1580. "msg": res.Transreturnmessage,
  1581. })
  1582. return
  1583. }
  1584. }
  1585. if isSuccess == true {
  1586. service.UpdataOrderInfoStatus(order.ID, order.Number, adminUser.CurrentOrgId)
  1587. c.ServeSuccessJSON(map[string]interface{}{
  1588. "msg": "撤销成功",
  1589. })
  1590. }
  1591. }
  1592. //获取verifyCode
  1593. func ReadCardGetCode(request string) (string, string) {
  1594. request = request + "|"
  1595. DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
  1596. readCards := DllDef2.MustFindProc("iVerifyCode")
  1597. str := request
  1598. str3 := make([]byte, 256)
  1599. ret4, _, _ := readCards.Call(StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  1600. fmt.Println(":", string(str3))
  1601. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  1602. if ret4 == 0 {
  1603. result := string(str3)
  1604. fmt.Println(result)
  1605. result_arr := strings.Split(result, "|")
  1606. verifyCode := result_arr[0] + "|" + result_arr[1]
  1607. versionCode := result_arr[2]
  1608. return verifyCode, versionCode
  1609. }
  1610. return "", ""
  1611. }
  1612. ////读卡
  1613. func ReadBasCardGetNumber(request string) (string, string, string, string, error, int64) {
  1614. DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
  1615. readCards := DllDef2.MustFindProc("iReadCardBas")
  1616. str := request
  1617. str3 := make([]byte, 1024)
  1618. fmt.Println(":", request)
  1619. fmt.Println(":", StrPtr(str))
  1620. ret4, _, err := readCards.Call(IntPtr(1), StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  1621. fmt.Println(":", string(str3))
  1622. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  1623. if ret4 == 0 {
  1624. result := string(str3)
  1625. fmt.Println(result)
  1626. result_arr := strings.Split(result, "|")
  1627. //医疗证号
  1628. yiliao_number := result_arr[12]
  1629. //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  1630. id_card_number := result_arr[1]
  1631. verifyCode := result_arr[11] + "|" + result_arr[13]
  1632. versionCode := result_arr[14]
  1633. return yiliao_number, id_card_number, verifyCode, versionCode, err, 0
  1634. }
  1635. return "", "", "", "", err, -10
  1636. }
  1637. //
  1638. ////iReadCardBas_HSM_Step1 ---- 1903 iCardInnerAuthentication --- iReadCardBas_HSM_Step2
  1639. //func ReadCardBasHSM(number string) string {
  1640. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  1641. // readCards := DllDef2.MustFindProc("iReadCardBas_HSM_Step1")
  1642. // str := make([]byte, 256)
  1643. // ret, _, _ := readCards.Call(IntPtr(3), (uintptr)(unsafe.Pointer(&str[0])))
  1644. // fmt.Println(":", string(str))
  1645. //
  1646. // result_arr := strings.Split(string(str), "|")
  1647. //
  1648. // if ret == 0 {
  1649. // readCards := DllDef2.MustFindProc("iCardInnerAuthentication")
  1650. // str2 := make([]byte, 256)
  1651. // str3 := "" + "|" + "" + "|" + "440300" + "|" + "" + "|" + "" + "|" + result_arr[1] + "|" + result_arr[2] + "|" + result_arr[3] + "|" + result_arr[4] + "|" + result_arr[5] + "|" + "" + "|" + "" + "|"
  1652. // ret2, _, _ := readCards.Call(StrPtr(str3), (uintptr)(unsafe.Pointer(&str2[0])))
  1653. // fmt.Println(":", string(str2))
  1654. //
  1655. // if ret2 == 0 {
  1656. // result_arr := strings.Split(string(str2), "|")
  1657. //
  1658. // if result_arr[2] == "0" {
  1659. // readCards := DllDef2.MustFindProc("iReadCardBas_HSM_Step2")
  1660. // str4 := result_arr[4] + "|" + result_arr[5]
  1661. // str5 := make([]byte, 256)
  1662. // ret3, _, _ := readCards.Call(StrPtr(str4), StrPtr(number), (uintptr)(unsafe.Pointer(&str5[0])))
  1663. //
  1664. // if ret3 == 0 {
  1665. // return string(str5)
  1666. //
  1667. // } else {
  1668. // return ""
  1669. // }
  1670. // } else {
  1671. // return ""
  1672. // }
  1673. // }
  1674. // return ""
  1675. // }
  1676. // return ""
  1677. //
  1678. //}
  1679. //
  1680. ////1904卡鉴权
  1681. //func CardAuth(request string) string {
  1682. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  1683. // readCards := DllDef2.MustFindProc("iCardAuthentication")
  1684. // str := request
  1685. // str3 := make([]byte, 256)
  1686. // ret4, _, _ := readCards.Call(StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  1687. // fmt.Println(":", string(str3))
  1688. //
  1689. // if ret4 == 0 {
  1690. // return string(str3)
  1691. // }
  1692. // return ""
  1693. //}
  1694. //func (c *SZHisApiController) GetDrugList() {
  1695. //
  1696. // adminUserInfo := c.GetAdminUserInfo()
  1697. // orgId := adminUserInfo.CurrentOrgId
  1698. // fmt.Println(orgId)
  1699. // //获取药品库数据
  1700. // list, _ := service.GetDrugList(orgId)
  1701. // //获取药品剂型
  1702. // drugs, _ := service.GetDrugDosageForm(orgId)
  1703. // for _, item := range list {
  1704. // fmt.Println(item.DrugDosageForm)
  1705. // for _, it := range drugs {
  1706. //
  1707. // if item.DrugDosageForm == it.Value {
  1708. // item.DrugDosageName = it.Name
  1709. // }
  1710. // }
  1711. // }
  1712. // fmt.Print("长度", len(list))
  1713. // miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  1714. // var doctor_name string
  1715. // var doctor_code string
  1716. //
  1717. // doctor_name = "黄亦轩"
  1718. // doctor_code = "1001"
  1719. //
  1720. // var pagesize int = 50
  1721. // var start int = 1
  1722. // var stop int
  1723. // var pagecount int
  1724. // var curpage int
  1725. // var isSuccess bool = true
  1726. // //总页数,向上取整,注意除之前要先转换类型为float64
  1727. // pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  1728. // fmt.Println("pageCount22222", pagecount)
  1729. // var ress []*Result
  1730. // for curpage = 1; curpage <= pagecount; curpage++ {
  1731. // if curpage == 1 {
  1732. // start = 1
  1733. // } else {
  1734. // start = (curpage-1)*pagesize + 1
  1735. // }
  1736. // stop = curpage * pagesize
  1737. // if stop > len(list) {
  1738. // stop = len(list)
  1739. // }
  1740. // //这里就可以查看开始和结束了
  1741. // var customs []*models.DrugDetail
  1742. // for _, item := range list {
  1743. //
  1744. // detail := &models.DrugDetail{
  1745. //
  1746. // MedicalInsuranceNumber: item.MedicalInsuranceNumber,
  1747. // Code: item.Code,
  1748. // DrugName: item.DrugName,
  1749. // DrugSpec: item.DrugSpec,
  1750. // DrugDosageName: item.DrugDosageName,
  1751. // ManufacturerName: item.ManufacturerName,
  1752. // MinUnit: item.MinUnit,
  1753. // RetailPrice: item.RetailPrice,
  1754. // LastPrice: item.LastPrice,
  1755. // LimitRemark: item.LimitRemark,
  1756. // }
  1757. // customs = append(customs, detail)
  1758. // }
  1759. //
  1760. // result := service.SzybML008(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop])
  1761. // fmt.Println("reuslt9999999999999", result)
  1762. //
  1763. // var dat map[string]interface{}
  1764. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1765. // //fmt.Println(dat)
  1766. // } else {
  1767. // //fmt.Println(err)
  1768. // }
  1769. //
  1770. // userJSONBytes, _ := json.Marshal(dat)
  1771. //
  1772. // var res Result
  1773. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1774. // utils.ErrorLog("解析失败:%v", err)
  1775. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1776. // return
  1777. // }
  1778. // if res.Transreturncode == "00000000" {
  1779. // ress = append(ress, &res)
  1780. // } else {
  1781. // isSuccess = false
  1782. // //失败
  1783. //
  1784. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorDrugPreSettleFaildParamWrong)
  1785. // return
  1786. // }
  1787. // fmt.Println(isSuccess)
  1788. // }
  1789. //}
  1790. //func (c *SZHisApiController) GetTreatmentProject() {
  1791. // fmt.Println("触发了吗2222222222")
  1792. // adminUserInfo := c.GetAdminUserInfo()
  1793. // orgId := adminUserInfo.CurrentOrgId
  1794. //
  1795. // //获取药品库数据
  1796. // list, _ := service.GetMyPorjecgList(orgId)
  1797. //
  1798. // miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  1799. // var doctor_name string
  1800. // var doctor_code string
  1801. //
  1802. // doctor_name = "黄亦轩"
  1803. // doctor_code = "1001"
  1804. //
  1805. // var pagesize int = 50
  1806. // var start int = 1
  1807. // var stop int
  1808. // var pagecount int
  1809. // var curpage int
  1810. // var isSuccess bool = true
  1811. // //总页数,向上取整,注意除之前要先转换类型为float64
  1812. // pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  1813. //
  1814. // var ress []*Result
  1815. // for curpage = 1; curpage <= pagecount; curpage++ {
  1816. // if curpage == 1 {
  1817. // start = 1
  1818. // } else {
  1819. // start = (curpage-1)*pagesize + 1
  1820. // }
  1821. // stop = curpage * pagesize
  1822. // if stop > len(list) {
  1823. // stop = len(list)
  1824. // }
  1825. // //这里就可以查看开始和结束了
  1826. // fmt.Println(list[start-1 : stop])
  1827. // var customs []*models.ProjectDetail
  1828. // for _, item := range list {
  1829. //
  1830. // detail := &models.ProjectDetail{
  1831. //
  1832. // SocialSecurityDirectoryCode: item.MedicalCode, //社保目录
  1833. // ProjectName: item.ProjectName,
  1834. // Price: item.Price,
  1835. // Category: strconv.FormatInt(item.Category, 10),
  1836. // Remark: item.Remark,
  1837. // }
  1838. // customs = append(customs, detail)
  1839. // }
  1840. // result := service.SzybML009(doctor_name, doctor_code, miConfig.Code, customs)
  1841. // fmt.Println("reuslt9999999999999999", result)
  1842. // var dat map[string]interface{}
  1843. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1844. // fmt.Println(dat)
  1845. // } else {
  1846. // fmt.Println(err)
  1847. // }
  1848. //
  1849. // userJSONBytes, _ := json.Marshal(dat)
  1850. //
  1851. // var res Result
  1852. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1853. // utils.ErrorLog("解析失败:%v", err)
  1854. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1855. // return
  1856. // }
  1857. // if res.Transreturncode == "00000000" {
  1858. // ress = append(ress, &res)
  1859. // } else {
  1860. // isSuccess = false
  1861. // //失败
  1862. //
  1863. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorDrugPreSettleFaildParamWrong)
  1864. // return
  1865. // }
  1866. // fmt.Println(isSuccess)
  1867. // }
  1868. //}
  1869. func (c *SZHisApiController) GetRevocation() {
  1870. adminUserInfo := c.GetAdminUserInfo()
  1871. orgId := adminUserInfo.CurrentOrgId
  1872. id, _ := c.GetInt64("id")
  1873. //用来区分是药品的撤销还是耗材的撤销 1.药品 2.诊疗项目 3.材料 5.辅助器具项目
  1874. type_id, _ := c.GetInt64("type_id")
  1875. fmt.Println("type_id2222222", type_id)
  1876. if type_id == 1 {
  1877. //获取药品库数据
  1878. list, _ := service.GetDrugListByDetail(orgId, id)
  1879. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  1880. var doctor_name string
  1881. var doctor_code string
  1882. doctor_name = "黄亦轩"
  1883. doctor_code = "1001"
  1884. var pagesize int = 50
  1885. var start int = 1
  1886. var stop int
  1887. var pagecount int
  1888. var curpage int
  1889. var isSuccess bool = true
  1890. //总页数,向上取整,注意除之前要先转换类型为float64
  1891. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  1892. var ress []*Result
  1893. for curpage = 1; curpage <= pagecount; curpage++ {
  1894. if curpage == 1 {
  1895. start = 1
  1896. } else {
  1897. start = (curpage-1)*pagesize + 1
  1898. }
  1899. stop = curpage * pagesize
  1900. if stop > len(list) {
  1901. stop = len(list)
  1902. }
  1903. //这里就可以查看开始和结束了
  1904. fmt.Println(list[start-1 : stop])
  1905. var customs []*models.DrugDetail
  1906. for _, item := range list {
  1907. fmt.Println("医疗机构编码", item.MedicalInsuranceNumber)
  1908. detail := &models.DrugDetail{
  1909. MedicalInsuranceNumber: item.MedicalInsuranceNumber, //社保目录
  1910. Code: item.Code, //协议机构内部目录编码
  1911. DrugName: item.DrugName, //协议机构内部目录名称
  1912. DrugSpec: item.DrugSpec,
  1913. ManufacturerName: item.ManufacturerName,
  1914. MinUnit: item.MinUnit,
  1915. RetailPrice: item.RetailPrice, //协议机构内部项目收费价格
  1916. LimitRemark: item.LimitRemark,
  1917. }
  1918. customs = append(customs, detail)
  1919. }
  1920. result := service.SzybML010(doctor_name, doctor_code, miConfig.Code, customs, type_id)
  1921. fmt.Println("reuslt", result)
  1922. var dat map[string]interface{}
  1923. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1924. fmt.Println(dat)
  1925. } else {
  1926. fmt.Println(err)
  1927. }
  1928. userJSONBytes, _ := json.Marshal(dat)
  1929. var res Result
  1930. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1931. utils.ErrorLog("解析失败:%v", err)
  1932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1933. return
  1934. }
  1935. if res.Transreturncode == "00000000" {
  1936. ress = append(ress, &res)
  1937. } else {
  1938. isSuccess = false
  1939. //失败
  1940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorDrugReturnFaildParamWrong)
  1941. return
  1942. }
  1943. fmt.Println(isSuccess)
  1944. }
  1945. if type_id == 2 {
  1946. //获取药品库数据
  1947. list, _ := service.GetMyPorjecgListDetail(orgId, id)
  1948. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  1949. var doctor_name string
  1950. var doctor_code string
  1951. doctor_name = "黄亦轩"
  1952. doctor_code = "1001"
  1953. var pagesize int = 50
  1954. var start int = 1
  1955. var stop int
  1956. var pagecount int
  1957. var curpage int
  1958. var isSuccess bool = true
  1959. //总页数,向上取整,注意除之前要先转换类型为float64
  1960. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  1961. var ress []*Result
  1962. for curpage = 1; curpage <= pagecount; curpage++ {
  1963. if curpage == 1 {
  1964. start = 1
  1965. } else {
  1966. start = (curpage-1)*pagesize + 1
  1967. }
  1968. stop = curpage * pagesize
  1969. if stop > len(list) {
  1970. stop = len(list)
  1971. }
  1972. //这里就可以查看开始和结束了
  1973. fmt.Println(list[start-1 : stop])
  1974. var customs []*models.DrugDetail
  1975. for _, item := range list {
  1976. detail := &models.DrugDetail{
  1977. SocialSecurityDirectoryCode: item.MedicalCode,
  1978. }
  1979. customs = append(customs, detail)
  1980. }
  1981. result := service.SzybML010(doctor_name, doctor_code, miConfig.Code, customs, type_id)
  1982. fmt.Println("reuslt", result)
  1983. var dat map[string]interface{}
  1984. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1985. fmt.Println(dat)
  1986. } else {
  1987. fmt.Println(err)
  1988. }
  1989. userJSONBytes, _ := json.Marshal(dat)
  1990. var res Result
  1991. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1992. utils.ErrorLog("解析失败:%v", err)
  1993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1994. return
  1995. }
  1996. if res.Transreturncode == "00000000" {
  1997. ress = append(ress, &res)
  1998. } else {
  1999. isSuccess = false
  2000. //失败
  2001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorDrugReturnFaildParamWrong)
  2002. return
  2003. }
  2004. fmt.Println(isSuccess)
  2005. }
  2006. }
  2007. if type_id == 3 {
  2008. //获取药品库数据
  2009. list, _ := service.GetGoodListByDetail(orgId, id)
  2010. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  2011. var doctor_name string
  2012. var doctor_code string
  2013. doctor_name = "黄亦轩"
  2014. doctor_code = "1001"
  2015. var pagesize int = 50
  2016. var start int = 1
  2017. var stop int
  2018. var pagecount int
  2019. var curpage int
  2020. var isSuccess bool = true
  2021. //总页数,向上取整,注意除之前要先转换类型为float64
  2022. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  2023. var ress []*Result
  2024. for curpage = 1; curpage <= pagecount; curpage++ {
  2025. if curpage == 1 {
  2026. start = 1
  2027. } else {
  2028. start = (curpage-1)*pagesize + 1
  2029. }
  2030. stop = curpage * pagesize
  2031. if stop > len(list) {
  2032. stop = len(list)
  2033. }
  2034. //这里就可以查看开始和结束了
  2035. fmt.Println(list[start-1 : stop])
  2036. var customs []*models.DrugDetail
  2037. for _, item := range list {
  2038. fmt.Println("医疗机构编码", item.MedicalInsuranceNumber)
  2039. detail := &models.DrugDetail{
  2040. SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
  2041. ManufacturerName: item.ManufacturerName,
  2042. }
  2043. customs = append(customs, detail)
  2044. }
  2045. result := service.SzybML010(doctor_name, doctor_code, miConfig.Code, customs, type_id)
  2046. fmt.Println("reuslt", result)
  2047. var dat map[string]interface{}
  2048. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2049. fmt.Println(dat)
  2050. } else {
  2051. fmt.Println(err)
  2052. }
  2053. userJSONBytes, _ := json.Marshal(dat)
  2054. var res Result
  2055. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2056. utils.ErrorLog("解析失败:%v", err)
  2057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2058. return
  2059. }
  2060. if res.Transreturncode == "00000000" {
  2061. ress = append(ress, &res)
  2062. } else {
  2063. isSuccess = false
  2064. //失败
  2065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorDrugReturnFaildParamWrong)
  2066. return
  2067. }
  2068. fmt.Println(isSuccess)
  2069. }
  2070. }
  2071. }
  2072. //func (c *SZHisApiController) GetInformationQuery() {
  2073. //
  2074. // var doctor_name string
  2075. // var doctor_code string
  2076. //
  2077. // doctor_name = "黄亦轩"
  2078. // doctor_code = "1001"
  2079. // miConfig, _ := service.FindMedicalInsuranceInfo(10028)
  2080. // result := service.SzybML010(doctor_name, doctor_code, miConfig.Code, customs)
  2081. // fmt.Println("reuslt9999999999999999", result)
  2082. // var dat map[string]interface{}
  2083. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2084. // fmt.Println(dat)
  2085. // } else {
  2086. // fmt.Println(err)
  2087. // }
  2088. //
  2089. // userJSONBytes, _ := json.Marshal(dat)
  2090. //
  2091. // var res Result
  2092. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2093. // utils.ErrorLog("解析失败:%v", err)
  2094. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2095. // return
  2096. // }
  2097. // if res.Transreturncode == "00000000" {
  2098. // ress = append(ress, &res)
  2099. // } else {
  2100. // isSuccess = false
  2101. // //失败
  2102. //
  2103. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
  2104. // return
  2105. // }
  2106. // fmt.Println(isSuccess)
  2107. //
  2108. //}
  2109. }
  2110. func (c *SZHisApiController) GetDoctorList() {
  2111. adminUserInfo := c.GetAdminUserInfo()
  2112. orgid := adminUserInfo.CurrentOrgId
  2113. fmt.Println("or3gi", orgid)
  2114. //获取所有医生护士信息
  2115. list, _ := service.GetDoctorList(9671)
  2116. //获取所有角色名称
  2117. roleList, _ := service.GetRoleList(9671)
  2118. miConfig, _ := service.FindMedicalInsuranceInfo(9671)
  2119. for _, item := range list {
  2120. for _, it := range roleList {
  2121. if item.RoleId == it.ID {
  2122. item.Name = it.RoleName
  2123. }
  2124. }
  2125. }
  2126. var doctor_name string
  2127. var doctor_code string
  2128. doctor_name = "黄亦轩"
  2129. doctor_code = "1001"
  2130. var pagesize int = 50
  2131. var start int = 1
  2132. var stop int
  2133. var pagecount int
  2134. var curpage int
  2135. var isSuccess bool = true
  2136. //总页数,向上取整,注意除之前要先转换类型为float64
  2137. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  2138. var ress []*Result
  2139. for curpage = 1; curpage <= pagecount; curpage++ {
  2140. if curpage == 1 {
  2141. start = 1
  2142. } else {
  2143. start = (curpage-1)*pagesize + 1
  2144. }
  2145. stop = curpage * pagesize
  2146. if stop > len(list) {
  2147. stop = len(list)
  2148. }
  2149. //这里就可以查看开始和结束了
  2150. fmt.Println(list[start-1 : stop])
  2151. var customs []*models.DocDetail
  2152. for _, item := range list {
  2153. fmt.Println("医护类别", item.Name)
  2154. sex := strconv.FormatInt(item.Sex, 10)
  2155. card_type := strconv.FormatInt(item.CardType, 10)
  2156. is_active := strconv.FormatInt(item.IsActive, 10)
  2157. detail := &models.DocDetail{
  2158. UserName: item.UserName,
  2159. RoleId: item.Name,
  2160. Sex: sex,
  2161. CardType: card_type,
  2162. IdCard: item.IdCard,
  2163. Phone: "",
  2164. WorkMajorName: item.WorkMajorName,
  2165. Nation: item.Nation,
  2166. BirthDay: 20201022,
  2167. WorkTime: 12,
  2168. Education: strconv.FormatInt(item.Education, 10),
  2169. StudyMajorName: item.StudyMajorName,
  2170. CertificateCode: "", //证书编码
  2171. MedicalCode: item.MedicalCode, //医师资格编码
  2172. MedicalRangeCode: strconv.FormatInt(item.MedicalRangeCode, 10), //医师执业范围代码
  2173. MedicalLevel: strconv.FormatInt(item.MedicalLevel, 10), //医生级别
  2174. TypeJob: strconv.FormatInt(item.DoctorTypeJob, 10), //职业类别
  2175. DoctorNumber: item.DoctorNumber, //医师编号
  2176. Licensing: strconv.FormatInt(item.Licensing, 10), //职业标志
  2177. DoctorServiceStatus: "", //医师医保服务资格状态
  2178. MonitoringLevel: "", //监控等级
  2179. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  2180. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  2181. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  2182. PharmacistType: "", //药师类别
  2183. PharmacistPracticeCategory: "", //药师执业类别
  2184. PharmacistsLicensing: "", //药师执业范围
  2185. PharmacistRegistrationNumber: item.PharmacistRegistrationNumber, //执业药师注册证编号
  2186. OfficeCode: "", //科室编码
  2187. JobNumber: item.JobNumber, //工号
  2188. PostName: "", //职位名称
  2189. TechnicalJobLevelCode: "", //专业技术职务级别编码
  2190. IsActive: is_active, //在职与否
  2191. PrescriptionQualificationIdentification: item.PharmacistRegistrationNumber, //处方资格标识
  2192. IdentificationOutpatients: "", //门诊大病医师标识
  2193. OutpatientIllnessCategory: item.OutpatientIllnessCategory, //门诊大病类别
  2194. StartTime: 1233, //开始日期
  2195. }
  2196. customs = append(customs, detail)
  2197. }
  2198. result := service.SzybYS001(doctor_name, doctor_code, miConfig.Code, customs)
  2199. fmt.Println("reuslt9999999999999999", result)
  2200. var dat map[string]interface{}
  2201. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2202. fmt.Println(dat)
  2203. } else {
  2204. fmt.Println(err)
  2205. }
  2206. userJSONBytes, _ := json.Marshal(dat)
  2207. var res Result
  2208. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2209. utils.ErrorLog("解析失败:%v", err)
  2210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2211. return
  2212. }
  2213. if res.Transreturncode == "00000000" {
  2214. ress = append(ress, &res)
  2215. } else {
  2216. isSuccess = false
  2217. //失败
  2218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorDoctorLoginFaildParamWrong)
  2219. return
  2220. }
  2221. fmt.Println(isSuccess)
  2222. }
  2223. }
  2224. func (c *SZHisApiController) GetMedicalList() {
  2225. adminUserInfo := c.GetAdminUserInfo()
  2226. orgId := adminUserInfo.CurrentOrgId
  2227. id, _ := c.GetInt64("id")
  2228. fmt.Println("id22222222", id)
  2229. //获取所有医生护士信息
  2230. list, _ := service.GetDoctorListByDetail(orgId, id)
  2231. //获取所有角色名称
  2232. roleList, _ := service.GetRoleList(orgId)
  2233. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  2234. for _, item := range list {
  2235. for _, it := range roleList {
  2236. if item.RoleId == it.ID {
  2237. item.Name = it.RoleName
  2238. }
  2239. }
  2240. }
  2241. var doctor_name string
  2242. var doctor_code string
  2243. doctor_name = "黄亦轩"
  2244. doctor_code = "1001"
  2245. var pagesize int = 50
  2246. var start int = 1
  2247. var stop int
  2248. var pagecount int
  2249. var curpage int
  2250. var isSuccess bool = true
  2251. //总页数,向上取整,注意除之前要先转换类型为float64
  2252. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  2253. var ress []*Result
  2254. for curpage = 1; curpage <= pagecount; curpage++ {
  2255. if curpage == 1 {
  2256. start = 1
  2257. } else {
  2258. start = (curpage-1)*pagesize + 1
  2259. }
  2260. stop = curpage * pagesize
  2261. if stop > len(list) {
  2262. stop = len(list)
  2263. }
  2264. //这里就可以查看开始和结束了
  2265. fmt.Println(list[start-1 : stop])
  2266. var customs []*models.DocDetail
  2267. for _, item := range list {
  2268. fmt.Println("医护类别", item.Name)
  2269. detail := &models.DocDetail{
  2270. StaffCode: "H27224269",
  2271. UserName: item.UserName,
  2272. RoleId: item.Name,
  2273. Sex: "1",
  2274. CardType: "01",
  2275. IdCard: "430526199408156511",
  2276. Phone: "13318464642",
  2277. WorkMajorName: "医生",
  2278. Nation: "01",
  2279. BirthDay: 20201022,
  2280. WorkTime: 20201022,
  2281. Education: "21",
  2282. StudyMajorName: "医生",
  2283. CertificateCode: "y2222222", //证书编码
  2284. MedicalCode: "y2222222", //医师资格编码
  2285. MedicalRangeCode: "101", //医师执业范围代码
  2286. MedicalLevel: "1", //医生级别
  2287. TypeJob: "1", //职业类别
  2288. DoctorNumber: "22222", //医师编号b
  2289. Licensing: "1", //职业标志
  2290. DoctorServiceStatus: "1", //医师医保服务资格状态
  2291. MonitoringLevel: "1", //监控等级
  2292. DrugPsychotropicSubstances: "1", //毒麻精神药品资格
  2293. HealthCareCode: "1001", // 母婴保健技术考核合格证书编号
  2294. PlanningTechnicalServiceCode: "1002", //计划生育技术服务人员合格证编号
  2295. PharmacistType: "1", //药师类别
  2296. PharmacistPracticeCategory: "1", //药师执业类别
  2297. PharmacistsLicensing: "1", //药师执业范围
  2298. PharmacistRegistrationNumber: "000200", //执业药师注册证编号
  2299. OfficeCode: "9933", //科室编码
  2300. JobNumber: "82021344", //工号
  2301. PostName: "主任", //职位名称
  2302. TechnicalJobLevelCode: "231", //专业技术职务级别编码
  2303. IsActive: "1", //在职与否
  2304. PrescriptionQualificationIdentification: "1", //处方资格标识
  2305. IdentificationOutpatients: "1", //门诊大病医师标识
  2306. OutpatientIllnessCategory: "血友病", //门诊大病类别
  2307. StartTime: 20210311, //开始日期
  2308. }
  2309. customs = append(customs, detail)
  2310. }
  2311. result := service.SzybYS002(doctor_name, doctor_code, miConfig.Code, customs)
  2312. fmt.Println("reuslt9999999999999999", result)
  2313. var dat map[string]interface{}
  2314. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2315. fmt.Println(dat)
  2316. } else {
  2317. fmt.Println(err)
  2318. }
  2319. userJSONBytes, _ := json.Marshal(dat)
  2320. var res Result
  2321. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2322. utils.ErrorLog("解析失败:%v", err)
  2323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2324. return
  2325. }
  2326. if res.Transreturncode == "00000000" {
  2327. ress = append(ress, &res)
  2328. } else {
  2329. isSuccess = false
  2330. //失败
  2331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorDrugReturnFaildParamWrong)
  2332. return
  2333. }
  2334. fmt.Println(isSuccess)
  2335. }
  2336. }
  2337. func (c *SZHisApiController) GetUpdateMedicalList() {
  2338. adminUserInfo := c.GetAdminUserInfo()
  2339. orgId := adminUserInfo.CurrentOrgId
  2340. //获取所有医生护士信息
  2341. list, _ := service.GetDoctorList(orgId)
  2342. //获取所有角色名称
  2343. roleList, _ := service.GetRoleList(orgId)
  2344. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  2345. for _, item := range list {
  2346. for _, it := range roleList {
  2347. if item.RoleId == it.ID {
  2348. item.Name = it.RoleName
  2349. }
  2350. }
  2351. }
  2352. var doctor_name string
  2353. var doctor_code string
  2354. doctor_name = "黄亦轩"
  2355. doctor_code = "1001"
  2356. var pagesize int = 50
  2357. var start int = 1
  2358. var stop int
  2359. var pagecount int
  2360. var curpage int
  2361. var isSuccess bool = true
  2362. //总页数,向上取整,注意除之前要先转换类型为float64
  2363. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  2364. var ress []*Result
  2365. for curpage = 1; curpage <= pagecount; curpage++ {
  2366. if curpage == 1 {
  2367. start = 1
  2368. } else {
  2369. start = (curpage-1)*pagesize + 1
  2370. }
  2371. stop = curpage * pagesize
  2372. if stop > len(list) {
  2373. stop = len(list)
  2374. }
  2375. //这里就可以查看开始和结束了
  2376. fmt.Println(list[start-1 : stop])
  2377. var customs []*models.DocDetail
  2378. for _, item := range list {
  2379. fmt.Println("医护类别", item.Name)
  2380. detail := &models.DocDetail{
  2381. StaffCode: "", //医护人员编码
  2382. UserName: item.UserName, //医护人员姓名
  2383. RoleId: item.Name, //医护人员类别
  2384. Sex: "", //性别
  2385. CardType: "", //证件类型
  2386. IdCard: "", //证件号码
  2387. Phone: "", //联系电话
  2388. WorkMajorName: "", //现从事专业名称
  2389. Nation: "", //民族
  2390. BirthDay: 20201022, //出生日期
  2391. WorkTime: 12, //参加工作日期
  2392. Education: "", //学历
  2393. StudyMajorName: "", //所学的专业名称
  2394. CertificateCode: "", //证书编码
  2395. MedicalCode: "", //医师资格编码
  2396. MedicalRangeCode: "", //医师执业范围代码
  2397. MedicalLevel: "", //医生级别
  2398. TypeJob: "", //职业类别
  2399. DoctorNumber: "", //医师编号
  2400. Licensing: "", //职业标志
  2401. DoctorServiceStatus: "", //医师医保服务资格状态
  2402. MonitoringLevel: "", //监控等级
  2403. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  2404. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  2405. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  2406. PharmacistType: "", //药师类别
  2407. PharmacistPracticeCategory: "", //药师执业类别
  2408. PharmacistsLicensing: "", //药师执业范围
  2409. PharmacistRegistrationNumber: "", //执业药师注册证编号
  2410. OfficeCode: "", //科室编码
  2411. JobNumber: "", //工号
  2412. PostName: "", //职位名称
  2413. TechnicalJobLevelCode: "", //专业技术职务级别编码
  2414. IsActive: "", //在职与否
  2415. PrescriptionQualificationIdentification: "", //处方资格标识
  2416. IdentificationOutpatients: "", //门诊大病医师标识
  2417. OutpatientIllnessCategory: "", //门诊大病类别
  2418. StartTime: 1233, //开始日期
  2419. EndTime: 123333,
  2420. }
  2421. customs = append(customs, detail)
  2422. }
  2423. result := service.SzybYS003(doctor_name, doctor_code, miConfig.Code, customs)
  2424. fmt.Println("reuslt9999999999999999", result)
  2425. var dat map[string]interface{}
  2426. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2427. fmt.Println(dat)
  2428. } else {
  2429. fmt.Println(err)
  2430. }
  2431. userJSONBytes, _ := json.Marshal(dat)
  2432. var res Result
  2433. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2434. utils.ErrorLog("解析失败:%v", err)
  2435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2436. return
  2437. }
  2438. if res.Transreturncode == "00000000" {
  2439. ress = append(ress, &res)
  2440. } else {
  2441. isSuccess = false
  2442. //失败
  2443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorDrugPreSettleFaildParamWrong)
  2444. return
  2445. }
  2446. fmt.Println(isSuccess)
  2447. }
  2448. }
  2449. //func (c *SZHisApiController) GetGoodsList() {
  2450. //
  2451. // adminUserInfo := c.GetAdminUserInfo()
  2452. // orgId := adminUserInfo.CurrentOrgId
  2453. // fmt.Println(orgId)
  2454. // //获取所有耗材信息
  2455. // list, _ := service.GetGoodInformationList(orgId)
  2456. // fmt.Println("list22222", list)
  2457. // //获取单位
  2458. // miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  2459. // var doctor_name string
  2460. // var doctor_code string
  2461. //
  2462. // doctor_name = "黄亦轩"
  2463. // doctor_code = "1001"
  2464. //
  2465. // var pagesize int = 50
  2466. // var start int = 1
  2467. // var stop int
  2468. // var pagecount int
  2469. // var curpage int
  2470. // var isSuccess bool = true
  2471. // //总页数,向上取整,注意除之前要先转换类型为float64
  2472. // pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  2473. //
  2474. // var ress []*Result
  2475. // for curpage = 1; curpage <= pagecount; curpage++ {
  2476. // if curpage == 1 {
  2477. // start = 1
  2478. // } else {
  2479. // start = (curpage-1)*pagesize + 1
  2480. // }
  2481. // stop = curpage * pagesize
  2482. // if stop > len(list) {
  2483. // stop = len(list)
  2484. // }
  2485. // //这里就可以查看开始和结束了
  2486. // fmt.Println(list[start-1 : stop])
  2487. // var customs []*models.GoodDetail
  2488. // for _, item := range list {
  2489. //
  2490. // detail := &models.GoodDetail{
  2491. // GoodName: item.GoodName,
  2492. // SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
  2493. // ManufacturerName: item.ManufacturerName,
  2494. // ProductionType: item.ProductionType,
  2495. // SpecialMedical: item.SpecialMedical,
  2496. // BuyPrice: item.BuyPrice,
  2497. // SellPrice: item.SellPrice,
  2498. // Remark: item.Remark,
  2499. // }
  2500. // customs = append(customs, detail)
  2501. // }
  2502. //
  2503. // result := service.SzybYML007(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop])
  2504. // fmt.Println("reuslt8888", result)
  2505. // var dat map[string]interface{}
  2506. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2507. // fmt.Println(dat)
  2508. // } else {
  2509. // fmt.Println(err)
  2510. // }
  2511. //
  2512. // userJSONBytes, _ := json.Marshal(dat)
  2513. //
  2514. // var res Result
  2515. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2516. // utils.ErrorLog("解析失败:%v", err)
  2517. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2518. // return
  2519. // }
  2520. // if res.Transreturncode == "00000000" {
  2521. // ress = append(ress, &res)
  2522. // } else {
  2523. // isSuccess = false
  2524. // //失败
  2525. //
  2526. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorDrugPreSettleFaildParamWrong)
  2527. // return
  2528. // }
  2529. // fmt.Println(isSuccess)
  2530. //
  2531. // }
  2532. //}
  2533. type Charset string
  2534. const (
  2535. UTF8 = Charset("UTF-8")
  2536. GB18030 = Charset("GB18030")
  2537. )
  2538. func ConvertToString(src string, srcCode string, tagCode string) string {
  2539. srcCoder := mahonia.NewDecoder(srcCode)
  2540. srcResult := srcCoder.ConvertString(src)
  2541. tagCoder := mahonia.NewDecoder(tagCode)
  2542. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  2543. result := string(cdata)
  2544. return result
  2545. }