sz_his_api_controller.go 177KB

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