sz_his_api_controller.go 91KB

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