sz_his_api_controller.go 90KB

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