sz_his_api_controller.go 176KB

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