sz_his_api_controller.go 154KB

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