sz_his_api_controller.go 161KB

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