his_api_controller.go 269KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574
  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"] = roles.AdminUserId
  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, 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))
  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. allTotal := fmt.Sprintf("%.4f", total)
  2933. if res.Infcode == 0 {
  2934. var rf []*ResultFive
  2935. json.Unmarshal([]byte(his.Iinfo), &rf)
  2936. chrg_bchno := chrg_bchno
  2937. cert_no := his.Certno
  2938. var insutypes []string
  2939. var insutype string
  2940. var is390 int = 0
  2941. var is310 int = 0
  2942. for _, item := range rf {
  2943. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2944. insutypes = append(insutypes, item.Insutype)
  2945. }
  2946. }
  2947. if len(insutypes) == 1 {
  2948. insutype = insutypes[0]
  2949. } else {
  2950. for _, i := range insutypes {
  2951. if i == "390" {
  2952. is390 = 1
  2953. }
  2954. if i == "310" {
  2955. is310 = 1
  2956. }
  2957. }
  2958. }
  2959. if is390 == 1 {
  2960. insutype = "390"
  2961. }
  2962. if is310 == 1 {
  2963. insutype = "310"
  2964. }
  2965. if len(insutypes) == 0 {
  2966. insutype = "310"
  2967. }
  2968. if len(insutypes) == 2 {
  2969. insutype = strconv.FormatInt(his.SocialType, 10)
  2970. }
  2971. //insutype = "390"
  2972. if his.IdCardType == 1 {
  2973. // cert_no = his.MedicalInsuranceNumber
  2974. cert_no = his.Certno
  2975. } else {
  2976. cert_no = his.Certno
  2977. }
  2978. var res ResultSeven
  2979. var src_resquest string
  2980. var result2 string
  2981. var acct_used_flag string
  2982. fmt.Println("pay_way")
  2983. fmt.Println(pay_way)
  2984. fmt.Println("pay_way")
  2985. if pay_way == 4 {
  2986. acct_used_flag = "1"
  2987. } else {
  2988. acct_used_flag = "0"
  2989. }
  2990. if miConfig.MdtrtareaAdmvs == "421300" {
  2991. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  2992. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  2993. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  2994. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  2995. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  2996. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  2997. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  2998. resp, requestErr := http.Get(api)
  2999. if requestErr != nil {
  3000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3001. return
  3002. }
  3003. body, ioErr := ioutil.ReadAll(resp.Body)
  3004. if ioErr != nil {
  3005. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3007. return
  3008. }
  3009. var respJSON map[string]interface{}
  3010. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3011. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3013. return
  3014. }
  3015. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3016. result, _ := json.Marshal(respJSON)
  3017. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3018. utils.ErrorLog("解析失败:%v", err)
  3019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3020. return
  3021. }
  3022. } else {
  3023. 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)
  3024. var dat map[string]interface{}
  3025. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  3026. fmt.Println(dat)
  3027. } else {
  3028. fmt.Println(err)
  3029. }
  3030. saveLog(result2, src_resquest, "2207", "结算")
  3031. userJSONBytes, _ := json.Marshal(dat)
  3032. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3033. utils.ErrorLog("解析失败:%v", err)
  3034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3035. return
  3036. }
  3037. }
  3038. if res.Infcode != 0 {
  3039. errlog := &models.HisOrderError{
  3040. UserOrgId: adminUser.CurrentOrgId,
  3041. Ctime: time.Now().Unix(),
  3042. Mtime: time.Now().Unix(),
  3043. Number: chrg_bchno,
  3044. ErrMsg: res.ErrMsg,
  3045. Status: 1,
  3046. PatientId: id,
  3047. RecordTime: recordDateTime,
  3048. Stage: 6,
  3049. }
  3050. service.CreateErrMsgLog(errlog)
  3051. c.ServeSuccessJSON(map[string]interface{}{
  3052. "failed_code": -10,
  3053. "msg": res.ErrMsg,
  3054. })
  3055. return
  3056. } else {
  3057. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3058. order.OrderStatus = 2
  3059. order.Status = 1
  3060. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3061. order.SetlId = res.Output.Setlinfo.SetlID
  3062. order.PsnNo = res.Output.Setlinfo.PsnNo
  3063. order.PsnName = res.Output.Setlinfo.PsnName
  3064. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3065. order.Certno = res.Output.Setlinfo.Certno
  3066. order.Gend = res.Output.Setlinfo.Gend
  3067. order.Naty = res.Output.Setlinfo.Naty
  3068. order.Age = res.Output.Setlinfo.Age
  3069. order.Insutype = res.Output.Setlinfo.Insutype
  3070. order.PsnType = res.Output.Setlinfo.PsnType
  3071. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3072. order.SetlTime = res.Output.Setlinfo.SetlTime
  3073. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3074. if res.Output.Setlinfo.MedType == "140101" {
  3075. order.MedType = "14"
  3076. } else {
  3077. order.MedType = res.Output.Setlinfo.MedType
  3078. }
  3079. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3080. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3081. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3082. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3083. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3084. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3085. order.HifpPay = res.Output.Setlinfo.HifpPay
  3086. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3087. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3088. order.HifesPay = res.Output.Setlinfo.HifesPay
  3089. order.HifobPay = res.Output.Setlinfo.HifobPay
  3090. order.MafPay = res.Output.Setlinfo.MafPay
  3091. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3092. order.OthPay = res.Output.Setlinfo.OthPay
  3093. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3094. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3095. order.AcctPay = res.Output.Setlinfo.AcctPay
  3096. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3097. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3098. order.Balc = res.Output.Setlinfo.Balc
  3099. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3100. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3101. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3102. order.ClrWay = res.Output.Setlinfo.ClrWay
  3103. order.Creator = order.Creator
  3104. order.Modify = roles.AdminUserId
  3105. order.RequestLog = src_resquest
  3106. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3107. detailStr := string(setlDetail)
  3108. order.SetlDetail = detailStr
  3109. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3110. err = service.UpDateOrder(order)
  3111. if err == nil {
  3112. c.ServeSuccessJSON(map[string]interface{}{
  3113. "msg": "结算成功",
  3114. })
  3115. } else {
  3116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3117. return
  3118. }
  3119. }
  3120. } else {
  3121. adminUser := c.GetAdminUserInfo()
  3122. errlog := &models.HisOrderError{
  3123. UserOrgId: adminUser.CurrentOrgId,
  3124. Ctime: time.Now().Unix(),
  3125. Mtime: time.Now().Unix(),
  3126. ErrMsg: res.ErrMsg,
  3127. Status: 1,
  3128. PatientId: id,
  3129. RecordTime: recordDateTime,
  3130. Stage: 4,
  3131. }
  3132. service.CreateErrMsgLog(errlog)
  3133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3134. return
  3135. }
  3136. } else {
  3137. adminUser := c.GetAdminUserInfo()
  3138. errlog := &models.HisOrderError{
  3139. UserOrgId: adminUser.CurrentOrgId,
  3140. Ctime: time.Now().Unix(),
  3141. Mtime: time.Now().Unix(),
  3142. ErrMsg: res.ErrMsg,
  3143. Status: 1,
  3144. PatientId: id,
  3145. RecordTime: recordDateTime,
  3146. Stage: 4,
  3147. }
  3148. service.CreateErrMsgLog(errlog)
  3149. c.ServeSuccessJSON(map[string]interface{}{
  3150. "failed_code": -10,
  3151. "msg": res.ErrMsg,
  3152. })
  3153. return
  3154. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  3155. //return
  3156. }
  3157. }
  3158. }
  3159. } else if tempOrder.ID > 0 {
  3160. if tempOrder.IsPre == 1 {
  3161. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  3162. var rf []*ResultFive
  3163. json.Unmarshal([]byte(his.Iinfo), &rf)
  3164. chrg_bchno := tempOrder.Number
  3165. cert_no := his.Certno
  3166. var insutypes []string
  3167. var insutype string
  3168. var is390 int = 0
  3169. var is310 int = 0
  3170. for _, item := range rf {
  3171. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3172. insutypes = append(insutypes, item.Insutype)
  3173. }
  3174. }
  3175. if len(insutypes) == 1 {
  3176. insutype = insutypes[0]
  3177. } else {
  3178. for _, i := range insutypes {
  3179. if i == "390" {
  3180. is390 = 1
  3181. }
  3182. if i == "310" {
  3183. is310 = 1
  3184. }
  3185. }
  3186. }
  3187. if is390 == 1 {
  3188. insutype = "390"
  3189. }
  3190. if is310 == 1 {
  3191. insutype = "310"
  3192. }
  3193. if len(insutypes) == 0 {
  3194. insutype = "310"
  3195. }
  3196. if len(insutypes) == 2 {
  3197. insutype = strconv.FormatInt(his.SocialType, 64)
  3198. }
  3199. //insutype = "390"
  3200. if his.IdCardType == 1 {
  3201. // cert_no = his.MedicalInsuranceNumber
  3202. cert_no = his.Certno
  3203. } else {
  3204. cert_no = his.Certno
  3205. }
  3206. var res ResultSeven
  3207. var src_resquest string
  3208. var result2 string
  3209. var acct_used_flag string
  3210. fmt.Println("pay_way")
  3211. fmt.Println(pay_way)
  3212. fmt.Println("pay_way")
  3213. if pay_way == 4 {
  3214. acct_used_flag = "1"
  3215. } else {
  3216. acct_used_flag = "0"
  3217. }
  3218. if miConfig.MdtrtareaAdmvs == "421300" {
  3219. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  3220. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  3221. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3222. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3223. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  3224. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  3225. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  3226. resp, requestErr := http.Get(api)
  3227. if requestErr != nil {
  3228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3229. return
  3230. }
  3231. body, ioErr := ioutil.ReadAll(resp.Body)
  3232. if ioErr != nil {
  3233. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3235. return
  3236. }
  3237. var respJSON map[string]interface{}
  3238. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3239. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3241. return
  3242. }
  3243. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3244. result, _ := json.Marshal(respJSON)
  3245. fmt.Println("log")
  3246. fmt.Println(string(result))
  3247. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3248. utils.ErrorLog("解析失败:%v", err)
  3249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3250. return
  3251. }
  3252. } else {
  3253. 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)
  3254. var dat map[string]interface{}
  3255. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  3256. fmt.Println(dat)
  3257. } else {
  3258. fmt.Println(err)
  3259. }
  3260. saveLog(result2, src_resquest, "2207", "结算")
  3261. userJSONBytes, _ := json.Marshal(dat)
  3262. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3263. utils.ErrorLog("解析失败:%v", err)
  3264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3265. return
  3266. }
  3267. }
  3268. if res.Infcode != 0 {
  3269. errlog := &models.HisOrderError{
  3270. UserOrgId: adminUser.CurrentOrgId,
  3271. Ctime: time.Now().Unix(),
  3272. Mtime: time.Now().Unix(),
  3273. Number: chrg_bchno,
  3274. ErrMsg: res.ErrMsg,
  3275. Status: 1,
  3276. PatientId: id,
  3277. RecordTime: recordDateTime,
  3278. Stage: 6,
  3279. }
  3280. service.CreateErrMsgLog(errlog)
  3281. c.ServeSuccessJSON(map[string]interface{}{
  3282. "failed_code": -10,
  3283. "msg": res.ErrMsg,
  3284. })
  3285. return
  3286. } else {
  3287. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3288. order.OrderStatus = 2
  3289. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3290. order.SetlId = res.Output.Setlinfo.SetlID
  3291. order.PsnNo = res.Output.Setlinfo.PsnNo
  3292. order.PsnName = res.Output.Setlinfo.PsnName
  3293. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3294. order.Certno = res.Output.Setlinfo.Certno
  3295. order.Gend = res.Output.Setlinfo.Gend
  3296. order.Naty = res.Output.Setlinfo.Naty
  3297. order.Age = res.Output.Setlinfo.Age
  3298. order.Insutype = res.Output.Setlinfo.Insutype
  3299. order.PsnType = res.Output.Setlinfo.PsnType
  3300. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3301. order.SetlTime = res.Output.Setlinfo.SetlTime
  3302. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3303. order.MedType = res.Output.Setlinfo.MedType
  3304. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3305. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3306. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3307. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3308. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3309. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3310. order.HifpPay = res.Output.Setlinfo.HifpPay
  3311. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3312. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3313. order.HifesPay = res.Output.Setlinfo.HifesPay
  3314. order.HifobPay = res.Output.Setlinfo.HifobPay
  3315. order.MafPay = res.Output.Setlinfo.MafPay
  3316. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3317. order.OthPay = res.Output.Setlinfo.OthPay
  3318. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3319. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3320. order.AcctPay = res.Output.Setlinfo.AcctPay
  3321. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3322. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3323. order.Balc = res.Output.Setlinfo.Balc
  3324. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3325. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3326. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3327. order.ClrWay = res.Output.Setlinfo.ClrWay
  3328. order.Creator = order.Creator
  3329. order.Modify = roles.AdminUserId
  3330. order.RequestLog = src_resquest
  3331. order.Diagnosis = diagnosis_id
  3332. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3333. detailStr := string(setlDetail)
  3334. order.SetlDetail = detailStr
  3335. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3336. err = service.UpDateOrder(order)
  3337. if err == nil {
  3338. c.ServeSuccessJSON(map[string]interface{}{
  3339. "msg": "结算成功",
  3340. })
  3341. } else {
  3342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3343. return
  3344. }
  3345. }
  3346. }
  3347. }
  3348. }
  3349. //func (c *HisApiController) GetPreUploadInfo() {
  3350. // id, _ := c.GetInt64("id")
  3351. // record_time := c.GetString("record_time")
  3352. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3353. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3354. //
  3355. // timeLayout := "2006-01-02"
  3356. // loc, _ := time.LoadLocation("Local")
  3357. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3358. // if err != nil {
  3359. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3360. // return
  3361. // }
  3362. // recordDateTime := theTime.Unix()
  3363. // adminUser := c.GetAdminUserInfo()
  3364. //
  3365. // var prescriptions []*models.HisPrescription
  3366. //
  3367. // var start_time int64
  3368. // var end_time int64
  3369. //
  3370. // data := make(map[string]interface{})
  3371. // if settle_accounts_type == 1 { //日结
  3372. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  3373. // data["pre"] = prescriptions
  3374. //
  3375. // } else { //月结
  3376. // start_time_str := c.GetString("start_time")
  3377. // end_time_str := c.GetString("end_time")
  3378. // timeLayout := "2006-01-02"
  3379. // loc, _ := time.LoadLocation("Local")
  3380. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3381. // if err != nil {
  3382. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3383. // return
  3384. // }
  3385. // recordStartTime := theStartTime.Unix()
  3386. // start_time = recordStartTime
  3387. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3388. // if err != nil {
  3389. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3390. // return
  3391. // }
  3392. // recordEndTime := theEndTime.Unix()
  3393. // end_time = recordEndTime
  3394. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  3395. // data["pre"] = prescriptions
  3396. //
  3397. // }
  3398. //
  3399. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3400. //
  3401. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3402. // timestamp := time.Now().Unix()
  3403. // tempTime := time.Unix(timestamp, 0)
  3404. // timeFormat := tempTime.Format("20060102150405")
  3405. // chrgBchno := rand.Intn(100000) + 10000
  3406. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3407. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3408. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3409. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3410. // strconv.FormatInt(his.PatientId, 10)
  3411. // client := &http.Client{}
  3412. // data["psn_no"] = his.PsnNo
  3413. // data["mdtrt_id"] = his.Number
  3414. // data["chrg_bchno"] = chrg_bchno
  3415. // data["org_name"] = miConfig.OrgName
  3416. // data["doctor"] = roles.UserName
  3417. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3418. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3419. // data["fixmedins_code"] = miConfig.Code
  3420. // data["dept_code"] = department.Number
  3421. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3422. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3423. // data["secret_key"] = miConfig.SecretKey
  3424. // var ids []int64
  3425. //
  3426. // for _, item := range prescriptions {
  3427. // ids = append(ids, item.ID)
  3428. // }
  3429. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3430. // if config.IsOpen == 1 { //对接了医保,走医保流程
  3431. // bytesData, _ := json.Marshal(data)
  3432. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  3433. // resp, _ := client.Do(req)
  3434. // defer resp.Body.Close()
  3435. // body, ioErr := ioutil.ReadAll(resp.Body)
  3436. // if ioErr != nil {
  3437. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3438. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3439. // return
  3440. // }
  3441. // var respJSON map[string]interface{}
  3442. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3443. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3444. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3445. // return
  3446. // }
  3447. //
  3448. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3449. // userJSONBytes, _ := json.Marshal(respJSON)
  3450. // var res ResultFour
  3451. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3452. // utils.ErrorLog("解析失败:%v", err)
  3453. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3454. // return
  3455. // }
  3456. //
  3457. // if res.Infcode == 0 {
  3458. // order := &models.HisOrder{
  3459. // UserOrgId: adminUser.CurrentOrgId,
  3460. // HisPatientId: his.ID,
  3461. // PatientId: his.PatientId,
  3462. // SettleAccountsDate: recordDateTime,
  3463. // Ctime: time.Now().Unix(),
  3464. // Mtime: time.Now().Unix(),
  3465. // Status: 1,
  3466. // Number: chrg_bchno,
  3467. // Infcode: res.Infcode,
  3468. // WarnMsg: res.WarnMsg,
  3469. // Cainfo: res.Cainfo,
  3470. // ErrMsg: res.ErrMsg,
  3471. // RespondTime: res.RefmsgTime,
  3472. // InfRefmsgid: res.InfRefmsgid,
  3473. // OrderStatus: 1,
  3474. // IsMedicineInsurance: 1,
  3475. // SettleType: settle_accounts_type,
  3476. // SettleStartTime: start_time,
  3477. // SettleEndTime: end_time,
  3478. // Creator: roles.ID,
  3479. // Modify: roles.ID,
  3480. // PType: 2,
  3481. // }
  3482. // err = service.CreateOrder(order)
  3483. // if err != nil {
  3484. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  3485. // return
  3486. // }
  3487. //
  3488. // for _, item := range res.Output.Result {
  3489. // temp := strings.Split(item.FeedetlSn, "-")
  3490. // var advice_id int64 = 0
  3491. // var project_id int64 = 0
  3492. // var types int64 = 0
  3493. //
  3494. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  3495. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  3496. //
  3497. // if temp[1] == "1" {
  3498. // advice_id = id
  3499. // project_id = 0
  3500. // } else if temp[1] == "2" {
  3501. // advice_id = 0
  3502. // project_id = id
  3503. // }
  3504. //
  3505. // info := &models.HisOrderInfo{
  3506. // OrderNumber: order.Number,
  3507. // FeedetlSn: item.FeedetlSn,
  3508. // UploadDate: time.Now().Unix(),
  3509. // AdviceId: advice_id,
  3510. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  3511. // Cnt: item.Cnt,
  3512. // Pric: float64(item.Pric),
  3513. // PatientId: his.PatientId,
  3514. // PricUplmtAmt: item.PricUplmtAmt,
  3515. // SelfpayProp: item.SelfpayProp,
  3516. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  3517. // OverlmtAmt: item.OverlmtAmt,
  3518. // PreselfpayAmt: item.PreselfpayAmt,
  3519. // BasMednFlag: item.BasMednFlag,
  3520. // MedChrgitmType: item.MedChrgitmType,
  3521. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  3522. // Status: 1,
  3523. // Memo: item.Memo,
  3524. // Mtime: time.Now().Unix(),
  3525. // InscpScpAmt: item.InscpScpAmt,
  3526. // DrtReimFlag: item.DrtReimFlag,
  3527. // Ctime: time.Now().Unix(),
  3528. // ListSpItemFlag: item.ListSpItemFlag,
  3529. // ChldMedcFlag: item.ChldMedcFlag,
  3530. // LmtUsedFlag: item.LmtUsedFlag,
  3531. // ChrgitmLv: item.ChrgitmLv,
  3532. // UserOrgId: adminUser.CurrentOrgId,
  3533. // HisPatientId: his.ID,
  3534. // OrderId: order.ID,
  3535. // ProjectId: project_id,
  3536. // Type: types,
  3537. // }
  3538. // service.CreateOrderInfo(info)
  3539. //
  3540. // }
  3541. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3542. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  3543. //
  3544. // var total float64
  3545. // for _, item := range prescriptions {
  3546. // if item.Type == 1 { //药品
  3547. // for _, subItem := range item.HisDoctorAdviceInfo {
  3548. // total = total + (subItem.Price * subItem.PrescribingNumber)
  3549. // }
  3550. // }
  3551. // if item.Type == 2 { //项目
  3552. // for _, subItem := range item.HisPrescriptionProject {
  3553. // total = total + (subItem.Price * float64(subItem.Count))
  3554. // }
  3555. // }
  3556. // }
  3557. //
  3558. // for _, item := range prescriptions {
  3559. // for _, subItem := range item.HisAdditionalCharge {
  3560. // total = total + (subItem.Price * float64(subItem.Count))
  3561. // }
  3562. // }
  3563. //
  3564. // allTotal := fmt.Sprintf("%.2f", total)
  3565. // if res.Infcode == 0 {
  3566. // var rf []*ResultFive
  3567. // json.Unmarshal([]byte(his.Iinfo), &rf)
  3568. // psn_no := his.PsnNo
  3569. // mdtrt_id := his.Number
  3570. // chrg_bchno := chrg_bchno
  3571. // cert_no := his.Certno
  3572. // insutype := rf[0].Insutype
  3573. //
  3574. // if his.IdCardType == 1 {
  3575. // cert_no = his.MedicalInsuranceNumber
  3576. //
  3577. // } else {
  3578. //
  3579. // cert_no = his.Certno
  3580. //
  3581. // }
  3582. //
  3583. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  3584. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  3585. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  3586. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  3587. // resp, requestErr := http.Get(api)
  3588. // if requestErr != nil {
  3589. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3590. // return
  3591. // }
  3592. // defer resp.Body.Close()
  3593. // body, ioErr := ioutil.ReadAll(resp.Body)
  3594. // if ioErr != nil {
  3595. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3596. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3597. // return
  3598. // }
  3599. // var respJSON map[string]interface{}
  3600. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3601. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3602. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3603. // return
  3604. // }
  3605. // fmt.Println(respJSON)
  3606. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3607. // userJSONBytes, _ := json.Marshal(respJSON)
  3608. // var res ResultSeven
  3609. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3610. // utils.ErrorLog("解析失败:%v", err)
  3611. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3612. // return
  3613. // }
  3614. // if res.Infcode != 0 {
  3615. // errlog := &models.HisOrderError{
  3616. // UserOrgId: adminUser.CurrentOrgId,
  3617. // Ctime: time.Now().Unix(),
  3618. // Mtime: time.Now().Unix(),
  3619. // Number: chrg_bchno,
  3620. // ErrMsg: res.ErrMsg,
  3621. // Status: 1,
  3622. // PatientId: id,
  3623. // RecordTime: recordDateTime,
  3624. // Stage: 7,
  3625. // }
  3626. // service.CreateErrMsgLog(errlog)
  3627. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3628. // return
  3629. // } else {
  3630. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3631. // order.OrderStatus = 1
  3632. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3633. // order.SetlId = res.Output.Setlinfo.SetlID
  3634. // order.PsnNo = res.Output.Setlinfo.PsnNo
  3635. // order.PsnName = res.Output.Setlinfo.PsnName
  3636. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3637. // order.Certno = res.Output.Setlinfo.Certno
  3638. // order.Gend = res.Output.Setlinfo.Gend
  3639. // order.Naty = res.Output.Setlinfo.Naty
  3640. // order.Age = res.Output.Setlinfo.Age
  3641. // order.Insutype = res.Output.Setlinfo.Insutype
  3642. // order.PsnType = res.Output.Setlinfo.PsnType
  3643. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3644. // order.SetlTime = res.Output.Setlinfo.SetlTime
  3645. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3646. // order.MedType = res.Output.Setlinfo.MedType
  3647. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3648. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3649. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3650. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3651. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3652. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3653. // order.HifpPay = res.Output.Setlinfo.HifpPay
  3654. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3655. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3656. // order.HifesPay = res.Output.Setlinfo.HifesPay
  3657. // order.HifobPay = res.Output.Setlinfo.HifobPay
  3658. // order.MafPay = res.Output.Setlinfo.MafPay
  3659. // order.OthPay = res.Output.Setlinfo.OthPay
  3660. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3661. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3662. // order.AcctPay = res.Output.Setlinfo.AcctPay
  3663. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3664. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3665. // order.Balc = res.Output.Setlinfo.Balc
  3666. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3667. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3668. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3669. // order.ClrWay = res.Output.Setlinfo.ClrWay
  3670. // order.Creator = order.Creator
  3671. // order.Modify = roles.ID
  3672. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3673. // detailStr := string(setlDetail)
  3674. // order.SetlDetail = detailStr
  3675. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3676. // err = service.UpDateOrder(order)
  3677. // if err == nil {
  3678. // c.ServeSuccessJSON(map[string]interface{}{
  3679. // "msg": "预结算成功",
  3680. // })
  3681. // } else {
  3682. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3683. // return
  3684. // }
  3685. // }
  3686. // } else {
  3687. // adminUser := c.GetAdminUserInfo()
  3688. // errlog := &models.HisOrderError{
  3689. // UserOrgId: adminUser.CurrentOrgId,
  3690. // Ctime: time.Now().Unix(),
  3691. // Mtime: time.Now().Unix(),
  3692. // ErrMsg: res.ErrMsg,
  3693. // Status: 1,
  3694. // PatientId: id,
  3695. // RecordTime: recordDateTime,
  3696. // Stage: 4,
  3697. // }
  3698. // service.CreateErrMsgLog(errlog)
  3699. //
  3700. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3701. // return
  3702. // }
  3703. // } else {
  3704. // adminUser := c.GetAdminUserInfo()
  3705. // errlog := &models.HisOrderError{
  3706. // UserOrgId: adminUser.CurrentOrgId,
  3707. // Ctime: time.Now().Unix(),
  3708. // Mtime: time.Now().Unix(),
  3709. // ErrMsg: res.ErrMsg,
  3710. // Status: 1,
  3711. // PatientId: id,
  3712. // RecordTime: recordDateTime,
  3713. // Stage: 4,
  3714. // }
  3715. // service.CreateErrMsgLog(errlog)
  3716. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  3717. // return
  3718. // }
  3719. //
  3720. // } else {
  3721. // var total float64
  3722. // for _, item := range prescriptions {
  3723. // if item.Type == 1 { //药品
  3724. // for _, subItem := range item.HisDoctorAdviceInfo {
  3725. // total = total + (subItem.Price * subItem.PrescribingNumber)
  3726. // }
  3727. // }
  3728. // if item.Type == 2 { //项目
  3729. // for _, subItem := range item.HisPrescriptionProject {
  3730. // total = total + (subItem.Price * float64(subItem.Count))
  3731. // }
  3732. // }
  3733. //
  3734. // for _, subItem := range item.HisAdditionalCharge {
  3735. // total = total + (subItem.Price * float64(subItem.Count))
  3736. // }
  3737. // }
  3738. //
  3739. // allTotal := fmt.Sprintf("%.2f", total)
  3740. // totals, _ := strconv.ParseFloat(allTotal, 64)
  3741. // order := &models.HisOrder{
  3742. // UserOrgId: adminUser.CurrentOrgId,
  3743. // HisPatientId: his.ID,
  3744. // PatientId: id,
  3745. // SettleAccountsDate: recordDateTime,
  3746. // Ctime: time.Now().Unix(),
  3747. // Mtime: time.Now().Unix(),
  3748. // Status: 1,
  3749. // OrderStatus: 2,
  3750. // Number: chrg_bchno,
  3751. // MedfeeSumamt: totals,
  3752. // }
  3753. // err = service.CreateOrder(order)
  3754. // if err != nil {
  3755. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  3756. // return
  3757. // }
  3758. //
  3759. // var customs []*Custom
  3760. // for _, item := range prescriptions {
  3761. //
  3762. // if item.Type == 1 { //药品
  3763. // for _, subItem := range item.HisDoctorAdviceInfo {
  3764. // cus := &Custom{
  3765. // AdviceId: subItem.ID,
  3766. // ProjectId: 0,
  3767. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  3768. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  3769. // FeedetlSn: subItem.FeedetlSn,
  3770. // Price: fmt.Sprintf("%.2f", subItem.Price),
  3771. // MedListCodg: subItem.MedListCodg,
  3772. // Type: 1,
  3773. // }
  3774. // customs = append(customs, cus)
  3775. // }
  3776. // }
  3777. //
  3778. // if item.Type == 2 { //项目
  3779. // for _, subItem := range item.HisPrescriptionProject {
  3780. //
  3781. // cus := &Custom{
  3782. // AdviceId: 0,
  3783. // ProjectId: subItem.ID,
  3784. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  3785. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  3786. // FeedetlSn: subItem.FeedetlSn,
  3787. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  3788. // MedListCodg: subItem.MedListCodg,
  3789. // Type: 2,
  3790. // }
  3791. //
  3792. // customs = append(customs, cus)
  3793. // }
  3794. // }
  3795. //
  3796. // for _, item := range item.HisAdditionalCharge {
  3797. // cus := &Custom{
  3798. // ItemId: item.ID,
  3799. // AdviceId: 0,
  3800. // ProjectId: 0,
  3801. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  3802. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  3803. // FeedetlSn: item.FeedetlSn,
  3804. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  3805. // MedListCodg: item.XtHisAddtionConfig.Code,
  3806. // Type: 3,
  3807. // }
  3808. //
  3809. // customs = append(customs, cus)
  3810. // }
  3811. //
  3812. // }
  3813. //
  3814. // for _, item := range customs {
  3815. // var advice_id int64 = 0
  3816. // var project_id int64 = 0
  3817. // var item_id int64 = 0
  3818. //
  3819. // var types int64 = 0
  3820. //
  3821. // if item.Type == 1 {
  3822. // advice_id = item.AdviceId
  3823. // project_id = 0
  3824. // item_id = 0
  3825. // } else if item.Type == 2 {
  3826. // advice_id = 0
  3827. // item_id = 0
  3828. //
  3829. // project_id = item.ProjectId
  3830. // } else if item.Type == 3 {
  3831. // advice_id = 0
  3832. // item_id = item.ItemId
  3833. // project_id = 0
  3834. // }
  3835. //
  3836. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  3837. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  3838. // pric, _ := strconv.ParseFloat(item.Price, 32)
  3839. //
  3840. // info := &models.HisOrderInfo{
  3841. // OrderNumber: order.Number,
  3842. // UploadDate: time.Now().Unix(),
  3843. // AdviceId: advice_id,
  3844. // DetItemFeeSumamt: detItemFeeSumamt,
  3845. // Cnt: cut,
  3846. // Pric: pric,
  3847. // PatientId: id,
  3848. // Status: 1,
  3849. // Mtime: time.Now().Unix(),
  3850. // Ctime: time.Now().Unix(),
  3851. // UserOrgId: adminUser.CurrentOrgId,
  3852. // HisPatientId: his.ID,
  3853. // OrderId: order.ID,
  3854. // ProjectId: project_id,
  3855. // Type: types,
  3856. // ItemId: item_id,
  3857. // }
  3858. // service.CreateOrderInfo(info)
  3859. // }
  3860. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3861. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3862. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  3863. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3864. // if err == nil {
  3865. // c.ServeSuccessJSON(map[string]interface{}{
  3866. // "msg": "结算成功",
  3867. // })
  3868. // } else {
  3869. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3870. // return
  3871. // }
  3872. // }
  3873. //}
  3874. //上传明细-预结算-
  3875. func (c *HisApiController) GetPreUploadInfo() {
  3876. id, _ := c.GetInt64("id")
  3877. record_time := c.GetString("record_time")
  3878. his_patient_id, _ := c.GetInt64("his_patient_id")
  3879. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3880. admin_user_id, _ := c.GetInt64("admin_user_id")
  3881. diagnosis_id := c.GetString("diagnosis")
  3882. sick_type, _ := c.GetInt64("sick_type")
  3883. reg_type, _ := c.GetInt64("p_type")
  3884. id_str := c.GetString("ids")
  3885. ids_arr := strings.Split(id_str, ",")
  3886. timeLayout := "2006-01-02"
  3887. loc, _ := time.LoadLocation("Local")
  3888. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3889. if err != nil {
  3890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3891. return
  3892. }
  3893. recordDateTime := theTime.Unix()
  3894. adminUser := c.GetAdminUserInfo()
  3895. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3896. var config []*models.HisXtDiagnoseConfig
  3897. for _, item := range diagnosis_ids {
  3898. id, _ := strconv.ParseInt(item, 10, 64)
  3899. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3900. config = append(config, &diagnosisConfig)
  3901. }
  3902. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  3903. sickConfig, _ := service.FindSickById(sick_type)
  3904. var prescriptions []*models.HisPrescription
  3905. var start_time int64
  3906. var end_time int64
  3907. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3908. fmt.Println(his_patient_id)
  3909. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3910. timestamp := time.Now().Unix()
  3911. tempTime := time.Unix(timestamp, 0)
  3912. timeFormat := tempTime.Format("20060102150405")
  3913. chrgBchno := rand.Intn(100000) + 10000
  3914. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3915. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3916. var patientPrescription models.HisPrescriptionInfo
  3917. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3918. if patientPrescription.ID == 0 {
  3919. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3920. }
  3921. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3922. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3923. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3924. strconv.FormatInt(his.PatientId, 10)
  3925. var res2 ResultSix
  3926. if miConfig.InsuplcAdmdvs == "421300" {
  3927. data := make(map[string]interface{})
  3928. client := &http.Client{}
  3929. data["psn_no"] = his.PsnNo
  3930. data["mdtrt_id"] = his.Number
  3931. data["doctor"] = roles.UserName
  3932. data["department"] = department.Name
  3933. data["org_name"] = miConfig.OrgName
  3934. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3935. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3936. data["fixmedins_code"] = miConfig.Code
  3937. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3938. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3939. data["secret_key"] = miConfig.SecretKey
  3940. data["sick_code"] = sickConfig.CountryCode
  3941. data["sick_name"] = sickConfig.ClassName
  3942. data["dept"] = strconv.FormatInt(department.ID, 10)
  3943. data["config"] = config
  3944. fmt.Println(data)
  3945. bytesData, _ := json.Marshal(data)
  3946. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3947. resp, _ := client.Do(req)
  3948. defer resp.Body.Close()
  3949. body, ioErr := ioutil.ReadAll(resp.Body)
  3950. if ioErr != nil {
  3951. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3953. return
  3954. }
  3955. var respJSON map[string]interface{}
  3956. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3957. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3959. return
  3960. }
  3961. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3962. userJSONBytes, _ := json.Marshal(respJSON)
  3963. fmt.Println("log")
  3964. fmt.Println(string(userJSONBytes))
  3965. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3966. utils.ErrorLog("解析失败:%v", err)
  3967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3968. return
  3969. }
  3970. } else {
  3971. var result string
  3972. var requestLog string
  3973. if miConfig.InsuplcAdmdvs == "440781" { //
  3974. 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)
  3975. } else {
  3976. 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)
  3977. saveLog(result, requestLog, "2203", "上传就诊信息")
  3978. var respJSON2 map[string]interface{}
  3979. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3982. return
  3983. }
  3984. userJSONBytes2, _ := json.Marshal(respJSON2)
  3985. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3986. utils.ErrorLog("解析失败:%v", err)
  3987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3988. return
  3989. }
  3990. }
  3991. }
  3992. if res2.Infcode != 0 {
  3993. adminUser := c.GetAdminUserInfo()
  3994. errlog := &models.HisOrderError{
  3995. UserOrgId: adminUser.CurrentOrgId,
  3996. Ctime: time.Now().Unix(),
  3997. Mtime: time.Now().Unix(),
  3998. ErrMsg: res2.ErrMsg,
  3999. Status: 1,
  4000. PatientId: id,
  4001. RecordTime: recordDateTime,
  4002. Stage: 3,
  4003. }
  4004. service.CreateErrMsgLog(errlog)
  4005. c.ServeSuccessJSON(map[string]interface{}{
  4006. "failed_code": -10,
  4007. "msg": res2.ErrMsg,
  4008. })
  4009. return
  4010. } else {
  4011. his.Diagnosis = diagnosis_id
  4012. his.SickType = sickConfig.ID
  4013. his.PType = fmt.Sprintf("%d", reg_type)
  4014. service.UpdateHisPatientThree(&his)
  4015. data := make(map[string]interface{})
  4016. if settle_accounts_type == 1 { //日结
  4017. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4018. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4019. } else {
  4020. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4021. }
  4022. data["pre"] = prescriptions
  4023. } else { //月结
  4024. start_time_str := c.GetString("start_time")
  4025. end_time_str := c.GetString("end_time")
  4026. timeLayout := "2006-01-02"
  4027. loc, _ := time.LoadLocation("Local")
  4028. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4029. if err != nil {
  4030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4031. return
  4032. }
  4033. recordStartTime := theStartTime.Unix()
  4034. start_time = recordStartTime
  4035. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4036. if err != nil {
  4037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4038. return
  4039. }
  4040. recordEndTime := theEndTime.Unix()
  4041. end_time = recordEndTime
  4042. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4043. data["pre"] = prescriptions
  4044. }
  4045. client := &http.Client{}
  4046. data["psn_no"] = his.PsnNo
  4047. data["mdtrt_id"] = his.Number
  4048. data["chrg_bchno"] = chrg_bchno
  4049. data["org_name"] = miConfig.OrgName
  4050. data["doctor"] = roles.UserName
  4051. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4052. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4053. data["fixmedins_code"] = miConfig.Code
  4054. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4055. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4056. data["dept_code"] = "15"
  4057. } else {
  4058. data["dept_code"] = department.Number
  4059. }
  4060. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4061. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4062. data["secret_key"] = miConfig.SecretKey
  4063. var ids []int64
  4064. for _, item := range prescriptions {
  4065. ids = append(ids, item.ID)
  4066. }
  4067. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4068. if config.IsOpen == 1 { //对接了医保,走医保流程
  4069. var res ResultFour
  4070. if miConfig.MdtrtareaAdmvs == "421300" {
  4071. bytesData, _ := json.Marshal(data)
  4072. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4073. resp, _ := client.Do(req)
  4074. defer resp.Body.Close()
  4075. body, ioErr := ioutil.ReadAll(resp.Body)
  4076. if ioErr != nil {
  4077. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4079. return
  4080. }
  4081. var respJSON map[string]interface{}
  4082. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4083. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4085. return
  4086. }
  4087. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4088. userJSONBytes, _ := json.Marshal(respJSON)
  4089. fmt.Println("log")
  4090. fmt.Println(string(userJSONBytes))
  4091. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4092. utils.ErrorLog("解析失败:%v", err)
  4093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4094. return
  4095. }
  4096. } else {
  4097. 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))
  4098. var dat map[string]interface{}
  4099. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4100. fmt.Println(dat)
  4101. } else {
  4102. fmt.Println(err)
  4103. }
  4104. saveLog(result, request_log, "2204", "上传费用明细")
  4105. userJSONBytes, _ := json.Marshal(dat)
  4106. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4107. utils.ErrorLog("解析失败:%v", err)
  4108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4109. return
  4110. }
  4111. }
  4112. if res.Infcode == 0 {
  4113. order := &models.HisOrder{
  4114. UserOrgId: adminUser.CurrentOrgId,
  4115. HisPatientId: his.ID,
  4116. PatientId: his.PatientId,
  4117. SettleAccountsDate: recordDateTime,
  4118. Ctime: time.Now().Unix(),
  4119. Mtime: time.Now().Unix(),
  4120. Status: 1,
  4121. Number: chrg_bchno,
  4122. Infcode: res.Infcode,
  4123. WarnMsg: res.WarnMsg,
  4124. Cainfo: res.Cainfo,
  4125. ErrMsg: res.ErrMsg,
  4126. RespondTime: res.RefmsgTime,
  4127. InfRefmsgid: res.InfRefmsgid,
  4128. OrderStatus: 1,
  4129. IsMedicineInsurance: 1,
  4130. SettleType: settle_accounts_type,
  4131. SettleStartTime: start_time,
  4132. SettleEndTime: end_time,
  4133. Creator: roles.AdminUserId,
  4134. Modify: roles.AdminUserId,
  4135. PType: 2,
  4136. Diagnosis: diagnosis_id,
  4137. }
  4138. err = service.CreateOrder(order)
  4139. if err != nil {
  4140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4141. return
  4142. }
  4143. for _, item := range res.Output.Result {
  4144. temp := strings.Split(item.FeedetlSn, "-")
  4145. var advice_id int64 = 0
  4146. var project_id int64 = 0
  4147. var types int64 = 0
  4148. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4149. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4150. if temp[1] == "1" {
  4151. advice_id = id
  4152. project_id = 0
  4153. } else if temp[1] == "2" {
  4154. advice_id = 0
  4155. project_id = id
  4156. }
  4157. info := &models.HisOrderInfo{
  4158. OrderNumber: order.Number,
  4159. FeedetlSn: item.FeedetlSn,
  4160. UploadDate: time.Now().Unix(),
  4161. AdviceId: advice_id,
  4162. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4163. Cnt: item.Cnt,
  4164. Pric: float64(item.Pric),
  4165. PatientId: his.PatientId,
  4166. PricUplmtAmt: item.PricUplmtAmt,
  4167. SelfpayProp: item.SelfpayProp,
  4168. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4169. OverlmtAmt: item.OverlmtAmt,
  4170. PreselfpayAmt: item.PreselfpayAmt,
  4171. BasMednFlag: item.BasMednFlag,
  4172. MedChrgitmType: item.MedChrgitmType,
  4173. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4174. Status: 1,
  4175. Memo: item.Memo,
  4176. Mtime: time.Now().Unix(),
  4177. InscpScpAmt: item.InscpScpAmt,
  4178. DrtReimFlag: item.DrtReimFlag,
  4179. Ctime: time.Now().Unix(),
  4180. ListSpItemFlag: item.ListSpItemFlag,
  4181. ChldMedcFlag: item.ChldMedcFlag,
  4182. LmtUsedFlag: item.LmtUsedFlag,
  4183. ChrgitmLv: item.ChrgitmLv,
  4184. UserOrgId: adminUser.CurrentOrgId,
  4185. HisPatientId: his.ID,
  4186. OrderId: order.ID,
  4187. ProjectId: project_id,
  4188. Type: types,
  4189. }
  4190. service.CreateOrderInfo(info)
  4191. }
  4192. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4193. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4194. var total float64
  4195. for _, item := range prescriptions {
  4196. if item.Type == 1 { //药品
  4197. for _, subItem := range item.HisDoctorAdviceInfo {
  4198. total = total + (subItem.Price * subItem.PrescribingNumber)
  4199. }
  4200. }
  4201. if item.Type == 2 { //项目
  4202. for _, subItem := range item.HisPrescriptionProject {
  4203. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4204. total = total + (subItem.Price * cnt)
  4205. }
  4206. }
  4207. }
  4208. for _, item := range prescriptions {
  4209. for _, subItem := range item.HisAdditionalCharge {
  4210. total = total + (subItem.Price * float64(subItem.Count))
  4211. }
  4212. }
  4213. allTotal := fmt.Sprintf("%.4f", total)
  4214. if res.Infcode == 0 {
  4215. var rf []*ResultFive
  4216. json.Unmarshal([]byte(his.Iinfo), &rf)
  4217. chrg_bchno := chrg_bchno
  4218. cert_no := his.Certno
  4219. var insutypes []string
  4220. var insutype string
  4221. var is390 int = 0
  4222. var is310 int = 0
  4223. for _, item := range rf {
  4224. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4225. insutypes = append(insutypes, item.Insutype)
  4226. }
  4227. }
  4228. if len(insutypes) == 1 {
  4229. insutype = insutypes[0]
  4230. } else {
  4231. for _, i := range insutypes {
  4232. if i == "390" {
  4233. is390 = 1
  4234. }
  4235. if i == "310" {
  4236. is310 = 1
  4237. }
  4238. }
  4239. }
  4240. if is390 == 1 {
  4241. insutype = "390"
  4242. }
  4243. if is310 == 1 {
  4244. insutype = "310"
  4245. }
  4246. if len(insutypes) == 0 {
  4247. insutype = "310"
  4248. }
  4249. if len(insutypes) == 2 {
  4250. insutype = strconv.FormatInt(his.SocialType, 64)
  4251. }
  4252. //insutype = "390"
  4253. if his.IdCardType == 1 {
  4254. cert_no = his.MedicalInsuranceNumber
  4255. } else {
  4256. cert_no = his.Certno
  4257. }
  4258. var res ResultSeven
  4259. if miConfig.MdtrtareaAdmvs == "421300" {
  4260. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4261. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4262. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4263. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4264. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4265. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4266. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  4267. resp, requestErr := http.Get(api)
  4268. if requestErr != nil {
  4269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4270. return
  4271. }
  4272. body, ioErr := ioutil.ReadAll(resp.Body)
  4273. if ioErr != nil {
  4274. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4276. return
  4277. }
  4278. var respJSON map[string]interface{}
  4279. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4280. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4282. return
  4283. }
  4284. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4285. result, _ := json.Marshal(respJSON)
  4286. fmt.Println("log")
  4287. fmt.Println(string(result))
  4288. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4289. utils.ErrorLog("解析失败:%v", err)
  4290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4291. return
  4292. }
  4293. } else {
  4294. 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)
  4295. var dat map[string]interface{}
  4296. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4297. fmt.Println(dat)
  4298. } else {
  4299. fmt.Println(err)
  4300. }
  4301. saveLog(result, request_log, "2206", "预结算")
  4302. userJSONBytes, _ := json.Marshal(dat)
  4303. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4304. utils.ErrorLog("解析失败:%v", err)
  4305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4306. return
  4307. }
  4308. }
  4309. if res.Infcode != 0 {
  4310. errlog := &models.HisOrderError{
  4311. UserOrgId: adminUser.CurrentOrgId,
  4312. Ctime: time.Now().Unix(),
  4313. Mtime: time.Now().Unix(),
  4314. Number: chrg_bchno,
  4315. ErrMsg: res.ErrMsg,
  4316. Status: 1,
  4317. PatientId: id,
  4318. RecordTime: recordDateTime,
  4319. Stage: 20,
  4320. }
  4321. service.CreateErrMsgLog(errlog)
  4322. c.ServeSuccessJSON(map[string]interface{}{
  4323. "failed_code": -10,
  4324. "msg": res.ErrMsg,
  4325. })
  4326. return
  4327. } else {
  4328. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4329. order.OrderStatus = 1
  4330. order.IsPre = 1
  4331. order.Status = 1
  4332. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4333. order.SetlId = res.Output.Setlinfo.SetlID
  4334. order.PsnNo = res.Output.Setlinfo.PsnNo
  4335. order.PsnName = res.Output.Setlinfo.PsnName
  4336. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4337. order.Certno = res.Output.Setlinfo.Certno
  4338. order.Gend = res.Output.Setlinfo.Gend
  4339. order.Naty = res.Output.Setlinfo.Naty
  4340. order.Age = res.Output.Setlinfo.Age
  4341. order.Insutype = res.Output.Setlinfo.Insutype
  4342. order.PsnType = res.Output.Setlinfo.PsnType
  4343. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4344. order.SetlTime = res.Output.Setlinfo.SetlTime
  4345. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4346. if res.Output.Setlinfo.MedType == "140101" {
  4347. order.MedType = "14"
  4348. } else {
  4349. order.MedType = res.Output.Setlinfo.MedType
  4350. }
  4351. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4352. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4353. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4354. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4355. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4356. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4357. order.HifpPay = res.Output.Setlinfo.HifpPay
  4358. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4359. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4360. order.HifesPay = res.Output.Setlinfo.HifesPay
  4361. order.HifobPay = res.Output.Setlinfo.HifobPay
  4362. order.MafPay = res.Output.Setlinfo.MafPay
  4363. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4364. order.OthPay = res.Output.Setlinfo.OthPay
  4365. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4366. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4367. order.AcctPay = res.Output.Setlinfo.AcctPay
  4368. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4369. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4370. order.Balc = res.Output.Setlinfo.Balc
  4371. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4372. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4373. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4374. order.ClrWay = res.Output.Setlinfo.ClrWay
  4375. order.Creator = order.Creator
  4376. order.Modify = roles.AdminUserId
  4377. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4378. detailStr := string(setlDetail)
  4379. order.SetlDetail = detailStr
  4380. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4381. err = service.UpDateOrder(order)
  4382. if err == nil {
  4383. c.ServeSuccessJSON(map[string]interface{}{
  4384. "msg": "预结算成功",
  4385. })
  4386. } else {
  4387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4388. return
  4389. }
  4390. }
  4391. } else {
  4392. adminUser := c.GetAdminUserInfo()
  4393. errlog := &models.HisOrderError{
  4394. UserOrgId: adminUser.CurrentOrgId,
  4395. Ctime: time.Now().Unix(),
  4396. Mtime: time.Now().Unix(),
  4397. ErrMsg: res.ErrMsg,
  4398. Status: 1,
  4399. PatientId: id,
  4400. RecordTime: recordDateTime,
  4401. Stage: 4,
  4402. }
  4403. service.CreateErrMsgLog(errlog)
  4404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4405. return
  4406. }
  4407. } else {
  4408. adminUser := c.GetAdminUserInfo()
  4409. errlog := &models.HisOrderError{
  4410. UserOrgId: adminUser.CurrentOrgId,
  4411. Ctime: time.Now().Unix(),
  4412. Mtime: time.Now().Unix(),
  4413. ErrMsg: res.ErrMsg,
  4414. Status: 1,
  4415. PatientId: id,
  4416. RecordTime: recordDateTime,
  4417. Stage: 4,
  4418. }
  4419. service.CreateErrMsgLog(errlog)
  4420. c.ServeSuccessJSON(map[string]interface{}{
  4421. "failed_code": -10,
  4422. "msg": res.ErrMsg,
  4423. })
  4424. return
  4425. }
  4426. }
  4427. }
  4428. }
  4429. //func (c *HisApiController) GetSettleInfo() {
  4430. // id, _ := c.GetInt64("id")
  4431. // order_id, _ := c.GetInt64("order_id")
  4432. //
  4433. // record_time := c.GetString("record_time")
  4434. // pay_way, _ := c.GetInt64("pay_way")
  4435. // pay_price, _ := c.GetFloat("pay_price")
  4436. // pay_card_no := c.GetString("pay_card_no")
  4437. // discount_price, _ := c.GetFloat("discount_price")
  4438. // preferential_price, _ := c.GetFloat("preferential_price")
  4439. // reality_price, _ := c.GetFloat("reality_price")
  4440. // found_price, _ := c.GetFloat("found_price")
  4441. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4442. // private_price, _ := c.GetFloat("private_price")
  4443. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4444. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4445. //
  4446. // timeLayout := "2006-01-02"
  4447. // loc, _ := time.LoadLocation("Local")
  4448. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4449. // if err != nil {
  4450. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4451. // return
  4452. // }
  4453. // recordDateTime := theTime.Unix()
  4454. // adminUser := c.GetAdminUserInfo()
  4455. //
  4456. // var prescriptions []*models.HisPrescription
  4457. //
  4458. // data := make(map[string]interface{})
  4459. // if settle_accounts_type == 1 { //日结
  4460. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  4461. // data["pre"] = prescriptions
  4462. //
  4463. // } else { //月结
  4464. // start_time_str := c.GetString("start_time")
  4465. // end_time_str := c.GetString("end_time")
  4466. // timeLayout := "2006-01-02"
  4467. // loc, _ := time.LoadLocation("Local")
  4468. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4469. // if err != nil {
  4470. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4471. // return
  4472. // }
  4473. // recordStartTime := theStartTime.Unix()
  4474. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4475. // if err != nil {
  4476. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4477. // return
  4478. // }
  4479. // recordEndTime := theEndTime.Unix()
  4480. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  4481. // data["pre"] = prescriptions
  4482. //
  4483. // }
  4484. //
  4485. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4486. //
  4487. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4488. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4489. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4490. // strconv.FormatInt(his.PatientId, 10)
  4491. //
  4492. // order_src, _ := service.GetHisOrderByID(order_id)
  4493. //
  4494. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4495. // if config.IsOpen == 1 { //对接了医保,走医保流程
  4496. //
  4497. // var total float64
  4498. // for _, item := range prescriptions {
  4499. // if item.Type == 1 { //药品
  4500. // for _, subItem := range item.HisDoctorAdviceInfo {
  4501. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4502. // }
  4503. // }
  4504. // if item.Type == 2 { //项目
  4505. // for _, subItem := range item.HisPrescriptionProject {
  4506. // total = total + (subItem.Price * float64(subItem.Count))
  4507. // }
  4508. // }
  4509. // }
  4510. //
  4511. // for _, item := range prescriptions {
  4512. // for _, subItem := range item.HisAdditionalCharge {
  4513. // total = total + (subItem.Price * float64(subItem.Count))
  4514. // }
  4515. // }
  4516. //
  4517. // allTotal := fmt.Sprintf("%.2f", total)
  4518. // var rf []*ResultFive
  4519. // json.Unmarshal([]byte(his.Iinfo), &rf)
  4520. // psn_no := order_src.PsnNo
  4521. // mdtrt_id := order_src.MdtrtId
  4522. // chrg_bchno := order_src.Number
  4523. // cert_no := order_src.Certno
  4524. // insutype := rf[0].Insutype
  4525. //
  4526. // if his.IdCardType == 1 {
  4527. // cert_no = his.MedicalInsuranceNumber
  4528. // } else {
  4529. // cert_no = his.Certno
  4530. // }
  4531. //
  4532. // 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)
  4533. // var dat map[string]interface{}
  4534. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4535. // fmt.Println(dat)
  4536. // } else {
  4537. // fmt.Println(err)
  4538. // }
  4539. //
  4540. // userJSONBytes, _ := json.Marshal(dat)
  4541. //
  4542. //
  4543. //
  4544. // var res ResultSeven
  4545. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4546. // utils.ErrorLog("解析失败:%v", err)
  4547. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4548. // return
  4549. // }
  4550. // if res.Infcode == -1 {
  4551. // errlog := &models.HisOrderError{
  4552. // UserOrgId: adminUser.CurrentOrgId,
  4553. // Ctime: time.Now().Unix(),
  4554. // Mtime: time.Now().Unix(),
  4555. // Number: chrg_bchno,
  4556. // ErrMsg: res.ErrMsg,
  4557. // Status: 1,
  4558. // PatientId: id,
  4559. // RecordTime: recordDateTime,
  4560. // Stage: 6,
  4561. // }
  4562. // service.CreateErrMsgLog(errlog)
  4563. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4564. // return
  4565. // } else {
  4566. // order_src.OrderStatus = 2
  4567. // order_src.PayWay = pay_way
  4568. // order_src.PayPrice = pay_price
  4569. // order_src.PayCardNo = pay_card_no
  4570. // order_src.DiscountPrice = discount_price
  4571. // order_src.PreferentialPrice = preferential_price
  4572. // order_src.RealityPrice = reality_price
  4573. // order_src.FoundPrice = found_price
  4574. // order_src.MedicalInsurancePrice = medical_insurance_price
  4575. // order_src.PrivatePrice = private_price
  4576. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  4577. // order_src.SetlId = res.Output.Setlinfo.SetlID
  4578. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  4579. // order_src.PsnName = res.Output.Setlinfo.PsnName
  4580. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  4581. // order_src.Certno = res.Output.Setlinfo.Certno
  4582. // order_src.Gend = res.Output.Setlinfo.Gend
  4583. // order_src.Naty = res.Output.Setlinfo.Naty
  4584. // order_src.Age = res.Output.Setlinfo.Age
  4585. // order_src.Insutype = res.Output.Setlinfo.Insutype
  4586. // order_src.PsnType = res.Output.Setlinfo.PsnType
  4587. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4588. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  4589. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4590. // order_src.MedType = res.Output.Setlinfo.MedType
  4591. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4592. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4593. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4594. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4595. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4596. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4597. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  4598. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  4599. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4600. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  4601. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  4602. // order_src.MafPay = res.Output.Setlinfo.MafPay
  4603. // order_src.OthPay = res.Output.Setlinfo.OthPay
  4604. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4605. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4606. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  4607. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4608. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4609. // order_src.Balc = res.Output.Setlinfo.Balc
  4610. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4611. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4612. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  4613. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  4614. // order_src.Creator = order_src.Creator
  4615. // order_src.Modify = roles.ID
  4616. // order_src.RequestLog = src_resquest
  4617. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4618. // detailStr := string(setlDetail)
  4619. // order_src.SetlDetail = detailStr
  4620. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4621. // err = service.UpDateOrder(order_src)
  4622. //
  4623. // if err == nil {
  4624. // c.ServeSuccessJSON(map[string]interface{}{
  4625. // "msg": "结算成功",
  4626. // })
  4627. // } else {
  4628. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4629. // return
  4630. // }
  4631. // }
  4632. // }
  4633. //}
  4634. //退款
  4635. func (c *HisApiController) Refund() {
  4636. order_id, _ := c.GetInt64("order_id")
  4637. admin_user_id, _ := c.GetInt64("admin_user_id")
  4638. //record_time := c.GetString("record_time")
  4639. //patient_id, _ := c.GetInt64("patient_id")
  4640. //timeLayout := "2006-01-02"
  4641. //loc, _ := time.LoadLocation("Local")
  4642. adminUser := c.GetAdminUserInfo()
  4643. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4644. //if err != nil {
  4645. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4646. // return
  4647. //}
  4648. //recordDateTime := theTime.Unix()
  4649. var order models.HisOrder
  4650. order, _ = service.GetHisOrderByID(order_id)
  4651. //his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4652. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4653. if order.ID == 0 {
  4654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4655. return
  4656. //order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  4657. }
  4658. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4659. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4660. if config.IsOpen == 1 { //对接了医保,走医保流程
  4661. var res ResultSixteen
  4662. var src_resquest string
  4663. var result string
  4664. if miConfig.MdtrtareaAdmvs == "421300" {
  4665. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  4666. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  4667. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  4668. resp3, requestErr3 := http.Get(api3)
  4669. if requestErr3 != nil {
  4670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4671. return
  4672. }
  4673. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  4674. if ioErr3 != nil {
  4675. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  4676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4677. return
  4678. }
  4679. var respJSON3 map[string]interface{}
  4680. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  4681. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4683. return
  4684. }
  4685. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4686. userJSONBytes3, _ := json.Marshal(respJSON3)
  4687. fmt.Println("log")
  4688. fmt.Println(string(userJSONBytes3))
  4689. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  4690. utils.ErrorLog("解析失败:%v", err)
  4691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4692. return
  4693. }
  4694. } else {
  4695. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  4696. var dat map[string]interface{}
  4697. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4698. fmt.Println(dat)
  4699. } else {
  4700. fmt.Println(err)
  4701. }
  4702. saveLog(result, src_resquest, "2208", "退费")
  4703. userJSONBytes, _ := json.Marshal(dat)
  4704. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4705. utils.ErrorLog("解析失败:%v", err)
  4706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4707. return
  4708. }
  4709. }
  4710. if res.Infcode == 0 {
  4711. var res2 ResultSix
  4712. if miConfig.MdtrtareaAdmvs == "421300" {
  4713. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  4714. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  4715. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  4716. resp3, requestErr3 := http.Get(api3)
  4717. if requestErr3 != nil {
  4718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4719. return
  4720. }
  4721. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  4722. if ioErr3 != nil {
  4723. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  4724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4725. return
  4726. }
  4727. var respJSON3 map[string]interface{}
  4728. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  4729. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4731. return
  4732. }
  4733. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4734. userJSONBytes3, _ := json.Marshal(respJSON3)
  4735. fmt.Println("log")
  4736. fmt.Println(string(userJSONBytes3))
  4737. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  4738. utils.ErrorLog("解析失败:%v", err)
  4739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4740. return
  4741. }
  4742. } else {
  4743. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  4744. var dat map[string]interface{}
  4745. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4746. fmt.Println(dat)
  4747. } else {
  4748. fmt.Println(err)
  4749. }
  4750. saveLog(result2, src_request, "2205", "撤销明细")
  4751. userJSONBytes, _ := json.Marshal(dat)
  4752. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4753. utils.ErrorLog("解析失败:%v", err)
  4754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4755. return
  4756. }
  4757. }
  4758. if res2.Infcode == 0 {
  4759. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  4760. if err == nil {
  4761. c.ServeSuccessJSON(map[string]interface{}{
  4762. "msg": "退费成功",
  4763. })
  4764. } else {
  4765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4766. return
  4767. }
  4768. } else {
  4769. c.ServeSuccessJSON(map[string]interface{}{
  4770. "code": -10,
  4771. "msg": res2.ErrMsg,
  4772. })
  4773. }
  4774. } else {
  4775. c.ServeSuccessJSON(map[string]interface{}{
  4776. "code": -10,
  4777. "msg": res.ErrMsg,
  4778. })
  4779. }
  4780. }
  4781. }
  4782. func (c *HisApiController) RefundNumber() {
  4783. record_time := c.GetString("record_time")
  4784. //patient_id, _ := c.GetInt64("patient_id")
  4785. admin_user_id, _ := c.GetInt64("admin_user_id")
  4786. his_patient_id, _ := c.GetInt64("id")
  4787. timeLayout := "2006-01-02"
  4788. loc, _ := time.LoadLocation("Local")
  4789. adminUser := c.GetAdminUserInfo()
  4790. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4791. fmt.Println(err)
  4792. if err != nil {
  4793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4794. return
  4795. }
  4796. recordDateTime := theTime.Unix()
  4797. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4798. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  4799. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4800. //order, _ := service.GetHisOrderByID(order_id)
  4801. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4802. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4803. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4804. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  4805. if count > 0 {
  4806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  4807. return
  4808. }
  4809. if config.IsOpen == 1 { //对接了医保,走医保流程
  4810. var res2 ResultSix
  4811. if miConfig.MdtrtareaAdmvs == "421300" {
  4812. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  4813. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  4814. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  4815. resp3, requestErr3 := http.Get(api3)
  4816. if requestErr3 != nil {
  4817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4818. return
  4819. }
  4820. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  4821. if ioErr3 != nil {
  4822. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  4823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4824. return
  4825. }
  4826. var respJSON3 map[string]interface{}
  4827. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  4828. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4830. return
  4831. }
  4832. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4833. userJSONBytes3, _ := json.Marshal(respJSON3)
  4834. fmt.Println("log")
  4835. fmt.Println(string(userJSONBytes3))
  4836. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  4837. utils.ErrorLog("解析失败:%v", err)
  4838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4839. return
  4840. }
  4841. } else {
  4842. api3 := "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  4843. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  4844. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  4845. resp3, requestErr3 := http.Get(api3)
  4846. if requestErr3 != nil {
  4847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4848. return
  4849. }
  4850. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  4851. if ioErr3 != nil {
  4852. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  4853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4854. return
  4855. }
  4856. var respJSON3 map[string]interface{}
  4857. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  4858. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4860. return
  4861. }
  4862. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4863. userJSONBytes3, _ := json.Marshal(respJSON3)
  4864. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  4865. utils.ErrorLog("解析失败:%v", err)
  4866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4867. return
  4868. }
  4869. }
  4870. if res2.Infcode == 0 {
  4871. if err == nil {
  4872. c.ServeSuccessJSON(map[string]interface{}{
  4873. "msg": "退号成功",
  4874. })
  4875. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  4876. } else {
  4877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4878. return
  4879. }
  4880. } else {
  4881. c.ServeSuccessJSON(map[string]interface{}{
  4882. "code": -10,
  4883. "msg": res2.ErrMsg,
  4884. })
  4885. }
  4886. } else {
  4887. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  4888. //if err == nil {
  4889. // c.ServeSuccessJSON(map[string]interface{}{
  4890. // "msg": "退费成功",
  4891. // })
  4892. //} else {
  4893. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4894. // return
  4895. //}
  4896. }
  4897. }
  4898. func (c *HisApiController) RefundDetail() {
  4899. order_id, _ := c.GetInt64("order_id")
  4900. //his_patient_id, _ := c.GetInt64("his_patient_id")
  4901. number := c.GetString("number")
  4902. record_time := c.GetString("record_time")
  4903. patient_id, _ := c.GetInt64("patient_id")
  4904. timeLayout := "2006-01-02"
  4905. loc, _ := time.LoadLocation("Local")
  4906. adminUser := c.GetAdminUserInfo()
  4907. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4908. fmt.Println(err)
  4909. if err != nil {
  4910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4911. return
  4912. }
  4913. recordDateTime := theTime.Unix()
  4914. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4915. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4916. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4917. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4918. var order models.HisOrder
  4919. order, _ = service.GetHisOrderByID(order_id)
  4920. if order.ID == 0 {
  4921. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  4922. }
  4923. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4924. if config.IsOpen == 1 { //对接了医保,走医保流程
  4925. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  4926. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  4927. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  4928. resp2, requestErr2 := http.Get(api2)
  4929. if requestErr2 != nil {
  4930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4931. return
  4932. }
  4933. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  4934. if ioErr2 != nil {
  4935. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  4936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4937. return
  4938. }
  4939. var respJSON2 map[string]interface{}
  4940. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  4941. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4943. return
  4944. }
  4945. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  4946. if err == nil {
  4947. c.ServeSuccessJSON(map[string]interface{}{
  4948. "msg": "退费成功",
  4949. })
  4950. } else {
  4951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4952. return
  4953. }
  4954. } else {
  4955. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  4956. if err == nil {
  4957. c.ServeSuccessJSON(map[string]interface{}{
  4958. "msg": "退费成功",
  4959. })
  4960. } else {
  4961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4962. return
  4963. }
  4964. }
  4965. }
  4966. //对账
  4967. func (c *HisApiController) GetCheckAccount() {
  4968. start_time := c.GetString("start_time")
  4969. end_time := c.GetString("end_time")
  4970. insutype := c.GetString("insutype")
  4971. clr_type := c.GetString("clr_type")
  4972. admin_user_id, _ := c.GetInt64("admin_user_id")
  4973. adminUser := c.GetAdminUserInfo()
  4974. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4975. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4976. timeLayout := "2006-01-02"
  4977. loc, _ := time.LoadLocation("Local")
  4978. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  4979. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  4980. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  4981. //orders_two, _ := service.GetOrderByTimeThree(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  4982. fixmedins_setl_cnt := int64(len(orders))
  4983. //
  4984. ////撤销的算2条数据为一笔
  4985. //for _, item := range orders_two {
  4986. // if item.OrderStatus == 3 {
  4987. // fixmedins_setl_cnt = fixmedins_setl_cnt + 1
  4988. // }
  4989. //}
  4990. var medfee_sumamt float64
  4991. var acct_pay float64
  4992. var fund_pay_sumamt float64
  4993. for _, item := range orders {
  4994. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  4995. acct_pay = acct_pay + item.AcctPay
  4996. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  4997. }
  4998. var user_name string
  4999. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5000. if role.ID == 0 {
  5001. user_name = "xxx"
  5002. } else {
  5003. user_name = role.UserName
  5004. }
  5005. if config.IsOpen == 1 {
  5006. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  5007. "insutype=" + insutype +
  5008. "&clr_type=" + clr_type +
  5009. "&setl_optins=" + "定点医保中心" +
  5010. "&stmt_begndate=" + start_time +
  5011. "&stm_enddate=" + end_time +
  5012. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  5013. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  5014. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  5015. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  5016. "&fixmedins_code=" + miConfig.Code +
  5017. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5018. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5019. "&secret_key=" + miConfig.SecretKey +
  5020. "&org_name=" + miConfig.OrgName +
  5021. "&doctor=" + user_name
  5022. fmt.Println(api)
  5023. resp, requestErr := http.Get(api)
  5024. if requestErr != nil {
  5025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5026. return
  5027. }
  5028. body, ioErr := ioutil.ReadAll(resp.Body)
  5029. fmt.Println(body)
  5030. if ioErr != nil {
  5031. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5033. return
  5034. }
  5035. var respJSON map[string]interface{}
  5036. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5037. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5039. return
  5040. }
  5041. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5042. userJSONBytes, _ := json.Marshal(respJSON)
  5043. var res ResultEight
  5044. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5045. utils.ErrorLog("解析失败:%v", err)
  5046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5047. return
  5048. }
  5049. if res.Infcode == 0 {
  5050. if res.Output.Stmtinfo.StmtRslt == "0" {
  5051. micc := &models.MedicalInsuranceCostCompare{
  5052. StartTime: startime.Unix(),
  5053. EndTime: endtime.Unix(),
  5054. Insutype: insutype,
  5055. CheckType: 1,
  5056. Num: fixmedins_setl_cnt,
  5057. Mtime: time.Now().Unix(),
  5058. Status: 1,
  5059. UserOrgId: adminUser.CurrentOrgId,
  5060. CostTotal: medfee_sumamt,
  5061. FuncTotal: fund_pay_sumamt,
  5062. PsnPay: acct_pay,
  5063. Creator: admin_user_id,
  5064. Ctime: time.Now().Unix(),
  5065. }
  5066. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  5067. if err == nil {
  5068. c.ServeSuccessJSON(map[string]interface{}{
  5069. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  5070. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  5071. })
  5072. } else {
  5073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5074. }
  5075. } else {
  5076. c.ServeSuccessJSON(map[string]interface{}{
  5077. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  5078. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  5079. })
  5080. }
  5081. } else {
  5082. c.ServeSuccessJSON(map[string]interface{}{
  5083. "code": -10,
  5084. "msg": res.ErrMsg,
  5085. })
  5086. }
  5087. }
  5088. }
  5089. func (c *HisApiController) Check310() {
  5090. adminUser := c.GetAdminUserInfo()
  5091. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5092. var user_name string
  5093. user_name = "xxx"
  5094. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  5095. "insutype=" + "310" +
  5096. "&clr_type=" + "11" +
  5097. "&setl_optins=" + "定点医保中心" +
  5098. "&stmt_begndate=" + "2021-03-01" +
  5099. "&stm_enddate=" + "2021-03-31" +
  5100. "&medfee_sumamt=" + "11521" +
  5101. "&fund_pay_sumamt=" + "10166.66" +
  5102. "&acct_pay=" + "0" +
  5103. "&fixmedins_setl_cnt=" + "7" +
  5104. "&fixmedins_code=" + miConfig.Code +
  5105. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5106. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5107. "&secret_key=" + miConfig.SecretKey +
  5108. "&org_name=" + miConfig.OrgName +
  5109. "&doctor=" + user_name
  5110. fmt.Println(api)
  5111. resp, requestErr := http.Get(api)
  5112. if requestErr != nil {
  5113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5114. return
  5115. }
  5116. body, ioErr := ioutil.ReadAll(resp.Body)
  5117. fmt.Println(body)
  5118. if ioErr != nil {
  5119. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5121. return
  5122. }
  5123. var respJSON map[string]interface{}
  5124. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5127. return
  5128. }
  5129. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5130. userJSONBytes, _ := json.Marshal(respJSON)
  5131. var res ResultEight
  5132. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5133. utils.ErrorLog("解析失败:%v", err)
  5134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5135. return
  5136. }
  5137. }
  5138. func (c *HisApiController) Check390() {
  5139. adminUser := c.GetAdminUserInfo()
  5140. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5141. var user_name string
  5142. user_name = "张俊杰"
  5143. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  5144. "insutype=" + "390" +
  5145. "&clr_type=" + "11" +
  5146. "&setl_optins=" + "定点医保中心" +
  5147. "&stmt_begndate=" + "2021-03-01" +
  5148. "&stm_enddate=" + "2021-03-31" +
  5149. "&medfee_sumamt=" + "209318.43" +
  5150. "&fund_pay_sumamt=" + "188029.12" +
  5151. "&acct_pay=" + "0" +
  5152. "&fixmedins_setl_cnt=" + "48" +
  5153. "&fixmedins_code=" + miConfig.Code +
  5154. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5155. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5156. "&secret_key=" + miConfig.SecretKey +
  5157. "&org_name=" + miConfig.OrgName +
  5158. "&doctor=" + user_name
  5159. fmt.Println(api)
  5160. resp, requestErr := http.Get(api)
  5161. if requestErr != nil {
  5162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5163. return
  5164. }
  5165. body, ioErr := ioutil.ReadAll(resp.Body)
  5166. fmt.Println(body)
  5167. if ioErr != nil {
  5168. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5170. return
  5171. }
  5172. var respJSON map[string]interface{}
  5173. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5176. return
  5177. }
  5178. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5179. userJSONBytes, _ := json.Marshal(respJSON)
  5180. var res ResultEight
  5181. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5182. utils.ErrorLog("解析失败:%v", err)
  5183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5184. return
  5185. }
  5186. }
  5187. //对账明细
  5188. func (c *HisApiController) GetCheckDetailAccount() {
  5189. start_time := c.GetString("start_time")
  5190. end_time := c.GetString("end_time")
  5191. admin_user_id, _ := c.GetInt64("admin_user_id")
  5192. adminUser := c.GetAdminUserInfo()
  5193. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5194. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5195. timeLayout := "2006-01-02"
  5196. loc, _ := time.LoadLocation("Local")
  5197. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  5198. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  5199. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  5200. Mkdir(miConfig.OrgName)
  5201. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  5202. file_name := file + ".txt"
  5203. zip_name := file + ".zip"
  5204. zip_path := miConfig.OrgName + "/" + zip_name
  5205. file_path := miConfig.OrgName + "/" + file_name
  5206. decimal.DivisionPrecision = 2
  5207. var medfee_sumamt float64
  5208. var psn_cash_pay float64
  5209. var fund_pay_sumamt float64
  5210. fixmedins_setl_cnt := int64(len(orders))
  5211. for _, item := range orders {
  5212. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  5213. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  5214. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  5215. }
  5216. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  5217. defer f.Close()
  5218. if err != nil {
  5219. fmt.Println(err.Error())
  5220. } else {
  5221. for _, item := range orders {
  5222. var refd_setl_flag string
  5223. if item.OrderStatus == 2 {
  5224. refd_setl_flag = "0"
  5225. var str string
  5226. str = item.SetlId + " " +
  5227. item.MdtrtId + " " +
  5228. item.PsnNo + " " +
  5229. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  5230. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  5231. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  5232. _, err = f.Write([]byte(str))
  5233. }
  5234. if item.OrderStatus == 3 {
  5235. var str string
  5236. str = item.SetlId + " " +
  5237. item.MdtrtId + " " +
  5238. item.PsnNo + " " +
  5239. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  5240. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  5241. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  5242. _, err = f.Write([]byte(str))
  5243. var str2 string
  5244. str2 = item.SetlId + " " +
  5245. item.MdtrtId + " " +
  5246. item.PsnNo + " " +
  5247. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  5248. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  5249. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  5250. _, err = f.Write([]byte(str2))
  5251. }
  5252. }
  5253. }
  5254. Zip(file_path, zip_path)
  5255. fmt.Println(ReadFile(zip_path))
  5256. fmt.Println(string(ReadFile(zip_path)))
  5257. if config.IsOpen == 1 {
  5258. var user_name string
  5259. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5260. if role.ID == 0 {
  5261. user_name = "管理员"
  5262. } else {
  5263. user_name = role.UserName
  5264. }
  5265. baseParams := models.BaseParams{
  5266. SecretKey: miConfig.SecretKey,
  5267. FixmedinsCode: miConfig.Code,
  5268. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  5269. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  5270. OrgName: miConfig.OrgName,
  5271. Doctor: user_name,
  5272. }
  5273. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  5274. var dat map[string]interface{}
  5275. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5276. fmt.Println(dat)
  5277. } else {
  5278. fmt.Println(err)
  5279. }
  5280. userJSONBytes, _ := json.Marshal(dat)
  5281. var res ResultNine
  5282. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5283. utils.ErrorLog("解析失败:%v", err)
  5284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5285. return
  5286. }
  5287. if res.Infcode == 0 {
  5288. fileNo := res.Output.FileQuryNo
  5289. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  5290. "file_qury_no=" + fileNo +
  5291. "&setl_optins=" + "定点医保中心" +
  5292. "&stmt_begndate=" + start_time +
  5293. "&stm_enddate=" + end_time +
  5294. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  5295. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  5296. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  5297. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  5298. "&fixmedins_code=" + miConfig.Code +
  5299. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  5300. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5301. "&secret_key=" + miConfig.SecretKey +
  5302. "&org_name=" + miConfig.OrgName +
  5303. "&doctor=" + user_name
  5304. resp, requestErr := http.Get(api)
  5305. if requestErr != nil {
  5306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5307. return
  5308. }
  5309. body, ioErr := ioutil.ReadAll(resp.Body)
  5310. if ioErr != nil {
  5311. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5313. return
  5314. }
  5315. var respJSON map[string]interface{}
  5316. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5317. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5319. return
  5320. }
  5321. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5322. userJSONBytes, _ := json.Marshal(respJSON)
  5323. var res ResultTen
  5324. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5325. utils.ErrorLog("解析失败:%v", err)
  5326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5327. return
  5328. }
  5329. if res.Infcode == 0 {
  5330. service.Gdyb9102(baseParams, zip_name, fileNo)
  5331. micc := &models.MedicalInsuranceCostCompare{
  5332. StartTime: startime.Unix(),
  5333. EndTime: endtime.Unix(),
  5334. Insutype: "0",
  5335. CheckType: 2,
  5336. Num: fixmedins_setl_cnt,
  5337. Mtime: time.Now().Unix(),
  5338. Status: 1,
  5339. UserOrgId: adminUser.CurrentOrgId,
  5340. CostTotal: medfee_sumamt,
  5341. FuncTotal: fund_pay_sumamt,
  5342. PsnPay: psn_cash_pay,
  5343. Creator: admin_user_id,
  5344. Ctime: time.Now().Unix(),
  5345. }
  5346. service.CreateMedicalInsuranceCostCompareRecord(micc)
  5347. c.ServeSuccessJSON(map[string]interface{}{
  5348. "msg": "明细对账成功",
  5349. })
  5350. }
  5351. } else {
  5352. }
  5353. }
  5354. }
  5355. type CustomOrderInfo struct {
  5356. Name string
  5357. Spec string
  5358. Unit string
  5359. Count float64
  5360. Price float64
  5361. Total float64
  5362. }
  5363. func (c *HisApiController) GetSettleAccounts() {
  5364. //id, _ := c.GetInt64("id")
  5365. //record_time := c.GetString("record_time")
  5366. order_id, _ := c.GetInt64("order_id")
  5367. admin_user_id, _ := c.GetInt64("admin_user_id")
  5368. //timeLayout := "2006-01-02"
  5369. //loc, _ := time.LoadLocation("Local")
  5370. //
  5371. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5372. //if err != nil {
  5373. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5374. // return
  5375. //}
  5376. //recordDateTime := theTime.Unix()
  5377. adminUser := c.GetAdminUserInfo()
  5378. order, _ := service.GetHisOrderByID(order_id)
  5379. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5380. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  5381. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  5382. orderInfos = append(orderInfos, orderInfos_two...)
  5383. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  5384. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5385. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  5386. //var config []*models.HisXtDiagnoseConfig
  5387. var name string
  5388. for _, item := range diagnosis_ids {
  5389. id, _ := strconv.ParseInt(item, 10, 64)
  5390. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5391. if len(name) == 0 {
  5392. name = diagnosisConfig.ClassName
  5393. } else {
  5394. name = name + "," + diagnosisConfig.ClassName
  5395. }
  5396. }
  5397. var bedCostTotal float64 = 0 //床位总费
  5398. var bedCostSelfTotal float64 = 0 //床位自费
  5399. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  5400. var operationCostTotal float64 = 0 //手术费
  5401. var operationCostSelfTotal float64 = 0 //手术费
  5402. var operationCostPartSelfTotal float64 = 0 //手术费
  5403. var otherCostTotal float64 = 0 //其他费用
  5404. var otherCostSelfTotal float64 = 0 //其他费用
  5405. var otherCostPartSelfTotal float64 = 0 //其他费用
  5406. var materialCostTotal float64 = 0 //材料费
  5407. var materialCostSelfTotal float64 = 0 //材料费
  5408. var materialCostPartSelfTotal float64 = 0 //材料费
  5409. var westernMedicineCostTotal float64 = 0 //西药费
  5410. var westernMedicineCostSelfTotal float64 = 0 //西药费
  5411. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  5412. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  5413. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  5414. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  5415. var checkCostTotal float64 = 0 //检查费
  5416. var checkCostSelfTotal float64 = 0 //检查费
  5417. var checkCostPartSelfTotal float64 = 0 //检查费
  5418. var laboratoryCostTotal float64 = 0 //化验费
  5419. var laboratoryCostSelfTotal float64 = 0 //化验费
  5420. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  5421. var treatCostTotal float64 = 0 //治疗费用
  5422. var treatCostSelfTotal float64 = 0 //治疗费用
  5423. var treatCostPartSelfTotal float64 = 0 //治疗费用
  5424. decimal.DivisionPrecision = 2
  5425. for _, item := range orderInfos {
  5426. if item.MedChrgitmType == "01" { //床位费
  5427. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5428. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5429. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5430. }
  5431. if item.MedChrgitmType == "03" { //检查费
  5432. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5433. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5434. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5435. }
  5436. if item.MedChrgitmType == "04" { //化验费
  5437. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5438. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5439. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5440. }
  5441. if item.MedChrgitmType == "05" { //治疗费
  5442. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5443. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5444. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5445. }
  5446. if item.MedChrgitmType == "06" { //手术费
  5447. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5448. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5449. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5450. }
  5451. if item.MedChrgitmType == "08" { //材料费
  5452. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5453. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5454. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5455. }
  5456. if item.MedChrgitmType == "09" { //西药费
  5457. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5458. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5459. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5460. }
  5461. if item.MedChrgitmType == "11" { //中成费
  5462. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5463. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5464. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5465. }
  5466. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  5467. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5468. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5469. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5470. }
  5471. }
  5472. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5473. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5474. var user_name string
  5475. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5476. if role.ID == 0 {
  5477. user_name = "管理员"
  5478. } else {
  5479. user_name = role.UserName
  5480. }
  5481. baseParams := models.BaseParams{
  5482. SecretKey: miConfig.SecretKey,
  5483. FixmedinsCode: miConfig.Code,
  5484. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  5485. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  5486. OrgName: miConfig.OrgName,
  5487. Doctor: user_name,
  5488. }
  5489. businessParams := models.BusinessParams{
  5490. PsnNo: order.PsnNo,
  5491. MdtrtId: order.MdtrtId,
  5492. SetlId: order.SetlId,
  5493. }
  5494. var res ResultEleven
  5495. if config.IsOpen == 1 {
  5496. if miConfig.MdtrtareaAdmvs == "421300" {
  5497. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  5498. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  5499. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  5500. resp, requestErr := http.Get(api)
  5501. if requestErr != nil {
  5502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5503. return
  5504. }
  5505. body, ioErr := ioutil.ReadAll(resp.Body)
  5506. if ioErr != nil {
  5507. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5509. return
  5510. }
  5511. var respJSON map[string]interface{}
  5512. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5513. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5515. return
  5516. }
  5517. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5518. result, _ := json.Marshal(respJSON)
  5519. fmt.Println("log")
  5520. fmt.Println(string(result))
  5521. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5522. utils.ErrorLog("解析失败:%v", err)
  5523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5524. return
  5525. }
  5526. } else {
  5527. result := service.Gdyb5203(baseParams, businessParams)
  5528. var dat map[string]interface{}
  5529. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5530. fmt.Println(dat)
  5531. } else {
  5532. fmt.Println(err)
  5533. }
  5534. userJSONBytes, _ := json.Marshal(dat)
  5535. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5536. utils.ErrorLog("解析失败:%v", err)
  5537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5538. return
  5539. }
  5540. }
  5541. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5542. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  5543. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  5544. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5545. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5546. var doctor_name string
  5547. if roles.ID == 0 {
  5548. doctor_name = "管理员"
  5549. } else {
  5550. doctor_name = roles.UserName
  5551. }
  5552. yiliao_leibie := ""
  5553. switch order.MedType {
  5554. case "11":
  5555. yiliao_leibie = "普通门诊"
  5556. break
  5557. case "12":
  5558. yiliao_leibie = "门诊挂号"
  5559. break
  5560. case "13":
  5561. yiliao_leibie = "急诊"
  5562. break
  5563. case "14":
  5564. yiliao_leibie = "门诊特殊病"
  5565. break
  5566. case "15":
  5567. yiliao_leibie = "门诊统筹"
  5568. break
  5569. case "16":
  5570. yiliao_leibie = "门诊慢性病"
  5571. break
  5572. case "21":
  5573. yiliao_leibie = "普通住院"
  5574. break
  5575. }
  5576. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5577. if res.Infcode == 0 {
  5578. c.ServeSuccessJSON(map[string]interface{}{
  5579. "diagnosis": name,
  5580. "order_infos": orderInfos,
  5581. "number": order.MdtrtId,
  5582. "date": order.SettleAccountsDate,
  5583. "charge_admin": charge_admin,
  5584. "printor_admin": printor_admin,
  5585. "info": res.Output.Setlinfo,
  5586. "bedCostTotal": bedCostTotal,
  5587. "bedCostSelfTotal": bedCostSelfTotal,
  5588. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  5589. "operationCostTotal": operationCostTotal,
  5590. "operationCostSelfTotal": operationCostSelfTotal,
  5591. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  5592. "otherCostTotal": otherCostTotal,
  5593. "otherCostSelfTotal": otherCostSelfTotal,
  5594. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  5595. "materialCostTotal": materialCostTotal,
  5596. "materialCostSelfTotal": materialCostSelfTotal,
  5597. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  5598. "westernMedicineCostTotal": westernMedicineCostTotal,
  5599. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  5600. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  5601. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  5602. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  5603. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  5604. "checkCostTotal": checkCostTotal,
  5605. "checkCostSelfTotal": checkCostSelfTotal,
  5606. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  5607. "laboratoryCostTotal": laboratoryCostTotal,
  5608. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  5609. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  5610. "treatCostTotal": treatCostTotal,
  5611. "treatCostSelfTotal": treatCostSelfTotal,
  5612. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  5613. "doctor_code": adminRole_two.DoctorCode,
  5614. "doctor_name": doctor_name,
  5615. "health_card_no": order.PsnNo,
  5616. "department": departments.Name,
  5617. "yiliao_leibie": yiliao_leibie,
  5618. "after_money": order.AccountPrice,
  5619. "patient": patient,
  5620. "org_name": miConfig.OrgName,
  5621. "org_code": miConfig.Code,
  5622. "order_number": order.Number,
  5623. //"check_order_info": cus_slice,
  5624. })
  5625. }
  5626. }
  5627. }
  5628. func (c *HisApiController) CheckTreatment() {
  5629. patient_id, _ := c.GetInt64("patient_id", 0)
  5630. record_time := c.GetString("record_time")
  5631. insutype := c.GetString("insutype")
  5632. timeLayout := "2006-01-02"
  5633. loc, _ := time.LoadLocation("Local")
  5634. adminUser := c.GetAdminUserInfo()
  5635. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5636. fmt.Println(err)
  5637. if err != nil {
  5638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5639. return
  5640. }
  5641. recordDateTime := theTime.Unix()
  5642. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5643. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5644. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5645. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5646. var user_name string
  5647. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  5648. if role.ID == 0 {
  5649. user_name = "xxx"
  5650. } else {
  5651. user_name = role.UserName
  5652. }
  5653. baseParams := models.BaseParams{
  5654. SecretKey: miConfig.SecretKey,
  5655. FixmedinsCode: miConfig.Code,
  5656. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  5657. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  5658. OrgName: miConfig.OrgName,
  5659. Doctor: user_name,
  5660. }
  5661. if config.IsOpen == 1 {
  5662. result := service.Gdyb2001(baseParams, his.PsnNo, insutype, strconv.FormatInt(patientPrescription.RegisterType, 10))
  5663. var dat map[string]interface{}
  5664. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5665. fmt.Println(dat)
  5666. } else {
  5667. fmt.Println(err)
  5668. }
  5669. }
  5670. }
  5671. func (c *HisApiController) PutRecord() {
  5672. id, _ := c.GetInt64("id")
  5673. record_time := c.GetString("record_time")
  5674. timeLayout := "2006-01-02"
  5675. loc, _ := time.LoadLocation("Local")
  5676. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5677. if err != nil {
  5678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5679. return
  5680. }
  5681. recordDateTime := theTime.Unix()
  5682. adminInfo := c.GetAdminUserInfo()
  5683. patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  5684. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  5685. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  5686. fmt.Println(miConfig.SecretKey)
  5687. if patient == nil {
  5688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  5689. return
  5690. }
  5691. if len(patient.IdCardNo) == 0 {
  5692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  5693. return
  5694. }
  5695. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  5696. if config.IsOpen == 1 {
  5697. 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
  5698. resp, requestErr := http.Get(api)
  5699. if requestErr != nil {
  5700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5701. return
  5702. }
  5703. defer resp.Body.Close()
  5704. body, ioErr := ioutil.ReadAll(resp.Body)
  5705. if ioErr != nil {
  5706. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5708. return
  5709. }
  5710. var respJSON map[string]interface{}
  5711. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5714. return
  5715. }
  5716. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5717. userJSONBytes, _ := json.Marshal(userJSON)
  5718. var res ResultTwo
  5719. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5720. utils.ErrorLog("解析失败:%v", err)
  5721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5722. return
  5723. }
  5724. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5725. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5726. infoStr := string(Iinfos)
  5727. idetinfoStr := string(Idetinfos)
  5728. if res.Infcode == 0 {
  5729. his := models.VMHisPatient{
  5730. Status: 1,
  5731. Ctime: time.Now().Unix(),
  5732. Mtime: time.Now().Unix(),
  5733. PsnNo: res.Output.Baseinfo.PsnNo,
  5734. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5735. Certno: res.Output.Baseinfo.Certno,
  5736. PsnName: res.Output.Baseinfo.PsnName,
  5737. Gend: res.Output.Baseinfo.Gend,
  5738. Naty: res.Output.Baseinfo.Naty,
  5739. Brdy: res.Output.Baseinfo.Brdy,
  5740. Age: res.Output.Baseinfo.Age,
  5741. Iinfo: infoStr,
  5742. Idetinfo: idetinfoStr,
  5743. PatientId: patient.ID,
  5744. RecordDate: theTime.Unix(),
  5745. UserOrgId: adminInfo.CurrentOrgId,
  5746. AdminUserId: adminInfo.AdminUser.Id,
  5747. IsReturn: 1,
  5748. }
  5749. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  5750. 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")
  5751. 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")
  5752. var dat map[string]interface{}
  5753. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5754. fmt.Println(dat)
  5755. } else {
  5756. fmt.Println(err)
  5757. }
  5758. var dat2 map[string]interface{}
  5759. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  5760. fmt.Println(dat2)
  5761. } else {
  5762. fmt.Println(err)
  5763. }
  5764. } else {
  5765. adminUser := c.GetAdminUserInfo()
  5766. errlog := &models.HisOrderError{
  5767. UserOrgId: adminUser.CurrentOrgId,
  5768. Ctime: time.Now().Unix(),
  5769. Mtime: time.Now().Unix(),
  5770. ErrMsg: res.ErrMsg,
  5771. Status: 1,
  5772. PatientId: id,
  5773. RecordTime: recordDateTime,
  5774. Stage: 1,
  5775. }
  5776. service.CreateErrMsgLog(errlog)
  5777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  5778. return
  5779. }
  5780. }
  5781. }
  5782. func (c *HisApiController) GetUploadDiag() {
  5783. id, _ := c.GetInt64("id")
  5784. record_time := c.GetString("record_time")
  5785. diagnosis_id, _ := c.GetInt64("diagnosis")
  5786. sick_type, _ := c.GetInt64("sick_type")
  5787. reg_type, _ := c.GetInt64("reg_type")
  5788. timeLayout := "2006-01-02"
  5789. loc, _ := time.LoadLocation("Local")
  5790. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5791. if err != nil {
  5792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5793. return
  5794. }
  5795. var patientPrescription models.HisPrescriptionInfo
  5796. recordDateTime := theTime.Unix()
  5797. adminInfo := c.GetAdminUserInfo()
  5798. patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  5799. if patientPrescription.ID == 0 {
  5800. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  5801. }
  5802. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  5803. diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  5804. his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  5805. sickConfig, _ := service.FindSickById(sick_type)
  5806. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5807. api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  5808. "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  5809. "&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 +
  5810. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  5811. resp2, requestErr2 := http.Get(api2)
  5812. if requestErr2 != nil {
  5813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5814. return
  5815. }
  5816. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  5817. if ioErr2 != nil {
  5818. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  5819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5820. return
  5821. }
  5822. var respJSON2 map[string]interface{}
  5823. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  5824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5826. return
  5827. }
  5828. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5829. userJSONBytes2, _ := json.Marshal(respJSON2)
  5830. var res2 ResultSix
  5831. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5832. utils.ErrorLog("解析失败:%v", err)
  5833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5834. return
  5835. }
  5836. if res2.Infcode != 0 {
  5837. adminUser := c.GetAdminUserInfo()
  5838. errlog := &models.HisOrderError{
  5839. UserOrgId: adminUser.CurrentOrgId,
  5840. Ctime: time.Now().Unix(),
  5841. Mtime: time.Now().Unix(),
  5842. ErrMsg: res2.ErrMsg,
  5843. Status: 1,
  5844. PatientId: id,
  5845. RecordTime: recordDateTime,
  5846. Stage: 3,
  5847. }
  5848. service.CreateErrMsgLog(errlog)
  5849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  5850. return
  5851. }
  5852. c.ServeSuccessJSON(map[string]interface{}{
  5853. "msg": "上传成功",
  5854. })
  5855. }
  5856. type QueryResult struct {
  5857. ID int64
  5858. Name string
  5859. Code string
  5860. List_type_code string
  5861. }
  5862. func (c *HisApiController) GetCheckCode() {
  5863. ids_str := c.GetString("ids")
  5864. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  5865. ids_arr := strings.Split(ids_str, ",")
  5866. var queryResult []QueryResult
  5867. ids := make([]int64, 0)
  5868. for _, item := range ids_arr {
  5869. id, _ := strconv.ParseInt(item, 10, 64)
  5870. ids = append(ids, id)
  5871. }
  5872. if record_type == 1 {
  5873. drugs, _ := service.GetBatchDrugList(ids)
  5874. for _, item := range drugs {
  5875. result := QueryResult{
  5876. ID: item.ID,
  5877. Name: item.DrugName,
  5878. Code: item.MedicalInsuranceNumber,
  5879. List_type_code: "101",
  5880. }
  5881. queryResult = append(queryResult, result)
  5882. }
  5883. } else if record_type == 2 {
  5884. goods, _ := service.GetBatchGoodInformationList(ids)
  5885. for _, item := range goods {
  5886. result := QueryResult{
  5887. ID: item.ID,
  5888. Name: item.GoodName,
  5889. Code: item.MedicalInsuranceNumber,
  5890. List_type_code: "301",
  5891. }
  5892. queryResult = append(queryResult, result)
  5893. }
  5894. } else if record_type == 3 {
  5895. projects, _ := service.GetBathchMyPorjecgList(ids)
  5896. for _, item := range projects {
  5897. result := QueryResult{
  5898. ID: item.ID,
  5899. Name: item.ProjectName,
  5900. Code: item.MedicalCode,
  5901. List_type_code: "201",
  5902. }
  5903. queryResult = append(queryResult, result)
  5904. }
  5905. }
  5906. admin_user_id, _ := c.GetInt64("admin_user_id")
  5907. adminUser := c.GetAdminUserInfo()
  5908. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5909. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5910. var user_name string
  5911. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5912. if role.ID == 0 {
  5913. user_name = "xxx"
  5914. } else {
  5915. user_name = role.UserName
  5916. }
  5917. baseParams := &models.BaseParams{
  5918. SecretKey: miConfig.SecretKey,
  5919. FixmedinsCode: miConfig.Code,
  5920. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  5921. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  5922. OrgName: miConfig.OrgName,
  5923. Doctor: user_name,
  5924. }
  5925. if config.IsOpen == 1 {
  5926. for _, item := range queryResult {
  5927. var result string
  5928. if record_type == 1 {
  5929. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  5930. } else if record_type == 2 {
  5931. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  5932. } else if record_type == 3 {
  5933. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  5934. }
  5935. var dat map[string]interface{}
  5936. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5937. fmt.Println(dat)
  5938. } else {
  5939. fmt.Println(err)
  5940. }
  5941. userJSONBytes, _ := json.Marshal(dat)
  5942. var res ResultSix
  5943. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5944. utils.ErrorLog("解析失败:%v", err)
  5945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5946. return
  5947. }
  5948. if res.Infcode == 0 {
  5949. if record_type == 1 {
  5950. service.UpdateBaseDrugById(item.ID)
  5951. } else if record_type == 2 {
  5952. service.UpdateGoodInformaitonByDetail(item.ID)
  5953. } else if record_type == 3 {
  5954. service.UpdateProjectById(item.ID)
  5955. }
  5956. c.ServeSuccessJSON(map[string]interface{}{
  5957. "failed_code": 0,
  5958. "msg": "目录对照成功",
  5959. })
  5960. } else {
  5961. c.ServeSuccessJSON(map[string]interface{}{
  5962. "failed_code": -10,
  5963. "msg": res.ErrMsg,
  5964. })
  5965. }
  5966. }
  5967. }
  5968. }
  5969. func (c *HisApiController) UnCheckCode() {
  5970. ids_str := c.GetString("ids")
  5971. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  5972. admin_user_id, _ := c.GetInt64("admin_user_id")
  5973. ids_arr := strings.Split(ids_str, ",")
  5974. var queryResult []QueryResult
  5975. ids := make([]int64, 0)
  5976. for _, item := range ids_arr {
  5977. id, _ := strconv.ParseInt(item, 10, 64)
  5978. ids = append(ids, id)
  5979. }
  5980. if record_type == 1 {
  5981. drugs, _ := service.GetBatchDrugList(ids)
  5982. for _, item := range drugs {
  5983. result := QueryResult{
  5984. ID: item.ID,
  5985. Name: item.DrugName,
  5986. Code: item.MedicalInsuranceNumber,
  5987. List_type_code: "101",
  5988. }
  5989. queryResult = append(queryResult, result)
  5990. }
  5991. } else if record_type == 2 {
  5992. goods, _ := service.GetBatchGoodInformationList(ids)
  5993. for _, item := range goods {
  5994. result := QueryResult{
  5995. ID: item.ID,
  5996. Name: item.GoodName,
  5997. Code: item.MedicalInsuranceNumber,
  5998. List_type_code: "301",
  5999. }
  6000. queryResult = append(queryResult, result)
  6001. }
  6002. } else if record_type == 3 {
  6003. projects, _ := service.GetBathchMyPorjecgList(ids)
  6004. for _, item := range projects {
  6005. result := QueryResult{
  6006. ID: item.ID,
  6007. Name: item.ProjectName,
  6008. Code: item.MedicalCode,
  6009. List_type_code: "201",
  6010. }
  6011. queryResult = append(queryResult, result)
  6012. }
  6013. }
  6014. adminUser := c.GetAdminUserInfo()
  6015. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6016. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6017. var user_name string
  6018. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6019. if role.ID == 0 {
  6020. user_name = "xxx"
  6021. } else {
  6022. user_name = role.UserName
  6023. }
  6024. baseParams := &models.BaseParams{
  6025. SecretKey: miConfig.SecretKey,
  6026. FixmedinsCode: miConfig.Code,
  6027. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  6028. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  6029. OrgName: miConfig.OrgName,
  6030. Doctor: user_name,
  6031. }
  6032. if config.IsOpen == 1 {
  6033. for _, item := range queryResult {
  6034. var result string
  6035. if record_type == 1 {
  6036. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  6037. } else if record_type == 2 {
  6038. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  6039. } else if record_type == 3 {
  6040. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  6041. }
  6042. var dat2 map[string]interface{}
  6043. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  6044. fmt.Println(dat2)
  6045. } else {
  6046. fmt.Println(err)
  6047. }
  6048. userJSONBytes, _ := json.Marshal(dat2)
  6049. var res ResultSix
  6050. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6051. utils.ErrorLog("解析失败:%v", err)
  6052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6053. return
  6054. }
  6055. if res.Infcode == 0 {
  6056. if record_type == 1 {
  6057. service.UpdateDrugByIdDetail(item.ID)
  6058. } else if record_type == 2 {
  6059. service.UpdateGoodInfoById(item.ID)
  6060. } else if record_type == 3 {
  6061. service.UpdateMyProjectById(item.ID)
  6062. }
  6063. c.ServeSuccessJSON(map[string]interface{}{
  6064. "failed_code": 0,
  6065. "msg": "撤销目录对照成功",
  6066. })
  6067. } else {
  6068. c.ServeSuccessJSON(map[string]interface{}{
  6069. "failed_code": -10,
  6070. "msg": res.ErrMsg,
  6071. })
  6072. }
  6073. }
  6074. }
  6075. }
  6076. func (c *HisApiController) GetPatientInfo() {
  6077. id_card_no := c.GetString("id_card_no")
  6078. admin_user_id, _ := c.GetInt64("admin_user_id")
  6079. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  6080. if patient.ID == 0 {
  6081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  6082. return
  6083. }
  6084. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6085. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6086. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  6087. if config.IsOpen == 1 {
  6088. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  6089. var dat map[string]interface{}
  6090. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6091. fmt.Println(dat)
  6092. } else {
  6093. fmt.Println(err)
  6094. }
  6095. userJSONBytes, _ := json.Marshal(dat)
  6096. var res ResultTwo
  6097. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6098. utils.ErrorLog("解析失败:%v", err)
  6099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6100. return
  6101. }
  6102. if res.Infcode != 0 {
  6103. c.ServeSuccessJSON(map[string]interface{}{
  6104. "failed_code": -10,
  6105. "msg": res.ErrMsg,
  6106. })
  6107. } else {
  6108. c.ServeSuccessJSON(map[string]interface{}{
  6109. "failed_code": 0,
  6110. "info": res,
  6111. })
  6112. }
  6113. }
  6114. }
  6115. func (c *HisApiController) PsnPutOnRecord() {
  6116. record_type, _ := c.GetInt64("type")
  6117. patient_id, _ := c.GetInt64("patient_id")
  6118. admin_user_id, _ := c.GetInt64("admin_user_id")
  6119. start_time := c.GetString("start_time")
  6120. end_time := c.GetString("end_time")
  6121. adminUser := c.GetAdminUserInfo()
  6122. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6123. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6124. var patients []*models.Patients
  6125. if record_type == 1 { //全部备案
  6126. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  6127. patients = append(patients, patient...)
  6128. } else { //单个备案
  6129. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  6130. patients = append(patients, patient)
  6131. }
  6132. var user_name string
  6133. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6134. if role.ID == 0 {
  6135. user_name = "xxx"
  6136. } else {
  6137. user_name = role.UserName
  6138. }
  6139. if config.IsOpen == 1 {
  6140. for _, item := range patients {
  6141. 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
  6142. resp, requestErr := http.Get(api)
  6143. if requestErr != nil {
  6144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6145. return
  6146. }
  6147. defer resp.Body.Close()
  6148. body, ioErr := ioutil.ReadAll(resp.Body)
  6149. if ioErr != nil {
  6150. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6152. return
  6153. }
  6154. var respJSON map[string]interface{}
  6155. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6158. return
  6159. }
  6160. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6161. userJSONBytes, _ := json.Marshal(userJSON)
  6162. var res ResultTwo
  6163. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6164. utils.ErrorLog("解析失败:%v", err)
  6165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6166. return
  6167. }
  6168. if res.Infcode == 0 {
  6169. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  6170. var dat map[string]interface{}
  6171. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6172. fmt.Println(dat)
  6173. } else {
  6174. fmt.Println(err)
  6175. }
  6176. userJSONBytes, _ := json.Marshal(dat)
  6177. var res2 ResultThirteen
  6178. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6179. utils.ErrorLog("解析失败:%v", err)
  6180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6181. return
  6182. }
  6183. if res2.Infcode == 0 {
  6184. psnResult := &models.GdybPsnRecord{
  6185. UserOrgId: adminUser.CurrentOrgId,
  6186. PatientId: item.ID,
  6187. PsnNo: res.Output.Baseinfo.PsnNo,
  6188. Ctime: time.Now().Unix(),
  6189. Mtime: time.Now().Unix(),
  6190. Status: 1,
  6191. IsCancel: 1,
  6192. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  6193. }
  6194. service.CreatePsnRecord(psnResult)
  6195. } else {
  6196. c.ServeSuccessJSON(map[string]interface{}{
  6197. "failed_code": -10,
  6198. "msg": res2.ErrMsg,
  6199. })
  6200. return
  6201. }
  6202. }
  6203. }
  6204. }
  6205. }
  6206. func (c *HisApiController) PsnUnPutOnRecord() {
  6207. id, _ := c.GetInt64("id")
  6208. //record_type, _ := c.GetInt64("type")
  6209. admin_user_id, _ := c.GetInt64("admin_user_id")
  6210. adminUser := c.GetAdminUserInfo()
  6211. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6212. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6213. var user_name string
  6214. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6215. if role.ID == 0 {
  6216. user_name = "xxx"
  6217. } else {
  6218. user_name = role.UserName
  6219. }
  6220. psn_record, _ := service.GetPsnRecordById(id)
  6221. if psn_record.ID == 0 {
  6222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  6223. return
  6224. }
  6225. if config.IsOpen == 1 {
  6226. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  6227. var dat map[string]interface{}
  6228. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6229. fmt.Println(dat)
  6230. } else {
  6231. fmt.Println(err)
  6232. }
  6233. userJSONBytes, _ := json.Marshal(dat)
  6234. var res ResultFourteen
  6235. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6236. utils.ErrorLog("解析失败:%v", err)
  6237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6238. return
  6239. }
  6240. if res.Infcode == 0 {
  6241. psn_record.IsCancel = 2
  6242. service.CreatePsnRecord(&psn_record)
  6243. } else {
  6244. c.ServeSuccessJSON(map[string]interface{}{
  6245. "failed_code": -10,
  6246. "msg": res.ErrMsg,
  6247. })
  6248. return
  6249. }
  6250. }
  6251. }
  6252. func (c *HisApiController) PsnPutNCDSOnRecord() {
  6253. patient_id, _ := c.GetInt64("patient_id")
  6254. insutype := c.GetString("insutype")
  6255. psn_no := c.GetString("psn_no")
  6256. doctor_id, _ := c.GetInt64("doctor_id")
  6257. sick_id, _ := c.GetInt64("sick_id")
  6258. department_id, _ := c.GetInt64("department_id")
  6259. adminUser := c.GetAdminUserInfo()
  6260. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  6261. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6262. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6263. sick, _ := service.FindSickById(sick_id)
  6264. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  6265. if config.IsOpen == 1 {
  6266. 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)
  6267. var dat map[string]interface{}
  6268. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6269. fmt.Println(dat)
  6270. } else {
  6271. fmt.Println(err)
  6272. }
  6273. userJSONBytes, _ := json.Marshal(dat)
  6274. var res2 ResultThirteen
  6275. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6276. utils.ErrorLog("解析失败:%v", err)
  6277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6278. return
  6279. }
  6280. if res2.Infcode == 0 {
  6281. psnResult := &models.GdybPsnNcdsRecord{
  6282. UserOrgId: adminUser.CurrentOrgId,
  6283. PatientId: patient.ID,
  6284. PsnNo: psn_no,
  6285. DoctorId: doctor.AdminUserId,
  6286. DepartmentId: department_id,
  6287. SickType: sick_id,
  6288. Insutype: insutype,
  6289. Ctime: time.Now().Unix(),
  6290. Mtime: time.Now().Unix(),
  6291. Status: 1,
  6292. IsCancel: 1,
  6293. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  6294. }
  6295. service.CreatePsnNCDSRecord(psnResult)
  6296. c.ServeSuccessJSON(map[string]interface{}{
  6297. "failed_code": 0,
  6298. "msg": "备案成功",
  6299. "result": psnResult,
  6300. })
  6301. } else {
  6302. c.ServeSuccessJSON(map[string]interface{}{
  6303. "failed_code": -10,
  6304. "msg": res2.ErrMsg,
  6305. })
  6306. return
  6307. }
  6308. }
  6309. }
  6310. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  6311. id, _ := c.GetInt64("id")
  6312. admin_user_id, _ := c.GetInt64("admin_user_id")
  6313. adminUser := c.GetAdminUserInfo()
  6314. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6315. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6316. var user_name string
  6317. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6318. if role.ID == 0 {
  6319. user_name = "xxx"
  6320. } else {
  6321. user_name = role.UserName
  6322. }
  6323. psn_record, _ := service.GetPsnNCDSRecordById(id)
  6324. if psn_record.ID == 0 {
  6325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  6326. return
  6327. }
  6328. if config.IsOpen == 1 {
  6329. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, user_name, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  6330. var dat map[string]interface{}
  6331. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6332. fmt.Println(dat)
  6333. } else {
  6334. fmt.Println(err)
  6335. }
  6336. userJSONBytes, _ := json.Marshal(dat)
  6337. var res ResultFourteen
  6338. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6339. utils.ErrorLog("解析失败:%v", err)
  6340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6341. return
  6342. }
  6343. if res.Infcode == 0 {
  6344. psn_record.IsCancel = 2
  6345. service.CreatePsnNCDSRecord(&psn_record)
  6346. c.ServeSuccessJSON(map[string]interface{}{
  6347. "failed_code": 0,
  6348. "msg": "撤销备案成功",
  6349. })
  6350. } else {
  6351. c.ServeSuccessJSON(map[string]interface{}{
  6352. "failed_code": -10,
  6353. "msg": res.ErrMsg,
  6354. })
  6355. return
  6356. }
  6357. }
  6358. }
  6359. func (c *HisApiController) TestTest() {
  6360. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  6361. fmt.Println(patient.Iinfo)
  6362. }
  6363. type CustomData struct {
  6364. MsgId string
  6365. PsnNo string
  6366. Info string
  6367. }
  6368. func (c *HisApiController) ReversalData() {
  6369. var customData []*CustomData
  6370. custom := &CustomData{
  6371. MsgId: "H44022900158202103301714472004",
  6372. PsnNo: "44020000001101329945",
  6373. Info: "2207",
  6374. }
  6375. customData = append(customData, custom)
  6376. custom1 := &CustomData{
  6377. MsgId: "H4402290015820210330172057803",
  6378. PsnNo: "44020000001101161813",
  6379. Info: "2207",
  6380. }
  6381. customData = append(customData, custom1)
  6382. custom2 := &CustomData{
  6383. MsgId: "H44022900158202103301705198813",
  6384. PsnNo: "44190000133097375417",
  6385. Info: "2207",
  6386. }
  6387. customData = append(customData, custom2)
  6388. custom3 := &CustomData{
  6389. MsgId: "H44022900158202103301715524756",
  6390. PsnNo: "44020000001100187221",
  6391. Info: "2207",
  6392. }
  6393. customData = append(customData, custom3)
  6394. custom4 := &CustomData{
  6395. MsgId: "H44022900158202103301730376224",
  6396. PsnNo: "44020000001101959155",
  6397. Info: "2207",
  6398. }
  6399. customData = append(customData, custom4)
  6400. custom5 := &CustomData{
  6401. MsgId: "H44022900158202103301748008725",
  6402. PsnNo: "44020000001104246641",
  6403. Info: "2207",
  6404. }
  6405. customData = append(customData, custom5)
  6406. custom6 := &CustomData{
  6407. MsgId: "H44022900158202103301718096755",
  6408. PsnNo: "44020000001102211860",
  6409. Info: "2207",
  6410. }
  6411. customData = append(customData, custom6)
  6412. custom7 := &CustomData{
  6413. MsgId: "H44022900158202103301736551640",
  6414. PsnNo: "44020000001102687718",
  6415. Info: "2207",
  6416. }
  6417. customData = append(customData, custom7)
  6418. custom8 := &CustomData{
  6419. MsgId: "H44022900158202103301743097676",
  6420. PsnNo: "44020000001102127785",
  6421. Info: "2207",
  6422. }
  6423. customData = append(customData, custom8)
  6424. custom9 := &CustomData{
  6425. MsgId: "H44022900158202103301712304203",
  6426. PsnNo: "44020000001101518097",
  6427. Info: "2207",
  6428. }
  6429. customData = append(customData, custom9)
  6430. custom10 := &CustomData{
  6431. MsgId: "H44022900158202103301738448785",
  6432. PsnNo: "44020000001100500813",
  6433. Info: "2207",
  6434. }
  6435. customData = append(customData, custom10)
  6436. custom11 := &CustomData{
  6437. MsgId: "H44022900158202103301732455843",
  6438. PsnNo: "44020000001102690557",
  6439. Info: "2207",
  6440. }
  6441. customData = append(customData, custom11)
  6442. custom12 := &CustomData{
  6443. MsgId: "H44022900158202103301745421708",
  6444. PsnNo: "44020000001102211928",
  6445. Info: "2207",
  6446. }
  6447. customData = append(customData, custom12)
  6448. custom1212 := &CustomData{
  6449. MsgId: "H440229001582021033017351627",
  6450. PsnNo: "44020000001102481733",
  6451. Info: "2207",
  6452. }
  6453. customData = append(customData, custom1212)
  6454. custom13 := &CustomData{
  6455. MsgId: "H44022900158202103301740327951",
  6456. PsnNo: "44020000001103174866",
  6457. Info: "2207",
  6458. }
  6459. customData = append(customData, custom13)
  6460. custom14 := &CustomData{
  6461. MsgId: "H4402290015820210330174922668",
  6462. PsnNo: "44020000001102927272",
  6463. Info: "2207",
  6464. }
  6465. customData = append(customData, custom14)
  6466. custom15 := &CustomData{
  6467. MsgId: "H44022900158202103301752362273",
  6468. PsnNo: "44020000001102942890",
  6469. Info: "2207",
  6470. }
  6471. customData = append(customData, custom15)
  6472. custom16 := &CustomData{
  6473. MsgId: "H44022900158202103301751082917",
  6474. PsnNo: "44020000001101662162",
  6475. Info: "2207",
  6476. }
  6477. customData = append(customData, custom16)
  6478. custom17 := &CustomData{
  6479. MsgId: "H44022900158202103301754147728",
  6480. PsnNo: "44020000000229014511",
  6481. Info: "2207",
  6482. }
  6483. customData = append(customData, custom17)
  6484. adminUser := c.GetAdminUserInfo()
  6485. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6486. for _, item := range customData {
  6487. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  6488. fmt.Println(result)
  6489. }
  6490. }
  6491. func (c *HisApiController) ReversalOtherData() {
  6492. var customData []*CustomData
  6493. custom := &CustomData{
  6494. MsgId: "H44022900158202103301714472004",
  6495. PsnNo: "44020000001101329945",
  6496. Info: "2208",
  6497. }
  6498. customData = append(customData, custom)
  6499. custom1 := &CustomData{
  6500. MsgId: "H4402290015820210330172057803",
  6501. PsnNo: "44020000001101161813",
  6502. Info: "2208",
  6503. }
  6504. customData = append(customData, custom1)
  6505. custom2 := &CustomData{
  6506. MsgId: "H44022900158202103301705198813",
  6507. PsnNo: "44190000133097375417",
  6508. Info: "2208",
  6509. }
  6510. customData = append(customData, custom2)
  6511. custom3 := &CustomData{
  6512. MsgId: "H44022900158202103301715524756",
  6513. PsnNo: "44020000001100187221",
  6514. Info: "2208",
  6515. }
  6516. customData = append(customData, custom3)
  6517. custom4 := &CustomData{
  6518. MsgId: "H44022900158202103301730376224",
  6519. PsnNo: "44020000001101959155",
  6520. Info: "2208",
  6521. }
  6522. customData = append(customData, custom4)
  6523. custom5 := &CustomData{
  6524. MsgId: "H44022900158202103301748008725",
  6525. PsnNo: "44020000001104246641",
  6526. Info: "2208",
  6527. }
  6528. customData = append(customData, custom5)
  6529. custom6 := &CustomData{
  6530. MsgId: "H44022900158202103301718096755",
  6531. PsnNo: "44020000001102211860",
  6532. Info: "2208",
  6533. }
  6534. customData = append(customData, custom6)
  6535. custom7 := &CustomData{
  6536. MsgId: "H44022900158202103301736551640",
  6537. PsnNo: "44020000001102687718",
  6538. Info: "2208",
  6539. }
  6540. customData = append(customData, custom7)
  6541. custom8 := &CustomData{
  6542. MsgId: "H44022900158202103301743097676",
  6543. PsnNo: "44020000001102127785",
  6544. Info: "2208",
  6545. }
  6546. customData = append(customData, custom8)
  6547. custom9 := &CustomData{
  6548. MsgId: "H44022900158202103301712304203",
  6549. PsnNo: "44020000001101518097",
  6550. Info: "2208",
  6551. }
  6552. customData = append(customData, custom9)
  6553. custom10 := &CustomData{
  6554. MsgId: "H44022900158202103301738448785",
  6555. PsnNo: "44020000001100500813",
  6556. Info: "2208",
  6557. }
  6558. customData = append(customData, custom10)
  6559. custom11 := &CustomData{
  6560. MsgId: "H44022900158202103301732455843",
  6561. PsnNo: "44020000001102690557",
  6562. Info: "2208",
  6563. }
  6564. customData = append(customData, custom11)
  6565. custom12 := &CustomData{
  6566. MsgId: "H44022900158202103301745421708",
  6567. PsnNo: "44020000001102211928",
  6568. Info: "2208",
  6569. }
  6570. customData = append(customData, custom12)
  6571. custom1212 := &CustomData{
  6572. MsgId: "H440229001582021033017351627",
  6573. PsnNo: "44020000001102481733",
  6574. Info: "2208",
  6575. }
  6576. customData = append(customData, custom1212)
  6577. custom13 := &CustomData{
  6578. MsgId: "H44022900158202103301740327951",
  6579. PsnNo: "44020000001103174866",
  6580. Info: "2208",
  6581. }
  6582. customData = append(customData, custom13)
  6583. custom14 := &CustomData{
  6584. MsgId: "H4402290015820210330174922668",
  6585. PsnNo: "44020000001102927272",
  6586. Info: "2208",
  6587. }
  6588. customData = append(customData, custom14)
  6589. custom15 := &CustomData{
  6590. MsgId: "H44022900158202103301752362273",
  6591. PsnNo: "44020000001102942890",
  6592. Info: "2208",
  6593. }
  6594. customData = append(customData, custom15)
  6595. custom16 := &CustomData{
  6596. MsgId: "H44022900158202103301751082917",
  6597. PsnNo: "44020000001101662162",
  6598. Info: "2208",
  6599. }
  6600. customData = append(customData, custom16)
  6601. custom17 := &CustomData{
  6602. MsgId: "H44022900158202103301754147728",
  6603. PsnNo: "44020000000229014511",
  6604. Info: "2208",
  6605. }
  6606. customData = append(customData, custom17)
  6607. adminUser := c.GetAdminUserInfo()
  6608. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6609. for _, item := range customData {
  6610. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  6611. fmt.Println(result)
  6612. }
  6613. }
  6614. func PathExists(path string) (bool, error) {
  6615. _, err := os.Stat(path)
  6616. if err == nil {
  6617. return true, nil
  6618. }
  6619. if os.IsNotExist(err) {
  6620. return false, nil
  6621. }
  6622. return false, err
  6623. }
  6624. //创建文件夹
  6625. func Mkdir(dir string) {
  6626. // 创建文件夹
  6627. exist, err := PathExists(dir)
  6628. if err != nil {
  6629. fmt.Println(err.Error())
  6630. } else {
  6631. if exist {
  6632. fmt.Println(dir + "文件夹已存在!")
  6633. } else {
  6634. // 文件夹名称,权限
  6635. err := os.Mkdir(dir, os.ModePerm)
  6636. if err != nil {
  6637. fmt.Println(dir+"文件夹创建失败:", err.Error())
  6638. } else {
  6639. fmt.Println(dir + "文件夹创建成功!")
  6640. }
  6641. }
  6642. }
  6643. }
  6644. //压缩文件
  6645. func Zip(srcFile string, destZip string) error {
  6646. zipfile, err := os.Create(destZip)
  6647. if err != nil {
  6648. return err
  6649. }
  6650. defer zipfile.Close()
  6651. archive := zip.NewWriter(zipfile)
  6652. defer archive.Close()
  6653. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  6654. if err != nil {
  6655. return err
  6656. }
  6657. header, err := zip.FileInfoHeader(info)
  6658. if err != nil {
  6659. return err
  6660. }
  6661. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  6662. // header.Name = path
  6663. if info.IsDir() {
  6664. header.Name += "/"
  6665. } else {
  6666. header.Method = zip.Deflate
  6667. }
  6668. writer, err := archive.CreateHeader(header)
  6669. if err != nil {
  6670. return err
  6671. }
  6672. if !info.IsDir() {
  6673. file, err := os.Open(path)
  6674. if err != nil {
  6675. return err
  6676. }
  6677. defer file.Close()
  6678. _, err = io.Copy(writer, file)
  6679. }
  6680. return err
  6681. })
  6682. return err
  6683. }
  6684. func ReadFile(filePath string) []byte {
  6685. f, err := os.Open(filePath)
  6686. if err != nil {
  6687. fmt.Println("read file fail", err)
  6688. return nil
  6689. }
  6690. defer f.Close()
  6691. fd, err := ioutil.ReadAll(f)
  6692. if err != nil {
  6693. fmt.Println("read to fd fail", err)
  6694. return nil
  6695. }
  6696. return fd
  6697. }
  6698. func RemoveRepeatedTeam(arr []*models.HisOrderInfo) (newArr []*models.HisOrderInfo) {
  6699. newArr = make([]*models.HisOrderInfo, 0)
  6700. for i := 0; i < len(arr); i++ {
  6701. repeat := false
  6702. for j := i + 1; j < len(arr); j++ {
  6703. if arr[i].HisPrescriptionProject.TeamId == arr[j].HisPrescriptionProject.TeamId {
  6704. repeat = true
  6705. break
  6706. }
  6707. }
  6708. if !repeat {
  6709. newArr = append(newArr, arr[i])
  6710. }
  6711. }
  6712. return
  6713. }
  6714. func saveRegisterLog(result string) {
  6715. org_id, _ := beego.AppConfig.Int64("org_id")
  6716. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  6717. dir := miConfig.OrgName + "日志"
  6718. utils.Mkdir(dir)
  6719. month := time.Unix(1557042972, 0).Format("1")
  6720. year := time.Now().Format("2006")
  6721. month = time.Now().Format("01")
  6722. day := time.Now().Format("02")
  6723. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  6724. file_name := file + ".txt"
  6725. file_path := miConfig.OrgName + "日志" + "/" + file_name
  6726. exist, _ := utils.PathExists(file_path)
  6727. if exist { //存在
  6728. fmt.Println("存在")
  6729. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  6730. if err != nil {
  6731. fmt.Println("read fail")
  6732. }
  6733. content := "\r\n" + result
  6734. n, _ := f.Seek(0, 2)
  6735. _, err = f.WriteAt([]byte(content), n)
  6736. } else { //不存在
  6737. fmt.Println("文件不存在,创建文件")
  6738. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  6739. defer f.Close()
  6740. if err != nil {
  6741. } else {
  6742. _, err = f.Write([]byte("记录日志"))
  6743. }
  6744. }
  6745. }
  6746. func saveLog(result string, request string, infno string, desc string) {
  6747. org_id, _ := beego.AppConfig.Int64("org_id")
  6748. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  6749. dir := miConfig.OrgName + "日志"
  6750. utils.Mkdir(dir)
  6751. month := time.Unix(1557042972, 0).Format("1")
  6752. year := time.Now().Format("2006")
  6753. month = time.Now().Format("01")
  6754. day := time.Now().Format("02")
  6755. hour := time.Now().Format("15")
  6756. min := time.Now().Format("04")
  6757. sec := time.Now().Format("05")
  6758. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  6759. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  6760. file_name := file + ".txt"
  6761. file_path := miConfig.OrgName + "日志" + "/" + file_name
  6762. exist, _ := utils.PathExists(file_path)
  6763. if exist { //存在
  6764. fmt.Println("存在")
  6765. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  6766. if err != nil {
  6767. fmt.Println("read fail")
  6768. }
  6769. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  6770. n, _ := f.Seek(0, 2)
  6771. _, err = f.WriteAt([]byte(content), n)
  6772. } else { //不存在
  6773. fmt.Println("文件不存在,创建文件")
  6774. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  6775. defer f.Close()
  6776. if err != nil {
  6777. } else {
  6778. _, err = f.Write([]byte("记录日志"))
  6779. }
  6780. }
  6781. }
  6782. type Charset string
  6783. const (
  6784. UTF8 = Charset("UTF-8")
  6785. GB18030 = Charset("GB18030")
  6786. )
  6787. func ConvertToString(src string, srcCode string, tagCode string) string {
  6788. srcCoder := mahonia.NewDecoder(srcCode)
  6789. srcResult := srcCoder.ConvertString(src)
  6790. tagCoder := mahonia.NewDecoder(tagCode)
  6791. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  6792. result := string(cdata)
  6793. return result
  6794. }
  6795. //func (c *HisApiController)HandleCheckDetailAccount(){
  6796. // psn_no, _ := c.GetString("psn_no")
  6797. // psn_no, _ := c.GetString("psn_no")
  6798. // psn_no, _ := c.GetString("psn_no")
  6799. //
  6800. //
  6801. //
  6802. //}