sz_his_api_controller.go 176KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033
  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. total, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", total), 64)
  2375. yiliao_number, id_card_number, verifyCode, version_code, health_card_no, _, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code + "|")
  2376. if ret4 == 0 {
  2377. //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  2378. tempPatient, _ := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
  2379. if tempPatient.ID == patient_id {
  2380. 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)
  2381. var dat map[string]interface{}
  2382. if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
  2383. fmt.Println(dat)
  2384. } else {
  2385. fmt.Println(err)
  2386. }
  2387. userJSONBytes, _ := json.Marshal(dat)
  2388. var res ResultTwo
  2389. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2390. utils.ErrorLog("解析失败:%v", err)
  2391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2392. return
  2393. }
  2394. if res.Transreturncode == "00000000" {
  2395. order.OrderStatus = 2
  2396. order.PayWay = pay_way
  2397. order.PayPrice = pay_price
  2398. order.PayCardNo = pay_card_no
  2399. order.PsnNo = health_card_no
  2400. order.DiscountPrice = discount_price
  2401. order.PreferentialPrice = preferential_price
  2402. order.RealityPrice = reality_price
  2403. order.FoundPrice = found_price
  2404. order.MedicalInsurancePrice = medical_insurance_price
  2405. order.PrivatePrice = private_price
  2406. order.Modify = admin_user_id
  2407. order.MedfeeSumamt = res.Transbody.Akc264
  2408. order.SetlId = res.Transbody.Ckc618
  2409. order.FundPaySumamt = res.Transbody.Akb068
  2410. order.AcctPay = res.Transbody.Akb066
  2411. order.PsnCashPay = res.Transbody.Akb067
  2412. order.PsnPartAmt = res.Transbody.Akb067
  2413. order.AccountPrice = res.Transbody.Aae240
  2414. order.MzNumber = mz_number
  2415. order.YiliaoNumber = yiliao_number
  2416. setlDetailOne, _ := json.Marshal(res.Transbody.Outputlist1)
  2417. detailStrOne := string(setlDetailOne)
  2418. order.SzChargeInfo = detailStrOne
  2419. setlDetailTwo, _ := json.Marshal(res.Transbody.Outputlist2)
  2420. detailStrTwo := string(setlDetailTwo)
  2421. order.SzProjectInfo = detailStrTwo
  2422. setlDetailThree, _ := json.Marshal(res.Transbody.Outputlist3)
  2423. detailStrThree := string(setlDetailThree)
  2424. order.SzMedicineInsuranceInfo = detailStrThree
  2425. order.Cainfo = result_three
  2426. err = service.UpdataOrderStatusTwo(order.Number, adminUser.CurrentOrgId)
  2427. err = service.UpDateOrderTwo(order)
  2428. c.ServeSuccessJSON(map[string]interface{}{
  2429. "msg": "结算成功",
  2430. })
  2431. } else {
  2432. //结算报错
  2433. errlog := &models.HisOrderError{
  2434. UserOrgId: adminUser.CurrentOrgId,
  2435. Ctime: time.Now().Unix(),
  2436. Mtime: time.Now().Unix(),
  2437. Number: chrg_bchno,
  2438. ErrMsg: res.Transreturnmessage,
  2439. Status: 1,
  2440. PatientId: patient_id,
  2441. RecordTime: recordDateTime,
  2442. Stage: 6,
  2443. }
  2444. service.CreateErrMsgLog(errlog)
  2445. c.ServeSuccessJSON(map[string]interface{}{
  2446. "failed_code": -10,
  2447. "msg": res.Transreturnmessage,
  2448. })
  2449. }
  2450. } else {
  2451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2452. return
  2453. }
  2454. } else {
  2455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2456. return
  2457. }
  2458. } else {
  2459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
  2460. return
  2461. }
  2462. }
  2463. //func (c *SZHisApiController) GetSettleInfo() {
  2464. // pay_way, _ := c.GetInt64("pay_way")
  2465. // pay_price, _ := c.GetFloat("pay_price")
  2466. // pay_card_no := c.GetString("pay_card_no")
  2467. // discount_price, _ := c.GetFloat("discount_price")
  2468. // preferential_price, _ := c.GetFloat("preferential_price")
  2469. // reality_price, _ := c.GetFloat("reality_price")
  2470. // found_price, _ := c.GetFloat("found_price")
  2471. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  2472. // private_price, _ := c.GetFloat("private_price")
  2473. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2474. // patient_id, _ := c.GetInt64("id")
  2475. // record_time := c.GetString("record_time")
  2476. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2477. // timestamp := time.Now().Unix()
  2478. // tempTime := time.Unix(timestamp, 0)
  2479. // timeFormat := tempTime.Format("20060102150405")
  2480. // chrgBchno := rand.Intn(10000) + 1000
  2481. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(1, 10)
  2482. // adminUser := c.GetAdminUserInfo()
  2483. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2484. // month := time.Unix(1557042972, 0).Format("1")
  2485. // year := time.Now().Format("2006")
  2486. // month = time.Now().Format("01")
  2487. // day := time.Now().Format("02")
  2488. //
  2489. // timeLayout := "2006-01-02"
  2490. // loc, _ := time.LoadLocation("Local")
  2491. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2492. // fmt.Println(err)
  2493. // if err != nil {
  2494. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2495. // return
  2496. // }
  2497. // recordDateTime := theTime.Unix()
  2498. //
  2499. // var prescriptions []*models.HisPrescription
  2500. //
  2501. // var start_time int64
  2502. // var end_time int64
  2503. //
  2504. // if settle_accounts_type == 1 { //日结
  2505. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2506. //
  2507. // } else { //月结
  2508. // start_time_str := c.GetString("start_time")
  2509. // end_time_str := c.GetString("end_time")
  2510. // timeLayout := "2006-01-02"
  2511. // loc, _ := time.LoadLocation("Local")
  2512. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2513. // if err != nil {
  2514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2515. // return
  2516. // }
  2517. // recordStartTime := theStartTime.Unix()
  2518. // start_time = recordStartTime
  2519. //
  2520. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2521. // if err != nil {
  2522. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2523. // return
  2524. // }
  2525. // recordEndTime := theEndTime.Unix()
  2526. // end_time = recordEndTime
  2527. //
  2528. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  2529. // }
  2530. //
  2531. // var ids []int64
  2532. // for _, item := range prescriptions {
  2533. // ids = append(ids, item.ID)
  2534. // }
  2535. //
  2536. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2537. //
  2538. // adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2539. //
  2540. // adminRole, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2541. // his, err := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2542. // mz_number := his.Number
  2543. // number := miConfig.Code + year + month + day +
  2544. // fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  2545. // var doctor_name string
  2546. // var doctor_code string
  2547. // var drug_doctor_code string
  2548. // drug_doctor_code = adminRole_two.DoctorCode
  2549. // drug_doctor_name := adminRole_two.UserName
  2550. //
  2551. // if adminRole.ID == 0 {
  2552. // doctor_name = "黄亦轩"
  2553. // doctor_code = "1"
  2554. // } else {
  2555. // doctor_name = adminRole.UserName
  2556. // doctor_code = strconv.FormatInt(admin_user_id, 10)
  2557. // }
  2558. //
  2559. // verifyCode, version_code := ReadCardGetCode("FY001" + "|" + number + "|" + miConfig.Code)
  2560. // //verifyCode := "000000|bf885fa312a7f92861d6b61542a637fa"
  2561. // //version_code := "V0.3"
  2562. // var customs []*models.CustomDetail
  2563. // for _, item := range prescriptions {
  2564. // if item.Type == 1 { //药品
  2565. // for _, subItem := range item.HisDoctorAdviceInfo {
  2566. // fmt.Println(subItem.BaseDrugLib.MedicalInsuranceNumber)
  2567. //
  2568. // if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2569. // _, dose_code := service.GetDoseCode(subItem.BaseDrugLib.DrugDosageForm, adminUser.CurrentOrgId)
  2570. // detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber), 64)
  2571. // price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  2572. // temp := strings.Split(subItem.FeedetlSn, "-")
  2573. // newFl := fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) + "-" + temp[1] + "-" + temp[2]
  2574. //
  2575. // cus := &models.CustomDetail{
  2576. // PrescriptionNumber: chrg_bchno,
  2577. // OrderType: "1",
  2578. // ChargeSerialNumber: newFl,
  2579. // Code: subItem.BaseDrugLib.MedicalInsuranceNumber,
  2580. // CodeName: subItem.BaseDrugLib.DrugName,
  2581. // Flag: "1",
  2582. // Price: price,
  2583. // Count: subItem.PrescribingNumber,
  2584. // ChargeOrderDate: year + month + day,
  2585. // DoctorCode: doctor_code,
  2586. // Total: detItemFeeSumamt,
  2587. // DoseCode: dose_code,
  2588. // Spec: subItem.BaseDrugLib.DrugSpec,
  2589. // }
  2590. // customs = append(customs, cus)
  2591. // }
  2592. // }
  2593. // }
  2594. //
  2595. // if item.Type == 2 { //项目
  2596. // for _, subItem := range item.HisPrescriptionProject {
  2597. // if len(subItem.HisProject.MedicalCode) > 0 {
  2598. // detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)), 64)
  2599. //
  2600. // count, _ := strconv.ParseFloat(fmt.Sprintf("%f", subItem.Count), 64)
  2601. // temp := strings.Split(subItem.FeedetlSn, "-")
  2602. // newFl := fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) + "-" + temp[1] + "-" + temp[2]
  2603. //
  2604. // cus := &models.CustomDetail{
  2605. // PrescriptionNumber: chrg_bchno,
  2606. // OrderType: "1",
  2607. // ChargeSerialNumber: newFl,
  2608. // Code: subItem.HisProject.MedicalCode,
  2609. // CodeName: subItem.HisProject.ProjectName,
  2610. // Flag: "1",
  2611. // Price: subItem.Price,
  2612. // Count: count,
  2613. // ChargeOrderDate: year + month + day,
  2614. // DoctorCode: doctor_code,
  2615. // Total: detItemFeeSumamt,
  2616. // DoseCode: "",
  2617. // Spec: "次",
  2618. // }
  2619. // customs = append(customs, cus)
  2620. // }
  2621. // }
  2622. // }
  2623. // //
  2624. // //for _, subItem := range item.HisAdditionalCharge {
  2625. // // if len(subItem.XtHisAddtionConfig.Code) > 0 {
  2626. // // detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)), 64)
  2627. // //
  2628. // // count, _ := strconv.ParseFloat(fmt.Sprintf("%f", subItem.Count), 64)
  2629. // // cus := &models.CustomDetail{
  2630. // // PrescriptionNumber: chrg_bchno,
  2631. // // OrderType: "1",
  2632. // // ChargeSerialNumber: subItem.FeedetlSn,
  2633. // // Code: subItem.XtHisAddtionConfig.Code,
  2634. // // CodeName: subItem.XtHisAddtionConfig.Name,
  2635. // // Flag: "1",
  2636. // // Price: subItem.Price,
  2637. // // Count: count,
  2638. // // ChargeOrderDate: year + month + day,
  2639. // // DoctorCode: doctor_code,
  2640. // // Total: detItemFeeSumamt,
  2641. // // DoseCode: "",
  2642. // // Spec: subItem.XtHisAddtionConfig.,
  2643. // // }
  2644. // // customs = append(customs, cus)
  2645. // // }
  2646. // //}
  2647. // }
  2648. //
  2649. // var pagesize int = 50
  2650. // var start int = 1
  2651. // var stop int
  2652. // var pagecount int
  2653. // var curpage int
  2654. // var isSuccess bool = true
  2655. // //总页数,向上取整,注意除之前要先转换类型为float64
  2656. // pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  2657. //
  2658. // var ress []*Result
  2659. // for curpage = 1; curpage <= pagecount; curpage++ {
  2660. // if curpage == 1 {
  2661. // start = 1
  2662. // } else {
  2663. // start = (curpage-1)*pagesize + 1
  2664. // }
  2665. // stop = curpage * pagesize
  2666. // if stop > len(customs) {
  2667. // stop = len(customs)
  2668. // }
  2669. // result := service.SzybFY001(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop], verifyCode, number, mz_number, version_code, drug_doctor_code)
  2670. // fmt.Println(result)
  2671. //
  2672. // var dat map[string]interface{}
  2673. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2674. // fmt.Println(dat)
  2675. // } else {
  2676. // fmt.Println(err)
  2677. // }
  2678. //
  2679. // userJSONBytes, _ := json.Marshal(dat)
  2680. //
  2681. // var res Result
  2682. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2683. // utils.ErrorLog("解析失败:%v", err)
  2684. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2685. // return
  2686. // }
  2687. // if res.Transreturncode == "00000000" {
  2688. // ress = append(ress, &res)
  2689. // } else {
  2690. // isSuccess = false
  2691. // errlog := &models.HisOrderError{
  2692. // UserOrgId: adminUser.CurrentOrgId,
  2693. // Ctime: time.Now().Unix(),
  2694. // Mtime: time.Now().Unix(),
  2695. // Number: chrg_bchno,
  2696. // ErrMsg: res.Transreturnmessage,
  2697. // Status: 1,
  2698. // PatientId: patient_id,
  2699. // RecordTime: recordDateTime,
  2700. // Stage: 4,
  2701. // }
  2702. // service.CreateErrMsgLog(errlog)
  2703. // c.ServeSuccessJSON(map[string]interface{}{
  2704. // "failed_code": -10,
  2705. // "msg": res.Transreturnmessage,
  2706. // })
  2707. // return
  2708. // }
  2709. // //设置变量,根据变量的值来判断上传是否成功
  2710. // }
  2711. // if isSuccess == true {
  2712. // order := &models.HisOrder{
  2713. // UserOrgId: adminUser.CurrentOrgId,
  2714. // HisPatientId: 0,
  2715. // PatientId: patient_id,
  2716. // SettleAccountsDate: recordDateTime,
  2717. // Ctime: time.Now().Unix(),
  2718. // Mtime: time.Now().Unix(),
  2719. // Status: 1,
  2720. // Number: chrg_bchno,
  2721. // Infcode: 0,
  2722. // WarnMsg: "",
  2723. // Cainfo: "",
  2724. // ErrMsg: "",
  2725. // RespondTime: "",
  2726. // InfRefmsgid: "",
  2727. // OrderStatus: 1,
  2728. // IsMedicineInsurance: 1,
  2729. // SettleType: settle_accounts_type,
  2730. // SettleStartTime: start_time,
  2731. // SettleEndTime: end_time,
  2732. // Creator: admin_user_id,
  2733. // Modify: admin_user_id,
  2734. // OrgSetlNumber: number,
  2735. // }
  2736. // data, _ := json.Marshal(ress)
  2737. // order.DetailLog = string(data)
  2738. //
  2739. // err = service.CreateOrder(order)
  2740. // if err != nil {
  2741. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2742. // return
  2743. // }
  2744. //
  2745. // for _, subItem := range ress {
  2746. // for _, item := range subItem.Transbody.Outputlist {
  2747. //
  2748. // temp := strings.Split(item.Bkf500, "-")
  2749. // var advice_id int64 = 0
  2750. // var project_id int64 = 0
  2751. // var types int64 = 0
  2752. //
  2753. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  2754. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  2755. //
  2756. // if temp[1] == "1" {
  2757. // advice_id = id
  2758. // project_id = 0
  2759. // } else if temp[1] == "2" {
  2760. // advice_id = 0
  2761. // project_id = id
  2762. // }
  2763. //
  2764. // info := &models.HisOrderInfo{
  2765. // OrderNumber: order.Number,
  2766. // FeedetlSn: item.Bkf500,
  2767. // UploadDate: time.Now().Unix(),
  2768. // AdviceId: advice_id,
  2769. // DetItemFeeSumamt: item.Akc264,
  2770. // Cnt: item.Akc226,
  2771. // Pric: float64(item.Akc225),
  2772. // PatientId: patient_id,
  2773. // Status: 1,
  2774. // ChrgitmLv: item.Aka065,
  2775. // Mtime: time.Now().Unix(),
  2776. // Ctime: time.Now().Unix(),
  2777. // UserOrgId: adminUser.CurrentOrgId,
  2778. // OrderId: order.ID,
  2779. // ProjectId: project_id,
  2780. // Type: types,
  2781. //
  2782. // OverPricPsnPay: item.Akc268,
  2783. // AllowReimburse: item.Cka319,
  2784. // }
  2785. // service.CreateOrderInfo(info)
  2786. //
  2787. // }
  2788. // }
  2789. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2790. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patient_id, chrg_bchno, recordDateTime)
  2791. // var total float64
  2792. // for _, item := range prescriptions {
  2793. // if item.Type == 1 { //药品
  2794. // for _, subItem := range item.HisDoctorAdviceInfo {
  2795. // total = total + (subItem.Price * subItem.PrescribingNumber)
  2796. // }
  2797. // }
  2798. // if item.Type == 2 { //项目
  2799. // for _, subItem := range item.HisPrescriptionProject {
  2800. // total = total + (subItem.Price * float64(subItem.Count))
  2801. // }
  2802. // }
  2803. // }
  2804. // for _, item := range prescriptions {
  2805. // for _, subItem := range item.HisAdditionalCharge {
  2806. // total = total + (subItem.Price * float64(subItem.Count))
  2807. // }
  2808. // }
  2809. //
  2810. // yiliao_number, id_card_number, verifyCode, version_code, _, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code + "|")
  2811. // if ret4 == 0 {
  2812. // //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  2813. // tempPatient, _ := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
  2814. // if tempPatient.ID == patient_id {
  2815. //
  2816. // 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)
  2817. // var dat map[string]interface{}
  2818. // if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
  2819. // fmt.Println(dat)
  2820. // } else {
  2821. // fmt.Println(err)
  2822. // }
  2823. // userJSONBytes, _ := json.Marshal(dat)
  2824. // var res ResultTwo
  2825. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2826. // utils.ErrorLog("解析失败:%v", err)
  2827. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2828. // return
  2829. // }
  2830. //
  2831. // if res.Transreturncode == "00000000" {
  2832. // order.OrderStatus = 2
  2833. // order.PayWay = pay_way
  2834. // order.PayPrice = pay_price
  2835. // order.PayCardNo = pay_card_no
  2836. // order.DiscountPrice = discount_price
  2837. // order.PreferentialPrice = preferential_price
  2838. // order.RealityPrice = reality_price
  2839. // order.FoundPrice = found_price
  2840. // order.MedicalInsurancePrice = medical_insurance_price
  2841. // order.PrivatePrice = private_price
  2842. // order.Modify = admin_user_id
  2843. // order.MedfeeSumamt = res.Transbody.Akc264
  2844. // order.SetlId = res.Transbody.Ckc618
  2845. // order.FundPaySumamt = res.Transbody.Akb068
  2846. // order.AcctPay = res.Transbody.Akb066
  2847. // order.PsnCashPay = res.Transbody.Akb067
  2848. // order.PsnPartAmt = res.Transbody.Akb067
  2849. // order.AccountPrice = res.Transbody.Aae240
  2850. // order.MzNumber = mz_number
  2851. // order.YiliaoNumber = yiliao_number
  2852. // setlDetailOne, _ := json.Marshal(res.Transbody.Outputlist1)
  2853. // detailStrOne := string(setlDetailOne)
  2854. // order.SzChargeInfo = detailStrOne
  2855. // setlDetailTwo, _ := json.Marshal(res.Transbody.Outputlist2)
  2856. // detailStrTwo := string(setlDetailTwo)
  2857. // order.SzProjectInfo = detailStrTwo
  2858. // setlDetailThree, _ := json.Marshal(res.Transbody.Outputlist3)
  2859. // detailStrThree := string(setlDetailThree)
  2860. // order.SzMedicineInsuranceInfo = detailStrThree
  2861. // order.Cainfo = result_three
  2862. // err = service.UpdataOrderStatusTwo(order.Number, adminUser.CurrentOrgId)
  2863. // err = service.UpDateOrderTwo(order)
  2864. // c.ServeSuccessJSON(map[string]interface{}{
  2865. // "msg": "结算成功",
  2866. // })
  2867. // } else {
  2868. // //结算报错
  2869. // errlog := &models.HisOrderError{
  2870. // UserOrgId: adminUser.CurrentOrgId,
  2871. // Ctime: time.Now().Unix(),
  2872. // Mtime: time.Now().Unix(),
  2873. // Number: chrg_bchno,
  2874. // ErrMsg: res.Transreturnmessage,
  2875. // Status: 1,
  2876. // PatientId: patient_id,
  2877. // RecordTime: recordDateTime,
  2878. // Stage: 6,
  2879. // }
  2880. // service.CreateErrMsgLog(errlog)
  2881. // c.ServeSuccessJSON(map[string]interface{}{
  2882. // "failed_code": -10,
  2883. // "msg": res.Transreturnmessage,
  2884. // })
  2885. // }
  2886. // } else {
  2887. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2888. // return
  2889. // }
  2890. // } else {
  2891. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2892. // return
  2893. // }
  2894. // } else {
  2895. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
  2896. // return
  2897. // }
  2898. //}
  2899. //结算
  2900. //func (c *SZHisApiController) GetSettleInfo() {
  2901. // patient_id, _ := c.GetInt64("id")
  2902. // order_id, _ := c.GetInt64("order_id")
  2903. // record_time := c.GetString("record_time")
  2904. // pay_way, _ := c.GetInt64("pay_way")
  2905. // pay_price, _ := c.GetFloat("pay_price")
  2906. // pay_card_no := c.GetString("pay_card_no")
  2907. // discount_price, _ := c.GetFloat("discount_price")
  2908. // preferential_price, _ := c.GetFloat("preferential_price")
  2909. // reality_price, _ := c.GetFloat("reality_price")
  2910. // found_price, _ := c.GetFloat("found_price")
  2911. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  2912. // private_price, _ := c.GetFloat("private_price")
  2913. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2914. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2915. //
  2916. // timeLayout := "2006-01-02"
  2917. // loc, _ := time.LoadLocation("Local")
  2918. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2919. // if err != nil {
  2920. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2921. // return
  2922. // }
  2923. // recordDateTime := theTime.Unix()
  2924. // adminUser := c.GetAdminUserInfo()
  2925. //
  2926. // var prescriptions []*models.HisPrescription
  2927. //
  2928. // data := make(map[string]interface{})
  2929. // if settle_accounts_type == 1 { //日结
  2930. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2931. // data["pre"] = prescriptions
  2932. //
  2933. // } else { //月结
  2934. // start_time_str := c.GetString("start_time")
  2935. // end_time_str := c.GetString("end_time")
  2936. // timeLayout := "2006-01-02"
  2937. // loc, _ := time.LoadLocation("Local")
  2938. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2939. // if err != nil {
  2940. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2941. // return
  2942. // }
  2943. // recordStartTime := theStartTime.Unix()
  2944. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2945. // if err != nil {
  2946. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2947. // return
  2948. // }
  2949. // recordEndTime := theEndTime.Unix()
  2950. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  2951. // data["pre"] = prescriptions
  2952. //
  2953. // }
  2954. //
  2955. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2956. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2957. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2958. // strconv.FormatInt(his.PatientId, 10)
  2959. //
  2960. // order_src, _ := service.GetHisOrderByID(order_id)
  2961. //
  2962. // if order_src.ID == 0 {
  2963. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2964. // return
  2965. // }
  2966. //
  2967. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2968. // if config.IsOpen == 1 { //对接了医保,走医保流程
  2969. // if order_src.OrderStatus != 2 {
  2970. // var total float64
  2971. // for _, item := range prescriptions {
  2972. // if item.Type == 1 { //药品
  2973. // for _, subItem := range item.HisDoctorAdviceInfo {
  2974. // total = total + (subItem.Price * subItem.PrescribingNumber)
  2975. // }
  2976. // }
  2977. // if item.Type == 2 { //项目
  2978. // for _, subItem := range item.HisPrescriptionProject {
  2979. // total = total + (subItem.Price * float64(subItem.Count))
  2980. // }
  2981. // }
  2982. // }
  2983. //
  2984. // for _, item := range prescriptions {
  2985. // for _, subItem := range item.HisAdditionalCharge {
  2986. // total = total + (subItem.Price * float64(subItem.Count))
  2987. // }
  2988. // }
  2989. //
  2990. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2991. //
  2992. // adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2993. //
  2994. // var drug_doctor string
  2995. // drug_doctor = adminRole_two.DoctorCode
  2996. // drug_doctor_name := adminRole_two.UserName
  2997. // //结算流程
  2998. // var doctor_name string
  2999. // var doctor_code string
  3000. // if roles.ID == 0 {
  3001. // doctor_name = "黄亦轩"
  3002. // doctor_code = "1010"
  3003. // } else {
  3004. // doctor_name = roles.UserName
  3005. // doctor_code = strconv.FormatInt(admin_user_id, 10)
  3006. // }
  3007. // number := order_src.OrgSetlNumber
  3008. // mz_number := his.Number
  3009. // verifyCode, version_code := ReadCardGetCode("FY005" + "|" + number + "|" + miConfig.Code)
  3010. //
  3011. // //verifyCode := "000000|707c35a62c2f0609d7b0a811649f3913"
  3012. // //version_code := "V0.3"
  3013. // yiliao_number, id_card_number, verifyCode, version_code, err, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code)
  3014. // yiliao_number := his.YiliaoNumber
  3015. // result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor, drug_doctor_name)
  3016. // var dat map[string]interface{}
  3017. // if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
  3018. // fmt.Println(dat)
  3019. // } else {
  3020. // fmt.Println(err)
  3021. // }
  3022. // userJSONBytes, _ := json.Marshal(dat)
  3023. // var res ResultTwo
  3024. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3025. // utils.ErrorLog("解析失败:%v", err)
  3026. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3027. // return
  3028. // }
  3029. //
  3030. // if res.Transreturncode == "00000000" {
  3031. // order_src.OrderStatus = 2
  3032. // order_src.PayWay = pay_way
  3033. // order_src.PayPrice = pay_price
  3034. // order_src.PayCardNo = pay_card_no
  3035. // order_src.DiscountPrice = discount_price
  3036. // order_src.PreferentialPrice = preferential_price
  3037. // order_src.RealityPrice = reality_price
  3038. // order_src.FoundPrice = found_price
  3039. // order_src.MedicalInsurancePrice = medical_insurance_price
  3040. // order_src.PrivatePrice = private_price
  3041. // order_src.Creator = order_src.Creator
  3042. // order_src.Modify = roles.ID
  3043. // order_src.MedfeeSumamt = res.Transbody.Akc264
  3044. // order_src.SetlId = res.Transbody.Ckc618
  3045. // order_src.FundPaySumamt = res.Transbody.Akb068
  3046. // order_src.AcctPay = res.Transbody.Akb066
  3047. // order_src.PsnCashPay = res.Transbody.Akb067
  3048. // order_src.PsnPartAmt = res.Transbody.Akb067
  3049. // order_src.AccountPrice = res.Transbody.Aae240
  3050. // order_src.MzNumber = mz_number
  3051. // order_src.YiliaoNumber = yiliao_number
  3052. // setlDetailOne, _ := json.Marshal(res.Transbody.Outputlist1)
  3053. // detailStrOne := string(setlDetailOne)
  3054. // order_src.SzChargeInfo = detailStrOne
  3055. // setlDetailTwo, _ := json.Marshal(res.Transbody.Outputlist2)
  3056. // detailStrTwo := string(setlDetailTwo)
  3057. // order_src.SzProjectInfo = detailStrTwo
  3058. // setlDetailThree, _ := json.Marshal(res.Transbody.Outputlist3)
  3059. // detailStrThree := string(setlDetailThree)
  3060. // order_src.SzMedicineInsuranceInfo = detailStrThree
  3061. // order_src.Cainfo = result_three
  3062. //
  3063. // err = service.UpdataOrderStatusTwo(order_src.Number, adminUser.CurrentOrgId)
  3064. // err = service.UpDateOrder(order_src)
  3065. //
  3066. // c.ServeSuccessJSON(map[string]interface{}{
  3067. // "msg": "结算成功",
  3068. // })
  3069. // } else {
  3070. // //version_code := "0.03"
  3071. // c.ServeSuccessJSON(map[string]interface{}{
  3072. // "failed_code": -10,
  3073. // "msg": res.Transreturnmessage,
  3074. // })
  3075. //
  3076. // }
  3077. // } else {
  3078. //
  3079. // //错误提示
  3080. //
  3081. // }
  3082. // } else {
  3083. // //错误提示
  3084. //
  3085. // }
  3086. //}
  3087. //当月退费
  3088. func (c *SZHisApiController) Refund() {
  3089. order_id, _ := c.GetInt64("order_id")
  3090. record_time := c.GetString("record_time")
  3091. patient_id, _ := c.GetInt64("patient_id")
  3092. admin_user_id, _ := c.GetInt64("admin_user_id")
  3093. timeLayout := "2006-01-02"
  3094. loc, _ := time.LoadLocation("Local")
  3095. adminUser := c.GetAdminUserInfo()
  3096. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3097. fmt.Println(err)
  3098. if err != nil {
  3099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3100. return
  3101. }
  3102. recordDateTime := theTime.Unix()
  3103. fmt.Println(recordDateTime)
  3104. var order models.HisOrder
  3105. order, _ = service.GetHisOrderByID(order_id)
  3106. if order.ID == 0 {
  3107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3108. return
  3109. }
  3110. his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, theTime.Unix())
  3111. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3112. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3113. //结算流程
  3114. var doctor_name string
  3115. var doctor_code string
  3116. if roles.ID == 0 {
  3117. doctor_name = "管理员"
  3118. doctor_code = "01"
  3119. } else {
  3120. doctor_name = roles.UserName
  3121. doctor_code = strconv.FormatInt(admin_user_id, 10)
  3122. }
  3123. month := time.Unix(1557042972, 0).Format("1")
  3124. year := time.Now().Format("2006")
  3125. month = time.Now().Format("01")
  3126. day := time.Now().Format("02")
  3127. //number := miConfig.Code + year + month + day + "1367866"
  3128. number := miConfig.Code + year + month + day +
  3129. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  3130. //number := miConfig.Code + year + month + day + "1590003"
  3131. //流水号
  3132. //number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  3133. verifyCode, version_code := ReadCardGetCode("JY002" + "|" + number + "|" + miConfig.Code)
  3134. //version_code := "V0.3"
  3135. //
  3136. //verifyCode := "000000|9972fca7ba9471c7dbe08324b2e31f70"
  3137. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3138. order_infos, _ := service.GetHisOrderInfoByNumber(order.Number)
  3139. var customs []*models.CustomDetail
  3140. for _, item := range order_infos {
  3141. cus := &models.CustomDetail{
  3142. PrescriptionNumber: item.OrderNumber,
  3143. ChargeSerialNumber: item.FeedetlSn,
  3144. }
  3145. customs = append(customs, cus)
  3146. }
  3147. if config.IsOpen == 1 { //对接了医保,走医保流程
  3148. result := service.SzybJY002(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, number, version_code)
  3149. fmt.Println(result)
  3150. var dat map[string]interface{}
  3151. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3152. fmt.Println(dat)
  3153. } else {
  3154. fmt.Println(err)
  3155. }
  3156. userJSONBytes, _ := json.Marshal(dat)
  3157. var res ResultThree
  3158. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3159. utils.ErrorLog("解析失败:%v", err)
  3160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3161. return
  3162. }
  3163. if res.Transreturncode == "00000000" {
  3164. service.UpdataOrderlog(order_id, adminUser.CurrentOrgId, result)
  3165. service.UpdataOrderStatusSZ(order_id, order.Number, adminUser.CurrentOrgId, his.MzNumber, his.Number)
  3166. service.UpdataOrderInfoStatus(order.ID, order.Number, adminUser.CurrentOrgId)
  3167. c.ServeSuccessJSON(map[string]interface{}{
  3168. "msg": "退费成功",
  3169. })
  3170. } else {
  3171. c.ServeSuccessJSON(map[string]interface{}{
  3172. "failed_code": -10,
  3173. "msg": res.Transreturnmessage,
  3174. })
  3175. }
  3176. }
  3177. }
  3178. //跨月退费
  3179. func (c *SZHisApiController) MonthRefund() {
  3180. order_id, _ := c.GetInt64("order_id")
  3181. record_time := c.GetString("record_time")
  3182. patient_id, _ := c.GetInt64("patient_id")
  3183. admin_user_id, _ := c.GetInt64("admin_user_id")
  3184. timeLayout := "2006-01-02"
  3185. loc, _ := time.LoadLocation("Local")
  3186. adminUser := c.GetAdminUserInfo()
  3187. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3188. fmt.Println(err)
  3189. if err != nil {
  3190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3191. return
  3192. }
  3193. recordDateTime := theTime.Unix()
  3194. var order models.HisOrder
  3195. order, _ = service.GetHisOrderByID(order_id)
  3196. if order.ID == 0 {
  3197. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  3198. }
  3199. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3200. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3201. //结算流程
  3202. var doctor_name string
  3203. var doctor_code string
  3204. if roles.ID == 0 {
  3205. doctor_name = "管理员"
  3206. doctor_code = "01"
  3207. } else {
  3208. doctor_name = roles.UserName
  3209. doctor_code = strconv.FormatInt(admin_user_id, 10)
  3210. }
  3211. month := time.Unix(1557042972, 0).Format("1")
  3212. year := time.Now().Format("2006")
  3213. month = time.Now().Format("01")
  3214. day := time.Now().Format("02")
  3215. //流水号
  3216. number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  3217. //verifyCode,version_code := ReadCardGetCode("JY002" + "|" + number_two + "|" + miConfig.Code)
  3218. version_code := "0.03"
  3219. fmt.Println(number_two)
  3220. verifyCode := "000000|0872038667cc34efdc35ce4668589a5f"
  3221. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3222. if config.IsOpen == 1 { //对接了医保,走医保流程
  3223. result := service.SzybJY003(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, version_code)
  3224. fmt.Println(result)
  3225. var dat map[string]interface{}
  3226. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3227. fmt.Println(dat)
  3228. } else {
  3229. fmt.Println(err)
  3230. }
  3231. userJSONBytes, _ := json.Marshal(dat)
  3232. var res ResultThree
  3233. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3234. utils.ErrorLog("解析失败:%v", err)
  3235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3236. return
  3237. }
  3238. if res.Transreturncode == "00000000" {
  3239. c.ServeSuccessJSON(map[string]interface{}{
  3240. "msg": "退费成功",
  3241. })
  3242. } else {
  3243. }
  3244. }
  3245. }
  3246. //查询
  3247. func (c *SZHisApiController) GetSettleAccounts() {
  3248. order_id, _ := c.GetInt64("order_id")
  3249. record_time := c.GetString("record_time")
  3250. patient_id, _ := c.GetInt64("patient_id")
  3251. admin_user_id, _ := c.GetInt64("admin_user_id")
  3252. timeLayout := "2006-01-02"
  3253. loc, _ := time.LoadLocation("Local")
  3254. adminUser := c.GetAdminUserInfo()
  3255. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3256. fmt.Println(err)
  3257. if err != nil {
  3258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3259. return
  3260. }
  3261. recordDateTime := theTime.Unix()
  3262. fmt.Println(recordDateTime)
  3263. var order models.HisOrder
  3264. order, _ = service.GetHisOrderByID(order_id)
  3265. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  3266. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, order.SettleAccountsDate)
  3267. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3268. his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, order.SettleAccountsDate)
  3269. yiliao_leibie := ""
  3270. switch his.MedicalTreatmentType {
  3271. case 11:
  3272. yiliao_leibie = "普通门诊"
  3273. break
  3274. case 12:
  3275. yiliao_leibie = "家庭通道"
  3276. break
  3277. case 13:
  3278. yiliao_leibie = "门诊大病"
  3279. break
  3280. case 14:
  3281. yiliao_leibie = "重疾特药"
  3282. break
  3283. case 15:
  3284. yiliao_leibie = "门诊慢病"
  3285. break
  3286. case 16:
  3287. yiliao_leibie = "门诊特检"
  3288. break
  3289. case 17:
  3290. yiliao_leibie = "健康体检"
  3291. break
  3292. case 18:
  3293. yiliao_leibie = "预防接种"
  3294. break
  3295. case 19:
  3296. yiliao_leibie = "门诊输血"
  3297. break
  3298. case 91:
  3299. yiliao_leibie = "新冠肺炎门诊"
  3300. break
  3301. }
  3302. //departments, _ := service.Get(patientPrescription.Departments)
  3303. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3304. if order.ID == 0 {
  3305. //order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  3306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3307. return
  3308. }
  3309. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3310. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3311. //结算流程
  3312. var doctor_name string
  3313. var doctor_code string
  3314. if roles.ID == 0 {
  3315. doctor_name = "管理员"
  3316. doctor_code = "01"
  3317. } else {
  3318. doctor_name = roles.UserName
  3319. doctor_code = strconv.FormatInt(admin_user_id, 10)
  3320. }
  3321. //month := time.Unix(1557042972, 0).Format("1")
  3322. //year := time.Now().Format("2006")
  3323. //month = time.Now().Format("01")
  3324. //day := time.Now().Format("02")
  3325. //流水号
  3326. //number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  3327. //fmt.Println(number_two)
  3328. verifyCode, version_code := ReadCardGetCode("JY001" + "|" + order.OrgSetlNumber + "|" + miConfig.Code)
  3329. //version_code := "V0.3"
  3330. //verifyCode := "000000|2c9854287e7c3cbc34439ab8e5157816"
  3331. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3332. if config.IsOpen == 1 { //对接了医保,走医保流程
  3333. result := service.SzybJY001(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, version_code)
  3334. fmt.Println(result)
  3335. var dat map[string]interface{}
  3336. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3337. fmt.Println(dat)
  3338. } else {
  3339. fmt.Println(err)
  3340. }
  3341. userJSONBytes, _ := json.Marshal(dat)
  3342. var res ResultFour
  3343. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3344. utils.ErrorLog("解析失败:%v", err)
  3345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3346. return
  3347. }
  3348. if res.Transreturncode == "00000000" {
  3349. var dat2 map[string]interface{}
  3350. if err := json.Unmarshal([]byte(his.PatientInfo), &dat2); err == nil {
  3351. fmt.Println(dat2)
  3352. } else {
  3353. fmt.Println(err)
  3354. }
  3355. userJSONBytes2, _ := json.Marshal(dat2)
  3356. var res2 ResultMZ001
  3357. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3358. utils.ErrorLog("解析失败:%v", err)
  3359. }
  3360. c.ServeSuccessJSON(map[string]interface{}{
  3361. "result": res,
  3362. "org_name": miConfig.OrgName,
  3363. "org_code": miConfig.Code,
  3364. "patient_name": patient.Name,
  3365. "doctor_code": adminRole_two.DoctorCode,
  3366. "doctor_name": doctor_name,
  3367. "health_card_no": order.PsnNo,
  3368. "health_card_no_two": res2.Transbody.Aaz500,
  3369. "order_number": order.Number,
  3370. "department": departments.Name,
  3371. "yiliao_leibie": yiliao_leibie,
  3372. "before_money": res2.Transbody.Aae240,
  3373. "after_money": order.AccountPrice,
  3374. })
  3375. } else {
  3376. c.ServeSuccessJSON(map[string]interface{}{
  3377. "failed_code": -10,
  3378. "msg": res.Transreturnmessage,
  3379. })
  3380. }
  3381. }
  3382. }
  3383. //费用录入取消
  3384. func (c *SZHisApiController) CancelOrderDetail() {
  3385. order_id, _ := c.GetInt64("order_id")
  3386. record_time := c.GetString("record_time")
  3387. patient_id, _ := c.GetInt64("patient_id")
  3388. admin_user_id, _ := c.GetInt64("admin_user_id")
  3389. timeLayout := "2006-01-02"
  3390. loc, _ := time.LoadLocation("Local")
  3391. adminUser := c.GetAdminUserInfo()
  3392. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3393. fmt.Println(err)
  3394. if err != nil {
  3395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3396. return
  3397. }
  3398. recordDateTime := theTime.Unix()
  3399. var order models.HisOrder
  3400. order, _ = service.GetHisOrderByID(order_id)
  3401. if order.ID == 0 {
  3402. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  3403. }
  3404. order_infos, _ := service.GetHisOrderInfoByNumber(order.Number)
  3405. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3406. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3407. //结算流程
  3408. var doctor_name string
  3409. var doctor_code string
  3410. if roles.ID == 0 {
  3411. doctor_name = "管理员"
  3412. doctor_code = "1001"
  3413. } else {
  3414. doctor_name = roles.UserName
  3415. doctor_code = strconv.FormatInt(admin_user_id, 10)
  3416. }
  3417. var customs []*models.CustomDetail
  3418. for _, item := range order_infos {
  3419. cus := &models.CustomDetail{
  3420. PrescriptionNumber: item.OrderNumber,
  3421. ChargeSerialNumber: item.FeedetlSn,
  3422. }
  3423. customs = append(customs, cus)
  3424. }
  3425. his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3426. verifyCode, version_code := ReadCardGetCode("FY002" + "|" + order.OrgSetlNumber + "|" + miConfig.Code)
  3427. var pagesize int = 50
  3428. var start int = 1
  3429. var stop int
  3430. var pagecount int
  3431. var curpage int
  3432. var isSuccess bool = true
  3433. var ress []*ResultFive
  3434. //总页数,向上取整,注意除之前要先转换类型为float64
  3435. pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  3436. for curpage = 1; curpage <= pagecount; curpage++ {
  3437. if curpage == 1 {
  3438. start = 1
  3439. } else {
  3440. start = (curpage-1)*pagesize + 1
  3441. }
  3442. stop = curpage * pagesize
  3443. if stop > len(customs) {
  3444. stop = len(customs)
  3445. }
  3446. result := service.SzybFY002(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop], verifyCode, order.OrgSetlNumber, his.Number, version_code)
  3447. fmt.Println(result)
  3448. var dat map[string]interface{}
  3449. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3450. fmt.Println(dat)
  3451. } else {
  3452. fmt.Println(err)
  3453. }
  3454. userJSONBytes, _ := json.Marshal(dat)
  3455. var res ResultFive
  3456. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3457. utils.ErrorLog("解析失败:%v", err)
  3458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3459. return
  3460. }
  3461. if res.Transreturncode == "00000000" {
  3462. ress = append(ress, &res)
  3463. } else {
  3464. isSuccess = false
  3465. //预结算报错
  3466. errlog := &models.HisOrderError{
  3467. UserOrgId: adminUser.CurrentOrgId,
  3468. Ctime: time.Now().Unix(),
  3469. Mtime: time.Now().Unix(),
  3470. ErrMsg: res.Transreturnmessage,
  3471. Status: 1,
  3472. PatientId: patient_id,
  3473. RecordTime: recordDateTime,
  3474. Stage: 11,
  3475. }
  3476. service.CreateErrMsgLog(errlog)
  3477. c.ServeSuccessJSON(map[string]interface{}{
  3478. "faild_code": -10,
  3479. "msg": res.Transreturnmessage,
  3480. })
  3481. return
  3482. }
  3483. }
  3484. if isSuccess == true {
  3485. service.UpdataOrderInfoStatus(order.ID, order.Number, adminUser.CurrentOrgId)
  3486. c.ServeSuccessJSON(map[string]interface{}{
  3487. "msg": "撤销成功",
  3488. })
  3489. }
  3490. }
  3491. //获取verifyCode
  3492. func ReadCardGetCode(request string) (string, string) {
  3493. request = request + "|"
  3494. DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
  3495. readCards := DllDef2.MustFindProc("iVerifyCode")
  3496. str := request
  3497. str3 := make([]byte, 256)
  3498. ret4, _, _ := readCards.Call(StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  3499. fmt.Println(":", string(str3))
  3500. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  3501. if ret4 == 0 {
  3502. result := string(str3)
  3503. fmt.Println(result)
  3504. result_arr := strings.Split(result, "|")
  3505. verifyCode := result_arr[0] + "|" + result_arr[1]
  3506. versionCode := result_arr[2]
  3507. return verifyCode, versionCode
  3508. }
  3509. return "", ""
  3510. }
  3511. ////获取卡信息
  3512. func ReadBasCardGetNumber(request string) (string, string, string, string, string, error, int64) {
  3513. DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
  3514. readCards := DllDef2.MustFindProc("iReadCardBas")
  3515. str := request
  3516. str3 := make([]byte, 1024)
  3517. fmt.Println(":", request)
  3518. fmt.Println(":", StrPtr(str))
  3519. ret4, _, err := readCards.Call(IntPtr(1), StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  3520. fmt.Println(":", string(str3))
  3521. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  3522. if ret4 == 0 {
  3523. result := string(str3)
  3524. fmt.Println(result)
  3525. result_arr := strings.Split(result, "|")
  3526. //医疗证号
  3527. yiliao_number := result_arr[12]
  3528. //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  3529. id_card_number := result_arr[1]
  3530. verifyCode := result_arr[11] + "|" + result_arr[13]
  3531. versionCode := result_arr[14]
  3532. health_card_no := result_arr[2]
  3533. return yiliao_number, id_card_number, verifyCode, versionCode, health_card_no, err, 0
  3534. }
  3535. return "", "", "", "", "", err, -10
  3536. }
  3537. //读卡
  3538. func ReadBasCard(request string) (string, string, error, int64) {
  3539. DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
  3540. readCards := DllDef2.MustFindProc("iReadCardBas")
  3541. str := request
  3542. str3 := make([]byte, 1024)
  3543. ret4, _, err := readCards.Call(IntPtr(1), StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  3544. fmt.Println(":", string(str3))
  3545. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  3546. if ret4 == 0 {
  3547. result := string(str3)
  3548. result_arr := strings.Split(result, "|")
  3549. //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  3550. id_card_number := result_arr[1]
  3551. health_card_no := result_arr[2]
  3552. return id_card_number, health_card_no, err, 0
  3553. }
  3554. return "", "", err, -10
  3555. }
  3556. //
  3557. ////iReadCardBas_HSM_Step1 ---- 1903 iCardInnerAuthentication --- iReadCardBas_HSM_Step2
  3558. //func ReadCardBasHSM(number string) string {
  3559. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  3560. // readCards := DllDef2.MustFindProc("iReadCardBas_HSM_Step1")
  3561. // str := make([]byte, 256)
  3562. // ret, _, _ := readCards.Call(IntPtr(3), (uintptr)(unsafe.Pointer(&str[0])))
  3563. // fmt.Println(":", string(str))
  3564. //
  3565. // result_arr := strings.Split(string(str), "|")
  3566. //
  3567. // if ret == 0 {
  3568. // readCards := DllDef2.MustFindProc("iCardInnerAuthentication")
  3569. // str2 := make([]byte, 256)
  3570. // str3 := "" + "|" + "" + "|" + "440300" + "|" + "" + "|" + "" + "|" + result_arr[1] + "|" + result_arr[2] + "|" + result_arr[3] + "|" + result_arr[4] + "|" + result_arr[5] + "|" + "" + "|" + "" + "|"
  3571. // ret2, _, _ := readCards.Call(StrPtr(str3), (uintptr)(unsafe.Pointer(&str2[0])))
  3572. // fmt.Println(":", string(str2))
  3573. //
  3574. // if ret2 == 0 {
  3575. // result_arr := strings.Split(string(str2), "|")
  3576. //
  3577. // if result_arr[2] == "0" {
  3578. // readCards := DllDef2.MustFindProc("iReadCardBas_HSM_Step2")
  3579. // str4 := result_arr[4] + "|" + result_arr[5]
  3580. // str5 := make([]byte, 256)
  3581. // ret3, _, _ := readCards.Call(StrPtr(str4), StrPtr(number), (uintptr)(unsafe.Pointer(&str5[0])))
  3582. //
  3583. // if ret3 == 0 {
  3584. // return string(str5)
  3585. //
  3586. // } else {
  3587. // return ""
  3588. // }
  3589. // } else {
  3590. // return ""
  3591. // }
  3592. // }
  3593. // return ""
  3594. // }
  3595. // return ""
  3596. //
  3597. //}
  3598. //
  3599. ////1904卡鉴权
  3600. //func CardAuth(request string) string {
  3601. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  3602. // readCards := DllDef2.MustFindProc("iCardAuthentication")
  3603. // str := request
  3604. // str3 := make([]byte, 256)
  3605. // ret4, _, _ := readCards.Call(StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  3606. // fmt.Println(":", string(str3))
  3607. //
  3608. // if ret4 == 0 {
  3609. // return string(str3)
  3610. // }
  3611. // return ""
  3612. //}
  3613. func (c *SZHisApiController) GetDrugList() {
  3614. adminUserInfo := c.GetAdminUserInfo()
  3615. orgId := adminUserInfo.CurrentOrgId
  3616. admin_user_id, _ := c.GetInt64("admin_user_id")
  3617. roles, _ := service.GetAdminUserInfoByID(orgId, admin_user_id)
  3618. ids := c.GetString("ids")
  3619. stringarr := strings.Split(ids, ",")
  3620. idss := make([]int64, 0)
  3621. for _, item := range stringarr {
  3622. itemsss, _ := strconv.ParseInt(item, 10, 64)
  3623. id := int64(itemsss)
  3624. idss = append(idss, id)
  3625. }
  3626. //批量获取
  3627. list, _ := service.GetBatchDrugList(idss)
  3628. //获取药品剂型
  3629. drugs, _ := service.GetDrugDosageForm(orgId)
  3630. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3631. var doctor_name string
  3632. var doctor_code string
  3633. doctor_name = roles.UserName
  3634. doctor_code = "1001"
  3635. var isSuccess bool = true
  3636. timeLayout := "20060102"
  3637. //这里就可以查看开始和结束了
  3638. for _, item := range list {
  3639. recordDate := time.Unix(item.RecordDate, 0).Format(timeLayout)
  3640. detail := &models.DrugDetail{
  3641. MedicalInsuranceNumber: item.SocialSecurityDirectoryCode,
  3642. Code: item.Code,
  3643. DrugName: item.DrugName,
  3644. DrugSpec: item.DrugSpec,
  3645. DrugDosageName: item.DrugDosageName,
  3646. ManufacturerName: item.ManufacturerName,
  3647. MinUnit: item.MinUnit,
  3648. RetailPrice: item.RetailPrice,
  3649. LastPrice: item.LastPrice,
  3650. LimitRemark: item.LimitRemark,
  3651. PrescriptionMark: strconv.FormatInt(item.PrescriptionMark, 10),
  3652. RecordDate: recordDate,
  3653. }
  3654. for _, it := range drugs {
  3655. if item.DrugDosageForm == it.Value {
  3656. detail.DrugDosageName = it.Code
  3657. }
  3658. }
  3659. result := service.SzybML008(doctor_name, doctor_code, miConfig.Code, detail)
  3660. var dat map[string]interface{}
  3661. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3662. //fmt.Println(dat)
  3663. } else {
  3664. //fmt.Println(err)
  3665. }
  3666. userJSONBytes, _ := json.Marshal(dat)
  3667. var res Result
  3668. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3669. utils.ErrorLog("解析失败:%v", err)
  3670. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3671. c.ServeSuccessJSON(map[string]interface{}{
  3672. "failed_code": -10,
  3673. "msg": res.Transreturnmessage,
  3674. })
  3675. return
  3676. }
  3677. if res.Transreturncode == "00000000" {
  3678. //更新备案状态
  3679. _, err := service.UpdateBaseDrugById(item.ID)
  3680. fmt.Println("err", err)
  3681. c.ServeSuccessJSON(map[string]interface{}{
  3682. "failed_code": -10,
  3683. "msg": res.Transreturnmessage,
  3684. })
  3685. return
  3686. }
  3687. fmt.Println(isSuccess)
  3688. c.ServeSuccessJSON(map[string]interface{}{
  3689. "failed_code": -10,
  3690. "msg": res.Transreturnmessage,
  3691. })
  3692. return
  3693. }
  3694. }
  3695. func (c *SZHisApiController) GetTreatmentProject() {
  3696. adminUserInfo := c.GetAdminUserInfo()
  3697. orgId := adminUserInfo.CurrentOrgId
  3698. ids := c.GetString("ids")
  3699. stringarr := strings.Split(ids, ",")
  3700. idss := make([]int64, 0)
  3701. admin_user_id, _ := c.GetInt64("admin_user_id")
  3702. roles, _ := service.GetAdminUserInfoByID(orgId, admin_user_id)
  3703. for _, item := range stringarr {
  3704. itemsss, _ := strconv.ParseInt(item, 10, 64)
  3705. id := int64(itemsss)
  3706. idss = append(idss, id)
  3707. }
  3708. //获取项目库数据
  3709. list, _ := service.GetBathchMyPorjecgList(idss)
  3710. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3711. var doctor_name string
  3712. var doctor_code string
  3713. doctor_name = roles.UserName
  3714. doctor_code = "1001"
  3715. var isSuccess bool = true
  3716. for _, item := range list {
  3717. detail := &models.MyHisProject{
  3718. MedicalCode: item.MedicalCode, //社保目录
  3719. ProjectName: item.ProjectName,
  3720. Price: item.Price,
  3721. Category: item.Category,
  3722. Remark: item.Remark,
  3723. SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
  3724. SpecailProject: item.SpecailProject,
  3725. RecordDate: item.RecordDate,
  3726. }
  3727. result := service.SzybML009(doctor_name, doctor_code, miConfig.Code, detail)
  3728. var dat map[string]interface{}
  3729. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3730. fmt.Println(dat)
  3731. } else {
  3732. fmt.Println(err)
  3733. }
  3734. userJSONBytes, _ := json.Marshal(dat)
  3735. var res Result
  3736. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3737. utils.ErrorLog("解析失败:%v", err)
  3738. c.ServeSuccessJSON(map[string]interface{}{
  3739. "failed_code": -10,
  3740. "msg": res.Transreturnmessage,
  3741. })
  3742. return
  3743. }
  3744. if res.Transreturncode == "00000000" {
  3745. //备案成功返回状态值
  3746. _, err := service.UpdateProjectById(item.ID)
  3747. fmt.Println("err", err)
  3748. } else {
  3749. isSuccess = false
  3750. //失败
  3751. c.ServeSuccessJSON(map[string]interface{}{
  3752. "failed_code": -10,
  3753. "msg": res.Transreturnmessage,
  3754. })
  3755. return
  3756. }
  3757. fmt.Println(isSuccess)
  3758. c.ServeSuccessJSON(map[string]interface{}{
  3759. "failed_code": -10,
  3760. "msg": res.Transreturnmessage,
  3761. })
  3762. return
  3763. }
  3764. }
  3765. func (c *SZHisApiController) GetRevocation() {
  3766. adminUserInfo := c.GetAdminUserInfo()
  3767. orgId := adminUserInfo.CurrentOrgId
  3768. id, _ := c.GetInt64("id")
  3769. admin_user_id, _ := c.GetInt64("admin_user_id")
  3770. roles, _ := service.GetAdminUserInfoByID(orgId, admin_user_id)
  3771. //用来区分是药品的撤销还是耗材的撤销 1.药品 2.诊疗项目 3.材料 5.辅助器具项目
  3772. is_mark, _ := c.GetInt64("is_mark")
  3773. type_id, _ := c.GetInt64("type_id")
  3774. if type_id == 1 {
  3775. //撤销
  3776. if is_mark == 1 {
  3777. //获取药品库数据
  3778. list, _ := service.GetDrugListByDetail(orgId, id)
  3779. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3780. var doctor_name string
  3781. var doctor_code string
  3782. doctor_name = roles.UserName
  3783. doctor_code = "1001"
  3784. var pagesize int = 50
  3785. var start int = 1
  3786. var stop int
  3787. var pagecount int
  3788. var curpage int
  3789. var isSuccess bool = true
  3790. //总页数,向上取整,注意除之前要先转换类型为float64
  3791. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  3792. for curpage = 1; curpage <= pagecount; curpage++ {
  3793. if curpage == 1 {
  3794. start = 1
  3795. } else {
  3796. start = (curpage-1)*pagesize + 1
  3797. }
  3798. stop = curpage * pagesize
  3799. if stop > len(list) {
  3800. stop = len(list)
  3801. }
  3802. //这里就可以查看开始和结束了
  3803. fmt.Println(list[start-1 : stop])
  3804. var customs []*models.DrugDetail
  3805. for _, item := range list {
  3806. detail := &models.DrugDetail{
  3807. SocialSecurityDirectoryCode: item.MedicalInsuranceNumber, //社保目录
  3808. Code: item.Code, //协议机构内部目录编码
  3809. DrugName: item.DrugName, //协议机构内部目录名称
  3810. DrugSpec: item.DrugSpec,
  3811. ManufacturerName: item.ManufacturerName,
  3812. MinUnit: item.MinUnit,
  3813. RetailPrice: item.RetailPrice, //协议机构内部项目收费价格
  3814. LimitRemark: item.LimitRemark,
  3815. MedicalInsuranceNumber: item.MedicalInsuranceNumber, //社保目录
  3816. }
  3817. customs = append(customs, detail)
  3818. }
  3819. result := service.SzybML010(doctor_name, doctor_code, miConfig.Code, customs, type_id)
  3820. fmt.Println("reuslt", result)
  3821. var dat map[string]interface{}
  3822. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3823. fmt.Println(dat)
  3824. } else {
  3825. fmt.Println(err)
  3826. }
  3827. userJSONBytes, _ := json.Marshal(dat)
  3828. var res Result
  3829. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3830. utils.ErrorLog("解析失败:%v", err)
  3831. c.ServeSuccessJSON(map[string]interface{}{
  3832. "failed_code": -10,
  3833. "msg": res.Transreturnmessage,
  3834. })
  3835. return
  3836. }
  3837. if res.Transreturncode == "00000000" {
  3838. //撤销成功
  3839. _, err := service.UpdateDrugByIdDetail(id)
  3840. fmt.Println("err", err)
  3841. } else {
  3842. isSuccess = false
  3843. //失败
  3844. c.ServeSuccessJSON(map[string]interface{}{
  3845. "failed_code": -10,
  3846. "msg": res.Transreturnmessage,
  3847. })
  3848. return
  3849. }
  3850. fmt.Println(isSuccess)
  3851. c.ServeSuccessJSON(map[string]interface{}{
  3852. "failed_code": -10,
  3853. "msg": res.Transreturnmessage,
  3854. })
  3855. return
  3856. }
  3857. }
  3858. // 备案
  3859. if is_mark == 0 {
  3860. adminUserInfo := c.GetAdminUserInfo()
  3861. orgId := adminUserInfo.CurrentOrgId
  3862. //获取药品库数据
  3863. list, _ := service.GetDrugListByDetail(orgId, id)
  3864. //获取药品剂型
  3865. drugs, _ := service.GetDrugDosageForm(orgId)
  3866. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3867. var doctor_name string
  3868. var doctor_code string
  3869. doctor_name = roles.UserName
  3870. doctor_code = "1001"
  3871. var isSuccess bool = true
  3872. //这里就可以查看开始和结束了
  3873. for _, item := range list {
  3874. detail := &models.DrugDetail{
  3875. MedicalInsuranceNumber: item.MedicalInsuranceNumber,
  3876. SocialSecurityDirectoryCode: item.MedicalInsuranceNumber,
  3877. Code: item.Code,
  3878. DrugName: item.DrugName,
  3879. DrugSpec: item.DrugSpec,
  3880. DrugDosageName: item.DrugDosageName,
  3881. ManufacturerName: item.ManufacturerName,
  3882. MinUnit: item.MinUnit,
  3883. RetailPrice: item.RetailPrice,
  3884. LastPrice: item.LastPrice,
  3885. LimitRemark: item.LimitRemark,
  3886. }
  3887. for _, it := range drugs {
  3888. if item.DrugDosageForm == it.Value {
  3889. detail.DrugDosageName = it.Code
  3890. }
  3891. }
  3892. result := service.SzybML008(doctor_name, doctor_code, miConfig.Code, detail)
  3893. var dat map[string]interface{}
  3894. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3895. //fmt.Println(dat)
  3896. } else {
  3897. //fmt.Println(err)
  3898. }
  3899. userJSONBytes, _ := json.Marshal(dat)
  3900. var res Result
  3901. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3902. utils.ErrorLog("解析失败:%v", err)
  3903. c.ServeSuccessJSON(map[string]interface{}{
  3904. "failed_code": -10,
  3905. "msg": res.Transreturnmessage,
  3906. })
  3907. return
  3908. }
  3909. if res.Transreturncode == "00000000" {
  3910. //更新备案状态
  3911. _, err := service.UpdateBaseDrugById(item.ID)
  3912. fmt.Println("err", err)
  3913. }
  3914. fmt.Println(isSuccess)
  3915. c.ServeSuccessJSON(map[string]interface{}{
  3916. "failed_code": -10,
  3917. "msg": res.Transreturnmessage,
  3918. })
  3919. return
  3920. }
  3921. }
  3922. }
  3923. if type_id == 2 {
  3924. //撤销
  3925. if is_mark == 1 {
  3926. //获取药品库数据
  3927. list, _ := service.GetMyPorjecgListDetail(orgId, id)
  3928. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3929. var doctor_name string
  3930. var doctor_code string
  3931. doctor_name = roles.UserName
  3932. doctor_code = "1001"
  3933. var pagesize int = 50
  3934. var start int = 1
  3935. var stop int
  3936. var pagecount int
  3937. var curpage int
  3938. var isSuccess bool = true
  3939. //总页数,向上取整,注意除之前要先转换类型为float64
  3940. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  3941. for curpage = 1; curpage <= pagecount; curpage++ {
  3942. if curpage == 1 {
  3943. start = 1
  3944. } else {
  3945. start = (curpage-1)*pagesize + 1
  3946. }
  3947. stop = curpage * pagesize
  3948. if stop > len(list) {
  3949. stop = len(list)
  3950. }
  3951. //这里就可以查看开始和结束了
  3952. fmt.Println(list[start-1 : stop])
  3953. var customs []*models.DrugDetail
  3954. for _, item := range list {
  3955. detail := &models.DrugDetail{
  3956. SocialSecurityDirectoryCode: item.MedicalCode,
  3957. }
  3958. customs = append(customs, detail)
  3959. }
  3960. result := service.SzybML010(doctor_name, doctor_code, miConfig.Code, customs, type_id)
  3961. fmt.Println("reuslt", result)
  3962. var dat map[string]interface{}
  3963. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3964. fmt.Println(dat)
  3965. } else {
  3966. fmt.Println(err)
  3967. }
  3968. userJSONBytes, _ := json.Marshal(dat)
  3969. var res Result
  3970. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3971. utils.ErrorLog("解析失败:%v", err)
  3972. c.ServeSuccessJSON(map[string]interface{}{
  3973. "failed_code": -10,
  3974. "msg": res.Transreturnmessage,
  3975. })
  3976. return
  3977. }
  3978. if res.Transreturncode == "00000000" {
  3979. //核销成功返回状态码
  3980. _, err := service.UpdateMyProjectById(id)
  3981. fmt.Println("err", err)
  3982. } else {
  3983. isSuccess = false
  3984. //失败
  3985. c.ServeSuccessJSON(map[string]interface{}{
  3986. "failed_code": -10,
  3987. "msg": res.Transreturnmessage,
  3988. })
  3989. return
  3990. }
  3991. fmt.Println(isSuccess)
  3992. c.ServeSuccessJSON(map[string]interface{}{
  3993. "failed_code": -10,
  3994. "msg": res.Transreturnmessage,
  3995. })
  3996. return
  3997. }
  3998. }
  3999. //备案
  4000. if is_mark == 0 {
  4001. adminUserInfo := c.GetAdminUserInfo()
  4002. orgId := adminUserInfo.CurrentOrgId
  4003. //获取药品库数据
  4004. list, _ := service.GetMyPorjecgListDetail(orgId, id)
  4005. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4006. var doctor_name string
  4007. var doctor_code string
  4008. doctor_name = roles.UserName
  4009. doctor_code = "1001"
  4010. var isSuccess bool = true
  4011. for _, item := range list {
  4012. detail := &models.MyHisProject{
  4013. MedicalCode: item.MedicalCode, //社保目录
  4014. ProjectName: item.ProjectName,
  4015. Price: item.Price,
  4016. Category: item.Category,
  4017. Remark: item.Remark,
  4018. }
  4019. result := service.SzybML009(doctor_name, doctor_code, miConfig.Code, detail)
  4020. fmt.Println("reuslt", result)
  4021. var dat map[string]interface{}
  4022. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4023. fmt.Println(dat)
  4024. } else {
  4025. fmt.Println(err)
  4026. }
  4027. userJSONBytes, _ := json.Marshal(dat)
  4028. var res Result
  4029. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4030. utils.ErrorLog("解析失败:%v", err)
  4031. c.ServeSuccessJSON(map[string]interface{}{
  4032. "failed_code": -10,
  4033. "msg": res.Transreturnmessage,
  4034. })
  4035. return
  4036. }
  4037. if res.Transreturncode == "00000000" {
  4038. //备案成功返回状态值
  4039. _, err := service.UpdateProjectById(item.ID)
  4040. fmt.Println("err", err)
  4041. } else {
  4042. isSuccess = false
  4043. //失败
  4044. c.ServeSuccessJSON(map[string]interface{}{
  4045. "failed_code": -10,
  4046. "msg": res.Transreturnmessage,
  4047. })
  4048. return
  4049. }
  4050. fmt.Println(isSuccess)
  4051. c.ServeSuccessJSON(map[string]interface{}{
  4052. "failed_code": -10,
  4053. "msg": res.Transreturnmessage,
  4054. })
  4055. return
  4056. }
  4057. }
  4058. }
  4059. if type_id == 3 {
  4060. //撤销
  4061. if is_mark == 1 {
  4062. //获取药品库数据
  4063. list, _ := service.GetGoodListByDetail(orgId, id)
  4064. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4065. var doctor_name string
  4066. var doctor_code string
  4067. doctor_name = roles.UserName
  4068. doctor_code = "1001"
  4069. var pagesize int = 50
  4070. var start int = 1
  4071. var stop int
  4072. var pagecount int
  4073. var curpage int
  4074. var isSuccess bool = true
  4075. //总页数,向上取整,注意除之前要先转换类型为float64
  4076. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  4077. for curpage = 1; curpage <= pagecount; curpage++ {
  4078. if curpage == 1 {
  4079. start = 1
  4080. } else {
  4081. start = (curpage-1)*pagesize + 1
  4082. }
  4083. stop = curpage * pagesize
  4084. if stop > len(list) {
  4085. stop = len(list)
  4086. }
  4087. //这里就可以查看开始和结束了
  4088. fmt.Println(list[start-1 : stop])
  4089. var customs []*models.DrugDetail
  4090. for _, item := range list {
  4091. fmt.Println("医疗机构编码", item.SocialSecurityDirectoryCode)
  4092. detail := &models.DrugDetail{
  4093. SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
  4094. ManufacturerName: item.ManufacturerName,
  4095. }
  4096. customs = append(customs, detail)
  4097. }
  4098. result := service.SzybML010(doctor_name, doctor_code, miConfig.Code, customs, type_id)
  4099. fmt.Println("reuslt", result)
  4100. var dat map[string]interface{}
  4101. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4102. fmt.Println(dat)
  4103. } else {
  4104. fmt.Println(err)
  4105. }
  4106. userJSONBytes, _ := json.Marshal(dat)
  4107. var res Result
  4108. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4109. utils.ErrorLog("解析失败:%v", err)
  4110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4111. return
  4112. }
  4113. if res.Transreturncode == "00000000" {
  4114. //撤销成功后改变状态
  4115. _, err := service.UpdateGoodInfoById(id)
  4116. fmt.Println("err", err)
  4117. } else {
  4118. isSuccess = false
  4119. //失败
  4120. c.ServeSuccessJSON(map[string]interface{}{
  4121. "failed_code": -10,
  4122. "msg": res.Transreturnmessage,
  4123. })
  4124. return
  4125. }
  4126. fmt.Println(isSuccess)
  4127. c.ServeSuccessJSON(map[string]interface{}{
  4128. "failed_code": -10,
  4129. "msg": res.Transreturnmessage,
  4130. })
  4131. return
  4132. }
  4133. }
  4134. //备案
  4135. if is_mark == 0 {
  4136. adminUserInfo := c.GetAdminUserInfo()
  4137. orgId := adminUserInfo.CurrentOrgId
  4138. //获取所有耗材信息
  4139. list, _ := service.GetGoodListByDetail(orgId, id)
  4140. //获取单位
  4141. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4142. var doctor_name string
  4143. var doctor_code string
  4144. doctor_name = roles.UserName
  4145. doctor_code = "1001"
  4146. var isSuccess bool = true
  4147. for _, item := range list {
  4148. detail := &models.XtGoodInformation{
  4149. GoodName: item.GoodName,
  4150. SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
  4151. ManufacturerName: item.ManufacturerName,
  4152. ProductionType: item.ProductionType,
  4153. SpecialMedical: item.SpecialMedical,
  4154. BuyPrice: item.BuyPrice,
  4155. SellPrice: item.SellPrice,
  4156. Remark: item.Remark,
  4157. SpecificationName: item.SpecificationName,
  4158. }
  4159. result := service.SzybYML007(doctor_name, doctor_code, miConfig.Code, detail)
  4160. fmt.Println("reuslt", result)
  4161. var dat map[string]interface{}
  4162. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4163. fmt.Println(dat)
  4164. } else {
  4165. fmt.Println(err)
  4166. }
  4167. userJSONBytes, _ := json.Marshal(dat)
  4168. var res Result
  4169. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4170. utils.ErrorLog("解析失败:%v", err)
  4171. c.ServeSuccessJSON(map[string]interface{}{
  4172. "failed_code": -10,
  4173. "msg": res.Transreturnmessage,
  4174. })
  4175. return
  4176. }
  4177. if res.Transreturncode == "00000000" {
  4178. //备案成功返回状态
  4179. _, err := service.UpdateGoodInformaitonByDetail(item.ID)
  4180. fmt.Println("err", err)
  4181. } else {
  4182. isSuccess = false
  4183. //失败
  4184. c.ServeSuccessJSON(map[string]interface{}{
  4185. "failed_code": -10,
  4186. "msg": res.Transreturnmessage,
  4187. })
  4188. return
  4189. }
  4190. fmt.Println(isSuccess)
  4191. c.ServeSuccessJSON(map[string]interface{}{
  4192. "failed_code": -10,
  4193. "msg": res.Transreturnmessage,
  4194. })
  4195. return
  4196. }
  4197. }
  4198. }
  4199. }
  4200. func (c *SZHisApiController) GetDoctorList() {
  4201. adminUserInfo := c.GetAdminUserInfo()
  4202. orgid := adminUserInfo.CurrentOrgId
  4203. ids := c.GetString("ids")
  4204. admin_user_id, _ := c.GetInt64("admin_user_id")
  4205. roles, _ := service.GetAdminUserInfoByID(orgid, admin_user_id)
  4206. stringarr := strings.Split(ids, ",")
  4207. idss := make([]int64, 0)
  4208. for _, item := range stringarr {
  4209. itemsss, _ := strconv.ParseInt(item, 10, 64)
  4210. id := int64(itemsss)
  4211. idss = append(idss, id)
  4212. }
  4213. //获取所有医生护士信息
  4214. //list, _ := service.GetDoctorList(orgid)
  4215. //批量查询
  4216. list, _ := service.GetBatchDoctorList(idss)
  4217. //获取所有角色名称
  4218. roleList, _ := service.GetRoleList(orgid)
  4219. miConfig, _ := service.FindMedicalInsuranceInfo(orgid)
  4220. for _, item := range list {
  4221. for _, it := range roleList {
  4222. if item.RoleId == it.ID {
  4223. item.Name = it.RoleName
  4224. }
  4225. }
  4226. }
  4227. var doctor_name string
  4228. var doctor_code string
  4229. doctor_name = roles.UserName
  4230. doctor_code = "1001"
  4231. var isSuccess bool = true
  4232. for _, item := range list {
  4233. depart, _ := service.GetDepartMentDetail(item.DepartmentId)
  4234. detail := &models.DocDetail{
  4235. UserName: item.UserName, //医护姓名
  4236. RoleId: item.Name, //医护人员类别
  4237. Sex: strconv.FormatInt(item.Sex, 10), //性别
  4238. CardType: strconv.FormatInt(item.CardType, 10), //证件类型
  4239. IdCard: item.IdCard, //证件号码
  4240. Phone: item.Mobile, //联系电话
  4241. WorkMajorName: item.WorkMajorName, // 现从事专业名称
  4242. Nation: "1", //民族
  4243. BirthDay: 20201022, // 出生日期
  4244. WorkTime: 20201022, //参加工作日期
  4245. Education: strconv.FormatInt(item.Education, 10), //学历
  4246. StudyMajorName: item.StudyMajorName, //所学的专业名称
  4247. CertificateCode: item.MedicalCode, //医(药)师执业证书编码
  4248. MedicalCode: item.DoctorCode, //医(药)师资格证编码
  4249. MedicalRangeCode: strconv.FormatInt(item.DoctorRangeCode, 10), //医师执业范围代码
  4250. MedicalLevel: strconv.FormatInt(item.DoctorLevel, 10), //医生执业资格证中的医师级别
  4251. TypeJob: strconv.FormatInt(item.DoctorTypeJob, 10), //医生执业资格证中的执业类别
  4252. DoctorNumber: item.DoctorNumber, //医保医师编号
  4253. Licensing: strconv.FormatInt(item.Licensing, 10), //多点执业标志
  4254. DoctorServiceStatus: "", //医师医保服务资格状态
  4255. MonitoringLevel: "", //监控等级
  4256. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  4257. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  4258. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  4259. PharmacistType: "", //药师类别
  4260. PharmacistPracticeCategory: "", //药师执业类别
  4261. PharmacistsLicensing: "", //药师执业范围
  4262. PharmacistRegistrationNumber: "", //执业药师注册证编号
  4263. OfficeCode: depart.Number, //科室编码
  4264. JobNumber: item.JobNumber, //工号
  4265. PostName: "", //职位名称
  4266. TechnicalJobLevelCode: "", //专业技术职务级别编码
  4267. IsActive: strconv.FormatInt(item.IsActive, 10), //在职与否
  4268. PrescriptionQualificationIdentification: strconv.FormatInt(item.PrescriptionQualificationIdentification, 10), //处方资格标识
  4269. IdentificationOutpatients: strconv.FormatInt(item.IdentificationOutpatients, 10), //门诊大病医师标识
  4270. OutpatientIllnessCategory: item.OutpatientIllnessCategory, //门诊大病类别
  4271. StartTime: 20201010, //开始日期
  4272. StaffCode: "", //医护人员编码
  4273. EndTime: 0, // 结束日期
  4274. }
  4275. result := service.SzybYS001(doctor_name, doctor_code, miConfig.Code, detail)
  4276. fmt.Println("reuslt", result)
  4277. var dat map[string]interface{}
  4278. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4279. fmt.Println(dat)
  4280. } else {
  4281. fmt.Println(err)
  4282. }
  4283. userJSONBytes, _ := json.Marshal(dat)
  4284. var res Result
  4285. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4286. utils.ErrorLog("解析失败:%v", err)
  4287. c.ServeSuccessJSON(map[string]interface{}{
  4288. "failed_code": -10,
  4289. "msg": res.Transreturnmessage,
  4290. })
  4291. return
  4292. }
  4293. if res.Transreturncode == "00000000" {
  4294. //批量插入数据
  4295. _, err := service.UpdateAdminUserRoleById(item.AdminUserId, orgid)
  4296. fmt.Println("err", err)
  4297. } else {
  4298. isSuccess = false
  4299. //失败
  4300. c.ServeSuccessJSON(map[string]interface{}{
  4301. "failed_code": -10,
  4302. "msg": res.Transreturnmessage,
  4303. })
  4304. return
  4305. }
  4306. fmt.Println(isSuccess)
  4307. c.ServeSuccessJSON(map[string]interface{}{
  4308. "failed_code": -10,
  4309. "msg": res.Transreturnmessage,
  4310. })
  4311. return
  4312. }
  4313. }
  4314. func (c *SZHisApiController) GetMedicalList() {
  4315. adminUserInfo := c.GetAdminUserInfo()
  4316. orgId := adminUserInfo.CurrentOrgId
  4317. id, _ := c.GetInt64("id")
  4318. is_mark, _ := c.GetInt64("is_mark")
  4319. admin_user_id, _ := c.GetInt64("admin_user_id")
  4320. roles, _ := service.GetAdminUserInfoByID(orgId, admin_user_id)
  4321. //去登记
  4322. if is_mark == 0 {
  4323. list, _ := service.GetDoctorListByDetail(orgId, id)
  4324. //获取所有角色名称
  4325. roleList, _ := service.GetRoleList(orgId)
  4326. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4327. for _, item := range list {
  4328. for _, it := range roleList {
  4329. if item.RoleId == it.ID {
  4330. item.Name = it.RoleName
  4331. }
  4332. }
  4333. }
  4334. var doctor_name string
  4335. var doctor_code string
  4336. doctor_name = roles.UserName
  4337. doctor_code = "1001"
  4338. var isSuccess bool = true
  4339. for _, item := range list {
  4340. detail := &models.DocDetail{
  4341. UserName: item.UserName, //医护姓名
  4342. RoleId: item.Name, //医护人员类别
  4343. Sex: strconv.FormatInt(item.Sex, 10), //性别
  4344. CardType: strconv.FormatInt(item.CardType, 10), //证件类型
  4345. IdCard: item.IdCard, //证件号码
  4346. Phone: item.Mobile, //联系电话
  4347. WorkMajorName: item.WorkMajorName, // 现从事专业名称
  4348. Nation: item.Nation, //民族
  4349. BirthDay: 20201022, // 出生日期
  4350. WorkTime: 20201022, //参加工作日期
  4351. Education: strconv.FormatInt(item.Education, 10), //学历
  4352. StudyMajorName: item.StudyMajorName, //所学的专业名称
  4353. CertificateCode: item.MedicalCode, //医(药)师执业证书编码
  4354. MedicalCode: item.DoctorCode, //医(药)师资格证编码
  4355. MedicalRangeCode: strconv.FormatInt(item.DoctorRangeCode, 10), //医师执业范围代码
  4356. MedicalLevel: strconv.FormatInt(item.DoctorLevel, 10), //医生执业资格证中的医师级别
  4357. TypeJob: strconv.FormatInt(item.DoctorTypeJob, 10), //医生执业资格证中的执业类别
  4358. DoctorNumber: item.DoctorNumber, //医保医师编号
  4359. Licensing: strconv.FormatInt(item.Licensing, 10), //多点执业标志
  4360. DoctorServiceStatus: "", //医师医保服务资格状态
  4361. MonitoringLevel: "", //监控等级
  4362. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  4363. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  4364. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  4365. PharmacistType: "", //药师类别
  4366. PharmacistPracticeCategory: "", //药师执业类别
  4367. PharmacistsLicensing: "", //药师执业范围
  4368. PharmacistRegistrationNumber: "", //执业药师注册证编号
  4369. OfficeCode: "", //科室编码
  4370. JobNumber: item.JobNumber, //工号
  4371. PostName: "", //职位名称
  4372. TechnicalJobLevelCode: "", //专业技术职务级别编码
  4373. IsActive: strconv.FormatInt(item.IsActive, 10), //在职与否
  4374. PrescriptionQualificationIdentification: strconv.FormatInt(item.PrescriptionQualificationIdentification, 10), //处方资格标识
  4375. IdentificationOutpatients: strconv.FormatInt(item.IdentificationOutpatients, 10), //门诊大病医师标识
  4376. OutpatientIllnessCategory: item.OutpatientIllnessCategory, //门诊大病类别
  4377. StartTime: 20201010, //开始日期
  4378. StaffCode: "", //医护人员编码
  4379. EndTime: 0, // 结束日期
  4380. }
  4381. result := service.SzybYS001(doctor_name, doctor_code, miConfig.Code, detail)
  4382. var dat map[string]interface{}
  4383. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4384. fmt.Println(dat)
  4385. } else {
  4386. fmt.Println(err)
  4387. }
  4388. userJSONBytes, _ := json.Marshal(dat)
  4389. var res Result
  4390. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4391. utils.ErrorLog("解析失败:%v", err)
  4392. c.ServeSuccessJSON(map[string]interface{}{
  4393. "failed_code": -10,
  4394. "msg": res.Transreturnmessage,
  4395. })
  4396. return
  4397. }
  4398. if res.Transreturncode == "00000000" {
  4399. //登记成功
  4400. service.UpdateAdminUserRoleById(item.ID, orgId)
  4401. } else {
  4402. isSuccess = false
  4403. //失败
  4404. c.ServeSuccessJSON(map[string]interface{}{
  4405. "failed_code": -10,
  4406. "msg": res.Transreturnmessage,
  4407. })
  4408. return
  4409. }
  4410. fmt.Println(isSuccess)
  4411. c.ServeSuccessJSON(map[string]interface{}{
  4412. "failed_code": -10,
  4413. "msg": res.Transreturnmessage,
  4414. })
  4415. return
  4416. }
  4417. }
  4418. //去撤销
  4419. if is_mark == 1 {
  4420. //获取所有医生护士信息
  4421. list, _ := service.GetDoctorListByDetail(orgId, id)
  4422. //获取所有角色名称
  4423. roleList, _ := service.GetRoleList(orgId)
  4424. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4425. for _, item := range list {
  4426. for _, it := range roleList {
  4427. if item.RoleId == it.ID {
  4428. item.Name = it.RoleName
  4429. }
  4430. }
  4431. }
  4432. var doctor_name string
  4433. var doctor_code string
  4434. doctor_name = "黄亦轩"
  4435. doctor_code = "1001"
  4436. var isSuccess bool = true
  4437. for _, item := range list {
  4438. detail := &models.DocDetail{
  4439. UserName: item.UserName, //医护姓名
  4440. RoleId: item.Name, //医护人员类别
  4441. Sex: strconv.FormatInt(item.Sex, 10), //性别
  4442. CardType: strconv.FormatInt(item.CardType, 10), //证件类型
  4443. IdCard: item.IdCard, //证件号码
  4444. Phone: item.Mobile, //联系电话
  4445. WorkMajorName: item.WorkMajorName, // 现从事专业名称
  4446. Nation: item.Nation, //民族
  4447. BirthDay: 20201022, // 出生日期
  4448. WorkTime: 20201022, //参加工作日期
  4449. Education: strconv.FormatInt(item.Education, 10), //学历
  4450. StudyMajorName: item.StudyMajorName, //所学的专业名称
  4451. CertificateCode: item.MedicalCode, //医(药)师执业证书编码
  4452. MedicalCode: item.DoctorCode, //医(药)师资格证编码
  4453. MedicalRangeCode: strconv.FormatInt(item.DoctorRangeCode, 10), //医师执业范围代码
  4454. MedicalLevel: strconv.FormatInt(item.DoctorLevel, 10), //医生执业资格证中的医师级别
  4455. TypeJob: strconv.FormatInt(item.DoctorTypeJob, 10), //医生执业资格证中的执业类别
  4456. DoctorNumber: item.DoctorNumber, //医保医师编号
  4457. Licensing: strconv.FormatInt(item.Licensing, 10), //多点执业标志
  4458. DoctorServiceStatus: "", //医师医保服务资格状态
  4459. MonitoringLevel: "", //监控等级
  4460. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  4461. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  4462. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  4463. PharmacistType: "", //药师类别
  4464. PharmacistPracticeCategory: "", //药师执业类别
  4465. PharmacistsLicensing: "", //药师执业范围
  4466. PharmacistRegistrationNumber: "", //执业药师注册证编号
  4467. OfficeCode: "", //科室编码
  4468. JobNumber: item.JobNumber, //工号
  4469. PostName: "", //职位名称
  4470. TechnicalJobLevelCode: "", //专业技术职务级别编码
  4471. IsActive: strconv.FormatInt(item.IsActive, 10), //在职与否
  4472. PrescriptionQualificationIdentification: strconv.FormatInt(item.PrescriptionQualificationIdentification, 10), //处方资格标识
  4473. IdentificationOutpatients: strconv.FormatInt(item.IdentificationOutpatients, 10), //门诊大病医师标识
  4474. OutpatientIllnessCategory: item.OutpatientIllnessCategory, //门诊大病类别
  4475. StartTime: 20201010, //开始日期
  4476. StaffCode: "", //医护人员编码
  4477. EndTime: 0, // 结束日期
  4478. }
  4479. result := service.SzybYS002(doctor_name, doctor_code, miConfig.Code, detail)
  4480. var dat map[string]interface{}
  4481. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4482. fmt.Println(dat)
  4483. } else {
  4484. fmt.Println(err)
  4485. }
  4486. userJSONBytes, _ := json.Marshal(dat)
  4487. var res Result
  4488. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4489. utils.ErrorLog("解析失败:%v", err)
  4490. c.ServeSuccessJSON(map[string]interface{}{
  4491. "failed_code": -10,
  4492. "msg": res.Transreturnmessage,
  4493. })
  4494. return
  4495. }
  4496. if res.Transreturncode == "00000000" {
  4497. //去撤销
  4498. service.UpdateAdminUserRoleById(item.ID, orgId)
  4499. } else {
  4500. isSuccess = false
  4501. //失败
  4502. c.ServeSuccessJSON(map[string]interface{}{
  4503. "failed_code": -10,
  4504. "msg": res.Transreturnmessage,
  4505. })
  4506. return
  4507. }
  4508. fmt.Println(isSuccess)
  4509. c.ServeSuccessJSON(map[string]interface{}{
  4510. "failed_code": -10,
  4511. "msg": res.Transreturnmessage,
  4512. })
  4513. return
  4514. }
  4515. }
  4516. }
  4517. func (c *SZHisApiController) GetUpdateMedicalList() {
  4518. adminUserInfo := c.GetAdminUserInfo()
  4519. orgId := adminUserInfo.CurrentOrgId
  4520. //获取所有医生护士信息
  4521. list, _ := service.GetDoctorList(orgId)
  4522. //获取所有角色名称
  4523. roleList, _ := service.GetRoleList(orgId)
  4524. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4525. for _, item := range list {
  4526. for _, it := range roleList {
  4527. if item.RoleId == it.ID {
  4528. item.Name = it.RoleName
  4529. }
  4530. }
  4531. }
  4532. var doctor_name string
  4533. var doctor_code string
  4534. doctor_name = "黄亦轩"
  4535. doctor_code = "1001"
  4536. var pagesize int = 50
  4537. var start int = 1
  4538. var stop int
  4539. var pagecount int
  4540. var curpage int
  4541. var isSuccess bool = true
  4542. //总页数,向上取整,注意除之前要先转换类型为float64
  4543. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  4544. var ress []*Result
  4545. for curpage = 1; curpage <= pagecount; curpage++ {
  4546. if curpage == 1 {
  4547. start = 1
  4548. } else {
  4549. start = (curpage-1)*pagesize + 1
  4550. }
  4551. stop = curpage * pagesize
  4552. if stop > len(list) {
  4553. stop = len(list)
  4554. }
  4555. //这里就可以查看开始和结束了
  4556. fmt.Println(list[start-1 : stop])
  4557. var customs []*models.DocDetail
  4558. for _, item := range list {
  4559. detail := &models.DocDetail{
  4560. StaffCode: "", //医护人员编码
  4561. UserName: item.UserName, //医护人员姓名
  4562. RoleId: item.Name, //医护人员类别
  4563. Sex: "", //性别
  4564. CardType: "", //证件类型
  4565. IdCard: "", //证件号码
  4566. Phone: "", //联系电话
  4567. WorkMajorName: "", //现从事专业名称
  4568. Nation: "", //民族
  4569. BirthDay: 20201022, //出生日期
  4570. WorkTime: 20201022, //参加工作日期
  4571. Education: "", //学历
  4572. StudyMajorName: "", //所学的专业名称
  4573. CertificateCode: "", //证书编码
  4574. MedicalCode: "", //医师资格编码
  4575. MedicalRangeCode: "", //医师执业范围代码
  4576. MedicalLevel: "", //医生级别
  4577. TypeJob: "", //职业类别
  4578. DoctorNumber: "", //医师编号
  4579. Licensing: "", //职业标志
  4580. DoctorServiceStatus: "", //医师医保服务资格状态
  4581. MonitoringLevel: "", //监控等级
  4582. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  4583. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  4584. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  4585. PharmacistType: "", //药师类别
  4586. PharmacistPracticeCategory: "", //药师执业类别
  4587. PharmacistsLicensing: "", //药师执业范围
  4588. PharmacistRegistrationNumber: "", //执业药师注册证编号
  4589. OfficeCode: "", //科室编码
  4590. JobNumber: "", //工号
  4591. PostName: "", //职位名称
  4592. TechnicalJobLevelCode: "", //专业技术职务级别编码
  4593. IsActive: "", //在职与否
  4594. PrescriptionQualificationIdentification: "", //处方资格标识
  4595. IdentificationOutpatients: "", //门诊大病医师标识
  4596. OutpatientIllnessCategory: "", //门诊大病类别
  4597. StartTime: 20201022, //开始日期
  4598. EndTime: 20201022,
  4599. }
  4600. customs = append(customs, detail)
  4601. }
  4602. result := service.SzybYS003(doctor_name, doctor_code, miConfig.Code, customs)
  4603. var dat map[string]interface{}
  4604. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4605. fmt.Println(dat)
  4606. } else {
  4607. fmt.Println(err)
  4608. }
  4609. userJSONBytes, _ := json.Marshal(dat)
  4610. var res Result
  4611. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4612. utils.ErrorLog("解析失败:%v", err)
  4613. c.ServeSuccessJSON(map[string]interface{}{
  4614. "failed_code": -10,
  4615. "msg": res.Transreturnmessage,
  4616. })
  4617. return
  4618. }
  4619. if res.Transreturncode == "00000000" {
  4620. ress = append(ress, &res)
  4621. } else {
  4622. isSuccess = false
  4623. //失败
  4624. c.ServeSuccessJSON(map[string]interface{}{
  4625. "failed_code": -10,
  4626. "msg": res.Transreturnmessage,
  4627. })
  4628. return
  4629. }
  4630. fmt.Println(isSuccess)
  4631. c.ServeSuccessJSON(map[string]interface{}{
  4632. "failed_code": -10,
  4633. "msg": res.Transreturnmessage,
  4634. })
  4635. return
  4636. }
  4637. }
  4638. func (c *SZHisApiController) GetGoodsList() {
  4639. adminUserInfo := c.GetAdminUserInfo()
  4640. orgId := adminUserInfo.CurrentOrgId
  4641. ids := c.GetString("ids")
  4642. admin_user_id, _ := c.GetInt64("admin_user_id")
  4643. roles, _ := service.GetAdminUserInfoByID(orgId, admin_user_id)
  4644. stringarr := strings.Split(ids, ",")
  4645. idss := make([]int64, 0)
  4646. for _, item := range stringarr {
  4647. itemsss, _ := strconv.ParseInt(item, 10, 64)
  4648. id := int64(itemsss)
  4649. idss = append(idss, id)
  4650. }
  4651. //批量获取所有耗材信息
  4652. list, _ := service.GetBatchGoodInformationList(idss)
  4653. //获取单位
  4654. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4655. var doctor_name string
  4656. var doctor_code string
  4657. doctor_name = roles.UserName
  4658. doctor_code = "1001"
  4659. var isSuccess bool = true
  4660. for _, item := range list {
  4661. detail := &models.XtGoodInformation{
  4662. GoodName: item.GoodName,
  4663. SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
  4664. ManufacturerName: item.ManufacturerName,
  4665. ProductionType: item.ProductionType,
  4666. SpecialMedical: item.SpecialMedical,
  4667. BuyPrice: item.BuyPrice,
  4668. SellPrice: item.SellPrice,
  4669. Remark: item.Remark,
  4670. SpecificationName: item.SpecificationName,
  4671. }
  4672. result := service.SzybYML007(doctor_name, doctor_code, miConfig.Code, detail)
  4673. fmt.Println("reuslt", result)
  4674. var dat map[string]interface{}
  4675. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4676. fmt.Println(dat)
  4677. } else {
  4678. fmt.Println(err)
  4679. }
  4680. userJSONBytes, _ := json.Marshal(dat)
  4681. var res Result
  4682. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4683. utils.ErrorLog("解析失败:%v", err)
  4684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4685. return
  4686. }
  4687. if res.Transreturncode == "00000000" {
  4688. //备案成功返回状态
  4689. _, err := service.UpdateGoodInformaitonByDetail(item.ID)
  4690. fmt.Println("err", err)
  4691. } else {
  4692. isSuccess = false
  4693. //失败
  4694. c.ServeSuccessJSON(map[string]interface{}{
  4695. "failed_code": -10,
  4696. "msg": res.Transreturnmessage,
  4697. })
  4698. return
  4699. }
  4700. fmt.Println(isSuccess)
  4701. c.ServeSuccessJSON(map[string]interface{}{
  4702. "failed_code": -10,
  4703. "msg": res.Transreturnmessage,
  4704. })
  4705. return
  4706. }
  4707. }
  4708. type Charset string
  4709. const (
  4710. UTF8 = Charset("UTF-8")
  4711. GB18030 = Charset("GB18030")
  4712. )
  4713. func ConvertToString(src string, srcCode string, tagCode string) string {
  4714. srcCoder := mahonia.NewDecoder(srcCode)
  4715. srcResult := srcCoder.ConvertString(src)
  4716. tagCoder := mahonia.NewDecoder(tagCode)
  4717. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  4718. result := string(cdata)
  4719. return result
  4720. }