sz_his_api_controller.go 131KB

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