sz_his_api_controller.go 177KB

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