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