sz_his_api_controller.go 100KB

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