his_api_controller.go 269KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "strconv"
  23. "strings"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. type HisApiController struct {
  29. controllers.BaseAuthAPIController
  30. }
  31. func HisManagerApiRegistRouters() {
  32. fmt.Println("----------")
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. beego.Router("/api/diag/upload", &HisApiController{}, "get:GetUploadDiag")
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  37. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  38. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  39. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  40. //beego.Router("/api/sscard", &HisApiController{}, "get:Sscard")
  41. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  42. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  43. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  44. beego.Router("/api/record/put", &HisApiController{}, "get:PutRecord")
  45. //beego.Router("/api/patient/info", &HisApiController{}, "get:GetHisPatientInfo")
  46. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  47. //beego.Router("/api/testcard", &HisApiController{}, "get:TestGetBasBaseInfo")
  48. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  49. //beego.Router("/api/testpay", &HisApiController{}, "get:TestPay")
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. //beego.Router("/api/settle/get", &HisApiController{}, "get:GetSettleInfo")
  52. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  53. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  54. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  55. //备案撤销相关接口
  56. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  57. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  58. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  59. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  60. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  61. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  62. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  63. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  64. //beego.Router("/api/reversal/one", &HisApiController{}, "get:ReversalOtherOneData")
  65. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  67. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  68. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  69. //beego.Router("/api/checkdetailaccount/handle", &HisApiController{}, "get:HandleCheckDetailAccount")
  70. //beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  71. //beego.Router("/api/testinit", &HisApiController{}, "get:TestGetBasBaseInit")
  72. //beego.Router("/api/test", &HisApiController{}, "get:TestGetBasBaseInfo")
  73. }
  74. func (c *HisApiController) CheckInsutype() {
  75. his_patient_id, _ := c.GetInt64("his_patient_id")
  76. admin_user_id, _ := c.GetInt64("admin_user_id")
  77. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  78. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  79. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  80. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  81. var dat map[string]interface{}
  82. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  83. fmt.Println(dat)
  84. } else {
  85. fmt.Println(err)
  86. }
  87. userJSONBytes, _ := json.Marshal(dat)
  88. var res Result90100
  89. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  90. utils.ErrorLog("解析失败:%v", err)
  91. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  92. return
  93. }
  94. if res.Infcode != 0 {
  95. c.ServeSuccessJSON(map[string]interface{}{
  96. "failed_code": -10,
  97. "msg": res.ErrMsg,
  98. })
  99. return
  100. } else {
  101. fmt.Println(res)
  102. }
  103. }
  104. func (c *HisApiController) CheckCardPWD() {
  105. card_pwd := c.GetString("card_pwd")
  106. his_patient_id, _ := c.GetInt64("his_patient_id")
  107. admin_user_id, _ := c.GetInt64("admin_user_id")
  108. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  109. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  110. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  111. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd)
  112. var dat map[string]interface{}
  113. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  114. fmt.Println(dat)
  115. } else {
  116. fmt.Println(err)
  117. }
  118. userJSONBytes, _ := json.Marshal(dat)
  119. var res Result90991
  120. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  121. utils.ErrorLog("解析失败:%v", err)
  122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  123. return
  124. }
  125. if res.Infcode != 0 {
  126. c.ServeSuccessJSON(map[string]interface{}{
  127. "failed_code": -10,
  128. "msg": res.ErrMsg,
  129. })
  130. return
  131. } else {
  132. if res.Output.Result.CheckStat == "0" {
  133. var msg string
  134. switch res.Output.Result.CardStat {
  135. case "00":
  136. msg = "未激活"
  137. break
  138. case "10":
  139. msg = "激活"
  140. break
  141. case "20":
  142. msg = "窗口挂失"
  143. break
  144. case "21":
  145. msg = "电话挂失"
  146. break
  147. case "22":
  148. msg = "单位网上申报挂失"
  149. break
  150. case "23":
  151. msg = "保健办挂失"
  152. break
  153. case "24":
  154. msg = "个人网上挂失"
  155. break
  156. case "25":
  157. msg = "网上服务大厅挂失"
  158. break
  159. case "30":
  160. msg = "注销"
  161. break
  162. case "40":
  163. msg = "回收"
  164. break
  165. case "99":
  166. msg = "制卡中(无效卡)"
  167. break
  168. }
  169. c.ServeSuccessJSON(map[string]interface{}{
  170. "failed_code": -10,
  171. "msg": msg,
  172. })
  173. return
  174. } else {
  175. c.ServeSuccessJSON(map[string]interface{}{
  176. "msg": "校验成功",
  177. })
  178. return
  179. }
  180. }
  181. }
  182. func (c *HisApiController) ReadCard() {
  183. id_card_type, _ := c.GetInt64("id_card_type")
  184. admin_user_id, _ := c.GetInt64("admin_user_id")
  185. certificates, _ := c.GetInt64("certificates")
  186. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  187. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  188. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  189. switch id_card_type {
  190. case 1:
  191. if miConfig.MdtrtareaAdmvs == "421300" {
  192. var res ResultTwo
  193. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  194. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  195. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(certificates, 10)
  196. resp, requestErr := http.Get(api)
  197. if requestErr != nil {
  198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  199. return
  200. }
  201. body, ioErr := ioutil.ReadAll(resp.Body)
  202. if ioErr != nil {
  203. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  205. return
  206. }
  207. var respJSON map[string]interface{}
  208. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  209. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  211. return
  212. }
  213. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  214. result, _ := json.Marshal(respJSON)
  215. fmt.Println("log")
  216. fmt.Println(string(result))
  217. if err := json.Unmarshal([]byte(result), &res); err != nil {
  218. utils.ErrorLog("解析失败:%v", err)
  219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  220. return
  221. }
  222. if res.Infcode == 0 {
  223. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  224. if err == gorm.ErrRecordNotFound {
  225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  226. return
  227. } else if err != nil {
  228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  229. return
  230. } else {
  231. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  232. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  233. infoStr := string(Iinfos)
  234. idetinfoStr := string(Idetinfos)
  235. psn := &models.HisPsn{
  236. PsnNo: res.Output.Baseinfo.PsnNo,
  237. Age: res.Output.Baseinfo.Age,
  238. PatientId: patient.ID,
  239. Certno: res.Output.Baseinfo.Certno,
  240. Brdy: res.Output.Baseinfo.Brdy,
  241. Gend: res.Output.Baseinfo.Gend,
  242. Naty: res.Output.Baseinfo.Naty,
  243. PsnCertType: res.Output.Baseinfo.PsnCertType,
  244. PsnName: res.Output.Baseinfo.PsnName,
  245. Idetinfo: idetinfoStr,
  246. Insuinfo: infoStr,
  247. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  248. }
  249. service.CreateHisPsn(psn)
  250. c.ServeSuccessJSON(map[string]interface{}{
  251. "patient": patient,
  252. "number": res.Output.Baseinfo.Certno,
  253. })
  254. }
  255. } else {
  256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  257. return
  258. }
  259. } else {
  260. if initFlag == 0 {
  261. c.TestGetBasBaseInit()
  262. }
  263. basStr := c.GetBasBaseInfo()
  264. if len(basStr) == 0 {
  265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  266. return
  267. }
  268. fmt.Println(basStr)
  269. bas := strings.Split(basStr, "|")
  270. basNumber := bas[1]
  271. fmt.Println(basNumber)
  272. card_sn := bas[3]
  273. fmt.Println(card_sn)
  274. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  275. var dat map[string]interface{}
  276. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  277. fmt.Println(dat)
  278. } else {
  279. fmt.Println(err)
  280. }
  281. userJSONBytes, _ := json.Marshal(dat)
  282. var res ResultTwo
  283. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  284. utils.ErrorLog("解析失败:%v", err)
  285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  286. return
  287. }
  288. if res.Infcode == 0 {
  289. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  290. if err == gorm.ErrRecordNotFound {
  291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  292. return
  293. } else if err != nil {
  294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  295. return
  296. } else {
  297. c.ServeSuccessJSON(map[string]interface{}{
  298. "patient": patient,
  299. "number": basNumber,
  300. })
  301. }
  302. } else {
  303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  304. return
  305. }
  306. break
  307. }
  308. case 2:
  309. SFZStr := c.GetSFZBaseInfo()
  310. id_card_str := strings.Split(SFZStr, "^")
  311. id_card_number := id_card_str[0]
  312. card_sn := ""
  313. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  314. var dat map[string]interface{}
  315. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  316. fmt.Println(dat)
  317. } else {
  318. fmt.Println(err)
  319. }
  320. userJSONBytes, _ := json.Marshal(dat)
  321. var res ResultTwo
  322. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  323. utils.ErrorLog("解析失败:%v", err)
  324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  325. return
  326. }
  327. if res.Infcode == 0 {
  328. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  329. if err == gorm.ErrRecordNotFound {
  330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  331. return
  332. } else if err != nil {
  333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  334. return
  335. } else {
  336. c.ServeSuccessJSON(map[string]interface{}{
  337. "patient": patient,
  338. "number": id_card_number,
  339. })
  340. }
  341. } else {
  342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  343. return
  344. }
  345. break
  346. case 3:
  347. break
  348. }
  349. }
  350. var initFlag int64 = 0
  351. func (c *HisApiController) TestGetBasBaseInit() {
  352. DllDef := syscall.MustLoadDLL("SSCard.dll")
  353. Iinit := DllDef.MustFindProc("Init")
  354. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  355. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  356. if ret != 0 {
  357. fmt.Println("SSCard的报错原因:", err)
  358. fmt.Println("SSCard的运算结果为:", ret)
  359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  360. return
  361. }
  362. result := int(ret)
  363. fmt.Println("SSCard的运算结果为1:", result)
  364. initFlag = 1
  365. return
  366. }
  367. func (c *HisApiController) GetSFZBaseInfo() string {
  368. DllDef := syscall.MustLoadDLL("SSCard.dll")
  369. readCard := DllDef.MustFindProc("ReadSFZ")
  370. if readCard == nil {
  371. fmt.Println("readcard is nil")
  372. readCard = DllDef.MustFindProc("ReadSFZ")
  373. }
  374. str := make([]byte, 256)
  375. str1 := make([]byte, 256)
  376. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  377. fmt.Println(r)
  378. return string(str)
  379. }
  380. func (c *HisApiController) GetBasBaseInfo() string {
  381. DllDef := syscall.MustLoadDLL("SSCard.dll")
  382. readCard := DllDef.MustFindProc("ReadCardBas")
  383. if readCard == nil {
  384. fmt.Println("readcard is nil")
  385. readCard = DllDef.MustFindProc("ReadCardBas")
  386. }
  387. str := make([]byte, 1024)
  388. str1 := make([]byte, 1024)
  389. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  390. fmt.Println(string(str1))
  391. fmt.Println(string(str))
  392. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  393. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  394. if ret2 != 0 {
  395. return ""
  396. }
  397. return string(str)
  398. }
  399. func prttostr(vcode uintptr) string {
  400. var vbyte []byte
  401. for i := 0; i < 10; i++ {
  402. sbyte := *((*byte)(unsafe.Pointer(vcode)))
  403. if sbyte == 0 {
  404. break
  405. }
  406. vbyte = append(vbyte, sbyte)
  407. vcode += 1
  408. }
  409. return string(vbyte)
  410. }
  411. type CustomFundPay struct {
  412. FundPayType string `json:"fund_pay_type"`
  413. FundPayamt float64 `json:"fund_payamt"`
  414. }
  415. func (c *HisApiController) GetSettleList() {
  416. order_id, _ := c.GetInt64("order_id")
  417. admin_user_id, _ := c.GetInt64("admin_user_id")
  418. order, _ := service.GetHisOrderByIDTwo(order_id)
  419. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  420. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  421. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  422. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  423. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  424. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  425. if order.ID == 0 {
  426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  427. return
  428. }
  429. struct4101 := service.Struct4101{
  430. PsnNo: order.PsnNo,
  431. MdtrtId: order.MdtrtId,
  432. SetlId: order.SetlId,
  433. PsnName: order.PsnName,
  434. Gend: order.Gend,
  435. Brdy: his.Brdy,
  436. Age: his.Age,
  437. Naty: order.Naty,
  438. PatnCertType: "01",
  439. Certno: order.Certno,
  440. Prfs: "90",
  441. ConerName: roles[0].UserName,
  442. PatnRlts: "99",
  443. ConerAddr: miConfig.OrgName,
  444. ConerTel: admin.Mobile,
  445. HiType: order.Insutype,
  446. Insuplc: miConfig.InsuplcAdmdvs,
  447. MaindiagFlag: "1",
  448. BillCode: order.FaPiaoCode,
  449. BillNo: order.FaPiaoNumber,
  450. BizSn: order.Number,
  451. PsnSelfPay: order.PsnPartAmt,
  452. PsnOwnPay: order.PsnPartAmt,
  453. AcctPay: order.AcctPay,
  454. PsnCashpay: order.PsnCashPay,
  455. HiPaymtd: "1",
  456. Hsorg: miConfig.InsuplcAdmdvs,
  457. HsorgOpter: miConfig.InsuplcAdmdvs,
  458. MedinsFillPsn: curRoles.UserName,
  459. MedinsFillDept: depart.Name,
  460. IptMedType: "2",
  461. }
  462. struct4101.SetlBegnDate = order.SetlTime
  463. struct4101.SetlEndDate = order.SetlTime
  464. //if order.SettleType == 1 {
  465. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  466. // dateStr := t.Format("2006-01-02")
  467. // struct4101.SetlBegnDate = dateStr
  468. // struct4101.SetlEndDate = dateStr
  469. //} else {
  470. // t := time.Unix(int64(order.SettleStartTime), 0)
  471. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  472. // dateStartStr := t.Format("2006-01-02")
  473. // dateEndStr := t2.Format("2006-01-02")
  474. // struct4101.SetlBegnDate = dateStartStr
  475. // struct4101.SetlEndDate = dateEndStr
  476. //}
  477. var rf []CustomFundPay
  478. json.Unmarshal([]byte(order.SetlDetail), &rf)
  479. var tempFunPays []service.CustomStruct
  480. for _, item := range rf {
  481. var tempFunPay service.CustomStruct
  482. tempFunPay.FundPayamt = item.FundPayamt
  483. tempFunPay.FundPayType = item.FundPayType
  484. tempFunPays = append(tempFunPays, tempFunPay)
  485. }
  486. struct4101.CustomStruct = tempFunPays
  487. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  488. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  489. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  490. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  491. var config []*models.HisXtDiagnoseConfig
  492. for _, item := range diagnosis_ids {
  493. id, _ := strconv.ParseInt(item, 10, 64)
  494. diagnosisConfig, _ := service.FindDiagnoseById(id)
  495. config = append(config, &diagnosisConfig)
  496. }
  497. for _, item := range config {
  498. var tempOpspdiseinfo service.OpspdiseinfoStruct
  499. tempOpspdiseinfo.DiagCode = item.CountryCode
  500. tempOpspdiseinfo.DiagName = item.CountryContentName
  501. tempOpspdiseinfo.MaindiagFlag = "1"
  502. tempOpspdiseinfo.OprnOprtCode = ""
  503. tempOpspdiseinfo.OprnOprtName = ""
  504. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  505. }
  506. sickConfigTwo, _ := service.FindSickById(his.SickType)
  507. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  508. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  509. tempOpspdiseinfo2.MaindiagFlag = "2"
  510. tempOpspdiseinfo2.OprnOprtCode = ""
  511. tempOpspdiseinfo2.OprnOprtName = ""
  512. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  513. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  514. var iteminfo service.IteminfoStruct
  515. var bedCostTotal float64 = 0 //床位总费
  516. var bedCostSelfTotal float64 = 0 //床位自费
  517. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  518. var operationCostTotal float64 = 0 //手术费
  519. var operationCostSelfTotal float64 = 0 //手术费
  520. var operationCostPartSelfTotal float64 = 0 //手术费
  521. var otherCostTotal float64 = 0 //其他费用
  522. var otherCostSelfTotal float64 = 0 //其他费用
  523. var otherCostPartSelfTotal float64 = 0 //其他费用
  524. var materialCostTotal float64 = 0 //材料费
  525. var materialCostSelfTotal float64 = 0 //材料费
  526. var materialCostPartSelfTotal float64 = 0 //材料费
  527. var westernMedicineCostTotal float64 = 0 //西药费
  528. var westernMedicineCostSelfTotal float64 = 0 //西药费
  529. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  530. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  531. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  532. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  533. var checkCostTotal float64 = 0 //检查费
  534. var checkCostSelfTotal float64 = 0 //检查费
  535. var checkCostPartSelfTotal float64 = 0 //检查费
  536. var laboratoryCostTotal float64 = 0 //化验费
  537. var laboratoryCostSelfTotal float64 = 0 //化验费
  538. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  539. var treatCostTotal float64 = 0 //治疗费用
  540. var treatCostSelfTotal float64 = 0 //治疗费用
  541. var treatCostPartSelfTotal float64 = 0 //治疗费用
  542. decimal.DivisionPrecision = 2
  543. var bed_fulamt_ownpay_amt float64 = 0
  544. var operation_fulamt_ownpay_amt float64 = 0
  545. var other_fulamt_ownpay_amt float64 = 0
  546. var westernMedicine_fulamt_ownpay_amt float64 = 0
  547. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  548. var check_fulamt_ownpay_amt float64 = 0
  549. var material_fulamt_ownpay_amt float64 = 0
  550. var laboratory_fulamt_ownpay_amt float64 = 0
  551. var treat_fulamt_ownpay_amt float64 = 0
  552. var bed_claa_sunmfee float64 = 0
  553. var bed_clab_amt float64 = 0
  554. var bed_other_amt float64 = 0
  555. var operation_claa_sunmfee float64 = 0
  556. var operation_clab_amt float64 = 0
  557. var operation_other_amt float64 = 0
  558. var other_claa_sunmfee float64 = 0
  559. var other_clab_amt float64 = 0
  560. var other_other_amt float64 = 0
  561. var westernMedicine_claa_sunmfee float64 = 0
  562. var westernMedicine_clab_amt float64 = 0
  563. var westernMedicine_other_amt float64 = 0
  564. var chineseTraditional_claa_sunmfee float64 = 0
  565. var chineseTraditional_clab_amt float64 = 0
  566. var chineseTraditional_other_amt float64 = 0
  567. var check_claa_sunmfee float64 = 0
  568. var check_clab_amt float64 = 0
  569. var check_other_amt float64 = 0
  570. var material_claa_sunmfee float64 = 0
  571. var material_clab_amt float64 = 0
  572. var material_other_amt float64 = 0
  573. var laboratory_claa_sunmfee float64 = 0
  574. var laboratory_clab_amt float64 = 0
  575. var laboratory_other_amt float64 = 0
  576. var treat_claa_sunmfee float64 = 0
  577. var treat_clab_amt float64 = 0
  578. var treat_other_amt float64 = 0
  579. for _, item := range order.HisOrderInfo {
  580. if item.MedChrgitmType == "01" { //床位费
  581. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  582. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  583. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  584. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  585. if item.ChrgitmLv == "1" {
  586. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  587. }
  588. if item.ChrgitmLv == "2" {
  589. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  590. }
  591. if item.ChrgitmLv == "3" {
  592. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  593. }
  594. }
  595. if item.MedChrgitmType == "03" { //检查费
  596. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  597. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  598. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  599. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  600. if item.ChrgitmLv == "1" {
  601. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  602. }
  603. if item.ChrgitmLv == "2" {
  604. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  605. }
  606. if item.ChrgitmLv == "3" {
  607. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  608. }
  609. }
  610. if item.MedChrgitmType == "04" { //化验费
  611. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  612. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  613. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  614. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  615. if item.ChrgitmLv == "1" {
  616. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  617. }
  618. if item.ChrgitmLv == "2" {
  619. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  620. }
  621. if item.ChrgitmLv == "3" {
  622. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  623. }
  624. }
  625. if item.MedChrgitmType == "05" { //治疗费
  626. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  627. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  628. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  629. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  630. if item.ChrgitmLv == "1" {
  631. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  632. }
  633. if item.ChrgitmLv == "2" {
  634. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  635. }
  636. if item.ChrgitmLv == "3" {
  637. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  638. }
  639. }
  640. if item.MedChrgitmType == "06" { //手术费
  641. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  642. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  643. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  644. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  645. if item.ChrgitmLv == "1" {
  646. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  647. }
  648. if item.ChrgitmLv == "2" {
  649. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  650. }
  651. if item.ChrgitmLv == "3" {
  652. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  653. }
  654. }
  655. if item.MedChrgitmType == "08" { //材料费
  656. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  657. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  658. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  659. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  660. if item.ChrgitmLv == "1" {
  661. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  662. }
  663. if item.ChrgitmLv == "2" {
  664. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  665. }
  666. if item.ChrgitmLv == "3" {
  667. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  668. }
  669. }
  670. if item.MedChrgitmType == "09" { //西药费
  671. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  672. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  673. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  674. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  675. if item.ChrgitmLv == "1" {
  676. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  677. }
  678. if item.ChrgitmLv == "2" {
  679. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  680. }
  681. if item.ChrgitmLv == "3" {
  682. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  683. }
  684. }
  685. if item.MedChrgitmType == "11" { //中成费
  686. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  687. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  688. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  689. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  690. if item.ChrgitmLv == "1" {
  691. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  692. }
  693. if item.ChrgitmLv == "2" {
  694. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  695. }
  696. if item.ChrgitmLv == "3" {
  697. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  698. }
  699. }
  700. if item.MedChrgitmType == "14" { //其他费
  701. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  702. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  703. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  704. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  705. if item.ChrgitmLv == "1" {
  706. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  707. }
  708. if item.ChrgitmLv == "2" {
  709. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  710. }
  711. if item.ChrgitmLv == "3" {
  712. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  713. }
  714. }
  715. }
  716. var iteminfoStructs []service.IteminfoStruct
  717. if bedCostTotal != 0 {
  718. iteminfo.MedChrgitm = "01"
  719. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  720. iteminfo.Amt = bedCostTotal
  721. iteminfo.ClaaSumfee = bed_claa_sunmfee
  722. iteminfo.ClabAmt = bed_clab_amt
  723. iteminfo.OthAmt = bed_other_amt
  724. iteminfoStructs = append(iteminfoStructs, iteminfo)
  725. }
  726. if checkCostTotal != 0 {
  727. iteminfo.MedChrgitm = "03"
  728. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  729. iteminfo.Amt = checkCostTotal
  730. iteminfo.ClaaSumfee = check_claa_sunmfee
  731. iteminfo.ClabAmt = check_clab_amt
  732. iteminfo.OthAmt = check_other_amt
  733. iteminfoStructs = append(iteminfoStructs, iteminfo)
  734. }
  735. if laboratoryCostTotal != 0 {
  736. iteminfo.MedChrgitm = "04"
  737. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  738. iteminfo.Amt = laboratoryCostTotal
  739. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  740. iteminfo.ClabAmt = laboratory_clab_amt
  741. iteminfo.OthAmt = laboratory_other_amt
  742. iteminfoStructs = append(iteminfoStructs, iteminfo)
  743. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  744. }
  745. if treatCostTotal != 0 {
  746. iteminfo.MedChrgitm = "05"
  747. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  748. iteminfo.Amt = treatCostTotal
  749. iteminfo.ClaaSumfee = treat_claa_sunmfee
  750. iteminfo.ClabAmt = treat_clab_amt
  751. iteminfo.OthAmt = treat_other_amt
  752. iteminfoStructs = append(iteminfoStructs, iteminfo)
  753. //(struct4101.IteminfoStruct, iteminfo)
  754. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  755. }
  756. if operationCostTotal != 0 {
  757. iteminfo.MedChrgitm = "06"
  758. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  759. iteminfo.Amt = operationCostTotal
  760. iteminfo.ClaaSumfee = operation_claa_sunmfee
  761. iteminfo.ClabAmt = operation_clab_amt
  762. iteminfo.OthAmt = operation_other_amt
  763. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  764. iteminfoStructs = append(iteminfoStructs, iteminfo)
  765. }
  766. if materialCostTotal != 0 {
  767. iteminfo.MedChrgitm = "08"
  768. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  769. iteminfo.Amt = materialCostTotal
  770. iteminfo.ClaaSumfee = material_claa_sunmfee
  771. iteminfo.ClabAmt = material_clab_amt
  772. iteminfo.OthAmt = material_other_amt
  773. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  774. iteminfoStructs = append(iteminfoStructs, iteminfo)
  775. }
  776. if westernMedicineCostTotal != 0 {
  777. iteminfo.MedChrgitm = "09"
  778. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  779. iteminfo.Amt = westernMedicineCostTotal
  780. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  781. iteminfo.ClabAmt = westernMedicine_clab_amt
  782. iteminfo.OthAmt = westernMedicine_other_amt
  783. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  784. iteminfoStructs = append(iteminfoStructs, iteminfo)
  785. }
  786. if chineseTraditionalMedicineCostTotal != 0 {
  787. iteminfo.MedChrgitm = "11"
  788. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  789. iteminfo.Amt = westernMedicineCostTotal
  790. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  791. iteminfo.ClabAmt = westernMedicine_clab_amt
  792. iteminfo.OthAmt = westernMedicine_other_amt
  793. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  794. iteminfoStructs = append(iteminfoStructs, iteminfo)
  795. }
  796. if otherCostTotal != 0 {
  797. iteminfo.MedChrgitm = "14"
  798. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  799. iteminfo.Amt = otherCostTotal
  800. iteminfo.ClaaSumfee = other_claa_sunmfee
  801. iteminfo.ClabAmt = other_clab_amt
  802. iteminfo.OthAmt = other_other_amt
  803. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  804. iteminfoStructs = append(iteminfoStructs, iteminfo)
  805. }
  806. struct4101.IteminfoStruct = iteminfoStructs
  807. struct4101.Ntly = "中国"
  808. struct4101.AdmCaty = "A03.06"
  809. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  810. fmt.Println(result)
  811. var dat map[string]interface{}
  812. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  813. fmt.Println(dat)
  814. } else {
  815. fmt.Println(err)
  816. }
  817. userJSONBytes, _ := json.Marshal(dat)
  818. var res ResultSeventeen
  819. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  820. utils.ErrorLog("解析失败:%v", err)
  821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  822. return
  823. }
  824. if res.Infcode != 0 {
  825. c.ServeSuccessJSON(map[string]interface{}{
  826. "failed_code": -10,
  827. "msg": res.ErrMsg,
  828. })
  829. return
  830. } else {
  831. hisFundSettleListResult := &models.HisFundSettleListResult{
  832. Number: res.Output.SetlListId,
  833. Status: 1,
  834. Ctime: time.Now().Unix(),
  835. Mtime: time.Now().Unix(),
  836. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  837. IsUpload: 1,
  838. OrderId: order_id,
  839. }
  840. service.CreateUploadRecord(hisFundSettleListResult)
  841. c.ServeSuccessJSON(map[string]interface{}{
  842. "msg": "上传成功",
  843. "result": hisFundSettleListResult,
  844. })
  845. return
  846. }
  847. }
  848. func (c *HisApiController) GetBatchSettleList() {
  849. org_id, _ := beego.AppConfig.Int64("org_id")
  850. //stage, _ := c.GetInt64("stage")
  851. orders, _ := service.GetAllHisOrder(org_id)
  852. for _, item := range orders {
  853. order_id := item.ID
  854. order, _ := service.GetHisOrderByIDTwo(order_id)
  855. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  856. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  857. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  858. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  859. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  860. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  861. if order.ID == 0 {
  862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  863. return
  864. }
  865. if his.BalanceAccountsType == 2 {
  866. continue
  867. }
  868. struct4101 := service.Struct4101{
  869. PsnNo: order.PsnNo,
  870. MdtrtId: order.MdtrtId,
  871. SetlId: order.SetlId,
  872. PsnName: order.PsnName,
  873. Gend: order.Gend,
  874. Brdy: his.Brdy,
  875. Age: his.Age,
  876. Naty: order.Naty,
  877. PatnCertType: "01",
  878. Certno: order.Certno,
  879. Prfs: "90",
  880. ConerName: roles[0].UserName,
  881. PatnRlts: "99",
  882. ConerAddr: miConfig.OrgName,
  883. ConerTel: admin.Mobile,
  884. HiType: order.Insutype,
  885. Insuplc: miConfig.InsuplcAdmdvs,
  886. MaindiagFlag: "1",
  887. BillCode: order.FaPiaoCode,
  888. BillNo: order.FaPiaoNumber,
  889. BizSn: order.Number,
  890. PsnSelfPay: order.PsnPartAmt,
  891. PsnOwnPay: order.PsnPartAmt,
  892. AcctPay: order.AcctPay,
  893. PsnCashpay: order.PsnCashPay,
  894. HiPaymtd: "1",
  895. Hsorg: miConfig.InsuplcAdmdvs,
  896. HsorgOpter: miConfig.InsuplcAdmdvs,
  897. MedinsFillPsn: curRoles.UserName,
  898. MedinsFillDept: depart.Name,
  899. IptMedType: "2",
  900. }
  901. struct4101.SetlBegnDate = order.SetlTime
  902. struct4101.SetlEndDate = order.SetlTime
  903. //if order.SettleType == 1 {
  904. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  905. // dateStr := t.Format("2006-01-02")
  906. // struct4101.SetlBegnDate = dateStr
  907. // struct4101.SetlEndDate = dateStr
  908. //} else {
  909. // t := time.Unix(int64(order.SettleStartTime), 0)
  910. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  911. // dateStartStr := t.Format("2006-01-02")
  912. // dateEndStr := t2.Format("2006-01-02")
  913. // struct4101.SetlBegnDate = dateStartStr
  914. // struct4101.SetlEndDate = dateEndStr
  915. //}
  916. var rf []CustomFundPay
  917. json.Unmarshal([]byte(order.SetlDetail), &rf)
  918. var tempFunPays []service.CustomStruct
  919. var tempFunPay610100 service.CustomStruct
  920. for _, item := range rf {
  921. if item.FundPayType == "610100" {
  922. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  923. tempFunPay610100.FundPayType = item.FundPayType
  924. } else {
  925. var tempFunPay service.CustomStruct
  926. tempFunPay.FundPayamt = item.FundPayamt
  927. tempFunPay.FundPayType = item.FundPayType
  928. tempFunPays = append(tempFunPays, tempFunPay)
  929. }
  930. }
  931. tempFunPays = append(tempFunPays, tempFunPay610100)
  932. struct4101.CustomStruct = tempFunPays
  933. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  934. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  935. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  936. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  937. var config []*models.HisXtDiagnoseConfig
  938. for _, item := range diagnosis_ids {
  939. id, _ := strconv.ParseInt(item, 10, 64)
  940. diagnosisConfig, _ := service.FindDiagnoseById(id)
  941. config = append(config, &diagnosisConfig)
  942. }
  943. for _, item := range config {
  944. var tempOpspdiseinfo service.OpspdiseinfoStruct
  945. tempOpspdiseinfo.DiagCode = item.CountryCode
  946. tempOpspdiseinfo.DiagName = item.CountryContentName
  947. tempOpspdiseinfo.MaindiagFlag = "1"
  948. tempOpspdiseinfo.OprnOprtCode = ""
  949. tempOpspdiseinfo.OprnOprtName = ""
  950. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  951. }
  952. sickConfigTwo, _ := service.FindSickById(his.SickType)
  953. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  954. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  955. tempOpspdiseinfo2.MaindiagFlag = "2"
  956. tempOpspdiseinfo2.OprnOprtCode = ""
  957. tempOpspdiseinfo2.OprnOprtName = ""
  958. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  959. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  960. var iteminfo service.IteminfoStruct
  961. var bedCostTotal float64 = 0 //床位总费
  962. var bedCostSelfTotal float64 = 0 //床位自费
  963. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  964. var examineCostTotal float64 = 0 //诊查总费
  965. var examineCostSelfTotal float64 = 0 //诊查自费
  966. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  967. var nursingCostTotal float64 = 0 //护理总费
  968. var nursingCostSelfTotal float64 = 0 //护理自费
  969. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  970. var chineseMedicineCostTotal float64 = 0 //中成药
  971. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  972. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  973. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  974. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  975. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  976. var registerCostTotal float64 = 0 //一般诊疗费
  977. var registerCostSelfTotal float64 = 0 //一般诊疗费
  978. var registerPartSelfTotal float64 = 0 //一般诊疗费
  979. var operationCostTotal float64 = 0 //手术费
  980. var operationCostSelfTotal float64 = 0 //手术费
  981. var operationCostPartSelfTotal float64 = 0 //手术费
  982. var otherCostTotal float64 = 0 //其他费用
  983. var otherCostSelfTotal float64 = 0 //其他费用
  984. var otherCostPartSelfTotal float64 = 0 //其他费用
  985. var materialCostTotal float64 = 0 //材料费
  986. var materialCostSelfTotal float64 = 0 //材料费
  987. var materialCostPartSelfTotal float64 = 0 //材料费
  988. var westernMedicineCostTotal float64 = 0 //西药费
  989. var westernMedicineCostSelfTotal float64 = 0 //西药费
  990. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  991. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  992. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  993. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  994. var checkCostTotal float64 = 0 //检查费
  995. var checkCostSelfTotal float64 = 0 //检查费
  996. var checkCostPartSelfTotal float64 = 0 //检查费
  997. var laboratoryCostTotal float64 = 0 //化验费
  998. var laboratoryCostSelfTotal float64 = 0 //化验费
  999. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1000. var treatCostTotal float64 = 0 //治疗费用
  1001. var treatCostSelfTotal float64 = 0 //治疗费用
  1002. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1003. decimal.DivisionPrecision = 2
  1004. var bed_fulamt_ownpay_amt float64 = 0
  1005. var examine_fulamt_ownpay_amt float64 = 0
  1006. var nursing_fulamt_ownpay_amt float64 = 0
  1007. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  1008. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  1009. var register_fulamt_ownpay_amt float64 = 0
  1010. var operation_fulamt_ownpay_amt float64 = 0
  1011. var other_fulamt_ownpay_amt float64 = 0
  1012. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1013. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1014. var check_fulamt_ownpay_amt float64 = 0
  1015. var material_fulamt_ownpay_amt float64 = 0
  1016. var laboratory_fulamt_ownpay_amt float64 = 0
  1017. var treat_fulamt_ownpay_amt float64 = 0
  1018. var bed_claa_sunmfee float64 = 0
  1019. var bed_clab_amt float64 = 0
  1020. var bed_other_amt float64 = 0
  1021. var examine_claa_sunmfee float64 = 0
  1022. var examine_clab_amt float64 = 0
  1023. var examine_other_amt float64 = 0
  1024. var nursing_claa_sunmfee float64 = 0
  1025. var nursing_clab_amt float64 = 0
  1026. var nursing_other_amt float64 = 0
  1027. var chinese_medicine_claa_sunmfee float64 = 0
  1028. var chinese_medicine_clab_amt float64 = 0
  1029. var chinese_medicine_other_amt float64 = 0
  1030. var commonly_treatment_claa_sunmfee float64 = 0
  1031. var commonly_treatment_clab_amt float64 = 0
  1032. var commonly_treatment_other_amt float64 = 0
  1033. var operation_claa_sunmfee float64 = 0
  1034. var operation_clab_amt float64 = 0
  1035. var operation_other_amt float64 = 0
  1036. var other_claa_sunmfee float64 = 0
  1037. var other_clab_amt float64 = 0
  1038. var other_other_amt float64 = 0
  1039. var westernMedicine_claa_sunmfee float64 = 0
  1040. var westernMedicine_clab_amt float64 = 0
  1041. var westernMedicine_other_amt float64 = 0
  1042. var chineseTraditional_claa_sunmfee float64 = 0
  1043. var chineseTraditional_clab_amt float64 = 0
  1044. var chineseTraditional_other_amt float64 = 0
  1045. var check_claa_sunmfee float64 = 0
  1046. var check_clab_amt float64 = 0
  1047. var check_other_amt float64 = 0
  1048. var material_claa_sunmfee float64 = 0
  1049. var material_clab_amt float64 = 0
  1050. var material_other_amt float64 = 0
  1051. var laboratory_claa_sunmfee float64 = 0
  1052. var laboratory_clab_amt float64 = 0
  1053. var laboratory_other_amt float64 = 0
  1054. var treat_claa_sunmfee float64 = 0
  1055. var treat_clab_amt float64 = 0
  1056. var treat_other_amt float64 = 0
  1057. var register_claa_sunmfee float64 = 0
  1058. var register_clab_amt float64 = 0
  1059. var register_other_amt float64 = 0
  1060. for _, item := range order.HisOrderInfo {
  1061. if item.MedChrgitmType == "01" { //床位费
  1062. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1063. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1064. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1065. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1066. if item.ChrgitmLv == "1" {
  1067. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1068. }
  1069. if item.ChrgitmLv == "2" {
  1070. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1071. }
  1072. if item.ChrgitmLv == "3" {
  1073. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1074. }
  1075. }
  1076. if item.MedChrgitmType == "02" { //诊查
  1077. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1078. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1079. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1080. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1081. if item.ChrgitmLv == "1" {
  1082. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1083. }
  1084. if item.ChrgitmLv == "2" {
  1085. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1086. }
  1087. if item.ChrgitmLv == "3" {
  1088. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1089. }
  1090. }
  1091. if item.MedChrgitmType == "03" { //检查费
  1092. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1093. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1094. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1095. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1096. if item.ChrgitmLv == "1" {
  1097. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1098. }
  1099. if item.ChrgitmLv == "2" {
  1100. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1101. }
  1102. if item.ChrgitmLv == "3" {
  1103. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1104. }
  1105. }
  1106. if item.MedChrgitmType == "04" { //化验费
  1107. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1108. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1109. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1110. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1111. if item.ChrgitmLv == "1" {
  1112. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1113. }
  1114. if item.ChrgitmLv == "2" {
  1115. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1116. }
  1117. if item.ChrgitmLv == "3" {
  1118. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1119. }
  1120. }
  1121. if item.MedChrgitmType == "05" { //治疗费
  1122. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1123. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1124. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1125. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1126. if item.ChrgitmLv == "1" {
  1127. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1128. }
  1129. if item.ChrgitmLv == "2" {
  1130. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1131. }
  1132. if item.ChrgitmLv == "3" {
  1133. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1134. }
  1135. }
  1136. if item.MedChrgitmType == "06" { //手术费
  1137. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1138. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1139. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1140. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1141. if item.ChrgitmLv == "1" {
  1142. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1143. }
  1144. if item.ChrgitmLv == "2" {
  1145. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1146. }
  1147. if item.ChrgitmLv == "3" {
  1148. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1149. }
  1150. }
  1151. if item.MedChrgitmType == "07" { //手术费
  1152. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1153. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1154. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1155. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1156. if item.ChrgitmLv == "1" {
  1157. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1158. }
  1159. if item.ChrgitmLv == "2" {
  1160. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1161. }
  1162. if item.ChrgitmLv == "3" {
  1163. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1164. }
  1165. }
  1166. if item.MedChrgitmType == "08" { //材料费
  1167. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1168. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1169. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1170. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1171. if item.ChrgitmLv == "1" {
  1172. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1173. }
  1174. if item.ChrgitmLv == "2" {
  1175. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1176. }
  1177. if item.ChrgitmLv == "3" {
  1178. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1179. }
  1180. }
  1181. if item.MedChrgitmType == "09" { //西药费
  1182. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1183. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1184. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1185. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1186. if item.ChrgitmLv == "1" {
  1187. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1188. }
  1189. if item.ChrgitmLv == "2" {
  1190. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1191. }
  1192. if item.ChrgitmLv == "3" {
  1193. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1194. }
  1195. }
  1196. if item.MedChrgitmType == "10" { //中药饮片
  1197. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1198. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1199. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1200. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1201. if item.ChrgitmLv == "1" {
  1202. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1203. }
  1204. if item.ChrgitmLv == "2" {
  1205. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1206. }
  1207. if item.ChrgitmLv == "3" {
  1208. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1209. }
  1210. }
  1211. if item.MedChrgitmType == "11" { //中成费
  1212. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1213. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1214. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1215. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1216. if item.ChrgitmLv == "1" {
  1217. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1218. }
  1219. if item.ChrgitmLv == "2" {
  1220. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1221. }
  1222. if item.ChrgitmLv == "3" {
  1223. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1224. }
  1225. }
  1226. if item.MedChrgitmType == "12" { //中成费
  1227. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1228. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1229. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1230. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1231. if item.ChrgitmLv == "1" {
  1232. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1233. }
  1234. if item.ChrgitmLv == "2" {
  1235. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1236. }
  1237. if item.ChrgitmLv == "3" {
  1238. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1239. }
  1240. }
  1241. if item.MedChrgitmType == "13" { //中成费
  1242. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1243. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1244. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1245. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1246. if item.ChrgitmLv == "1" {
  1247. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1248. }
  1249. if item.ChrgitmLv == "2" {
  1250. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1251. }
  1252. if item.ChrgitmLv == "3" {
  1253. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1254. }
  1255. }
  1256. if item.MedChrgitmType == "14" { //其他费
  1257. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1258. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1259. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1260. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1261. if item.ChrgitmLv == "1" {
  1262. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1263. }
  1264. if item.ChrgitmLv == "2" {
  1265. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1266. }
  1267. if item.ChrgitmLv == "3" {
  1268. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1269. }
  1270. }
  1271. }
  1272. var iteminfoStructs []service.IteminfoStruct
  1273. if bedCostTotal != 0 {
  1274. iteminfo.MedChrgitm = "01"
  1275. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1276. iteminfo.Amt = bedCostTotal
  1277. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1278. iteminfo.ClabAmt = bed_clab_amt
  1279. iteminfo.OthAmt = bed_other_amt
  1280. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1281. }
  1282. if examineCostTotal != 0 {
  1283. iteminfo.MedChrgitm = "02"
  1284. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  1285. iteminfo.Amt = examineCostTotal
  1286. iteminfo.ClaaSumfee = examine_claa_sunmfee
  1287. iteminfo.ClabAmt = examine_clab_amt
  1288. iteminfo.OthAmt = examine_other_amt
  1289. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1290. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1291. }
  1292. if checkCostTotal != 0 {
  1293. iteminfo.MedChrgitm = "03"
  1294. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1295. iteminfo.Amt = checkCostTotal
  1296. iteminfo.ClaaSumfee = check_claa_sunmfee
  1297. iteminfo.ClabAmt = check_clab_amt
  1298. iteminfo.OthAmt = check_other_amt
  1299. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1300. }
  1301. if laboratoryCostTotal != 0 {
  1302. iteminfo.MedChrgitm = "04"
  1303. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1304. iteminfo.Amt = laboratoryCostTotal
  1305. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1306. iteminfo.ClabAmt = laboratory_clab_amt
  1307. iteminfo.OthAmt = laboratory_other_amt
  1308. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1309. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1310. }
  1311. if treatCostTotal != 0 {
  1312. iteminfo.MedChrgitm = "05"
  1313. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1314. iteminfo.Amt = treatCostTotal
  1315. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1316. iteminfo.ClabAmt = treat_clab_amt
  1317. iteminfo.OthAmt = treat_other_amt
  1318. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1319. //(struct4101.IteminfoStruct, iteminfo)
  1320. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1321. }
  1322. if operationCostTotal != 0 {
  1323. iteminfo.MedChrgitm = "06"
  1324. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1325. iteminfo.Amt = operationCostTotal
  1326. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1327. iteminfo.ClabAmt = operation_clab_amt
  1328. iteminfo.OthAmt = operation_other_amt
  1329. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1330. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1331. }
  1332. if nursingCostTotal != 0 {
  1333. iteminfo.MedChrgitm = "07"
  1334. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  1335. iteminfo.Amt = nursingCostTotal
  1336. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  1337. iteminfo.ClabAmt = nursing_clab_amt
  1338. iteminfo.OthAmt = nursing_other_amt
  1339. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1340. }
  1341. if materialCostTotal != 0 {
  1342. iteminfo.MedChrgitm = "08"
  1343. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1344. iteminfo.Amt = materialCostTotal
  1345. iteminfo.ClaaSumfee = material_claa_sunmfee
  1346. iteminfo.ClabAmt = material_clab_amt
  1347. iteminfo.OthAmt = material_other_amt
  1348. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1349. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1350. }
  1351. if westernMedicineCostTotal != 0 {
  1352. iteminfo.MedChrgitm = "09"
  1353. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1354. iteminfo.Amt = westernMedicineCostTotal
  1355. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1356. iteminfo.ClabAmt = westernMedicine_clab_amt
  1357. iteminfo.OthAmt = westernMedicine_other_amt
  1358. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1359. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1360. }
  1361. if chineseMedicineCostTotal != 0 {
  1362. iteminfo.MedChrgitm = "10"
  1363. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  1364. iteminfo.Amt = chineseMedicineCostTotal
  1365. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  1366. iteminfo.ClabAmt = chinese_medicine_clab_amt
  1367. iteminfo.OthAmt = chinese_medicine_other_amt
  1368. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1369. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1370. }
  1371. if chineseTraditionalMedicineCostTotal != 0 {
  1372. iteminfo.MedChrgitm = "11"
  1373. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1374. iteminfo.Amt = westernMedicineCostTotal
  1375. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1376. iteminfo.ClabAmt = westernMedicine_clab_amt
  1377. iteminfo.OthAmt = westernMedicine_other_amt
  1378. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1379. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1380. }
  1381. if commonlyTreatmentCostTotal != 0 {
  1382. iteminfo.MedChrgitm = "12"
  1383. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  1384. iteminfo.Amt = commonlyTreatmentCostTotal
  1385. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  1386. iteminfo.ClabAmt = commonly_treatment_clab_amt
  1387. iteminfo.OthAmt = commonly_treatment_other_amt
  1388. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1389. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1390. }
  1391. if registerCostTotal != 0 {
  1392. iteminfo.MedChrgitm = "13"
  1393. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  1394. iteminfo.Amt = registerCostTotal
  1395. iteminfo.ClaaSumfee = register_claa_sunmfee
  1396. iteminfo.ClabAmt = register_clab_amt
  1397. iteminfo.OthAmt = register_other_amt
  1398. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1399. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1400. }
  1401. if otherCostTotal != 0 {
  1402. iteminfo.MedChrgitm = "14"
  1403. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1404. iteminfo.Amt = otherCostTotal
  1405. iteminfo.ClaaSumfee = other_claa_sunmfee
  1406. iteminfo.ClabAmt = other_clab_amt
  1407. iteminfo.OthAmt = other_other_amt
  1408. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1409. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1410. }
  1411. struct4101.IteminfoStruct = iteminfoStructs
  1412. struct4101.Ntly = "中国"
  1413. struct4101.AdmCaty = "A03.06"
  1414. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  1415. fmt.Println(result)
  1416. var dat map[string]interface{}
  1417. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1418. fmt.Println(dat)
  1419. } else {
  1420. fmt.Println(err)
  1421. }
  1422. userJSONBytes, _ := json.Marshal(dat)
  1423. var res ResultSeventeen
  1424. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1425. utils.ErrorLog("解析失败:%v", err)
  1426. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1427. adminUser := c.GetAdminUserInfo()
  1428. errlog := &models.HisOrderError{
  1429. UserOrgId: adminUser.CurrentOrgId,
  1430. Ctime: time.Now().Unix(),
  1431. Mtime: time.Now().Unix(),
  1432. ErrMsg: res.ErrMsg + "解析失败",
  1433. Status: 1,
  1434. PatientId: order_id,
  1435. Stage: 40,
  1436. }
  1437. service.CreateErrMsgLog(errlog)
  1438. continue
  1439. }
  1440. if res.Infcode != 0 {
  1441. adminUser := c.GetAdminUserInfo()
  1442. errlog := &models.HisOrderError{
  1443. UserOrgId: adminUser.CurrentOrgId,
  1444. Ctime: time.Now().Unix(),
  1445. Mtime: time.Now().Unix(),
  1446. ErrMsg: res.ErrMsg,
  1447. Status: 1,
  1448. PatientId: order_id,
  1449. Stage: 40,
  1450. }
  1451. service.CreateErrMsgLog(errlog)
  1452. continue
  1453. } else {
  1454. hisFundSettleListResult := &models.HisFundSettleListResult{
  1455. Number: res.Output.SetlListId,
  1456. Status: 1,
  1457. Ctime: time.Now().Unix(),
  1458. Mtime: time.Now().Unix(),
  1459. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1460. IsUpload: 1,
  1461. OrderId: order_id,
  1462. }
  1463. service.CreateUploadRecord(hisFundSettleListResult)
  1464. continue
  1465. }
  1466. }
  1467. }
  1468. //func (c *HisApiController) TestPay() {
  1469. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  1470. // readCards := DllDef2.MustFindProc("BankTrans")
  1471. // inputData := make(map[string]interface{})
  1472. // inputData["transId"] = "05"
  1473. // inputData["amount"] = "0.01"
  1474. // inputData["traceNo"] = "20210227093601325405377"
  1475. // inputData["cardNo"] = "F36084348"
  1476. // inputData["id"] = "44022919620927046X"
  1477. // //jsonStr := `
  1478. // // {
  1479. // // "transId": "05",
  1480. // // "amount":"1.00",
  1481. // // "traceNo":"20210227093601325405377",
  1482. // // "cardNo":"F36084348",
  1483. // // "id":"44022919620927046X"
  1484. // //
  1485. // // }
  1486. // //`
  1487. //
  1488. // bytes_arr, _ := json.Marshal(inputData)
  1489. // str3 := make([]byte, 256)
  1490. // ret4, _, err4 := readCards.Call(StrPtr(string(bytes_arr)), (uintptr)(unsafe.Pointer(&str3[0])))
  1491. // fmt.Println(":", string(str3))
  1492. //
  1493. // if err4 != nil {
  1494. // fmt.Println("SSCard的运算结果为:", ret4)
  1495. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1496. // return
  1497. // }
  1498. //
  1499. //}
  1500. //func (c *HisApiController) TestGetBasBaseInfo() {
  1501. //
  1502. // //result := C.Init(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  1503. // //fmt.Println(result)
  1504. // //cs1 := C.CString("")
  1505. // //cs2 := C.CString("")
  1506. // //C.ReadCardBas(cs1, IntPtr(1024), cs2, IntPtr(1024))
  1507. // //fmt.Println(cs1)
  1508. // //fmt.Println(cs2)
  1509. // //C.free(unsafe.Pointer(cs1))
  1510. // //C.free(unsafe.Pointer(cs2))
  1511. //
  1512. // //
  1513. //
  1514. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  1515. // Iinit := DllDef.MustFindProc("Init")
  1516. // readCard := DllDef.MustFindProc("ReadCardBas")
  1517. // ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  1518. // if ret != 0 {
  1519. // fmt.Println("SSCard的报错原因:", err)
  1520. // fmt.Println("SSCard的运算结果为:", ret)
  1521. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1522. // return
  1523. // }
  1524. //
  1525. // result := int(ret)
  1526. // fmt.Println("SSCard的运算结果为1:", result)
  1527. //
  1528. // //path := ""
  1529. // //bytePath := []byte( "\x00")
  1530. // //bytePath2 := []byte( "\x00")
  1531. // //ssss
  1532. //
  1533. // str := make([]byte, 256)
  1534. // str1 := make([]byte, 256)
  1535. // s2 := []byte(string(str))
  1536. // s3 := []byte(string(str1))
  1537. // ret2, _, err2 := readCard.Call((uintptr)(unsafe.Pointer(&s2[0])), IntPtr(256), (uintptr)(unsafe.Pointer(&s3[0])), IntPtr(256))
  1538. // fmt.Println(" Add(4,5)的结果为:", ret2)
  1539. // fmt.Println(" str:", s2)
  1540. // fmt.Println(" str1:", s3)
  1541. // if err2 != nil {
  1542. // fmt.Println("SSCard的运算结果为:", ret2)
  1543. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1544. // return
  1545. // }
  1546. //
  1547. // //DllDef := syscall.MustLoadDLL("SSCard.dll")
  1548. //
  1549. //}
  1550. func (c *HisApiController) GetOrgInfo() {
  1551. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  1552. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  1553. }
  1554. func (c *HisApiController) GetHisPatientInfo() {
  1555. medical_insurance_card := c.GetString("medical_insurance_card")
  1556. id_card_type, _ := c.GetInt64("id_card_type")
  1557. id_card := c.GetString("id_card")
  1558. adminInfo := c.GetAdminUserInfo()
  1559. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  1560. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1561. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  1562. IdCardNo := ""
  1563. if id_card_type == 1 {
  1564. IdCardNo = medical_insurance_card
  1565. } else if id_card_type == 2 {
  1566. IdCardNo = id_card
  1567. }
  1568. if config.IsOpen == 1 {
  1569. api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  1570. resp, requestErr := http.Get(api)
  1571. if requestErr != nil {
  1572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1573. return
  1574. }
  1575. defer resp.Body.Close()
  1576. body, ioErr := ioutil.ReadAll(resp.Body)
  1577. if ioErr != nil {
  1578. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1580. return
  1581. }
  1582. var respJSON map[string]interface{}
  1583. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1586. return
  1587. }
  1588. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1589. userJSONBytes, _ := json.Marshal(userJSON)
  1590. var res ResultTwo
  1591. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1592. utils.ErrorLog("解析失败:%v", err)
  1593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1594. return
  1595. }
  1596. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1597. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1598. infoStr := string(Iinfos)
  1599. idetinfoStr := string(Idetinfos)
  1600. if res.Infcode == 0 {
  1601. his := models.VMHisPatient{
  1602. Status: 1,
  1603. Ctime: time.Now().Unix(),
  1604. Mtime: time.Now().Unix(),
  1605. PsnNo: res.Output.Baseinfo.PsnNo,
  1606. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1607. Certno: res.Output.Baseinfo.Certno,
  1608. PsnName: res.Output.Baseinfo.PsnName,
  1609. Gend: res.Output.Baseinfo.Gend,
  1610. Naty: res.Output.Baseinfo.Naty,
  1611. Brdy: res.Output.Baseinfo.Brdy,
  1612. Age: res.Output.Baseinfo.Age,
  1613. Iinfo: infoStr,
  1614. Idetinfo: idetinfoStr,
  1615. UserOrgId: adminInfo.CurrentOrgId,
  1616. IsReturn: 1,
  1617. IdCardType: id_card_type,
  1618. }
  1619. c.ServeSuccessJSON(map[string]interface{}{
  1620. "info": his,
  1621. })
  1622. } else {
  1623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1624. return
  1625. }
  1626. }
  1627. }
  1628. //func GetBasBaseInfo() (jsonStr string, err error) {
  1629. //
  1630. // handle := syscall.NewLazyDLL("SSCard.dll")
  1631. // add := handle.NewProc("ReadCardBas")
  1632. // str := make([]byte, 1024)
  1633. // str1 := make([]byte, 1024)
  1634. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1635. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  1636. //
  1637. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  1638. //
  1639. // fmt.Println("> Add(4,5)的结果为:", ret)
  1640. // handle.Release()
  1641. //
  1642. // return "", nil
  1643. //
  1644. //}
  1645. //func GetQRBaseInfo() (jsonStr string, err error) {
  1646. // handle := syscall.LoadDLL("SSCard.dll")
  1647. // ReadCardBas := handle.FindProc("GetQRBase")
  1648. //
  1649. // str := make([]byte, 256)
  1650. // str1 := make([]byte, 256)
  1651. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1652. //
  1653. // fmt.Println(string(str))
  1654. // fmt.Println(r)
  1655. // return string(str), nil
  1656. //}
  1657. //func CardInit() int {
  1658. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  1659. // add := DllTestDef.MustFindProc("Init")
  1660. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  1661. // if err != nil {
  1662. // fmt.Println("SSCard的运算结果为:", ret)
  1663. // }
  1664. // result := int(ret)
  1665. // return result
  1666. //}
  1667. //func CardInit() int {
  1668. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  1669. // if err != nil {
  1670. // fmt.Println("SSCard的运算结果为:", ret)
  1671. // }
  1672. // fmt.Println(err)
  1673. // result := int(ret)
  1674. // return result
  1675. //}
  1676. func IntPtr(n int) uintptr {
  1677. return uintptr(n)
  1678. }
  1679. func StrPtr(s string) uintptr {
  1680. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  1681. }
  1682. type ResultTwo struct {
  1683. ErrMsg string `json:"err_msg"`
  1684. InfRefmsgid string `json:"inf_refmsgid"`
  1685. Infcode int64 `json:"infcode"`
  1686. Output struct {
  1687. Baseinfo struct {
  1688. Age float64 `json:"age"`
  1689. Brdy string `json:"brdy"`
  1690. Certno string `json:"certno"`
  1691. Gend string `json:"gend"`
  1692. Naty string `json:"naty"`
  1693. PsnCertType string `json:"psn_cert_type"`
  1694. PsnName string `json:"psn_name"`
  1695. PsnNo string `json:"psn_no"`
  1696. } `json:"baseinfo"`
  1697. Idetinfo []interface{} `json:"idetinfo"`
  1698. Iinfo []struct {
  1699. Balc float64 `json:"balc"`
  1700. CvlservFlag string `json:"cvlserv_flag"`
  1701. EmpName string `json:"emp_name"`
  1702. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1703. Insutype string `json:"insutype"`
  1704. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  1705. PausInsuDate string `json:"paus_insu_date"`
  1706. PsnInsuDate string `json:"psn_insu_date"`
  1707. PsnInsuStas string `json:"psn_insu_stas"`
  1708. PsnType string `json:"psn_type"`
  1709. } `json:"insuinfo"`
  1710. } `json:"output"`
  1711. RefmsgTime string `json:"refmsg_time"`
  1712. RespondTime string `json:"respond_time"`
  1713. Signtype interface{} `json:"signtype"`
  1714. WarnInfo interface{} `json:"warn_info"`
  1715. }
  1716. type ResultThree struct {
  1717. Cainfo interface{} `json:"cainfo"`
  1718. ErrMsg string `json:"err_msg"`
  1719. InfRefmsgid string `json:"inf_refmsgid"`
  1720. Infcode int64 `json:"infcode"`
  1721. Output struct {
  1722. Data struct {
  1723. IptOtpNo string `json:"ipt_otp_no"`
  1724. MdtrtID string `json:"mdtrt_id"`
  1725. PsnNo string `json:"psn_no"`
  1726. } `json:"data"`
  1727. } `json:"output"`
  1728. RefmsgTime string `json:"refmsg_time"`
  1729. RespondTime string `json:"respond_time"`
  1730. Signtype interface{} `json:"signtype"`
  1731. WarnMsg interface{} `json:"warn_msg"`
  1732. }
  1733. type ResultFour struct {
  1734. Cainfo string `json:"cainfo"`
  1735. ErrMsg string `json:"err_msg"`
  1736. InfRefmsgid string `json:"inf_refmsgid"`
  1737. Infcode int64 `json:"infcode"`
  1738. Output struct {
  1739. Result []struct {
  1740. BasMednFlag string `json:"bas_medn_flag"`
  1741. ChldMedcFlag string `json:"chld_medc_flag"`
  1742. ChrgitmLv string `json:"chrgitm_lv"`
  1743. Cnt float64 `json:"cnt"`
  1744. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  1745. DrtReimFlag string `json:"drt_reim_flag"`
  1746. FeedetlSn string `json:"feedetl_sn"`
  1747. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1748. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  1749. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1750. ListSpItemFlag string `json:"list_sp_item_flag"`
  1751. LmtUsedFlag string `json:"lmt_used_flag"`
  1752. MedChrgitmType string `json:"med_chrgitm_type"`
  1753. Memo string `json:"memo"`
  1754. OverlmtAmt float64 `json:"overlmt_amt"`
  1755. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1756. Pric float64 `json:"pric"`
  1757. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  1758. SelfpayProp float64 `json:"selfpay_prop"`
  1759. } `json:"result"`
  1760. } `json:"output"`
  1761. RefmsgTime string `json:"refmsg_time"`
  1762. RespondTime string `json:"respond_time"`
  1763. Signtype string `json:"signtype"`
  1764. WarnMsg string `json:"warn_msg"`
  1765. }
  1766. type ResultFive struct {
  1767. Balc float64 `json:"balc"`
  1768. CvlservFlag string `json:"cvlserv_flag"`
  1769. EmpName string `json:"emp_name"`
  1770. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1771. Insutype string `json:"insutype"`
  1772. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  1773. PausInsuDate string `json:"paus_insu_date"`
  1774. PsnInsuDate string `json:"psn_insu_date"`
  1775. PsnInsuStas string `json:"psn_insu_stas"`
  1776. PsnType string `json:"psn_type"`
  1777. }
  1778. type ResultSix struct {
  1779. Cainfo interface{} `json:"cainfo"`
  1780. ErrMsg string `json:"err_msg"`
  1781. InfRefmsgid string `json:"inf_refmsgid"`
  1782. Infcode int64 `json:"infcode"`
  1783. Output struct {
  1784. } `json:"output"`
  1785. RefmsgTime string `json:"refmsg_time"`
  1786. RespondTime string `json:"respond_time"`
  1787. Signtype interface{} `json:"signtype"`
  1788. WarnMsg interface{} `json:"warn_msg"`
  1789. }
  1790. type ResultSeven struct {
  1791. Cainfo string `json:"cainfo"`
  1792. ErrMsg string `json:"err_msg"`
  1793. InfRefmsgid string `json:"inf_refmsgid"`
  1794. Infcode int64 `json:"infcode"`
  1795. Output struct {
  1796. Setldetail []interface{} `json:"setldetail"`
  1797. Setlinfo struct {
  1798. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  1799. AcctPay float64 `json:"acct_pay"`
  1800. ActPayDedc float64 `json:"act_pay_dedc"`
  1801. Age float64 `json:"age"`
  1802. Balc float64 `json:"balc"`
  1803. Brdy string `json:"brdy"`
  1804. Certno string `json:"certno"`
  1805. ClrOptins string `json:"clr_optins"`
  1806. ClrType string `json:"clr_type"`
  1807. ClrWay string `json:"clr_way"`
  1808. CvlservFlag string `json:"cvlserv_flag"`
  1809. CvlservPay float64 `json:"cvlserv_pay"`
  1810. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1811. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1812. Gend string `json:"gend"`
  1813. HifesPay float64 `json:"hifes_pay"`
  1814. HifmiPay float64 `json:"hifmi_pay"`
  1815. HifpPay float64 `json:"hifp_pay"`
  1816. HospPartAmt float64 `json:"hosp_part_amt"`
  1817. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1818. Insutype string `json:"insutype"`
  1819. MafPay float64 `json:"maf_pay"`
  1820. MdtrtCertType string `json:"mdtrt_cert_type"`
  1821. HifobPay float64 `json:"hifob_pay"`
  1822. MdtrtID string `json:"mdtrt_id"`
  1823. MedType string `json:"med_type"`
  1824. MedfeeSumamt float64 `json:"medfee_sumamt"`
  1825. MedinsSetlID string `json:"medins_setl_id"`
  1826. Naty string `json:"naty"`
  1827. OthPay float64 `json:"oth_pay"`
  1828. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1829. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1830. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1831. PsnCashPay float64 `json:"psn_cash_pay"`
  1832. PsnCertType string `json:"psn_cert_type"`
  1833. PsnName string `json:"psn_name"`
  1834. PsnNo string `json:"psn_no"`
  1835. PsnPartAmt float64 `json:"psn_part_amt"`
  1836. PsnType string `json:"psn_type"`
  1837. SetlID string `json:"setl_id"`
  1838. SetlTime string `json:"setl_time"`
  1839. } `json:"setlinfo"`
  1840. } `json:"output"`
  1841. RefmsgTime string `json:"refmsg_time"`
  1842. RespondTime string `json:"respond_time"`
  1843. Signtype interface{} `json:"signtype"`
  1844. WarnMsg interface{} `json:"warn_msg"`
  1845. }
  1846. type ResultEight struct {
  1847. Cainfo string `json:"cainfo"`
  1848. ErrMsg string `json:"err_msg"`
  1849. InfRefmsgid string `json:"inf_refmsgid"`
  1850. Infcode int64 `json:"infcode"`
  1851. Output struct {
  1852. Stmtinfo struct {
  1853. SetlOptins string `json:"setl_optins"`
  1854. StmtRslt string `json:"stmt_rslt"`
  1855. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  1856. } `json:"stmtinfo"`
  1857. } `json:"output"`
  1858. RefmsgTime string `json:"refmsg_time"`
  1859. RespondTime string `json:"respond_time"`
  1860. Signtype interface{} `json:"signtype"`
  1861. WarnMsg interface{} `json:"warn_msg"`
  1862. }
  1863. type ResultNine struct {
  1864. Cainfo string `json:"cainfo"`
  1865. ErrMsg string `json:"err_msg"`
  1866. InfRefmsgid string `json:"inf_refmsgid"`
  1867. Infcode int64 `json:"infcode"`
  1868. Output struct {
  1869. FileQuryNo string `json:"file_qury_no"`
  1870. } `json:"output"`
  1871. RefmsgTime string `json:"refmsg_time"`
  1872. RespondTime string `json:"respond_time"`
  1873. Signtype interface{} `json:"signtype"`
  1874. WarnMsg interface{} `json:"warn_msg"`
  1875. }
  1876. type ResultTen struct {
  1877. Cainfo string `json:"cainfo"`
  1878. ErrMsg string `json:"err_msg"`
  1879. InfRefmsgid string `json:"inf_refmsgid"`
  1880. Infcode int64 `json:"infcode"`
  1881. Output struct {
  1882. DldEndtime string `json:"dld_endtime"`
  1883. FileQuryNo string `json:"file_qury_no"`
  1884. Filename string `json:"filename"`
  1885. } `json:"output"`
  1886. RefmsgTime string `json:"refmsg_time"`
  1887. RespondTime string `json:"respond_time"`
  1888. Signtype interface{} `json:"signtype"`
  1889. WarnMsg interface{} `json:"warn_msg"`
  1890. }
  1891. //type Autogenerated struct {
  1892. // Output struct {
  1893. // Setlinfo struct {
  1894. // SetlTime string `json:"setl_time"`
  1895. // CvlservPay float64 `json:"cvlserv_pay"`
  1896. // Year string `json:"year"`
  1897. // MedType string `json:"med_type"`
  1898. // PsnPay float64 `json:"psn_pay"`
  1899. // OpterID string `json:"opter_id"`
  1900. // Begndate string `json:"begndate"`
  1901. // FlxempeFlag string `json:"flxempe_flag"`
  1902. // HifmiPay float64 `json:"hifmi_pay"`
  1903. // PsnNo string `json:"psn_no"`
  1904. // ActPayDedc float64 `json:"act_pay_dedc"`
  1905. // MedinsSetlID interface{} `json:"medins_setl_id"`
  1906. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  1907. // ClrWay string `json:"clr_way"`
  1908. // OthPay float64 `json:"oth_pay"`
  1909. // Gend string `json:"gend"`
  1910. // MdtrtID string `json:"mdtrt_id"`
  1911. // AcctPay float64 `json:"acct_pay"`
  1912. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  1913. // Insutype string `json:"insutype"`
  1914. // Invono interface{} `json:"invono"`
  1915. // Enddate string `json:"enddate"`
  1916. // CashPayamt float64 `json:"cash_payamt"`
  1917. // PsnType string `json:"psn_type"`
  1918. // FixmedinsName string `json:"fixmedins_name"`
  1919. // HifpPay float64 `json:"hifp_pay"`
  1920. // NewFlag interface{} `json:"new_flag"`
  1921. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1922. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  1923. // PayLoc string `json:"pay_loc"`
  1924. // ClrType string `json:"clr_type"`
  1925. // RefdSetlFlag string `json:"refd_setl_flag"`
  1926. // CvlservFlag string `json:"cvlserv_flag"`
  1927. // EmpName string `json:"emp_name"`
  1928. // Brdy string `json:"brdy"`
  1929. // Naty string `json:"naty"`
  1930. // Certno string `json:"certno"`
  1931. // DiseCode string `json:"dise_code"`
  1932. // FixmedinsCode string `json:"fixmedins_code"`
  1933. // DedcHospLv string `json:"dedc_hosp_lv"`
  1934. // OpterName string `json:"opter_name"`
  1935. // Balc float64 `json:"balc"`
  1936. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  1937. // PsnCertType string `json:"psn_cert_type"`
  1938. // HifobPay float64 `json:"hifob_pay"`
  1939. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  1940. // HifesPay float64 `json:"hifes_pay"`
  1941. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1942. // OptTime string `json:"opt_time"`
  1943. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1944. // SetlID string `json:"setl_id"`
  1945. // MafPay float64 `json:"maf_pay"`
  1946. // PsnName string `json:"psn_name"`
  1947. // InsuOptins interface{} `json:"insu_optins"`
  1948. // PrefFundPay interface{} `json:"pref_fund_pay"`
  1949. // ClrOptins string `json:"clr_optins"`
  1950. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1951. // DiseName string `json:"dise_name"`
  1952. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  1953. // Age float64 `json:"age"`
  1954. // DtrtCertType string `json:"dtrt_cert_type"`
  1955. // HospLv string `json:"hosp_lv"`
  1956. // } `json:"setlinfo"`
  1957. // Setldetail []struct {
  1958. // FundPayType string `json:"fund_pay_type"`
  1959. // FundPayamt float64 `json:"fund_payamt"`
  1960. // SetlProcInfo interface{} `json:"setl_proc_info"`
  1961. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  1962. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  1963. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  1964. // PrefFundPay interface{} `json:"pref_fund_pay"`
  1965. // } `json:"setldetail"`
  1966. // } `json:"output"`
  1967. // Infcode int `json:"infcode"`
  1968. // WarnMsg interface{} `json:"warn_msg"`
  1969. // Cainfo interface{} `json:"cainfo"`
  1970. // ErrMsg interface{} `json:"err_msg"`
  1971. // RefmsgTime string `json:"refmsg_time"`
  1972. // Signtype interface{} `json:"signtype"`
  1973. // RespondTime string `json:"respond_time"`
  1974. // InfRefmsgid string `json:"inf_refmsgid"`
  1975. //}
  1976. type ResultEleven struct {
  1977. Cainfo string `json:"cainfo"`
  1978. ErrMsg string `json:"err_msg"`
  1979. InfRefmsgid string `json:"inf_refmsgid"`
  1980. Infcode int64 `json:"infcode"`
  1981. Output struct {
  1982. Setlinfo struct {
  1983. SetlTime string `json:"setl_time"`
  1984. CvlservPay float64 `json:"cvlserv_pay"`
  1985. Year string `json:"year"`
  1986. MedType string `json:"med_type"`
  1987. PsnPay float64 `json:"psn_pay"`
  1988. OpterID string `json:"opter_id"`
  1989. Begndate string `json:"begndate"`
  1990. FlxempeFlag string `json:"flxempe_flag"`
  1991. HifmiPay float64 `json:"hifmi_pay"`
  1992. PsnNo string `json:"psn_no"`
  1993. ActPayDedc float64 `json:"act_pay_dedc"`
  1994. MedinsSetlID interface{} `json:"medins_setl_id"`
  1995. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  1996. ClrWay string `json:"clr_way"`
  1997. OthPay float64 `json:"oth_pay"`
  1998. Gend string `json:"gend"`
  1999. MdtrtID string `json:"mdtrt_id"`
  2000. AcctPay float64 `json:"acct_pay"`
  2001. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2002. Insutype string `json:"insutype"`
  2003. Invono interface{} `json:"invono"`
  2004. Enddate string `json:"enddate"`
  2005. CashPayamt float64 `json:"cash_payamt"`
  2006. PsnType string `json:"psn_type"`
  2007. FixmedinsName string `json:"fixmedins_name"`
  2008. HifpPay float64 `json:"hifp_pay"`
  2009. NewFlag interface{} `json:"new_flag"`
  2010. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2011. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2012. PayLoc string `json:"pay_loc"`
  2013. ClrType string `json:"clr_type"`
  2014. RefdSetlFlag string `json:"refd_setl_flag"`
  2015. CvlservFlag string `json:"cvlserv_flag"`
  2016. EmpName string `json:"emp_name"`
  2017. Brdy string `json:"brdy"`
  2018. Naty string `json:"naty"`
  2019. Certno string `json:"certno"`
  2020. DiseCode string `json:"dise_code"`
  2021. FixmedinsCode string `json:"fixmedins_code"`
  2022. DedcHospLv string `json:"dedc_hosp_lv"`
  2023. OpterName string `json:"opter_name"`
  2024. Balc float64 `json:"balc"`
  2025. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2026. PsnCertType string `json:"psn_cert_type"`
  2027. HifobPay float64 `json:"hifob_pay"`
  2028. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2029. HifesPay float64 `json:"hifes_pay"`
  2030. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2031. OptTime string `json:"opt_time"`
  2032. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2033. SetlID string `json:"setl_id"`
  2034. MafPay float64 `json:"maf_pay"`
  2035. PsnName string `json:"psn_name"`
  2036. InsuOptins interface{} `json:"insu_optins"`
  2037. PrefFundPay interface{} `json:"pref_fund_pay"`
  2038. ClrOptins string `json:"clr_optins"`
  2039. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2040. DiseName string `json:"dise_name"`
  2041. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2042. Age float64 `json:"age"`
  2043. DtrtCertType string `json:"dtrt_cert_type"`
  2044. HospLv string `json:"hosp_lv"`
  2045. } `json:"setlinfo"`
  2046. } `json:"output"`
  2047. RefmsgTime string `json:"refmsg_time"`
  2048. RespondTime string `json:"respond_time"`
  2049. Signtype interface{} `json:"signtype"`
  2050. WarnMsg interface{} `json:"warn_msg"`
  2051. }
  2052. type ResultTwelve struct {
  2053. Cainfo string `json:"cainfo"`
  2054. ErrMsg string `json:"err_msg"`
  2055. InfRefmsgid string `json:"inf_refmsgid"`
  2056. Infcode int64 `json:"infcode"`
  2057. Output struct {
  2058. MdtrtId string `json:"mdtrt_id"`
  2059. ChrgBchno string `json:"chrg_bchno"`
  2060. PsnNo string `json:"psn_no"`
  2061. } `json:"output"`
  2062. RefmsgTime string `json:"refmsg_time"`
  2063. RespondTime string `json:"respond_time"`
  2064. Signtype interface{} `json:"signtype"`
  2065. WarnMsg interface{} `json:"warn_msg"`
  2066. }
  2067. type ResultThirteen struct {
  2068. ErrMsg string `json:"err_msg"`
  2069. InfRefmsgid string `json:"inf_refmsgid"`
  2070. Infcode int64 `json:"infcode"`
  2071. Output struct {
  2072. Result struct {
  2073. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2074. } `json:"result"`
  2075. } `json:"output"`
  2076. RefmsgTime string `json:"refmsg_time"`
  2077. RespondTime string `json:"respond_time"`
  2078. Signtype interface{} `json:"signtype"`
  2079. WarnInfo interface{} `json:"warn_info"`
  2080. }
  2081. type ResultFourteen struct {
  2082. ErrMsg string `json:"err_msg"`
  2083. InfRefmsgid string `json:"inf_refmsgid"`
  2084. Infcode int64 `json:"infcode"`
  2085. Output struct {
  2086. } `json:"output"`
  2087. RefmsgTime string `json:"refmsg_time"`
  2088. RespondTime string `json:"respond_time"`
  2089. Signtype interface{} `json:"signtype"`
  2090. WarnInfo interface{} `json:"warn_info"`
  2091. }
  2092. type ResultSixteen struct {
  2093. Cainfo string `json:"cainfo"`
  2094. ErrMsg string `json:"err_msg"`
  2095. InfRefmsgid string `json:"inf_refmsgid"`
  2096. Infcode int64 `json:"infcode"`
  2097. Output struct {
  2098. Setldetail []interface{} `json:"setldetail"`
  2099. Setlinfo struct {
  2100. MdtrtID string `json:"mdtrt_id"`
  2101. SetlID string `json:"setl_id"`
  2102. ClrOptins string `json:"clr_optins"`
  2103. SetlTime string `json:"setl_time"`
  2104. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2105. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2106. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2107. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2108. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2109. ActPayDedc float64 `json:"act_pay_dedc"`
  2110. HifpPay float64 `json:"hifp_pay"`
  2111. PoolPropSe float64 `json:"pool_prop_selfpay"`
  2112. Lfpay float64 `json:"selfpay"`
  2113. CvlservPay float64 `json:"cvlserv_pay"`
  2114. HifesPay float64 `json:"hifes_pay"`
  2115. HifmiPay float64 `json:"hifmi_pay"`
  2116. HifobPay float64 `json:"hifob_pay"`
  2117. MafPay float64 `json:"maf_pay"`
  2118. OthPay float64 `json:"oth_pay"`
  2119. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2120. PsnPartAmt float64 `json:"psn_part_amt"`
  2121. AcctPay float64 `json:"acct_pay"`
  2122. Balc float64 `json:"balc"`
  2123. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2124. HospPartAmt float64 `json:"hosp_part_amt"`
  2125. MedinsSetlID string `json:"medins_setl_id"`
  2126. PdnCashPay string `json:"pdn_cash_pay"`
  2127. } `json:"setlinfo"`
  2128. } `json:"output"`
  2129. RefmsgTime string `json:"refmsg_time"`
  2130. RespondTime string `json:"respond_time"`
  2131. Signtype interface{} `json:"signtype"`
  2132. WarnMsg interface{} `json:"warn_msg"`
  2133. }
  2134. type ResultSeventeen struct {
  2135. ErrMsg string `json:"err_msg"`
  2136. InfRefmsgid string `json:"inf_refmsgid"`
  2137. Infcode int64 `json:"infcode"`
  2138. Output struct {
  2139. SetlListId string `json:"setl_list_id"`
  2140. } `json:"output"`
  2141. RefmsgTime string `json:"refmsg_time"`
  2142. RespondTime string `json:"respond_time"`
  2143. Signtype string `json:"signtype"`
  2144. WarnInfo string `json:"warn_info"`
  2145. }
  2146. type Result90991 struct {
  2147. ErrMsg string `json:"err_msg"`
  2148. InfRefmsgid string `json:"inf_refmsgid"`
  2149. Infcode int64 `json:"infcode"`
  2150. Output struct {
  2151. Result struct {
  2152. PsnNo string `json:"psn_no"`
  2153. CardStat string `json:"card_stat"`
  2154. Certno string `json:"certno"`
  2155. PsnName string `json:"psn_name"`
  2156. CheckStat string `json:"check_stat"`
  2157. } `json:"result"`
  2158. } `json:"output"`
  2159. RefmsgTime string `json:"refmsg_time"`
  2160. RespondTime string `json:"respond_time"`
  2161. Signtype interface{} `json:"signtype"`
  2162. WarnInfo interface{} `json:"warn_info"`
  2163. }
  2164. type Result90100 struct {
  2165. ErrMsg string `json:"err_msg"`
  2166. InfRefmsgid string `json:"inf_refmsgid"`
  2167. Infcode int64 `json:"infcode"`
  2168. Output struct {
  2169. PoolareaNo string `json:"poolarea_no"`
  2170. PoolareaNoName string `json:"poolarea_no_name"`
  2171. Insutype string `json:"insutype"`
  2172. InsutypeName string `json:"insutype_name"`
  2173. ClctType string `json:"clct_type"`
  2174. ClctTypeName string `json:"clct_type_name"`
  2175. ClctFlag string `json:"clct_flag"`
  2176. ClctFlagName string `json:"clct_flag_name"`
  2177. AccrymBegn string `json:"accrym_begn"`
  2178. AccrymEnd string `json:"accrym_end"`
  2179. ClctTime string `json:"clct_time"`
  2180. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  2181. } `json:"output"`
  2182. RefmsgTime string `json:"refmsg_time"`
  2183. RespondTime string `json:"respond_time"`
  2184. Signtype interface{} `json:"signtype"`
  2185. WarnInfo interface{} `json:"warn_info"`
  2186. }
  2187. type Custom struct {
  2188. DetItemFeeSumamt string
  2189. Cut string
  2190. FeedetlSn string
  2191. Price string
  2192. MedListCodg string
  2193. Type int64
  2194. AdviceId int64
  2195. ProjectId int64
  2196. ItemId int64
  2197. }
  2198. //获取个人信息----挂号-----上传就诊信息
  2199. func (c *HisApiController) GetRegisterInfo() {
  2200. fmt.Println("~~~~~~~~")
  2201. id, _ := c.GetInt64("id")
  2202. record_time := c.GetString("record_time")
  2203. settlementValue, _ := c.GetInt64("settlement_value")
  2204. medical_insurance_card := c.GetString("medical_insurance_card")
  2205. name := c.GetString("name")
  2206. id_card_type, _ := c.GetInt64("id_card_type")
  2207. certificates, _ := c.GetInt64("certificates")
  2208. medical_care, _ := c.GetInt64("medical_care")
  2209. birthday := c.GetString("birthday")
  2210. //age, _ := c.GetInt64("age")
  2211. id_card := c.GetString("id_card")
  2212. register_type, _ := c.GetInt64("register")
  2213. doctor, _ := c.GetInt64("doctor")
  2214. department, _ := c.GetInt64("department")
  2215. gender, _ := c.GetInt64("sex")
  2216. //phone := c.GetString("phone")
  2217. registration_fee, _ := c.GetFloat("registration_fee")
  2218. medical_expenses, _ := c.GetFloat("medical_expenses")
  2219. social_type, _ := c.GetInt64("social_type")
  2220. med_type := c.GetString("social_type")
  2221. admin_user_id, _ := c.GetInt64("admin_user_id")
  2222. timeLayout := "2006-01-02"
  2223. loc, _ := time.LoadLocation("Local")
  2224. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  2225. birthUnix := birthdays.Unix()
  2226. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2227. if err != nil {
  2228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2229. return
  2230. }
  2231. recordDateTime := theTime.Unix()
  2232. adminInfo := c.GetAdminUserInfo()
  2233. var patient service.Patients
  2234. if id == 0 {
  2235. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  2236. } else {
  2237. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  2238. }
  2239. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  2240. if patientPrescription.ID == 0 {
  2241. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  2242. }
  2243. //adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
  2244. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  2245. //sickConfig, _ := service.FindSickById(sick_type)
  2246. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2247. if patient.ID == 0 {
  2248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  2249. return
  2250. }
  2251. if len(patient.IdCardNo) == 0 {
  2252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  2253. return
  2254. }
  2255. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2256. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  2257. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  2258. //就诊结算未完成,不能进行二次挂号
  2259. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  2260. if len(his) >= 1 {
  2261. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  2262. if len(his) >= 1 && order.ID == 0 {
  2263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  2264. return
  2265. }
  2266. }
  2267. //var register_log string
  2268. if config.IsOpen == 1 {
  2269. var res ResultTwo
  2270. var PsnNo string
  2271. var PsnCertType string
  2272. var Certno string
  2273. var PsnName string
  2274. var Gend string
  2275. var Naty string
  2276. var Brdy string
  2277. var Age float64
  2278. var infoStr string
  2279. var idetinfoStr string
  2280. if miConfig.MdtrtareaAdmvs == "421300" {
  2281. psn_info, _ := service.GetPsnByPatientId(id)
  2282. PsnNo = psn_info.PsnNo
  2283. PsnCertType = psn_info.PsnCertType
  2284. Certno = psn_info.Certno
  2285. PsnName = psn_info.PsnName
  2286. Gend = psn_info.Gend
  2287. Naty = psn_info.Naty
  2288. Brdy = psn_info.Brdy
  2289. Age = psn_info.Age
  2290. infoStr = psn_info.Insuinfo
  2291. idetinfoStr = psn_info.Idetinfo
  2292. } else {
  2293. result, requestLog := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10))
  2294. saveLog(result, requestLog, "1101", "人员基本信息获取")
  2295. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2296. utils.ErrorLog("解析失败:%v", err)
  2297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2298. return
  2299. }
  2300. PsnNo = res.Output.Baseinfo.PsnNo
  2301. PsnCertType = res.Output.Baseinfo.PsnCertType
  2302. Certno = res.Output.Baseinfo.Certno
  2303. PsnName = res.Output.Baseinfo.PsnName
  2304. Gend = res.Output.Baseinfo.Gend
  2305. Naty = res.Output.Baseinfo.Naty
  2306. Brdy = res.Output.Baseinfo.Brdy
  2307. Age = res.Output.Baseinfo.Age
  2308. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2309. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2310. infoStr = string(Iinfos)
  2311. idetinfoStr = string(Idetinfos)
  2312. }
  2313. if res.Infcode == 0 {
  2314. his := models.VMHisPatient{
  2315. Name: name,
  2316. Gender: gender,
  2317. Birthday: birthUnix,
  2318. MedicalTreatmentType: medical_care,
  2319. IdType: certificates,
  2320. IdCardNo: id_card,
  2321. BalanceAccountsType: settlementValue,
  2322. SocialType: social_type,
  2323. MedicalInsuranceNumber: medical_insurance_card,
  2324. RegisterType: register_type,
  2325. RegisterCost: registration_fee,
  2326. TreatmentCost: medical_expenses,
  2327. Status: 1,
  2328. Ctime: time.Now().Unix(),
  2329. Mtime: time.Now().Unix(),
  2330. PsnNo: PsnNo,
  2331. PsnCertType: PsnCertType,
  2332. Certno: Certno,
  2333. PsnName: PsnName,
  2334. Gend: Gend,
  2335. Naty: Naty,
  2336. Brdy: Brdy,
  2337. Age: Age,
  2338. Iinfo: infoStr,
  2339. Idetinfo: idetinfoStr,
  2340. PatientId: patient.ID,
  2341. RecordDate: theTime.Unix(),
  2342. UserOrgId: adminInfo.CurrentOrgId,
  2343. AdminUserId: admin_user_id,
  2344. IsReturn: 1,
  2345. IdCardType: id_card_type,
  2346. Doctor: doctor,
  2347. Departments: department,
  2348. }
  2349. timestamp := time.Now().Unix()
  2350. tempTime := time.Unix(timestamp, 0)
  2351. timeFormat := tempTime.Format("20060102150405")
  2352. chrgBchno := rand.Intn(100000) + 10000
  2353. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  2354. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  2355. department, _ := service.GetDepartMentDetail(department)
  2356. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  2357. IdCardNo := ""
  2358. if id_card_type == 1 {
  2359. // IdCardNo = medical_insurance_card
  2360. IdCardNo = patient.IdCardNo
  2361. } else {
  2362. IdCardNo = patient.IdCardNo
  2363. }
  2364. //var insutypes []string
  2365. //
  2366. //var insutype string
  2367. //var is390 int = 0
  2368. //var is310 int = 0
  2369. //for _, item := range res.Output.Iinfo {
  2370. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2371. // insutypes = append(insutypes, item.Insutype)
  2372. // }
  2373. //}
  2374. //if len(insutypes) == 1 {
  2375. // insutype = insutypes[0]
  2376. //} else {
  2377. // for _, i := range insutypes {
  2378. // if i == "390" {
  2379. // is390 = 1
  2380. // }
  2381. //
  2382. // if i == "310" {
  2383. // is310 = 1
  2384. // }
  2385. // }
  2386. //}
  2387. //if is390 == 1 {
  2388. // insutype = "390"
  2389. //}
  2390. //if is310 == 1 {
  2391. // insutype = "310"
  2392. //}
  2393. //
  2394. //if len(insutypes) == 0 {
  2395. // insutype = "310"
  2396. //}
  2397. var rf []*ResultFive
  2398. json.Unmarshal([]byte(his.Iinfo), &rf)
  2399. var insutypes []*ResultFive
  2400. var insutype string
  2401. var insuplc_admdvs string
  2402. var is390 int = 0
  2403. var is310 int = 0
  2404. for _, item := range rf {
  2405. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2406. insutypes = append(insutypes, item)
  2407. }
  2408. }
  2409. if len(insutypes) == 1 {
  2410. insutype = insutypes[0].Insutype
  2411. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  2412. } else {
  2413. for _, i := range insutypes {
  2414. if i.Insutype == "390" {
  2415. is390 = 1
  2416. }
  2417. if i.Insutype == "310" {
  2418. is310 = 1
  2419. }
  2420. }
  2421. }
  2422. if is390 == 1 {
  2423. insutype = "390"
  2424. }
  2425. if is310 == 1 {
  2426. insutype = "310"
  2427. }
  2428. if len(insutypes) == 0 {
  2429. insutype = "310"
  2430. }
  2431. if len(insutypes) == 2 {
  2432. insutype = med_type
  2433. }
  2434. for _, item := range rf {
  2435. if item.Insutype == insutype {
  2436. insuplc_admdvs = item.InsuplcAdmdvs
  2437. }
  2438. }
  2439. var resThree ResultThree
  2440. if miConfig.MdtrtareaAdmvs == "421300" {
  2441. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  2442. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  2443. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id
  2444. resp, requestErr := http.Get(api)
  2445. if requestErr != nil {
  2446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2447. return
  2448. }
  2449. body, ioErr := ioutil.ReadAll(resp.Body)
  2450. if ioErr != nil {
  2451. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2453. return
  2454. }
  2455. var respJSON map[string]interface{}
  2456. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2459. return
  2460. }
  2461. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2462. result, _ := json.Marshal(respJSON)
  2463. fmt.Println("log")
  2464. fmt.Println(string(result))
  2465. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  2466. utils.ErrorLog("解析失败:%v", err)
  2467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2468. return
  2469. }
  2470. } else {
  2471. fmt.Println(roles.UserName)
  2472. result, requestLog := service.Gdyb2201(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName)
  2473. saveLog(result, requestLog, "2201", "挂号")
  2474. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  2475. utils.ErrorLog("解析失败:%v", err)
  2476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2477. return
  2478. }
  2479. }
  2480. if resThree.Infcode != 0 {
  2481. adminUser := c.GetAdminUserInfo()
  2482. errlog := &models.HisOrderError{
  2483. UserOrgId: adminUser.CurrentOrgId,
  2484. Ctime: time.Now().Unix(),
  2485. Mtime: time.Now().Unix(),
  2486. ErrMsg: resThree.ErrMsg,
  2487. Status: 1,
  2488. PatientId: id,
  2489. RecordTime: recordDateTime,
  2490. Stage: 2,
  2491. }
  2492. service.CreateErrMsgLog(errlog)
  2493. c.ServeSuccessJSON(map[string]interface{}{
  2494. "failed_code": -10,
  2495. "msg": resThree.ErrMsg,
  2496. })
  2497. return
  2498. }
  2499. his.Number = resThree.Output.Data.MdtrtID
  2500. his.PsnNo = resThree.Output.Data.PsnNo
  2501. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  2502. his.IdCardNo = patient.IdCardNo
  2503. his.PhoneNumber = patient.Phone
  2504. his.UserOrgId = adminInfo.CurrentOrgId
  2505. his.Ctime = time.Now().Unix()
  2506. his.Mtime = time.Now().Unix()
  2507. his.InsuplcAdmdvs = insuplc_admdvs
  2508. his.Status = 1
  2509. service.UpdateHisPatientStatus(&his)
  2510. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  2511. c.ServeSuccessJSON(map[string]interface{}{
  2512. "his_info": his,
  2513. })
  2514. } else {
  2515. adminUser := c.GetAdminUserInfo()
  2516. errlog := &models.HisOrderError{
  2517. UserOrgId: adminUser.CurrentOrgId,
  2518. Ctime: time.Now().Unix(),
  2519. Mtime: time.Now().Unix(),
  2520. ErrMsg: res.ErrMsg,
  2521. Status: 1,
  2522. PatientId: id,
  2523. RecordTime: recordDateTime,
  2524. Stage: 1,
  2525. }
  2526. service.CreateErrMsgLog(errlog)
  2527. c.ServeSuccessJSON(map[string]interface{}{
  2528. "failed_code": -10,
  2529. "msg": res.ErrMsg,
  2530. })
  2531. return
  2532. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  2533. }
  2534. }
  2535. }
  2536. //上传明细----预结算----确认订单
  2537. func (c *HisApiController) GetUploadInfo() {
  2538. id, _ := c.GetInt64("id")
  2539. record_time := c.GetString("record_time")
  2540. his_patient_id, _ := c.GetInt64("his_patient_id")
  2541. order_id, _ := c.GetInt64("order_id")
  2542. pay_way, _ := c.GetInt64("pay_way")
  2543. pay_price, _ := c.GetFloat("pay_price")
  2544. pay_card_no := c.GetString("pay_card_no")
  2545. discount_price, _ := c.GetFloat("discount_price")
  2546. preferential_price, _ := c.GetFloat("preferential_price")
  2547. reality_price, _ := c.GetFloat("reality_price")
  2548. found_price, _ := c.GetFloat("found_price")
  2549. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  2550. private_price, _ := c.GetFloat("private_price")
  2551. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2552. admin_user_id, _ := c.GetInt64("admin_user_id")
  2553. fapiao_code := c.GetString("fapiao_code")
  2554. fapiao_number := c.GetString("fapiao_number")
  2555. diagnosis_id := c.GetString("diagnosis")
  2556. sick_type, _ := c.GetInt64("sick_type")
  2557. reg_type, _ := c.GetInt64("p_type")
  2558. id_str := c.GetString("ids")
  2559. ids_arr := strings.Split(id_str, ",")
  2560. timeLayout := "2006-01-02"
  2561. loc, _ := time.LoadLocation("Local")
  2562. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2563. if err != nil {
  2564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2565. return
  2566. }
  2567. recordDateTime := theTime.Unix()
  2568. adminUser := c.GetAdminUserInfo()
  2569. var tempOrder models.HisOrder
  2570. tempOrder, _ = service.GetHisOrderByID(order_id)
  2571. var prescriptions []*models.HisPrescription
  2572. var start_time int64
  2573. var end_time int64
  2574. //if adminUser.CurrentOrgId == 10106{
  2575. // if len(fapiao_code) == 0{
  2576. // fapiao_code = "144072080589"
  2577. // }
  2578. // if len(fapiao_number) == 0{
  2579. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  2580. // if order.ID == 0{
  2581. // fapiao_number = "00001520"
  2582. // }else{
  2583. // //fapiao_code = "00001520"
  2584. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  2585. // var zero string
  2586. // if fpNumber >= 1000{
  2587. // zero = "0000" + strconv.Itoa(fpNumber)
  2588. // }else if fpNumber >= 10000{
  2589. // zero = "000" + strconv.Itoa(fpNumber)
  2590. // } else if fpNumber >= 100000{
  2591. // zero = "00" + strconv.Itoa(fpNumber)
  2592. // } else if fpNumber >= 1000000{
  2593. // zero = "0" + strconv.Itoa(fpNumber)
  2594. // }else {
  2595. // zero = strconv.Itoa(fpNumber)
  2596. // }
  2597. // fapiao_number = zero
  2598. // }
  2599. // }
  2600. //}
  2601. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2602. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2603. var patientPrescription models.HisPrescriptionInfo
  2604. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2605. if patientPrescription.ID == 0 {
  2606. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2607. }
  2608. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2609. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2610. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2611. diagnosis_ids := strings.Split(diagnosis_id, ",")
  2612. var config []*models.HisXtDiagnoseConfig
  2613. for _, item := range diagnosis_ids {
  2614. id, _ := strconv.ParseInt(item, 10, 64)
  2615. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2616. config = append(config, &diagnosisConfig)
  2617. }
  2618. sickConfig, _ := service.FindSickById(sick_type)
  2619. if tempOrder.ID == 0 {
  2620. tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  2621. }
  2622. if tempOrder.ID == 0 {
  2623. var result string
  2624. var requestLog string
  2625. var res2 ResultSix
  2626. if miConfig.InsuplcAdmdvs == "421300" {
  2627. data := make(map[string]interface{})
  2628. client := &http.Client{}
  2629. data["psn_no"] = his.PsnNo
  2630. data["mdtrt_id"] = his.Number
  2631. data["doctor"] = roles.UserName
  2632. data["department"] = department.Name
  2633. data["org_name"] = miConfig.OrgName
  2634. data["med_type"] = strconv.FormatInt(reg_type, 10)
  2635. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  2636. data["fixmedins_code"] = miConfig.Code
  2637. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2638. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2639. data["secret_key"] = miConfig.SecretKey
  2640. data["sick_code"] = sickConfig.CountryCode
  2641. data["sick_name"] = sickConfig.ClassName
  2642. data["dept"] = strconv.FormatInt(department.ID, 10)
  2643. data["config"] = config
  2644. bytesData, _ := json.Marshal(data)
  2645. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  2646. resp, _ := client.Do(req)
  2647. defer resp.Body.Close()
  2648. body, ioErr := ioutil.ReadAll(resp.Body)
  2649. if ioErr != nil {
  2650. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2652. return
  2653. }
  2654. var respJSON map[string]interface{}
  2655. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2658. return
  2659. }
  2660. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2661. userJSONBytes, _ := json.Marshal(respJSON)
  2662. fmt.Println("log")
  2663. fmt.Println(string(userJSONBytes))
  2664. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  2665. utils.ErrorLog("解析失败:%v", err)
  2666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2667. return
  2668. }
  2669. } else {
  2670. if miConfig.InsuplcAdmdvs == "440781" { //
  2671. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config)
  2672. } else {
  2673. result, requestLog = service.Gdyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config)
  2674. }
  2675. saveLog(result, requestLog, "2203", "上传就诊信息")
  2676. var respJSON2 map[string]interface{}
  2677. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2678. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2680. return
  2681. }
  2682. userJSONBytes2, _ := json.Marshal(respJSON2)
  2683. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2684. utils.ErrorLog("解析失败:%v", err)
  2685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2686. return
  2687. }
  2688. }
  2689. if res2.Infcode != 0 {
  2690. adminUser := c.GetAdminUserInfo()
  2691. errlog := &models.HisOrderError{
  2692. UserOrgId: adminUser.CurrentOrgId,
  2693. Ctime: time.Now().Unix(),
  2694. Mtime: time.Now().Unix(),
  2695. ErrMsg: res2.ErrMsg,
  2696. Status: 1,
  2697. PatientId: id,
  2698. RecordTime: recordDateTime,
  2699. Stage: 3,
  2700. }
  2701. service.CreateErrMsgLog(errlog)
  2702. c.ServeSuccessJSON(map[string]interface{}{
  2703. "failed_code": -10,
  2704. "msg": res2.ErrMsg,
  2705. })
  2706. return
  2707. } else {
  2708. his.Diagnosis = diagnosis_id
  2709. his.SickType = sickConfig.ID
  2710. var p_type int64
  2711. if reg_type == 1111 || reg_type == 1112 {
  2712. p_type = 11
  2713. }
  2714. his.PType = fmt.Sprintf("%d", p_type)
  2715. service.UpdateHisPatientThree(&his)
  2716. data := make(map[string]interface{})
  2717. if settle_accounts_type == 1 { //日结
  2718. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  2719. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  2720. } else {
  2721. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  2722. }
  2723. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  2724. data["pre"] = prescriptions
  2725. } else { //月结
  2726. start_time_str := c.GetString("start_time")
  2727. end_time_str := c.GetString("end_time")
  2728. timeLayout := "2006-01-02"
  2729. loc, _ := time.LoadLocation("Local")
  2730. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2731. if err != nil {
  2732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2733. return
  2734. }
  2735. recordStartTime := theStartTime.Unix()
  2736. start_time = recordStartTime
  2737. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2738. if err != nil {
  2739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2740. return
  2741. }
  2742. recordEndTime := theEndTime.Unix()
  2743. end_time = recordEndTime
  2744. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  2745. data["pre"] = prescriptions
  2746. }
  2747. timestamp := time.Now().Unix()
  2748. tempTime := time.Unix(timestamp, 0)
  2749. timeFormat := tempTime.Format("20060102150405")
  2750. chrgBchno := rand.Intn(100000) + 10000
  2751. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  2752. strconv.FormatInt(his.PatientId, 10)
  2753. client := &http.Client{}
  2754. data["psn_no"] = his.PsnNo
  2755. data["mdtrt_id"] = his.Number
  2756. data["chrg_bchno"] = chrg_bchno
  2757. data["org_name"] = miConfig.OrgName
  2758. data["doctor"] = roles.UserName
  2759. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  2760. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  2761. data["fixmedins_code"] = miConfig.Code
  2762. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  2763. data["dept_code"] = "15"
  2764. } else {
  2765. data["dept_code"] = department.Number
  2766. }
  2767. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2768. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2769. data["secret_key"] = miConfig.SecretKey
  2770. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  2771. var ids []int64
  2772. for _, item := range prescriptions {
  2773. ids = append(ids, item.ID)
  2774. }
  2775. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2776. if config.IsOpen == 1 { //对接了医保,走医保流程
  2777. var res ResultFour
  2778. if miConfig.MdtrtareaAdmvs == "421300" {
  2779. bytesData, _ := json.Marshal(data)
  2780. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  2781. resp, _ := client.Do(req)
  2782. defer resp.Body.Close()
  2783. body, ioErr := ioutil.ReadAll(resp.Body)
  2784. if ioErr != nil {
  2785. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2787. return
  2788. }
  2789. var respJSON map[string]interface{}
  2790. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2791. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2793. return
  2794. }
  2795. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2796. userJSONBytes, _ := json.Marshal(respJSON)
  2797. fmt.Println("log")
  2798. fmt.Println(string(userJSONBytes))
  2799. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2800. utils.ErrorLog("解析失败:%v", err)
  2801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2802. return
  2803. }
  2804. } else {
  2805. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, data["doctor_id"].(string), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string))
  2806. var dat map[string]interface{}
  2807. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2808. fmt.Println(dat)
  2809. } else {
  2810. fmt.Println(err)
  2811. }
  2812. saveLog(result, request_log, "2204", "上传费用明细")
  2813. userJSONBytes, _ := json.Marshal(dat)
  2814. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2815. utils.ErrorLog("解析失败:%v", err)
  2816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2817. return
  2818. }
  2819. }
  2820. if res.Infcode == 0 {
  2821. order := &models.HisOrder{
  2822. UserOrgId: adminUser.CurrentOrgId,
  2823. HisPatientId: his.ID,
  2824. PatientId: his.PatientId,
  2825. SettleAccountsDate: recordDateTime,
  2826. Ctime: time.Now().Unix(),
  2827. Mtime: time.Now().Unix(),
  2828. Status: 1,
  2829. Number: chrg_bchno,
  2830. Infcode: res.Infcode,
  2831. WarnMsg: res.WarnMsg,
  2832. Cainfo: res.Cainfo,
  2833. ErrMsg: res.ErrMsg,
  2834. RespondTime: res.RefmsgTime,
  2835. InfRefmsgid: res.InfRefmsgid,
  2836. OrderStatus: 1,
  2837. PayWay: pay_way,
  2838. PayPrice: pay_price,
  2839. PayCardNo: pay_card_no,
  2840. DiscountPrice: discount_price,
  2841. PreferentialPrice: preferential_price,
  2842. RealityPrice: reality_price,
  2843. FoundPrice: found_price,
  2844. MedicalInsurancePrice: medical_insurance_price,
  2845. PrivatePrice: private_price,
  2846. IsMedicineInsurance: 1,
  2847. SettleType: settle_accounts_type,
  2848. SettleStartTime: start_time,
  2849. SettleEndTime: end_time,
  2850. Creator: roles.AdminUserId,
  2851. Modify: roles.AdminUserId,
  2852. FaPiaoNumber: fapiao_number,
  2853. FaPiaoCode: fapiao_code,
  2854. PType: 2,
  2855. Diagnosis: diagnosis_id,
  2856. }
  2857. err = service.CreateOrder(order)
  2858. if err != nil {
  2859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2860. return
  2861. }
  2862. for _, item := range res.Output.Result {
  2863. temp := strings.Split(item.FeedetlSn, "-")
  2864. var advice_id int64 = 0
  2865. var project_id int64 = 0
  2866. var types int64 = 0
  2867. id, _ := strconv.ParseInt(temp[2], 10, 64)
  2868. types, _ = strconv.ParseInt(temp[1], 10, 64)
  2869. if temp[1] == "1" {
  2870. advice_id = id
  2871. project_id = 0
  2872. } else if temp[1] == "2" {
  2873. advice_id = 0
  2874. project_id = id
  2875. }
  2876. info := &models.HisOrderInfo{
  2877. OrderNumber: order.Number,
  2878. FeedetlSn: item.FeedetlSn,
  2879. UploadDate: time.Now().Unix(),
  2880. AdviceId: advice_id,
  2881. DetItemFeeSumamt: item.DetItemFeeSumamt,
  2882. Cnt: item.Cnt,
  2883. Pric: float64(item.Pric),
  2884. PatientId: his.PatientId,
  2885. PricUplmtAmt: item.PricUplmtAmt,
  2886. SelfpayProp: item.SelfpayProp,
  2887. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  2888. OverlmtAmt: item.OverlmtAmt,
  2889. PreselfpayAmt: item.PreselfpayAmt,
  2890. BasMednFlag: item.BasMednFlag,
  2891. MedChrgitmType: item.MedChrgitmType,
  2892. HiNegoDrugFlag: item.HiNegoDrugFlag,
  2893. Status: 1,
  2894. Memo: item.Memo,
  2895. Mtime: time.Now().Unix(),
  2896. InscpScpAmt: item.InscpScpAmt,
  2897. DrtReimFlag: item.DrtReimFlag,
  2898. Ctime: time.Now().Unix(),
  2899. ListSpItemFlag: item.ListSpItemFlag,
  2900. ChldMedcFlag: item.ChldMedcFlag,
  2901. LmtUsedFlag: item.LmtUsedFlag,
  2902. ChrgitmLv: item.ChrgitmLv,
  2903. UserOrgId: adminUser.CurrentOrgId,
  2904. HisPatientId: his.ID,
  2905. OrderId: order.ID,
  2906. ProjectId: project_id,
  2907. Type: types,
  2908. }
  2909. service.CreateOrderInfo(info)
  2910. }
  2911. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2912. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  2913. var total float64
  2914. for _, item := range prescriptions {
  2915. if item.Type == 1 { //药品
  2916. for _, subItem := range item.HisDoctorAdviceInfo {
  2917. total = total + (subItem.Price * subItem.PrescribingNumber)
  2918. }
  2919. }
  2920. if item.Type == 2 { //项目
  2921. for _, subItem := range item.HisPrescriptionProject {
  2922. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2923. total = total + (subItem.Price * cnt)
  2924. }
  2925. }
  2926. }
  2927. for _, item := range prescriptions {
  2928. for _, subItem := range item.HisAdditionalCharge {
  2929. total = total + (subItem.Price * float64(subItem.Count))
  2930. }
  2931. }
  2932. var allTotal string
  2933. if adminUser.CurrentOrgId == 9919 {
  2934. allTotal = fmt.Sprintf("%.2f", total)
  2935. } else {
  2936. allTotal = fmt.Sprintf("%.4f", total)
  2937. }
  2938. if res.Infcode == 0 {
  2939. var rf []*ResultFive
  2940. json.Unmarshal([]byte(his.Iinfo), &rf)
  2941. chrg_bchno := chrg_bchno
  2942. cert_no := his.Certno
  2943. var insutypes []string
  2944. var insutype string
  2945. var is390 int = 0
  2946. var is310 int = 0
  2947. for _, item := range rf {
  2948. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2949. insutypes = append(insutypes, item.Insutype)
  2950. }
  2951. }
  2952. if len(insutypes) == 1 {
  2953. insutype = insutypes[0]
  2954. } else {
  2955. for _, i := range insutypes {
  2956. if i == "390" {
  2957. is390 = 1
  2958. }
  2959. if i == "310" {
  2960. is310 = 1
  2961. }
  2962. }
  2963. }
  2964. if is390 == 1 {
  2965. insutype = "390"
  2966. }
  2967. if is310 == 1 {
  2968. insutype = "310"
  2969. }
  2970. if len(insutypes) == 0 {
  2971. insutype = "310"
  2972. }
  2973. if len(insutypes) == 2 {
  2974. insutype = strconv.FormatInt(his.SocialType, 10)
  2975. }
  2976. //insutype = "390"
  2977. if his.IdCardType == 1 {
  2978. // cert_no = his.MedicalInsuranceNumber
  2979. cert_no = his.Certno
  2980. } else {
  2981. cert_no = his.Certno
  2982. }
  2983. var res ResultSeven
  2984. var src_resquest string
  2985. var result2 string
  2986. var acct_used_flag string
  2987. fmt.Println("pay_way")
  2988. fmt.Println(pay_way)
  2989. fmt.Println("pay_way")
  2990. if pay_way == 4 {
  2991. acct_used_flag = "1"
  2992. } else {
  2993. acct_used_flag = "0"
  2994. }
  2995. if miConfig.MdtrtareaAdmvs == "421300" {
  2996. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  2997. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  2998. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  2999. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3000. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3001. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3002. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3003. resp, requestErr := http.Get(api)
  3004. if requestErr != nil {
  3005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3006. return
  3007. }
  3008. body, ioErr := ioutil.ReadAll(resp.Body)
  3009. if ioErr != nil {
  3010. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3012. return
  3013. }
  3014. var respJSON map[string]interface{}
  3015. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3016. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3018. return
  3019. }
  3020. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3021. result, _ := json.Marshal(respJSON)
  3022. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3023. utils.ErrorLog("解析失败:%v", err)
  3024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3025. return
  3026. }
  3027. } else {
  3028. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, acct_used_flag)
  3029. var dat map[string]interface{}
  3030. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  3031. fmt.Println(dat)
  3032. } else {
  3033. fmt.Println(err)
  3034. }
  3035. saveLog(result2, src_resquest, "2207", "结算")
  3036. userJSONBytes, _ := json.Marshal(dat)
  3037. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3038. utils.ErrorLog("解析失败:%v", err)
  3039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3040. return
  3041. }
  3042. }
  3043. if res.Infcode != 0 {
  3044. errlog := &models.HisOrderError{
  3045. UserOrgId: adminUser.CurrentOrgId,
  3046. Ctime: time.Now().Unix(),
  3047. Mtime: time.Now().Unix(),
  3048. Number: chrg_bchno,
  3049. ErrMsg: res.ErrMsg,
  3050. Status: 1,
  3051. PatientId: id,
  3052. RecordTime: recordDateTime,
  3053. Stage: 6,
  3054. }
  3055. service.CreateErrMsgLog(errlog)
  3056. c.ServeSuccessJSON(map[string]interface{}{
  3057. "failed_code": -10,
  3058. "msg": res.ErrMsg,
  3059. })
  3060. return
  3061. } else {
  3062. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3063. order.OrderStatus = 2
  3064. order.Status = 1
  3065. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3066. order.SetlId = res.Output.Setlinfo.SetlID
  3067. order.PsnNo = res.Output.Setlinfo.PsnNo
  3068. order.PsnName = res.Output.Setlinfo.PsnName
  3069. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3070. order.Certno = res.Output.Setlinfo.Certno
  3071. order.Gend = res.Output.Setlinfo.Gend
  3072. order.Naty = res.Output.Setlinfo.Naty
  3073. order.Age = res.Output.Setlinfo.Age
  3074. order.Insutype = res.Output.Setlinfo.Insutype
  3075. order.PsnType = res.Output.Setlinfo.PsnType
  3076. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3077. order.SetlTime = res.Output.Setlinfo.SetlTime
  3078. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3079. if res.Output.Setlinfo.MedType == "140101" {
  3080. order.MedType = "14"
  3081. } else {
  3082. order.MedType = res.Output.Setlinfo.MedType
  3083. }
  3084. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3085. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3086. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3087. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3088. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3089. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3090. order.HifpPay = res.Output.Setlinfo.HifpPay
  3091. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3092. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3093. order.HifesPay = res.Output.Setlinfo.HifesPay
  3094. order.HifobPay = res.Output.Setlinfo.HifobPay
  3095. order.MafPay = res.Output.Setlinfo.MafPay
  3096. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3097. order.OthPay = res.Output.Setlinfo.OthPay
  3098. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3099. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3100. order.AcctPay = res.Output.Setlinfo.AcctPay
  3101. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3102. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3103. order.Balc = res.Output.Setlinfo.Balc
  3104. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3105. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3106. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3107. order.ClrWay = res.Output.Setlinfo.ClrWay
  3108. order.Creator = order.Creator
  3109. order.Modify = roles.AdminUserId
  3110. order.RequestLog = src_resquest
  3111. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3112. detailStr := string(setlDetail)
  3113. order.SetlDetail = detailStr
  3114. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3115. err = service.UpDateOrder(order)
  3116. if err == nil {
  3117. c.ServeSuccessJSON(map[string]interface{}{
  3118. "msg": "结算成功",
  3119. })
  3120. } else {
  3121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3122. return
  3123. }
  3124. }
  3125. } else {
  3126. adminUser := c.GetAdminUserInfo()
  3127. errlog := &models.HisOrderError{
  3128. UserOrgId: adminUser.CurrentOrgId,
  3129. Ctime: time.Now().Unix(),
  3130. Mtime: time.Now().Unix(),
  3131. ErrMsg: res.ErrMsg,
  3132. Status: 1,
  3133. PatientId: id,
  3134. RecordTime: recordDateTime,
  3135. Stage: 4,
  3136. }
  3137. service.CreateErrMsgLog(errlog)
  3138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3139. return
  3140. }
  3141. } else {
  3142. adminUser := c.GetAdminUserInfo()
  3143. errlog := &models.HisOrderError{
  3144. UserOrgId: adminUser.CurrentOrgId,
  3145. Ctime: time.Now().Unix(),
  3146. Mtime: time.Now().Unix(),
  3147. ErrMsg: res.ErrMsg,
  3148. Status: 1,
  3149. PatientId: id,
  3150. RecordTime: recordDateTime,
  3151. Stage: 4,
  3152. }
  3153. service.CreateErrMsgLog(errlog)
  3154. c.ServeSuccessJSON(map[string]interface{}{
  3155. "failed_code": -10,
  3156. "msg": res.ErrMsg,
  3157. })
  3158. return
  3159. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  3160. //return
  3161. }
  3162. }
  3163. }
  3164. } else if tempOrder.ID > 0 {
  3165. if tempOrder.IsPre == 1 {
  3166. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  3167. var rf []*ResultFive
  3168. json.Unmarshal([]byte(his.Iinfo), &rf)
  3169. chrg_bchno := tempOrder.Number
  3170. cert_no := his.Certno
  3171. var insutypes []string
  3172. var insutype string
  3173. var is390 int = 0
  3174. var is310 int = 0
  3175. for _, item := range rf {
  3176. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3177. insutypes = append(insutypes, item.Insutype)
  3178. }
  3179. }
  3180. if len(insutypes) == 1 {
  3181. insutype = insutypes[0]
  3182. } else {
  3183. for _, i := range insutypes {
  3184. if i == "390" {
  3185. is390 = 1
  3186. }
  3187. if i == "310" {
  3188. is310 = 1
  3189. }
  3190. }
  3191. }
  3192. if is390 == 1 {
  3193. insutype = "390"
  3194. }
  3195. if is310 == 1 {
  3196. insutype = "310"
  3197. }
  3198. if len(insutypes) == 0 {
  3199. insutype = "310"
  3200. }
  3201. if len(insutypes) == 2 {
  3202. insutype = strconv.FormatInt(his.SocialType, 64)
  3203. }
  3204. //insutype = "390"
  3205. if his.IdCardType == 1 {
  3206. // cert_no = his.MedicalInsuranceNumber
  3207. cert_no = his.Certno
  3208. } else {
  3209. cert_no = his.Certno
  3210. }
  3211. var res ResultSeven
  3212. var src_resquest string
  3213. var result2 string
  3214. var acct_used_flag string
  3215. fmt.Println("pay_way")
  3216. fmt.Println(pay_way)
  3217. fmt.Println("pay_way")
  3218. if pay_way == 4 {
  3219. acct_used_flag = "1"
  3220. } else {
  3221. acct_used_flag = "0"
  3222. }
  3223. if miConfig.MdtrtareaAdmvs == "421300" {
  3224. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3225. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3226. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3227. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3228. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3229. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3230. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3231. resp, requestErr := http.Get(api)
  3232. if requestErr != nil {
  3233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3234. return
  3235. }
  3236. body, ioErr := ioutil.ReadAll(resp.Body)
  3237. if ioErr != nil {
  3238. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3240. return
  3241. }
  3242. var respJSON map[string]interface{}
  3243. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3244. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3246. return
  3247. }
  3248. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3249. result, _ := json.Marshal(respJSON)
  3250. fmt.Println("log")
  3251. fmt.Println(string(result))
  3252. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3253. utils.ErrorLog("解析失败:%v", err)
  3254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3255. return
  3256. }
  3257. } else {
  3258. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  3259. var dat map[string]interface{}
  3260. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  3261. fmt.Println(dat)
  3262. } else {
  3263. fmt.Println(err)
  3264. }
  3265. saveLog(result2, src_resquest, "2207", "结算")
  3266. userJSONBytes, _ := json.Marshal(dat)
  3267. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3268. utils.ErrorLog("解析失败:%v", err)
  3269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3270. return
  3271. }
  3272. }
  3273. if res.Infcode != 0 {
  3274. errlog := &models.HisOrderError{
  3275. UserOrgId: adminUser.CurrentOrgId,
  3276. Ctime: time.Now().Unix(),
  3277. Mtime: time.Now().Unix(),
  3278. Number: chrg_bchno,
  3279. ErrMsg: res.ErrMsg,
  3280. Status: 1,
  3281. PatientId: id,
  3282. RecordTime: recordDateTime,
  3283. Stage: 6,
  3284. }
  3285. service.CreateErrMsgLog(errlog)
  3286. c.ServeSuccessJSON(map[string]interface{}{
  3287. "failed_code": -10,
  3288. "msg": res.ErrMsg,
  3289. })
  3290. return
  3291. } else {
  3292. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3293. order.OrderStatus = 2
  3294. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3295. order.SetlId = res.Output.Setlinfo.SetlID
  3296. order.PsnNo = res.Output.Setlinfo.PsnNo
  3297. order.PsnName = res.Output.Setlinfo.PsnName
  3298. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3299. order.Certno = res.Output.Setlinfo.Certno
  3300. order.Gend = res.Output.Setlinfo.Gend
  3301. order.Naty = res.Output.Setlinfo.Naty
  3302. order.Age = res.Output.Setlinfo.Age
  3303. order.Insutype = res.Output.Setlinfo.Insutype
  3304. order.PsnType = res.Output.Setlinfo.PsnType
  3305. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3306. order.SetlTime = res.Output.Setlinfo.SetlTime
  3307. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3308. order.MedType = res.Output.Setlinfo.MedType
  3309. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3310. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3311. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3312. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3313. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3314. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3315. order.HifpPay = res.Output.Setlinfo.HifpPay
  3316. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3317. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3318. order.HifesPay = res.Output.Setlinfo.HifesPay
  3319. order.HifobPay = res.Output.Setlinfo.HifobPay
  3320. order.MafPay = res.Output.Setlinfo.MafPay
  3321. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3322. order.OthPay = res.Output.Setlinfo.OthPay
  3323. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3324. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3325. order.AcctPay = res.Output.Setlinfo.AcctPay
  3326. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3327. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3328. order.Balc = res.Output.Setlinfo.Balc
  3329. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3330. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3331. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3332. order.ClrWay = res.Output.Setlinfo.ClrWay
  3333. order.Creator = order.Creator
  3334. order.Modify = roles.AdminUserId
  3335. order.RequestLog = src_resquest
  3336. order.Diagnosis = diagnosis_id
  3337. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3338. detailStr := string(setlDetail)
  3339. order.SetlDetail = detailStr
  3340. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3341. err = service.UpDateOrder(order)
  3342. if err == nil {
  3343. c.ServeSuccessJSON(map[string]interface{}{
  3344. "msg": "结算成功",
  3345. })
  3346. } else {
  3347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3348. return
  3349. }
  3350. }
  3351. }
  3352. }
  3353. }
  3354. //func (c *HisApiController) GetPreUploadInfo() {
  3355. // id, _ := c.GetInt64("id")
  3356. // record_time := c.GetString("record_time")
  3357. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3358. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3359. //
  3360. // timeLayout := "2006-01-02"
  3361. // loc, _ := time.LoadLocation("Local")
  3362. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3363. // if err != nil {
  3364. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3365. // return
  3366. // }
  3367. // recordDateTime := theTime.Unix()
  3368. // adminUser := c.GetAdminUserInfo()
  3369. //
  3370. // var prescriptions []*models.HisPrescription
  3371. //
  3372. // var start_time int64
  3373. // var end_time int64
  3374. //
  3375. // data := make(map[string]interface{})
  3376. // if settle_accounts_type == 1 { //日结
  3377. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  3378. // data["pre"] = prescriptions
  3379. //
  3380. // } else { //月结
  3381. // start_time_str := c.GetString("start_time")
  3382. // end_time_str := c.GetString("end_time")
  3383. // timeLayout := "2006-01-02"
  3384. // loc, _ := time.LoadLocation("Local")
  3385. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3386. // if err != nil {
  3387. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3388. // return
  3389. // }
  3390. // recordStartTime := theStartTime.Unix()
  3391. // start_time = recordStartTime
  3392. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3393. // if err != nil {
  3394. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3395. // return
  3396. // }
  3397. // recordEndTime := theEndTime.Unix()
  3398. // end_time = recordEndTime
  3399. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  3400. // data["pre"] = prescriptions
  3401. //
  3402. // }
  3403. //
  3404. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3405. //
  3406. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3407. // timestamp := time.Now().Unix()
  3408. // tempTime := time.Unix(timestamp, 0)
  3409. // timeFormat := tempTime.Format("20060102150405")
  3410. // chrgBchno := rand.Intn(100000) + 10000
  3411. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3412. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3413. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3414. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3415. // strconv.FormatInt(his.PatientId, 10)
  3416. // client := &http.Client{}
  3417. // data["psn_no"] = his.PsnNo
  3418. // data["mdtrt_id"] = his.Number
  3419. // data["chrg_bchno"] = chrg_bchno
  3420. // data["org_name"] = miConfig.OrgName
  3421. // data["doctor"] = roles.UserName
  3422. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3423. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3424. // data["fixmedins_code"] = miConfig.Code
  3425. // data["dept_code"] = department.Number
  3426. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3427. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3428. // data["secret_key"] = miConfig.SecretKey
  3429. // var ids []int64
  3430. //
  3431. // for _, item := range prescriptions {
  3432. // ids = append(ids, item.ID)
  3433. // }
  3434. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3435. // if config.IsOpen == 1 { //对接了医保,走医保流程
  3436. // bytesData, _ := json.Marshal(data)
  3437. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  3438. // resp, _ := client.Do(req)
  3439. // defer resp.Body.Close()
  3440. // body, ioErr := ioutil.ReadAll(resp.Body)
  3441. // if ioErr != nil {
  3442. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3443. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3444. // return
  3445. // }
  3446. // var respJSON map[string]interface{}
  3447. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3448. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3449. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3450. // return
  3451. // }
  3452. //
  3453. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3454. // userJSONBytes, _ := json.Marshal(respJSON)
  3455. // var res ResultFour
  3456. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3457. // utils.ErrorLog("解析失败:%v", err)
  3458. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3459. // return
  3460. // }
  3461. //
  3462. // if res.Infcode == 0 {
  3463. // order := &models.HisOrder{
  3464. // UserOrgId: adminUser.CurrentOrgId,
  3465. // HisPatientId: his.ID,
  3466. // PatientId: his.PatientId,
  3467. // SettleAccountsDate: recordDateTime,
  3468. // Ctime: time.Now().Unix(),
  3469. // Mtime: time.Now().Unix(),
  3470. // Status: 1,
  3471. // Number: chrg_bchno,
  3472. // Infcode: res.Infcode,
  3473. // WarnMsg: res.WarnMsg,
  3474. // Cainfo: res.Cainfo,
  3475. // ErrMsg: res.ErrMsg,
  3476. // RespondTime: res.RefmsgTime,
  3477. // InfRefmsgid: res.InfRefmsgid,
  3478. // OrderStatus: 1,
  3479. // IsMedicineInsurance: 1,
  3480. // SettleType: settle_accounts_type,
  3481. // SettleStartTime: start_time,
  3482. // SettleEndTime: end_time,
  3483. // Creator: roles.ID,
  3484. // Modify: roles.ID,
  3485. // PType: 2,
  3486. // }
  3487. // err = service.CreateOrder(order)
  3488. // if err != nil {
  3489. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  3490. // return
  3491. // }
  3492. //
  3493. // for _, item := range res.Output.Result {
  3494. // temp := strings.Split(item.FeedetlSn, "-")
  3495. // var advice_id int64 = 0
  3496. // var project_id int64 = 0
  3497. // var types int64 = 0
  3498. //
  3499. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  3500. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  3501. //
  3502. // if temp[1] == "1" {
  3503. // advice_id = id
  3504. // project_id = 0
  3505. // } else if temp[1] == "2" {
  3506. // advice_id = 0
  3507. // project_id = id
  3508. // }
  3509. //
  3510. // info := &models.HisOrderInfo{
  3511. // OrderNumber: order.Number,
  3512. // FeedetlSn: item.FeedetlSn,
  3513. // UploadDate: time.Now().Unix(),
  3514. // AdviceId: advice_id,
  3515. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  3516. // Cnt: item.Cnt,
  3517. // Pric: float64(item.Pric),
  3518. // PatientId: his.PatientId,
  3519. // PricUplmtAmt: item.PricUplmtAmt,
  3520. // SelfpayProp: item.SelfpayProp,
  3521. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  3522. // OverlmtAmt: item.OverlmtAmt,
  3523. // PreselfpayAmt: item.PreselfpayAmt,
  3524. // BasMednFlag: item.BasMednFlag,
  3525. // MedChrgitmType: item.MedChrgitmType,
  3526. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  3527. // Status: 1,
  3528. // Memo: item.Memo,
  3529. // Mtime: time.Now().Unix(),
  3530. // InscpScpAmt: item.InscpScpAmt,
  3531. // DrtReimFlag: item.DrtReimFlag,
  3532. // Ctime: time.Now().Unix(),
  3533. // ListSpItemFlag: item.ListSpItemFlag,
  3534. // ChldMedcFlag: item.ChldMedcFlag,
  3535. // LmtUsedFlag: item.LmtUsedFlag,
  3536. // ChrgitmLv: item.ChrgitmLv,
  3537. // UserOrgId: adminUser.CurrentOrgId,
  3538. // HisPatientId: his.ID,
  3539. // OrderId: order.ID,
  3540. // ProjectId: project_id,
  3541. // Type: types,
  3542. // }
  3543. // service.CreateOrderInfo(info)
  3544. //
  3545. // }
  3546. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3547. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  3548. //
  3549. // var total float64
  3550. // for _, item := range prescriptions {
  3551. // if item.Type == 1 { //药品
  3552. // for _, subItem := range item.HisDoctorAdviceInfo {
  3553. // total = total + (subItem.Price * subItem.PrescribingNumber)
  3554. // }
  3555. // }
  3556. // if item.Type == 2 { //项目
  3557. // for _, subItem := range item.HisPrescriptionProject {
  3558. // total = total + (subItem.Price * float64(subItem.Count))
  3559. // }
  3560. // }
  3561. // }
  3562. //
  3563. // for _, item := range prescriptions {
  3564. // for _, subItem := range item.HisAdditionalCharge {
  3565. // total = total + (subItem.Price * float64(subItem.Count))
  3566. // }
  3567. // }
  3568. //
  3569. // allTotal := fmt.Sprintf("%.2f", total)
  3570. // if res.Infcode == 0 {
  3571. // var rf []*ResultFive
  3572. // json.Unmarshal([]byte(his.Iinfo), &rf)
  3573. // psn_no := his.PsnNo
  3574. // mdtrt_id := his.Number
  3575. // chrg_bchno := chrg_bchno
  3576. // cert_no := his.Certno
  3577. // insutype := rf[0].Insutype
  3578. //
  3579. // if his.IdCardType == 1 {
  3580. // cert_no = his.MedicalInsuranceNumber
  3581. //
  3582. // } else {
  3583. //
  3584. // cert_no = his.Certno
  3585. //
  3586. // }
  3587. //
  3588. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  3589. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  3590. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  3591. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  3592. // resp, requestErr := http.Get(api)
  3593. // if requestErr != nil {
  3594. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3595. // return
  3596. // }
  3597. // defer resp.Body.Close()
  3598. // body, ioErr := ioutil.ReadAll(resp.Body)
  3599. // if ioErr != nil {
  3600. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3601. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3602. // return
  3603. // }
  3604. // var respJSON map[string]interface{}
  3605. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3606. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3607. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3608. // return
  3609. // }
  3610. // fmt.Println(respJSON)
  3611. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3612. // userJSONBytes, _ := json.Marshal(respJSON)
  3613. // var res ResultSeven
  3614. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3615. // utils.ErrorLog("解析失败:%v", err)
  3616. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3617. // return
  3618. // }
  3619. // if res.Infcode != 0 {
  3620. // errlog := &models.HisOrderError{
  3621. // UserOrgId: adminUser.CurrentOrgId,
  3622. // Ctime: time.Now().Unix(),
  3623. // Mtime: time.Now().Unix(),
  3624. // Number: chrg_bchno,
  3625. // ErrMsg: res.ErrMsg,
  3626. // Status: 1,
  3627. // PatientId: id,
  3628. // RecordTime: recordDateTime,
  3629. // Stage: 7,
  3630. // }
  3631. // service.CreateErrMsgLog(errlog)
  3632. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3633. // return
  3634. // } else {
  3635. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3636. // order.OrderStatus = 1
  3637. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3638. // order.SetlId = res.Output.Setlinfo.SetlID
  3639. // order.PsnNo = res.Output.Setlinfo.PsnNo
  3640. // order.PsnName = res.Output.Setlinfo.PsnName
  3641. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3642. // order.Certno = res.Output.Setlinfo.Certno
  3643. // order.Gend = res.Output.Setlinfo.Gend
  3644. // order.Naty = res.Output.Setlinfo.Naty
  3645. // order.Age = res.Output.Setlinfo.Age
  3646. // order.Insutype = res.Output.Setlinfo.Insutype
  3647. // order.PsnType = res.Output.Setlinfo.PsnType
  3648. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3649. // order.SetlTime = res.Output.Setlinfo.SetlTime
  3650. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3651. // order.MedType = res.Output.Setlinfo.MedType
  3652. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3653. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3654. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3655. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3656. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3657. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3658. // order.HifpPay = res.Output.Setlinfo.HifpPay
  3659. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3660. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3661. // order.HifesPay = res.Output.Setlinfo.HifesPay
  3662. // order.HifobPay = res.Output.Setlinfo.HifobPay
  3663. // order.MafPay = res.Output.Setlinfo.MafPay
  3664. // order.OthPay = res.Output.Setlinfo.OthPay
  3665. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3666. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3667. // order.AcctPay = res.Output.Setlinfo.AcctPay
  3668. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3669. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3670. // order.Balc = res.Output.Setlinfo.Balc
  3671. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3672. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3673. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3674. // order.ClrWay = res.Output.Setlinfo.ClrWay
  3675. // order.Creator = order.Creator
  3676. // order.Modify = roles.ID
  3677. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3678. // detailStr := string(setlDetail)
  3679. // order.SetlDetail = detailStr
  3680. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3681. // err = service.UpDateOrder(order)
  3682. // if err == nil {
  3683. // c.ServeSuccessJSON(map[string]interface{}{
  3684. // "msg": "预结算成功",
  3685. // })
  3686. // } else {
  3687. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3688. // return
  3689. // }
  3690. // }
  3691. // } else {
  3692. // adminUser := c.GetAdminUserInfo()
  3693. // errlog := &models.HisOrderError{
  3694. // UserOrgId: adminUser.CurrentOrgId,
  3695. // Ctime: time.Now().Unix(),
  3696. // Mtime: time.Now().Unix(),
  3697. // ErrMsg: res.ErrMsg,
  3698. // Status: 1,
  3699. // PatientId: id,
  3700. // RecordTime: recordDateTime,
  3701. // Stage: 4,
  3702. // }
  3703. // service.CreateErrMsgLog(errlog)
  3704. //
  3705. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3706. // return
  3707. // }
  3708. // } else {
  3709. // adminUser := c.GetAdminUserInfo()
  3710. // errlog := &models.HisOrderError{
  3711. // UserOrgId: adminUser.CurrentOrgId,
  3712. // Ctime: time.Now().Unix(),
  3713. // Mtime: time.Now().Unix(),
  3714. // ErrMsg: res.ErrMsg,
  3715. // Status: 1,
  3716. // PatientId: id,
  3717. // RecordTime: recordDateTime,
  3718. // Stage: 4,
  3719. // }
  3720. // service.CreateErrMsgLog(errlog)
  3721. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  3722. // return
  3723. // }
  3724. //
  3725. // } else {
  3726. // var total float64
  3727. // for _, item := range prescriptions {
  3728. // if item.Type == 1 { //药品
  3729. // for _, subItem := range item.HisDoctorAdviceInfo {
  3730. // total = total + (subItem.Price * subItem.PrescribingNumber)
  3731. // }
  3732. // }
  3733. // if item.Type == 2 { //项目
  3734. // for _, subItem := range item.HisPrescriptionProject {
  3735. // total = total + (subItem.Price * float64(subItem.Count))
  3736. // }
  3737. // }
  3738. //
  3739. // for _, subItem := range item.HisAdditionalCharge {
  3740. // total = total + (subItem.Price * float64(subItem.Count))
  3741. // }
  3742. // }
  3743. //
  3744. // allTotal := fmt.Sprintf("%.2f", total)
  3745. // totals, _ := strconv.ParseFloat(allTotal, 64)
  3746. // order := &models.HisOrder{
  3747. // UserOrgId: adminUser.CurrentOrgId,
  3748. // HisPatientId: his.ID,
  3749. // PatientId: id,
  3750. // SettleAccountsDate: recordDateTime,
  3751. // Ctime: time.Now().Unix(),
  3752. // Mtime: time.Now().Unix(),
  3753. // Status: 1,
  3754. // OrderStatus: 2,
  3755. // Number: chrg_bchno,
  3756. // MedfeeSumamt: totals,
  3757. // }
  3758. // err = service.CreateOrder(order)
  3759. // if err != nil {
  3760. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  3761. // return
  3762. // }
  3763. //
  3764. // var customs []*Custom
  3765. // for _, item := range prescriptions {
  3766. //
  3767. // if item.Type == 1 { //药品
  3768. // for _, subItem := range item.HisDoctorAdviceInfo {
  3769. // cus := &Custom{
  3770. // AdviceId: subItem.ID,
  3771. // ProjectId: 0,
  3772. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  3773. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  3774. // FeedetlSn: subItem.FeedetlSn,
  3775. // Price: fmt.Sprintf("%.2f", subItem.Price),
  3776. // MedListCodg: subItem.MedListCodg,
  3777. // Type: 1,
  3778. // }
  3779. // customs = append(customs, cus)
  3780. // }
  3781. // }
  3782. //
  3783. // if item.Type == 2 { //项目
  3784. // for _, subItem := range item.HisPrescriptionProject {
  3785. //
  3786. // cus := &Custom{
  3787. // AdviceId: 0,
  3788. // ProjectId: subItem.ID,
  3789. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  3790. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  3791. // FeedetlSn: subItem.FeedetlSn,
  3792. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  3793. // MedListCodg: subItem.MedListCodg,
  3794. // Type: 2,
  3795. // }
  3796. //
  3797. // customs = append(customs, cus)
  3798. // }
  3799. // }
  3800. //
  3801. // for _, item := range item.HisAdditionalCharge {
  3802. // cus := &Custom{
  3803. // ItemId: item.ID,
  3804. // AdviceId: 0,
  3805. // ProjectId: 0,
  3806. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  3807. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  3808. // FeedetlSn: item.FeedetlSn,
  3809. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  3810. // MedListCodg: item.XtHisAddtionConfig.Code,
  3811. // Type: 3,
  3812. // }
  3813. //
  3814. // customs = append(customs, cus)
  3815. // }
  3816. //
  3817. // }
  3818. //
  3819. // for _, item := range customs {
  3820. // var advice_id int64 = 0
  3821. // var project_id int64 = 0
  3822. // var item_id int64 = 0
  3823. //
  3824. // var types int64 = 0
  3825. //
  3826. // if item.Type == 1 {
  3827. // advice_id = item.AdviceId
  3828. // project_id = 0
  3829. // item_id = 0
  3830. // } else if item.Type == 2 {
  3831. // advice_id = 0
  3832. // item_id = 0
  3833. //
  3834. // project_id = item.ProjectId
  3835. // } else if item.Type == 3 {
  3836. // advice_id = 0
  3837. // item_id = item.ItemId
  3838. // project_id = 0
  3839. // }
  3840. //
  3841. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  3842. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  3843. // pric, _ := strconv.ParseFloat(item.Price, 32)
  3844. //
  3845. // info := &models.HisOrderInfo{
  3846. // OrderNumber: order.Number,
  3847. // UploadDate: time.Now().Unix(),
  3848. // AdviceId: advice_id,
  3849. // DetItemFeeSumamt: detItemFeeSumamt,
  3850. // Cnt: cut,
  3851. // Pric: pric,
  3852. // PatientId: id,
  3853. // Status: 1,
  3854. // Mtime: time.Now().Unix(),
  3855. // Ctime: time.Now().Unix(),
  3856. // UserOrgId: adminUser.CurrentOrgId,
  3857. // HisPatientId: his.ID,
  3858. // OrderId: order.ID,
  3859. // ProjectId: project_id,
  3860. // Type: types,
  3861. // ItemId: item_id,
  3862. // }
  3863. // service.CreateOrderInfo(info)
  3864. // }
  3865. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3866. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3867. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  3868. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3869. // if err == nil {
  3870. // c.ServeSuccessJSON(map[string]interface{}{
  3871. // "msg": "结算成功",
  3872. // })
  3873. // } else {
  3874. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3875. // return
  3876. // }
  3877. // }
  3878. //}
  3879. //上传明细-预结算-
  3880. func (c *HisApiController) GetPreUploadInfo() {
  3881. id, _ := c.GetInt64("id")
  3882. record_time := c.GetString("record_time")
  3883. his_patient_id, _ := c.GetInt64("his_patient_id")
  3884. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3885. admin_user_id, _ := c.GetInt64("admin_user_id")
  3886. diagnosis_id := c.GetString("diagnosis")
  3887. sick_type, _ := c.GetInt64("sick_type")
  3888. reg_type, _ := c.GetInt64("p_type")
  3889. id_str := c.GetString("ids")
  3890. ids_arr := strings.Split(id_str, ",")
  3891. timeLayout := "2006-01-02"
  3892. loc, _ := time.LoadLocation("Local")
  3893. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3894. if err != nil {
  3895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3896. return
  3897. }
  3898. recordDateTime := theTime.Unix()
  3899. adminUser := c.GetAdminUserInfo()
  3900. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3901. var config []*models.HisXtDiagnoseConfig
  3902. for _, item := range diagnosis_ids {
  3903. id, _ := strconv.ParseInt(item, 10, 64)
  3904. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3905. config = append(config, &diagnosisConfig)
  3906. }
  3907. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  3908. sickConfig, _ := service.FindSickById(sick_type)
  3909. var prescriptions []*models.HisPrescription
  3910. var start_time int64
  3911. var end_time int64
  3912. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3913. fmt.Println(his_patient_id)
  3914. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3915. timestamp := time.Now().Unix()
  3916. tempTime := time.Unix(timestamp, 0)
  3917. timeFormat := tempTime.Format("20060102150405")
  3918. chrgBchno := rand.Intn(100000) + 10000
  3919. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3920. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3921. var patientPrescription models.HisPrescriptionInfo
  3922. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3923. if patientPrescription.ID == 0 {
  3924. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3925. }
  3926. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3927. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3928. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3929. strconv.FormatInt(his.PatientId, 10)
  3930. var res2 ResultSix
  3931. if miConfig.InsuplcAdmdvs == "421300" {
  3932. data := make(map[string]interface{})
  3933. client := &http.Client{}
  3934. data["psn_no"] = his.PsnNo
  3935. data["mdtrt_id"] = his.Number
  3936. data["doctor"] = roles.UserName
  3937. data["department"] = department.Name
  3938. data["org_name"] = miConfig.OrgName
  3939. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3940. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3941. data["fixmedins_code"] = miConfig.Code
  3942. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3943. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3944. data["secret_key"] = miConfig.SecretKey
  3945. data["sick_code"] = sickConfig.CountryCode
  3946. data["sick_name"] = sickConfig.ClassName
  3947. data["dept"] = strconv.FormatInt(department.ID, 10)
  3948. data["config"] = config
  3949. fmt.Println(data)
  3950. bytesData, _ := json.Marshal(data)
  3951. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3952. resp, _ := client.Do(req)
  3953. defer resp.Body.Close()
  3954. body, ioErr := ioutil.ReadAll(resp.Body)
  3955. if ioErr != nil {
  3956. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3958. return
  3959. }
  3960. var respJSON map[string]interface{}
  3961. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3962. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3964. return
  3965. }
  3966. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3967. userJSONBytes, _ := json.Marshal(respJSON)
  3968. fmt.Println("log")
  3969. fmt.Println(string(userJSONBytes))
  3970. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3971. utils.ErrorLog("解析失败:%v", err)
  3972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3973. return
  3974. }
  3975. } else {
  3976. var result string
  3977. var requestLog string
  3978. if miConfig.InsuplcAdmdvs == "440781" { //
  3979. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config)
  3980. } else {
  3981. result, requestLog = service.Gdyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.CountryCode, sickConfig.ClassName, roles.UserName, config)
  3982. saveLog(result, requestLog, "2203", "上传就诊信息")
  3983. var respJSON2 map[string]interface{}
  3984. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3985. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3987. return
  3988. }
  3989. userJSONBytes2, _ := json.Marshal(respJSON2)
  3990. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3991. utils.ErrorLog("解析失败:%v", err)
  3992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3993. return
  3994. }
  3995. }
  3996. }
  3997. if res2.Infcode != 0 {
  3998. adminUser := c.GetAdminUserInfo()
  3999. errlog := &models.HisOrderError{
  4000. UserOrgId: adminUser.CurrentOrgId,
  4001. Ctime: time.Now().Unix(),
  4002. Mtime: time.Now().Unix(),
  4003. ErrMsg: res2.ErrMsg,
  4004. Status: 1,
  4005. PatientId: id,
  4006. RecordTime: recordDateTime,
  4007. Stage: 3,
  4008. }
  4009. service.CreateErrMsgLog(errlog)
  4010. c.ServeSuccessJSON(map[string]interface{}{
  4011. "failed_code": -10,
  4012. "msg": res2.ErrMsg,
  4013. })
  4014. return
  4015. } else {
  4016. his.Diagnosis = diagnosis_id
  4017. his.SickType = sickConfig.ID
  4018. his.PType = fmt.Sprintf("%d", reg_type)
  4019. service.UpdateHisPatientThree(&his)
  4020. data := make(map[string]interface{})
  4021. if settle_accounts_type == 1 { //日结
  4022. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4023. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4024. } else {
  4025. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4026. }
  4027. data["pre"] = prescriptions
  4028. } else { //月结
  4029. start_time_str := c.GetString("start_time")
  4030. end_time_str := c.GetString("end_time")
  4031. timeLayout := "2006-01-02"
  4032. loc, _ := time.LoadLocation("Local")
  4033. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4034. if err != nil {
  4035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4036. return
  4037. }
  4038. recordStartTime := theStartTime.Unix()
  4039. start_time = recordStartTime
  4040. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4041. if err != nil {
  4042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4043. return
  4044. }
  4045. recordEndTime := theEndTime.Unix()
  4046. end_time = recordEndTime
  4047. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4048. data["pre"] = prescriptions
  4049. }
  4050. client := &http.Client{}
  4051. data["psn_no"] = his.PsnNo
  4052. data["mdtrt_id"] = his.Number
  4053. data["chrg_bchno"] = chrg_bchno
  4054. data["org_name"] = miConfig.OrgName
  4055. data["doctor"] = roles.UserName
  4056. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4057. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4058. data["fixmedins_code"] = miConfig.Code
  4059. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4060. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4061. data["dept_code"] = "15"
  4062. } else {
  4063. data["dept_code"] = department.Number
  4064. }
  4065. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4066. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4067. data["secret_key"] = miConfig.SecretKey
  4068. var ids []int64
  4069. for _, item := range prescriptions {
  4070. ids = append(ids, item.ID)
  4071. }
  4072. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4073. if config.IsOpen == 1 { //对接了医保,走医保流程
  4074. var res ResultFour
  4075. if miConfig.MdtrtareaAdmvs == "421300" {
  4076. bytesData, _ := json.Marshal(data)
  4077. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4078. resp, _ := client.Do(req)
  4079. defer resp.Body.Close()
  4080. body, ioErr := ioutil.ReadAll(resp.Body)
  4081. if ioErr != nil {
  4082. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4084. return
  4085. }
  4086. var respJSON map[string]interface{}
  4087. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4088. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4090. return
  4091. }
  4092. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4093. userJSONBytes, _ := json.Marshal(respJSON)
  4094. fmt.Println("log")
  4095. fmt.Println(string(userJSONBytes))
  4096. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4097. utils.ErrorLog("解析失败:%v", err)
  4098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4099. return
  4100. }
  4101. } else {
  4102. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, data["dept"].(string), data["fixmedins_code"].(string), data["dept_code"].(string), data["doctor_id"].(string), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string))
  4103. var dat map[string]interface{}
  4104. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4105. fmt.Println(dat)
  4106. } else {
  4107. fmt.Println(err)
  4108. }
  4109. saveLog(result, request_log, "2204", "上传费用明细")
  4110. userJSONBytes, _ := json.Marshal(dat)
  4111. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4112. utils.ErrorLog("解析失败:%v", err)
  4113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4114. return
  4115. }
  4116. }
  4117. if res.Infcode == 0 {
  4118. order := &models.HisOrder{
  4119. UserOrgId: adminUser.CurrentOrgId,
  4120. HisPatientId: his.ID,
  4121. PatientId: his.PatientId,
  4122. SettleAccountsDate: recordDateTime,
  4123. Ctime: time.Now().Unix(),
  4124. Mtime: time.Now().Unix(),
  4125. Status: 1,
  4126. Number: chrg_bchno,
  4127. Infcode: res.Infcode,
  4128. WarnMsg: res.WarnMsg,
  4129. Cainfo: res.Cainfo,
  4130. ErrMsg: res.ErrMsg,
  4131. RespondTime: res.RefmsgTime,
  4132. InfRefmsgid: res.InfRefmsgid,
  4133. OrderStatus: 1,
  4134. IsMedicineInsurance: 1,
  4135. SettleType: settle_accounts_type,
  4136. SettleStartTime: start_time,
  4137. SettleEndTime: end_time,
  4138. Creator: roles.AdminUserId,
  4139. Modify: roles.AdminUserId,
  4140. PType: 2,
  4141. Diagnosis: diagnosis_id,
  4142. }
  4143. err = service.CreateOrder(order)
  4144. if err != nil {
  4145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4146. return
  4147. }
  4148. for _, item := range res.Output.Result {
  4149. temp := strings.Split(item.FeedetlSn, "-")
  4150. var advice_id int64 = 0
  4151. var project_id int64 = 0
  4152. var types int64 = 0
  4153. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4154. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4155. if temp[1] == "1" {
  4156. advice_id = id
  4157. project_id = 0
  4158. } else if temp[1] == "2" {
  4159. advice_id = 0
  4160. project_id = id
  4161. }
  4162. info := &models.HisOrderInfo{
  4163. OrderNumber: order.Number,
  4164. FeedetlSn: item.FeedetlSn,
  4165. UploadDate: time.Now().Unix(),
  4166. AdviceId: advice_id,
  4167. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4168. Cnt: item.Cnt,
  4169. Pric: float64(item.Pric),
  4170. PatientId: his.PatientId,
  4171. PricUplmtAmt: item.PricUplmtAmt,
  4172. SelfpayProp: item.SelfpayProp,
  4173. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4174. OverlmtAmt: item.OverlmtAmt,
  4175. PreselfpayAmt: item.PreselfpayAmt,
  4176. BasMednFlag: item.BasMednFlag,
  4177. MedChrgitmType: item.MedChrgitmType,
  4178. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4179. Status: 1,
  4180. Memo: item.Memo,
  4181. Mtime: time.Now().Unix(),
  4182. InscpScpAmt: item.InscpScpAmt,
  4183. DrtReimFlag: item.DrtReimFlag,
  4184. Ctime: time.Now().Unix(),
  4185. ListSpItemFlag: item.ListSpItemFlag,
  4186. ChldMedcFlag: item.ChldMedcFlag,
  4187. LmtUsedFlag: item.LmtUsedFlag,
  4188. ChrgitmLv: item.ChrgitmLv,
  4189. UserOrgId: adminUser.CurrentOrgId,
  4190. HisPatientId: his.ID,
  4191. OrderId: order.ID,
  4192. ProjectId: project_id,
  4193. Type: types,
  4194. }
  4195. service.CreateOrderInfo(info)
  4196. }
  4197. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4198. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4199. var total float64
  4200. for _, item := range prescriptions {
  4201. if item.Type == 1 { //药品
  4202. for _, subItem := range item.HisDoctorAdviceInfo {
  4203. total = total + (subItem.Price * subItem.PrescribingNumber)
  4204. }
  4205. }
  4206. if item.Type == 2 { //项目
  4207. for _, subItem := range item.HisPrescriptionProject {
  4208. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4209. total = total + (subItem.Price * cnt)
  4210. }
  4211. }
  4212. }
  4213. for _, item := range prescriptions {
  4214. for _, subItem := range item.HisAdditionalCharge {
  4215. total = total + (subItem.Price * float64(subItem.Count))
  4216. }
  4217. }
  4218. allTotal := fmt.Sprintf("%.4f", total)
  4219. if res.Infcode == 0 {
  4220. var rf []*ResultFive
  4221. json.Unmarshal([]byte(his.Iinfo), &rf)
  4222. chrg_bchno := chrg_bchno
  4223. cert_no := his.Certno
  4224. var insutypes []string
  4225. var insutype string
  4226. var is390 int = 0
  4227. var is310 int = 0
  4228. for _, item := range rf {
  4229. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4230. insutypes = append(insutypes, item.Insutype)
  4231. }
  4232. }
  4233. if len(insutypes) == 1 {
  4234. insutype = insutypes[0]
  4235. } else {
  4236. for _, i := range insutypes {
  4237. if i == "390" {
  4238. is390 = 1
  4239. }
  4240. if i == "310" {
  4241. is310 = 1
  4242. }
  4243. }
  4244. }
  4245. if is390 == 1 {
  4246. insutype = "390"
  4247. }
  4248. if is310 == 1 {
  4249. insutype = "310"
  4250. }
  4251. if len(insutypes) == 0 {
  4252. insutype = "310"
  4253. }
  4254. if len(insutypes) == 2 {
  4255. insutype = strconv.FormatInt(his.SocialType, 64)
  4256. }
  4257. //insutype = "390"
  4258. if his.IdCardType == 1 {
  4259. cert_no = his.MedicalInsuranceNumber
  4260. } else {
  4261. cert_no = his.Certno
  4262. }
  4263. var res ResultSeven
  4264. if miConfig.MdtrtareaAdmvs == "421300" {
  4265. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4266. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4267. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4268. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4269. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4270. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4271. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  4272. resp, requestErr := http.Get(api)
  4273. if requestErr != nil {
  4274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4275. return
  4276. }
  4277. body, ioErr := ioutil.ReadAll(resp.Body)
  4278. if ioErr != nil {
  4279. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4281. return
  4282. }
  4283. var respJSON map[string]interface{}
  4284. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4285. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4287. return
  4288. }
  4289. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4290. result, _ := json.Marshal(respJSON)
  4291. fmt.Println("log")
  4292. fmt.Println(string(result))
  4293. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4294. utils.ErrorLog("解析失败:%v", err)
  4295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4296. return
  4297. }
  4298. } else {
  4299. result, request_log := service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
  4300. var dat map[string]interface{}
  4301. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4302. fmt.Println(dat)
  4303. } else {
  4304. fmt.Println(err)
  4305. }
  4306. saveLog(result, request_log, "2206", "预结算")
  4307. userJSONBytes, _ := json.Marshal(dat)
  4308. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4309. utils.ErrorLog("解析失败:%v", err)
  4310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4311. return
  4312. }
  4313. }
  4314. if res.Infcode != 0 {
  4315. errlog := &models.HisOrderError{
  4316. UserOrgId: adminUser.CurrentOrgId,
  4317. Ctime: time.Now().Unix(),
  4318. Mtime: time.Now().Unix(),
  4319. Number: chrg_bchno,
  4320. ErrMsg: res.ErrMsg,
  4321. Status: 1,
  4322. PatientId: id,
  4323. RecordTime: recordDateTime,
  4324. Stage: 20,
  4325. }
  4326. service.CreateErrMsgLog(errlog)
  4327. c.ServeSuccessJSON(map[string]interface{}{
  4328. "failed_code": -10,
  4329. "msg": res.ErrMsg,
  4330. })
  4331. return
  4332. } else {
  4333. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4334. order.OrderStatus = 1
  4335. order.IsPre = 1
  4336. order.Status = 1
  4337. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4338. order.SetlId = res.Output.Setlinfo.SetlID
  4339. order.PsnNo = res.Output.Setlinfo.PsnNo
  4340. order.PsnName = res.Output.Setlinfo.PsnName
  4341. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4342. order.Certno = res.Output.Setlinfo.Certno
  4343. order.Gend = res.Output.Setlinfo.Gend
  4344. order.Naty = res.Output.Setlinfo.Naty
  4345. order.Age = res.Output.Setlinfo.Age
  4346. order.Insutype = res.Output.Setlinfo.Insutype
  4347. order.PsnType = res.Output.Setlinfo.PsnType
  4348. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4349. order.SetlTime = res.Output.Setlinfo.SetlTime
  4350. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4351. if res.Output.Setlinfo.MedType == "140101" {
  4352. order.MedType = "14"
  4353. } else {
  4354. order.MedType = res.Output.Setlinfo.MedType
  4355. }
  4356. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4357. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4358. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4359. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4360. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4361. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4362. order.HifpPay = res.Output.Setlinfo.HifpPay
  4363. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4364. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4365. order.HifesPay = res.Output.Setlinfo.HifesPay
  4366. order.HifobPay = res.Output.Setlinfo.HifobPay
  4367. order.MafPay = res.Output.Setlinfo.MafPay
  4368. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4369. order.OthPay = res.Output.Setlinfo.OthPay
  4370. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4371. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4372. order.AcctPay = res.Output.Setlinfo.AcctPay
  4373. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4374. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4375. order.Balc = res.Output.Setlinfo.Balc
  4376. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4377. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4378. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4379. order.ClrWay = res.Output.Setlinfo.ClrWay
  4380. order.Creator = order.Creator
  4381. order.Modify = roles.AdminUserId
  4382. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4383. detailStr := string(setlDetail)
  4384. order.SetlDetail = detailStr
  4385. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4386. err = service.UpDateOrder(order)
  4387. if err == nil {
  4388. c.ServeSuccessJSON(map[string]interface{}{
  4389. "msg": "预结算成功",
  4390. })
  4391. } else {
  4392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4393. return
  4394. }
  4395. }
  4396. } else {
  4397. adminUser := c.GetAdminUserInfo()
  4398. errlog := &models.HisOrderError{
  4399. UserOrgId: adminUser.CurrentOrgId,
  4400. Ctime: time.Now().Unix(),
  4401. Mtime: time.Now().Unix(),
  4402. ErrMsg: res.ErrMsg,
  4403. Status: 1,
  4404. PatientId: id,
  4405. RecordTime: recordDateTime,
  4406. Stage: 4,
  4407. }
  4408. service.CreateErrMsgLog(errlog)
  4409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4410. return
  4411. }
  4412. } else {
  4413. adminUser := c.GetAdminUserInfo()
  4414. errlog := &models.HisOrderError{
  4415. UserOrgId: adminUser.CurrentOrgId,
  4416. Ctime: time.Now().Unix(),
  4417. Mtime: time.Now().Unix(),
  4418. ErrMsg: res.ErrMsg,
  4419. Status: 1,
  4420. PatientId: id,
  4421. RecordTime: recordDateTime,
  4422. Stage: 4,
  4423. }
  4424. service.CreateErrMsgLog(errlog)
  4425. c.ServeSuccessJSON(map[string]interface{}{
  4426. "failed_code": -10,
  4427. "msg": res.ErrMsg,
  4428. })
  4429. return
  4430. }
  4431. }
  4432. }
  4433. }
  4434. //func (c *HisApiController) GetSettleInfo() {
  4435. // id, _ := c.GetInt64("id")
  4436. // order_id, _ := c.GetInt64("order_id")
  4437. //
  4438. // record_time := c.GetString("record_time")
  4439. // pay_way, _ := c.GetInt64("pay_way")
  4440. // pay_price, _ := c.GetFloat("pay_price")
  4441. // pay_card_no := c.GetString("pay_card_no")
  4442. // discount_price, _ := c.GetFloat("discount_price")
  4443. // preferential_price, _ := c.GetFloat("preferential_price")
  4444. // reality_price, _ := c.GetFloat("reality_price")
  4445. // found_price, _ := c.GetFloat("found_price")
  4446. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4447. // private_price, _ := c.GetFloat("private_price")
  4448. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4449. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4450. //
  4451. // timeLayout := "2006-01-02"
  4452. // loc, _ := time.LoadLocation("Local")
  4453. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4454. // if err != nil {
  4455. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4456. // return
  4457. // }
  4458. // recordDateTime := theTime.Unix()
  4459. // adminUser := c.GetAdminUserInfo()
  4460. //
  4461. // var prescriptions []*models.HisPrescription
  4462. //
  4463. // data := make(map[string]interface{})
  4464. // if settle_accounts_type == 1 { //日结
  4465. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  4466. // data["pre"] = prescriptions
  4467. //
  4468. // } else { //月结
  4469. // start_time_str := c.GetString("start_time")
  4470. // end_time_str := c.GetString("end_time")
  4471. // timeLayout := "2006-01-02"
  4472. // loc, _ := time.LoadLocation("Local")
  4473. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4474. // if err != nil {
  4475. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4476. // return
  4477. // }
  4478. // recordStartTime := theStartTime.Unix()
  4479. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4480. // if err != nil {
  4481. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4482. // return
  4483. // }
  4484. // recordEndTime := theEndTime.Unix()
  4485. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  4486. // data["pre"] = prescriptions
  4487. //
  4488. // }
  4489. //
  4490. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4491. //
  4492. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4493. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4494. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4495. // strconv.FormatInt(his.PatientId, 10)
  4496. //
  4497. // order_src, _ := service.GetHisOrderByID(order_id)
  4498. //
  4499. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4500. // if config.IsOpen == 1 { //对接了医保,走医保流程
  4501. //
  4502. // var total float64
  4503. // for _, item := range prescriptions {
  4504. // if item.Type == 1 { //药品
  4505. // for _, subItem := range item.HisDoctorAdviceInfo {
  4506. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4507. // }
  4508. // }
  4509. // if item.Type == 2 { //项目
  4510. // for _, subItem := range item.HisPrescriptionProject {
  4511. // total = total + (subItem.Price * float64(subItem.Count))
  4512. // }
  4513. // }
  4514. // }
  4515. //
  4516. // for _, item := range prescriptions {
  4517. // for _, subItem := range item.HisAdditionalCharge {
  4518. // total = total + (subItem.Price * float64(subItem.Count))
  4519. // }
  4520. // }
  4521. //
  4522. // allTotal := fmt.Sprintf("%.2f", total)
  4523. // var rf []*ResultFive
  4524. // json.Unmarshal([]byte(his.Iinfo), &rf)
  4525. // psn_no := order_src.PsnNo
  4526. // mdtrt_id := order_src.MdtrtId
  4527. // chrg_bchno := order_src.Number
  4528. // cert_no := order_src.Certno
  4529. // insutype := rf[0].Insutype
  4530. //
  4531. // if his.IdCardType == 1 {
  4532. // cert_no = his.MedicalInsuranceNumber
  4533. // } else {
  4534. // cert_no = his.Certno
  4535. // }
  4536. //
  4537. // result, src_resquest := service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, strconv.FormatFloat(total, 'E', -1, 64) ,miConfig.OrgName,roles.UserName,miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(patientPrescription.RegisterType, 10),his.IdCardType, order_src.FulamtOwnpayAmt,order_src.OverlmtSelfPay,order_src.PreselfpayAmt,order_src.InscpScpAmt)
  4538. // var dat map[string]interface{}
  4539. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4540. // fmt.Println(dat)
  4541. // } else {
  4542. // fmt.Println(err)
  4543. // }
  4544. //
  4545. // userJSONBytes, _ := json.Marshal(dat)
  4546. //
  4547. //
  4548. //
  4549. // var res ResultSeven
  4550. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4551. // utils.ErrorLog("解析失败:%v", err)
  4552. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4553. // return
  4554. // }
  4555. // if res.Infcode == -1 {
  4556. // errlog := &models.HisOrderError{
  4557. // UserOrgId: adminUser.CurrentOrgId,
  4558. // Ctime: time.Now().Unix(),
  4559. // Mtime: time.Now().Unix(),
  4560. // Number: chrg_bchno,
  4561. // ErrMsg: res.ErrMsg,
  4562. // Status: 1,
  4563. // PatientId: id,
  4564. // RecordTime: recordDateTime,
  4565. // Stage: 6,
  4566. // }
  4567. // service.CreateErrMsgLog(errlog)
  4568. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4569. // return
  4570. // } else {
  4571. // order_src.OrderStatus = 2
  4572. // order_src.PayWay = pay_way
  4573. // order_src.PayPrice = pay_price
  4574. // order_src.PayCardNo = pay_card_no
  4575. // order_src.DiscountPrice = discount_price
  4576. // order_src.PreferentialPrice = preferential_price
  4577. // order_src.RealityPrice = reality_price
  4578. // order_src.FoundPrice = found_price
  4579. // order_src.MedicalInsurancePrice = medical_insurance_price
  4580. // order_src.PrivatePrice = private_price
  4581. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  4582. // order_src.SetlId = res.Output.Setlinfo.SetlID
  4583. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  4584. // order_src.PsnName = res.Output.Setlinfo.PsnName
  4585. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  4586. // order_src.Certno = res.Output.Setlinfo.Certno
  4587. // order_src.Gend = res.Output.Setlinfo.Gend
  4588. // order_src.Naty = res.Output.Setlinfo.Naty
  4589. // order_src.Age = res.Output.Setlinfo.Age
  4590. // order_src.Insutype = res.Output.Setlinfo.Insutype
  4591. // order_src.PsnType = res.Output.Setlinfo.PsnType
  4592. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4593. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  4594. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4595. // order_src.MedType = res.Output.Setlinfo.MedType
  4596. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4597. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4598. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4599. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4600. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4601. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4602. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  4603. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  4604. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4605. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  4606. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  4607. // order_src.MafPay = res.Output.Setlinfo.MafPay
  4608. // order_src.OthPay = res.Output.Setlinfo.OthPay
  4609. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4610. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4611. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  4612. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4613. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4614. // order_src.Balc = res.Output.Setlinfo.Balc
  4615. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4616. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4617. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  4618. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  4619. // order_src.Creator = order_src.Creator
  4620. // order_src.Modify = roles.ID
  4621. // order_src.RequestLog = src_resquest
  4622. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4623. // detailStr := string(setlDetail)
  4624. // order_src.SetlDetail = detailStr
  4625. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4626. // err = service.UpDateOrder(order_src)
  4627. //
  4628. // if err == nil {
  4629. // c.ServeSuccessJSON(map[string]interface{}{
  4630. // "msg": "结算成功",
  4631. // })
  4632. // } else {
  4633. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4634. // return
  4635. // }
  4636. // }
  4637. // }
  4638. //}
  4639. //退款
  4640. func (c *HisApiController) Refund() {
  4641. order_id, _ := c.GetInt64("order_id")
  4642. admin_user_id, _ := c.GetInt64("admin_user_id")
  4643. //record_time := c.GetString("record_time")
  4644. //patient_id, _ := c.GetInt64("patient_id")
  4645. //timeLayout := "2006-01-02"
  4646. //loc, _ := time.LoadLocation("Local")
  4647. adminUser := c.GetAdminUserInfo()
  4648. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4649. //if err != nil {
  4650. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4651. // return
  4652. //}
  4653. //recordDateTime := theTime.Unix()
  4654. var order models.HisOrder
  4655. order, _ = service.GetHisOrderByID(order_id)
  4656. //his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4657. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4658. if order.ID == 0 {
  4659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4660. return
  4661. //order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  4662. }
  4663. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4664. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4665. if config.IsOpen == 1 { //对接了医保,走医保流程
  4666. var res ResultSixteen
  4667. var src_resquest string
  4668. var result string
  4669. if miConfig.MdtrtareaAdmvs == "421300" {
  4670. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  4671. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  4672. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  4673. resp3, requestErr3 := http.Get(api3)
  4674. if requestErr3 != nil {
  4675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4676. return
  4677. }
  4678. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  4679. if ioErr3 != nil {
  4680. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  4681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4682. return
  4683. }
  4684. var respJSON3 map[string]interface{}
  4685. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  4686. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4688. return
  4689. }
  4690. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4691. userJSONBytes3, _ := json.Marshal(respJSON3)
  4692. fmt.Println("log")
  4693. fmt.Println(string(userJSONBytes3))
  4694. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4695. utils.ErrorLog("解析失败:%v", err)
  4696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4697. return
  4698. }
  4699. } else {
  4700. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  4701. var dat map[string]interface{}
  4702. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4703. fmt.Println(dat)
  4704. } else {
  4705. fmt.Println(err)
  4706. }
  4707. saveLog(result, src_resquest, "2208", "退费")
  4708. userJSONBytes, _ := json.Marshal(dat)
  4709. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4710. utils.ErrorLog("解析失败:%v", err)
  4711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4712. return
  4713. }
  4714. }
  4715. if res.Infcode == 0 {
  4716. var res2 ResultSix
  4717. if miConfig.MdtrtareaAdmvs == "421300" {
  4718. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  4719. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  4720. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  4721. resp3, requestErr3 := http.Get(api3)
  4722. if requestErr3 != nil {
  4723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4724. return
  4725. }
  4726. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  4727. if ioErr3 != nil {
  4728. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  4729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4730. return
  4731. }
  4732. var respJSON3 map[string]interface{}
  4733. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  4734. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4736. return
  4737. }
  4738. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4739. userJSONBytes3, _ := json.Marshal(respJSON3)
  4740. fmt.Println("log")
  4741. fmt.Println(string(userJSONBytes3))
  4742. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  4743. utils.ErrorLog("解析失败:%v", err)
  4744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4745. return
  4746. }
  4747. } else {
  4748. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  4749. var dat map[string]interface{}
  4750. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4751. fmt.Println(dat)
  4752. } else {
  4753. fmt.Println(err)
  4754. }
  4755. saveLog(result2, src_request, "2205", "撤销明细")
  4756. userJSONBytes, _ := json.Marshal(dat)
  4757. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4758. utils.ErrorLog("解析失败:%v", err)
  4759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4760. return
  4761. }
  4762. }
  4763. if res2.Infcode == 0 {
  4764. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  4765. if err == nil {
  4766. c.ServeSuccessJSON(map[string]interface{}{
  4767. "msg": "退费成功",
  4768. })
  4769. } else {
  4770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4771. return
  4772. }
  4773. } else {
  4774. c.ServeSuccessJSON(map[string]interface{}{
  4775. "code": -10,
  4776. "msg": res2.ErrMsg,
  4777. })
  4778. }
  4779. } else {
  4780. c.ServeSuccessJSON(map[string]interface{}{
  4781. "code": -10,
  4782. "msg": res.ErrMsg,
  4783. })
  4784. }
  4785. }
  4786. }
  4787. func (c *HisApiController) RefundNumber() {
  4788. record_time := c.GetString("record_time")
  4789. //patient_id, _ := c.GetInt64("patient_id")
  4790. admin_user_id, _ := c.GetInt64("admin_user_id")
  4791. his_patient_id, _ := c.GetInt64("id")
  4792. timeLayout := "2006-01-02"
  4793. loc, _ := time.LoadLocation("Local")
  4794. adminUser := c.GetAdminUserInfo()
  4795. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4796. fmt.Println(err)
  4797. if err != nil {
  4798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4799. return
  4800. }
  4801. recordDateTime := theTime.Unix()
  4802. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4803. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  4804. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4805. //order, _ := service.GetHisOrderByID(order_id)
  4806. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4807. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4808. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4809. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  4810. if count > 0 {
  4811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  4812. return
  4813. }
  4814. if config.IsOpen == 1 { //对接了医保,走医保流程
  4815. var res2 ResultSix
  4816. if miConfig.MdtrtareaAdmvs == "421300" {
  4817. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  4818. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  4819. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  4820. resp3, requestErr3 := http.Get(api3)
  4821. if requestErr3 != nil {
  4822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4823. return
  4824. }
  4825. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  4826. if ioErr3 != nil {
  4827. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  4828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4829. return
  4830. }
  4831. var respJSON3 map[string]interface{}
  4832. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  4833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4835. return
  4836. }
  4837. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4838. userJSONBytes3, _ := json.Marshal(respJSON3)
  4839. fmt.Println("log")
  4840. fmt.Println(string(userJSONBytes3))
  4841. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  4842. utils.ErrorLog("解析失败:%v", err)
  4843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4844. return
  4845. }
  4846. } else {
  4847. api3 := "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  4848. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  4849. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  4850. resp3, requestErr3 := http.Get(api3)
  4851. if requestErr3 != nil {
  4852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4853. return
  4854. }
  4855. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  4856. if ioErr3 != nil {
  4857. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  4858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4859. return
  4860. }
  4861. var respJSON3 map[string]interface{}
  4862. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  4863. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4865. return
  4866. }
  4867. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4868. userJSONBytes3, _ := json.Marshal(respJSON3)
  4869. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  4870. utils.ErrorLog("解析失败:%v", err)
  4871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4872. return
  4873. }
  4874. }
  4875. if res2.Infcode == 0 {
  4876. if err == nil {
  4877. c.ServeSuccessJSON(map[string]interface{}{
  4878. "msg": "退号成功",
  4879. })
  4880. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  4881. } else {
  4882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4883. return
  4884. }
  4885. } else {
  4886. c.ServeSuccessJSON(map[string]interface{}{
  4887. "code": -10,
  4888. "msg": res2.ErrMsg,
  4889. })
  4890. }
  4891. } else {
  4892. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  4893. //if err == nil {
  4894. // c.ServeSuccessJSON(map[string]interface{}{
  4895. // "msg": "退费成功",
  4896. // })
  4897. //} else {
  4898. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4899. // return
  4900. //}
  4901. }
  4902. }
  4903. func (c *HisApiController) RefundDetail() {
  4904. order_id, _ := c.GetInt64("order_id")
  4905. //his_patient_id, _ := c.GetInt64("his_patient_id")
  4906. number := c.GetString("number")
  4907. record_time := c.GetString("record_time")
  4908. patient_id, _ := c.GetInt64("patient_id")
  4909. timeLayout := "2006-01-02"
  4910. loc, _ := time.LoadLocation("Local")
  4911. adminUser := c.GetAdminUserInfo()
  4912. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4913. fmt.Println(err)
  4914. if err != nil {
  4915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4916. return
  4917. }
  4918. recordDateTime := theTime.Unix()
  4919. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4920. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4921. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4922. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4923. var order models.HisOrder
  4924. order, _ = service.GetHisOrderByID(order_id)
  4925. if order.ID == 0 {
  4926. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  4927. }
  4928. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4929. if config.IsOpen == 1 { //对接了医保,走医保流程
  4930. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  4931. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  4932. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  4933. resp2, requestErr2 := http.Get(api2)
  4934. if requestErr2 != nil {
  4935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4936. return
  4937. }
  4938. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  4939. if ioErr2 != nil {
  4940. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  4941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4942. return
  4943. }
  4944. var respJSON2 map[string]interface{}
  4945. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  4946. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4948. return
  4949. }
  4950. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  4951. if err == nil {
  4952. c.ServeSuccessJSON(map[string]interface{}{
  4953. "msg": "退费成功",
  4954. })
  4955. } else {
  4956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4957. return
  4958. }
  4959. } else {
  4960. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  4961. if err == nil {
  4962. c.ServeSuccessJSON(map[string]interface{}{
  4963. "msg": "退费成功",
  4964. })
  4965. } else {
  4966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4967. return
  4968. }
  4969. }
  4970. }
  4971. //对账
  4972. func (c *HisApiController) GetCheckAccount() {
  4973. start_time := c.GetString("start_time")
  4974. end_time := c.GetString("end_time")
  4975. insutype := c.GetString("insutype")
  4976. clr_type := c.GetString("clr_type")
  4977. admin_user_id, _ := c.GetInt64("admin_user_id")
  4978. adminUser := c.GetAdminUserInfo()
  4979. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4980. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4981. timeLayout := "2006-01-02"
  4982. loc, _ := time.LoadLocation("Local")
  4983. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  4984. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  4985. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  4986. //orders_two, _ := service.GetOrderByTimeThree(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  4987. fixmedins_setl_cnt := int64(len(orders))
  4988. //
  4989. ////撤销的算2条数据为一笔
  4990. //for _, item := range orders_two {
  4991. // if item.OrderStatus == 3 {
  4992. // fixmedins_setl_cnt = fixmedins_setl_cnt + 1
  4993. // }
  4994. //}
  4995. var medfee_sumamt float64
  4996. var acct_pay float64
  4997. var fund_pay_sumamt float64
  4998. for _, item := range orders {
  4999. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  5000. acct_pay = acct_pay + item.AcctPay
  5001. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  5002. }
  5003. var user_name string
  5004. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5005. if role.ID == 0 {
  5006. user_name = "xxx"
  5007. } else {
  5008. user_name = role.UserName
  5009. }
  5010. if config.IsOpen == 1 {
  5011. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  5012. "insutype=" + insutype +
  5013. "&clr_type=" + clr_type +
  5014. "&setl_optins=" + "定点医保中心" +
  5015. "&stmt_begndate=" + start_time +
  5016. "&stm_enddate=" + end_time +
  5017. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  5018. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  5019. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  5020. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  5021. "&fixmedins_code=" + miConfig.Code +
  5022. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5023. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5024. "&secret_key=" + miConfig.SecretKey +
  5025. "&org_name=" + miConfig.OrgName +
  5026. "&doctor=" + user_name
  5027. fmt.Println(api)
  5028. resp, requestErr := http.Get(api)
  5029. if requestErr != nil {
  5030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5031. return
  5032. }
  5033. body, ioErr := ioutil.ReadAll(resp.Body)
  5034. fmt.Println(body)
  5035. if ioErr != nil {
  5036. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5038. return
  5039. }
  5040. var respJSON map[string]interface{}
  5041. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5042. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5044. return
  5045. }
  5046. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5047. userJSONBytes, _ := json.Marshal(respJSON)
  5048. var res ResultEight
  5049. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5050. utils.ErrorLog("解析失败:%v", err)
  5051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5052. return
  5053. }
  5054. if res.Infcode == 0 {
  5055. if res.Output.Stmtinfo.StmtRslt == "0" {
  5056. micc := &models.MedicalInsuranceCostCompare{
  5057. StartTime: startime.Unix(),
  5058. EndTime: endtime.Unix(),
  5059. Insutype: insutype,
  5060. CheckType: 1,
  5061. Num: fixmedins_setl_cnt,
  5062. Mtime: time.Now().Unix(),
  5063. Status: 1,
  5064. UserOrgId: adminUser.CurrentOrgId,
  5065. CostTotal: medfee_sumamt,
  5066. FuncTotal: fund_pay_sumamt,
  5067. PsnPay: acct_pay,
  5068. Creator: admin_user_id,
  5069. Ctime: time.Now().Unix(),
  5070. }
  5071. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  5072. if err == nil {
  5073. c.ServeSuccessJSON(map[string]interface{}{
  5074. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  5075. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  5076. })
  5077. } else {
  5078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5079. }
  5080. } else {
  5081. c.ServeSuccessJSON(map[string]interface{}{
  5082. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  5083. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  5084. })
  5085. }
  5086. } else {
  5087. c.ServeSuccessJSON(map[string]interface{}{
  5088. "code": -10,
  5089. "msg": res.ErrMsg,
  5090. })
  5091. }
  5092. }
  5093. }
  5094. func (c *HisApiController) Check310() {
  5095. adminUser := c.GetAdminUserInfo()
  5096. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5097. var user_name string
  5098. user_name = "xxx"
  5099. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  5100. "insutype=" + "310" +
  5101. "&clr_type=" + "11" +
  5102. "&setl_optins=" + "定点医保中心" +
  5103. "&stmt_begndate=" + "2021-03-01" +
  5104. "&stm_enddate=" + "2021-03-31" +
  5105. "&medfee_sumamt=" + "11521" +
  5106. "&fund_pay_sumamt=" + "10166.66" +
  5107. "&acct_pay=" + "0" +
  5108. "&fixmedins_setl_cnt=" + "7" +
  5109. "&fixmedins_code=" + miConfig.Code +
  5110. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5111. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5112. "&secret_key=" + miConfig.SecretKey +
  5113. "&org_name=" + miConfig.OrgName +
  5114. "&doctor=" + user_name
  5115. fmt.Println(api)
  5116. resp, requestErr := http.Get(api)
  5117. if requestErr != nil {
  5118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5119. return
  5120. }
  5121. body, ioErr := ioutil.ReadAll(resp.Body)
  5122. fmt.Println(body)
  5123. if ioErr != nil {
  5124. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5126. return
  5127. }
  5128. var respJSON map[string]interface{}
  5129. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5132. return
  5133. }
  5134. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5135. userJSONBytes, _ := json.Marshal(respJSON)
  5136. var res ResultEight
  5137. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5138. utils.ErrorLog("解析失败:%v", err)
  5139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5140. return
  5141. }
  5142. }
  5143. func (c *HisApiController) Check390() {
  5144. adminUser := c.GetAdminUserInfo()
  5145. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5146. var user_name string
  5147. user_name = "张俊杰"
  5148. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  5149. "insutype=" + "390" +
  5150. "&clr_type=" + "11" +
  5151. "&setl_optins=" + "定点医保中心" +
  5152. "&stmt_begndate=" + "2021-03-01" +
  5153. "&stm_enddate=" + "2021-03-31" +
  5154. "&medfee_sumamt=" + "209318.43" +
  5155. "&fund_pay_sumamt=" + "188029.12" +
  5156. "&acct_pay=" + "0" +
  5157. "&fixmedins_setl_cnt=" + "48" +
  5158. "&fixmedins_code=" + miConfig.Code +
  5159. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5160. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5161. "&secret_key=" + miConfig.SecretKey +
  5162. "&org_name=" + miConfig.OrgName +
  5163. "&doctor=" + user_name
  5164. fmt.Println(api)
  5165. resp, requestErr := http.Get(api)
  5166. if requestErr != nil {
  5167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5168. return
  5169. }
  5170. body, ioErr := ioutil.ReadAll(resp.Body)
  5171. fmt.Println(body)
  5172. if ioErr != nil {
  5173. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5175. return
  5176. }
  5177. var respJSON map[string]interface{}
  5178. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5179. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5181. return
  5182. }
  5183. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5184. userJSONBytes, _ := json.Marshal(respJSON)
  5185. var res ResultEight
  5186. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5187. utils.ErrorLog("解析失败:%v", err)
  5188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5189. return
  5190. }
  5191. }
  5192. //对账明细
  5193. func (c *HisApiController) GetCheckDetailAccount() {
  5194. start_time := c.GetString("start_time")
  5195. end_time := c.GetString("end_time")
  5196. admin_user_id, _ := c.GetInt64("admin_user_id")
  5197. adminUser := c.GetAdminUserInfo()
  5198. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5199. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5200. timeLayout := "2006-01-02"
  5201. loc, _ := time.LoadLocation("Local")
  5202. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  5203. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  5204. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  5205. Mkdir(miConfig.OrgName)
  5206. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  5207. file_name := file + ".txt"
  5208. zip_name := file + ".zip"
  5209. zip_path := miConfig.OrgName + "/" + zip_name
  5210. file_path := miConfig.OrgName + "/" + file_name
  5211. decimal.DivisionPrecision = 2
  5212. var medfee_sumamt float64
  5213. var psn_cash_pay float64
  5214. var fund_pay_sumamt float64
  5215. fixmedins_setl_cnt := int64(len(orders))
  5216. for _, item := range orders {
  5217. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  5218. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  5219. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  5220. }
  5221. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  5222. defer f.Close()
  5223. if err != nil {
  5224. fmt.Println(err.Error())
  5225. } else {
  5226. for _, item := range orders {
  5227. var refd_setl_flag string
  5228. if item.OrderStatus == 2 {
  5229. refd_setl_flag = "0"
  5230. var str string
  5231. str = item.SetlId + " " +
  5232. item.MdtrtId + " " +
  5233. item.PsnNo + " " +
  5234. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  5235. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  5236. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  5237. _, err = f.Write([]byte(str))
  5238. }
  5239. if item.OrderStatus == 3 {
  5240. var str string
  5241. str = item.SetlId + " " +
  5242. item.MdtrtId + " " +
  5243. item.PsnNo + " " +
  5244. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  5245. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  5246. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  5247. _, err = f.Write([]byte(str))
  5248. var str2 string
  5249. str2 = item.SetlId + " " +
  5250. item.MdtrtId + " " +
  5251. item.PsnNo + " " +
  5252. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  5253. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  5254. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  5255. _, err = f.Write([]byte(str2))
  5256. }
  5257. }
  5258. }
  5259. Zip(file_path, zip_path)
  5260. fmt.Println(ReadFile(zip_path))
  5261. fmt.Println(string(ReadFile(zip_path)))
  5262. if config.IsOpen == 1 {
  5263. var user_name string
  5264. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5265. if role.ID == 0 {
  5266. user_name = "管理员"
  5267. } else {
  5268. user_name = role.UserName
  5269. }
  5270. baseParams := models.BaseParams{
  5271. SecretKey: miConfig.SecretKey,
  5272. FixmedinsCode: miConfig.Code,
  5273. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  5274. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  5275. OrgName: miConfig.OrgName,
  5276. Doctor: user_name,
  5277. }
  5278. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  5279. var dat map[string]interface{}
  5280. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5281. fmt.Println(dat)
  5282. } else {
  5283. fmt.Println(err)
  5284. }
  5285. userJSONBytes, _ := json.Marshal(dat)
  5286. var res ResultNine
  5287. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5288. utils.ErrorLog("解析失败:%v", err)
  5289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5290. return
  5291. }
  5292. if res.Infcode == 0 {
  5293. fileNo := res.Output.FileQuryNo
  5294. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  5295. "file_qury_no=" + fileNo +
  5296. "&setl_optins=" + "定点医保中心" +
  5297. "&stmt_begndate=" + start_time +
  5298. "&stm_enddate=" + end_time +
  5299. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  5300. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  5301. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  5302. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  5303. "&fixmedins_code=" + miConfig.Code +
  5304. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5305. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5306. "&secret_key=" + miConfig.SecretKey +
  5307. "&org_name=" + miConfig.OrgName +
  5308. "&doctor=" + user_name
  5309. resp, requestErr := http.Get(api)
  5310. if requestErr != nil {
  5311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5312. return
  5313. }
  5314. body, ioErr := ioutil.ReadAll(resp.Body)
  5315. if ioErr != nil {
  5316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5318. return
  5319. }
  5320. var respJSON map[string]interface{}
  5321. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5324. return
  5325. }
  5326. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5327. userJSONBytes, _ := json.Marshal(respJSON)
  5328. var res ResultTen
  5329. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5330. utils.ErrorLog("解析失败:%v", err)
  5331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5332. return
  5333. }
  5334. if res.Infcode == 0 {
  5335. service.Gdyb9102(baseParams, zip_name, fileNo)
  5336. micc := &models.MedicalInsuranceCostCompare{
  5337. StartTime: startime.Unix(),
  5338. EndTime: endtime.Unix(),
  5339. Insutype: "0",
  5340. CheckType: 2,
  5341. Num: fixmedins_setl_cnt,
  5342. Mtime: time.Now().Unix(),
  5343. Status: 1,
  5344. UserOrgId: adminUser.CurrentOrgId,
  5345. CostTotal: medfee_sumamt,
  5346. FuncTotal: fund_pay_sumamt,
  5347. PsnPay: psn_cash_pay,
  5348. Creator: admin_user_id,
  5349. Ctime: time.Now().Unix(),
  5350. }
  5351. service.CreateMedicalInsuranceCostCompareRecord(micc)
  5352. c.ServeSuccessJSON(map[string]interface{}{
  5353. "msg": "明细对账成功",
  5354. })
  5355. }
  5356. } else {
  5357. }
  5358. }
  5359. }
  5360. type CustomOrderInfo struct {
  5361. Name string
  5362. Spec string
  5363. Unit string
  5364. Count float64
  5365. Price float64
  5366. Total float64
  5367. }
  5368. func (c *HisApiController) GetSettleAccounts() {
  5369. //id, _ := c.GetInt64("id")
  5370. //record_time := c.GetString("record_time")
  5371. order_id, _ := c.GetInt64("order_id")
  5372. admin_user_id, _ := c.GetInt64("admin_user_id")
  5373. //timeLayout := "2006-01-02"
  5374. //loc, _ := time.LoadLocation("Local")
  5375. //
  5376. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5377. //if err != nil {
  5378. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5379. // return
  5380. //}
  5381. //recordDateTime := theTime.Unix()
  5382. adminUser := c.GetAdminUserInfo()
  5383. order, _ := service.GetHisOrderByID(order_id)
  5384. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5385. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  5386. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  5387. orderInfos = append(orderInfos, orderInfos_two...)
  5388. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  5389. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5390. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  5391. //var config []*models.HisXtDiagnoseConfig
  5392. var name string
  5393. for _, item := range diagnosis_ids {
  5394. id, _ := strconv.ParseInt(item, 10, 64)
  5395. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5396. if len(name) == 0 {
  5397. name = diagnosisConfig.ClassName
  5398. } else {
  5399. name = name + "," + diagnosisConfig.ClassName
  5400. }
  5401. }
  5402. var bedCostTotal float64 = 0 //床位总费
  5403. var bedCostSelfTotal float64 = 0 //床位自费
  5404. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  5405. var operationCostTotal float64 = 0 //手术费
  5406. var operationCostSelfTotal float64 = 0 //手术费
  5407. var operationCostPartSelfTotal float64 = 0 //手术费
  5408. var otherCostTotal float64 = 0 //其他费用
  5409. var otherCostSelfTotal float64 = 0 //其他费用
  5410. var otherCostPartSelfTotal float64 = 0 //其他费用
  5411. var materialCostTotal float64 = 0 //材料费
  5412. var materialCostSelfTotal float64 = 0 //材料费
  5413. var materialCostPartSelfTotal float64 = 0 //材料费
  5414. var westernMedicineCostTotal float64 = 0 //西药费
  5415. var westernMedicineCostSelfTotal float64 = 0 //西药费
  5416. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  5417. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  5418. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  5419. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  5420. var checkCostTotal float64 = 0 //检查费
  5421. var checkCostSelfTotal float64 = 0 //检查费
  5422. var checkCostPartSelfTotal float64 = 0 //检查费
  5423. var laboratoryCostTotal float64 = 0 //化验费
  5424. var laboratoryCostSelfTotal float64 = 0 //化验费
  5425. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  5426. var treatCostTotal float64 = 0 //治疗费用
  5427. var treatCostSelfTotal float64 = 0 //治疗费用
  5428. var treatCostPartSelfTotal float64 = 0 //治疗费用
  5429. decimal.DivisionPrecision = 2
  5430. for _, item := range orderInfos {
  5431. if item.MedChrgitmType == "01" { //床位费
  5432. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5433. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5434. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5435. }
  5436. if item.MedChrgitmType == "03" { //检查费
  5437. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5438. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5439. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5440. }
  5441. if item.MedChrgitmType == "04" { //化验费
  5442. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5443. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5444. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5445. }
  5446. if item.MedChrgitmType == "05" { //治疗费
  5447. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5448. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5449. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5450. }
  5451. if item.MedChrgitmType == "06" { //手术费
  5452. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5453. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5454. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5455. }
  5456. if item.MedChrgitmType == "08" { //材料费
  5457. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5458. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5459. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5460. }
  5461. if item.MedChrgitmType == "09" { //西药费
  5462. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5463. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5464. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5465. }
  5466. if item.MedChrgitmType == "11" { //中成费
  5467. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5468. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5469. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5470. }
  5471. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  5472. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5473. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5474. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5475. }
  5476. }
  5477. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5478. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5479. var user_name string
  5480. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5481. if role.ID == 0 {
  5482. user_name = "管理员"
  5483. } else {
  5484. user_name = role.UserName
  5485. }
  5486. baseParams := models.BaseParams{
  5487. SecretKey: miConfig.SecretKey,
  5488. FixmedinsCode: miConfig.Code,
  5489. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  5490. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  5491. OrgName: miConfig.OrgName,
  5492. Doctor: user_name,
  5493. }
  5494. businessParams := models.BusinessParams{
  5495. PsnNo: order.PsnNo,
  5496. MdtrtId: order.MdtrtId,
  5497. SetlId: order.SetlId,
  5498. }
  5499. var res ResultEleven
  5500. if config.IsOpen == 1 {
  5501. if miConfig.MdtrtareaAdmvs == "421300" {
  5502. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  5503. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  5504. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5505. resp, requestErr := http.Get(api)
  5506. if requestErr != nil {
  5507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5508. return
  5509. }
  5510. body, ioErr := ioutil.ReadAll(resp.Body)
  5511. if ioErr != nil {
  5512. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5514. return
  5515. }
  5516. var respJSON map[string]interface{}
  5517. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5518. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5520. return
  5521. }
  5522. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5523. result, _ := json.Marshal(respJSON)
  5524. fmt.Println("log")
  5525. fmt.Println(string(result))
  5526. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5527. utils.ErrorLog("解析失败:%v", err)
  5528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5529. return
  5530. }
  5531. } else {
  5532. result := service.Gdyb5203(baseParams, businessParams)
  5533. var dat map[string]interface{}
  5534. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5535. fmt.Println(dat)
  5536. } else {
  5537. fmt.Println(err)
  5538. }
  5539. userJSONBytes, _ := json.Marshal(dat)
  5540. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5541. utils.ErrorLog("解析失败:%v", err)
  5542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5543. return
  5544. }
  5545. }
  5546. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5547. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  5548. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  5549. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5550. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5551. var doctor_name string
  5552. if roles.ID == 0 {
  5553. doctor_name = "管理员"
  5554. } else {
  5555. doctor_name = roles.UserName
  5556. }
  5557. yiliao_leibie := ""
  5558. switch order.MedType {
  5559. case "11":
  5560. yiliao_leibie = "普通门诊"
  5561. break
  5562. case "12":
  5563. yiliao_leibie = "门诊挂号"
  5564. break
  5565. case "13":
  5566. yiliao_leibie = "急诊"
  5567. break
  5568. case "14":
  5569. yiliao_leibie = "门诊特殊病"
  5570. break
  5571. case "15":
  5572. yiliao_leibie = "门诊统筹"
  5573. break
  5574. case "16":
  5575. yiliao_leibie = "门诊慢性病"
  5576. break
  5577. case "21":
  5578. yiliao_leibie = "普通住院"
  5579. break
  5580. }
  5581. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5582. if res.Infcode == 0 {
  5583. c.ServeSuccessJSON(map[string]interface{}{
  5584. "diagnosis": name,
  5585. "order_infos": orderInfos,
  5586. "number": order.MdtrtId,
  5587. "date": order.SettleAccountsDate,
  5588. "charge_admin": charge_admin,
  5589. "printor_admin": printor_admin,
  5590. "info": res.Output.Setlinfo,
  5591. "bedCostTotal": bedCostTotal,
  5592. "bedCostSelfTotal": bedCostSelfTotal,
  5593. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  5594. "operationCostTotal": operationCostTotal,
  5595. "operationCostSelfTotal": operationCostSelfTotal,
  5596. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  5597. "otherCostTotal": otherCostTotal,
  5598. "otherCostSelfTotal": otherCostSelfTotal,
  5599. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  5600. "materialCostTotal": materialCostTotal,
  5601. "materialCostSelfTotal": materialCostSelfTotal,
  5602. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  5603. "westernMedicineCostTotal": westernMedicineCostTotal,
  5604. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  5605. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  5606. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  5607. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  5608. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  5609. "checkCostTotal": checkCostTotal,
  5610. "checkCostSelfTotal": checkCostSelfTotal,
  5611. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  5612. "laboratoryCostTotal": laboratoryCostTotal,
  5613. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  5614. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  5615. "treatCostTotal": treatCostTotal,
  5616. "treatCostSelfTotal": treatCostSelfTotal,
  5617. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  5618. "doctor_code": adminRole_two.DoctorCode,
  5619. "doctor_name": doctor_name,
  5620. "health_card_no": order.PsnNo,
  5621. "department": departments.Name,
  5622. "yiliao_leibie": yiliao_leibie,
  5623. "after_money": order.AccountPrice,
  5624. "patient": patient,
  5625. "org_name": miConfig.OrgName,
  5626. "org_code": miConfig.Code,
  5627. "order_number": order.Number,
  5628. //"check_order_info": cus_slice,
  5629. })
  5630. }
  5631. }
  5632. }
  5633. func (c *HisApiController) CheckTreatment() {
  5634. patient_id, _ := c.GetInt64("patient_id", 0)
  5635. record_time := c.GetString("record_time")
  5636. insutype := c.GetString("insutype")
  5637. timeLayout := "2006-01-02"
  5638. loc, _ := time.LoadLocation("Local")
  5639. adminUser := c.GetAdminUserInfo()
  5640. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5641. fmt.Println(err)
  5642. if err != nil {
  5643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5644. return
  5645. }
  5646. recordDateTime := theTime.Unix()
  5647. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5648. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5649. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5650. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5651. var user_name string
  5652. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  5653. if role.ID == 0 {
  5654. user_name = "xxx"
  5655. } else {
  5656. user_name = role.UserName
  5657. }
  5658. baseParams := models.BaseParams{
  5659. SecretKey: miConfig.SecretKey,
  5660. FixmedinsCode: miConfig.Code,
  5661. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  5662. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  5663. OrgName: miConfig.OrgName,
  5664. Doctor: user_name,
  5665. }
  5666. if config.IsOpen == 1 {
  5667. result := service.Gdyb2001(baseParams, his.PsnNo, insutype, strconv.FormatInt(patientPrescription.RegisterType, 10))
  5668. var dat map[string]interface{}
  5669. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5670. fmt.Println(dat)
  5671. } else {
  5672. fmt.Println(err)
  5673. }
  5674. }
  5675. }
  5676. func (c *HisApiController) PutRecord() {
  5677. id, _ := c.GetInt64("id")
  5678. record_time := c.GetString("record_time")
  5679. timeLayout := "2006-01-02"
  5680. loc, _ := time.LoadLocation("Local")
  5681. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5682. if err != nil {
  5683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5684. return
  5685. }
  5686. recordDateTime := theTime.Unix()
  5687. adminInfo := c.GetAdminUserInfo()
  5688. patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  5689. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  5690. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  5691. fmt.Println(miConfig.SecretKey)
  5692. if patient == nil {
  5693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  5694. return
  5695. }
  5696. if len(patient.IdCardNo) == 0 {
  5697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  5698. return
  5699. }
  5700. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  5701. if config.IsOpen == 1 {
  5702. api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + patient.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5703. resp, requestErr := http.Get(api)
  5704. if requestErr != nil {
  5705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5706. return
  5707. }
  5708. defer resp.Body.Close()
  5709. body, ioErr := ioutil.ReadAll(resp.Body)
  5710. if ioErr != nil {
  5711. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5713. return
  5714. }
  5715. var respJSON map[string]interface{}
  5716. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5717. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5719. return
  5720. }
  5721. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5722. userJSONBytes, _ := json.Marshal(userJSON)
  5723. var res ResultTwo
  5724. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5725. utils.ErrorLog("解析失败:%v", err)
  5726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5727. return
  5728. }
  5729. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5730. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5731. infoStr := string(Iinfos)
  5732. idetinfoStr := string(Idetinfos)
  5733. if res.Infcode == 0 {
  5734. his := models.VMHisPatient{
  5735. Status: 1,
  5736. Ctime: time.Now().Unix(),
  5737. Mtime: time.Now().Unix(),
  5738. PsnNo: res.Output.Baseinfo.PsnNo,
  5739. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5740. Certno: res.Output.Baseinfo.Certno,
  5741. PsnName: res.Output.Baseinfo.PsnName,
  5742. Gend: res.Output.Baseinfo.Gend,
  5743. Naty: res.Output.Baseinfo.Naty,
  5744. Brdy: res.Output.Baseinfo.Brdy,
  5745. Age: res.Output.Baseinfo.Age,
  5746. Iinfo: infoStr,
  5747. Idetinfo: idetinfoStr,
  5748. PatientId: patient.ID,
  5749. RecordDate: theTime.Unix(),
  5750. UserOrgId: adminInfo.CurrentOrgId,
  5751. AdminUserId: adminInfo.AdminUser.Id,
  5752. IsReturn: 1,
  5753. }
  5754. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  5755. result := service.Gdyb2503(his.PsnNo, res.Output.Iinfo[0].Insutype, miConfig.OrgName, patientPrescription.Doctor, miConfig.Code, doctor_id, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "重症尿毒症透析(血透)", "M07801")
  5756. result2 := service.Gdyb5301(his.PsnNo, res.Output.Iinfo[0].Insutype, miConfig.OrgName, patientPrescription.Doctor, miConfig.Code, doctor_id, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "重症尿毒症透析(血透)", "M07801")
  5757. var dat map[string]interface{}
  5758. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5759. fmt.Println(dat)
  5760. } else {
  5761. fmt.Println(err)
  5762. }
  5763. var dat2 map[string]interface{}
  5764. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  5765. fmt.Println(dat2)
  5766. } else {
  5767. fmt.Println(err)
  5768. }
  5769. } else {
  5770. adminUser := c.GetAdminUserInfo()
  5771. errlog := &models.HisOrderError{
  5772. UserOrgId: adminUser.CurrentOrgId,
  5773. Ctime: time.Now().Unix(),
  5774. Mtime: time.Now().Unix(),
  5775. ErrMsg: res.ErrMsg,
  5776. Status: 1,
  5777. PatientId: id,
  5778. RecordTime: recordDateTime,
  5779. Stage: 1,
  5780. }
  5781. service.CreateErrMsgLog(errlog)
  5782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  5783. return
  5784. }
  5785. }
  5786. }
  5787. func (c *HisApiController) GetUploadDiag() {
  5788. id, _ := c.GetInt64("id")
  5789. record_time := c.GetString("record_time")
  5790. diagnosis_id, _ := c.GetInt64("diagnosis")
  5791. sick_type, _ := c.GetInt64("sick_type")
  5792. reg_type, _ := c.GetInt64("reg_type")
  5793. timeLayout := "2006-01-02"
  5794. loc, _ := time.LoadLocation("Local")
  5795. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5796. if err != nil {
  5797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5798. return
  5799. }
  5800. var patientPrescription models.HisPrescriptionInfo
  5801. recordDateTime := theTime.Unix()
  5802. adminInfo := c.GetAdminUserInfo()
  5803. patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  5804. if patientPrescription.ID == 0 {
  5805. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  5806. }
  5807. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  5808. diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  5809. his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  5810. sickConfig, _ := service.FindSickById(sick_type)
  5811. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5812. api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  5813. "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  5814. "&diag=" + diagnosisConfig.ClassName + "&org_name=" + miConfig.OrgName + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&doctor_id=" + strconv.FormatInt(patientPrescription.DoctorId, 10) + "&fixmedins_code=" + miConfig.Code + "&diag_code=" + diagnosisConfig.CountryCode +
  5815. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  5816. resp2, requestErr2 := http.Get(api2)
  5817. if requestErr2 != nil {
  5818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5819. return
  5820. }
  5821. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  5822. if ioErr2 != nil {
  5823. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  5824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5825. return
  5826. }
  5827. var respJSON2 map[string]interface{}
  5828. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  5829. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5831. return
  5832. }
  5833. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5834. userJSONBytes2, _ := json.Marshal(respJSON2)
  5835. var res2 ResultSix
  5836. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5837. utils.ErrorLog("解析失败:%v", err)
  5838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5839. return
  5840. }
  5841. if res2.Infcode != 0 {
  5842. adminUser := c.GetAdminUserInfo()
  5843. errlog := &models.HisOrderError{
  5844. UserOrgId: adminUser.CurrentOrgId,
  5845. Ctime: time.Now().Unix(),
  5846. Mtime: time.Now().Unix(),
  5847. ErrMsg: res2.ErrMsg,
  5848. Status: 1,
  5849. PatientId: id,
  5850. RecordTime: recordDateTime,
  5851. Stage: 3,
  5852. }
  5853. service.CreateErrMsgLog(errlog)
  5854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  5855. return
  5856. }
  5857. c.ServeSuccessJSON(map[string]interface{}{
  5858. "msg": "上传成功",
  5859. })
  5860. }
  5861. type QueryResult struct {
  5862. ID int64
  5863. Name string
  5864. Code string
  5865. List_type_code string
  5866. }
  5867. func (c *HisApiController) GetCheckCode() {
  5868. ids_str := c.GetString("ids")
  5869. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  5870. ids_arr := strings.Split(ids_str, ",")
  5871. var queryResult []QueryResult
  5872. ids := make([]int64, 0)
  5873. for _, item := range ids_arr {
  5874. id, _ := strconv.ParseInt(item, 10, 64)
  5875. ids = append(ids, id)
  5876. }
  5877. if record_type == 1 {
  5878. drugs, _ := service.GetBatchDrugList(ids)
  5879. for _, item := range drugs {
  5880. result := QueryResult{
  5881. ID: item.ID,
  5882. Name: item.DrugName,
  5883. Code: item.MedicalInsuranceNumber,
  5884. List_type_code: "101",
  5885. }
  5886. queryResult = append(queryResult, result)
  5887. }
  5888. } else if record_type == 2 {
  5889. goods, _ := service.GetBatchGoodInformationList(ids)
  5890. for _, item := range goods {
  5891. result := QueryResult{
  5892. ID: item.ID,
  5893. Name: item.GoodName,
  5894. Code: item.MedicalInsuranceNumber,
  5895. List_type_code: "301",
  5896. }
  5897. queryResult = append(queryResult, result)
  5898. }
  5899. } else if record_type == 3 {
  5900. projects, _ := service.GetBathchMyPorjecgList(ids)
  5901. for _, item := range projects {
  5902. result := QueryResult{
  5903. ID: item.ID,
  5904. Name: item.ProjectName,
  5905. Code: item.MedicalCode,
  5906. List_type_code: "201",
  5907. }
  5908. queryResult = append(queryResult, result)
  5909. }
  5910. }
  5911. admin_user_id, _ := c.GetInt64("admin_user_id")
  5912. adminUser := c.GetAdminUserInfo()
  5913. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5914. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5915. var user_name string
  5916. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5917. if role.ID == 0 {
  5918. user_name = "xxx"
  5919. } else {
  5920. user_name = role.UserName
  5921. }
  5922. baseParams := &models.BaseParams{
  5923. SecretKey: miConfig.SecretKey,
  5924. FixmedinsCode: miConfig.Code,
  5925. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  5926. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  5927. OrgName: miConfig.OrgName,
  5928. Doctor: user_name,
  5929. }
  5930. if config.IsOpen == 1 {
  5931. for _, item := range queryResult {
  5932. var result string
  5933. if record_type == 1 {
  5934. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  5935. } else if record_type == 2 {
  5936. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  5937. } else if record_type == 3 {
  5938. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  5939. }
  5940. var dat map[string]interface{}
  5941. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5942. fmt.Println(dat)
  5943. } else {
  5944. fmt.Println(err)
  5945. }
  5946. userJSONBytes, _ := json.Marshal(dat)
  5947. var res ResultSix
  5948. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5949. utils.ErrorLog("解析失败:%v", err)
  5950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5951. return
  5952. }
  5953. if res.Infcode == 0 {
  5954. if record_type == 1 {
  5955. service.UpdateBaseDrugById(item.ID)
  5956. } else if record_type == 2 {
  5957. service.UpdateGoodInformaitonByDetail(item.ID)
  5958. } else if record_type == 3 {
  5959. service.UpdateProjectById(item.ID)
  5960. }
  5961. c.ServeSuccessJSON(map[string]interface{}{
  5962. "failed_code": 0,
  5963. "msg": "目录对照成功",
  5964. })
  5965. } else {
  5966. c.ServeSuccessJSON(map[string]interface{}{
  5967. "failed_code": -10,
  5968. "msg": res.ErrMsg,
  5969. })
  5970. }
  5971. }
  5972. }
  5973. }
  5974. func (c *HisApiController) UnCheckCode() {
  5975. ids_str := c.GetString("ids")
  5976. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  5977. admin_user_id, _ := c.GetInt64("admin_user_id")
  5978. ids_arr := strings.Split(ids_str, ",")
  5979. var queryResult []QueryResult
  5980. ids := make([]int64, 0)
  5981. for _, item := range ids_arr {
  5982. id, _ := strconv.ParseInt(item, 10, 64)
  5983. ids = append(ids, id)
  5984. }
  5985. if record_type == 1 {
  5986. drugs, _ := service.GetBatchDrugList(ids)
  5987. for _, item := range drugs {
  5988. result := QueryResult{
  5989. ID: item.ID,
  5990. Name: item.DrugName,
  5991. Code: item.MedicalInsuranceNumber,
  5992. List_type_code: "101",
  5993. }
  5994. queryResult = append(queryResult, result)
  5995. }
  5996. } else if record_type == 2 {
  5997. goods, _ := service.GetBatchGoodInformationList(ids)
  5998. for _, item := range goods {
  5999. result := QueryResult{
  6000. ID: item.ID,
  6001. Name: item.GoodName,
  6002. Code: item.MedicalInsuranceNumber,
  6003. List_type_code: "301",
  6004. }
  6005. queryResult = append(queryResult, result)
  6006. }
  6007. } else if record_type == 3 {
  6008. projects, _ := service.GetBathchMyPorjecgList(ids)
  6009. for _, item := range projects {
  6010. result := QueryResult{
  6011. ID: item.ID,
  6012. Name: item.ProjectName,
  6013. Code: item.MedicalCode,
  6014. List_type_code: "201",
  6015. }
  6016. queryResult = append(queryResult, result)
  6017. }
  6018. }
  6019. adminUser := c.GetAdminUserInfo()
  6020. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6021. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6022. var user_name string
  6023. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6024. if role.ID == 0 {
  6025. user_name = "xxx"
  6026. } else {
  6027. user_name = role.UserName
  6028. }
  6029. baseParams := &models.BaseParams{
  6030. SecretKey: miConfig.SecretKey,
  6031. FixmedinsCode: miConfig.Code,
  6032. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6033. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6034. OrgName: miConfig.OrgName,
  6035. Doctor: user_name,
  6036. }
  6037. if config.IsOpen == 1 {
  6038. for _, item := range queryResult {
  6039. var result string
  6040. if record_type == 1 {
  6041. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  6042. } else if record_type == 2 {
  6043. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  6044. } else if record_type == 3 {
  6045. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  6046. }
  6047. var dat2 map[string]interface{}
  6048. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  6049. fmt.Println(dat2)
  6050. } else {
  6051. fmt.Println(err)
  6052. }
  6053. userJSONBytes, _ := json.Marshal(dat2)
  6054. var res ResultSix
  6055. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6056. utils.ErrorLog("解析失败:%v", err)
  6057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6058. return
  6059. }
  6060. if res.Infcode == 0 {
  6061. if record_type == 1 {
  6062. service.UpdateDrugByIdDetail(item.ID)
  6063. } else if record_type == 2 {
  6064. service.UpdateGoodInfoById(item.ID)
  6065. } else if record_type == 3 {
  6066. service.UpdateMyProjectById(item.ID)
  6067. }
  6068. c.ServeSuccessJSON(map[string]interface{}{
  6069. "failed_code": 0,
  6070. "msg": "撤销目录对照成功",
  6071. })
  6072. } else {
  6073. c.ServeSuccessJSON(map[string]interface{}{
  6074. "failed_code": -10,
  6075. "msg": res.ErrMsg,
  6076. })
  6077. }
  6078. }
  6079. }
  6080. }
  6081. func (c *HisApiController) GetPatientInfo() {
  6082. id_card_no := c.GetString("id_card_no")
  6083. admin_user_id, _ := c.GetInt64("admin_user_id")
  6084. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  6085. if patient.ID == 0 {
  6086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  6087. return
  6088. }
  6089. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6090. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6091. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  6092. if config.IsOpen == 1 {
  6093. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  6094. var dat map[string]interface{}
  6095. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6096. fmt.Println(dat)
  6097. } else {
  6098. fmt.Println(err)
  6099. }
  6100. userJSONBytes, _ := json.Marshal(dat)
  6101. var res ResultTwo
  6102. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6103. utils.ErrorLog("解析失败:%v", err)
  6104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6105. return
  6106. }
  6107. if res.Infcode != 0 {
  6108. c.ServeSuccessJSON(map[string]interface{}{
  6109. "failed_code": -10,
  6110. "msg": res.ErrMsg,
  6111. })
  6112. } else {
  6113. c.ServeSuccessJSON(map[string]interface{}{
  6114. "failed_code": 0,
  6115. "info": res,
  6116. })
  6117. }
  6118. }
  6119. }
  6120. func (c *HisApiController) PsnPutOnRecord() {
  6121. record_type, _ := c.GetInt64("type")
  6122. patient_id, _ := c.GetInt64("patient_id")
  6123. admin_user_id, _ := c.GetInt64("admin_user_id")
  6124. start_time := c.GetString("start_time")
  6125. end_time := c.GetString("end_time")
  6126. adminUser := c.GetAdminUserInfo()
  6127. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6128. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6129. var patients []*models.Patients
  6130. if record_type == 1 { //全部备案
  6131. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  6132. patients = append(patients, patient...)
  6133. } else { //单个备案
  6134. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  6135. patients = append(patients, patient)
  6136. }
  6137. var user_name string
  6138. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6139. if role.ID == 0 {
  6140. user_name = "xxx"
  6141. } else {
  6142. user_name = role.UserName
  6143. }
  6144. if config.IsOpen == 1 {
  6145. for _, item := range patients {
  6146. api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + item.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + user_name + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6147. resp, requestErr := http.Get(api)
  6148. if requestErr != nil {
  6149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6150. return
  6151. }
  6152. defer resp.Body.Close()
  6153. body, ioErr := ioutil.ReadAll(resp.Body)
  6154. if ioErr != nil {
  6155. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6157. return
  6158. }
  6159. var respJSON map[string]interface{}
  6160. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6161. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6163. return
  6164. }
  6165. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6166. userJSONBytes, _ := json.Marshal(userJSON)
  6167. var res ResultTwo
  6168. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6169. utils.ErrorLog("解析失败:%v", err)
  6170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6171. return
  6172. }
  6173. if res.Infcode == 0 {
  6174. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  6175. var dat map[string]interface{}
  6176. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6177. fmt.Println(dat)
  6178. } else {
  6179. fmt.Println(err)
  6180. }
  6181. userJSONBytes, _ := json.Marshal(dat)
  6182. var res2 ResultThirteen
  6183. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6184. utils.ErrorLog("解析失败:%v", err)
  6185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6186. return
  6187. }
  6188. if res2.Infcode == 0 {
  6189. psnResult := &models.GdybPsnRecord{
  6190. UserOrgId: adminUser.CurrentOrgId,
  6191. PatientId: item.ID,
  6192. PsnNo: res.Output.Baseinfo.PsnNo,
  6193. Ctime: time.Now().Unix(),
  6194. Mtime: time.Now().Unix(),
  6195. Status: 1,
  6196. IsCancel: 1,
  6197. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  6198. }
  6199. service.CreatePsnRecord(psnResult)
  6200. } else {
  6201. c.ServeSuccessJSON(map[string]interface{}{
  6202. "failed_code": -10,
  6203. "msg": res2.ErrMsg,
  6204. })
  6205. return
  6206. }
  6207. }
  6208. }
  6209. }
  6210. }
  6211. func (c *HisApiController) PsnUnPutOnRecord() {
  6212. id, _ := c.GetInt64("id")
  6213. //record_type, _ := c.GetInt64("type")
  6214. admin_user_id, _ := c.GetInt64("admin_user_id")
  6215. adminUser := c.GetAdminUserInfo()
  6216. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6217. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6218. var user_name string
  6219. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6220. if role.ID == 0 {
  6221. user_name = "xxx"
  6222. } else {
  6223. user_name = role.UserName
  6224. }
  6225. psn_record, _ := service.GetPsnRecordById(id)
  6226. if psn_record.ID == 0 {
  6227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  6228. return
  6229. }
  6230. if config.IsOpen == 1 {
  6231. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  6232. var dat map[string]interface{}
  6233. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6234. fmt.Println(dat)
  6235. } else {
  6236. fmt.Println(err)
  6237. }
  6238. userJSONBytes, _ := json.Marshal(dat)
  6239. var res ResultFourteen
  6240. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6241. utils.ErrorLog("解析失败:%v", err)
  6242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6243. return
  6244. }
  6245. if res.Infcode == 0 {
  6246. psn_record.IsCancel = 2
  6247. service.CreatePsnRecord(&psn_record)
  6248. } else {
  6249. c.ServeSuccessJSON(map[string]interface{}{
  6250. "failed_code": -10,
  6251. "msg": res.ErrMsg,
  6252. })
  6253. return
  6254. }
  6255. }
  6256. }
  6257. func (c *HisApiController) PsnPutNCDSOnRecord() {
  6258. patient_id, _ := c.GetInt64("patient_id")
  6259. insutype := c.GetString("insutype")
  6260. psn_no := c.GetString("psn_no")
  6261. doctor_id, _ := c.GetInt64("doctor_id")
  6262. sick_id, _ := c.GetInt64("sick_id")
  6263. department_id, _ := c.GetInt64("department_id")
  6264. adminUser := c.GetAdminUserInfo()
  6265. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  6266. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6267. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6268. sick, _ := service.FindSickById(sick_id)
  6269. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  6270. if config.IsOpen == 1 {
  6271. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode)
  6272. var dat map[string]interface{}
  6273. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6274. fmt.Println(dat)
  6275. } else {
  6276. fmt.Println(err)
  6277. }
  6278. userJSONBytes, _ := json.Marshal(dat)
  6279. var res2 ResultThirteen
  6280. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6281. utils.ErrorLog("解析失败:%v", err)
  6282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6283. return
  6284. }
  6285. if res2.Infcode == 0 {
  6286. psnResult := &models.GdybPsnNcdsRecord{
  6287. UserOrgId: adminUser.CurrentOrgId,
  6288. PatientId: patient.ID,
  6289. PsnNo: psn_no,
  6290. DoctorId: doctor.AdminUserId,
  6291. DepartmentId: department_id,
  6292. SickType: sick_id,
  6293. Insutype: insutype,
  6294. Ctime: time.Now().Unix(),
  6295. Mtime: time.Now().Unix(),
  6296. Status: 1,
  6297. IsCancel: 1,
  6298. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  6299. }
  6300. service.CreatePsnNCDSRecord(psnResult)
  6301. c.ServeSuccessJSON(map[string]interface{}{
  6302. "failed_code": 0,
  6303. "msg": "备案成功",
  6304. "result": psnResult,
  6305. })
  6306. } else {
  6307. c.ServeSuccessJSON(map[string]interface{}{
  6308. "failed_code": -10,
  6309. "msg": res2.ErrMsg,
  6310. })
  6311. return
  6312. }
  6313. }
  6314. }
  6315. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  6316. id, _ := c.GetInt64("id")
  6317. admin_user_id, _ := c.GetInt64("admin_user_id")
  6318. adminUser := c.GetAdminUserInfo()
  6319. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6320. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6321. var user_name string
  6322. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6323. if role.ID == 0 {
  6324. user_name = "xxx"
  6325. } else {
  6326. user_name = role.UserName
  6327. }
  6328. psn_record, _ := service.GetPsnNCDSRecordById(id)
  6329. if psn_record.ID == 0 {
  6330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  6331. return
  6332. }
  6333. if config.IsOpen == 1 {
  6334. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, user_name, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  6335. var dat map[string]interface{}
  6336. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6337. fmt.Println(dat)
  6338. } else {
  6339. fmt.Println(err)
  6340. }
  6341. userJSONBytes, _ := json.Marshal(dat)
  6342. var res ResultFourteen
  6343. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6344. utils.ErrorLog("解析失败:%v", err)
  6345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6346. return
  6347. }
  6348. if res.Infcode == 0 {
  6349. psn_record.IsCancel = 2
  6350. service.CreatePsnNCDSRecord(&psn_record)
  6351. c.ServeSuccessJSON(map[string]interface{}{
  6352. "failed_code": 0,
  6353. "msg": "撤销备案成功",
  6354. })
  6355. } else {
  6356. c.ServeSuccessJSON(map[string]interface{}{
  6357. "failed_code": -10,
  6358. "msg": res.ErrMsg,
  6359. })
  6360. return
  6361. }
  6362. }
  6363. }
  6364. func (c *HisApiController) TestTest() {
  6365. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  6366. fmt.Println(patient.Iinfo)
  6367. }
  6368. type CustomData struct {
  6369. MsgId string
  6370. PsnNo string
  6371. Info string
  6372. }
  6373. func (c *HisApiController) ReversalData() {
  6374. var customData []*CustomData
  6375. custom := &CustomData{
  6376. MsgId: "H44022900158202103301714472004",
  6377. PsnNo: "44020000001101329945",
  6378. Info: "2207",
  6379. }
  6380. customData = append(customData, custom)
  6381. custom1 := &CustomData{
  6382. MsgId: "H4402290015820210330172057803",
  6383. PsnNo: "44020000001101161813",
  6384. Info: "2207",
  6385. }
  6386. customData = append(customData, custom1)
  6387. custom2 := &CustomData{
  6388. MsgId: "H44022900158202103301705198813",
  6389. PsnNo: "44190000133097375417",
  6390. Info: "2207",
  6391. }
  6392. customData = append(customData, custom2)
  6393. custom3 := &CustomData{
  6394. MsgId: "H44022900158202103301715524756",
  6395. PsnNo: "44020000001100187221",
  6396. Info: "2207",
  6397. }
  6398. customData = append(customData, custom3)
  6399. custom4 := &CustomData{
  6400. MsgId: "H44022900158202103301730376224",
  6401. PsnNo: "44020000001101959155",
  6402. Info: "2207",
  6403. }
  6404. customData = append(customData, custom4)
  6405. custom5 := &CustomData{
  6406. MsgId: "H44022900158202103301748008725",
  6407. PsnNo: "44020000001104246641",
  6408. Info: "2207",
  6409. }
  6410. customData = append(customData, custom5)
  6411. custom6 := &CustomData{
  6412. MsgId: "H44022900158202103301718096755",
  6413. PsnNo: "44020000001102211860",
  6414. Info: "2207",
  6415. }
  6416. customData = append(customData, custom6)
  6417. custom7 := &CustomData{
  6418. MsgId: "H44022900158202103301736551640",
  6419. PsnNo: "44020000001102687718",
  6420. Info: "2207",
  6421. }
  6422. customData = append(customData, custom7)
  6423. custom8 := &CustomData{
  6424. MsgId: "H44022900158202103301743097676",
  6425. PsnNo: "44020000001102127785",
  6426. Info: "2207",
  6427. }
  6428. customData = append(customData, custom8)
  6429. custom9 := &CustomData{
  6430. MsgId: "H44022900158202103301712304203",
  6431. PsnNo: "44020000001101518097",
  6432. Info: "2207",
  6433. }
  6434. customData = append(customData, custom9)
  6435. custom10 := &CustomData{
  6436. MsgId: "H44022900158202103301738448785",
  6437. PsnNo: "44020000001100500813",
  6438. Info: "2207",
  6439. }
  6440. customData = append(customData, custom10)
  6441. custom11 := &CustomData{
  6442. MsgId: "H44022900158202103301732455843",
  6443. PsnNo: "44020000001102690557",
  6444. Info: "2207",
  6445. }
  6446. customData = append(customData, custom11)
  6447. custom12 := &CustomData{
  6448. MsgId: "H44022900158202103301745421708",
  6449. PsnNo: "44020000001102211928",
  6450. Info: "2207",
  6451. }
  6452. customData = append(customData, custom12)
  6453. custom1212 := &CustomData{
  6454. MsgId: "H440229001582021033017351627",
  6455. PsnNo: "44020000001102481733",
  6456. Info: "2207",
  6457. }
  6458. customData = append(customData, custom1212)
  6459. custom13 := &CustomData{
  6460. MsgId: "H44022900158202103301740327951",
  6461. PsnNo: "44020000001103174866",
  6462. Info: "2207",
  6463. }
  6464. customData = append(customData, custom13)
  6465. custom14 := &CustomData{
  6466. MsgId: "H4402290015820210330174922668",
  6467. PsnNo: "44020000001102927272",
  6468. Info: "2207",
  6469. }
  6470. customData = append(customData, custom14)
  6471. custom15 := &CustomData{
  6472. MsgId: "H44022900158202103301752362273",
  6473. PsnNo: "44020000001102942890",
  6474. Info: "2207",
  6475. }
  6476. customData = append(customData, custom15)
  6477. custom16 := &CustomData{
  6478. MsgId: "H44022900158202103301751082917",
  6479. PsnNo: "44020000001101662162",
  6480. Info: "2207",
  6481. }
  6482. customData = append(customData, custom16)
  6483. custom17 := &CustomData{
  6484. MsgId: "H44022900158202103301754147728",
  6485. PsnNo: "44020000000229014511",
  6486. Info: "2207",
  6487. }
  6488. customData = append(customData, custom17)
  6489. adminUser := c.GetAdminUserInfo()
  6490. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6491. for _, item := range customData {
  6492. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  6493. fmt.Println(result)
  6494. }
  6495. }
  6496. func (c *HisApiController) ReversalOtherData() {
  6497. var customData []*CustomData
  6498. custom := &CustomData{
  6499. MsgId: "H44022900158202103301714472004",
  6500. PsnNo: "44020000001101329945",
  6501. Info: "2208",
  6502. }
  6503. customData = append(customData, custom)
  6504. custom1 := &CustomData{
  6505. MsgId: "H4402290015820210330172057803",
  6506. PsnNo: "44020000001101161813",
  6507. Info: "2208",
  6508. }
  6509. customData = append(customData, custom1)
  6510. custom2 := &CustomData{
  6511. MsgId: "H44022900158202103301705198813",
  6512. PsnNo: "44190000133097375417",
  6513. Info: "2208",
  6514. }
  6515. customData = append(customData, custom2)
  6516. custom3 := &CustomData{
  6517. MsgId: "H44022900158202103301715524756",
  6518. PsnNo: "44020000001100187221",
  6519. Info: "2208",
  6520. }
  6521. customData = append(customData, custom3)
  6522. custom4 := &CustomData{
  6523. MsgId: "H44022900158202103301730376224",
  6524. PsnNo: "44020000001101959155",
  6525. Info: "2208",
  6526. }
  6527. customData = append(customData, custom4)
  6528. custom5 := &CustomData{
  6529. MsgId: "H44022900158202103301748008725",
  6530. PsnNo: "44020000001104246641",
  6531. Info: "2208",
  6532. }
  6533. customData = append(customData, custom5)
  6534. custom6 := &CustomData{
  6535. MsgId: "H44022900158202103301718096755",
  6536. PsnNo: "44020000001102211860",
  6537. Info: "2208",
  6538. }
  6539. customData = append(customData, custom6)
  6540. custom7 := &CustomData{
  6541. MsgId: "H44022900158202103301736551640",
  6542. PsnNo: "44020000001102687718",
  6543. Info: "2208",
  6544. }
  6545. customData = append(customData, custom7)
  6546. custom8 := &CustomData{
  6547. MsgId: "H44022900158202103301743097676",
  6548. PsnNo: "44020000001102127785",
  6549. Info: "2208",
  6550. }
  6551. customData = append(customData, custom8)
  6552. custom9 := &CustomData{
  6553. MsgId: "H44022900158202103301712304203",
  6554. PsnNo: "44020000001101518097",
  6555. Info: "2208",
  6556. }
  6557. customData = append(customData, custom9)
  6558. custom10 := &CustomData{
  6559. MsgId: "H44022900158202103301738448785",
  6560. PsnNo: "44020000001100500813",
  6561. Info: "2208",
  6562. }
  6563. customData = append(customData, custom10)
  6564. custom11 := &CustomData{
  6565. MsgId: "H44022900158202103301732455843",
  6566. PsnNo: "44020000001102690557",
  6567. Info: "2208",
  6568. }
  6569. customData = append(customData, custom11)
  6570. custom12 := &CustomData{
  6571. MsgId: "H44022900158202103301745421708",
  6572. PsnNo: "44020000001102211928",
  6573. Info: "2208",
  6574. }
  6575. customData = append(customData, custom12)
  6576. custom1212 := &CustomData{
  6577. MsgId: "H440229001582021033017351627",
  6578. PsnNo: "44020000001102481733",
  6579. Info: "2208",
  6580. }
  6581. customData = append(customData, custom1212)
  6582. custom13 := &CustomData{
  6583. MsgId: "H44022900158202103301740327951",
  6584. PsnNo: "44020000001103174866",
  6585. Info: "2208",
  6586. }
  6587. customData = append(customData, custom13)
  6588. custom14 := &CustomData{
  6589. MsgId: "H4402290015820210330174922668",
  6590. PsnNo: "44020000001102927272",
  6591. Info: "2208",
  6592. }
  6593. customData = append(customData, custom14)
  6594. custom15 := &CustomData{
  6595. MsgId: "H44022900158202103301752362273",
  6596. PsnNo: "44020000001102942890",
  6597. Info: "2208",
  6598. }
  6599. customData = append(customData, custom15)
  6600. custom16 := &CustomData{
  6601. MsgId: "H44022900158202103301751082917",
  6602. PsnNo: "44020000001101662162",
  6603. Info: "2208",
  6604. }
  6605. customData = append(customData, custom16)
  6606. custom17 := &CustomData{
  6607. MsgId: "H44022900158202103301754147728",
  6608. PsnNo: "44020000000229014511",
  6609. Info: "2208",
  6610. }
  6611. customData = append(customData, custom17)
  6612. adminUser := c.GetAdminUserInfo()
  6613. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6614. for _, item := range customData {
  6615. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  6616. fmt.Println(result)
  6617. }
  6618. }
  6619. func PathExists(path string) (bool, error) {
  6620. _, err := os.Stat(path)
  6621. if err == nil {
  6622. return true, nil
  6623. }
  6624. if os.IsNotExist(err) {
  6625. return false, nil
  6626. }
  6627. return false, err
  6628. }
  6629. //创建文件夹
  6630. func Mkdir(dir string) {
  6631. // 创建文件夹
  6632. exist, err := PathExists(dir)
  6633. if err != nil {
  6634. fmt.Println(err.Error())
  6635. } else {
  6636. if exist {
  6637. fmt.Println(dir + "文件夹已存在!")
  6638. } else {
  6639. // 文件夹名称,权限
  6640. err := os.Mkdir(dir, os.ModePerm)
  6641. if err != nil {
  6642. fmt.Println(dir+"文件夹创建失败:", err.Error())
  6643. } else {
  6644. fmt.Println(dir + "文件夹创建成功!")
  6645. }
  6646. }
  6647. }
  6648. }
  6649. //压缩文件
  6650. func Zip(srcFile string, destZip string) error {
  6651. zipfile, err := os.Create(destZip)
  6652. if err != nil {
  6653. return err
  6654. }
  6655. defer zipfile.Close()
  6656. archive := zip.NewWriter(zipfile)
  6657. defer archive.Close()
  6658. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  6659. if err != nil {
  6660. return err
  6661. }
  6662. header, err := zip.FileInfoHeader(info)
  6663. if err != nil {
  6664. return err
  6665. }
  6666. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  6667. // header.Name = path
  6668. if info.IsDir() {
  6669. header.Name += "/"
  6670. } else {
  6671. header.Method = zip.Deflate
  6672. }
  6673. writer, err := archive.CreateHeader(header)
  6674. if err != nil {
  6675. return err
  6676. }
  6677. if !info.IsDir() {
  6678. file, err := os.Open(path)
  6679. if err != nil {
  6680. return err
  6681. }
  6682. defer file.Close()
  6683. _, err = io.Copy(writer, file)
  6684. }
  6685. return err
  6686. })
  6687. return err
  6688. }
  6689. func ReadFile(filePath string) []byte {
  6690. f, err := os.Open(filePath)
  6691. if err != nil {
  6692. fmt.Println("read file fail", err)
  6693. return nil
  6694. }
  6695. defer f.Close()
  6696. fd, err := ioutil.ReadAll(f)
  6697. if err != nil {
  6698. fmt.Println("read to fd fail", err)
  6699. return nil
  6700. }
  6701. return fd
  6702. }
  6703. func RemoveRepeatedTeam(arr []*models.HisOrderInfo) (newArr []*models.HisOrderInfo) {
  6704. newArr = make([]*models.HisOrderInfo, 0)
  6705. for i := 0; i < len(arr); i++ {
  6706. repeat := false
  6707. for j := i + 1; j < len(arr); j++ {
  6708. if arr[i].HisPrescriptionProject.TeamId == arr[j].HisPrescriptionProject.TeamId {
  6709. repeat = true
  6710. break
  6711. }
  6712. }
  6713. if !repeat {
  6714. newArr = append(newArr, arr[i])
  6715. }
  6716. }
  6717. return
  6718. }
  6719. func saveRegisterLog(result string) {
  6720. org_id, _ := beego.AppConfig.Int64("org_id")
  6721. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  6722. dir := miConfig.OrgName + "日志"
  6723. utils.Mkdir(dir)
  6724. month := time.Unix(1557042972, 0).Format("1")
  6725. year := time.Now().Format("2006")
  6726. month = time.Now().Format("01")
  6727. day := time.Now().Format("02")
  6728. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  6729. file_name := file + ".txt"
  6730. file_path := miConfig.OrgName + "日志" + "/" + file_name
  6731. exist, _ := utils.PathExists(file_path)
  6732. if exist { //存在
  6733. fmt.Println("存在")
  6734. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  6735. if err != nil {
  6736. fmt.Println("read fail")
  6737. }
  6738. content := "\r\n" + result
  6739. n, _ := f.Seek(0, 2)
  6740. _, err = f.WriteAt([]byte(content), n)
  6741. } else { //不存在
  6742. fmt.Println("文件不存在,创建文件")
  6743. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  6744. defer f.Close()
  6745. if err != nil {
  6746. } else {
  6747. _, err = f.Write([]byte("记录日志"))
  6748. }
  6749. }
  6750. }
  6751. func saveLog(result string, request string, infno string, desc string) {
  6752. org_id, _ := beego.AppConfig.Int64("org_id")
  6753. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  6754. dir := miConfig.OrgName + "日志"
  6755. utils.Mkdir(dir)
  6756. month := time.Unix(1557042972, 0).Format("1")
  6757. year := time.Now().Format("2006")
  6758. month = time.Now().Format("01")
  6759. day := time.Now().Format("02")
  6760. hour := time.Now().Format("15")
  6761. min := time.Now().Format("04")
  6762. sec := time.Now().Format("05")
  6763. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  6764. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  6765. file_name := file + ".txt"
  6766. file_path := miConfig.OrgName + "日志" + "/" + file_name
  6767. exist, _ := utils.PathExists(file_path)
  6768. if exist { //存在
  6769. fmt.Println("存在")
  6770. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  6771. if err != nil {
  6772. fmt.Println("read fail")
  6773. }
  6774. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  6775. n, _ := f.Seek(0, 2)
  6776. _, err = f.WriteAt([]byte(content), n)
  6777. } else { //不存在
  6778. fmt.Println("文件不存在,创建文件")
  6779. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  6780. defer f.Close()
  6781. if err != nil {
  6782. } else {
  6783. _, err = f.Write([]byte("记录日志"))
  6784. }
  6785. }
  6786. }
  6787. type Charset string
  6788. const (
  6789. UTF8 = Charset("UTF-8")
  6790. GB18030 = Charset("GB18030")
  6791. )
  6792. func ConvertToString(src string, srcCode string, tagCode string) string {
  6793. srcCoder := mahonia.NewDecoder(srcCode)
  6794. srcResult := srcCoder.ConvertString(src)
  6795. tagCoder := mahonia.NewDecoder(tagCode)
  6796. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  6797. result := string(cdata)
  6798. return result
  6799. }
  6800. //func (c *HisApiController)HandleCheckDetailAccount(){
  6801. // psn_no, _ := c.GetString("psn_no")
  6802. // psn_no, _ := c.GetString("psn_no")
  6803. // psn_no, _ := c.GetString("psn_no")
  6804. //
  6805. //
  6806. //
  6807. //}