his_api_controller.go 380KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426
  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. //挂号
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. //上传就诊信息-上传明细-结算
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. //查询
  37. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  38. //对总账
  39. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  40. //对明细
  41. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  42. //退费,退明细
  43. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  44. //退号
  45. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  46. //退明细
  47. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  48. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  49. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  50. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  51. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  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. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  56. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  57. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  58. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  59. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  60. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  61. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  62. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. }
  73. func (c *HisApiController) GetPsnNcdsInfo() {
  74. admin_user_id, _ := c.GetInt64("admin_user_id")
  75. patient_id, _ := c.GetInt64("patient_id")
  76. id, _ := c.GetInt64("id")
  77. adminUser := c.GetAdminUserInfo()
  78. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  79. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  80. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  81. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  82. psn_record, _ := service.GetPsnNCDSRecordById(id)
  83. //
  84. //if psn_record.ID == 0 {
  85. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  86. // return
  87. //}
  88. var res Result5301
  89. var res10265 Result5301For10265
  90. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  91. psn_info, _ := service.GetPsnByPatientId(patient_id)
  92. var api string
  93. if miConfig.MdtrtareaAdmvs == "320921" {
  94. api = "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  95. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  96. } else {
  97. api = "http://192.168.5.251:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  98. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  99. }
  100. resp, requestErr := http.Get(api)
  101. if requestErr != nil {
  102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  103. return
  104. }
  105. body, ioErr := ioutil.ReadAll(resp.Body)
  106. if ioErr != nil {
  107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  109. return
  110. }
  111. var respJSON map[string]interface{}
  112. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  115. return
  116. }
  117. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  118. result, _ := json.Marshal(respJSON)
  119. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  120. utils.ErrorLog("解析失败:%v", err)
  121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  122. return
  123. }
  124. res.ErrMsg = res10265.ErrMsg
  125. res.Output = res10265.Output
  126. res.InfRefmsgid = res10265.InfRefmsgid
  127. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  128. res.Infcode = infocode
  129. } else {
  130. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  131. var dat map[string]interface{}
  132. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  133. fmt.Println(dat)
  134. } else {
  135. fmt.Println(err)
  136. }
  137. userJSONBytes, _ := json.Marshal(dat)
  138. if miConfig.Code == "H15049901371" {
  139. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  140. utils.ErrorLog("解析失败:%v", err)
  141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  142. return
  143. }
  144. res.InfRefmsgid = res10265.InfRefmsgid
  145. res.Output = res10265.Output
  146. res.ErrMsg = res10265.ErrMsg
  147. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  148. res.Infcode = infocode
  149. } else {
  150. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  151. utils.ErrorLog("解析失败:%v", err)
  152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  153. return
  154. }
  155. }
  156. }
  157. if res.Infcode == 0 {
  158. c.ServeSuccessJSON(map[string]interface{}{
  159. "result": res.Output.Result,
  160. })
  161. }
  162. }
  163. func (c *HisApiController) CheckInsutype() {
  164. his_patient_id, _ := c.GetInt64("his_patient_id")
  165. admin_user_id, _ := c.GetInt64("admin_user_id")
  166. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  167. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  168. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  169. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  170. var dat map[string]interface{}
  171. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  172. fmt.Println(dat)
  173. } else {
  174. fmt.Println(err)
  175. }
  176. userJSONBytes, _ := json.Marshal(dat)
  177. var res Result90100
  178. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  179. utils.ErrorLog("解析失败:%v", err)
  180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  181. return
  182. }
  183. if res.Infcode != 0 {
  184. c.ServeSuccessJSON(map[string]interface{}{
  185. "failed_code": -10,
  186. "msg": res.ErrMsg,
  187. })
  188. return
  189. } else {
  190. fmt.Println(res)
  191. }
  192. }
  193. func (c *HisApiController) CheckCardPWD() {
  194. card_pwd := c.GetString("card_pwd")
  195. his_patient_id, _ := c.GetInt64("his_patient_id")
  196. admin_user_id, _ := c.GetInt64("admin_user_id")
  197. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  198. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  199. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  200. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd)
  201. var dat map[string]interface{}
  202. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  203. fmt.Println(dat)
  204. } else {
  205. fmt.Println(err)
  206. }
  207. userJSONBytes, _ := json.Marshal(dat)
  208. var res Result90991
  209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  210. utils.ErrorLog("解析失败:%v", err)
  211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  212. return
  213. }
  214. if res.Infcode != 0 {
  215. c.ServeSuccessJSON(map[string]interface{}{
  216. "failed_code": -10,
  217. "msg": res.ErrMsg,
  218. })
  219. return
  220. } else {
  221. if res.Output.Result.CheckStat == "0" {
  222. var msg string
  223. switch res.Output.Result.CardStat {
  224. case "00":
  225. msg = "未激活"
  226. break
  227. case "10":
  228. msg = "激活"
  229. break
  230. case "20":
  231. msg = "窗口挂失"
  232. break
  233. case "21":
  234. msg = "电话挂失"
  235. break
  236. case "22":
  237. msg = "单位网上申报挂失"
  238. break
  239. case "23":
  240. msg = "保健办挂失"
  241. break
  242. case "24":
  243. msg = "个人网上挂失"
  244. break
  245. case "25":
  246. msg = "网上服务大厅挂失"
  247. break
  248. case "30":
  249. msg = "注销"
  250. break
  251. case "40":
  252. msg = "回收"
  253. break
  254. case "99":
  255. msg = "制卡中(无效卡)"
  256. break
  257. }
  258. c.ServeSuccessJSON(map[string]interface{}{
  259. "failed_code": -10,
  260. "msg": msg,
  261. })
  262. return
  263. } else {
  264. c.ServeSuccessJSON(map[string]interface{}{
  265. "msg": "校验成功",
  266. })
  267. return
  268. }
  269. }
  270. }
  271. func (c *HisApiController) ReadCard() {
  272. id_card_type, _ := c.GetInt64("id_card_type")
  273. admin_user_id, _ := c.GetInt64("admin_user_id")
  274. certificates, _ := c.GetInt64("certificates")
  275. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  276. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  277. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  278. switch id_card_type {
  279. case 1:
  280. if miConfig.MdtrtareaAdmvs == "421300" {
  281. var res ResultTwo
  282. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  283. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  284. "&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)
  285. resp, requestErr := http.Get(api)
  286. if requestErr != nil {
  287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  288. return
  289. }
  290. body, ioErr := ioutil.ReadAll(resp.Body)
  291. if ioErr != nil {
  292. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  294. return
  295. }
  296. var respJSON map[string]interface{}
  297. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  300. return
  301. }
  302. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  303. result, _ := json.Marshal(respJSON)
  304. fmt.Println("log")
  305. fmt.Println(string(result))
  306. if err := json.Unmarshal([]byte(result), &res); err != nil {
  307. utils.ErrorLog("解析失败:%v", err)
  308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  309. return
  310. }
  311. if res.Infcode == 0 {
  312. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  313. if err == gorm.ErrRecordNotFound {
  314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  315. return
  316. } else if err != nil {
  317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  318. return
  319. } else {
  320. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  321. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  322. infoStr := string(Iinfos)
  323. idetinfoStr := string(Idetinfos)
  324. psn := &models.HisPsn{
  325. PsnNo: res.Output.Baseinfo.PsnNo,
  326. Age: res.Output.Baseinfo.Age,
  327. PatientId: patient.ID,
  328. Certno: res.Output.Baseinfo.Certno,
  329. Brdy: res.Output.Baseinfo.Brdy,
  330. Gend: res.Output.Baseinfo.Gend,
  331. Naty: res.Output.Baseinfo.Naty,
  332. PsnCertType: res.Output.Baseinfo.PsnCertType,
  333. PsnName: res.Output.Baseinfo.PsnName,
  334. Idetinfo: idetinfoStr,
  335. Insuinfo: infoStr,
  336. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  337. }
  338. service.CreateHisPsn(psn)
  339. c.ServeSuccessJSON(map[string]interface{}{
  340. "patient": patient,
  341. "number": res.Output.Baseinfo.Certno,
  342. })
  343. }
  344. } else {
  345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  346. return
  347. }
  348. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  349. var api string
  350. if miConfig.MdtrtareaAdmvs == "320921" {
  351. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  352. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  353. } else {
  354. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  355. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  356. }
  357. resp, requestErr := http.Get(api)
  358. if requestErr != nil {
  359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  360. return
  361. }
  362. body, ioErr := ioutil.ReadAll(resp.Body)
  363. if ioErr != nil {
  364. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  366. return
  367. }
  368. var respJSON map[string]interface{}
  369. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  370. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  372. return
  373. }
  374. var status string
  375. status = respJSON["data"].(map[string]interface{})["status"].(string)
  376. if status == "0" { //读卡成功
  377. var card_info string //卡信息
  378. var busi_card_info string
  379. var res ResultTwo //1101结果
  380. var res10265 ResultTwo10265 //1101结果
  381. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  382. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  383. fmt.Println(card_info)
  384. fmt.Println(busi_card_info)
  385. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  386. result, _ := json.Marshal(respJSON)
  387. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  388. utils.ErrorLog("解析失败:%v", err)
  389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  390. return
  391. }
  392. res.ErrMsg = res10265.ErrMsg
  393. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  394. res.Infcode = infocode
  395. res.Output = res10265.Output
  396. res.InfRefmsgid = res10265.InfRefmsgid
  397. if res.Infcode == 0 {
  398. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  399. if err == gorm.ErrRecordNotFound {
  400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  401. return
  402. } else if err != nil {
  403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  404. return
  405. } else {
  406. bas := strings.Split(card_info, "|")
  407. basNumber := bas[2]
  408. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  409. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  410. infoStr := string(Iinfos)
  411. idetinfoStr := string(Idetinfos)
  412. psn := &models.HisPsn{
  413. PsnNo: res.Output.Baseinfo.PsnNo,
  414. Age: res.Output.Baseinfo.Age,
  415. PatientId: patient.ID,
  416. Certno: res.Output.Baseinfo.Certno,
  417. Brdy: res.Output.Baseinfo.Brdy,
  418. Gend: res.Output.Baseinfo.Gend,
  419. Naty: res.Output.Baseinfo.Naty,
  420. PsnCertType: res.Output.Baseinfo.PsnCertType,
  421. PsnName: res.Output.Baseinfo.PsnName,
  422. Idetinfo: idetinfoStr,
  423. Insuinfo: infoStr,
  424. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  425. CardInfo: card_info,
  426. VerifyNumber: busi_card_info,
  427. }
  428. service.CreateHisPsn(psn)
  429. c.ServeSuccessJSON(map[string]interface{}{
  430. "patient": patient,
  431. "number": basNumber,
  432. })
  433. }
  434. } else {
  435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  436. return
  437. }
  438. } else { //读卡失败
  439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  440. return
  441. }
  442. } else {
  443. if initFlag == 0 {
  444. c.TestGetBasBaseInit()
  445. }
  446. basStr := c.GetBasBaseInfo()
  447. if len(basStr) == 0 {
  448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  449. return
  450. }
  451. fmt.Println(basStr)
  452. bas := strings.Split(basStr, "|")
  453. basNumber := bas[1]
  454. fmt.Println(basNumber)
  455. card_sn := bas[3]
  456. fmt.Println(card_sn)
  457. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  458. var dat map[string]interface{}
  459. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  460. fmt.Println(dat)
  461. } else {
  462. fmt.Println(err)
  463. }
  464. userJSONBytes, _ := json.Marshal(dat)
  465. var res ResultTwo
  466. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  467. utils.ErrorLog("解析失败:%v", err)
  468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  469. return
  470. }
  471. if res.Infcode == 0 {
  472. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  473. if err == gorm.ErrRecordNotFound {
  474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  475. return
  476. } else if err != nil {
  477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  478. return
  479. } else {
  480. c.ServeSuccessJSON(map[string]interface{}{
  481. "patient": patient,
  482. "number": basNumber,
  483. })
  484. }
  485. } else {
  486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  487. return
  488. }
  489. break
  490. }
  491. case 2:
  492. SFZStr := c.GetSFZBaseInfo()
  493. id_card_str := strings.Split(SFZStr, "^")
  494. id_card_number := id_card_str[0]
  495. card_sn := ""
  496. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  497. var dat map[string]interface{}
  498. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  499. fmt.Println(dat)
  500. } else {
  501. fmt.Println(err)
  502. }
  503. userJSONBytes, _ := json.Marshal(dat)
  504. var res ResultTwo
  505. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  506. utils.ErrorLog("解析失败:%v", err)
  507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  508. return
  509. }
  510. if res.Infcode == 0 {
  511. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  512. if err == gorm.ErrRecordNotFound {
  513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  514. return
  515. } else if err != nil {
  516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  517. return
  518. } else {
  519. c.ServeSuccessJSON(map[string]interface{}{
  520. "patient": patient,
  521. "number": id_card_number,
  522. })
  523. }
  524. } else {
  525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  526. return
  527. }
  528. break
  529. case 3:
  530. break
  531. }
  532. }
  533. var initFlag int64 = 0
  534. func (c *HisApiController) TestGetBasBaseInit() {
  535. DllDef := syscall.MustLoadDLL("SSCard.dll")
  536. Iinit := DllDef.MustFindProc("Init")
  537. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  538. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  539. if ret != 0 {
  540. fmt.Println("SSCard的报错原因:", err)
  541. fmt.Println("SSCard的运算结果为:", ret)
  542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  543. return
  544. }
  545. result := int(ret)
  546. fmt.Println("SSCard的运算结果为1:", result)
  547. initFlag = 1
  548. return
  549. }
  550. func (c *HisApiController) GetSFZBaseInfo() string {
  551. DllDef := syscall.MustLoadDLL("SSCard.dll")
  552. readCard := DllDef.MustFindProc("ReadSFZ")
  553. if readCard == nil {
  554. fmt.Println("readcard is nil")
  555. readCard = DllDef.MustFindProc("ReadSFZ")
  556. }
  557. str := make([]byte, 256)
  558. str1 := make([]byte, 256)
  559. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  560. fmt.Println(r)
  561. return string(str)
  562. }
  563. func (c *HisApiController) GetBasBaseInfo() string {
  564. DllDef := syscall.MustLoadDLL("SSCard.dll")
  565. readCard := DllDef.MustFindProc("ReadCardBas")
  566. if readCard == nil {
  567. fmt.Println("readcard is nil")
  568. readCard = DllDef.MustFindProc("ReadCardBas")
  569. }
  570. str := make([]byte, 1024)
  571. str1 := make([]byte, 1024)
  572. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  573. fmt.Println(string(str1))
  574. fmt.Println(string(str))
  575. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  576. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  577. if ret2 != 0 {
  578. return ""
  579. }
  580. return string(str)
  581. }
  582. type CustomFundPay struct {
  583. FundPayType string `json:"fund_pay_type"`
  584. FundPayamt float64 `json:"fund_payamt"`
  585. }
  586. func (c *HisApiController) GetSettleList() {
  587. order_id, _ := c.GetInt64("order_id")
  588. admin_user_id, _ := c.GetInt64("admin_user_id")
  589. order, _ := service.GetHisOrderByIDTwo(order_id)
  590. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  591. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  592. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  593. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  594. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  595. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  596. if order.ID == 0 {
  597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  598. return
  599. }
  600. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  601. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  602. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  603. fmt.Println(count)
  604. var zero string
  605. number := count + 1
  606. if number >= 1000 {
  607. zero = "0000" + strconv.FormatInt(number, 10)
  608. } else if number >= 10000 {
  609. zero = "000" + strconv.FormatInt(number, 10)
  610. } else if number >= 100000 {
  611. zero = "00" + strconv.FormatInt(number, 10)
  612. } else if number >= 1000000 {
  613. zero = "0" + strconv.FormatInt(number, 10)
  614. } else {
  615. zero = strconv.FormatInt(number, 10)
  616. }
  617. fmt.Println(zero)
  618. struct4101 := service.Struct4101{
  619. PsnNo: order.PsnNo,
  620. MdtrtId: order.MdtrtId,
  621. SetlId: order.SetlId,
  622. PsnName: order.PsnName,
  623. Gend: order.Gend,
  624. Brdy: his.Brdy,
  625. Age: his.Age,
  626. Naty: order.Naty,
  627. PatnCertType: "01",
  628. Certno: order.Certno,
  629. Prfs: "90",
  630. ConerName: roles[0].UserName,
  631. PatnRlts: "99",
  632. ConerAddr: miConfig.OrgName,
  633. ConerTel: admin.Mobile,
  634. HiType: order.Insutype,
  635. Insuplc: miConfig.InsuplcAdmdvs,
  636. MaindiagFlag: "1",
  637. BillCode: last_order.FaPiaoCode,
  638. BillNo: zero,
  639. BizSn: order.Number,
  640. PsnSelfPay: order.PsnPartAmt,
  641. PsnOwnPay: order.PsnPartAmt,
  642. AcctPay: order.AcctPay,
  643. PsnCashpay: order.PsnCashPay,
  644. HiPaymtd: "1",
  645. Hsorg: miConfig.InsuplcAdmdvs,
  646. HsorgOpter: miConfig.InsuplcAdmdvs,
  647. MedinsFillPsn: curRoles.UserName,
  648. MedinsFillDept: depart.Name,
  649. IptMedType: "2",
  650. }
  651. struct4101.SetlBegnDate = order.SetlTime
  652. struct4101.SetlEndDate = order.SetlTime
  653. time_arr := strings.Split(order.SetlTime, " ")
  654. struct4101.AdmTime = time_arr[0]
  655. struct4101.AdmEndTime = time_arr[0]
  656. var rf []CustomFundPay
  657. json.Unmarshal([]byte(order.SetlDetail), &rf)
  658. var tempFunPays []service.CustomStruct
  659. for _, item := range rf {
  660. var tempFunPay service.CustomStruct
  661. tempFunPay.FundPayamt = item.FundPayamt
  662. tempFunPay.FundPayType = item.FundPayType
  663. tempFunPays = append(tempFunPays, tempFunPay)
  664. }
  665. struct4101.CustomStruct = tempFunPays
  666. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  667. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  668. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  669. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  670. var config []*models.HisXtDiagnoseConfig
  671. for _, item := range diagnosis_ids {
  672. id, _ := strconv.ParseInt(item, 10, 64)
  673. diagnosisConfig, _ := service.FindDiagnoseById(id)
  674. config = append(config, &diagnosisConfig)
  675. }
  676. for _, item := range config {
  677. var tempOpspdiseinfo service.OpspdiseinfoStruct
  678. tempOpspdiseinfo.DiagCode = item.CountryCode
  679. tempOpspdiseinfo.DiagName = item.CountryContentName
  680. tempOpspdiseinfo.MaindiagFlag = "1"
  681. tempOpspdiseinfo.OprnOprtCode = ""
  682. tempOpspdiseinfo.OprnOprtName = ""
  683. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  684. }
  685. sickConfigTwo, _ := service.FindSickById(his.SickType)
  686. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  687. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  688. tempOpspdiseinfo2.MaindiagFlag = "2"
  689. tempOpspdiseinfo2.OprnOprtCode = ""
  690. tempOpspdiseinfo2.OprnOprtName = ""
  691. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  692. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  693. var iteminfo service.IteminfoStruct
  694. var bedCostTotal float64 = 0 //床位总费
  695. var bedCostSelfTotal float64 = 0 //床位自费
  696. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  697. var operationCostTotal float64 = 0 //手术费
  698. var operationCostSelfTotal float64 = 0 //手术费
  699. var operationCostPartSelfTotal float64 = 0 //手术费
  700. var otherCostTotal float64 = 0 //其他费用
  701. var otherCostSelfTotal float64 = 0 //其他费用
  702. var otherCostPartSelfTotal float64 = 0 //其他费用
  703. var materialCostTotal float64 = 0 //材料费
  704. var materialCostSelfTotal float64 = 0 //材料费
  705. var materialCostPartSelfTotal float64 = 0 //材料费
  706. var westernMedicineCostTotal float64 = 0 //西药费
  707. var westernMedicineCostSelfTotal float64 = 0 //西药费
  708. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  709. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  710. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  711. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  712. var checkCostTotal float64 = 0 //检查费
  713. var checkCostSelfTotal float64 = 0 //检查费
  714. var checkCostPartSelfTotal float64 = 0 //检查费
  715. var laboratoryCostTotal float64 = 0 //化验费
  716. var laboratoryCostSelfTotal float64 = 0 //化验费
  717. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  718. var treatCostTotal float64 = 0 //治疗费用
  719. var treatCostSelfTotal float64 = 0 //治疗费用
  720. var treatCostPartSelfTotal float64 = 0 //治疗费用
  721. decimal.DivisionPrecision = 2
  722. var bed_fulamt_ownpay_amt float64 = 0
  723. var operation_fulamt_ownpay_amt float64 = 0
  724. var other_fulamt_ownpay_amt float64 = 0
  725. var westernMedicine_fulamt_ownpay_amt float64 = 0
  726. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  727. var check_fulamt_ownpay_amt float64 = 0
  728. var material_fulamt_ownpay_amt float64 = 0
  729. var laboratory_fulamt_ownpay_amt float64 = 0
  730. var treat_fulamt_ownpay_amt float64 = 0
  731. var bed_claa_sunmfee float64 = 0
  732. var bed_clab_amt float64 = 0
  733. var bed_other_amt float64 = 0
  734. var operation_claa_sunmfee float64 = 0
  735. var operation_clab_amt float64 = 0
  736. var operation_other_amt float64 = 0
  737. var other_claa_sunmfee float64 = 0
  738. var other_clab_amt float64 = 0
  739. var other_other_amt float64 = 0
  740. var westernMedicine_claa_sunmfee float64 = 0
  741. var westernMedicine_clab_amt float64 = 0
  742. var westernMedicine_other_amt float64 = 0
  743. var chineseTraditional_claa_sunmfee float64 = 0
  744. var chineseTraditional_clab_amt float64 = 0
  745. var chineseTraditional_other_amt float64 = 0
  746. var check_claa_sunmfee float64 = 0
  747. var check_clab_amt float64 = 0
  748. var check_other_amt float64 = 0
  749. var material_claa_sunmfee float64 = 0
  750. var material_clab_amt float64 = 0
  751. var material_other_amt float64 = 0
  752. var laboratory_claa_sunmfee float64 = 0
  753. var laboratory_clab_amt float64 = 0
  754. var laboratory_other_amt float64 = 0
  755. var treat_claa_sunmfee float64 = 0
  756. var treat_clab_amt float64 = 0
  757. var treat_other_amt float64 = 0
  758. for _, item := range order.HisOrderInfo {
  759. if item.MedChrgitmType == "01" { //床位费
  760. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  761. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  762. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  763. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  764. if item.ChrgitmLv == "1" {
  765. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  766. }
  767. if item.ChrgitmLv == "2" {
  768. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  769. }
  770. if item.ChrgitmLv == "3" {
  771. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  772. }
  773. }
  774. if item.MedChrgitmType == "03" { //检查费
  775. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  776. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  777. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  778. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  779. if item.ChrgitmLv == "1" {
  780. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  781. }
  782. if item.ChrgitmLv == "2" {
  783. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  784. }
  785. if item.ChrgitmLv == "3" {
  786. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  787. }
  788. }
  789. if item.MedChrgitmType == "04" { //化验费
  790. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  791. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  792. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  793. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  794. if item.ChrgitmLv == "1" {
  795. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  796. }
  797. if item.ChrgitmLv == "2" {
  798. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  799. }
  800. if item.ChrgitmLv == "3" {
  801. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  802. }
  803. }
  804. if item.MedChrgitmType == "05" { //治疗费
  805. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  806. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  807. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  808. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  809. if item.ChrgitmLv == "1" {
  810. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  811. }
  812. if item.ChrgitmLv == "2" {
  813. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  814. }
  815. if item.ChrgitmLv == "3" {
  816. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  817. }
  818. }
  819. if item.MedChrgitmType == "06" { //手术费
  820. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  821. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  822. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  823. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  824. if item.ChrgitmLv == "1" {
  825. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  826. }
  827. if item.ChrgitmLv == "2" {
  828. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  829. }
  830. if item.ChrgitmLv == "3" {
  831. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  832. }
  833. }
  834. if item.MedChrgitmType == "08" { //材料费
  835. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  836. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  837. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  838. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  839. if item.ChrgitmLv == "1" {
  840. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  841. }
  842. if item.ChrgitmLv == "2" {
  843. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  844. }
  845. if item.ChrgitmLv == "3" {
  846. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  847. }
  848. }
  849. if item.MedChrgitmType == "09" { //西药费
  850. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  851. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  852. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  853. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  854. if item.ChrgitmLv == "1" {
  855. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  856. }
  857. if item.ChrgitmLv == "2" {
  858. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  859. }
  860. if item.ChrgitmLv == "3" {
  861. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  862. }
  863. }
  864. if item.MedChrgitmType == "11" { //中成费
  865. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  866. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  867. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  868. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  869. if item.ChrgitmLv == "1" {
  870. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  871. }
  872. if item.ChrgitmLv == "2" {
  873. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  874. }
  875. if item.ChrgitmLv == "3" {
  876. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  877. }
  878. }
  879. if item.MedChrgitmType == "14" { //其他费
  880. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  881. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  882. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  883. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  884. if item.ChrgitmLv == "1" {
  885. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  886. }
  887. if item.ChrgitmLv == "2" {
  888. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  889. }
  890. if item.ChrgitmLv == "3" {
  891. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  892. }
  893. }
  894. }
  895. var iteminfoStructs []service.IteminfoStruct
  896. if bedCostTotal != 0 {
  897. iteminfo.MedChrgitm = "01"
  898. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  899. iteminfo.Amt = bedCostTotal
  900. iteminfo.ClaaSumfee = bed_claa_sunmfee
  901. iteminfo.ClabAmt = bed_clab_amt
  902. iteminfo.OthAmt = bed_other_amt
  903. iteminfoStructs = append(iteminfoStructs, iteminfo)
  904. }
  905. if checkCostTotal != 0 {
  906. iteminfo.MedChrgitm = "03"
  907. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  908. iteminfo.Amt = checkCostTotal
  909. iteminfo.ClaaSumfee = check_claa_sunmfee
  910. iteminfo.ClabAmt = check_clab_amt
  911. iteminfo.OthAmt = check_other_amt
  912. iteminfoStructs = append(iteminfoStructs, iteminfo)
  913. }
  914. if laboratoryCostTotal != 0 {
  915. iteminfo.MedChrgitm = "04"
  916. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  917. iteminfo.Amt = laboratoryCostTotal
  918. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  919. iteminfo.ClabAmt = laboratory_clab_amt
  920. iteminfo.OthAmt = laboratory_other_amt
  921. iteminfoStructs = append(iteminfoStructs, iteminfo)
  922. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  923. }
  924. if treatCostTotal != 0 {
  925. iteminfo.MedChrgitm = "05"
  926. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  927. iteminfo.Amt = treatCostTotal
  928. iteminfo.ClaaSumfee = treat_claa_sunmfee
  929. iteminfo.ClabAmt = treat_clab_amt
  930. iteminfo.OthAmt = treat_other_amt
  931. iteminfoStructs = append(iteminfoStructs, iteminfo)
  932. //(struct4101.IteminfoStruct, iteminfo)
  933. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  934. }
  935. if operationCostTotal != 0 {
  936. iteminfo.MedChrgitm = "06"
  937. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  938. iteminfo.Amt = operationCostTotal
  939. iteminfo.ClaaSumfee = operation_claa_sunmfee
  940. iteminfo.ClabAmt = operation_clab_amt
  941. iteminfo.OthAmt = operation_other_amt
  942. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  943. iteminfoStructs = append(iteminfoStructs, iteminfo)
  944. }
  945. if materialCostTotal != 0 {
  946. iteminfo.MedChrgitm = "08"
  947. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  948. iteminfo.Amt = materialCostTotal
  949. iteminfo.ClaaSumfee = material_claa_sunmfee
  950. iteminfo.ClabAmt = material_clab_amt
  951. iteminfo.OthAmt = material_other_amt
  952. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  953. iteminfoStructs = append(iteminfoStructs, iteminfo)
  954. }
  955. if westernMedicineCostTotal != 0 {
  956. iteminfo.MedChrgitm = "09"
  957. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  958. iteminfo.Amt = westernMedicineCostTotal
  959. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  960. iteminfo.ClabAmt = westernMedicine_clab_amt
  961. iteminfo.OthAmt = westernMedicine_other_amt
  962. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  963. iteminfoStructs = append(iteminfoStructs, iteminfo)
  964. }
  965. if chineseTraditionalMedicineCostTotal != 0 {
  966. iteminfo.MedChrgitm = "11"
  967. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  968. iteminfo.Amt = westernMedicineCostTotal
  969. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  970. iteminfo.ClabAmt = westernMedicine_clab_amt
  971. iteminfo.OthAmt = westernMedicine_other_amt
  972. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  973. iteminfoStructs = append(iteminfoStructs, iteminfo)
  974. }
  975. if otherCostTotal != 0 {
  976. iteminfo.MedChrgitm = "14"
  977. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  978. iteminfo.Amt = otherCostTotal
  979. iteminfo.ClaaSumfee = other_claa_sunmfee
  980. iteminfo.ClabAmt = other_clab_amt
  981. iteminfo.OthAmt = other_other_amt
  982. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  983. iteminfoStructs = append(iteminfoStructs, iteminfo)
  984. }
  985. struct4101.IteminfoStruct = iteminfoStructs
  986. struct4101.Ntly = "中国"
  987. struct4101.AdmCaty = "A03.06"
  988. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  989. fmt.Println(result)
  990. var dat map[string]interface{}
  991. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  992. fmt.Println(dat)
  993. } else {
  994. fmt.Println(err)
  995. }
  996. userJSONBytes, _ := json.Marshal(dat)
  997. var res ResultSeventeen
  998. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  999. utils.ErrorLog("解析失败:%v", err)
  1000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1001. return
  1002. }
  1003. if res.Infcode != 0 {
  1004. c.ServeSuccessJSON(map[string]interface{}{
  1005. "failed_code": -10,
  1006. "msg": res.ErrMsg,
  1007. })
  1008. return
  1009. } else {
  1010. order.FaPiaoNumber = zero
  1011. order.FaPiaoCode = last_order.FaPiaoCode
  1012. service.UpdateOrder(order)
  1013. hisFundSettleListResult := &models.HisFundSettleListResult{
  1014. Number: res.Output.SetlListId,
  1015. Status: 1,
  1016. Ctime: time.Now().Unix(),
  1017. Mtime: time.Now().Unix(),
  1018. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1019. IsUpload: 1,
  1020. OrderId: order_id,
  1021. }
  1022. service.CreateUploadRecord(hisFundSettleListResult)
  1023. c.ServeSuccessJSON(map[string]interface{}{
  1024. "msg": "上传成功",
  1025. "result": hisFundSettleListResult,
  1026. })
  1027. return
  1028. }
  1029. }
  1030. func (c *HisApiController) GetSettleListHospital() {
  1031. order_id, _ := c.GetInt64("order_id")
  1032. admin_user_id, _ := c.GetInt64("admin_user_id")
  1033. order, _ := service.GetHisOrderByIDTwo(order_id)
  1034. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1035. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1036. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1037. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1038. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1039. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1040. if order.ID == 0 {
  1041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1042. return
  1043. }
  1044. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1045. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1046. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1047. fmt.Println(count)
  1048. var zero string
  1049. number := count + 1
  1050. if number >= 1000 {
  1051. zero = "0000" + strconv.FormatInt(number, 10)
  1052. } else if number >= 10000 {
  1053. zero = "000" + strconv.FormatInt(number, 10)
  1054. } else if number >= 100000 {
  1055. zero = "00" + strconv.FormatInt(number, 10)
  1056. } else if number >= 1000000 {
  1057. zero = "0" + strconv.FormatInt(number, 10)
  1058. } else {
  1059. zero = strconv.FormatInt(number, 10)
  1060. }
  1061. fmt.Println(zero)
  1062. struct4101 := service.Struct4101{
  1063. PsnNo: order.PsnNo,
  1064. MdtrtId: order.MdtrtId,
  1065. SetlId: order.SetlId,
  1066. PsnName: order.PsnName,
  1067. Gend: order.Gend,
  1068. Brdy: his.Brdy,
  1069. Age: int64(order.Age),
  1070. Naty: order.Naty,
  1071. PatnCertType: "01",
  1072. Certno: order.Certno,
  1073. Prfs: "90",
  1074. ConerName: roles[0].UserName,
  1075. PatnRlts: "99",
  1076. ConerAddr: miConfig.OrgName,
  1077. ConerTel: admin.Mobile,
  1078. HiType: order.Insutype,
  1079. Insuplc: miConfig.InsuplcAdmdvs,
  1080. MaindiagFlag: "1",
  1081. BillCode: last_order.FaPiaoCode,
  1082. BillNo: zero,
  1083. BizSn: order.Number,
  1084. PsnSelfPay: order.PsnPartAmt,
  1085. PsnOwnPay: order.PsnPartAmt,
  1086. AcctPay: order.AcctPay,
  1087. PsnCashpay: order.PsnCashPay,
  1088. HiPaymtd: "1",
  1089. Hsorg: miConfig.InsuplcAdmdvs,
  1090. HsorgOpter: miConfig.InsuplcAdmdvs,
  1091. MedinsFillPsn: curRoles.UserName,
  1092. MedinsFillDept: depart.Name,
  1093. IptMedType: "2",
  1094. }
  1095. struct4101.SetlBegnDate = order.SetlTime
  1096. struct4101.SetlEndDate = order.SetlTime
  1097. var rf []CustomFundPay
  1098. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1099. var tempFunPays []service.CustomStruct
  1100. for _, item := range rf {
  1101. var tempFunPay service.CustomStruct
  1102. tempFunPay.FundPayamt = item.FundPayamt
  1103. tempFunPay.FundPayType = item.FundPayType
  1104. tempFunPays = append(tempFunPays, tempFunPay)
  1105. }
  1106. struct4101.CustomStruct = tempFunPays
  1107. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1108. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1109. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  1110. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1111. var config []*models.HisXtDiagnoseConfig
  1112. for _, item := range diagnosis_ids {
  1113. id, _ := strconv.ParseInt(item, 10, 64)
  1114. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1115. config = append(config, &diagnosisConfig)
  1116. }
  1117. for _, item := range config {
  1118. var tempOpspdiseinfo service.OpspdiseinfoStruct
  1119. tempOpspdiseinfo.DiagCode = item.CountryCode
  1120. tempOpspdiseinfo.DiagName = item.CountryContentName
  1121. tempOpspdiseinfo.MaindiagFlag = "1"
  1122. tempOpspdiseinfo.OprnOprtCode = ""
  1123. tempOpspdiseinfo.OprnOprtName = ""
  1124. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  1125. }
  1126. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1127. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1128. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1129. tempOpspdiseinfo2.MaindiagFlag = "2"
  1130. tempOpspdiseinfo2.OprnOprtCode = ""
  1131. tempOpspdiseinfo2.OprnOprtName = ""
  1132. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1133. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1134. var iteminfo service.IteminfoStruct
  1135. var bedCostTotal float64 = 0 //床位总费
  1136. var bedCostSelfTotal float64 = 0 //床位自费
  1137. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1138. var operationCostTotal float64 = 0 //手术费
  1139. var operationCostSelfTotal float64 = 0 //手术费
  1140. var operationCostPartSelfTotal float64 = 0 //手术费
  1141. var otherCostTotal float64 = 0 //其他费用
  1142. var otherCostSelfTotal float64 = 0 //其他费用
  1143. var otherCostPartSelfTotal float64 = 0 //其他费用
  1144. var materialCostTotal float64 = 0 //材料费
  1145. var materialCostSelfTotal float64 = 0 //材料费
  1146. var materialCostPartSelfTotal float64 = 0 //材料费
  1147. var westernMedicineCostTotal float64 = 0 //西药费
  1148. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1149. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1150. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1151. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1152. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1153. var checkCostTotal float64 = 0 //检查费
  1154. var checkCostSelfTotal float64 = 0 //检查费
  1155. var checkCostPartSelfTotal float64 = 0 //检查费
  1156. var laboratoryCostTotal float64 = 0 //化验费
  1157. var laboratoryCostSelfTotal float64 = 0 //化验费
  1158. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1159. var treatCostTotal float64 = 0 //治疗费用
  1160. var treatCostSelfTotal float64 = 0 //治疗费用
  1161. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1162. decimal.DivisionPrecision = 2
  1163. var bed_fulamt_ownpay_amt float64 = 0
  1164. var operation_fulamt_ownpay_amt float64 = 0
  1165. var other_fulamt_ownpay_amt float64 = 0
  1166. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1167. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1168. var check_fulamt_ownpay_amt float64 = 0
  1169. var material_fulamt_ownpay_amt float64 = 0
  1170. var laboratory_fulamt_ownpay_amt float64 = 0
  1171. var treat_fulamt_ownpay_amt float64 = 0
  1172. var bed_claa_sunmfee float64 = 0
  1173. var bed_clab_amt float64 = 0
  1174. var bed_other_amt float64 = 0
  1175. var operation_claa_sunmfee float64 = 0
  1176. var operation_clab_amt float64 = 0
  1177. var operation_other_amt float64 = 0
  1178. var other_claa_sunmfee float64 = 0
  1179. var other_clab_amt float64 = 0
  1180. var other_other_amt float64 = 0
  1181. var westernMedicine_claa_sunmfee float64 = 0
  1182. var westernMedicine_clab_amt float64 = 0
  1183. var westernMedicine_other_amt float64 = 0
  1184. var chineseTraditional_claa_sunmfee float64 = 0
  1185. var chineseTraditional_clab_amt float64 = 0
  1186. var chineseTraditional_other_amt float64 = 0
  1187. var check_claa_sunmfee float64 = 0
  1188. var check_clab_amt float64 = 0
  1189. var check_other_amt float64 = 0
  1190. var material_claa_sunmfee float64 = 0
  1191. var material_clab_amt float64 = 0
  1192. var material_other_amt float64 = 0
  1193. var laboratory_claa_sunmfee float64 = 0
  1194. var laboratory_clab_amt float64 = 0
  1195. var laboratory_other_amt float64 = 0
  1196. var treat_claa_sunmfee float64 = 0
  1197. var treat_clab_amt float64 = 0
  1198. var treat_other_amt float64 = 0
  1199. for _, item := range order.HisOrderInfo {
  1200. if item.MedChrgitmType == "01" { //床位费
  1201. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1202. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1203. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1204. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1205. if item.ChrgitmLv == "1" {
  1206. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1207. }
  1208. if item.ChrgitmLv == "2" {
  1209. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1210. }
  1211. if item.ChrgitmLv == "3" {
  1212. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1213. }
  1214. }
  1215. if item.MedChrgitmType == "03" { //检查费
  1216. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1217. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1218. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1219. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1220. if item.ChrgitmLv == "1" {
  1221. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1222. }
  1223. if item.ChrgitmLv == "2" {
  1224. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1225. }
  1226. if item.ChrgitmLv == "3" {
  1227. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1228. }
  1229. }
  1230. if item.MedChrgitmType == "04" { //化验费
  1231. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1232. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1233. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1234. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1235. if item.ChrgitmLv == "1" {
  1236. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1237. }
  1238. if item.ChrgitmLv == "2" {
  1239. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1240. }
  1241. if item.ChrgitmLv == "3" {
  1242. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1243. }
  1244. }
  1245. if item.MedChrgitmType == "05" { //治疗费
  1246. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1247. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1248. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1249. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1250. if item.ChrgitmLv == "1" {
  1251. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1252. }
  1253. if item.ChrgitmLv == "2" {
  1254. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1255. }
  1256. if item.ChrgitmLv == "3" {
  1257. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1258. }
  1259. }
  1260. if item.MedChrgitmType == "06" { //手术费
  1261. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1262. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1263. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1264. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1265. if item.ChrgitmLv == "1" {
  1266. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1267. }
  1268. if item.ChrgitmLv == "2" {
  1269. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1270. }
  1271. if item.ChrgitmLv == "3" {
  1272. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1273. }
  1274. }
  1275. if item.MedChrgitmType == "08" { //材料费
  1276. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1277. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1278. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1279. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1280. if item.ChrgitmLv == "1" {
  1281. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1282. }
  1283. if item.ChrgitmLv == "2" {
  1284. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1285. }
  1286. if item.ChrgitmLv == "3" {
  1287. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1288. }
  1289. }
  1290. if item.MedChrgitmType == "09" { //西药费
  1291. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1292. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1293. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1294. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1295. if item.ChrgitmLv == "1" {
  1296. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1297. }
  1298. if item.ChrgitmLv == "2" {
  1299. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1300. }
  1301. if item.ChrgitmLv == "3" {
  1302. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1303. }
  1304. }
  1305. if item.MedChrgitmType == "11" { //中成费
  1306. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1307. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1308. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1309. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1310. if item.ChrgitmLv == "1" {
  1311. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1312. }
  1313. if item.ChrgitmLv == "2" {
  1314. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1315. }
  1316. if item.ChrgitmLv == "3" {
  1317. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1318. }
  1319. }
  1320. if item.MedChrgitmType == "14" { //其他费
  1321. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1322. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1323. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1324. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1325. if item.ChrgitmLv == "1" {
  1326. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1327. }
  1328. if item.ChrgitmLv == "2" {
  1329. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1330. }
  1331. if item.ChrgitmLv == "3" {
  1332. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1333. }
  1334. }
  1335. }
  1336. var iteminfoStructs []service.IteminfoStruct
  1337. if bedCostTotal != 0 {
  1338. iteminfo.MedChrgitm = "01"
  1339. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1340. iteminfo.Amt = bedCostTotal
  1341. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1342. iteminfo.ClabAmt = bed_clab_amt
  1343. iteminfo.OthAmt = bed_other_amt
  1344. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1345. }
  1346. if checkCostTotal != 0 {
  1347. iteminfo.MedChrgitm = "03"
  1348. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1349. iteminfo.Amt = checkCostTotal
  1350. iteminfo.ClaaSumfee = check_claa_sunmfee
  1351. iteminfo.ClabAmt = check_clab_amt
  1352. iteminfo.OthAmt = check_other_amt
  1353. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1354. }
  1355. if laboratoryCostTotal != 0 {
  1356. iteminfo.MedChrgitm = "04"
  1357. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1358. iteminfo.Amt = laboratoryCostTotal
  1359. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1360. iteminfo.ClabAmt = laboratory_clab_amt
  1361. iteminfo.OthAmt = laboratory_other_amt
  1362. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1363. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1364. }
  1365. if treatCostTotal != 0 {
  1366. iteminfo.MedChrgitm = "05"
  1367. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1368. iteminfo.Amt = treatCostTotal
  1369. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1370. iteminfo.ClabAmt = treat_clab_amt
  1371. iteminfo.OthAmt = treat_other_amt
  1372. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1373. //(struct4101.IteminfoStruct, iteminfo)
  1374. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1375. }
  1376. if operationCostTotal != 0 {
  1377. iteminfo.MedChrgitm = "06"
  1378. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1379. iteminfo.Amt = operationCostTotal
  1380. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1381. iteminfo.ClabAmt = operation_clab_amt
  1382. iteminfo.OthAmt = operation_other_amt
  1383. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1384. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1385. }
  1386. if materialCostTotal != 0 {
  1387. iteminfo.MedChrgitm = "08"
  1388. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1389. iteminfo.Amt = materialCostTotal
  1390. iteminfo.ClaaSumfee = material_claa_sunmfee
  1391. iteminfo.ClabAmt = material_clab_amt
  1392. iteminfo.OthAmt = material_other_amt
  1393. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1394. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1395. }
  1396. if westernMedicineCostTotal != 0 {
  1397. iteminfo.MedChrgitm = "09"
  1398. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1399. iteminfo.Amt = westernMedicineCostTotal
  1400. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1401. iteminfo.ClabAmt = westernMedicine_clab_amt
  1402. iteminfo.OthAmt = westernMedicine_other_amt
  1403. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1404. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1405. }
  1406. if chineseTraditionalMedicineCostTotal != 0 {
  1407. iteminfo.MedChrgitm = "11"
  1408. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1409. iteminfo.Amt = westernMedicineCostTotal
  1410. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1411. iteminfo.ClabAmt = westernMedicine_clab_amt
  1412. iteminfo.OthAmt = westernMedicine_other_amt
  1413. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1414. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1415. }
  1416. if otherCostTotal != 0 {
  1417. iteminfo.MedChrgitm = "14"
  1418. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1419. iteminfo.Amt = otherCostTotal
  1420. iteminfo.ClaaSumfee = other_claa_sunmfee
  1421. iteminfo.ClabAmt = other_clab_amt
  1422. iteminfo.OthAmt = other_other_amt
  1423. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1424. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1425. }
  1426. struct4101.IteminfoStruct = iteminfoStructs
  1427. struct4101.Ntly = "中国"
  1428. struct4101.AdmCaty = "A03.06"
  1429. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1430. fmt.Println(result)
  1431. var dat map[string]interface{}
  1432. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1433. fmt.Println(dat)
  1434. } else {
  1435. fmt.Println(err)
  1436. }
  1437. userJSONBytes, _ := json.Marshal(dat)
  1438. var res ResultSeventeen
  1439. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1440. utils.ErrorLog("解析失败:%v", err)
  1441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1442. return
  1443. }
  1444. if res.Infcode != 0 {
  1445. c.ServeSuccessJSON(map[string]interface{}{
  1446. "failed_code": -10,
  1447. "msg": res.ErrMsg,
  1448. })
  1449. return
  1450. } else {
  1451. order.FaPiaoNumber = zero
  1452. order.FaPiaoCode = last_order.FaPiaoCode
  1453. service.UpdateOrder(order)
  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. c.ServeSuccessJSON(map[string]interface{}{
  1465. "msg": "上传成功",
  1466. "result": hisFundSettleListResult,
  1467. })
  1468. return
  1469. }
  1470. }
  1471. func (c *HisApiController) GetBatchSettleList() {
  1472. org_id, _ := beego.AppConfig.Int64("org_id")
  1473. //stage, _ := c.GetInt64("stage")
  1474. orders, _ := service.GetAllHisOrder(org_id)
  1475. for _, item := range orders {
  1476. order_id := item.ID
  1477. order, _ := service.GetHisOrderByIDTwo(order_id)
  1478. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1479. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1480. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1481. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2185)
  1482. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1483. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1484. if order.ID == 0 {
  1485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1486. return
  1487. }
  1488. if his.BalanceAccountsType == 2 {
  1489. continue
  1490. }
  1491. struct4101 := service.Struct4101{
  1492. PsnNo: order.PsnNo,
  1493. MdtrtId: order.MdtrtId,
  1494. SetlId: order.SetlId,
  1495. PsnName: order.PsnName,
  1496. Gend: order.Gend,
  1497. Brdy: his.Brdy,
  1498. Age: his.Age,
  1499. Naty: order.Naty,
  1500. PatnCertType: "01",
  1501. Certno: order.Certno,
  1502. Prfs: "90",
  1503. ConerName: roles[0].UserName,
  1504. PatnRlts: "99",
  1505. ConerAddr: miConfig.OrgName,
  1506. ConerTel: admin.Mobile,
  1507. HiType: order.Insutype,
  1508. Insuplc: his.InsuplcAdmdvs,
  1509. MaindiagFlag: "1",
  1510. BillCode: order.FaPiaoCode,
  1511. BillNo: order.FaPiaoNumber,
  1512. BizSn: order.Number,
  1513. PsnSelfPay: order.PsnPartAmt,
  1514. PsnOwnPay: order.PsnPartAmt,
  1515. AcctPay: order.AcctPay,
  1516. PsnCashpay: order.PsnCashPay,
  1517. HiPaymtd: "1",
  1518. Hsorg: his.InsuplcAdmdvs,
  1519. HsorgOpter: his.InsuplcAdmdvs,
  1520. MedinsFillPsn: curRoles.UserName,
  1521. MedinsFillDept: depart.Name,
  1522. IptMedType: "2",
  1523. }
  1524. struct4101.SetlBegnDate = order.SetlTime
  1525. struct4101.SetlEndDate = order.SetlTime
  1526. //if order.SettleType == 1 {
  1527. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  1528. // dateStr := t.Format("2006-01-02")
  1529. // struct4101.SetlBegnDate = dateStr
  1530. // struct4101.SetlEndDate = dateStr
  1531. //} else {
  1532. // t := time.Unix(int64(order.SettleStartTime), 0)
  1533. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  1534. // dateStartStr := t.Format("2006-01-02")
  1535. // dateEndStr := t2.Format("2006-01-02")
  1536. // struct4101.SetlBegnDate = dateStartStr
  1537. // struct4101.SetlEndDate = dateEndStr
  1538. //}
  1539. var rf []CustomFundPay
  1540. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1541. var tempFunPays []service.CustomStruct
  1542. var tempFunPay610100 service.CustomStruct
  1543. for _, item := range rf {
  1544. if item.FundPayType == "610100" {
  1545. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  1546. tempFunPay610100.FundPayType = item.FundPayType
  1547. } else {
  1548. var tempFunPay service.CustomStruct
  1549. tempFunPay.FundPayamt = item.FundPayamt
  1550. tempFunPay.FundPayType = item.FundPayType
  1551. tempFunPays = append(tempFunPays, tempFunPay)
  1552. }
  1553. }
  1554. tempFunPays = append(tempFunPays, tempFunPay610100)
  1555. struct4101.CustomStruct = tempFunPays
  1556. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1557. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1558. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  1559. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1560. var config []*models.HisXtDiagnoseConfig
  1561. for _, item := range diagnosis_ids {
  1562. id, _ := strconv.ParseInt(item, 10, 64)
  1563. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1564. config = append(config, &diagnosisConfig)
  1565. }
  1566. for index, item := range config {
  1567. var tempOpspdiseinfo service.OpspdiseinfoStruct
  1568. tempOpspdiseinfo.DiagCode = item.CountryCode
  1569. tempOpspdiseinfo.DiagName = item.CountryContentName
  1570. tempOpspdiseinfo.MaindiagFlag = strconv.Itoa(index)
  1571. tempOpspdiseinfo.OprnOprtCode = ""
  1572. tempOpspdiseinfo.OprnOprtName = ""
  1573. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  1574. }
  1575. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1576. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1577. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1578. tempOpspdiseinfo2.MaindiagFlag = "1"
  1579. tempOpspdiseinfo2.OprnOprtCode = ""
  1580. tempOpspdiseinfo2.OprnOprtName = ""
  1581. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1582. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1583. var iteminfo service.IteminfoStruct
  1584. var bedCostTotal float64 = 0 //床位总费
  1585. var bedCostSelfTotal float64 = 0 //床位自费
  1586. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1587. var examineCostTotal float64 = 0 //诊查总费
  1588. var examineCostSelfTotal float64 = 0 //诊查自费
  1589. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  1590. var nursingCostTotal float64 = 0 //护理总费
  1591. var nursingCostSelfTotal float64 = 0 //护理自费
  1592. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  1593. var chineseMedicineCostTotal float64 = 0 //中成药
  1594. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  1595. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  1596. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  1597. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  1598. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  1599. var registerCostTotal float64 = 0 //一般诊疗费
  1600. var registerCostSelfTotal float64 = 0 //一般诊疗费
  1601. var registerPartSelfTotal float64 = 0 //一般诊疗费
  1602. var operationCostTotal float64 = 0 //手术费
  1603. var operationCostSelfTotal float64 = 0 //手术费
  1604. var operationCostPartSelfTotal float64 = 0 //手术费
  1605. var otherCostTotal float64 = 0 //其他费用
  1606. var otherCostSelfTotal float64 = 0 //其他费用
  1607. var otherCostPartSelfTotal float64 = 0 //其他费用
  1608. var materialCostTotal float64 = 0 //材料费
  1609. var materialCostSelfTotal float64 = 0 //材料费
  1610. var materialCostPartSelfTotal float64 = 0 //材料费
  1611. var westernMedicineCostTotal float64 = 0 //西药费
  1612. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1613. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1614. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1615. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1616. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1617. var checkCostTotal float64 = 0 //检查费
  1618. var checkCostSelfTotal float64 = 0 //检查费
  1619. var checkCostPartSelfTotal float64 = 0 //检查费
  1620. var laboratoryCostTotal float64 = 0 //化验费
  1621. var laboratoryCostSelfTotal float64 = 0 //化验费
  1622. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1623. var treatCostTotal float64 = 0 //治疗费用
  1624. var treatCostSelfTotal float64 = 0 //治疗费用
  1625. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1626. decimal.DivisionPrecision = 2
  1627. var bed_fulamt_ownpay_amt float64 = 0
  1628. var examine_fulamt_ownpay_amt float64 = 0
  1629. var nursing_fulamt_ownpay_amt float64 = 0
  1630. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  1631. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  1632. var register_fulamt_ownpay_amt float64 = 0
  1633. var operation_fulamt_ownpay_amt float64 = 0
  1634. var other_fulamt_ownpay_amt float64 = 0
  1635. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1636. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1637. var check_fulamt_ownpay_amt float64 = 0
  1638. var material_fulamt_ownpay_amt float64 = 0
  1639. var laboratory_fulamt_ownpay_amt float64 = 0
  1640. var treat_fulamt_ownpay_amt float64 = 0
  1641. var bed_claa_sunmfee float64 = 0
  1642. var bed_clab_amt float64 = 0
  1643. var bed_other_amt float64 = 0
  1644. var examine_claa_sunmfee float64 = 0
  1645. var examine_clab_amt float64 = 0
  1646. var examine_other_amt float64 = 0
  1647. var nursing_claa_sunmfee float64 = 0
  1648. var nursing_clab_amt float64 = 0
  1649. var nursing_other_amt float64 = 0
  1650. var chinese_medicine_claa_sunmfee float64 = 0
  1651. var chinese_medicine_clab_amt float64 = 0
  1652. var chinese_medicine_other_amt float64 = 0
  1653. var commonly_treatment_claa_sunmfee float64 = 0
  1654. var commonly_treatment_clab_amt float64 = 0
  1655. var commonly_treatment_other_amt float64 = 0
  1656. var operation_claa_sunmfee float64 = 0
  1657. var operation_clab_amt float64 = 0
  1658. var operation_other_amt float64 = 0
  1659. var other_claa_sunmfee float64 = 0
  1660. var other_clab_amt float64 = 0
  1661. var other_other_amt float64 = 0
  1662. var westernMedicine_claa_sunmfee float64 = 0
  1663. var westernMedicine_clab_amt float64 = 0
  1664. var westernMedicine_other_amt float64 = 0
  1665. var chineseTraditional_claa_sunmfee float64 = 0
  1666. var chineseTraditional_clab_amt float64 = 0
  1667. var chineseTraditional_other_amt float64 = 0
  1668. var check_claa_sunmfee float64 = 0
  1669. var check_clab_amt float64 = 0
  1670. var check_other_amt float64 = 0
  1671. var material_claa_sunmfee float64 = 0
  1672. var material_clab_amt float64 = 0
  1673. var material_other_amt float64 = 0
  1674. var laboratory_claa_sunmfee float64 = 0
  1675. var laboratory_clab_amt float64 = 0
  1676. var laboratory_other_amt float64 = 0
  1677. var treat_claa_sunmfee float64 = 0
  1678. var treat_clab_amt float64 = 0
  1679. var treat_other_amt float64 = 0
  1680. var register_claa_sunmfee float64 = 0
  1681. var register_clab_amt float64 = 0
  1682. var register_other_amt float64 = 0
  1683. for _, item := range order.HisOrderInfo {
  1684. if item.MedChrgitmType == "01" { //床位费
  1685. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1686. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1687. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1688. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1689. if item.ChrgitmLv == "1" {
  1690. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1691. }
  1692. if item.ChrgitmLv == "2" {
  1693. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1694. }
  1695. if item.ChrgitmLv == "3" {
  1696. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1697. }
  1698. }
  1699. if item.MedChrgitmType == "02" { //诊查
  1700. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1701. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1702. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1703. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1704. if item.ChrgitmLv == "1" {
  1705. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1706. }
  1707. if item.ChrgitmLv == "2" {
  1708. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1709. }
  1710. if item.ChrgitmLv == "3" {
  1711. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1712. }
  1713. }
  1714. if item.MedChrgitmType == "03" { //检查费
  1715. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1716. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1717. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1718. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1719. if item.ChrgitmLv == "1" {
  1720. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1721. }
  1722. if item.ChrgitmLv == "2" {
  1723. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1724. }
  1725. if item.ChrgitmLv == "3" {
  1726. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1727. }
  1728. }
  1729. if item.MedChrgitmType == "04" { //化验费
  1730. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1731. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1732. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1733. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1734. if item.ChrgitmLv == "1" {
  1735. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1736. }
  1737. if item.ChrgitmLv == "2" {
  1738. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1739. }
  1740. if item.ChrgitmLv == "3" {
  1741. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1742. }
  1743. }
  1744. if item.MedChrgitmType == "05" { //治疗费
  1745. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1746. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1747. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1748. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1749. if item.ChrgitmLv == "1" {
  1750. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1751. }
  1752. if item.ChrgitmLv == "2" {
  1753. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1754. }
  1755. if item.ChrgitmLv == "3" {
  1756. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1757. }
  1758. }
  1759. if item.MedChrgitmType == "06" { //手术费
  1760. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1761. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1762. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1763. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1764. if item.ChrgitmLv == "1" {
  1765. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1766. }
  1767. if item.ChrgitmLv == "2" {
  1768. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1769. }
  1770. if item.ChrgitmLv == "3" {
  1771. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1772. }
  1773. }
  1774. if item.MedChrgitmType == "07" { //手术费
  1775. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1776. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1777. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1778. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1779. if item.ChrgitmLv == "1" {
  1780. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1781. }
  1782. if item.ChrgitmLv == "2" {
  1783. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1784. }
  1785. if item.ChrgitmLv == "3" {
  1786. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1787. }
  1788. }
  1789. if item.MedChrgitmType == "08" { //材料费
  1790. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1791. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1792. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1793. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1794. if item.ChrgitmLv == "1" {
  1795. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1796. }
  1797. if item.ChrgitmLv == "2" {
  1798. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1799. }
  1800. if item.ChrgitmLv == "3" {
  1801. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1802. }
  1803. }
  1804. if item.MedChrgitmType == "09" { //西药费
  1805. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1806. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1807. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1808. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1809. if item.ChrgitmLv == "1" {
  1810. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1811. }
  1812. if item.ChrgitmLv == "2" {
  1813. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1814. }
  1815. if item.ChrgitmLv == "3" {
  1816. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1817. }
  1818. }
  1819. if item.MedChrgitmType == "10" { //中药饮片
  1820. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1821. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1822. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1823. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1824. if item.ChrgitmLv == "1" {
  1825. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1826. }
  1827. if item.ChrgitmLv == "2" {
  1828. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1829. }
  1830. if item.ChrgitmLv == "3" {
  1831. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1832. }
  1833. }
  1834. if item.MedChrgitmType == "11" { //中成费
  1835. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1836. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1837. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1838. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1839. if item.ChrgitmLv == "1" {
  1840. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1841. }
  1842. if item.ChrgitmLv == "2" {
  1843. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1844. }
  1845. if item.ChrgitmLv == "3" {
  1846. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1847. }
  1848. }
  1849. if item.MedChrgitmType == "12" { //中成费
  1850. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1851. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1852. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1853. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1854. if item.ChrgitmLv == "1" {
  1855. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1856. }
  1857. if item.ChrgitmLv == "2" {
  1858. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1859. }
  1860. if item.ChrgitmLv == "3" {
  1861. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1862. }
  1863. }
  1864. if item.MedChrgitmType == "13" { //中成费
  1865. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1866. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1867. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1868. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1869. if item.ChrgitmLv == "1" {
  1870. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1871. }
  1872. if item.ChrgitmLv == "2" {
  1873. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1874. }
  1875. if item.ChrgitmLv == "3" {
  1876. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1877. }
  1878. }
  1879. if item.MedChrgitmType == "14" { //其他费
  1880. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1881. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1882. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1883. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1884. if item.ChrgitmLv == "1" {
  1885. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1886. }
  1887. if item.ChrgitmLv == "2" {
  1888. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1889. }
  1890. if item.ChrgitmLv == "3" {
  1891. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1892. }
  1893. }
  1894. }
  1895. var iteminfoStructs []service.IteminfoStruct
  1896. if bedCostTotal != 0 {
  1897. iteminfo.MedChrgitm = "01"
  1898. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1899. iteminfo.Amt = bedCostTotal
  1900. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1901. iteminfo.ClabAmt = bed_clab_amt
  1902. iteminfo.OthAmt = bed_other_amt
  1903. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1904. }
  1905. if examineCostTotal != 0 {
  1906. iteminfo.MedChrgitm = "02"
  1907. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  1908. iteminfo.Amt = examineCostTotal
  1909. iteminfo.ClaaSumfee = examine_claa_sunmfee
  1910. iteminfo.ClabAmt = examine_clab_amt
  1911. iteminfo.OthAmt = examine_other_amt
  1912. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1913. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1914. }
  1915. if checkCostTotal != 0 {
  1916. iteminfo.MedChrgitm = "03"
  1917. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1918. iteminfo.Amt = checkCostTotal
  1919. iteminfo.ClaaSumfee = check_claa_sunmfee
  1920. iteminfo.ClabAmt = check_clab_amt
  1921. iteminfo.OthAmt = check_other_amt
  1922. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1923. }
  1924. if laboratoryCostTotal != 0 {
  1925. iteminfo.MedChrgitm = "04"
  1926. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1927. iteminfo.Amt = laboratoryCostTotal
  1928. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1929. iteminfo.ClabAmt = laboratory_clab_amt
  1930. iteminfo.OthAmt = laboratory_other_amt
  1931. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1932. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1933. }
  1934. if treatCostTotal != 0 {
  1935. iteminfo.MedChrgitm = "05"
  1936. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1937. iteminfo.Amt = treatCostTotal
  1938. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1939. iteminfo.ClabAmt = treat_clab_amt
  1940. iteminfo.OthAmt = treat_other_amt
  1941. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1942. //(struct4101.IteminfoStruct, iteminfo)
  1943. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1944. }
  1945. if operationCostTotal != 0 {
  1946. iteminfo.MedChrgitm = "06"
  1947. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1948. iteminfo.Amt = operationCostTotal
  1949. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1950. iteminfo.ClabAmt = operation_clab_amt
  1951. iteminfo.OthAmt = operation_other_amt
  1952. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1953. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1954. }
  1955. if nursingCostTotal != 0 {
  1956. iteminfo.MedChrgitm = "07"
  1957. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  1958. iteminfo.Amt = nursingCostTotal
  1959. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  1960. iteminfo.ClabAmt = nursing_clab_amt
  1961. iteminfo.OthAmt = nursing_other_amt
  1962. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1963. }
  1964. if materialCostTotal != 0 {
  1965. iteminfo.MedChrgitm = "08"
  1966. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1967. iteminfo.Amt = materialCostTotal
  1968. iteminfo.ClaaSumfee = material_claa_sunmfee
  1969. iteminfo.ClabAmt = material_clab_amt
  1970. iteminfo.OthAmt = material_other_amt
  1971. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1972. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1973. }
  1974. if westernMedicineCostTotal != 0 {
  1975. iteminfo.MedChrgitm = "09"
  1976. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1977. iteminfo.Amt = westernMedicineCostTotal
  1978. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1979. iteminfo.ClabAmt = westernMedicine_clab_amt
  1980. iteminfo.OthAmt = westernMedicine_other_amt
  1981. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1982. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1983. }
  1984. if chineseMedicineCostTotal != 0 {
  1985. iteminfo.MedChrgitm = "10"
  1986. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  1987. iteminfo.Amt = chineseMedicineCostTotal
  1988. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  1989. iteminfo.ClabAmt = chinese_medicine_clab_amt
  1990. iteminfo.OthAmt = chinese_medicine_other_amt
  1991. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1992. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1993. }
  1994. if chineseTraditionalMedicineCostTotal != 0 {
  1995. iteminfo.MedChrgitm = "11"
  1996. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1997. iteminfo.Amt = westernMedicineCostTotal
  1998. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1999. iteminfo.ClabAmt = westernMedicine_clab_amt
  2000. iteminfo.OthAmt = westernMedicine_other_amt
  2001. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2002. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2003. }
  2004. if commonlyTreatmentCostTotal != 0 {
  2005. iteminfo.MedChrgitm = "12"
  2006. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2007. iteminfo.Amt = commonlyTreatmentCostTotal
  2008. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2009. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2010. iteminfo.OthAmt = commonly_treatment_other_amt
  2011. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2012. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2013. }
  2014. if registerCostTotal != 0 {
  2015. iteminfo.MedChrgitm = "13"
  2016. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2017. iteminfo.Amt = registerCostTotal
  2018. iteminfo.ClaaSumfee = register_claa_sunmfee
  2019. iteminfo.ClabAmt = register_clab_amt
  2020. iteminfo.OthAmt = register_other_amt
  2021. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2022. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2023. }
  2024. if otherCostTotal != 0 {
  2025. iteminfo.MedChrgitm = "14"
  2026. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2027. iteminfo.Amt = otherCostTotal
  2028. iteminfo.ClaaSumfee = other_claa_sunmfee
  2029. iteminfo.ClabAmt = other_clab_amt
  2030. iteminfo.OthAmt = other_other_amt
  2031. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2032. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2033. }
  2034. struct4101.IteminfoStruct = iteminfoStructs
  2035. struct4101.Ntly = "中国"
  2036. struct4101.AdmCaty = "A03.06"
  2037. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, org_id)
  2038. fmt.Println(result)
  2039. var dat map[string]interface{}
  2040. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2041. fmt.Println(dat)
  2042. } else {
  2043. fmt.Println(err)
  2044. }
  2045. userJSONBytes, _ := json.Marshal(dat)
  2046. var res ResultSeventeen
  2047. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2048. utils.ErrorLog("解析失败:%v", err)
  2049. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2050. adminUser := c.GetAdminUserInfo()
  2051. errlog := &models.HisOrderError{
  2052. UserOrgId: adminUser.CurrentOrgId,
  2053. Ctime: time.Now().Unix(),
  2054. Mtime: time.Now().Unix(),
  2055. ErrMsg: res.ErrMsg + "解析失败",
  2056. Status: 1,
  2057. PatientId: order_id,
  2058. Stage: 1000,
  2059. }
  2060. service.CreateErrMsgLog(errlog)
  2061. continue
  2062. }
  2063. if res.Infcode != 0 {
  2064. adminUser := c.GetAdminUserInfo()
  2065. errlog := &models.HisOrderError{
  2066. UserOrgId: adminUser.CurrentOrgId,
  2067. Ctime: time.Now().Unix(),
  2068. Mtime: time.Now().Unix(),
  2069. ErrMsg: res.ErrMsg,
  2070. Status: 1,
  2071. PatientId: order_id,
  2072. Stage: 1000,
  2073. }
  2074. service.CreateErrMsgLog(errlog)
  2075. continue
  2076. } else {
  2077. hisFundSettleListResult := &models.HisFundSettleListResult{
  2078. Number: res.Output.SetlListId,
  2079. Status: 1,
  2080. Ctime: time.Now().Unix(),
  2081. Mtime: time.Now().Unix(),
  2082. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2083. IsUpload: 1,
  2084. OrderId: order_id,
  2085. }
  2086. service.CreateUploadRecord(hisFundSettleListResult)
  2087. continue
  2088. }
  2089. }
  2090. }
  2091. func (c *HisApiController) GetOrgInfo() {
  2092. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2093. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2094. }
  2095. func (c *HisApiController) GetHisPatientInfo() {
  2096. medical_insurance_card := c.GetString("medical_insurance_card")
  2097. id_card_type, _ := c.GetInt64("id_card_type")
  2098. id_card := c.GetString("id_card")
  2099. adminInfo := c.GetAdminUserInfo()
  2100. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2101. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2102. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2103. IdCardNo := ""
  2104. if id_card_type == 1 {
  2105. IdCardNo = medical_insurance_card
  2106. } else if id_card_type == 2 {
  2107. IdCardNo = id_card
  2108. }
  2109. if config.IsOpen == 1 {
  2110. 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
  2111. resp, requestErr := http.Get(api)
  2112. if requestErr != nil {
  2113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2114. return
  2115. }
  2116. defer resp.Body.Close()
  2117. body, ioErr := ioutil.ReadAll(resp.Body)
  2118. if ioErr != nil {
  2119. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2121. return
  2122. }
  2123. var respJSON map[string]interface{}
  2124. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2127. return
  2128. }
  2129. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2130. userJSONBytes, _ := json.Marshal(userJSON)
  2131. var res ResultTwo
  2132. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2133. utils.ErrorLog("解析失败:%v", err)
  2134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2135. return
  2136. }
  2137. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2138. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2139. infoStr := string(Iinfos)
  2140. idetinfoStr := string(Idetinfos)
  2141. if res.Infcode == 0 {
  2142. his := models.VMHisPatient{
  2143. Status: 1,
  2144. Ctime: time.Now().Unix(),
  2145. Mtime: time.Now().Unix(),
  2146. PsnNo: res.Output.Baseinfo.PsnNo,
  2147. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2148. Certno: res.Output.Baseinfo.Certno,
  2149. PsnName: res.Output.Baseinfo.PsnName,
  2150. Gend: res.Output.Baseinfo.Gend,
  2151. Naty: res.Output.Baseinfo.Naty,
  2152. Brdy: res.Output.Baseinfo.Brdy,
  2153. Age: res.Output.Baseinfo.Age,
  2154. Iinfo: infoStr,
  2155. Idetinfo: idetinfoStr,
  2156. UserOrgId: adminInfo.CurrentOrgId,
  2157. IsReturn: 1,
  2158. IdCardType: id_card_type,
  2159. }
  2160. c.ServeSuccessJSON(map[string]interface{}{
  2161. "info": his,
  2162. })
  2163. } else {
  2164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2165. return
  2166. }
  2167. }
  2168. }
  2169. //func GetBasBaseInfo() (jsonStr string, err error) {
  2170. //
  2171. // handle := syscall.NewLazyDLL("SSCard.dll")
  2172. // add := handle.NewProc("ReadCardBas")
  2173. // str := make([]byte, 1024)
  2174. // str1 := make([]byte, 1024)
  2175. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2176. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  2177. //
  2178. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  2179. //
  2180. // fmt.Println("> Add(4,5)的结果为:", ret)
  2181. // handle.Release()
  2182. //
  2183. // return "", nil
  2184. //
  2185. //}
  2186. //func GetQRBaseInfo() (jsonStr string, err error) {
  2187. // handle := syscall.LoadDLL("SSCard.dll")
  2188. // ReadCardBas := handle.FindProc("GetQRBase")
  2189. //
  2190. // str := make([]byte, 256)
  2191. // str1 := make([]byte, 256)
  2192. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2193. //
  2194. // fmt.Println(string(str))
  2195. // fmt.Println(r)
  2196. // return string(str), nil
  2197. //}
  2198. //func CardInit() int {
  2199. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  2200. // add := DllTestDef.MustFindProc("Init")
  2201. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2202. // if err != nil {
  2203. // fmt.Println("SSCard的运算结果为:", ret)
  2204. // }
  2205. // result := int(ret)
  2206. // return result
  2207. //}
  2208. //func CardInit() int {
  2209. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2210. // if err != nil {
  2211. // fmt.Println("SSCard的运算结果为:", ret)
  2212. // }
  2213. // fmt.Println(err)
  2214. // result := int(ret)
  2215. // return result
  2216. //}
  2217. func IntPtr(n int) uintptr {
  2218. return uintptr(n)
  2219. }
  2220. func StrPtr(s string) uintptr {
  2221. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  2222. }
  2223. type Result2001 struct {
  2224. Cainfo interface{} `json:"cainfo"`
  2225. ErrMsg string `json:"err_msg"`
  2226. InfRefmsgid string `json:"inf_refmsgid"`
  2227. Infcode int64 `json:"infcode"`
  2228. Output struct {
  2229. Trtinfo struct {
  2230. PsnNo string `json:"psn_no"`
  2231. TrtChkType string `json:"trt_chk_type"`
  2232. FundPayType string `json:"fund_pay_type"`
  2233. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2234. Begndate string `json:"begndate"`
  2235. Enddate string `json:"enddate"`
  2236. TrtChkRslt string `json:"trt_chk_rslt"`
  2237. } `json:"trtinfo"`
  2238. } `json:"output"`
  2239. RefmsgTime string `json:"refmsg_time"`
  2240. RespondTime string `json:"respond_time"`
  2241. Signtype interface{} `json:"signtype"`
  2242. WarnMsg interface{} `json:"warn_msg"`
  2243. }
  2244. type Result2001Org10265 struct {
  2245. Cainfo interface{} `json:"cainfo"`
  2246. ErrMsg string `json:"err_msg"`
  2247. InfRefmsgid string `json:"inf_refmsgid"`
  2248. Infcode string `json:"infcode"`
  2249. Output struct {
  2250. Trtinfo struct {
  2251. PsnNo string `json:"psn_no"`
  2252. TrtChkType string `json:"trt_chk_type"`
  2253. FundPayType string `json:"fund_pay_type"`
  2254. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2255. Begndate string `json:"begndate"`
  2256. Enddate string `json:"enddate"`
  2257. TrtChkRslt string `json:"trt_chk_rslt"`
  2258. } `json:"trtinfo"`
  2259. } `json:"output"`
  2260. RefmsgTime string `json:"refmsg_time"`
  2261. RespondTime string `json:"respond_time"`
  2262. Signtype interface{} `json:"signtype"`
  2263. WarnMsg interface{} `json:"warn_msg"`
  2264. }
  2265. type ResultTwo struct {
  2266. ErrMsg string `json:"err_msg"`
  2267. InfRefmsgid string `json:"inf_refmsgid"`
  2268. Infcode int64 `json:"infcode"`
  2269. Output struct {
  2270. Baseinfo struct {
  2271. Age float64 `json:"age"`
  2272. Brdy string `json:"brdy"`
  2273. Certno string `json:"certno"`
  2274. Gend string `json:"gend"`
  2275. Naty string `json:"naty"`
  2276. PsnCertType string `json:"psn_cert_type"`
  2277. PsnName string `json:"psn_name"`
  2278. PsnNo string `json:"psn_no"`
  2279. } `json:"baseinfo"`
  2280. Idetinfo []interface{} `json:"idetinfo"`
  2281. Iinfo []struct {
  2282. Balc float64 `json:"balc"`
  2283. CvlservFlag string `json:"cvlserv_flag"`
  2284. EmpName string `json:"emp_name"`
  2285. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2286. Insutype string `json:"insutype"`
  2287. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2288. PausInsuDate string `json:"paus_insu_date"`
  2289. PsnInsuDate string `json:"psn_insu_date"`
  2290. PsnInsuStas string `json:"psn_insu_stas"`
  2291. PsnType string `json:"psn_type"`
  2292. } `json:"insuinfo"`
  2293. } `json:"output"`
  2294. RefmsgTime string `json:"refmsg_time"`
  2295. RespondTime string `json:"respond_time"`
  2296. Signtype interface{} `json:"signtype"`
  2297. WarnInfo interface{} `json:"warn_info"`
  2298. }
  2299. type ResultTwo10265 struct {
  2300. ErrMsg string `json:"err_msg"`
  2301. InfRefmsgid string `json:"inf_refmsgid"`
  2302. Infcode string `json:"infcode"`
  2303. Output struct {
  2304. Baseinfo struct {
  2305. Age float64 `json:"age"`
  2306. Brdy string `json:"brdy"`
  2307. Certno string `json:"certno"`
  2308. Gend string `json:"gend"`
  2309. Naty string `json:"naty"`
  2310. PsnCertType string `json:"psn_cert_type"`
  2311. PsnName string `json:"psn_name"`
  2312. PsnNo string `json:"psn_no"`
  2313. } `json:"baseinfo"`
  2314. Idetinfo []interface{} `json:"idetinfo"`
  2315. Iinfo []struct {
  2316. Balc float64 `json:"balc"`
  2317. CvlservFlag string `json:"cvlserv_flag"`
  2318. EmpName string `json:"emp_name"`
  2319. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2320. Insutype string `json:"insutype"`
  2321. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2322. PausInsuDate string `json:"paus_insu_date"`
  2323. PsnInsuDate string `json:"psn_insu_date"`
  2324. PsnInsuStas string `json:"psn_insu_stas"`
  2325. PsnType string `json:"psn_type"`
  2326. } `json:"insuinfo"`
  2327. } `json:"output"`
  2328. RefmsgTime string `json:"refmsg_time"`
  2329. RespondTime string `json:"respond_time"`
  2330. Signtype interface{} `json:"signtype"`
  2331. WarnInfo interface{} `json:"warn_info"`
  2332. }
  2333. type ResultThree struct {
  2334. Cainfo interface{} `json:"cainfo"`
  2335. ErrMsg string `json:"err_msg"`
  2336. InfRefmsgid string `json:"inf_refmsgid"`
  2337. Infcode int64 `json:"infcode"`
  2338. Output struct {
  2339. Data struct {
  2340. IptOtpNo string `json:"ipt_otp_no"`
  2341. MdtrtID string `json:"mdtrt_id"`
  2342. PsnNo string `json:"psn_no"`
  2343. } `json:"data"`
  2344. } `json:"output"`
  2345. RefmsgTime string `json:"refmsg_time"`
  2346. RespondTime string `json:"respond_time"`
  2347. Signtype interface{} `json:"signtype"`
  2348. WarnMsg interface{} `json:"warn_msg"`
  2349. }
  2350. type ResultThree10265 struct {
  2351. Cainfo interface{} `json:"cainfo"`
  2352. ErrMsg string `json:"err_msg"`
  2353. InfRefmsgid string `json:"inf_refmsgid"`
  2354. Infcode string `json:"infcode"`
  2355. Output struct {
  2356. Data struct {
  2357. IptOtpNo string `json:"ipt_otp_no"`
  2358. MdtrtID string `json:"mdtrt_id"`
  2359. PsnNo string `json:"psn_no"`
  2360. } `json:"data"`
  2361. } `json:"output"`
  2362. RefmsgTime string `json:"refmsg_time"`
  2363. RespondTime string `json:"respond_time"`
  2364. Signtype interface{} `json:"signtype"`
  2365. WarnMsg interface{} `json:"warn_msg"`
  2366. }
  2367. type ResultFour struct {
  2368. Cainfo string `json:"cainfo"`
  2369. ErrMsg string `json:"err_msg"`
  2370. InfRefmsgid string `json:"inf_refmsgid"`
  2371. Infcode int64 `json:"infcode"`
  2372. Output struct {
  2373. Result []struct {
  2374. BasMednFlag string `json:"bas_medn_flag"`
  2375. ChldMedcFlag string `json:"chld_medc_flag"`
  2376. ChrgitmLv string `json:"chrgitm_lv"`
  2377. Cnt float64 `json:"cnt"`
  2378. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2379. DrtReimFlag string `json:"drt_reim_flag"`
  2380. FeedetlSn string `json:"feedetl_sn"`
  2381. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2382. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2383. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2384. ListSpItemFlag string `json:"list_sp_item_flag"`
  2385. LmtUsedFlag string `json:"lmt_used_flag"`
  2386. MedChrgitmType string `json:"med_chrgitm_type"`
  2387. Memo string `json:"memo"`
  2388. OverlmtAmt float64 `json:"overlmt_amt"`
  2389. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2390. Pric float64 `json:"pric"`
  2391. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2392. SelfpayProp float64 `json:"selfpay_prop"`
  2393. } `json:"result"`
  2394. } `json:"output"`
  2395. RefmsgTime string `json:"refmsg_time"`
  2396. RespondTime string `json:"respond_time"`
  2397. Signtype string `json:"signtype"`
  2398. WarnMsg string `json:"warn_msg"`
  2399. }
  2400. type ResultFour10265 struct {
  2401. Cainfo string `json:"cainfo"`
  2402. ErrMsg string `json:"err_msg"`
  2403. InfRefmsgid string `json:"inf_refmsgid"`
  2404. Infcode string `json:"infcode"`
  2405. Output struct {
  2406. Result []struct {
  2407. BasMednFlag string `json:"bas_medn_flag"`
  2408. ChldMedcFlag string `json:"chld_medc_flag"`
  2409. ChrgitmLv string `json:"chrgitm_lv"`
  2410. Cnt float64 `json:"cnt"`
  2411. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2412. DrtReimFlag string `json:"drt_reim_flag"`
  2413. FeedetlSn string `json:"feedetl_sn"`
  2414. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2415. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2416. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2417. ListSpItemFlag string `json:"list_sp_item_flag"`
  2418. LmtUsedFlag string `json:"lmt_used_flag"`
  2419. MedChrgitmType string `json:"med_chrgitm_type"`
  2420. Memo string `json:"memo"`
  2421. OverlmtAmt float64 `json:"overlmt_amt"`
  2422. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2423. Pric float64 `json:"pric"`
  2424. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2425. SelfpayProp float64 `json:"selfpay_prop"`
  2426. } `json:"result"`
  2427. } `json:"output"`
  2428. RefmsgTime string `json:"refmsg_time"`
  2429. RespondTime string `json:"respond_time"`
  2430. Signtype string `json:"signtype"`
  2431. WarnMsg string `json:"warn_msg"`
  2432. }
  2433. type ResultFive struct {
  2434. Balc float64 `json:"balc"`
  2435. CvlservFlag string `json:"cvlserv_flag"`
  2436. EmpName string `json:"emp_name"`
  2437. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2438. Insutype string `json:"insutype"`
  2439. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2440. PausInsuDate string `json:"paus_insu_date"`
  2441. PsnInsuDate string `json:"psn_insu_date"`
  2442. PsnInsuStas string `json:"psn_insu_stas"`
  2443. PsnType string `json:"psn_type"`
  2444. }
  2445. type ResultSix struct {
  2446. Cainfo interface{} `json:"cainfo"`
  2447. ErrMsg string `json:"err_msg"`
  2448. InfRefmsgid string `json:"inf_refmsgid"`
  2449. Infcode int64 `json:"infcode"`
  2450. Output struct {
  2451. } `json:"output"`
  2452. RefmsgTime string `json:"refmsg_time"`
  2453. RespondTime string `json:"respond_time"`
  2454. Signtype interface{} `json:"signtype"`
  2455. WarnMsg interface{} `json:"warn_msg"`
  2456. }
  2457. type ResultSix10265 struct {
  2458. Cainfo interface{} `json:"cainfo"`
  2459. ErrMsg string `json:"err_msg"`
  2460. InfRefmsgid string `json:"inf_refmsgid"`
  2461. Infcode string `json:"infcode"`
  2462. Output struct {
  2463. } `json:"output"`
  2464. RefmsgTime string `json:"refmsg_time"`
  2465. RespondTime string `json:"respond_time"`
  2466. Signtype interface{} `json:"signtype"`
  2467. WarnMsg interface{} `json:"warn_msg"`
  2468. }
  2469. type ResultSeven struct {
  2470. Cainfo string `json:"cainfo"`
  2471. ErrMsg string `json:"err_msg"`
  2472. InfRefmsgid string `json:"inf_refmsgid"`
  2473. Infcode int64 `json:"infcode"`
  2474. Output struct {
  2475. Setldetail []interface{} `json:"setldetail"`
  2476. Setlinfo struct {
  2477. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2478. AcctPay float64 `json:"acct_pay"`
  2479. ActPayDedc float64 `json:"act_pay_dedc"`
  2480. Age float64 `json:"age"`
  2481. Balc float64 `json:"balc"`
  2482. Brdy string `json:"brdy"`
  2483. Certno string `json:"certno"`
  2484. ClrOptins string `json:"clr_optins"`
  2485. ClrType string `json:"clr_type"`
  2486. ClrWay string `json:"clr_way"`
  2487. CvlservFlag string `json:"cvlserv_flag"`
  2488. CvlservPay float64 `json:"cvlserv_pay"`
  2489. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2490. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2491. Gend string `json:"gend"`
  2492. HifesPay float64 `json:"hifes_pay"`
  2493. HifmiPay float64 `json:"hifmi_pay"`
  2494. HifpPay float64 `json:"hifp_pay"`
  2495. HospPartAmt float64 `json:"hosp_part_amt"`
  2496. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2497. Insutype string `json:"insutype"`
  2498. MafPay float64 `json:"maf_pay"`
  2499. MdtrtCertType string `json:"mdtrt_cert_type"`
  2500. HifobPay float64 `json:"hifob_pay"`
  2501. MdtrtID string `json:"mdtrt_id"`
  2502. MedType string `json:"med_type"`
  2503. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2504. MedinsSetlID string `json:"medins_setl_id"`
  2505. Naty string `json:"naty"`
  2506. OthPay float64 `json:"oth_pay"`
  2507. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2508. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2509. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2510. PsnCashPay float64 `json:"psn_cash_pay"`
  2511. PsnCertType string `json:"psn_cert_type"`
  2512. PsnName string `json:"psn_name"`
  2513. PsnNo string `json:"psn_no"`
  2514. PsnPartAmt float64 `json:"psn_part_amt"`
  2515. PsnType string `json:"psn_type"`
  2516. SetlID string `json:"setl_id"`
  2517. SetlTime string `json:"setl_time"`
  2518. } `json:"setlinfo"`
  2519. } `json:"output"`
  2520. RefmsgTime string `json:"refmsg_time"`
  2521. RespondTime string `json:"respond_time"`
  2522. Signtype interface{} `json:"signtype"`
  2523. WarnMsg interface{} `json:"warn_msg"`
  2524. }
  2525. type ResultSeven10265 struct {
  2526. Cainfo string `json:"cainfo"`
  2527. ErrMsg string `json:"err_msg"`
  2528. InfRefmsgid string `json:"inf_refmsgid"`
  2529. Infcode string `json:"infcode"`
  2530. Output struct {
  2531. Setldetail []interface{} `json:"setldetail"`
  2532. Setlinfo struct {
  2533. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2534. AcctPay float64 `json:"acct_pay"`
  2535. ActPayDedc float64 `json:"act_pay_dedc"`
  2536. Age float64 `json:"age"`
  2537. Balc float64 `json:"balc"`
  2538. Brdy string `json:"brdy"`
  2539. Certno string `json:"certno"`
  2540. ClrOptins string `json:"clr_optins"`
  2541. ClrType string `json:"clr_type"`
  2542. ClrWay string `json:"clr_way"`
  2543. CvlservFlag string `json:"cvlserv_flag"`
  2544. CvlservPay float64 `json:"cvlserv_pay"`
  2545. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2546. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2547. Gend string `json:"gend"`
  2548. HifesPay float64 `json:"hifes_pay"`
  2549. HifmiPay float64 `json:"hifmi_pay"`
  2550. HifpPay float64 `json:"hifp_pay"`
  2551. HospPartAmt float64 `json:"hosp_part_amt"`
  2552. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2553. Insutype string `json:"insutype"`
  2554. MafPay float64 `json:"maf_pay"`
  2555. MdtrtCertType string `json:"mdtrt_cert_type"`
  2556. HifobPay float64 `json:"hifob_pay"`
  2557. MdtrtID string `json:"mdtrt_id"`
  2558. MedType string `json:"med_type"`
  2559. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2560. MedinsSetlID string `json:"medins_setl_id"`
  2561. Naty string `json:"naty"`
  2562. OthPay float64 `json:"oth_pay"`
  2563. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2564. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2565. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2566. PsnCashPay float64 `json:"psn_cash_pay"`
  2567. PsnCertType string `json:"psn_cert_type"`
  2568. PsnName string `json:"psn_name"`
  2569. PsnNo string `json:"psn_no"`
  2570. PsnPartAmt float64 `json:"psn_part_amt"`
  2571. PsnType string `json:"psn_type"`
  2572. SetlID string `json:"setl_id"`
  2573. SetlTime string `json:"setl_time"`
  2574. } `json:"setlinfo"`
  2575. } `json:"output"`
  2576. RefmsgTime string `json:"refmsg_time"`
  2577. RespondTime string `json:"respond_time"`
  2578. Signtype interface{} `json:"signtype"`
  2579. WarnMsg interface{} `json:"warn_msg"`
  2580. }
  2581. type ResultEight struct {
  2582. Cainfo string `json:"cainfo"`
  2583. ErrMsg string `json:"err_msg"`
  2584. InfRefmsgid string `json:"inf_refmsgid"`
  2585. Infcode int64 `json:"infcode"`
  2586. Output struct {
  2587. Stmtinfo struct {
  2588. SetlOptins string `json:"setl_optins"`
  2589. StmtRslt string `json:"stmt_rslt"`
  2590. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2591. } `json:"stmtinfo"`
  2592. } `json:"output"`
  2593. RefmsgTime string `json:"refmsg_time"`
  2594. RespondTime string `json:"respond_time"`
  2595. Signtype interface{} `json:"signtype"`
  2596. WarnMsg interface{} `json:"warn_msg"`
  2597. }
  2598. type ResultEightFor10188 struct {
  2599. Cainfo string `json:"cainfo"`
  2600. ErrMsg string `json:"err_msg"`
  2601. InfRefmsgid string `json:"inf_refmsgid"`
  2602. Infcode string `json:"infcode"`
  2603. Output struct {
  2604. Stmtinfo struct {
  2605. SetlOptins string `json:"setl_optins"`
  2606. StmtRslt string `json:"stmt_rslt"`
  2607. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2608. } `json:"stmtinfo"`
  2609. } `json:"output"`
  2610. RefmsgTime string `json:"refmsg_time"`
  2611. RespondTime string `json:"respond_time"`
  2612. Signtype interface{} `json:"signtype"`
  2613. WarnMsg interface{} `json:"warn_msg"`
  2614. }
  2615. type ResultNine struct {
  2616. Cainfo string `json:"cainfo"`
  2617. ErrMsg string `json:"err_msg"`
  2618. InfRefmsgid string `json:"inf_refmsgid"`
  2619. Infcode int64 `json:"infcode"`
  2620. Output struct {
  2621. FileQuryNo string `json:"file_qury_no"`
  2622. } `json:"output"`
  2623. RefmsgTime string `json:"refmsg_time"`
  2624. RespondTime string `json:"respond_time"`
  2625. Signtype interface{} `json:"signtype"`
  2626. WarnMsg interface{} `json:"warn_msg"`
  2627. }
  2628. type ResultTen struct {
  2629. Cainfo string `json:"cainfo"`
  2630. ErrMsg string `json:"err_msg"`
  2631. InfRefmsgid string `json:"inf_refmsgid"`
  2632. Infcode int64 `json:"infcode"`
  2633. Output struct {
  2634. DldEndtime string `json:"dld_endtime"`
  2635. FileQuryNo string `json:"file_qury_no"`
  2636. Filename string `json:"filename"`
  2637. } `json:"output"`
  2638. RefmsgTime string `json:"refmsg_time"`
  2639. RespondTime string `json:"respond_time"`
  2640. Signtype interface{} `json:"signtype"`
  2641. WarnMsg interface{} `json:"warn_msg"`
  2642. }
  2643. //type Autogenerated struct {
  2644. // Output struct {
  2645. // Setlinfo struct {
  2646. // SetlTime string `json:"setl_time"`
  2647. // CvlservPay float64 `json:"cvlserv_pay"`
  2648. // Year string `json:"year"`
  2649. // MedType string `json:"med_type"`
  2650. // PsnPay float64 `json:"psn_pay"`
  2651. // OpterID string `json:"opter_id"`
  2652. // Begndate string `json:"begndate"`
  2653. // FlxempeFlag string `json:"flxempe_flag"`
  2654. // HifmiPay float64 `json:"hifmi_pay"`
  2655. // PsnNo string `json:"psn_no"`
  2656. // ActPayDedc float64 `json:"act_pay_dedc"`
  2657. // MedinsSetlID interface{} `json:"medins_setl_id"`
  2658. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2659. // ClrWay string `json:"clr_way"`
  2660. // OthPay float64 `json:"oth_pay"`
  2661. // Gend string `json:"gend"`
  2662. // MdtrtID string `json:"mdtrt_id"`
  2663. // AcctPay float64 `json:"acct_pay"`
  2664. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  2665. // Insutype string `json:"insutype"`
  2666. // Invono interface{} `json:"invono"`
  2667. // Enddate string `json:"enddate"`
  2668. // CashPayamt float64 `json:"cash_payamt"`
  2669. // PsnType string `json:"psn_type"`
  2670. // FixmedinsName string `json:"fixmedins_name"`
  2671. // HifpPay float64 `json:"hifp_pay"`
  2672. // NewFlag interface{} `json:"new_flag"`
  2673. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2674. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  2675. // PayLoc string `json:"pay_loc"`
  2676. // ClrType string `json:"clr_type"`
  2677. // RefdSetlFlag string `json:"refd_setl_flag"`
  2678. // CvlservFlag string `json:"cvlserv_flag"`
  2679. // EmpName string `json:"emp_name"`
  2680. // Brdy string `json:"brdy"`
  2681. // Naty string `json:"naty"`
  2682. // Certno string `json:"certno"`
  2683. // DiseCode string `json:"dise_code"`
  2684. // FixmedinsCode string `json:"fixmedins_code"`
  2685. // DedcHospLv string `json:"dedc_hosp_lv"`
  2686. // OpterName string `json:"opter_name"`
  2687. // Balc float64 `json:"balc"`
  2688. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2689. // PsnCertType string `json:"psn_cert_type"`
  2690. // HifobPay float64 `json:"hifob_pay"`
  2691. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  2692. // HifesPay float64 `json:"hifes_pay"`
  2693. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2694. // OptTime string `json:"opt_time"`
  2695. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2696. // SetlID string `json:"setl_id"`
  2697. // MafPay float64 `json:"maf_pay"`
  2698. // PsnName string `json:"psn_name"`
  2699. // InsuOptins interface{} `json:"insu_optins"`
  2700. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2701. // ClrOptins string `json:"clr_optins"`
  2702. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2703. // DiseName string `json:"dise_name"`
  2704. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2705. // Age float64 `json:"age"`
  2706. // DtrtCertType string `json:"dtrt_cert_type"`
  2707. // HospLv string `json:"hosp_lv"`
  2708. // } `json:"setlinfo"`
  2709. // Setldetail []struct {
  2710. // FundPayType string `json:"fund_pay_type"`
  2711. // FundPayamt float64 `json:"fund_payamt"`
  2712. // SetlProcInfo interface{} `json:"setl_proc_info"`
  2713. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  2714. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  2715. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  2716. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2717. // } `json:"setldetail"`
  2718. // } `json:"output"`
  2719. // Infcode int `json:"infcode"`
  2720. // WarnMsg interface{} `json:"warn_msg"`
  2721. // Cainfo interface{} `json:"cainfo"`
  2722. // ErrMsg interface{} `json:"err_msg"`
  2723. // RefmsgTime string `json:"refmsg_time"`
  2724. // Signtype interface{} `json:"signtype"`
  2725. // RespondTime string `json:"respond_time"`
  2726. // InfRefmsgid string `json:"inf_refmsgid"`
  2727. //}
  2728. type ResultEleven struct {
  2729. Cainfo string `json:"cainfo"`
  2730. ErrMsg string `json:"err_msg"`
  2731. InfRefmsgid string `json:"inf_refmsgid"`
  2732. Infcode int64 `json:"infcode"`
  2733. Output struct {
  2734. Setlinfo struct {
  2735. SetlTime string `json:"setl_time"`
  2736. CvlservPay float64 `json:"cvlserv_pay"`
  2737. Year string `json:"year"`
  2738. MedType string `json:"med_type"`
  2739. PsnPay float64 `json:"psn_pay"`
  2740. OpterID string `json:"opter_id"`
  2741. Begndate string `json:"begndate"`
  2742. FlxempeFlag string `json:"flxempe_flag"`
  2743. HifmiPay float64 `json:"hifmi_pay"`
  2744. PsnNo string `json:"psn_no"`
  2745. ActPayDedc float64 `json:"act_pay_dedc"`
  2746. MedinsSetlID interface{} `json:"medins_setl_id"`
  2747. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2748. ClrWay string `json:"clr_way"`
  2749. OthPay float64 `json:"oth_pay"`
  2750. Gend string `json:"gend"`
  2751. MdtrtID string `json:"mdtrt_id"`
  2752. AcctPay float64 `json:"acct_pay"`
  2753. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2754. Insutype string `json:"insutype"`
  2755. Invono interface{} `json:"invono"`
  2756. Enddate string `json:"enddate"`
  2757. CashPayamt float64 `json:"cash_payamt"`
  2758. PsnType string `json:"psn_type"`
  2759. FixmedinsName string `json:"fixmedins_name"`
  2760. HifpPay float64 `json:"hifp_pay"`
  2761. NewFlag interface{} `json:"new_flag"`
  2762. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2763. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2764. PayLoc string `json:"pay_loc"`
  2765. ClrType string `json:"clr_type"`
  2766. RefdSetlFlag string `json:"refd_setl_flag"`
  2767. CvlservFlag string `json:"cvlserv_flag"`
  2768. EmpName string `json:"emp_name"`
  2769. Brdy string `json:"brdy"`
  2770. Naty string `json:"naty"`
  2771. Certno string `json:"certno"`
  2772. DiseCode string `json:"dise_code"`
  2773. FixmedinsCode string `json:"fixmedins_code"`
  2774. DedcHospLv string `json:"dedc_hosp_lv"`
  2775. OpterName string `json:"opter_name"`
  2776. Balc float64 `json:"balc"`
  2777. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2778. PsnCertType string `json:"psn_cert_type"`
  2779. HifobPay float64 `json:"hifob_pay"`
  2780. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2781. HifesPay float64 `json:"hifes_pay"`
  2782. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2783. OptTime string `json:"opt_time"`
  2784. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2785. SetlID string `json:"setl_id"`
  2786. MafPay float64 `json:"maf_pay"`
  2787. PsnName string `json:"psn_name"`
  2788. InsuOptins interface{} `json:"insu_optins"`
  2789. PrefFundPay interface{} `json:"pref_fund_pay"`
  2790. ClrOptins string `json:"clr_optins"`
  2791. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2792. DiseName string `json:"dise_name"`
  2793. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2794. Age float64 `json:"age"`
  2795. DtrtCertType string `json:"dtrt_cert_type"`
  2796. HospLv string `json:"hosp_lv"`
  2797. } `json:"setlinfo"`
  2798. } `json:"output"`
  2799. RefmsgTime string `json:"refmsg_time"`
  2800. RespondTime string `json:"respond_time"`
  2801. Signtype interface{} `json:"signtype"`
  2802. WarnMsg interface{} `json:"warn_msg"`
  2803. }
  2804. type ResultEleven10265 struct {
  2805. Cainfo string `json:"cainfo"`
  2806. ErrMsg string `json:"err_msg"`
  2807. InfRefmsgid string `json:"inf_refmsgid"`
  2808. Infcode string `json:"infcode"`
  2809. Output struct {
  2810. Setlinfo struct {
  2811. SetlTime string `json:"setl_time"`
  2812. CvlservPay float64 `json:"cvlserv_pay"`
  2813. Year string `json:"year"`
  2814. MedType string `json:"med_type"`
  2815. PsnPay float64 `json:"psn_pay"`
  2816. OpterID string `json:"opter_id"`
  2817. Begndate string `json:"begndate"`
  2818. FlxempeFlag string `json:"flxempe_flag"`
  2819. HifmiPay float64 `json:"hifmi_pay"`
  2820. PsnNo string `json:"psn_no"`
  2821. ActPayDedc float64 `json:"act_pay_dedc"`
  2822. MedinsSetlID interface{} `json:"medins_setl_id"`
  2823. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2824. ClrWay string `json:"clr_way"`
  2825. OthPay float64 `json:"oth_pay"`
  2826. Gend string `json:"gend"`
  2827. MdtrtID string `json:"mdtrt_id"`
  2828. AcctPay float64 `json:"acct_pay"`
  2829. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2830. Insutype string `json:"insutype"`
  2831. Invono interface{} `json:"invono"`
  2832. Enddate string `json:"enddate"`
  2833. CashPayamt float64 `json:"cash_payamt"`
  2834. PsnType string `json:"psn_type"`
  2835. FixmedinsName string `json:"fixmedins_name"`
  2836. HifpPay float64 `json:"hifp_pay"`
  2837. NewFlag interface{} `json:"new_flag"`
  2838. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2839. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2840. PayLoc string `json:"pay_loc"`
  2841. ClrType string `json:"clr_type"`
  2842. RefdSetlFlag string `json:"refd_setl_flag"`
  2843. CvlservFlag string `json:"cvlserv_flag"`
  2844. EmpName string `json:"emp_name"`
  2845. Brdy string `json:"brdy"`
  2846. Naty string `json:"naty"`
  2847. Certno string `json:"certno"`
  2848. DiseCode string `json:"dise_code"`
  2849. FixmedinsCode string `json:"fixmedins_code"`
  2850. DedcHospLv string `json:"dedc_hosp_lv"`
  2851. OpterName string `json:"opter_name"`
  2852. Balc float64 `json:"balc"`
  2853. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2854. PsnCertType string `json:"psn_cert_type"`
  2855. HifobPay float64 `json:"hifob_pay"`
  2856. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2857. HifesPay float64 `json:"hifes_pay"`
  2858. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2859. OptTime string `json:"opt_time"`
  2860. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2861. SetlID string `json:"setl_id"`
  2862. MafPay float64 `json:"maf_pay"`
  2863. PsnName string `json:"psn_name"`
  2864. InsuOptins interface{} `json:"insu_optins"`
  2865. PrefFundPay interface{} `json:"pref_fund_pay"`
  2866. ClrOptins string `json:"clr_optins"`
  2867. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2868. DiseName string `json:"dise_name"`
  2869. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2870. Age float64 `json:"age"`
  2871. DtrtCertType string `json:"dtrt_cert_type"`
  2872. HospLv string `json:"hosp_lv"`
  2873. } `json:"setlinfo"`
  2874. } `json:"output"`
  2875. RefmsgTime string `json:"refmsg_time"`
  2876. RespondTime string `json:"respond_time"`
  2877. Signtype interface{} `json:"signtype"`
  2878. WarnMsg interface{} `json:"warn_msg"`
  2879. }
  2880. type ResultTwelve struct {
  2881. Cainfo string `json:"cainfo"`
  2882. ErrMsg string `json:"err_msg"`
  2883. InfRefmsgid string `json:"inf_refmsgid"`
  2884. Infcode int64 `json:"infcode"`
  2885. Output struct {
  2886. MdtrtId string `json:"mdtrt_id"`
  2887. ChrgBchno string `json:"chrg_bchno"`
  2888. PsnNo string `json:"psn_no"`
  2889. } `json:"output"`
  2890. RefmsgTime string `json:"refmsg_time"`
  2891. RespondTime string `json:"respond_time"`
  2892. Signtype interface{} `json:"signtype"`
  2893. WarnMsg interface{} `json:"warn_msg"`
  2894. }
  2895. type ResultThirteen struct {
  2896. ErrMsg string `json:"err_msg"`
  2897. InfRefmsgid string `json:"inf_refmsgid"`
  2898. Infcode int64 `json:"infcode"`
  2899. Output struct {
  2900. Result struct {
  2901. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2902. } `json:"result"`
  2903. } `json:"output"`
  2904. RefmsgTime string `json:"refmsg_time"`
  2905. RespondTime string `json:"respond_time"`
  2906. Signtype interface{} `json:"signtype"`
  2907. WarnInfo interface{} `json:"warn_info"`
  2908. }
  2909. type ResultThirteen10265 struct {
  2910. ErrMsg string `json:"err_msg"`
  2911. InfRefmsgid string `json:"inf_refmsgid"`
  2912. Infcode string `json:"infcode"`
  2913. Output struct {
  2914. Result struct {
  2915. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2916. } `json:"result"`
  2917. } `json:"output"`
  2918. RefmsgTime string `json:"refmsg_time"`
  2919. RespondTime string `json:"respond_time"`
  2920. Signtype interface{} `json:"signtype"`
  2921. WarnInfo interface{} `json:"warn_info"`
  2922. }
  2923. type ResultFourteen struct {
  2924. ErrMsg string `json:"err_msg"`
  2925. InfRefmsgid string `json:"inf_refmsgid"`
  2926. Infcode int64 `json:"infcode"`
  2927. Output struct {
  2928. } `json:"output"`
  2929. RefmsgTime string `json:"refmsg_time"`
  2930. RespondTime string `json:"respond_time"`
  2931. Signtype interface{} `json:"signtype"`
  2932. WarnInfo interface{} `json:"warn_info"`
  2933. }
  2934. type ResultFourteen10265 struct {
  2935. ErrMsg string `json:"err_msg"`
  2936. InfRefmsgid string `json:"inf_refmsgid"`
  2937. Infcode string `json:"infcode"`
  2938. Output struct {
  2939. } `json:"output"`
  2940. RefmsgTime string `json:"refmsg_time"`
  2941. RespondTime string `json:"respond_time"`
  2942. Signtype interface{} `json:"signtype"`
  2943. WarnInfo interface{} `json:"warn_info"`
  2944. }
  2945. type ResultSixteen struct {
  2946. Cainfo string `json:"cainfo"`
  2947. ErrMsg string `json:"err_msg"`
  2948. InfRefmsgid string `json:"inf_refmsgid"`
  2949. Infcode int64 `json:"infcode"`
  2950. Output struct {
  2951. Setldetail []interface{} `json:"setldetail"`
  2952. Setlinfo struct {
  2953. MdtrtID string `json:"mdtrt_id"`
  2954. SetlID string `json:"setl_id"`
  2955. ClrOptins string `json:"clr_optins"`
  2956. SetlTime string `json:"setl_time"`
  2957. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2958. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2959. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2960. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2961. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2962. ActPayDedc float64 `json:"act_pay_dedc"`
  2963. HifpPay float64 `json:"hifp_pay"`
  2964. PoolPropSe float64 `json:"pool_prop_selfpay"`
  2965. Lfpay float64 `json:"selfpay"`
  2966. CvlservPay float64 `json:"cvlserv_pay"`
  2967. HifesPay float64 `json:"hifes_pay"`
  2968. HifmiPay float64 `json:"hifmi_pay"`
  2969. HifobPay float64 `json:"hifob_pay"`
  2970. MafPay float64 `json:"maf_pay"`
  2971. OthPay float64 `json:"oth_pay"`
  2972. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2973. PsnPartAmt float64 `json:"psn_part_amt"`
  2974. AcctPay float64 `json:"acct_pay"`
  2975. Balc float64 `json:"balc"`
  2976. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2977. HospPartAmt float64 `json:"hosp_part_amt"`
  2978. MedinsSetlID string `json:"medins_setl_id"`
  2979. PdnCashPay string `json:"pdn_cash_pay"`
  2980. } `json:"setlinfo"`
  2981. } `json:"output"`
  2982. RefmsgTime string `json:"refmsg_time"`
  2983. RespondTime string `json:"respond_time"`
  2984. Signtype interface{} `json:"signtype"`
  2985. WarnMsg interface{} `json:"warn_msg"`
  2986. }
  2987. type ResultSixteen10265 struct {
  2988. Cainfo string `json:"cainfo"`
  2989. ErrMsg string `json:"err_msg"`
  2990. InfRefmsgid string `json:"inf_refmsgid"`
  2991. Infcode string `json:"infcode"`
  2992. Output struct {
  2993. Setldetail []interface{} `json:"setldetail"`
  2994. Setlinfo struct {
  2995. MdtrtID string `json:"mdtrt_id"`
  2996. SetlID string `json:"setl_id"`
  2997. ClrOptins string `json:"clr_optins"`
  2998. SetlTime string `json:"setl_time"`
  2999. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3000. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3001. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3002. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3003. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3004. ActPayDedc float64 `json:"act_pay_dedc"`
  3005. HifpPay float64 `json:"hifp_pay"`
  3006. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3007. Lfpay float64 `json:"selfpay"`
  3008. CvlservPay float64 `json:"cvlserv_pay"`
  3009. HifesPay float64 `json:"hifes_pay"`
  3010. HifmiPay float64 `json:"hifmi_pay"`
  3011. HifobPay float64 `json:"hifob_pay"`
  3012. MafPay float64 `json:"maf_pay"`
  3013. OthPay float64 `json:"oth_pay"`
  3014. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3015. PsnPartAmt float64 `json:"psn_part_amt"`
  3016. AcctPay float64 `json:"acct_pay"`
  3017. Balc float64 `json:"balc"`
  3018. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3019. HospPartAmt float64 `json:"hosp_part_amt"`
  3020. MedinsSetlID string `json:"medins_setl_id"`
  3021. PdnCashPay string `json:"pdn_cash_pay"`
  3022. } `json:"setlinfo"`
  3023. } `json:"output"`
  3024. RefmsgTime string `json:"refmsg_time"`
  3025. RespondTime string `json:"respond_time"`
  3026. Signtype interface{} `json:"signtype"`
  3027. WarnMsg interface{} `json:"warn_msg"`
  3028. }
  3029. type ResultSeventeen struct {
  3030. ErrMsg string `json:"err_msg"`
  3031. InfRefmsgid string `json:"inf_refmsgid"`
  3032. Infcode int64 `json:"infcode"`
  3033. Output struct {
  3034. SetlListId string `json:"setl_list_id"`
  3035. } `json:"output"`
  3036. RefmsgTime string `json:"refmsg_time"`
  3037. RespondTime string `json:"respond_time"`
  3038. Signtype string `json:"signtype"`
  3039. WarnInfo string `json:"warn_info"`
  3040. }
  3041. type Result90991 struct {
  3042. ErrMsg string `json:"err_msg"`
  3043. InfRefmsgid string `json:"inf_refmsgid"`
  3044. Infcode int64 `json:"infcode"`
  3045. Output struct {
  3046. Result struct {
  3047. PsnNo string `json:"psn_no"`
  3048. CardStat string `json:"card_stat"`
  3049. Certno string `json:"certno"`
  3050. PsnName string `json:"psn_name"`
  3051. CheckStat string `json:"check_stat"`
  3052. } `json:"result"`
  3053. } `json:"output"`
  3054. RefmsgTime string `json:"refmsg_time"`
  3055. RespondTime string `json:"respond_time"`
  3056. Signtype interface{} `json:"signtype"`
  3057. WarnInfo interface{} `json:"warn_info"`
  3058. }
  3059. type Result90100 struct {
  3060. ErrMsg string `json:"err_msg"`
  3061. InfRefmsgid string `json:"inf_refmsgid"`
  3062. Infcode int64 `json:"infcode"`
  3063. Output struct {
  3064. PoolareaNo string `json:"poolarea_no"`
  3065. PoolareaNoName string `json:"poolarea_no_name"`
  3066. Insutype string `json:"insutype"`
  3067. InsutypeName string `json:"insutype_name"`
  3068. ClctType string `json:"clct_type"`
  3069. ClctTypeName string `json:"clct_type_name"`
  3070. ClctFlag string `json:"clct_flag"`
  3071. ClctFlagName string `json:"clct_flag_name"`
  3072. AccrymBegn string `json:"accrym_begn"`
  3073. AccrymEnd string `json:"accrym_end"`
  3074. ClctTime string `json:"clct_time"`
  3075. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3076. } `json:"output"`
  3077. RefmsgTime string `json:"refmsg_time"`
  3078. RespondTime string `json:"respond_time"`
  3079. Signtype interface{} `json:"signtype"`
  3080. WarnInfo interface{} `json:"warn_info"`
  3081. }
  3082. type Custom struct {
  3083. DetItemFeeSumamt string
  3084. Cut string
  3085. FeedetlSn string
  3086. Price string
  3087. MedListCodg string
  3088. Type int64
  3089. AdviceId int64
  3090. ProjectId int64
  3091. ItemId int64
  3092. }
  3093. type Result5301 struct {
  3094. ErrMsg string `json:"err_msg"`
  3095. InfRefmsgid string `json:"inf_refmsgid"`
  3096. Infcode int64 `json:"infcode"`
  3097. Output struct {
  3098. Result []struct {
  3099. OpspDiseCode string `json:"opsp_dise_code"`
  3100. OpspDiseName string `json:"opsp_dise_name"`
  3101. Begndate string `json:"begndate"`
  3102. Enddate string `json:"enddate"`
  3103. } `json:"feedetail"`
  3104. } `json:"output"`
  3105. RefmsgTime string `json:"refmsg_time"`
  3106. RespondTime string `json:"respond_time"`
  3107. Signtype interface{} `json:"signtype"`
  3108. WarnInfo interface{} `json:"warn_info"`
  3109. }
  3110. type Result5301For10265 struct {
  3111. ErrMsg string `json:"err_msg"`
  3112. InfRefmsgid string `json:"inf_refmsgid"`
  3113. Infcode string `json:"infcode"`
  3114. Output struct {
  3115. Result []struct {
  3116. OpspDiseCode string `json:"opsp_dise_code"`
  3117. OpspDiseName string `json:"opsp_dise_name"`
  3118. Begndate string `json:"begndate"`
  3119. Enddate string `json:"enddate"`
  3120. } `json:"feedetail"`
  3121. } `json:"output"`
  3122. RefmsgTime string `json:"refmsg_time"`
  3123. RespondTime string `json:"respond_time"`
  3124. Signtype interface{} `json:"signtype"`
  3125. WarnInfo interface{} `json:"warn_info"`
  3126. }
  3127. //获取个人信息----挂号-----上传就诊信息
  3128. func (c *HisApiController) GetRegisterInfo() {
  3129. id, _ := c.GetInt64("id")
  3130. record_time := c.GetString("record_time")
  3131. settlementValue, _ := c.GetInt64("settlement_value")
  3132. medical_insurance_card := c.GetString("medical_insurance_card")
  3133. name := c.GetString("name")
  3134. id_card_type, _ := c.GetInt64("id_card_type")
  3135. certificates, _ := c.GetInt64("certificates")
  3136. medical_care, _ := c.GetInt64("medical_care")
  3137. birthday := c.GetString("birthday")
  3138. id_card := c.GetString("id_card")
  3139. register_type, _ := c.GetInt64("register")
  3140. doctor, _ := c.GetInt64("doctor")
  3141. department, _ := c.GetInt64("department")
  3142. gender, _ := c.GetInt64("sex")
  3143. registration_fee, _ := c.GetFloat("registration_fee")
  3144. medical_expenses, _ := c.GetFloat("medical_expenses")
  3145. social_type, _ := c.GetInt64("social_type")
  3146. med_type := c.GetString("social_type")
  3147. admin_user_id, _ := c.GetInt64("admin_user_id")
  3148. insuplc_admdvs := c.GetString("insuplc_admdvs")
  3149. timeLayout := "2006-01-02"
  3150. loc, _ := time.LoadLocation("Local")
  3151. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  3152. birthUnix := birthdays.Unix()
  3153. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3154. if err != nil {
  3155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3156. return
  3157. }
  3158. recordDateTime := theTime.Unix()
  3159. adminInfo := c.GetAdminUserInfo()
  3160. var patient service.Patients
  3161. if id == 0 {
  3162. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  3163. } else {
  3164. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  3165. }
  3166. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3167. if patientPrescription.ID == 0 {
  3168. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3169. }
  3170. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3171. if patient.ID == 0 {
  3172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  3173. return
  3174. }
  3175. if len(patient.IdCardNo) == 0 {
  3176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  3177. return
  3178. }
  3179. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3180. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  3181. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  3182. //就诊结算未完成,不能进行二次挂号
  3183. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  3184. if len(his) >= 1 {
  3185. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  3186. if len(his) >= 1 && order.ID == 0 {
  3187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  3188. return
  3189. }
  3190. }
  3191. //var register_log string
  3192. if config.IsOpen == 1 {
  3193. var res ResultTwo
  3194. var res10265 ResultTwo10265
  3195. var PsnNo string
  3196. var PsnCertType string
  3197. var Certno string
  3198. var PsnName string
  3199. var Gend string
  3200. var Naty string
  3201. var Brdy string
  3202. var Age float64
  3203. var infoStr string
  3204. var idetinfoStr string
  3205. var infocode int64
  3206. var verify_number string
  3207. fmt.Println(verify_number)
  3208. if miConfig.MdtrtareaAdmvs == "421300" {
  3209. psn_info, _ := service.GetPsnByPatientId(id)
  3210. PsnNo = psn_info.PsnNo
  3211. PsnCertType = psn_info.PsnCertType
  3212. Certno = psn_info.Certno
  3213. PsnName = psn_info.PsnName
  3214. Gend = psn_info.Gend
  3215. Naty = psn_info.Naty
  3216. Brdy = psn_info.Brdy
  3217. Age = psn_info.Age
  3218. infoStr = psn_info.Insuinfo
  3219. idetinfoStr = psn_info.Idetinfo
  3220. infocode = 0
  3221. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3222. psn_info, _ := service.GetPsnByPatientId(id)
  3223. PsnNo = psn_info.PsnNo
  3224. PsnCertType = psn_info.PsnCertType
  3225. Certno = psn_info.Certno
  3226. PsnName = psn_info.PsnName
  3227. Gend = psn_info.Gend
  3228. Naty = psn_info.Naty
  3229. Brdy = psn_info.Brdy
  3230. Age = psn_info.Age
  3231. infoStr = psn_info.Insuinfo
  3232. idetinfoStr = psn_info.Idetinfo
  3233. infocode = 0
  3234. verify_number = psn_info.VerifyNumber
  3235. } else {
  3236. var result string
  3237. var requestLog string
  3238. if miConfig.UserOrgId == 10138 {
  3239. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  3240. } else {
  3241. 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), name)
  3242. }
  3243. saveLog(result, requestLog, "1101", "人员基本信息获取")
  3244. if miConfig.Code == "H15049901371" {
  3245. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3246. utils.ErrorLog("解析失败:%v", err)
  3247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3248. return
  3249. }
  3250. res.ErrMsg = res10265.ErrMsg
  3251. res.Output = res10265.Output
  3252. res.InfRefmsgid = res10265.InfRefmsgid
  3253. } else {
  3254. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3255. utils.ErrorLog("解析失败:%v", err)
  3256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3257. return
  3258. }
  3259. }
  3260. PsnNo = res.Output.Baseinfo.PsnNo
  3261. PsnCertType = res.Output.Baseinfo.PsnCertType
  3262. Certno = res.Output.Baseinfo.Certno
  3263. PsnName = res.Output.Baseinfo.PsnName
  3264. Gend = res.Output.Baseinfo.Gend
  3265. Naty = res.Output.Baseinfo.Naty
  3266. Brdy = res.Output.Baseinfo.Brdy
  3267. Age = res.Output.Baseinfo.Age
  3268. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3269. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3270. infoStr = string(Iinfos)
  3271. idetinfoStr = string(Idetinfos)
  3272. if miConfig.Code == "H15049901371" {
  3273. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  3274. } else {
  3275. infocode = res.Infcode
  3276. }
  3277. }
  3278. if infocode == 0 {
  3279. his := models.VMHisPatient{
  3280. Name: name,
  3281. Gender: gender,
  3282. Birthday: birthUnix,
  3283. MedicalTreatmentType: medical_care,
  3284. IdType: certificates,
  3285. IdCardNo: id_card,
  3286. BalanceAccountsType: settlementValue,
  3287. SocialType: social_type,
  3288. MedicalInsuranceNumber: medical_insurance_card,
  3289. RegisterType: register_type,
  3290. RegisterCost: registration_fee,
  3291. TreatmentCost: medical_expenses,
  3292. Status: 1,
  3293. Ctime: time.Now().Unix(),
  3294. Mtime: time.Now().Unix(),
  3295. PsnNo: PsnNo,
  3296. PsnCertType: PsnCertType,
  3297. Certno: Certno,
  3298. PsnName: PsnName,
  3299. Gend: Gend,
  3300. Naty: Naty,
  3301. Brdy: Brdy,
  3302. Age: Age,
  3303. Iinfo: infoStr,
  3304. Idetinfo: idetinfoStr,
  3305. PatientId: patient.ID,
  3306. RecordDate: theTime.Unix(),
  3307. UserOrgId: adminInfo.CurrentOrgId,
  3308. AdminUserId: admin_user_id,
  3309. IsReturn: 1,
  3310. IdCardType: id_card_type,
  3311. Doctor: doctor,
  3312. Departments: department,
  3313. }
  3314. timestamp := time.Now().Unix()
  3315. tempTime := time.Unix(timestamp, 0)
  3316. timeFormat := tempTime.Format("20060102150405")
  3317. chrgBchno := rand.Intn(100000) + 10000
  3318. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3319. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  3320. department, _ := service.GetDepartMentDetail(department)
  3321. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  3322. IdCardNo := ""
  3323. if id_card_type == 1 {
  3324. // IdCardNo = medical_insurance_card
  3325. IdCardNo = patient.IdCardNo
  3326. } else {
  3327. IdCardNo = patient.IdCardNo
  3328. }
  3329. var rf []*ResultFive
  3330. json.Unmarshal([]byte(his.Iinfo), &rf)
  3331. var insutypes []*ResultFive
  3332. var insutype string
  3333. var insuplc_admdvs_temp string
  3334. var is390 int = 0
  3335. var is310 int = 0
  3336. for _, item := range rf {
  3337. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3338. insutypes = append(insutypes, item)
  3339. }
  3340. }
  3341. if len(insutypes) == 1 {
  3342. insutype = insutypes[0].Insutype
  3343. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3344. } else {
  3345. for _, i := range insutypes {
  3346. if i.Insutype == "390" {
  3347. is390 = 1
  3348. }
  3349. if i.Insutype == "310" {
  3350. is310 = 1
  3351. }
  3352. }
  3353. }
  3354. if is390 == 1 {
  3355. insutype = "390"
  3356. }
  3357. if is310 == 1 {
  3358. insutype = "310"
  3359. }
  3360. if len(insutypes) == 0 {
  3361. insutype = "310"
  3362. }
  3363. if len(insutypes) == 2 {
  3364. insutype = med_type
  3365. }
  3366. if len(med_type) > 0 {
  3367. insutype = med_type
  3368. }
  3369. //for _, item := range rf {
  3370. // if item.Insutype == insutype {
  3371. // insuplc_admdvs = item.InsuplcAdmdvs
  3372. // }
  3373. //}
  3374. var infocode int64
  3375. var resThree ResultThree
  3376. var resThree10265 ResultThree10265
  3377. if len(insuplc_admdvs) == 0 {
  3378. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  3379. } else {
  3380. insuplc_admdvs_temp = insuplc_admdvs
  3381. }
  3382. if miConfig.MdtrtareaAdmvs == "421300" {
  3383. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  3384. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3385. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&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 + "&doctor_name=" + doctor_info.UserName
  3386. resp, requestErr := http.Get(api)
  3387. if requestErr != nil {
  3388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3389. return
  3390. }
  3391. body, ioErr := ioutil.ReadAll(resp.Body)
  3392. if ioErr != nil {
  3393. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3395. return
  3396. }
  3397. var respJSON map[string]interface{}
  3398. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3401. return
  3402. }
  3403. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3404. result, _ := json.Marshal(respJSON)
  3405. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3406. utils.ErrorLog("解析失败:%v", err)
  3407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3408. return
  3409. }
  3410. infocode = resThree.Infcode
  3411. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3412. psn_info, _ := service.GetPsnByPatientId(id)
  3413. bas := strings.Split(psn_info.CardInfo, "|")
  3414. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3415. var api string
  3416. if miConfig.MdtrtareaAdmvs == "320921" {
  3417. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3418. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3419. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&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 + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  3420. } else {
  3421. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3422. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3423. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&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 + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  3424. }
  3425. resp, requestErr := http.Get(api)
  3426. if requestErr != nil {
  3427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3428. return
  3429. }
  3430. body, ioErr := ioutil.ReadAll(resp.Body)
  3431. if ioErr != nil {
  3432. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3434. return
  3435. }
  3436. var respJSON map[string]interface{}
  3437. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3438. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3440. return
  3441. }
  3442. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3443. result, _ := json.Marshal(respJSON)
  3444. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3445. utils.ErrorLog("解析失败:%v", err)
  3446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3447. return
  3448. }
  3449. resThree.ErrMsg = resThree10265.ErrMsg
  3450. resThree.Output = resThree10265.Output
  3451. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3452. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3453. } else {
  3454. 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_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName)
  3455. saveLog(result, requestLog, "2201", "挂号")
  3456. if miConfig.Code == "H15049901371" {
  3457. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3458. utils.ErrorLog("解析失败:%v", err)
  3459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3460. return
  3461. }
  3462. resThree.ErrMsg = resThree10265.ErrMsg
  3463. resThree.Output = resThree10265.Output
  3464. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3465. } else {
  3466. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3467. utils.ErrorLog("解析失败:%v", err)
  3468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3469. return
  3470. }
  3471. }
  3472. if miConfig.Code == "H15049901371" {
  3473. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3474. } else {
  3475. infocode = resThree.Infcode
  3476. }
  3477. }
  3478. if infocode != 0 {
  3479. adminUser := c.GetAdminUserInfo()
  3480. errlog := &models.HisOrderError{
  3481. UserOrgId: adminUser.CurrentOrgId,
  3482. Ctime: time.Now().Unix(),
  3483. Mtime: time.Now().Unix(),
  3484. ErrMsg: resThree.ErrMsg,
  3485. Status: 1,
  3486. PatientId: id,
  3487. RecordTime: recordDateTime,
  3488. Stage: 2,
  3489. }
  3490. service.CreateErrMsgLog(errlog)
  3491. c.ServeSuccessJSON(map[string]interface{}{
  3492. "failed_code": -10,
  3493. "msg": resThree.ErrMsg,
  3494. })
  3495. return
  3496. }
  3497. his.Number = resThree.Output.Data.MdtrtID
  3498. his.PsnNo = resThree.Output.Data.PsnNo
  3499. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  3500. his.IdCardNo = patient.IdCardNo
  3501. his.PhoneNumber = patient.Phone
  3502. his.UserOrgId = adminInfo.CurrentOrgId
  3503. his.Insutype = insutype
  3504. his.Ctime = time.Now().Unix()
  3505. his.Mtime = time.Now().Unix()
  3506. his.InsuplcAdmdvs = insuplc_admdvs_temp
  3507. his.Status = 1
  3508. service.UpdateHisPatientStatus(&his)
  3509. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  3510. c.ServeSuccessJSON(map[string]interface{}{
  3511. "his_info": his,
  3512. })
  3513. } else {
  3514. adminUser := c.GetAdminUserInfo()
  3515. errlog := &models.HisOrderError{
  3516. UserOrgId: adminUser.CurrentOrgId,
  3517. Ctime: time.Now().Unix(),
  3518. Mtime: time.Now().Unix(),
  3519. ErrMsg: res.ErrMsg,
  3520. Status: 1,
  3521. PatientId: id,
  3522. RecordTime: recordDateTime,
  3523. Stage: 1,
  3524. }
  3525. service.CreateErrMsgLog(errlog)
  3526. c.ServeSuccessJSON(map[string]interface{}{
  3527. "failed_code": -10,
  3528. "msg": res.ErrMsg,
  3529. })
  3530. return
  3531. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  3532. }
  3533. }
  3534. }
  3535. //上传明细----预结算----确认订单
  3536. func (c *HisApiController) GetUploadInfo() {
  3537. id, _ := c.GetInt64("id")
  3538. record_time := c.GetString("record_time")
  3539. his_patient_id, _ := c.GetInt64("his_patient_id")
  3540. order_id, _ := c.GetInt64("order_id")
  3541. pay_way, _ := c.GetInt64("pay_way")
  3542. pay_price, _ := c.GetFloat("pay_price")
  3543. pay_card_no := c.GetString("pay_card_no")
  3544. discount_price, _ := c.GetFloat("discount_price")
  3545. preferential_price, _ := c.GetFloat("preferential_price")
  3546. reality_price, _ := c.GetFloat("reality_price")
  3547. found_price, _ := c.GetFloat("found_price")
  3548. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3549. private_price, _ := c.GetFloat("private_price")
  3550. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3551. admin_user_id, _ := c.GetInt64("admin_user_id")
  3552. fapiao_code := c.GetString("fapiao_code")
  3553. fapiao_number := c.GetString("fapiao_number")
  3554. diagnosis_id := c.GetString("diagnosis")
  3555. sick_type, _ := c.GetInt64("sick_type")
  3556. reg_type, _ := c.GetInt64("p_type")
  3557. begin_time := c.GetString("begin_time")
  3558. id_str := c.GetString("ids")
  3559. ids_arr := strings.Split(id_str, ",")
  3560. timeLayout := "2006-01-02"
  3561. loc, _ := time.LoadLocation("Local")
  3562. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3563. if err != nil {
  3564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3565. return
  3566. }
  3567. recordDateTime := theTime.Unix()
  3568. adminUser := c.GetAdminUserInfo()
  3569. var tempOrder models.HisOrder
  3570. tempOrder, _ = service.GetHisOrderByID(order_id)
  3571. var prescriptions []*models.HisPrescription
  3572. var start_time int64
  3573. var end_time int64
  3574. //if adminUser.CurrentOrgId == 10106{
  3575. // if len(fapiao_code) == 0{
  3576. // fapiao_code = "144072080589"
  3577. // }
  3578. // if len(fapiao_number) == 0{
  3579. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  3580. // if order.ID == 0{
  3581. // fapiao_number = "00001520"
  3582. // }else{
  3583. // //fapiao_code = "00001520"
  3584. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  3585. // var zero string
  3586. // if fpNumber >= 1000{
  3587. // zero = "0000" + strconv.Itoa(fpNumber)
  3588. // }else if fpNumber >= 10000{
  3589. // zero = "000" + strconv.Itoa(fpNumber)
  3590. // } else if fpNumber >= 100000{
  3591. // zero = "00" + strconv.Itoa(fpNumber)
  3592. // } else if fpNumber >= 1000000{
  3593. // zero = "0" + strconv.Itoa(fpNumber)
  3594. // }else {
  3595. // zero = strconv.Itoa(fpNumber)
  3596. // }
  3597. // fapiao_number = zero
  3598. // }
  3599. // }
  3600. //}
  3601. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3602. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3603. var patientPrescription models.HisPrescriptionInfo
  3604. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3605. if patientPrescription.ID == 0 {
  3606. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3607. }
  3608. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3609. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3610. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3611. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3612. var config []*models.HisXtDiagnoseConfig
  3613. for _, item := range diagnosis_ids {
  3614. id, _ := strconv.ParseInt(item, 10, 64)
  3615. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3616. config = append(config, &diagnosisConfig)
  3617. }
  3618. sickConfig, _ := service.FindSickById(sick_type)
  3619. //if tempOrder.ID == 0 {
  3620. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  3621. //}
  3622. if tempOrder.ID == 0 {
  3623. var result string
  3624. var requestLog string
  3625. var res2 ResultSix
  3626. var ressix10265 ResultSix10265
  3627. if miConfig.MdtrtareaAdmvs == "421300" {
  3628. data := make(map[string]interface{})
  3629. client := &http.Client{}
  3630. data["psn_no"] = his.PsnNo
  3631. data["mdtrt_id"] = his.Number
  3632. data["doctor"] = roles.UserName
  3633. data["department"] = department.Name
  3634. data["org_name"] = miConfig.OrgName
  3635. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3636. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3637. data["fixmedins_code"] = miConfig.Code
  3638. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3639. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3640. data["secret_key"] = miConfig.SecretKey
  3641. data["sick_code"] = sickConfig.CountryCode
  3642. data["sick_name"] = sickConfig.ClassName
  3643. data["dept"] = strconv.FormatInt(department.ID, 10)
  3644. data["config"] = config
  3645. data["begin_time"] = begin_time
  3646. bytesData, _ := json.Marshal(data)
  3647. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3648. resp, _ := client.Do(req)
  3649. defer resp.Body.Close()
  3650. body, ioErr := ioutil.ReadAll(resp.Body)
  3651. if ioErr != nil {
  3652. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3654. return
  3655. }
  3656. var respJSON map[string]interface{}
  3657. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3658. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3660. return
  3661. }
  3662. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3663. userJSONBytes, _ := json.Marshal(respJSON)
  3664. fmt.Println("log")
  3665. fmt.Println(string(userJSONBytes))
  3666. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3667. utils.ErrorLog("解析失败:%v", err)
  3668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3669. return
  3670. }
  3671. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3672. //江苏地区国家医保医疗类别
  3673. //职工透析:医疗类别选特殊情况门诊9933
  3674. //居民血透门慢: 医疗类别选门诊慢病1402
  3675. //var med_type string
  3676. //if his.Insutype == "310" {
  3677. // if reg_type == 14 {
  3678. // med_type = "9933"
  3679. // } else if reg_type == 11 {
  3680. // med_type = "11"
  3681. //
  3682. // }
  3683. //} else if his.Insutype == "390" {
  3684. // if reg_type == 14 {
  3685. // med_type = "1402"
  3686. // } else if reg_type == 11 {
  3687. // med_type = "11"
  3688. // }
  3689. //}
  3690. data := make(map[string]interface{})
  3691. client := &http.Client{}
  3692. data["psn_no"] = his.PsnNo
  3693. data["mdtrt_id"] = his.Number
  3694. data["doctor"] = roles.UserName
  3695. data["department"] = department.Name
  3696. data["org_name"] = miConfig.OrgName
  3697. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3698. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3699. data["fixmedins_code"] = miConfig.Code
  3700. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3701. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3702. data["secret_key"] = miConfig.SecretKey
  3703. data["sick_code"] = sickConfig.CountryCode
  3704. data["sick_name"] = sickConfig.ClassName
  3705. data["url"] = miConfig.Url
  3706. data["ak"] = miConfig.AccessKey
  3707. data["begin_time"] = begin_time
  3708. data["cainfo"] = miConfig.Cainfo
  3709. data["dept"] = strconv.FormatInt(department.ID, 10)
  3710. data["config"] = config
  3711. bytesData, _ := json.Marshal(data)
  3712. var req *http.Request
  3713. if miConfig.MdtrtareaAdmvs == "320921" {
  3714. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3715. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  3716. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  3717. } else {
  3718. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3719. }
  3720. resp, _ := client.Do(req)
  3721. defer resp.Body.Close()
  3722. body, ioErr := ioutil.ReadAll(resp.Body)
  3723. if ioErr != nil {
  3724. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3726. return
  3727. }
  3728. var respJSON map[string]interface{}
  3729. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3732. return
  3733. }
  3734. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3735. userJSONBytes, _ := json.Marshal(respJSON)
  3736. fmt.Println("log")
  3737. fmt.Println(string(userJSONBytes))
  3738. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  3739. utils.ErrorLog("解析失败:%v", err)
  3740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3741. return
  3742. }
  3743. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3744. res2.Output = ressix10265.Output
  3745. res2.ErrMsg = ressix10265.ErrMsg
  3746. res2.Cainfo = ressix10265.Cainfo
  3747. res2.WarnMsg = ressix10265.WarnMsg
  3748. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3749. res2.Infcode = infocode
  3750. } else {
  3751. if miConfig.MdtrtareaAdmvs == "440781" { //
  3752. 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, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  3753. } else {
  3754. if miConfig.Code == "H15049901371" {
  3755. //赤峰地区国家医保医疗类别
  3756. //职工透析:医疗类别选特殊情况门诊990502
  3757. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3758. var med_type string
  3759. if his.Insutype == "390" {
  3760. if reg_type == 14 {
  3761. med_type = "9933"
  3762. } else if reg_type == 11 {
  3763. med_type = "11"
  3764. }
  3765. } else if his.Insutype == "310" {
  3766. if reg_type == 14 {
  3767. med_type = "990502"
  3768. } else if reg_type == 11 {
  3769. med_type = "11"
  3770. }
  3771. }
  3772. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, med_type, doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  3773. } else {
  3774. 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, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  3775. }
  3776. }
  3777. saveLog(result, requestLog, "2203", "上传就诊信息")
  3778. var respJSON2 map[string]interface{}
  3779. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3780. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3782. return
  3783. }
  3784. userJSONBytes2, _ := json.Marshal(respJSON2)
  3785. if miConfig.Code == "H15049901371" {
  3786. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  3787. utils.ErrorLog("解析失败:%v", err)
  3788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3789. return
  3790. }
  3791. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3792. res2.Output = ressix10265.Output
  3793. res2.ErrMsg = ressix10265.ErrMsg
  3794. res2.Cainfo = ressix10265.Cainfo
  3795. res2.WarnMsg = ressix10265.WarnMsg
  3796. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3797. res2.Infcode = infocode
  3798. } else {
  3799. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3800. utils.ErrorLog("解析失败:%v", err)
  3801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3802. return
  3803. }
  3804. }
  3805. }
  3806. if res2.Infcode != 0 {
  3807. adminUser := c.GetAdminUserInfo()
  3808. errlog := &models.HisOrderError{
  3809. UserOrgId: adminUser.CurrentOrgId,
  3810. Ctime: time.Now().Unix(),
  3811. Mtime: time.Now().Unix(),
  3812. ErrMsg: res2.ErrMsg,
  3813. Status: 1,
  3814. PatientId: id,
  3815. RecordTime: recordDateTime,
  3816. Stage: 3,
  3817. }
  3818. service.CreateErrMsgLog(errlog)
  3819. c.ServeSuccessJSON(map[string]interface{}{
  3820. "failed_code": -10,
  3821. "msg": res2.ErrMsg,
  3822. })
  3823. return
  3824. } else {
  3825. his.Diagnosis = diagnosis_id
  3826. his.SickType = sickConfig.ID
  3827. var p_type int64
  3828. if reg_type == 1111 || reg_type == 1112 {
  3829. p_type = 11
  3830. }
  3831. his.PType = fmt.Sprintf("%d", p_type)
  3832. service.UpdateHisPatientThree(&his)
  3833. data := make(map[string]interface{})
  3834. if settle_accounts_type == 1 { //日结
  3835. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  3836. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  3837. } else {
  3838. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  3839. }
  3840. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  3841. data["pre"] = prescriptions
  3842. } else { //月结
  3843. start_time_str := c.GetString("start_time")
  3844. end_time_str := c.GetString("end_time")
  3845. timeLayout := "2006-01-02"
  3846. loc, _ := time.LoadLocation("Local")
  3847. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3848. if err != nil {
  3849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3850. return
  3851. }
  3852. recordStartTime := theStartTime.Unix()
  3853. start_time = recordStartTime
  3854. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3855. if err != nil {
  3856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3857. return
  3858. }
  3859. recordEndTime := theEndTime.Unix()
  3860. end_time = recordEndTime
  3861. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  3862. data["pre"] = prescriptions
  3863. }
  3864. timestamp := time.Now().Unix()
  3865. tempTime := time.Unix(timestamp, 0)
  3866. timeFormat := tempTime.Format("20060102150405")
  3867. chrgBchno := rand.Intn(100000) + 10000
  3868. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3869. strconv.FormatInt(his.PatientId, 10)
  3870. client := &http.Client{}
  3871. data["psn_no"] = his.PsnNo
  3872. data["mdtrt_id"] = his.Number
  3873. data["chrg_bchno"] = chrg_bchno
  3874. data["org_name"] = miConfig.OrgName
  3875. data["doctor"] = roles.UserName
  3876. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3877. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3878. data["fixmedins_code"] = miConfig.Code
  3879. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  3880. // data["dept_code"] = "15"
  3881. //} else {
  3882. data["dept_code"] = department.Number
  3883. //}
  3884. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3885. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3886. data["secret_key"] = miConfig.SecretKey
  3887. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  3888. data["url"] = miConfig.Url
  3889. data["ak"] = miConfig.AccessKey
  3890. data["new_doctor_name"] = patientPrescription.Doctor
  3891. data["diag_code"] = sickConfig.CountryCode
  3892. data["cainfo"] = miConfig.Cainfo
  3893. var ids []int64
  3894. for _, item := range prescriptions {
  3895. ids = append(ids, item.ID)
  3896. }
  3897. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3898. if config.IsOpen == 1 { //对接了医保,走医保流程
  3899. var res ResultFour
  3900. var resFour10265 ResultFour10265
  3901. if miConfig.MdtrtareaAdmvs == "421300" {
  3902. bytesData, _ := json.Marshal(data)
  3903. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  3904. resp, _ := client.Do(req)
  3905. defer resp.Body.Close()
  3906. body, ioErr := ioutil.ReadAll(resp.Body)
  3907. if ioErr != nil {
  3908. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3910. return
  3911. }
  3912. var respJSON map[string]interface{}
  3913. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3914. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3916. return
  3917. }
  3918. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3919. userJSONBytes, _ := json.Marshal(respJSON)
  3920. fmt.Println("log")
  3921. fmt.Println(string(userJSONBytes))
  3922. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3923. utils.ErrorLog("解析失败:%v", err)
  3924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3925. return
  3926. }
  3927. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3928. bytesData, _ := json.Marshal(data)
  3929. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  3930. resp, _ := client.Do(req)
  3931. defer resp.Body.Close()
  3932. body, ioErr := ioutil.ReadAll(resp.Body)
  3933. if ioErr != nil {
  3934. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3936. return
  3937. }
  3938. var respJSON map[string]interface{}
  3939. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3940. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3942. return
  3943. }
  3944. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3945. userJSONBytes, _ := json.Marshal(respJSON)
  3946. fmt.Println("log")
  3947. fmt.Println(string(userJSONBytes))
  3948. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3949. utils.ErrorLog("解析失败:%v", err)
  3950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3951. return
  3952. }
  3953. res.InfRefmsgid = resFour10265.InfRefmsgid
  3954. res.Output = resFour10265.Output
  3955. res.ErrMsg = resFour10265.ErrMsg
  3956. res.Cainfo = resFour10265.Cainfo
  3957. res.WarnMsg = resFour10265.WarnMsg
  3958. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3959. res.Infcode = infocode
  3960. } else {
  3961. if miConfig.Code == "H15049901371" {
  3962. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), patientPrescription.DoctorId, sickConfig.CountryCode)
  3963. var dat map[string]interface{}
  3964. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3965. fmt.Println(dat)
  3966. } else {
  3967. fmt.Println(err)
  3968. }
  3969. saveLog(result, request_log, "2204", "上传费用明细")
  3970. userJSONBytes, _ := json.Marshal(dat)
  3971. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  3972. utils.ErrorLog("解析失败:%v", err)
  3973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3974. return
  3975. }
  3976. res.InfRefmsgid = resFour10265.InfRefmsgid
  3977. res.Output = resFour10265.Output
  3978. res.ErrMsg = resFour10265.ErrMsg
  3979. res.Cainfo = resFour10265.Cainfo
  3980. res.WarnMsg = resFour10265.WarnMsg
  3981. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  3982. res.Infcode = infocode
  3983. } else {
  3984. result, request_log := service.Gdyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), patientPrescription.DoctorId, sickConfig.CountryCode)
  3985. var dat map[string]interface{}
  3986. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3987. fmt.Println(dat)
  3988. } else {
  3989. fmt.Println(err)
  3990. }
  3991. saveLog(result, request_log, "2204", "上传费用明细")
  3992. userJSONBytes, _ := json.Marshal(dat)
  3993. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3994. utils.ErrorLog("解析失败:%v", err)
  3995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3996. return
  3997. }
  3998. }
  3999. }
  4000. if res.Infcode == 0 {
  4001. order := &models.HisOrder{
  4002. UserOrgId: adminUser.CurrentOrgId,
  4003. HisPatientId: his.ID,
  4004. PatientId: his.PatientId,
  4005. SettleAccountsDate: recordDateTime,
  4006. MdtrtId: his.Number,
  4007. PsnNo: his.PsnNo,
  4008. MedType: strconv.FormatInt(reg_type, 10),
  4009. Ctime: time.Now().Unix(),
  4010. Mtime: time.Now().Unix(),
  4011. Status: 1,
  4012. Number: chrg_bchno,
  4013. Infcode: res.Infcode,
  4014. WarnMsg: res.WarnMsg,
  4015. Cainfo: res.Cainfo,
  4016. ErrMsg: res.ErrMsg,
  4017. RespondTime: res.RefmsgTime,
  4018. InfRefmsgid: res.InfRefmsgid,
  4019. OrderStatus: 1,
  4020. PayWay: pay_way,
  4021. PayPrice: pay_price,
  4022. PayCardNo: pay_card_no,
  4023. DiscountPrice: discount_price,
  4024. PreferentialPrice: preferential_price,
  4025. RealityPrice: reality_price,
  4026. FoundPrice: found_price,
  4027. MedicalInsurancePrice: medical_insurance_price,
  4028. PrivatePrice: private_price,
  4029. IsMedicineInsurance: 1,
  4030. SettleType: settle_accounts_type,
  4031. SettleStartTime: start_time,
  4032. SettleEndTime: end_time,
  4033. Creator: roles.AdminUserId,
  4034. Modify: roles.AdminUserId,
  4035. FaPiaoNumber: fapiao_number,
  4036. FaPiaoCode: fapiao_code,
  4037. PType: 2,
  4038. Diagnosis: diagnosis_id,
  4039. }
  4040. err = service.CreateOrder(order)
  4041. if err != nil {
  4042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4043. return
  4044. }
  4045. for _, item := range res.Output.Result {
  4046. temp := strings.Split(item.FeedetlSn, "-")
  4047. var advice_id int64 = 0
  4048. var project_id int64 = 0
  4049. var types int64 = 0
  4050. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4051. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4052. if temp[1] == "1" {
  4053. advice_id = id
  4054. project_id = 0
  4055. } else if temp[1] == "2" {
  4056. advice_id = 0
  4057. project_id = id
  4058. }
  4059. info := &models.HisOrderInfo{
  4060. OrderNumber: order.Number,
  4061. FeedetlSn: item.FeedetlSn,
  4062. UploadDate: time.Now().Unix(),
  4063. AdviceId: advice_id,
  4064. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4065. Cnt: item.Cnt,
  4066. Pric: float64(item.Pric),
  4067. PatientId: his.PatientId,
  4068. PricUplmtAmt: item.PricUplmtAmt,
  4069. SelfpayProp: item.SelfpayProp,
  4070. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4071. OverlmtAmt: item.OverlmtAmt,
  4072. PreselfpayAmt: item.PreselfpayAmt,
  4073. BasMednFlag: item.BasMednFlag,
  4074. MedChrgitmType: item.MedChrgitmType,
  4075. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4076. Status: 1,
  4077. Memo: item.Memo,
  4078. Mtime: time.Now().Unix(),
  4079. InscpScpAmt: item.InscpScpAmt,
  4080. DrtReimFlag: item.DrtReimFlag,
  4081. Ctime: time.Now().Unix(),
  4082. ListSpItemFlag: item.ListSpItemFlag,
  4083. ChldMedcFlag: item.ChldMedcFlag,
  4084. LmtUsedFlag: item.LmtUsedFlag,
  4085. ChrgitmLv: item.ChrgitmLv,
  4086. UserOrgId: adminUser.CurrentOrgId,
  4087. HisPatientId: his.ID,
  4088. OrderId: order.ID,
  4089. ProjectId: project_id,
  4090. Type: types,
  4091. }
  4092. service.CreateOrderInfo(info)
  4093. }
  4094. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4095. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4096. var total float64
  4097. for _, item := range prescriptions {
  4098. if item.Type == 1 { //药品
  4099. for _, subItem := range item.HisDoctorAdviceInfo {
  4100. total = total + (subItem.Price * subItem.PrescribingNumber)
  4101. }
  4102. }
  4103. if item.Type == 2 { //项目
  4104. for _, subItem := range item.HisPrescriptionProject {
  4105. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4106. total = total + (subItem.Price * cnt)
  4107. }
  4108. }
  4109. }
  4110. for _, item := range prescriptions {
  4111. for _, subItem := range item.HisAdditionalCharge {
  4112. total = total + (subItem.Price * float64(subItem.Count))
  4113. }
  4114. }
  4115. var allTotal string
  4116. if adminUser.CurrentOrgId == 9919 {
  4117. allTotal = fmt.Sprintf("%.4f", total)
  4118. } else {
  4119. allTotal = fmt.Sprintf("%.4f", total)
  4120. }
  4121. if res.Infcode == 0 {
  4122. var rf []*ResultFive
  4123. json.Unmarshal([]byte(his.Iinfo), &rf)
  4124. chrg_bchno := chrg_bchno
  4125. cert_no := his.Certno
  4126. var insutypes []string
  4127. var insutype string
  4128. var is390 int = 0
  4129. var is310 int = 0
  4130. for _, item := range rf {
  4131. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4132. insutypes = append(insutypes, item.Insutype)
  4133. }
  4134. }
  4135. if len(insutypes) == 1 {
  4136. insutype = insutypes[0]
  4137. } else {
  4138. for _, i := range insutypes {
  4139. if i == "390" {
  4140. is390 = 1
  4141. }
  4142. if i == "310" {
  4143. is310 = 1
  4144. }
  4145. }
  4146. }
  4147. if is390 == 1 {
  4148. insutype = "390"
  4149. }
  4150. if is310 == 1 {
  4151. insutype = "310"
  4152. }
  4153. if len(insutypes) == 0 {
  4154. insutype = "310"
  4155. }
  4156. if len(insutypes) == 2 {
  4157. insutype = strconv.FormatInt(his.SocialType, 10)
  4158. }
  4159. insutype = strconv.FormatInt(his.SocialType, 10)
  4160. //insutype = "390"
  4161. if his.IdCardType == 1 {
  4162. // cert_no = his.MedicalInsuranceNumber
  4163. cert_no = his.Certno
  4164. } else {
  4165. cert_no = his.Certno
  4166. }
  4167. var res ResultSeven
  4168. var resSeven10265 ResultSeven10265
  4169. var src_resquest string
  4170. var result2 string
  4171. var acct_used_flag string
  4172. fmt.Println("pay_way")
  4173. fmt.Println(pay_way)
  4174. fmt.Println("pay_way")
  4175. if pay_way == 4 {
  4176. acct_used_flag = "1"
  4177. } else {
  4178. acct_used_flag = "0"
  4179. }
  4180. if miConfig.MdtrtareaAdmvs == "421300" {
  4181. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4182. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4183. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4184. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4185. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4186. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4187. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4188. resp, requestErr := http.Get(api)
  4189. if requestErr != nil {
  4190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4191. return
  4192. }
  4193. body, ioErr := ioutil.ReadAll(resp.Body)
  4194. if ioErr != nil {
  4195. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4197. return
  4198. }
  4199. var respJSON map[string]interface{}
  4200. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4201. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4203. return
  4204. }
  4205. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4206. result, _ := json.Marshal(respJSON)
  4207. if miConfig.Code == "H15049901371" {
  4208. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4209. utils.ErrorLog("解析失败:%v", err)
  4210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4211. return
  4212. }
  4213. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4214. res.Output = resSeven10265.Output
  4215. res.ErrMsg = resSeven10265.ErrMsg
  4216. res.Cainfo = resSeven10265.Cainfo
  4217. res.WarnMsg = resSeven10265.WarnMsg
  4218. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4219. res.Infcode = infocode
  4220. } else {
  4221. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4222. utils.ErrorLog("解析失败:%v", err)
  4223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4224. return
  4225. }
  4226. }
  4227. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4228. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4229. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4230. //psn_info, _ := service.GetPsnByPatientId(id)
  4231. bas := strings.Split(psn_info.CardInfo, "|")
  4232. if his.IdCardType == 1 {
  4233. cert_no = bas[2]
  4234. } else {
  4235. cert_no = bas[1]
  4236. }
  4237. //江苏地区国家医保医疗类别
  4238. //职工透析:医疗类别选特殊情况门诊9933
  4239. //居民血透门慢: 医疗类别选门诊慢病1402
  4240. //var med_type string
  4241. //if his.Insutype == "310" {
  4242. // if reg_type == 14 {
  4243. // med_type = "9933"
  4244. // } else if reg_type == 11 {
  4245. // med_type = "11"
  4246. //
  4247. // }
  4248. //} else if his.Insutype == "390" {
  4249. // if reg_type == 14 {
  4250. // med_type = "1402"
  4251. // } else if reg_type == 11 {
  4252. // med_type = "11"
  4253. // }
  4254. //}
  4255. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4256. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4257. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4258. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4259. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4260. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4261. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4262. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4263. resp, requestErr := http.Get(api)
  4264. if requestErr != nil {
  4265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4266. return
  4267. }
  4268. body, ioErr := ioutil.ReadAll(resp.Body)
  4269. if ioErr != nil {
  4270. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4272. return
  4273. }
  4274. var respJSON map[string]interface{}
  4275. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4276. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4278. return
  4279. }
  4280. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4281. result, _ := json.Marshal(respJSON)
  4282. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4283. utils.ErrorLog("解析失败:%v", err)
  4284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4285. return
  4286. }
  4287. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4288. res.Output = resSeven10265.Output
  4289. res.ErrMsg = resSeven10265.ErrMsg
  4290. res.Cainfo = resSeven10265.Cainfo
  4291. res.WarnMsg = resSeven10265.WarnMsg
  4292. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4293. res.Infcode = infocode
  4294. } else {
  4295. if miConfig.Code == "H15049901371" {
  4296. //赤峰地区国家医保医疗类别
  4297. //职工透析:医疗类别选特殊情况门诊990502
  4298. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4299. var med_type string
  4300. if his.Insutype == "390" {
  4301. if reg_type == 14 {
  4302. med_type = "9933"
  4303. } else if reg_type == 11 {
  4304. med_type = "11"
  4305. }
  4306. } else if his.Insutype == "310" {
  4307. if reg_type == 14 {
  4308. med_type = "990502"
  4309. } else if reg_type == 11 {
  4310. med_type = "11"
  4311. }
  4312. }
  4313. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  4314. } else {
  4315. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.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)
  4316. }
  4317. //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)
  4318. var dat map[string]interface{}
  4319. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4320. fmt.Println(dat)
  4321. } else {
  4322. fmt.Println(err)
  4323. }
  4324. saveLog(result2, src_resquest, "2207", "结算")
  4325. userJSONBytes, _ := json.Marshal(dat)
  4326. if miConfig.Code == "H15049901371" {
  4327. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4328. utils.ErrorLog("解析失败:%v", err)
  4329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4330. return
  4331. }
  4332. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4333. res.Output = resSeven10265.Output
  4334. res.ErrMsg = resSeven10265.ErrMsg
  4335. res.Cainfo = resSeven10265.Cainfo
  4336. res.WarnMsg = resSeven10265.WarnMsg
  4337. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4338. res.Infcode = infocode
  4339. } else {
  4340. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4341. utils.ErrorLog("解析失败:%v", err)
  4342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4343. return
  4344. }
  4345. }
  4346. }
  4347. if res.Infcode != 0 {
  4348. errlog := &models.HisOrderError{
  4349. UserOrgId: adminUser.CurrentOrgId,
  4350. Ctime: time.Now().Unix(),
  4351. Mtime: time.Now().Unix(),
  4352. Number: chrg_bchno,
  4353. ErrMsg: res.ErrMsg,
  4354. Status: 1,
  4355. PatientId: id,
  4356. RecordTime: recordDateTime,
  4357. Stage: 6,
  4358. }
  4359. service.CreateErrMsgLog(errlog)
  4360. c.ServeSuccessJSON(map[string]interface{}{
  4361. "failed_code": -10,
  4362. "msg": res.ErrMsg,
  4363. })
  4364. return
  4365. } else {
  4366. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4367. order.OrderStatus = 2
  4368. order.Status = 1
  4369. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4370. order.SetlId = res.Output.Setlinfo.SetlID
  4371. order.PsnNo = res.Output.Setlinfo.PsnNo
  4372. order.PsnName = res.Output.Setlinfo.PsnName
  4373. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4374. order.Certno = res.Output.Setlinfo.Certno
  4375. order.Gend = res.Output.Setlinfo.Gend
  4376. order.Naty = res.Output.Setlinfo.Naty
  4377. order.Age = res.Output.Setlinfo.Age
  4378. order.Insutype = res.Output.Setlinfo.Insutype
  4379. order.PsnType = res.Output.Setlinfo.PsnType
  4380. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4381. order.SetlTime = res.Output.Setlinfo.SetlTime
  4382. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4383. if res.Output.Setlinfo.MedType == "140101" {
  4384. order.MedType = "14"
  4385. } else {
  4386. order.MedType = res.Output.Setlinfo.MedType
  4387. }
  4388. if reg_type == 1112 {
  4389. order.MedType = "1112"
  4390. }
  4391. if reg_type == 1111 {
  4392. order.MedType = "1111"
  4393. }
  4394. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4395. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4396. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4397. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4398. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4399. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4400. order.HifpPay = res.Output.Setlinfo.HifpPay
  4401. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4402. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4403. order.HifesPay = res.Output.Setlinfo.HifesPay
  4404. order.HifobPay = res.Output.Setlinfo.HifobPay
  4405. order.MafPay = res.Output.Setlinfo.MafPay
  4406. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4407. order.OthPay = res.Output.Setlinfo.OthPay
  4408. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4409. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4410. order.AcctPay = res.Output.Setlinfo.AcctPay
  4411. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4412. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4413. order.Balc = res.Output.Setlinfo.Balc
  4414. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4415. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4416. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4417. order.ClrType = res.Output.Setlinfo.ClrType
  4418. order.ClrWay = res.Output.Setlinfo.ClrWay
  4419. order.Creator = order.Creator
  4420. order.Modify = roles.AdminUserId
  4421. order.RequestLog = src_resquest
  4422. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4423. detailStr := string(setlDetail)
  4424. order.SetlDetail = detailStr
  4425. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4426. err = service.UpDateOrder(order)
  4427. if err == nil {
  4428. c.ServeSuccessJSON(map[string]interface{}{
  4429. "msg": "结算成功",
  4430. })
  4431. } else {
  4432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4433. return
  4434. }
  4435. }
  4436. } else {
  4437. adminUser := c.GetAdminUserInfo()
  4438. errlog := &models.HisOrderError{
  4439. UserOrgId: adminUser.CurrentOrgId,
  4440. Ctime: time.Now().Unix(),
  4441. Mtime: time.Now().Unix(),
  4442. ErrMsg: res.ErrMsg,
  4443. Status: 1,
  4444. PatientId: id,
  4445. RecordTime: recordDateTime,
  4446. Stage: 4,
  4447. }
  4448. service.CreateErrMsgLog(errlog)
  4449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4450. return
  4451. }
  4452. } else {
  4453. adminUser := c.GetAdminUserInfo()
  4454. errlog := &models.HisOrderError{
  4455. UserOrgId: adminUser.CurrentOrgId,
  4456. Ctime: time.Now().Unix(),
  4457. Mtime: time.Now().Unix(),
  4458. ErrMsg: res.ErrMsg,
  4459. Status: 1,
  4460. PatientId: id,
  4461. RecordTime: recordDateTime,
  4462. Stage: 4,
  4463. }
  4464. service.CreateErrMsgLog(errlog)
  4465. c.ServeSuccessJSON(map[string]interface{}{
  4466. "failed_code": -10,
  4467. "msg": res.ErrMsg,
  4468. })
  4469. return
  4470. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4471. //return
  4472. }
  4473. }
  4474. }
  4475. } else if tempOrder.ID > 0 {
  4476. if tempOrder.IsPre == 1 {
  4477. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  4478. var rf []*ResultFive
  4479. json.Unmarshal([]byte(his.Iinfo), &rf)
  4480. chrg_bchno := tempOrder.Number
  4481. cert_no := his.Certno
  4482. var insutypes []string
  4483. var insutype string
  4484. var is390 int = 0
  4485. var is310 int = 0
  4486. for _, item := range rf {
  4487. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4488. insutypes = append(insutypes, item.Insutype)
  4489. }
  4490. }
  4491. if len(insutypes) == 1 {
  4492. insutype = insutypes[0]
  4493. } else {
  4494. for _, i := range insutypes {
  4495. if i == "390" {
  4496. is390 = 1
  4497. }
  4498. if i == "310" {
  4499. is310 = 1
  4500. }
  4501. }
  4502. }
  4503. if is390 == 1 {
  4504. insutype = "390"
  4505. }
  4506. if is310 == 1 {
  4507. insutype = "310"
  4508. }
  4509. if len(insutypes) == 0 {
  4510. insutype = "310"
  4511. }
  4512. if len(insutypes) == 2 {
  4513. insutype = strconv.FormatInt(his.SocialType, 64)
  4514. }
  4515. //insutype = "390"
  4516. if his.IdCardType == 1 {
  4517. // cert_no = his.MedicalInsuranceNumber
  4518. cert_no = his.Certno
  4519. } else {
  4520. cert_no = his.Certno
  4521. }
  4522. var res ResultSeven
  4523. var resSeven10265 ResultSeven10265
  4524. var src_resquest string
  4525. var result2 string
  4526. var acct_used_flag string
  4527. fmt.Println("pay_way")
  4528. fmt.Println(pay_way)
  4529. fmt.Println("pay_way")
  4530. if pay_way == 4 {
  4531. acct_used_flag = "1"
  4532. } else {
  4533. acct_used_flag = "0"
  4534. }
  4535. if miConfig.MdtrtareaAdmvs == "421300" {
  4536. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4537. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4538. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4539. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4540. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4541. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4542. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4543. resp, requestErr := http.Get(api)
  4544. if requestErr != nil {
  4545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4546. return
  4547. }
  4548. body, ioErr := ioutil.ReadAll(resp.Body)
  4549. if ioErr != nil {
  4550. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4552. return
  4553. }
  4554. var respJSON map[string]interface{}
  4555. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4556. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4558. return
  4559. }
  4560. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4561. result, _ := json.Marshal(respJSON)
  4562. fmt.Println("log")
  4563. fmt.Println(string(result))
  4564. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4565. utils.ErrorLog("解析失败:%v", err)
  4566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4567. return
  4568. }
  4569. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4570. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4571. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4572. //psn_info, _ := service.GetPsnByPatientId(id)
  4573. bas := strings.Split(psn_info.CardInfo, "|")
  4574. if his.IdCardType == 1 {
  4575. cert_no = bas[2]
  4576. } else {
  4577. cert_no = bas[1]
  4578. }
  4579. //江苏地区国家医保医疗类别
  4580. //职工透析:医疗类别选特殊情况门诊9933
  4581. //居民血透门慢: 医疗类别选门诊慢病1402
  4582. //var med_type string
  4583. //if his.Insutype == "310" {
  4584. // if reg_type == 14 {
  4585. // med_type = "9933"
  4586. // } else if reg_type == 11 {
  4587. // med_type = "11"
  4588. //
  4589. // }
  4590. //} else if his.Insutype == "390" {
  4591. // if reg_type == 14 {
  4592. // med_type = "1402"
  4593. // } else if reg_type == 11 {
  4594. // med_type = "11"
  4595. // }
  4596. //}
  4597. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4598. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4599. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4600. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4601. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4602. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4603. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4604. resp, requestErr := http.Get(api)
  4605. if requestErr != nil {
  4606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4607. return
  4608. }
  4609. body, ioErr := ioutil.ReadAll(resp.Body)
  4610. if ioErr != nil {
  4611. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4613. return
  4614. }
  4615. var respJSON map[string]interface{}
  4616. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4617. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4619. return
  4620. }
  4621. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4622. result, _ := json.Marshal(respJSON)
  4623. fmt.Println("log")
  4624. fmt.Println(string(result))
  4625. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4626. utils.ErrorLog("解析失败:%v", err)
  4627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4628. return
  4629. }
  4630. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4631. res.Output = resSeven10265.Output
  4632. res.ErrMsg = resSeven10265.ErrMsg
  4633. res.Cainfo = resSeven10265.Cainfo
  4634. res.WarnMsg = resSeven10265.WarnMsg
  4635. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4636. res.Infcode = infocode
  4637. } else {
  4638. var src_resquest string
  4639. if miConfig.Code == "H15049901371" {
  4640. //赤峰地区国家医保医疗类别
  4641. //职工透析:医疗类别选特殊情况门诊990502
  4642. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4643. var med_type string
  4644. if his.Insutype == "390" {
  4645. if reg_type == 14 {
  4646. med_type = "9933"
  4647. } else if reg_type == 11 {
  4648. med_type = "11"
  4649. }
  4650. } else if his.Insutype == "310" {
  4651. if reg_type == 14 {
  4652. med_type = "990502"
  4653. } else if reg_type == 11 {
  4654. med_type = "11"
  4655. }
  4656. }
  4657. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag)
  4658. } else {
  4659. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.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)
  4660. }
  4661. var dat map[string]interface{}
  4662. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4663. fmt.Println(dat)
  4664. } else {
  4665. fmt.Println(err)
  4666. }
  4667. saveLog(result2, src_resquest, "2207", "结算")
  4668. userJSONBytes, _ := json.Marshal(dat)
  4669. if miConfig.Code == "H15049901371" {
  4670. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4671. utils.ErrorLog("解析失败:%v", err)
  4672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4673. return
  4674. }
  4675. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4676. res.Output = resSeven10265.Output
  4677. res.ErrMsg = resSeven10265.ErrMsg
  4678. res.Cainfo = resSeven10265.Cainfo
  4679. res.WarnMsg = resSeven10265.WarnMsg
  4680. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4681. res.Infcode = infocode
  4682. } else {
  4683. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4684. utils.ErrorLog("解析失败:%v", err)
  4685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4686. return
  4687. }
  4688. }
  4689. }
  4690. if res.Infcode != 0 {
  4691. errlog := &models.HisOrderError{
  4692. UserOrgId: adminUser.CurrentOrgId,
  4693. Ctime: time.Now().Unix(),
  4694. Mtime: time.Now().Unix(),
  4695. Number: chrg_bchno,
  4696. ErrMsg: res.ErrMsg,
  4697. Status: 1,
  4698. PatientId: id,
  4699. RecordTime: recordDateTime,
  4700. Stage: 6,
  4701. }
  4702. service.CreateErrMsgLog(errlog)
  4703. c.ServeSuccessJSON(map[string]interface{}{
  4704. "failed_code": -10,
  4705. "msg": res.ErrMsg,
  4706. })
  4707. return
  4708. } else {
  4709. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4710. order.OrderStatus = 2
  4711. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4712. order.SetlId = res.Output.Setlinfo.SetlID
  4713. order.PsnNo = res.Output.Setlinfo.PsnNo
  4714. order.PsnName = res.Output.Setlinfo.PsnName
  4715. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4716. order.Certno = res.Output.Setlinfo.Certno
  4717. order.Gend = res.Output.Setlinfo.Gend
  4718. order.Naty = res.Output.Setlinfo.Naty
  4719. order.Age = res.Output.Setlinfo.Age
  4720. order.Insutype = res.Output.Setlinfo.Insutype
  4721. order.PsnType = res.Output.Setlinfo.PsnType
  4722. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4723. order.SetlTime = res.Output.Setlinfo.SetlTime
  4724. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4725. //order.MedType = res.Output.Setlinfo.MedType
  4726. if reg_type == 1112 {
  4727. order.MedType = "1112"
  4728. }
  4729. if reg_type == 1111 {
  4730. order.MedType = "1111"
  4731. }
  4732. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4733. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4734. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4735. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4736. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4737. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4738. order.HifpPay = res.Output.Setlinfo.HifpPay
  4739. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4740. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4741. order.HifesPay = res.Output.Setlinfo.HifesPay
  4742. order.HifobPay = res.Output.Setlinfo.HifobPay
  4743. order.MafPay = res.Output.Setlinfo.MafPay
  4744. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4745. order.OthPay = res.Output.Setlinfo.OthPay
  4746. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4747. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4748. order.AcctPay = res.Output.Setlinfo.AcctPay
  4749. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4750. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4751. order.Balc = res.Output.Setlinfo.Balc
  4752. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4753. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4754. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4755. order.ClrWay = res.Output.Setlinfo.ClrWay
  4756. order.Creator = order.Creator
  4757. order.Modify = roles.AdminUserId
  4758. order.RequestLog = src_resquest
  4759. order.Diagnosis = diagnosis_id
  4760. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4761. detailStr := string(setlDetail)
  4762. order.SetlDetail = detailStr
  4763. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4764. err = service.UpDateOrder(order)
  4765. if err == nil {
  4766. c.ServeSuccessJSON(map[string]interface{}{
  4767. "msg": "结算成功",
  4768. })
  4769. } else {
  4770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4771. return
  4772. }
  4773. }
  4774. }
  4775. }
  4776. }
  4777. //func (c *HisApiController) GetPreUploadInfo() {
  4778. // id, _ := c.GetInt64("id")
  4779. // record_time := c.GetString("record_time")
  4780. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4781. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4782. //
  4783. // timeLayout := "2006-01-02"
  4784. // loc, _ := time.LoadLocation("Local")
  4785. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4786. // if err != nil {
  4787. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4788. // return
  4789. // }
  4790. // recordDateTime := theTime.Unix()
  4791. // adminUser := c.GetAdminUserInfo()
  4792. //
  4793. // var prescriptions []*models.HisPrescription
  4794. //
  4795. // var start_time int64
  4796. // var end_time int64
  4797. //
  4798. // data := make(map[string]interface{})
  4799. // if settle_accounts_type == 1 { //日结
  4800. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  4801. // data["pre"] = prescriptions
  4802. //
  4803. // } else { //月结
  4804. // start_time_str := c.GetString("start_time")
  4805. // end_time_str := c.GetString("end_time")
  4806. // timeLayout := "2006-01-02"
  4807. // loc, _ := time.LoadLocation("Local")
  4808. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4809. // if err != nil {
  4810. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4811. // return
  4812. // }
  4813. // recordStartTime := theStartTime.Unix()
  4814. // start_time = recordStartTime
  4815. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4816. // if err != nil {
  4817. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4818. // return
  4819. // }
  4820. // recordEndTime := theEndTime.Unix()
  4821. // end_time = recordEndTime
  4822. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  4823. // data["pre"] = prescriptions
  4824. //
  4825. // }
  4826. //
  4827. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4828. //
  4829. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4830. // timestamp := time.Now().Unix()
  4831. // tempTime := time.Unix(timestamp, 0)
  4832. // timeFormat := tempTime.Format("20060102150405")
  4833. // chrgBchno := rand.Intn(100000) + 10000
  4834. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4835. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4836. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4837. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4838. // strconv.FormatInt(his.PatientId, 10)
  4839. // client := &http.Client{}
  4840. // data["psn_no"] = his.PsnNo
  4841. // data["mdtrt_id"] = his.Number
  4842. // data["chrg_bchno"] = chrg_bchno
  4843. // data["org_name"] = miConfig.OrgName
  4844. // data["doctor"] = roles.UserName
  4845. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4846. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4847. // data["fixmedins_code"] = miConfig.Code
  4848. // data["dept_code"] = department.Number
  4849. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4850. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4851. // data["secret_key"] = miConfig.SecretKey
  4852. // var ids []int64
  4853. //
  4854. // for _, item := range prescriptions {
  4855. // ids = append(ids, item.ID)
  4856. // }
  4857. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4858. // if config.IsOpen == 1 { //对接了医保,走医保流程
  4859. // bytesData, _ := json.Marshal(data)
  4860. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  4861. // resp, _ := client.Do(req)
  4862. // defer resp.Body.Close()
  4863. // body, ioErr := ioutil.ReadAll(resp.Body)
  4864. // if ioErr != nil {
  4865. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4866. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4867. // return
  4868. // }
  4869. // var respJSON map[string]interface{}
  4870. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4871. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4872. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4873. // return
  4874. // }
  4875. //
  4876. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4877. // userJSONBytes, _ := json.Marshal(respJSON)
  4878. // var res ResultFour
  4879. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4880. // utils.ErrorLog("解析失败:%v", err)
  4881. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4882. // return
  4883. // }
  4884. //
  4885. // if res.Infcode == 0 {
  4886. // order := &models.HisOrder{
  4887. // UserOrgId: adminUser.CurrentOrgId,
  4888. // HisPatientId: his.ID,
  4889. // PatientId: his.PatientId,
  4890. // SettleAccountsDate: recordDateTime,
  4891. // Ctime: time.Now().Unix(),
  4892. // Mtime: time.Now().Unix(),
  4893. // Status: 1,
  4894. // Number: chrg_bchno,
  4895. // Infcode: res.Infcode,
  4896. // WarnMsg: res.WarnMsg,
  4897. // Cainfo: res.Cainfo,
  4898. // ErrMsg: res.ErrMsg,
  4899. // RespondTime: res.RefmsgTime,
  4900. // InfRefmsgid: res.InfRefmsgid,
  4901. // OrderStatus: 1,
  4902. // IsMedicineInsurance: 1,
  4903. // SettleType: settle_accounts_type,
  4904. // SettleStartTime: start_time,
  4905. // SettleEndTime: end_time,
  4906. // Creator: roles.ID,
  4907. // Modify: roles.ID,
  4908. // PType: 2,
  4909. // }
  4910. // err = service.CreateOrder(order)
  4911. // if err != nil {
  4912. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4913. // return
  4914. // }
  4915. //
  4916. // for _, item := range res.Output.Result {
  4917. // temp := strings.Split(item.FeedetlSn, "-")
  4918. // var advice_id int64 = 0
  4919. // var project_id int64 = 0
  4920. // var types int64 = 0
  4921. //
  4922. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  4923. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  4924. //
  4925. // if temp[1] == "1" {
  4926. // advice_id = id
  4927. // project_id = 0
  4928. // } else if temp[1] == "2" {
  4929. // advice_id = 0
  4930. // project_id = id
  4931. // }
  4932. //
  4933. // info := &models.HisOrderInfo{
  4934. // OrderNumber: order.Number,
  4935. // FeedetlSn: item.FeedetlSn,
  4936. // UploadDate: time.Now().Unix(),
  4937. // AdviceId: advice_id,
  4938. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  4939. // Cnt: item.Cnt,
  4940. // Pric: float64(item.Pric),
  4941. // PatientId: his.PatientId,
  4942. // PricUplmtAmt: item.PricUplmtAmt,
  4943. // SelfpayProp: item.SelfpayProp,
  4944. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4945. // OverlmtAmt: item.OverlmtAmt,
  4946. // PreselfpayAmt: item.PreselfpayAmt,
  4947. // BasMednFlag: item.BasMednFlag,
  4948. // MedChrgitmType: item.MedChrgitmType,
  4949. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  4950. // Status: 1,
  4951. // Memo: item.Memo,
  4952. // Mtime: time.Now().Unix(),
  4953. // InscpScpAmt: item.InscpScpAmt,
  4954. // DrtReimFlag: item.DrtReimFlag,
  4955. // Ctime: time.Now().Unix(),
  4956. // ListSpItemFlag: item.ListSpItemFlag,
  4957. // ChldMedcFlag: item.ChldMedcFlag,
  4958. // LmtUsedFlag: item.LmtUsedFlag,
  4959. // ChrgitmLv: item.ChrgitmLv,
  4960. // UserOrgId: adminUser.CurrentOrgId,
  4961. // HisPatientId: his.ID,
  4962. // OrderId: order.ID,
  4963. // ProjectId: project_id,
  4964. // Type: types,
  4965. // }
  4966. // service.CreateOrderInfo(info)
  4967. //
  4968. // }
  4969. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4970. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  4971. //
  4972. // var total float64
  4973. // for _, item := range prescriptions {
  4974. // if item.Type == 1 { //药品
  4975. // for _, subItem := range item.HisDoctorAdviceInfo {
  4976. // total = total + (subItem.Price * subItem.PrescribingNumber)
  4977. // }
  4978. // }
  4979. // if item.Type == 2 { //项目
  4980. // for _, subItem := range item.HisPrescriptionProject {
  4981. // total = total + (subItem.Price * float64(subItem.Count))
  4982. // }
  4983. // }
  4984. // }
  4985. //
  4986. // for _, item := range prescriptions {
  4987. // for _, subItem := range item.HisAdditionalCharge {
  4988. // total = total + (subItem.Price * float64(subItem.Count))
  4989. // }
  4990. // }
  4991. //
  4992. // allTotal := fmt.Sprintf("%.2f", total)
  4993. // if res.Infcode == 0 {
  4994. // var rf []*ResultFive
  4995. // json.Unmarshal([]byte(his.Iinfo), &rf)
  4996. // psn_no := his.PsnNo
  4997. // mdtrt_id := his.Number
  4998. // chrg_bchno := chrg_bchno
  4999. // cert_no := his.Certno
  5000. // insutype := rf[0].Insutype
  5001. //
  5002. // if his.IdCardType == 1 {
  5003. // cert_no = his.MedicalInsuranceNumber
  5004. //
  5005. // } else {
  5006. //
  5007. // cert_no = his.Certno
  5008. //
  5009. // }
  5010. //
  5011. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  5012. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  5013. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  5014. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  5015. // resp, requestErr := http.Get(api)
  5016. // if requestErr != nil {
  5017. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5018. // return
  5019. // }
  5020. // defer resp.Body.Close()
  5021. // body, ioErr := ioutil.ReadAll(resp.Body)
  5022. // if ioErr != nil {
  5023. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5024. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5025. // return
  5026. // }
  5027. // var respJSON map[string]interface{}
  5028. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5029. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5030. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5031. // return
  5032. // }
  5033. // fmt.Println(respJSON)
  5034. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5035. // userJSONBytes, _ := json.Marshal(respJSON)
  5036. // var res ResultSeven
  5037. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5038. // utils.ErrorLog("解析失败:%v", err)
  5039. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5040. // return
  5041. // }
  5042. // if res.Infcode != 0 {
  5043. // errlog := &models.HisOrderError{
  5044. // UserOrgId: adminUser.CurrentOrgId,
  5045. // Ctime: time.Now().Unix(),
  5046. // Mtime: time.Now().Unix(),
  5047. // Number: chrg_bchno,
  5048. // ErrMsg: res.ErrMsg,
  5049. // Status: 1,
  5050. // PatientId: id,
  5051. // RecordTime: recordDateTime,
  5052. // Stage: 7,
  5053. // }
  5054. // service.CreateErrMsgLog(errlog)
  5055. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5056. // return
  5057. // } else {
  5058. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5059. // order.OrderStatus = 1
  5060. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5061. // order.SetlId = res.Output.Setlinfo.SetlID
  5062. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5063. // order.PsnName = res.Output.Setlinfo.PsnName
  5064. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5065. // order.Certno = res.Output.Setlinfo.Certno
  5066. // order.Gend = res.Output.Setlinfo.Gend
  5067. // order.Naty = res.Output.Setlinfo.Naty
  5068. // order.Age = res.Output.Setlinfo.Age
  5069. // order.Insutype = res.Output.Setlinfo.Insutype
  5070. // order.PsnType = res.Output.Setlinfo.PsnType
  5071. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5072. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5073. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5074. // order.MedType = res.Output.Setlinfo.MedType
  5075. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5076. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5077. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5078. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5079. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5080. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5081. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5082. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5083. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5084. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5085. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5086. // order.MafPay = res.Output.Setlinfo.MafPay
  5087. // order.OthPay = res.Output.Setlinfo.OthPay
  5088. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5089. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5090. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5091. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5092. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5093. // order.Balc = res.Output.Setlinfo.Balc
  5094. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5095. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5096. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5097. // order.ClrWay = res.Output.Setlinfo.ClrWay
  5098. // order.Creator = order.Creator
  5099. // order.Modify = roles.ID
  5100. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5101. // detailStr := string(setlDetail)
  5102. // order.SetlDetail = detailStr
  5103. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5104. // err = service.UpDateOrder(order)
  5105. // if err == nil {
  5106. // c.ServeSuccessJSON(map[string]interface{}{
  5107. // "msg": "预结算成功",
  5108. // })
  5109. // } else {
  5110. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5111. // return
  5112. // }
  5113. // }
  5114. // } else {
  5115. // adminUser := c.GetAdminUserInfo()
  5116. // errlog := &models.HisOrderError{
  5117. // UserOrgId: adminUser.CurrentOrgId,
  5118. // Ctime: time.Now().Unix(),
  5119. // Mtime: time.Now().Unix(),
  5120. // ErrMsg: res.ErrMsg,
  5121. // Status: 1,
  5122. // PatientId: id,
  5123. // RecordTime: recordDateTime,
  5124. // Stage: 4,
  5125. // }
  5126. // service.CreateErrMsgLog(errlog)
  5127. //
  5128. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5129. // return
  5130. // }
  5131. // } else {
  5132. // adminUser := c.GetAdminUserInfo()
  5133. // errlog := &models.HisOrderError{
  5134. // UserOrgId: adminUser.CurrentOrgId,
  5135. // Ctime: time.Now().Unix(),
  5136. // Mtime: time.Now().Unix(),
  5137. // ErrMsg: res.ErrMsg,
  5138. // Status: 1,
  5139. // PatientId: id,
  5140. // RecordTime: recordDateTime,
  5141. // Stage: 4,
  5142. // }
  5143. // service.CreateErrMsgLog(errlog)
  5144. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5145. // return
  5146. // }
  5147. //
  5148. // } else {
  5149. // var total float64
  5150. // for _, item := range prescriptions {
  5151. // if item.Type == 1 { //药品
  5152. // for _, subItem := range item.HisDoctorAdviceInfo {
  5153. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5154. // }
  5155. // }
  5156. // if item.Type == 2 { //项目
  5157. // for _, subItem := range item.HisPrescriptionProject {
  5158. // total = total + (subItem.Price * float64(subItem.Count))
  5159. // }
  5160. // }
  5161. //
  5162. // for _, subItem := range item.HisAdditionalCharge {
  5163. // total = total + (subItem.Price * float64(subItem.Count))
  5164. // }
  5165. // }
  5166. //
  5167. // allTotal := fmt.Sprintf("%.2f", total)
  5168. // totals, _ := strconv.ParseFloat(allTotal, 64)
  5169. // order := &models.HisOrder{
  5170. // UserOrgId: adminUser.CurrentOrgId,
  5171. // HisPatientId: his.ID,
  5172. // PatientId: id,
  5173. // SettleAccountsDate: recordDateTime,
  5174. // Ctime: time.Now().Unix(),
  5175. // Mtime: time.Now().Unix(),
  5176. // Status: 1,
  5177. // OrderStatus: 2,
  5178. // Number: chrg_bchno,
  5179. // MedfeeSumamt: totals,
  5180. // }
  5181. // err = service.CreateOrder(order)
  5182. // if err != nil {
  5183. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5184. // return
  5185. // }
  5186. //
  5187. // var customs []*Custom
  5188. // for _, item := range prescriptions {
  5189. //
  5190. // if item.Type == 1 { //药品
  5191. // for _, subItem := range item.HisDoctorAdviceInfo {
  5192. // cus := &Custom{
  5193. // AdviceId: subItem.ID,
  5194. // ProjectId: 0,
  5195. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  5196. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  5197. // FeedetlSn: subItem.FeedetlSn,
  5198. // Price: fmt.Sprintf("%.2f", subItem.Price),
  5199. // MedListCodg: subItem.MedListCodg,
  5200. // Type: 1,
  5201. // }
  5202. // customs = append(customs, cus)
  5203. // }
  5204. // }
  5205. //
  5206. // if item.Type == 2 { //项目
  5207. // for _, subItem := range item.HisPrescriptionProject {
  5208. //
  5209. // cus := &Custom{
  5210. // AdviceId: 0,
  5211. // ProjectId: subItem.ID,
  5212. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  5213. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  5214. // FeedetlSn: subItem.FeedetlSn,
  5215. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  5216. // MedListCodg: subItem.MedListCodg,
  5217. // Type: 2,
  5218. // }
  5219. //
  5220. // customs = append(customs, cus)
  5221. // }
  5222. // }
  5223. //
  5224. // for _, item := range item.HisAdditionalCharge {
  5225. // cus := &Custom{
  5226. // ItemId: item.ID,
  5227. // AdviceId: 0,
  5228. // ProjectId: 0,
  5229. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  5230. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  5231. // FeedetlSn: item.FeedetlSn,
  5232. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  5233. // MedListCodg: item.XtHisAddtionConfig.Code,
  5234. // Type: 3,
  5235. // }
  5236. //
  5237. // customs = append(customs, cus)
  5238. // }
  5239. //
  5240. // }
  5241. //
  5242. // for _, item := range customs {
  5243. // var advice_id int64 = 0
  5244. // var project_id int64 = 0
  5245. // var item_id int64 = 0
  5246. //
  5247. // var types int64 = 0
  5248. //
  5249. // if item.Type == 1 {
  5250. // advice_id = item.AdviceId
  5251. // project_id = 0
  5252. // item_id = 0
  5253. // } else if item.Type == 2 {
  5254. // advice_id = 0
  5255. // item_id = 0
  5256. //
  5257. // project_id = item.ProjectId
  5258. // } else if item.Type == 3 {
  5259. // advice_id = 0
  5260. // item_id = item.ItemId
  5261. // project_id = 0
  5262. // }
  5263. //
  5264. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  5265. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  5266. // pric, _ := strconv.ParseFloat(item.Price, 32)
  5267. //
  5268. // info := &models.HisOrderInfo{
  5269. // OrderNumber: order.Number,
  5270. // UploadDate: time.Now().Unix(),
  5271. // AdviceId: advice_id,
  5272. // DetItemFeeSumamt: detItemFeeSumamt,
  5273. // Cnt: cut,
  5274. // Pric: pric,
  5275. // PatientId: id,
  5276. // Status: 1,
  5277. // Mtime: time.Now().Unix(),
  5278. // Ctime: time.Now().Unix(),
  5279. // UserOrgId: adminUser.CurrentOrgId,
  5280. // HisPatientId: his.ID,
  5281. // OrderId: order.ID,
  5282. // ProjectId: project_id,
  5283. // Type: types,
  5284. // ItemId: item_id,
  5285. // }
  5286. // service.CreateOrderInfo(info)
  5287. // }
  5288. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5289. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5290. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  5291. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5292. // if err == nil {
  5293. // c.ServeSuccessJSON(map[string]interface{}{
  5294. // "msg": "结算成功",
  5295. // })
  5296. // } else {
  5297. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5298. // return
  5299. // }
  5300. // }
  5301. //}
  5302. //上传明细-预结算-
  5303. func (c *HisApiController) GetPreUploadInfo() {
  5304. id, _ := c.GetInt64("id")
  5305. record_time := c.GetString("record_time")
  5306. his_patient_id, _ := c.GetInt64("his_patient_id")
  5307. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5308. admin_user_id, _ := c.GetInt64("admin_user_id")
  5309. diagnosis_id := c.GetString("diagnosis")
  5310. sick_type, _ := c.GetInt64("sick_type")
  5311. reg_type, _ := c.GetInt64("p_type")
  5312. begin_time := c.GetString("begin_time")
  5313. id_str := c.GetString("ids")
  5314. ids_arr := strings.Split(id_str, ",")
  5315. timeLayout := "2006-01-02"
  5316. loc, _ := time.LoadLocation("Local")
  5317. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5318. if err != nil {
  5319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5320. return
  5321. }
  5322. recordDateTime := theTime.Unix()
  5323. adminUser := c.GetAdminUserInfo()
  5324. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5325. var config []*models.HisXtDiagnoseConfig
  5326. for _, item := range diagnosis_ids {
  5327. id, _ := strconv.ParseInt(item, 10, 64)
  5328. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5329. config = append(config, &diagnosisConfig)
  5330. }
  5331. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  5332. sickConfig, _ := service.FindSickById(sick_type)
  5333. var prescriptions []*models.HisPrescription
  5334. var start_time int64
  5335. var end_time int64
  5336. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5337. fmt.Println(his_patient_id)
  5338. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5339. timestamp := time.Now().Unix()
  5340. tempTime := time.Unix(timestamp, 0)
  5341. timeFormat := tempTime.Format("20060102150405")
  5342. chrgBchno := rand.Intn(100000) + 10000
  5343. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5344. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5345. var patientPrescription models.HisPrescriptionInfo
  5346. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5347. if patientPrescription.ID == 0 {
  5348. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5349. }
  5350. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5351. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5352. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5353. strconv.FormatInt(his.PatientId, 10)
  5354. var res2 ResultSix
  5355. var resSix10265 ResultSix10265
  5356. var time_stamp string
  5357. if miConfig.MdtrtareaAdmvs == "421300" {
  5358. data := make(map[string]interface{})
  5359. client := &http.Client{}
  5360. data["psn_no"] = his.PsnNo
  5361. data["mdtrt_id"] = his.Number
  5362. data["doctor"] = roles.UserName
  5363. data["department"] = department.Name
  5364. data["org_name"] = miConfig.OrgName
  5365. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5366. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5367. data["fixmedins_code"] = miConfig.Code
  5368. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5369. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5370. data["secret_key"] = miConfig.SecretKey
  5371. data["sick_code"] = sickConfig.CountryCode
  5372. data["sick_name"] = sickConfig.ClassName
  5373. data["begin_time"] = begin_time
  5374. data["dept"] = strconv.FormatInt(department.ID, 10)
  5375. data["config"] = config
  5376. fmt.Println(data)
  5377. bytesData, _ := json.Marshal(data)
  5378. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5379. resp, _ := client.Do(req)
  5380. defer resp.Body.Close()
  5381. body, ioErr := ioutil.ReadAll(resp.Body)
  5382. if ioErr != nil {
  5383. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5385. return
  5386. }
  5387. var respJSON map[string]interface{}
  5388. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5391. return
  5392. }
  5393. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5394. userJSONBytes, _ := json.Marshal(respJSON)
  5395. fmt.Println("log")
  5396. fmt.Println(string(userJSONBytes))
  5397. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5398. utils.ErrorLog("解析失败:%v", err)
  5399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5400. return
  5401. }
  5402. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5403. //江苏地区国家医保医疗类别
  5404. //职工透析:医疗类别选特殊情况门诊9933
  5405. //居民血透门慢: 医疗类别选门诊慢病1402
  5406. //var med_type string
  5407. //if his.Insutype == "310" {
  5408. // if reg_type == 14 {
  5409. // med_type = "9933"
  5410. // } else if reg_type == 11 {
  5411. // med_type = "11"
  5412. //
  5413. // }
  5414. //} else if his.Insutype == "390" {
  5415. // if reg_type == 14 {
  5416. // med_type = "1402"
  5417. // } else if reg_type == 11 {
  5418. // med_type = "11"
  5419. // }
  5420. //}
  5421. data := make(map[string]interface{})
  5422. client := &http.Client{}
  5423. data["psn_no"] = his.PsnNo
  5424. data["mdtrt_id"] = his.Number
  5425. data["doctor"] = roles.UserName
  5426. data["department"] = department.Name
  5427. data["org_name"] = miConfig.OrgName
  5428. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5429. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5430. data["fixmedins_code"] = miConfig.Code
  5431. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5432. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5433. data["secret_key"] = miConfig.SecretKey
  5434. data["sick_code"] = sickConfig.CountryCode
  5435. data["sick_name"] = sickConfig.ClassName
  5436. data["begin_time"] = begin_time
  5437. data["dept"] = strconv.FormatInt(department.ID, 10)
  5438. data["config"] = config
  5439. data["url"] = miConfig.Url
  5440. data["ak"] = miConfig.AccessKey
  5441. data["cainfo"] = miConfig.Cainfo
  5442. bytesData, _ := json.Marshal(data)
  5443. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5444. resp, _ := client.Do(req)
  5445. defer resp.Body.Close()
  5446. body, ioErr := ioutil.ReadAll(resp.Body)
  5447. if ioErr != nil {
  5448. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5450. return
  5451. }
  5452. var respJSON map[string]interface{}
  5453. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5454. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5456. return
  5457. }
  5458. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  5459. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  5460. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  5461. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5462. userJSONBytes, _ := json.Marshal(respJSON)
  5463. fmt.Println("log")
  5464. fmt.Println(string(userJSONBytes))
  5465. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5466. utils.ErrorLog("解析失败:%v", err)
  5467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5468. return
  5469. }
  5470. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5471. res2.Output = resSix10265.Output
  5472. res2.ErrMsg = resSix10265.ErrMsg
  5473. res2.Cainfo = resSix10265.Cainfo
  5474. res2.WarnMsg = resSix10265.WarnMsg
  5475. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5476. res2.Infcode = infocode
  5477. } else {
  5478. var result string
  5479. var requestLog string
  5480. if miConfig.MdtrtareaAdmvs == "440781" { //
  5481. 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, begin_time)
  5482. } else {
  5483. if miConfig.Code == "H15049901371" {
  5484. //赤峰地区国家医保医疗类别
  5485. //职工透析:医疗类别选特殊情况门诊990502
  5486. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5487. var med_type string
  5488. if his.Insutype == "390" {
  5489. if reg_type == 14 {
  5490. med_type = "9933"
  5491. } else if reg_type == 11 {
  5492. med_type = "11"
  5493. }
  5494. } else if his.Insutype == "310" {
  5495. if reg_type == 14 {
  5496. med_type = "990502"
  5497. } else if reg_type == 11 {
  5498. med_type = "11"
  5499. }
  5500. }
  5501. result, requestLog = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, med_type, doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  5502. } else {
  5503. 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, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time)
  5504. }
  5505. saveLog(result, requestLog, "2203", "上传就诊信息")
  5506. var respJSON2 map[string]interface{}
  5507. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5508. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5510. return
  5511. }
  5512. userJSONBytes2, _ := json.Marshal(respJSON2)
  5513. if miConfig.Code == "H15049901371" {
  5514. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  5515. utils.ErrorLog("解析失败:%v", err)
  5516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5517. return
  5518. }
  5519. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5520. res2.Output = resSix10265.Output
  5521. res2.ErrMsg = resSix10265.ErrMsg
  5522. res2.Cainfo = resSix10265.Cainfo
  5523. res2.WarnMsg = resSix10265.WarnMsg
  5524. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5525. res2.Infcode = infocode
  5526. } else {
  5527. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5528. utils.ErrorLog("解析失败:%v", err)
  5529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5530. return
  5531. }
  5532. }
  5533. }
  5534. }
  5535. if res2.Infcode != 0 {
  5536. adminUser := c.GetAdminUserInfo()
  5537. errlog := &models.HisOrderError{
  5538. UserOrgId: adminUser.CurrentOrgId,
  5539. Ctime: time.Now().Unix(),
  5540. Mtime: time.Now().Unix(),
  5541. ErrMsg: res2.ErrMsg,
  5542. Status: 1,
  5543. PatientId: id,
  5544. RecordTime: recordDateTime,
  5545. Stage: 3,
  5546. }
  5547. service.CreateErrMsgLog(errlog)
  5548. c.ServeSuccessJSON(map[string]interface{}{
  5549. "failed_code": -10,
  5550. "msg": res2.ErrMsg,
  5551. })
  5552. return
  5553. } else {
  5554. his.Diagnosis = diagnosis_id
  5555. his.SickType = sickConfig.ID
  5556. his.PType = fmt.Sprintf("%d", reg_type)
  5557. service.UpdateHisPatientThree(&his)
  5558. data := make(map[string]interface{})
  5559. if settle_accounts_type == 1 { //日结
  5560. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5561. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5562. } else {
  5563. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5564. }
  5565. data["pre"] = prescriptions
  5566. } else { //月结
  5567. start_time_str := c.GetString("start_time")
  5568. end_time_str := c.GetString("end_time")
  5569. timeLayout := "2006-01-02"
  5570. loc, _ := time.LoadLocation("Local")
  5571. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5572. if err != nil {
  5573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5574. return
  5575. }
  5576. recordStartTime := theStartTime.Unix()
  5577. start_time = recordStartTime
  5578. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5579. if err != nil {
  5580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5581. return
  5582. }
  5583. recordEndTime := theEndTime.Unix()
  5584. end_time = recordEndTime
  5585. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5586. data["pre"] = prescriptions
  5587. }
  5588. client := &http.Client{}
  5589. data["psn_no"] = his.PsnNo
  5590. data["mdtrt_id"] = his.Number
  5591. data["chrg_bchno"] = chrg_bchno
  5592. data["org_name"] = miConfig.OrgName
  5593. data["doctor"] = roles.UserName
  5594. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5595. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5596. data["fixmedins_code"] = miConfig.Code
  5597. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5598. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5599. data["dept_code"] = "15"
  5600. } else {
  5601. data["dept_code"] = department.Number
  5602. }
  5603. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5604. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5605. data["secret_key"] = miConfig.SecretKey
  5606. data["url"] = miConfig.Url
  5607. data["ak"] = miConfig.AccessKey
  5608. data["new_doctor_name"] = patientPrescription.Doctor
  5609. data["diag_code"] = sickConfig.CountryCode
  5610. data["time_stamp"] = time_stamp
  5611. data["cainfo"] = miConfig.Cainfo
  5612. var ids []int64
  5613. for _, item := range prescriptions {
  5614. ids = append(ids, item.ID)
  5615. }
  5616. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5617. if config.IsOpen == 1 { //对接了医保,走医保流程
  5618. var res ResultFour
  5619. var resFour10265 ResultFour10265
  5620. if miConfig.MdtrtareaAdmvs == "421300" {
  5621. bytesData, _ := json.Marshal(data)
  5622. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5623. resp, _ := client.Do(req)
  5624. defer resp.Body.Close()
  5625. body, ioErr := ioutil.ReadAll(resp.Body)
  5626. if ioErr != nil {
  5627. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5629. return
  5630. }
  5631. var respJSON map[string]interface{}
  5632. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5633. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5635. return
  5636. }
  5637. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5638. userJSONBytes, _ := json.Marshal(respJSON)
  5639. fmt.Println("log")
  5640. fmt.Println(string(userJSONBytes))
  5641. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5642. utils.ErrorLog("解析失败:%v", err)
  5643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5644. return
  5645. }
  5646. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5647. bytesData, _ := json.Marshal(data)
  5648. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5649. resp, _ := client.Do(req)
  5650. defer resp.Body.Close()
  5651. body, ioErr := ioutil.ReadAll(resp.Body)
  5652. if ioErr != nil {
  5653. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5655. return
  5656. }
  5657. var respJSON map[string]interface{}
  5658. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5659. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5661. return
  5662. }
  5663. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5664. userJSONBytes, _ := json.Marshal(respJSON)
  5665. fmt.Println("log")
  5666. fmt.Println(string(userJSONBytes))
  5667. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5668. utils.ErrorLog("解析失败:%v", err)
  5669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5670. return
  5671. }
  5672. res.InfRefmsgid = resFour10265.InfRefmsgid
  5673. res.Output = resFour10265.Output
  5674. res.ErrMsg = resFour10265.ErrMsg
  5675. res.Cainfo = resFour10265.Cainfo
  5676. res.WarnMsg = resFour10265.WarnMsg
  5677. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5678. res.Infcode = infocode
  5679. } else {
  5680. if miConfig.Code == "H15049901371" {
  5681. 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), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), patientPrescription.DoctorId, sickConfig.CountryCode)
  5682. var dat map[string]interface{}
  5683. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5684. fmt.Println(dat)
  5685. } else {
  5686. fmt.Println(err)
  5687. }
  5688. saveLog(result, request_log, "2204", "上传费用明细")
  5689. userJSONBytes, _ := json.Marshal(dat)
  5690. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5691. utils.ErrorLog("解析失败:%v", err)
  5692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5693. return
  5694. }
  5695. res.InfRefmsgid = resFour10265.InfRefmsgid
  5696. res.Output = resFour10265.Output
  5697. res.ErrMsg = resFour10265.ErrMsg
  5698. res.Cainfo = resFour10265.Cainfo
  5699. res.WarnMsg = resFour10265.WarnMsg
  5700. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5701. res.Infcode = infocode
  5702. } else {
  5703. 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), patientPrescription.DoctorId, sickConfig.CountryCode)
  5704. var dat map[string]interface{}
  5705. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5706. fmt.Println(dat)
  5707. } else {
  5708. fmt.Println(err)
  5709. }
  5710. saveLog(result, request_log, "2204", "上传费用明细")
  5711. userJSONBytes, _ := json.Marshal(dat)
  5712. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5713. utils.ErrorLog("解析失败:%v", err)
  5714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5715. return
  5716. }
  5717. }
  5718. }
  5719. if res.Infcode == 0 {
  5720. order := &models.HisOrder{
  5721. UserOrgId: adminUser.CurrentOrgId,
  5722. HisPatientId: his.ID,
  5723. PatientId: his.PatientId,
  5724. SettleAccountsDate: recordDateTime,
  5725. Ctime: time.Now().Unix(),
  5726. Mtime: time.Now().Unix(),
  5727. MdtrtId: his.Number,
  5728. PsnNo: his.PsnNo,
  5729. MedType: strconv.FormatInt(reg_type, 10),
  5730. Status: 1,
  5731. Number: chrg_bchno,
  5732. Infcode: res.Infcode,
  5733. WarnMsg: res.WarnMsg,
  5734. Cainfo: res.Cainfo,
  5735. ErrMsg: res.ErrMsg,
  5736. RespondTime: res.RefmsgTime,
  5737. InfRefmsgid: res.InfRefmsgid,
  5738. OrderStatus: 1,
  5739. IsMedicineInsurance: 1,
  5740. SettleType: settle_accounts_type,
  5741. SettleStartTime: start_time,
  5742. SettleEndTime: end_time,
  5743. Creator: roles.AdminUserId,
  5744. Modify: roles.AdminUserId,
  5745. PType: 2,
  5746. Diagnosis: diagnosis_id,
  5747. }
  5748. err = service.CreateOrder(order)
  5749. if err != nil {
  5750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5751. return
  5752. }
  5753. for _, item := range res.Output.Result {
  5754. temp := strings.Split(item.FeedetlSn, "-")
  5755. var advice_id int64 = 0
  5756. var project_id int64 = 0
  5757. var types int64 = 0
  5758. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5759. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5760. if temp[1] == "1" {
  5761. advice_id = id
  5762. project_id = 0
  5763. } else if temp[1] == "2" {
  5764. advice_id = 0
  5765. project_id = id
  5766. }
  5767. info := &models.HisOrderInfo{
  5768. OrderNumber: order.Number,
  5769. FeedetlSn: item.FeedetlSn,
  5770. UploadDate: time.Now().Unix(),
  5771. AdviceId: advice_id,
  5772. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5773. Cnt: item.Cnt,
  5774. Pric: float64(item.Pric),
  5775. PatientId: his.PatientId,
  5776. PricUplmtAmt: item.PricUplmtAmt,
  5777. SelfpayProp: item.SelfpayProp,
  5778. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5779. OverlmtAmt: item.OverlmtAmt,
  5780. PreselfpayAmt: item.PreselfpayAmt,
  5781. BasMednFlag: item.BasMednFlag,
  5782. MedChrgitmType: item.MedChrgitmType,
  5783. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5784. Status: 1,
  5785. Memo: item.Memo,
  5786. Mtime: time.Now().Unix(),
  5787. InscpScpAmt: item.InscpScpAmt,
  5788. DrtReimFlag: item.DrtReimFlag,
  5789. Ctime: time.Now().Unix(),
  5790. ListSpItemFlag: item.ListSpItemFlag,
  5791. ChldMedcFlag: item.ChldMedcFlag,
  5792. LmtUsedFlag: item.LmtUsedFlag,
  5793. ChrgitmLv: item.ChrgitmLv,
  5794. UserOrgId: adminUser.CurrentOrgId,
  5795. HisPatientId: his.ID,
  5796. OrderId: order.ID,
  5797. ProjectId: project_id,
  5798. Type: types,
  5799. }
  5800. service.CreateOrderInfo(info)
  5801. }
  5802. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5803. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5804. var total float64
  5805. for _, item := range prescriptions {
  5806. if item.Type == 1 { //药品
  5807. for _, subItem := range item.HisDoctorAdviceInfo {
  5808. total = total + (subItem.Price * subItem.PrescribingNumber)
  5809. }
  5810. }
  5811. if item.Type == 2 { //项目
  5812. for _, subItem := range item.HisPrescriptionProject {
  5813. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5814. total = total + (subItem.Price * cnt)
  5815. }
  5816. }
  5817. }
  5818. for _, item := range prescriptions {
  5819. for _, subItem := range item.HisAdditionalCharge {
  5820. total = total + (subItem.Price * float64(subItem.Count))
  5821. }
  5822. }
  5823. allTotal := fmt.Sprintf("%.4f", total)
  5824. if res.Infcode == 0 {
  5825. var rf []*ResultFive
  5826. json.Unmarshal([]byte(his.Iinfo), &rf)
  5827. chrg_bchno := chrg_bchno
  5828. cert_no := his.Certno
  5829. var insutypes []string
  5830. var insutype string
  5831. var is390 int = 0
  5832. var is310 int = 0
  5833. for _, item := range rf {
  5834. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5835. insutypes = append(insutypes, item.Insutype)
  5836. }
  5837. }
  5838. if len(insutypes) == 1 {
  5839. insutype = insutypes[0]
  5840. } else {
  5841. for _, i := range insutypes {
  5842. if i == "390" {
  5843. is390 = 1
  5844. }
  5845. if i == "310" {
  5846. is310 = 1
  5847. }
  5848. }
  5849. }
  5850. if is390 == 1 {
  5851. insutype = "390"
  5852. }
  5853. if is310 == 1 {
  5854. insutype = "310"
  5855. }
  5856. if len(insutypes) == 0 {
  5857. insutype = "310"
  5858. }
  5859. if len(insutypes) == 2 {
  5860. insutype = strconv.FormatInt(his.SocialType, 64)
  5861. }
  5862. //insutype = "390"
  5863. if his.IdCardType == 1 {
  5864. cert_no = his.MedicalInsuranceNumber
  5865. } else {
  5866. cert_no = his.Certno
  5867. }
  5868. var res ResultSeven
  5869. var resSeven10265 ResultSeven10265
  5870. if miConfig.MdtrtareaAdmvs == "421300" {
  5871. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5872. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5873. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5874. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5875. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5876. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5877. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  5878. resp, requestErr := http.Get(api)
  5879. if requestErr != nil {
  5880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5881. return
  5882. }
  5883. body, ioErr := ioutil.ReadAll(resp.Body)
  5884. if ioErr != nil {
  5885. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5887. return
  5888. }
  5889. var respJSON map[string]interface{}
  5890. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5891. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5893. return
  5894. }
  5895. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5896. result, _ := json.Marshal(respJSON)
  5897. fmt.Println("log")
  5898. fmt.Println(string(result))
  5899. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5900. utils.ErrorLog("解析失败:%v", err)
  5901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5902. return
  5903. }
  5904. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5905. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5906. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5907. bas := strings.Split(psn_info.CardInfo, "|")
  5908. if his.IdCardType == 1 {
  5909. cert_no = bas[2]
  5910. } else {
  5911. cert_no = bas[1]
  5912. }
  5913. //江苏地区国家医保医疗类别
  5914. //职工透析:医疗类别选特殊情况门诊9933
  5915. //居民血透门慢: 医疗类别选门诊慢病1402
  5916. //var med_type string
  5917. //if his.Insutype == "310" {
  5918. // if reg_type == 14 {
  5919. // med_type = "9933"
  5920. // } else if reg_type == 11 {
  5921. // med_type = "11"
  5922. //
  5923. // }
  5924. //} else if his.Insutype == "390" {
  5925. // if reg_type == 14 {
  5926. // med_type = "1402"
  5927. // } else if reg_type == 11 {
  5928. // med_type = "11"
  5929. // }
  5930. //}
  5931. api := "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5932. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5933. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5934. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5935. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5936. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5937. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5938. resp, requestErr := http.Get(api)
  5939. if requestErr != nil {
  5940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5941. return
  5942. }
  5943. body, ioErr := ioutil.ReadAll(resp.Body)
  5944. if ioErr != nil {
  5945. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5947. return
  5948. }
  5949. var respJSON map[string]interface{}
  5950. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5953. return
  5954. }
  5955. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5956. result, _ := json.Marshal(respJSON)
  5957. fmt.Println("log")
  5958. fmt.Println(string(result))
  5959. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5960. utils.ErrorLog("解析失败:%v", err)
  5961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5962. return
  5963. }
  5964. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5965. res.Output = resSeven10265.Output
  5966. res.ErrMsg = resSeven10265.ErrMsg
  5967. res.Cainfo = resSeven10265.Cainfo
  5968. res.WarnMsg = resSeven10265.WarnMsg
  5969. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5970. res.Infcode = infocode
  5971. } else {
  5972. var result string
  5973. var request_log string
  5974. if miConfig.Code == "H15049901371" {
  5975. //赤峰地区国家医保医疗类别
  5976. //职工透析:医疗类别选特殊情况门诊990502
  5977. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5978. var med_type string
  5979. if his.Insutype == "390" {
  5980. if reg_type == 14 {
  5981. med_type = "9933"
  5982. } else if reg_type == 11 {
  5983. med_type = "11"
  5984. }
  5985. } else if his.Insutype == "310" {
  5986. if reg_type == 14 {
  5987. med_type = "990502"
  5988. } else if reg_type == 11 {
  5989. med_type = "11"
  5990. }
  5991. }
  5992. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, 0, 0, 0, 0, his.IdType)
  5993. } else {
  5994. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType)
  5995. }
  5996. var dat map[string]interface{}
  5997. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5998. fmt.Println(dat)
  5999. } else {
  6000. fmt.Println(err)
  6001. }
  6002. saveLog(result, request_log, "2206", "预结算")
  6003. //userJSONBytes, _ := json.Marshal(dat)
  6004. //
  6005. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6006. // utils.ErrorLog("解析失败:%v", err)
  6007. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6008. // return
  6009. //}
  6010. userJSONBytes, _ := json.Marshal(dat)
  6011. if miConfig.Code == "H15049901371" {
  6012. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6013. utils.ErrorLog("解析失败:%v", err)
  6014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6015. return
  6016. }
  6017. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6018. res.Output = resSeven10265.Output
  6019. res.ErrMsg = resSeven10265.ErrMsg
  6020. res.Cainfo = resSeven10265.Cainfo
  6021. res.WarnMsg = resSeven10265.WarnMsg
  6022. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6023. res.Infcode = infocode
  6024. } else {
  6025. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6026. utils.ErrorLog("解析失败:%v", err)
  6027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6028. return
  6029. }
  6030. }
  6031. }
  6032. if res.Infcode != 0 {
  6033. errlog := &models.HisOrderError{
  6034. UserOrgId: adminUser.CurrentOrgId,
  6035. Ctime: time.Now().Unix(),
  6036. Mtime: time.Now().Unix(),
  6037. Number: chrg_bchno,
  6038. ErrMsg: res.ErrMsg,
  6039. Status: 1,
  6040. PatientId: id,
  6041. RecordTime: recordDateTime,
  6042. Stage: 20,
  6043. }
  6044. service.CreateErrMsgLog(errlog)
  6045. c.ServeSuccessJSON(map[string]interface{}{
  6046. "failed_code": -10,
  6047. "msg": res.ErrMsg,
  6048. })
  6049. return
  6050. } else {
  6051. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6052. order.OrderStatus = 1
  6053. order.IsPre = 1
  6054. order.Status = 1
  6055. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6056. order.SetlId = res.Output.Setlinfo.SetlID
  6057. order.PsnNo = res.Output.Setlinfo.PsnNo
  6058. order.PsnName = res.Output.Setlinfo.PsnName
  6059. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6060. order.Certno = res.Output.Setlinfo.Certno
  6061. order.Gend = res.Output.Setlinfo.Gend
  6062. order.Naty = res.Output.Setlinfo.Naty
  6063. order.Age = res.Output.Setlinfo.Age
  6064. order.Insutype = res.Output.Setlinfo.Insutype
  6065. order.PsnType = res.Output.Setlinfo.PsnType
  6066. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6067. order.SetlTime = res.Output.Setlinfo.SetlTime
  6068. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6069. if res.Output.Setlinfo.MedType == "140101" {
  6070. order.MedType = "14"
  6071. } else {
  6072. order.MedType = res.Output.Setlinfo.MedType
  6073. }
  6074. if reg_type == 1112 {
  6075. order.MedType = "1112"
  6076. }
  6077. if reg_type == 1111 {
  6078. order.MedType = "1111"
  6079. }
  6080. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6081. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6082. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6083. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6084. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6085. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6086. order.HifpPay = res.Output.Setlinfo.HifpPay
  6087. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6088. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6089. order.HifesPay = res.Output.Setlinfo.HifesPay
  6090. order.HifobPay = res.Output.Setlinfo.HifobPay
  6091. order.MafPay = res.Output.Setlinfo.MafPay
  6092. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6093. order.OthPay = res.Output.Setlinfo.OthPay
  6094. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6095. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6096. order.AcctPay = res.Output.Setlinfo.AcctPay
  6097. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6098. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6099. order.Balc = res.Output.Setlinfo.Balc
  6100. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6101. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6102. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6103. order.ClrWay = res.Output.Setlinfo.ClrWay
  6104. order.Creator = order.Creator
  6105. order.Modify = roles.AdminUserId
  6106. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6107. detailStr := string(setlDetail)
  6108. order.SetlDetail = detailStr
  6109. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6110. err = service.UpDateOrder(order)
  6111. if err == nil {
  6112. c.ServeSuccessJSON(map[string]interface{}{
  6113. "msg": "预结算成功",
  6114. })
  6115. } else {
  6116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6117. return
  6118. }
  6119. }
  6120. } else {
  6121. adminUser := c.GetAdminUserInfo()
  6122. errlog := &models.HisOrderError{
  6123. UserOrgId: adminUser.CurrentOrgId,
  6124. Ctime: time.Now().Unix(),
  6125. Mtime: time.Now().Unix(),
  6126. ErrMsg: res.ErrMsg,
  6127. Status: 1,
  6128. PatientId: id,
  6129. RecordTime: recordDateTime,
  6130. Stage: 4,
  6131. }
  6132. service.CreateErrMsgLog(errlog)
  6133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6134. return
  6135. }
  6136. } else {
  6137. adminUser := c.GetAdminUserInfo()
  6138. errlog := &models.HisOrderError{
  6139. UserOrgId: adminUser.CurrentOrgId,
  6140. Ctime: time.Now().Unix(),
  6141. Mtime: time.Now().Unix(),
  6142. ErrMsg: res.ErrMsg,
  6143. Status: 1,
  6144. PatientId: id,
  6145. RecordTime: recordDateTime,
  6146. Stage: 4,
  6147. }
  6148. service.CreateErrMsgLog(errlog)
  6149. c.ServeSuccessJSON(map[string]interface{}{
  6150. "failed_code": -10,
  6151. "msg": res.ErrMsg,
  6152. })
  6153. return
  6154. }
  6155. }
  6156. }
  6157. }
  6158. //func (c *HisApiController) GetSettleInfo() {
  6159. // id, _ := c.GetInt64("id")
  6160. // order_id, _ := c.GetInt64("order_id")
  6161. //
  6162. // record_time := c.GetString("record_time")
  6163. // pay_way, _ := c.GetInt64("pay_way")
  6164. // pay_price, _ := c.GetFloat("pay_price")
  6165. // pay_card_no := c.GetString("pay_card_no")
  6166. // discount_price, _ := c.GetFloat("discount_price")
  6167. // preferential_price, _ := c.GetFloat("preferential_price")
  6168. // reality_price, _ := c.GetFloat("reality_price")
  6169. // found_price, _ := c.GetFloat("found_price")
  6170. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  6171. // private_price, _ := c.GetFloat("private_price")
  6172. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6173. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6174. //
  6175. // timeLayout := "2006-01-02"
  6176. // loc, _ := time.LoadLocation("Local")
  6177. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6178. // if err != nil {
  6179. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6180. // return
  6181. // }
  6182. // recordDateTime := theTime.Unix()
  6183. // adminUser := c.GetAdminUserInfo()
  6184. //
  6185. // var prescriptions []*models.HisPrescription
  6186. //
  6187. // data := make(map[string]interface{})
  6188. // if settle_accounts_type == 1 { //日结
  6189. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6190. // data["pre"] = prescriptions
  6191. //
  6192. // } else { //月结
  6193. // start_time_str := c.GetString("start_time")
  6194. // end_time_str := c.GetString("end_time")
  6195. // timeLayout := "2006-01-02"
  6196. // loc, _ := time.LoadLocation("Local")
  6197. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6198. // if err != nil {
  6199. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6200. // return
  6201. // }
  6202. // recordStartTime := theStartTime.Unix()
  6203. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6204. // if err != nil {
  6205. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6206. // return
  6207. // }
  6208. // recordEndTime := theEndTime.Unix()
  6209. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6210. // data["pre"] = prescriptions
  6211. //
  6212. // }
  6213. //
  6214. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6215. //
  6216. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6217. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6218. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6219. // strconv.FormatInt(his.PatientId, 10)
  6220. //
  6221. // order_src, _ := service.GetHisOrderByID(order_id)
  6222. //
  6223. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6224. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6225. //
  6226. // var total float64
  6227. // for _, item := range prescriptions {
  6228. // if item.Type == 1 { //药品
  6229. // for _, subItem := range item.HisDoctorAdviceInfo {
  6230. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6231. // }
  6232. // }
  6233. // if item.Type == 2 { //项目
  6234. // for _, subItem := range item.HisPrescriptionProject {
  6235. // total = total + (subItem.Price * float64(subItem.Count))
  6236. // }
  6237. // }
  6238. // }
  6239. //
  6240. // for _, item := range prescriptions {
  6241. // for _, subItem := range item.HisAdditionalCharge {
  6242. // total = total + (subItem.Price * float64(subItem.Count))
  6243. // }
  6244. // }
  6245. //
  6246. // allTotal := fmt.Sprintf("%.2f", total)
  6247. // var rf []*ResultFive
  6248. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6249. // psn_no := order_src.PsnNo
  6250. // mdtrt_id := order_src.MdtrtId
  6251. // chrg_bchno := order_src.Number
  6252. // cert_no := order_src.Certno
  6253. // insutype := rf[0].Insutype
  6254. //
  6255. // if his.IdCardType == 1 {
  6256. // cert_no = his.MedicalInsuranceNumber
  6257. // } else {
  6258. // cert_no = his.Certno
  6259. // }
  6260. //
  6261. // 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)
  6262. // var dat map[string]interface{}
  6263. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6264. // fmt.Println(dat)
  6265. // } else {
  6266. // fmt.Println(err)
  6267. // }
  6268. //
  6269. // userJSONBytes, _ := json.Marshal(dat)
  6270. //
  6271. //
  6272. //
  6273. // var res ResultSeven
  6274. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6275. // utils.ErrorLog("解析失败:%v", err)
  6276. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6277. // return
  6278. // }
  6279. // if res.Infcode == -1 {
  6280. // errlog := &models.HisOrderError{
  6281. // UserOrgId: adminUser.CurrentOrgId,
  6282. // Ctime: time.Now().Unix(),
  6283. // Mtime: time.Now().Unix(),
  6284. // Number: chrg_bchno,
  6285. // ErrMsg: res.ErrMsg,
  6286. // Status: 1,
  6287. // PatientId: id,
  6288. // RecordTime: recordDateTime,
  6289. // Stage: 6,
  6290. // }
  6291. // service.CreateErrMsgLog(errlog)
  6292. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6293. // return
  6294. // } else {
  6295. // order_src.OrderStatus = 2
  6296. // order_src.PayWay = pay_way
  6297. // order_src.PayPrice = pay_price
  6298. // order_src.PayCardNo = pay_card_no
  6299. // order_src.DiscountPrice = discount_price
  6300. // order_src.PreferentialPrice = preferential_price
  6301. // order_src.RealityPrice = reality_price
  6302. // order_src.FoundPrice = found_price
  6303. // order_src.MedicalInsurancePrice = medical_insurance_price
  6304. // order_src.PrivatePrice = private_price
  6305. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  6306. // order_src.SetlId = res.Output.Setlinfo.SetlID
  6307. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  6308. // order_src.PsnName = res.Output.Setlinfo.PsnName
  6309. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  6310. // order_src.Certno = res.Output.Setlinfo.Certno
  6311. // order_src.Gend = res.Output.Setlinfo.Gend
  6312. // order_src.Naty = res.Output.Setlinfo.Naty
  6313. // order_src.Age = res.Output.Setlinfo.Age
  6314. // order_src.Insutype = res.Output.Setlinfo.Insutype
  6315. // order_src.PsnType = res.Output.Setlinfo.PsnType
  6316. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6317. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  6318. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6319. // order_src.MedType = res.Output.Setlinfo.MedType
  6320. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6321. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6322. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6323. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6324. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6325. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6326. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  6327. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  6328. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6329. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  6330. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  6331. // order_src.MafPay = res.Output.Setlinfo.MafPay
  6332. // order_src.OthPay = res.Output.Setlinfo.OthPay
  6333. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6334. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6335. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  6336. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6337. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6338. // order_src.Balc = res.Output.Setlinfo.Balc
  6339. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6340. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6341. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  6342. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  6343. // order_src.Creator = order_src.Creator
  6344. // order_src.Modify = roles.ID
  6345. // order_src.RequestLog = src_resquest
  6346. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6347. // detailStr := string(setlDetail)
  6348. // order_src.SetlDetail = detailStr
  6349. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6350. // err = service.UpDateOrder(order_src)
  6351. //
  6352. // if err == nil {
  6353. // c.ServeSuccessJSON(map[string]interface{}{
  6354. // "msg": "结算成功",
  6355. // })
  6356. // } else {
  6357. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6358. // return
  6359. // }
  6360. // }
  6361. // }
  6362. //}
  6363. //退款
  6364. func (c *HisApiController) Refund() {
  6365. order_id, _ := c.GetInt64("order_id")
  6366. admin_user_id, _ := c.GetInt64("admin_user_id")
  6367. adminUser := c.GetAdminUserInfo()
  6368. var order models.HisOrder
  6369. order, _ = service.GetHisOrderByID(order_id)
  6370. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6371. if order.ID == 0 {
  6372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6373. return
  6374. }
  6375. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6376. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6377. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6378. if config.IsOpen == 1 { //对接了医保,走医保流程
  6379. var res ResultSixteen
  6380. var resSixteen10265 ResultSixteen10265
  6381. var src_resquest string
  6382. var result string
  6383. if miConfig.MdtrtareaAdmvs == "421300" {
  6384. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  6385. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6386. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6387. resp3, requestErr3 := http.Get(api3)
  6388. if requestErr3 != nil {
  6389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6390. return
  6391. }
  6392. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6393. if ioErr3 != nil {
  6394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6396. return
  6397. }
  6398. var respJSON3 map[string]interface{}
  6399. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6402. return
  6403. }
  6404. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6405. userJSONBytes3, _ := json.Marshal(respJSON3)
  6406. fmt.Println("log")
  6407. fmt.Println(string(userJSONBytes3))
  6408. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  6409. utils.ErrorLog("解析失败:%v", err)
  6410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6411. return
  6412. }
  6413. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6414. api3 := "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6415. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6416. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6417. resp3, requestErr3 := http.Get(api3)
  6418. if requestErr3 != nil {
  6419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6420. return
  6421. }
  6422. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6423. if ioErr3 != nil {
  6424. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6426. return
  6427. }
  6428. var respJSON3 map[string]interface{}
  6429. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6430. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6432. return
  6433. }
  6434. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6435. userJSONBytes3, _ := json.Marshal(respJSON3)
  6436. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  6437. utils.ErrorLog("解析失败:%v", err)
  6438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6439. return
  6440. }
  6441. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6442. res.Output = resSixteen10265.Output
  6443. res.ErrMsg = resSixteen10265.ErrMsg
  6444. res.Cainfo = resSixteen10265.Cainfo
  6445. res.WarnMsg = resSixteen10265.WarnMsg
  6446. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6447. res.Infcode = infocode
  6448. } else {
  6449. if miConfig.Code == "H15049901371" {
  6450. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6451. var dat map[string]interface{}
  6452. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6453. fmt.Println(dat)
  6454. } else {
  6455. fmt.Println(err)
  6456. }
  6457. saveLog(result, src_resquest, "2208", "退费")
  6458. userJSONBytes, _ := json.Marshal(dat)
  6459. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  6460. utils.ErrorLog("解析失败:%v", err)
  6461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6462. return
  6463. }
  6464. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6465. res.Output = resSixteen10265.Output
  6466. res.ErrMsg = resSixteen10265.ErrMsg
  6467. res.Cainfo = resSixteen10265.Cainfo
  6468. res.WarnMsg = resSixteen10265.WarnMsg
  6469. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6470. res.Infcode = infocode
  6471. } else {
  6472. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6473. var dat map[string]interface{}
  6474. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6475. fmt.Println(dat)
  6476. } else {
  6477. fmt.Println(err)
  6478. }
  6479. saveLog(result, src_resquest, "2208", "退费")
  6480. userJSONBytes, _ := json.Marshal(dat)
  6481. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6482. utils.ErrorLog("解析失败:%v", err)
  6483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6484. return
  6485. }
  6486. }
  6487. }
  6488. if res.Infcode == 0 {
  6489. var res2 ResultSix
  6490. var resSix10265 ResultSix10265
  6491. if miConfig.MdtrtareaAdmvs == "421300" {
  6492. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6493. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6494. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6495. resp3, requestErr3 := http.Get(api3)
  6496. if requestErr3 != nil {
  6497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6498. return
  6499. }
  6500. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6501. if ioErr3 != nil {
  6502. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6504. return
  6505. }
  6506. var respJSON3 map[string]interface{}
  6507. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6508. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6510. return
  6511. }
  6512. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6513. userJSONBytes3, _ := json.Marshal(respJSON3)
  6514. fmt.Println("log")
  6515. fmt.Println(string(userJSONBytes3))
  6516. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6517. utils.ErrorLog("解析失败:%v", err)
  6518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6519. return
  6520. }
  6521. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6522. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6523. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6524. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6525. resp3, requestErr3 := http.Get(api3)
  6526. if requestErr3 != nil {
  6527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6528. return
  6529. }
  6530. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6531. if ioErr3 != nil {
  6532. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6534. return
  6535. }
  6536. var respJSON3 map[string]interface{}
  6537. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6538. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6540. return
  6541. }
  6542. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6543. userJSONBytes3, _ := json.Marshal(respJSON3)
  6544. fmt.Println("log")
  6545. fmt.Println(string(userJSONBytes3))
  6546. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6547. utils.ErrorLog("解析失败:%v", err)
  6548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6549. return
  6550. }
  6551. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6552. res2.Output = resSix10265.Output
  6553. res2.ErrMsg = resSix10265.ErrMsg
  6554. res2.Cainfo = resSix10265.Cainfo
  6555. res2.WarnMsg = resSix10265.WarnMsg
  6556. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6557. res2.Infcode = infocode
  6558. } else {
  6559. if miConfig.Code == "H15049901371" {
  6560. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6561. var dat map[string]interface{}
  6562. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6563. fmt.Println(dat)
  6564. } else {
  6565. fmt.Println(err)
  6566. }
  6567. saveLog(result2, src_request, "2205", "撤销明细")
  6568. userJSONBytes, _ := json.Marshal(dat)
  6569. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6570. utils.ErrorLog("解析失败:%v", err)
  6571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6572. return
  6573. }
  6574. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6575. res2.Output = resSix10265.Output
  6576. res2.ErrMsg = resSix10265.ErrMsg
  6577. res2.Cainfo = resSix10265.Cainfo
  6578. res2.WarnMsg = resSix10265.WarnMsg
  6579. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6580. res2.Infcode = infocode
  6581. } else {
  6582. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6583. var dat map[string]interface{}
  6584. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6585. fmt.Println(dat)
  6586. } else {
  6587. fmt.Println(err)
  6588. }
  6589. saveLog(result2, src_request, "2205", "撤销明细")
  6590. userJSONBytes, _ := json.Marshal(dat)
  6591. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6592. utils.ErrorLog("解析失败:%v", err)
  6593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6594. return
  6595. }
  6596. }
  6597. }
  6598. if res2.Infcode == 0 {
  6599. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  6600. if err == nil {
  6601. c.ServeSuccessJSON(map[string]interface{}{
  6602. "msg": "退费成功",
  6603. })
  6604. } else {
  6605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6606. return
  6607. }
  6608. } else {
  6609. c.ServeSuccessJSON(map[string]interface{}{
  6610. "code": -10,
  6611. "msg": res2.ErrMsg,
  6612. })
  6613. }
  6614. } else {
  6615. c.ServeSuccessJSON(map[string]interface{}{
  6616. "code": -10,
  6617. "msg": res.ErrMsg,
  6618. })
  6619. }
  6620. }
  6621. }
  6622. func (c *HisApiController) RefundNumber() {
  6623. record_time := c.GetString("record_time")
  6624. //patient_id, _ := c.GetInt64("patient_id")
  6625. admin_user_id, _ := c.GetInt64("admin_user_id")
  6626. his_patient_id, _ := c.GetInt64("id")
  6627. timeLayout := "2006-01-02"
  6628. loc, _ := time.LoadLocation("Local")
  6629. adminUser := c.GetAdminUserInfo()
  6630. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6631. fmt.Println(err)
  6632. if err != nil {
  6633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6634. return
  6635. }
  6636. recordDateTime := theTime.Unix()
  6637. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6638. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  6639. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6640. //order, _ := service.GetHisOrderByID(order_id)
  6641. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6642. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6643. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6644. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  6645. if count > 0 {
  6646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  6647. return
  6648. }
  6649. if config.IsOpen == 1 { //对接了医保,走医保流程
  6650. var res2 ResultSix
  6651. var resSix10265 ResultSix10265
  6652. if miConfig.MdtrtareaAdmvs == "421300" {
  6653. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  6654. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6655. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6656. resp3, requestErr3 := http.Get(api3)
  6657. if requestErr3 != nil {
  6658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6659. return
  6660. }
  6661. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6662. if ioErr3 != nil {
  6663. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6665. return
  6666. }
  6667. var respJSON3 map[string]interface{}
  6668. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6671. return
  6672. }
  6673. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6674. userJSONBytes3, _ := json.Marshal(respJSON3)
  6675. fmt.Println("log")
  6676. fmt.Println(string(userJSONBytes3))
  6677. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6678. utils.ErrorLog("解析失败:%v", err)
  6679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6680. return
  6681. }
  6682. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6683. api3 := "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  6684. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6685. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6686. resp3, requestErr3 := http.Get(api3)
  6687. if requestErr3 != nil {
  6688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6689. return
  6690. }
  6691. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6692. if ioErr3 != nil {
  6693. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6695. return
  6696. }
  6697. var respJSON3 map[string]interface{}
  6698. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6699. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6701. return
  6702. }
  6703. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6704. userJSONBytes3, _ := json.Marshal(respJSON3)
  6705. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6706. utils.ErrorLog("解析失败:%v", err)
  6707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6708. return
  6709. }
  6710. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6711. res2.Output = resSix10265.Output
  6712. res2.ErrMsg = resSix10265.ErrMsg
  6713. res2.Cainfo = resSix10265.Cainfo
  6714. res2.WarnMsg = resSix10265.WarnMsg
  6715. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6716. res2.Infcode = infocode
  6717. } else {
  6718. var api3 string
  6719. if miConfig.Code == "H15049901371" {
  6720. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6721. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6722. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6723. } else {
  6724. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6725. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6726. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6727. }
  6728. resp3, requestErr3 := http.Get(api3)
  6729. if requestErr3 != nil {
  6730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6731. return
  6732. }
  6733. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6734. if ioErr3 != nil {
  6735. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6737. return
  6738. }
  6739. var respJSON3 map[string]interface{}
  6740. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6743. return
  6744. }
  6745. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6746. userJSONBytes3, _ := json.Marshal(respJSON3)
  6747. if miConfig.Code == "H15049901371" {
  6748. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6749. utils.ErrorLog("解析失败:%v", err)
  6750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6751. return
  6752. }
  6753. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6754. res2.Output = resSix10265.Output
  6755. res2.ErrMsg = resSix10265.ErrMsg
  6756. res2.Cainfo = resSix10265.Cainfo
  6757. res2.WarnMsg = resSix10265.WarnMsg
  6758. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6759. res2.Infcode = infocode
  6760. } else {
  6761. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6762. utils.ErrorLog("解析失败:%v", err)
  6763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6764. return
  6765. }
  6766. }
  6767. }
  6768. if res2.Infcode == 0 {
  6769. if err == nil {
  6770. c.ServeSuccessJSON(map[string]interface{}{
  6771. "msg": "退号成功",
  6772. })
  6773. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  6774. } else {
  6775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6776. return
  6777. }
  6778. } else {
  6779. c.ServeSuccessJSON(map[string]interface{}{
  6780. "code": -10,
  6781. "msg": res2.ErrMsg,
  6782. })
  6783. }
  6784. } else {
  6785. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  6786. //if err == nil {
  6787. // c.ServeSuccessJSON(map[string]interface{}{
  6788. // "msg": "退费成功",
  6789. // })
  6790. //} else {
  6791. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6792. // return
  6793. //}
  6794. }
  6795. }
  6796. func (c *HisApiController) RefundDetail() {
  6797. order_id, _ := c.GetInt64("order_id")
  6798. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6799. //his_patient_id, _ := c.GetInt64("his_patient_id")
  6800. number := c.GetString("number")
  6801. record_time := c.GetString("record_time")
  6802. patient_id, _ := c.GetInt64("patient_id")
  6803. timeLayout := "2006-01-02"
  6804. loc, _ := time.LoadLocation("Local")
  6805. adminUser := c.GetAdminUserInfo()
  6806. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6807. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6808. fmt.Println(err)
  6809. if err != nil {
  6810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6811. return
  6812. }
  6813. recordDateTime := theTime.Unix()
  6814. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6815. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6816. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6817. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6818. var order models.HisOrder
  6819. order, _ = service.GetHisOrderByID(order_id)
  6820. if order.ID == 0 {
  6821. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  6822. }
  6823. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6824. if config.IsOpen == 1 { //对接了医保,走医保流程
  6825. var res2 ResultSix
  6826. if miConfig.MdtrtareaAdmvs == "421300" {
  6827. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6828. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6829. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6830. resp3, requestErr3 := http.Get(api3)
  6831. if requestErr3 != nil {
  6832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6833. return
  6834. }
  6835. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6836. if ioErr3 != nil {
  6837. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6839. return
  6840. }
  6841. var respJSON3 map[string]interface{}
  6842. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6843. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6845. return
  6846. }
  6847. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6848. userJSONBytes3, _ := json.Marshal(respJSON3)
  6849. fmt.Println("log")
  6850. fmt.Println(string(userJSONBytes3))
  6851. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6852. utils.ErrorLog("解析失败:%v", err)
  6853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6854. return
  6855. }
  6856. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6857. if err == nil {
  6858. c.ServeSuccessJSON(map[string]interface{}{
  6859. "msg": "撤销明细成功",
  6860. })
  6861. return
  6862. } else {
  6863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6864. return
  6865. }
  6866. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6867. var resSix10265 ResultSix10265
  6868. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6869. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6870. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6871. resp3, requestErr3 := http.Get(api3)
  6872. if requestErr3 != nil {
  6873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6874. return
  6875. }
  6876. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6877. if ioErr3 != nil {
  6878. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6880. return
  6881. }
  6882. var respJSON3 map[string]interface{}
  6883. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6884. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6886. return
  6887. }
  6888. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6889. userJSONBytes3, _ := json.Marshal(respJSON3)
  6890. fmt.Println("log")
  6891. fmt.Println(string(userJSONBytes3))
  6892. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6893. utils.ErrorLog("解析失败:%v", err)
  6894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6895. return
  6896. }
  6897. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6898. res2.Output = resSix10265.Output
  6899. res2.ErrMsg = resSix10265.ErrMsg
  6900. res2.Cainfo = resSix10265.Cainfo
  6901. res2.WarnMsg = resSix10265.WarnMsg
  6902. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6903. res2.Infcode = infocode
  6904. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6905. if err == nil {
  6906. c.ServeSuccessJSON(map[string]interface{}{
  6907. "msg": "撤销明细成功",
  6908. })
  6909. return
  6910. } else {
  6911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6912. return
  6913. }
  6914. } else {
  6915. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  6916. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6917. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6918. resp2, requestErr2 := http.Get(api2)
  6919. if requestErr2 != nil {
  6920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6921. return
  6922. }
  6923. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6924. if ioErr2 != nil {
  6925. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6927. return
  6928. }
  6929. var respJSON2 map[string]interface{}
  6930. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  6931. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6933. return
  6934. }
  6935. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6936. if err == nil {
  6937. c.ServeSuccessJSON(map[string]interface{}{
  6938. "msg": "撤销明细成功",
  6939. })
  6940. return
  6941. } else {
  6942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6943. return
  6944. }
  6945. }
  6946. } else {
  6947. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6948. if err == nil {
  6949. c.ServeSuccessJSON(map[string]interface{}{
  6950. "msg": "退费成功",
  6951. })
  6952. } else {
  6953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6954. return
  6955. }
  6956. }
  6957. }
  6958. //对账
  6959. func (c *HisApiController) GetCheckAccount() {
  6960. start_time := c.GetString("start_time")
  6961. end_time := c.GetString("end_time")
  6962. insutype := c.GetString("insutype")
  6963. clr_type := c.GetString("clr_type")
  6964. clr_org := c.GetString("clr_optins")
  6965. admin_user_id, _ := c.GetInt64("admin_user_id")
  6966. adminUser := c.GetAdminUserInfo()
  6967. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6968. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6969. if len(clr_org) == 0 {
  6970. clr_org = miConfig.MdtrtareaAdmvs
  6971. }
  6972. timeLayout := "2006-01-02"
  6973. loc, _ := time.LoadLocation("Local")
  6974. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  6975. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  6976. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  6977. fixmedins_setl_cnt := int64(len(orders))
  6978. var medfee_sumamt float64
  6979. var acct_pay float64
  6980. var fund_pay_sumamt float64
  6981. for _, item := range orders {
  6982. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  6983. acct_pay = acct_pay + item.AcctPay
  6984. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  6985. }
  6986. var user_name string
  6987. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6988. if role.ID == 0 {
  6989. user_name = "xxx"
  6990. } else {
  6991. user_name = role.UserName
  6992. }
  6993. var res ResultEight
  6994. var res10188 ResultEightFor10188
  6995. if config.IsOpen == 1 {
  6996. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6997. api := "http://192.168.3.111:9532/" + "jsyb/3201" +
  6998. "insutype=" + insutype +
  6999. "&clr_type=" + clr_type +
  7000. "&setl_optins=" + clr_org +
  7001. "&stmt_begndate=" + start_time +
  7002. "&stm_enddate=" + end_time +
  7003. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7004. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7005. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7006. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7007. "&fixmedins_code=" + miConfig.Code +
  7008. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7009. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7010. "&secret_key=" + miConfig.SecretKey +
  7011. "&org_name=" + miConfig.OrgName +
  7012. "&doctor=" + user_name +
  7013. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7014. fmt.Println(api)
  7015. resp, requestErr := http.Get(api)
  7016. if requestErr != nil {
  7017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7018. return
  7019. }
  7020. body, ioErr := ioutil.ReadAll(resp.Body)
  7021. fmt.Println(body)
  7022. if ioErr != nil {
  7023. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7025. return
  7026. }
  7027. var respJSON map[string]interface{}
  7028. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7029. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7031. return
  7032. }
  7033. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7034. userJSONBytes, _ := json.Marshal(respJSON)
  7035. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7036. utils.ErrorLog("解析失败:%v", err)
  7037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7038. return
  7039. }
  7040. res.InfRefmsgid = res10188.InfRefmsgid
  7041. res.Output = res10188.Output
  7042. res.ErrMsg = res10188.ErrMsg
  7043. res.Cainfo = res10188.Cainfo
  7044. res.WarnMsg = res10188.WarnMsg
  7045. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  7046. res.Infcode = infocode
  7047. } else {
  7048. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7049. "insutype=" + insutype +
  7050. "&clr_type=" + clr_type +
  7051. "&setl_optins=" + clr_org +
  7052. "&stmt_begndate=" + start_time +
  7053. "&stm_enddate=" + end_time +
  7054. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7055. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7056. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7057. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7058. "&fixmedins_code=" + miConfig.Code +
  7059. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7060. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7061. "&secret_key=" + miConfig.SecretKey +
  7062. "&org_name=" + miConfig.OrgName +
  7063. "&doctor=" + user_name
  7064. fmt.Println(api)
  7065. resp, requestErr := http.Get(api)
  7066. if requestErr != nil {
  7067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7068. return
  7069. }
  7070. body, ioErr := ioutil.ReadAll(resp.Body)
  7071. fmt.Println(body)
  7072. if ioErr != nil {
  7073. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7075. return
  7076. }
  7077. var respJSON map[string]interface{}
  7078. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7081. return
  7082. }
  7083. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7084. userJSONBytes, _ := json.Marshal(respJSON)
  7085. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7086. utils.ErrorLog("解析失败:%v", err)
  7087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7088. return
  7089. }
  7090. }
  7091. if res.Infcode == 0 {
  7092. if res.Output.Stmtinfo.StmtRslt == "0" {
  7093. micc := &models.MedicalInsuranceCostCompare{
  7094. StartTime: startime.Unix(),
  7095. EndTime: endtime.Unix(),
  7096. Insutype: insutype,
  7097. CheckType: 1,
  7098. Num: fixmedins_setl_cnt,
  7099. Mtime: time.Now().Unix(),
  7100. Status: 1,
  7101. UserOrgId: adminUser.CurrentOrgId,
  7102. CostTotal: medfee_sumamt,
  7103. FuncTotal: fund_pay_sumamt,
  7104. PsnPay: acct_pay,
  7105. Creator: admin_user_id,
  7106. Ctime: time.Now().Unix(),
  7107. }
  7108. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  7109. if err == nil {
  7110. c.ServeSuccessJSON(map[string]interface{}{
  7111. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7112. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7113. })
  7114. } else {
  7115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7116. }
  7117. } else {
  7118. c.ServeSuccessJSON(map[string]interface{}{
  7119. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7120. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7121. })
  7122. }
  7123. } else {
  7124. c.ServeSuccessJSON(map[string]interface{}{
  7125. "code": -10,
  7126. "msg": res.ErrMsg,
  7127. })
  7128. }
  7129. }
  7130. }
  7131. func (c *HisApiController) Check310() {
  7132. adminUser := c.GetAdminUserInfo()
  7133. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7134. var user_name string
  7135. user_name = "高慧裕"
  7136. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7137. "insutype=" + "310" +
  7138. "&clr_type=" + "11" +
  7139. "&setl_optins=" + "441202" +
  7140. "&stmt_begndate=" + "2022-03-01" +
  7141. "&stm_enddate=" + "2022-03-31" +
  7142. "&medfee_sumamt=" + "194930.12" +
  7143. "&fund_pay_sumamt=" + "188741.46" +
  7144. "&acct_pay=" + "0" +
  7145. "&fixmedins_setl_cnt=" + "452" +
  7146. "&fixmedins_code=" + miConfig.Code +
  7147. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7148. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7149. "&secret_key=" + miConfig.SecretKey +
  7150. "&org_name=" + miConfig.OrgName +
  7151. "&doctor=" + user_name
  7152. fmt.Println(api)
  7153. resp, requestErr := http.Get(api)
  7154. if requestErr != nil {
  7155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7156. return
  7157. }
  7158. body, ioErr := ioutil.ReadAll(resp.Body)
  7159. fmt.Println(body)
  7160. if ioErr != nil {
  7161. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7163. return
  7164. }
  7165. var respJSON map[string]interface{}
  7166. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7167. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7169. return
  7170. }
  7171. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7172. userJSONBytes, _ := json.Marshal(respJSON)
  7173. var res ResultEight
  7174. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7175. utils.ErrorLog("解析失败:%v", err)
  7176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7177. return
  7178. }
  7179. }
  7180. func (c *HisApiController) Check390() {
  7181. adminUser := c.GetAdminUserInfo()
  7182. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7183. var user_name string
  7184. user_name = "高慧裕"
  7185. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7186. "insutype=" + "390" +
  7187. "&clr_type=" + "11" +
  7188. "&setl_optins=" + "441202" +
  7189. "&stmt_begndate=" + "2022-03-01" +
  7190. "&stm_enddate=" + "2022-03-31" +
  7191. "&medfee_sumamt=" + "1068448.89" +
  7192. "&fund_pay_sumamt=" + "1014677.62" +
  7193. "&acct_pay=" + "0" +
  7194. "&fixmedins_setl_cnt=" + "1950" +
  7195. "&fixmedins_code=" + miConfig.Code +
  7196. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7197. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7198. "&secret_key=" + miConfig.SecretKey +
  7199. "&org_name=" + miConfig.OrgName +
  7200. "&doctor=" + user_name
  7201. fmt.Println(api)
  7202. resp, requestErr := http.Get(api)
  7203. if requestErr != nil {
  7204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7205. return
  7206. }
  7207. body, ioErr := ioutil.ReadAll(resp.Body)
  7208. fmt.Println(body)
  7209. if ioErr != nil {
  7210. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7212. return
  7213. }
  7214. var respJSON map[string]interface{}
  7215. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7218. return
  7219. }
  7220. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7221. userJSONBytes, _ := json.Marshal(respJSON)
  7222. var res ResultEight
  7223. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7224. utils.ErrorLog("解析失败:%v", err)
  7225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7226. return
  7227. }
  7228. }
  7229. //对账明细
  7230. func (c *HisApiController) GetCheckDetailAccount() {
  7231. start_time := c.GetString("start_time")
  7232. end_time := c.GetString("end_time")
  7233. admin_user_id, _ := c.GetInt64("admin_user_id")
  7234. adminUser := c.GetAdminUserInfo()
  7235. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7236. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7237. timeLayout := "2006-01-02"
  7238. loc, _ := time.LoadLocation("Local")
  7239. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7240. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7241. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  7242. Mkdir(miConfig.OrgName)
  7243. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  7244. file_name := file + ".txt"
  7245. zip_name := file + ".zip"
  7246. zip_path := miConfig.OrgName + "/" + zip_name
  7247. file_path := miConfig.OrgName + "/" + file_name
  7248. decimal.DivisionPrecision = 2
  7249. var medfee_sumamt float64
  7250. var psn_cash_pay float64
  7251. var fund_pay_sumamt float64
  7252. fixmedins_setl_cnt := int64(len(orders))
  7253. for _, item := range orders {
  7254. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7255. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  7256. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7257. }
  7258. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  7259. defer f.Close()
  7260. if err != nil {
  7261. fmt.Println(err.Error())
  7262. } else {
  7263. for _, item := range orders {
  7264. var refd_setl_flag string
  7265. if item.OrderStatus == 2 {
  7266. refd_setl_flag = "0"
  7267. var str string
  7268. str = item.SetlId + " " +
  7269. item.MdtrtId + " " +
  7270. item.PsnNo + " " +
  7271. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7272. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7273. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  7274. _, err = f.Write([]byte(str))
  7275. }
  7276. if item.OrderStatus == 3 {
  7277. var str string
  7278. str = item.SetlId + " " +
  7279. item.MdtrtId + " " +
  7280. item.PsnNo + " " +
  7281. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7282. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7283. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  7284. _, err = f.Write([]byte(str))
  7285. var str2 string
  7286. str2 = item.SetlId + " " +
  7287. item.MdtrtId + " " +
  7288. item.PsnNo + " " +
  7289. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  7290. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  7291. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  7292. _, err = f.Write([]byte(str2))
  7293. }
  7294. }
  7295. }
  7296. Zip(file_path, zip_path)
  7297. fmt.Println(ReadFile(zip_path))
  7298. fmt.Println(string(ReadFile(zip_path)))
  7299. if config.IsOpen == 1 {
  7300. var user_name string
  7301. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7302. if role.ID == 0 {
  7303. user_name = "管理员"
  7304. } else {
  7305. user_name = role.UserName
  7306. }
  7307. baseParams := models.BaseParams{
  7308. SecretKey: miConfig.SecretKey,
  7309. FixmedinsCode: miConfig.Code,
  7310. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7311. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7312. OrgName: miConfig.OrgName,
  7313. Doctor: user_name,
  7314. }
  7315. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  7316. var dat map[string]interface{}
  7317. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7318. fmt.Println(dat)
  7319. } else {
  7320. fmt.Println(err)
  7321. }
  7322. userJSONBytes, _ := json.Marshal(dat)
  7323. var res ResultNine
  7324. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7325. utils.ErrorLog("解析失败:%v", err)
  7326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7327. return
  7328. }
  7329. if res.Infcode == 0 {
  7330. fileNo := res.Output.FileQuryNo
  7331. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  7332. "file_qury_no=" + fileNo +
  7333. "&setl_optins=" + "定点医保中心" +
  7334. "&stmt_begndate=" + start_time +
  7335. "&stm_enddate=" + end_time +
  7336. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7337. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7338. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  7339. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7340. "&fixmedins_code=" + miConfig.Code +
  7341. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7342. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7343. "&secret_key=" + miConfig.SecretKey +
  7344. "&org_name=" + miConfig.OrgName +
  7345. "&doctor=" + user_name
  7346. resp, requestErr := http.Get(api)
  7347. if requestErr != nil {
  7348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7349. return
  7350. }
  7351. body, ioErr := ioutil.ReadAll(resp.Body)
  7352. if ioErr != nil {
  7353. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7355. return
  7356. }
  7357. var respJSON map[string]interface{}
  7358. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7361. return
  7362. }
  7363. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7364. userJSONBytes, _ := json.Marshal(respJSON)
  7365. var res ResultTen
  7366. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7367. utils.ErrorLog("解析失败:%v", err)
  7368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7369. return
  7370. }
  7371. if res.Infcode == 0 {
  7372. service.Gdyb9102(baseParams, zip_name, fileNo)
  7373. micc := &models.MedicalInsuranceCostCompare{
  7374. StartTime: startime.Unix(),
  7375. EndTime: endtime.Unix(),
  7376. Insutype: "0",
  7377. CheckType: 2,
  7378. Num: fixmedins_setl_cnt,
  7379. Mtime: time.Now().Unix(),
  7380. Status: 1,
  7381. UserOrgId: adminUser.CurrentOrgId,
  7382. CostTotal: medfee_sumamt,
  7383. FuncTotal: fund_pay_sumamt,
  7384. PsnPay: psn_cash_pay,
  7385. Creator: admin_user_id,
  7386. Ctime: time.Now().Unix(),
  7387. }
  7388. service.CreateMedicalInsuranceCostCompareRecord(micc)
  7389. c.ServeSuccessJSON(map[string]interface{}{
  7390. "msg": "明细对账成功",
  7391. })
  7392. }
  7393. } else {
  7394. }
  7395. }
  7396. }
  7397. type CustomOrderInfo struct {
  7398. Name string
  7399. Spec string
  7400. Unit string
  7401. Count float64
  7402. Price float64
  7403. Total float64
  7404. }
  7405. func (c *HisApiController) GetSettleAccounts() {
  7406. //id, _ := c.GetInt64("id")
  7407. //record_time := c.GetString("record_time")
  7408. order_id, _ := c.GetInt64("order_id")
  7409. admin_user_id, _ := c.GetInt64("admin_user_id")
  7410. //timeLayout := "2006-01-02"
  7411. //loc, _ := time.LoadLocation("Local")
  7412. //
  7413. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7414. //if err != nil {
  7415. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7416. // return
  7417. //}
  7418. //recordDateTime := theTime.Unix()
  7419. adminUser := c.GetAdminUserInfo()
  7420. order, _ := service.GetHisOrderByID(order_id)
  7421. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7422. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  7423. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  7424. orderInfos = append(orderInfos, orderInfos_two...)
  7425. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  7426. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7427. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  7428. //var config []*models.HisXtDiagnoseConfig
  7429. var name string
  7430. for _, item := range diagnosis_ids {
  7431. id, _ := strconv.ParseInt(item, 10, 64)
  7432. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7433. if len(name) == 0 {
  7434. name = diagnosisConfig.ClassName
  7435. } else {
  7436. name = name + "," + diagnosisConfig.ClassName
  7437. }
  7438. }
  7439. var bedCostTotal float64 = 0 //床位总费
  7440. var bedCostSelfTotal float64 = 0 //床位自费
  7441. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7442. var operationCostTotal float64 = 0 //手术费
  7443. var operationCostSelfTotal float64 = 0 //手术费
  7444. var operationCostPartSelfTotal float64 = 0 //手术费
  7445. var otherCostTotal float64 = 0 //其他费用
  7446. var otherCostSelfTotal float64 = 0 //其他费用
  7447. var otherCostPartSelfTotal float64 = 0 //其他费用
  7448. var materialCostTotal float64 = 0 //材料费
  7449. var materialCostSelfTotal float64 = 0 //材料费
  7450. var materialCostPartSelfTotal float64 = 0 //材料费
  7451. var westernMedicineCostTotal float64 = 0 //西药费
  7452. var westernMedicineCostSelfTotal float64 = 0 //西药费
  7453. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7454. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7455. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7456. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7457. var checkCostTotal float64 = 0 //检查费
  7458. var checkCostSelfTotal float64 = 0 //检查费
  7459. var checkCostPartSelfTotal float64 = 0 //检查费
  7460. var laboratoryCostTotal float64 = 0 //化验费
  7461. var laboratoryCostSelfTotal float64 = 0 //化验费
  7462. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7463. var treatCostTotal float64 = 0 //治疗费用
  7464. var treatCostSelfTotal float64 = 0 //治疗费用
  7465. var treatCostPartSelfTotal float64 = 0 //治疗费用
  7466. decimal.DivisionPrecision = 2
  7467. for _, item := range orderInfos {
  7468. if item.MedChrgitmType == "01" { //床位费
  7469. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7470. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7471. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7472. }
  7473. if item.MedChrgitmType == "03" { //检查费
  7474. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7475. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7476. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7477. }
  7478. if item.MedChrgitmType == "04" { //化验费
  7479. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7480. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7481. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7482. }
  7483. if item.MedChrgitmType == "05" || item.MedChrgitmType == "05" || item.MedChrgitmType == "05" { //治疗费
  7484. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7485. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7486. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7487. }
  7488. if item.MedChrgitmType == "06" { //手术费
  7489. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7490. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7491. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7492. }
  7493. if item.MedChrgitmType == "08" { //材料费
  7494. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7495. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7496. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7497. }
  7498. if item.MedChrgitmType == "09" { //西药费
  7499. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7500. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7501. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7502. }
  7503. if item.MedChrgitmType == "11" { //中成费
  7504. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7505. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7506. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7507. }
  7508. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  7509. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7510. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7511. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7512. }
  7513. }
  7514. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7515. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7516. var user_name string
  7517. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7518. if role.ID == 0 {
  7519. user_name = "管理员"
  7520. } else {
  7521. user_name = role.UserName
  7522. }
  7523. baseParams := models.BaseParams{
  7524. SecretKey: miConfig.SecretKey,
  7525. FixmedinsCode: miConfig.Code,
  7526. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7527. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7528. OrgName: miConfig.OrgName,
  7529. Doctor: user_name,
  7530. }
  7531. businessParams := models.BusinessParams{
  7532. PsnNo: order.PsnNo,
  7533. MdtrtId: order.MdtrtId,
  7534. SetlId: order.SetlId,
  7535. }
  7536. var res ResultEleven
  7537. var resEleven10265 ResultEleven10265
  7538. if config.IsOpen == 1 {
  7539. if miConfig.MdtrtareaAdmvs == "421300" {
  7540. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7541. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7542. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7543. resp, requestErr := http.Get(api)
  7544. if requestErr != nil {
  7545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7546. return
  7547. }
  7548. body, ioErr := ioutil.ReadAll(resp.Body)
  7549. if ioErr != nil {
  7550. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7552. return
  7553. }
  7554. var respJSON map[string]interface{}
  7555. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7556. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7558. return
  7559. }
  7560. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7561. result, _ := json.Marshal(respJSON)
  7562. fmt.Println("log")
  7563. fmt.Println(string(result))
  7564. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7565. utils.ErrorLog("解析失败:%v", err)
  7566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7567. return
  7568. }
  7569. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7570. api := "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7571. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7572. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7573. resp, requestErr := http.Get(api)
  7574. if requestErr != nil {
  7575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7576. return
  7577. }
  7578. body, ioErr := ioutil.ReadAll(resp.Body)
  7579. if ioErr != nil {
  7580. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7582. return
  7583. }
  7584. var respJSON map[string]interface{}
  7585. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7586. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7588. return
  7589. }
  7590. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7591. result, _ := json.Marshal(respJSON)
  7592. fmt.Println("log")
  7593. fmt.Println(string(result))
  7594. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  7595. utils.ErrorLog("解析失败:%v", err)
  7596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7597. return
  7598. }
  7599. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7600. res.Output = resEleven10265.Output
  7601. res.ErrMsg = resEleven10265.ErrMsg
  7602. res.Cainfo = resEleven10265.Cainfo
  7603. res.WarnMsg = resEleven10265.WarnMsg
  7604. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7605. res.Infcode = infocode
  7606. } else {
  7607. result2 := service.Gdyb5204(baseParams, businessParams)
  7608. saveLog(result2, "", "5204", "查询")
  7609. result := service.Gdyb5203(baseParams, businessParams)
  7610. var dat map[string]interface{}
  7611. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7612. fmt.Println(dat)
  7613. } else {
  7614. fmt.Println(err)
  7615. }
  7616. userJSONBytes, _ := json.Marshal(dat)
  7617. if miConfig.Code == "H15049901371" {
  7618. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  7619. utils.ErrorLog("解析失败:%v", err)
  7620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7621. return
  7622. }
  7623. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7624. res.Output = resEleven10265.Output
  7625. res.ErrMsg = resEleven10265.ErrMsg
  7626. res.Cainfo = resEleven10265.Cainfo
  7627. res.WarnMsg = resEleven10265.WarnMsg
  7628. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7629. res.Infcode = infocode
  7630. } else {
  7631. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7632. utils.ErrorLog("解析失败:%v", err)
  7633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7634. return
  7635. }
  7636. }
  7637. }
  7638. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7639. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  7640. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  7641. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7642. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7643. var doctor_name string
  7644. if roles.ID == 0 {
  7645. doctor_name = "管理员"
  7646. } else {
  7647. doctor_name = roles.UserName
  7648. }
  7649. yiliao_leibie := ""
  7650. switch order.MedType {
  7651. case "11":
  7652. yiliao_leibie = "普通门诊"
  7653. break
  7654. case "12":
  7655. yiliao_leibie = "门诊挂号"
  7656. break
  7657. case "13":
  7658. yiliao_leibie = "急诊"
  7659. break
  7660. case "14":
  7661. yiliao_leibie = "门诊特殊病"
  7662. break
  7663. case "15":
  7664. yiliao_leibie = "门诊统筹"
  7665. break
  7666. case "16":
  7667. yiliao_leibie = "门诊慢性病"
  7668. break
  7669. case "21":
  7670. yiliao_leibie = "普通住院"
  7671. break
  7672. }
  7673. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7674. if res.Infcode == 0 {
  7675. c.ServeSuccessJSON(map[string]interface{}{
  7676. "diagnosis": name,
  7677. "order_infos": orderInfos,
  7678. "number": order.MdtrtId,
  7679. "date": order.SettleAccountsDate,
  7680. "charge_admin": charge_admin,
  7681. "printor_admin": printor_admin,
  7682. "info": res.Output.Setlinfo,
  7683. "bedCostTotal": bedCostTotal,
  7684. "bedCostSelfTotal": bedCostSelfTotal,
  7685. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  7686. "operationCostTotal": operationCostTotal,
  7687. "operationCostSelfTotal": operationCostSelfTotal,
  7688. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  7689. "otherCostTotal": otherCostTotal,
  7690. "otherCostSelfTotal": otherCostSelfTotal,
  7691. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  7692. "materialCostTotal": materialCostTotal,
  7693. "materialCostSelfTotal": materialCostSelfTotal,
  7694. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  7695. "westernMedicineCostTotal": westernMedicineCostTotal,
  7696. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  7697. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  7698. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  7699. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  7700. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  7701. "checkCostTotal": checkCostTotal,
  7702. "checkCostSelfTotal": checkCostSelfTotal,
  7703. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  7704. "laboratoryCostTotal": laboratoryCostTotal,
  7705. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  7706. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  7707. "treatCostTotal": treatCostTotal,
  7708. "treatCostSelfTotal": treatCostSelfTotal,
  7709. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  7710. "doctor_code": adminRole_two.DoctorCode,
  7711. "doctor_name": doctor_name,
  7712. "health_card_no": order.PsnNo,
  7713. "department": departments.Name,
  7714. "yiliao_leibie": yiliao_leibie,
  7715. "after_money": order.AccountPrice,
  7716. "patient": patient,
  7717. "org_name": miConfig.OrgName,
  7718. "org_code": miConfig.Code,
  7719. "order_number": order.Number,
  7720. //"check_order_info": cus_slice,
  7721. })
  7722. }
  7723. }
  7724. }
  7725. func (c *HisApiController) CheckTreatment() {
  7726. patient_id, _ := c.GetInt64("patient_id")
  7727. id_card_no := c.GetString("id_card_no")
  7728. insutype := c.GetString("insutype")
  7729. med_type := c.GetString("med_type")
  7730. admin_user_id, _ := c.GetInt64("admin_user_id")
  7731. adminUser := c.GetAdminUserInfo()
  7732. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7733. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7734. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7735. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7736. if miConfig.MdtrtareaAdmvs == "421300" {
  7737. var res ResultTwo
  7738. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7739. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7740. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(2, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(2, 10)
  7741. resp, requestErr := http.Get(api)
  7742. if requestErr != nil {
  7743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7744. return
  7745. }
  7746. body, ioErr := ioutil.ReadAll(resp.Body)
  7747. if ioErr != nil {
  7748. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7750. return
  7751. }
  7752. var respJSON map[string]interface{}
  7753. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7756. return
  7757. }
  7758. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7759. result, _ := json.Marshal(respJSON)
  7760. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7761. utils.ErrorLog("解析失败:%v", err)
  7762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7763. return
  7764. }
  7765. if res.Infcode == 0 {
  7766. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  7767. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7768. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  7769. resp, requestErr := http.Get(api)
  7770. if requestErr != nil {
  7771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7772. return
  7773. }
  7774. body, ioErr := ioutil.ReadAll(resp.Body)
  7775. if ioErr != nil {
  7776. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7778. return
  7779. }
  7780. var respJSON map[string]interface{}
  7781. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7782. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7784. return
  7785. }
  7786. var res Result2001
  7787. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7788. result2, _ := json.Marshal(respJSON)
  7789. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  7790. utils.ErrorLog("解析失败:%v", err)
  7791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7792. return
  7793. }
  7794. if res.Infcode == 0 {
  7795. c.ServeSuccessJSON(map[string]interface{}{
  7796. "msg": res.Output.Trtinfo,
  7797. })
  7798. }
  7799. } else {
  7800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7801. return
  7802. }
  7803. } else {
  7804. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7805. var dat map[string]interface{}
  7806. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7807. fmt.Println(dat)
  7808. } else {
  7809. fmt.Println(err)
  7810. }
  7811. userJSONBytes, _ := json.Marshal(dat)
  7812. var res ResultTwo
  7813. var res10265 ResultTwo10265
  7814. if miConfig.Code == "H15049901371" {
  7815. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7816. utils.ErrorLog("解析失败:%v", err)
  7817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7818. return
  7819. }
  7820. res.ErrMsg = res10265.ErrMsg
  7821. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7822. res.Infcode = infocode
  7823. res.Output = res10265.Output
  7824. res.InfRefmsgid = res10265.InfRefmsgid
  7825. } else {
  7826. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7827. utils.ErrorLog("解析失败:%v", err)
  7828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7829. return
  7830. }
  7831. }
  7832. var user_name string
  7833. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  7834. if role.ID == 0 {
  7835. user_name = "xxx"
  7836. } else {
  7837. user_name = role.UserName
  7838. }
  7839. baseParams := models.BaseParams{
  7840. SecretKey: miConfig.SecretKey,
  7841. FixmedinsCode: miConfig.Code,
  7842. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7843. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7844. OrgName: miConfig.OrgName,
  7845. Doctor: user_name,
  7846. }
  7847. if config.IsOpen == 1 {
  7848. if miConfig.Code == "H15049901371" {
  7849. if med_type == "14" {
  7850. if insutype == "390" {
  7851. med_type = "9933"
  7852. } else if insutype == "310" {
  7853. med_type = "990502"
  7854. }
  7855. } else if med_type == "11" {
  7856. med_type = "11"
  7857. }
  7858. }
  7859. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  7860. var dat map[string]interface{}
  7861. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7862. fmt.Println(dat)
  7863. } else {
  7864. fmt.Println(err)
  7865. }
  7866. var res Result2001
  7867. var res10265 Result2001Org10265
  7868. if miConfig.Code == "H15049901371" {
  7869. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7870. utils.ErrorLog("解析失败:%v", err)
  7871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7872. return
  7873. }
  7874. res.ErrMsg = res10265.ErrMsg
  7875. res.Output = res10265.Output
  7876. res.InfRefmsgid = res10265.InfRefmsgid
  7877. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7878. res.Infcode = infocode
  7879. } else {
  7880. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7881. utils.ErrorLog("解析失败:%v", err)
  7882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7883. return
  7884. }
  7885. }
  7886. if res.Infcode == 0 {
  7887. c.ServeSuccessJSON(map[string]interface{}{
  7888. "msg": res.Output.Trtinfo,
  7889. })
  7890. }
  7891. }
  7892. }
  7893. }
  7894. //func (c *HisApiController) PutRecord() {
  7895. // id, _ := c.GetInt64("id")
  7896. // record_time := c.GetString("record_time")
  7897. // timeLayout := "2006-01-02"
  7898. // loc, _ := time.LoadLocation("Local")
  7899. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7900. // if err != nil {
  7901. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7902. // return
  7903. // }
  7904. // recordDateTime := theTime.Unix()
  7905. //
  7906. // adminInfo := c.GetAdminUserInfo()
  7907. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  7908. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7909. //
  7910. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7911. //
  7912. // fmt.Println(miConfig.SecretKey)
  7913. //
  7914. // if patient == nil {
  7915. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7916. // return
  7917. // }
  7918. // if len(patient.IdCardNo) == 0 {
  7919. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  7920. // return
  7921. // }
  7922. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7923. // if config.IsOpen == 1 {
  7924. // 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
  7925. // resp, requestErr := http.Get(api)
  7926. // if requestErr != nil {
  7927. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7928. // return
  7929. // }
  7930. // defer resp.Body.Close()
  7931. // body, ioErr := ioutil.ReadAll(resp.Body)
  7932. // if ioErr != nil {
  7933. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7934. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7935. // return
  7936. // }
  7937. // var respJSON map[string]interface{}
  7938. //
  7939. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7940. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7941. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7942. // return
  7943. // }
  7944. //
  7945. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7946. // userJSONBytes, _ := json.Marshal(userJSON)
  7947. // var res ResultTwo
  7948. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7949. // utils.ErrorLog("解析失败:%v", err)
  7950. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7951. // return
  7952. // }
  7953. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7954. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7955. // infoStr := string(Iinfos)
  7956. // idetinfoStr := string(Idetinfos)
  7957. //
  7958. // if res.Infcode == 0 {
  7959. // his := models.VMHisPatient{
  7960. // Status: 1,
  7961. // Ctime: time.Now().Unix(),
  7962. // Mtime: time.Now().Unix(),
  7963. // PsnNo: res.Output.Baseinfo.PsnNo,
  7964. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  7965. // Certno: res.Output.Baseinfo.Certno,
  7966. // PsnName: res.Output.Baseinfo.PsnName,
  7967. // Gend: res.Output.Baseinfo.Gend,
  7968. // Naty: res.Output.Baseinfo.Naty,
  7969. // Brdy: res.Output.Baseinfo.Brdy,
  7970. // Age: res.Output.Baseinfo.Age,
  7971. // Iinfo: infoStr,
  7972. // Idetinfo: idetinfoStr,
  7973. // PatientId: patient.ID,
  7974. // RecordDate: theTime.Unix(),
  7975. // UserOrgId: adminInfo.CurrentOrgId,
  7976. // AdminUserId: adminInfo.AdminUser.Id,
  7977. // IsReturn: 1,
  7978. // }
  7979. //
  7980. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  7981. // //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")
  7982. // //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")
  7983. //
  7984. // //var dat map[string]interface{}
  7985. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7986. // // fmt.Println(dat)
  7987. // //} else {
  7988. // // fmt.Println(err)
  7989. // //}
  7990. //
  7991. // var dat2 map[string]interface{}
  7992. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  7993. // fmt.Println(dat2)
  7994. // } else {
  7995. // fmt.Println(err)
  7996. // }
  7997. //
  7998. // } else {
  7999. // adminUser := c.GetAdminUserInfo()
  8000. // errlog := &models.HisOrderError{
  8001. // UserOrgId: adminUser.CurrentOrgId,
  8002. // Ctime: time.Now().Unix(),
  8003. // Mtime: time.Now().Unix(),
  8004. // ErrMsg: res.ErrMsg,
  8005. // Status: 1,
  8006. // PatientId: id,
  8007. // RecordTime: recordDateTime,
  8008. // Stage: 1,
  8009. // }
  8010. // service.CreateErrMsgLog(errlog)
  8011. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  8012. // return
  8013. // }
  8014. // }
  8015. //
  8016. //}
  8017. //func (c *HisApiController) GetUploadDiag() {
  8018. // id, _ := c.GetInt64("id")
  8019. // record_time := c.GetString("record_time")
  8020. //
  8021. // diagnosis_id, _ := c.GetInt64("diagnosis")
  8022. // sick_type, _ := c.GetInt64("sick_type")
  8023. // reg_type, _ := c.GetInt64("reg_type")
  8024. //
  8025. // timeLayout := "2006-01-02"
  8026. // loc, _ := time.LoadLocation("Local")
  8027. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8028. // if err != nil {
  8029. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8030. // return
  8031. // }
  8032. //
  8033. // var patientPrescription models.HisPrescriptionInfo
  8034. // recordDateTime := theTime.Unix()
  8035. // adminInfo := c.GetAdminUserInfo()
  8036. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8037. //
  8038. // if patientPrescription.ID == 0 {
  8039. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8040. // }
  8041. //
  8042. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8043. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  8044. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8045. // sickConfig, _ := service.FindSickById(sick_type)
  8046. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8047. //
  8048. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  8049. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  8050. // "&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 +
  8051. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  8052. // resp2, requestErr2 := http.Get(api2)
  8053. // if requestErr2 != nil {
  8054. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8055. // return
  8056. // }
  8057. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8058. // if ioErr2 != nil {
  8059. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8060. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8061. // return
  8062. // }
  8063. // var respJSON2 map[string]interface{}
  8064. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8065. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8066. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8067. // return
  8068. // }
  8069. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8070. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8071. //
  8072. // var res2 ResultSix
  8073. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8074. // utils.ErrorLog("解析失败:%v", err)
  8075. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8076. // return
  8077. // }
  8078. // if res2.Infcode != 0 {
  8079. // adminUser := c.GetAdminUserInfo()
  8080. // errlog := &models.HisOrderError{
  8081. // UserOrgId: adminUser.CurrentOrgId,
  8082. // Ctime: time.Now().Unix(),
  8083. // Mtime: time.Now().Unix(),
  8084. // ErrMsg: res2.ErrMsg,
  8085. // Status: 1,
  8086. // PatientId: id,
  8087. // RecordTime: recordDateTime,
  8088. // Stage: 3,
  8089. // }
  8090. // service.CreateErrMsgLog(errlog)
  8091. //
  8092. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  8093. // return
  8094. // }
  8095. //
  8096. // c.ServeSuccessJSON(map[string]interface{}{
  8097. // "msg": "上传成功",
  8098. // })
  8099. //
  8100. //}
  8101. type QueryResult struct {
  8102. ID int64
  8103. Name string
  8104. Code string
  8105. List_type_code string
  8106. }
  8107. func (c *HisApiController) GetCheckCode() {
  8108. ids_str := c.GetString("ids")
  8109. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8110. ids_arr := strings.Split(ids_str, ",")
  8111. var queryResult []QueryResult
  8112. ids := make([]int64, 0)
  8113. for _, item := range ids_arr {
  8114. id, _ := strconv.ParseInt(item, 10, 64)
  8115. ids = append(ids, id)
  8116. }
  8117. if record_type == 1 {
  8118. drugs, _ := service.GetBatchDrugList(ids)
  8119. for _, item := range drugs {
  8120. result := QueryResult{
  8121. ID: item.ID,
  8122. Name: item.DrugName,
  8123. Code: item.MedicalInsuranceNumber,
  8124. List_type_code: "101",
  8125. }
  8126. queryResult = append(queryResult, result)
  8127. }
  8128. } else if record_type == 2 {
  8129. goods, _ := service.GetBatchGoodInformationList(ids)
  8130. for _, item := range goods {
  8131. result := QueryResult{
  8132. ID: item.ID,
  8133. Name: item.GoodName,
  8134. Code: item.MedicalInsuranceNumber,
  8135. List_type_code: "301",
  8136. }
  8137. queryResult = append(queryResult, result)
  8138. }
  8139. } else if record_type == 3 {
  8140. projects, _ := service.GetBathchMyPorjecgList(ids)
  8141. for _, item := range projects {
  8142. result := QueryResult{
  8143. ID: item.ID,
  8144. Name: item.ProjectName,
  8145. Code: item.MedicalCode,
  8146. List_type_code: "201",
  8147. }
  8148. queryResult = append(queryResult, result)
  8149. }
  8150. }
  8151. admin_user_id, _ := c.GetInt64("admin_user_id")
  8152. adminUser := c.GetAdminUserInfo()
  8153. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8154. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8155. var user_name string
  8156. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8157. if role.ID == 0 {
  8158. user_name = "xxx"
  8159. } else {
  8160. user_name = role.UserName
  8161. }
  8162. baseParams := &models.BaseParams{
  8163. SecretKey: miConfig.SecretKey,
  8164. FixmedinsCode: miConfig.Code,
  8165. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8166. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8167. OrgName: miConfig.OrgName,
  8168. Doctor: user_name,
  8169. }
  8170. if config.IsOpen == 1 {
  8171. for _, item := range queryResult {
  8172. var result string
  8173. if record_type == 1 {
  8174. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8175. } else if record_type == 2 {
  8176. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8177. } else if record_type == 3 {
  8178. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8179. }
  8180. var dat map[string]interface{}
  8181. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8182. fmt.Println(dat)
  8183. } else {
  8184. fmt.Println(err)
  8185. }
  8186. userJSONBytes, _ := json.Marshal(dat)
  8187. var res ResultSix
  8188. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8189. utils.ErrorLog("解析失败:%v", err)
  8190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8191. return
  8192. }
  8193. if res.Infcode == 0 {
  8194. if record_type == 1 {
  8195. service.UpdateBaseDrugById(item.ID)
  8196. } else if record_type == 2 {
  8197. service.UpdateGoodInformaitonByDetail(item.ID)
  8198. } else if record_type == 3 {
  8199. service.UpdateProjectById(item.ID)
  8200. }
  8201. c.ServeSuccessJSON(map[string]interface{}{
  8202. "failed_code": 0,
  8203. "msg": "目录对照成功",
  8204. })
  8205. } else {
  8206. c.ServeSuccessJSON(map[string]interface{}{
  8207. "failed_code": -10,
  8208. "msg": res.ErrMsg,
  8209. })
  8210. }
  8211. }
  8212. }
  8213. }
  8214. func (c *HisApiController) UnCheckCode() {
  8215. ids_str := c.GetString("ids")
  8216. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8217. admin_user_id, _ := c.GetInt64("admin_user_id")
  8218. ids_arr := strings.Split(ids_str, ",")
  8219. var queryResult []QueryResult
  8220. ids := make([]int64, 0)
  8221. for _, item := range ids_arr {
  8222. id, _ := strconv.ParseInt(item, 10, 64)
  8223. ids = append(ids, id)
  8224. }
  8225. if record_type == 1 {
  8226. drugs, _ := service.GetBatchDrugList(ids)
  8227. for _, item := range drugs {
  8228. result := QueryResult{
  8229. ID: item.ID,
  8230. Name: item.DrugName,
  8231. Code: item.MedicalInsuranceNumber,
  8232. List_type_code: "101",
  8233. }
  8234. queryResult = append(queryResult, result)
  8235. }
  8236. } else if record_type == 2 {
  8237. goods, _ := service.GetBatchGoodInformationList(ids)
  8238. for _, item := range goods {
  8239. result := QueryResult{
  8240. ID: item.ID,
  8241. Name: item.GoodName,
  8242. Code: item.MedicalInsuranceNumber,
  8243. List_type_code: "301",
  8244. }
  8245. queryResult = append(queryResult, result)
  8246. }
  8247. } else if record_type == 3 {
  8248. projects, _ := service.GetBathchMyPorjecgList(ids)
  8249. for _, item := range projects {
  8250. result := QueryResult{
  8251. ID: item.ID,
  8252. Name: item.ProjectName,
  8253. Code: item.MedicalCode,
  8254. List_type_code: "201",
  8255. }
  8256. queryResult = append(queryResult, result)
  8257. }
  8258. }
  8259. adminUser := c.GetAdminUserInfo()
  8260. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8261. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8262. var user_name string
  8263. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8264. if role.ID == 0 {
  8265. user_name = "xxx"
  8266. } else {
  8267. user_name = role.UserName
  8268. }
  8269. baseParams := &models.BaseParams{
  8270. SecretKey: miConfig.SecretKey,
  8271. FixmedinsCode: miConfig.Code,
  8272. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8273. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8274. OrgName: miConfig.OrgName,
  8275. Doctor: user_name,
  8276. }
  8277. if config.IsOpen == 1 {
  8278. for _, item := range queryResult {
  8279. var result string
  8280. if record_type == 1 {
  8281. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8282. } else if record_type == 2 {
  8283. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8284. } else if record_type == 3 {
  8285. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8286. }
  8287. var dat2 map[string]interface{}
  8288. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  8289. fmt.Println(dat2)
  8290. } else {
  8291. fmt.Println(err)
  8292. }
  8293. userJSONBytes, _ := json.Marshal(dat2)
  8294. var res ResultSix
  8295. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8296. utils.ErrorLog("解析失败:%v", err)
  8297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8298. return
  8299. }
  8300. if res.Infcode == 0 {
  8301. if record_type == 1 {
  8302. service.UpdateDrugByIdDetail(item.ID)
  8303. } else if record_type == 2 {
  8304. service.UpdateGoodInfoById(item.ID)
  8305. } else if record_type == 3 {
  8306. service.UpdateMyProjectById(item.ID)
  8307. }
  8308. c.ServeSuccessJSON(map[string]interface{}{
  8309. "failed_code": 0,
  8310. "msg": "撤销目录对照成功",
  8311. })
  8312. } else {
  8313. c.ServeSuccessJSON(map[string]interface{}{
  8314. "failed_code": -10,
  8315. "msg": res.ErrMsg,
  8316. })
  8317. }
  8318. }
  8319. }
  8320. }
  8321. func (c *HisApiController) GetPatientInfo() {
  8322. id_card_no := c.GetString("id_card_no")
  8323. admin_user_id, _ := c.GetInt64("admin_user_id")
  8324. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8325. if patient.ID == 0 {
  8326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8327. return
  8328. }
  8329. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8330. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8331. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  8332. if config.IsOpen == 1 {
  8333. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8334. var dat map[string]interface{}
  8335. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8336. fmt.Println(dat)
  8337. } else {
  8338. fmt.Println(err)
  8339. }
  8340. userJSONBytes, _ := json.Marshal(dat)
  8341. var res ResultTwo
  8342. var res10265 ResultTwo10265
  8343. if miConfig.Code == "H15049901371" {
  8344. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8345. utils.ErrorLog("解析失败:%v", err)
  8346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8347. return
  8348. }
  8349. res.ErrMsg = res10265.ErrMsg
  8350. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8351. res.Infcode = infocode
  8352. res.Output = res10265.Output
  8353. res.InfRefmsgid = res10265.InfRefmsgid
  8354. } else {
  8355. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8356. utils.ErrorLog("解析失败:%v", err)
  8357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8358. return
  8359. }
  8360. }
  8361. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8362. // utils.ErrorLog("解析失败:%v", err)
  8363. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8364. // return
  8365. //}
  8366. if res.Infcode != 0 {
  8367. c.ServeSuccessJSON(map[string]interface{}{
  8368. "failed_code": -10,
  8369. "msg": res.ErrMsg,
  8370. })
  8371. } else {
  8372. c.ServeSuccessJSON(map[string]interface{}{
  8373. "failed_code": 0,
  8374. "info": res,
  8375. })
  8376. }
  8377. }
  8378. }
  8379. func (c *HisApiController) PsnPutOnRecord() {
  8380. record_type, _ := c.GetInt64("type")
  8381. patient_id, _ := c.GetInt64("patient_id")
  8382. admin_user_id, _ := c.GetInt64("admin_user_id")
  8383. start_time := c.GetString("start_time")
  8384. end_time := c.GetString("end_time")
  8385. adminUser := c.GetAdminUserInfo()
  8386. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8387. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8388. var patients []*models.Patients
  8389. if record_type == 1 { //全部备案
  8390. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  8391. patients = append(patients, patient...)
  8392. } else { //单个备案
  8393. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8394. patients = append(patients, patient)
  8395. }
  8396. var user_name string
  8397. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8398. if role.ID == 0 {
  8399. user_name = "xxx"
  8400. } else {
  8401. user_name = role.UserName
  8402. }
  8403. if config.IsOpen == 1 {
  8404. for _, item := range patients {
  8405. 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
  8406. resp, requestErr := http.Get(api)
  8407. if requestErr != nil {
  8408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8409. return
  8410. }
  8411. defer resp.Body.Close()
  8412. body, ioErr := ioutil.ReadAll(resp.Body)
  8413. if ioErr != nil {
  8414. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8416. return
  8417. }
  8418. var respJSON map[string]interface{}
  8419. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8422. return
  8423. }
  8424. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8425. userJSONBytes, _ := json.Marshal(userJSON)
  8426. var res ResultTwo
  8427. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8428. utils.ErrorLog("解析失败:%v", err)
  8429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8430. return
  8431. }
  8432. if res.Infcode == 0 {
  8433. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  8434. var dat map[string]interface{}
  8435. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8436. fmt.Println(dat)
  8437. } else {
  8438. fmt.Println(err)
  8439. }
  8440. userJSONBytes, _ := json.Marshal(dat)
  8441. var res2 ResultThirteen
  8442. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8443. utils.ErrorLog("解析失败:%v", err)
  8444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8445. return
  8446. }
  8447. if res2.Infcode == 0 {
  8448. psnResult := &models.GdybPsnRecord{
  8449. UserOrgId: adminUser.CurrentOrgId,
  8450. PatientId: item.ID,
  8451. PsnNo: res.Output.Baseinfo.PsnNo,
  8452. Ctime: time.Now().Unix(),
  8453. Mtime: time.Now().Unix(),
  8454. Status: 1,
  8455. IsCancel: 1,
  8456. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8457. }
  8458. service.CreatePsnRecord(psnResult)
  8459. } else {
  8460. c.ServeSuccessJSON(map[string]interface{}{
  8461. "failed_code": -10,
  8462. "msg": res2.ErrMsg,
  8463. })
  8464. return
  8465. }
  8466. }
  8467. }
  8468. }
  8469. }
  8470. func (c *HisApiController) PsnUnPutOnRecord() {
  8471. id, _ := c.GetInt64("id")
  8472. //record_type, _ := c.GetInt64("type")
  8473. admin_user_id, _ := c.GetInt64("admin_user_id")
  8474. adminUser := c.GetAdminUserInfo()
  8475. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8476. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8477. var user_name string
  8478. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8479. if role.ID == 0 {
  8480. user_name = "xxx"
  8481. } else {
  8482. user_name = role.UserName
  8483. }
  8484. psn_record, _ := service.GetPsnRecordById(id)
  8485. if psn_record.ID == 0 {
  8486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8487. return
  8488. }
  8489. if config.IsOpen == 1 {
  8490. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8491. var dat map[string]interface{}
  8492. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8493. fmt.Println(dat)
  8494. } else {
  8495. fmt.Println(err)
  8496. }
  8497. userJSONBytes, _ := json.Marshal(dat)
  8498. var res ResultFourteen
  8499. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8500. utils.ErrorLog("解析失败:%v", err)
  8501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8502. return
  8503. }
  8504. if res.Infcode == 0 {
  8505. psn_record.IsCancel = 2
  8506. service.CreatePsnRecord(&psn_record)
  8507. } else {
  8508. c.ServeSuccessJSON(map[string]interface{}{
  8509. "failed_code": -10,
  8510. "msg": res.ErrMsg,
  8511. })
  8512. return
  8513. }
  8514. }
  8515. }
  8516. func (c *HisApiController) PsnPutNCDSOnRecord() {
  8517. patient_id, _ := c.GetInt64("patient_id")
  8518. insutype_two := c.GetString("insutype")
  8519. psn_no := c.GetString("psn_no")
  8520. doctor_id, _ := c.GetInt64("doctor_id")
  8521. sick_id, _ := c.GetInt64("sick_id")
  8522. department_id, _ := c.GetInt64("department_id")
  8523. start_time := c.GetString("start_time")
  8524. end_time := c.GetString("end_time")
  8525. check_time := c.GetString("check_time")
  8526. adminUser := c.GetAdminUserInfo()
  8527. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8528. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8529. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8530. sick, _ := service.FindSickById(sick_id)
  8531. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8532. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8533. var res ResultTwo
  8534. var res10265 ResultTwo10265
  8535. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8536. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  8537. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  8538. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8539. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(3, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  8540. resp, requestErr := http.Get(api)
  8541. if requestErr != nil {
  8542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8543. return
  8544. }
  8545. body, ioErr := ioutil.ReadAll(resp.Body)
  8546. if ioErr != nil {
  8547. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8549. return
  8550. }
  8551. var respJSON map[string]interface{}
  8552. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8553. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8555. return
  8556. }
  8557. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8558. result, _ := json.Marshal(respJSON)
  8559. fmt.Println("log")
  8560. fmt.Println(string(result))
  8561. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8562. utils.ErrorLog("解析失败:%v", err)
  8563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8564. return
  8565. }
  8566. res.ErrMsg = res10265.ErrMsg
  8567. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8568. res.Infcode = infocode
  8569. res.Output = res10265.Output
  8570. res.InfRefmsgid = res10265.InfRefmsgid
  8571. } else {
  8572. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8573. if miConfig.Code == "H15049901371" {
  8574. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8575. utils.ErrorLog("解析失败:%v", err)
  8576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8577. return
  8578. }
  8579. res.ErrMsg = res10265.ErrMsg
  8580. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8581. res.Infcode = infocode
  8582. res.Output = res10265.Output
  8583. res.InfRefmsgid = res10265.InfRefmsgid
  8584. } else {
  8585. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8586. utils.ErrorLog("解析失败:%v", err)
  8587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8588. return
  8589. }
  8590. }
  8591. }
  8592. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8593. infoStr := string(Iinfos)
  8594. var rf []*ResultFive
  8595. json.Unmarshal([]byte(infoStr), &rf)
  8596. var insuplc_admdvs string
  8597. var insutype string
  8598. var is390 int = 0
  8599. var is310 int = 0
  8600. var insutypes []*ResultFive
  8601. for _, item := range rf {
  8602. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8603. insutypes = append(insutypes, item)
  8604. }
  8605. }
  8606. if len(insutypes) == 1 {
  8607. insutype = insutypes[0].Insutype
  8608. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8609. } else {
  8610. for _, i := range insutypes {
  8611. if i.Insutype == "390" {
  8612. is390 = 1
  8613. }
  8614. if i.Insutype == "310" {
  8615. is310 = 1
  8616. }
  8617. }
  8618. }
  8619. if is390 == 1 {
  8620. insutype = "390"
  8621. }
  8622. if is310 == 1 {
  8623. insutype = "310"
  8624. }
  8625. if len(insutypes) == 2 {
  8626. insutype = insutype_two
  8627. }
  8628. if len(insutypes) == 0 {
  8629. insutype = "310"
  8630. }
  8631. insutype = insutype_two
  8632. fmt.Println(insutype)
  8633. for _, item := range rf {
  8634. fmt.Println(item.Insutype)
  8635. fmt.Println(insutype)
  8636. if item.Insutype == insutype {
  8637. fmt.Println(item.Insutype)
  8638. fmt.Println(insutype)
  8639. insuplc_admdvs = item.InsuplcAdmdvs
  8640. }
  8641. }
  8642. fmt.Println(insuplc_admdvs)
  8643. var res2 ResultThirteen
  8644. var res10265_2 ResultThirteen10265
  8645. if config.IsOpen == 1 {
  8646. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8647. } else {
  8648. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time)
  8649. var dat map[string]interface{}
  8650. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8651. fmt.Println(dat)
  8652. } else {
  8653. fmt.Println(err)
  8654. }
  8655. userJSONBytes, _ := json.Marshal(dat)
  8656. if miConfig.Code == "H15049901371" {
  8657. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  8658. utils.ErrorLog("解析失败:%v", err)
  8659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8660. return
  8661. }
  8662. res2.ErrMsg = res10265_2.ErrMsg
  8663. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  8664. res2.Infcode = infocode
  8665. res2.Output = res10265_2.Output
  8666. res2.InfRefmsgid = res10265_2.InfRefmsgid
  8667. } else {
  8668. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8669. utils.ErrorLog("解析失败:%v", err)
  8670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8671. return
  8672. }
  8673. }
  8674. }
  8675. if res2.Infcode == 0 {
  8676. psnResult := &models.GdybPsnNcdsRecord{
  8677. UserOrgId: adminUser.CurrentOrgId,
  8678. PatientId: patient.ID,
  8679. PsnNo: psn_no,
  8680. DoctorId: doctor.AdminUserId,
  8681. DepartmentId: department_id,
  8682. SickType: sick_id,
  8683. Insutype: insutype,
  8684. Ctime: time.Now().Unix(),
  8685. Mtime: time.Now().Unix(),
  8686. Status: 1,
  8687. IsCancel: 1,
  8688. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8689. }
  8690. service.CreatePsnNCDSRecord(psnResult)
  8691. c.ServeSuccessJSON(map[string]interface{}{
  8692. "failed_code": 0,
  8693. "msg": "备案成功",
  8694. "result": psnResult,
  8695. })
  8696. } else {
  8697. c.ServeSuccessJSON(map[string]interface{}{
  8698. "failed_code": -10,
  8699. "msg": res2.ErrMsg,
  8700. })
  8701. return
  8702. }
  8703. }
  8704. }
  8705. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  8706. id, _ := c.GetInt64("id")
  8707. admin_user_id, _ := c.GetInt64("admin_user_id")
  8708. adminUser := c.GetAdminUserInfo()
  8709. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8710. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8711. //config, _ := service.Ge(adminUser.CurrentOrgId)
  8712. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  8713. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8714. //var user_name string
  8715. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8716. //if role.ID == 0 {
  8717. // user_name = "xxx"
  8718. //} else {
  8719. // user_name = role.UserName
  8720. //}
  8721. psn_record, _ := service.GetPsnNCDSRecordById(id)
  8722. if psn_record.ID == 0 {
  8723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8724. return
  8725. }
  8726. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8727. var res ResultTwo
  8728. var res10265 ResultTwo10265
  8729. if miConfig.Code == "H15049901371" {
  8730. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8731. utils.ErrorLog("解析失败:%v", err)
  8732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8733. return
  8734. }
  8735. res.ErrMsg = res10265.ErrMsg
  8736. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8737. res.Infcode = infocode
  8738. res.Output = res10265.Output
  8739. res.InfRefmsgid = res10265.InfRefmsgid
  8740. } else {
  8741. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8742. utils.ErrorLog("解析失败:%v", err)
  8743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8744. return
  8745. }
  8746. }
  8747. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8748. infoStr := string(Iinfos)
  8749. var rf []*ResultFive
  8750. json.Unmarshal([]byte(infoStr), &rf)
  8751. var insuplc_admdvs string
  8752. var insutype string
  8753. var is390 int = 0
  8754. var is310 int = 0
  8755. var insutypes []*ResultFive
  8756. for _, item := range rf {
  8757. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8758. insutypes = append(insutypes, item)
  8759. }
  8760. }
  8761. if len(insutypes) == 1 {
  8762. insutype = insutypes[0].Insutype
  8763. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8764. } else {
  8765. for _, i := range insutypes {
  8766. if i.Insutype == "390" {
  8767. is390 = 1
  8768. }
  8769. if i.Insutype == "310" {
  8770. is310 = 1
  8771. }
  8772. }
  8773. }
  8774. if is390 == 1 {
  8775. insutype = "390"
  8776. }
  8777. if is310 == 1 {
  8778. insutype = "310"
  8779. }
  8780. if len(insutypes) == 0 {
  8781. insutype = "310"
  8782. }
  8783. insutype = psn_record.Insutype
  8784. for _, item := range rf {
  8785. if item.Insutype == insutype {
  8786. insuplc_admdvs = item.InsuplcAdmdvs
  8787. }
  8788. }
  8789. if config.IsOpen == 1 {
  8790. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8791. var dat map[string]interface{}
  8792. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8793. fmt.Println(dat)
  8794. } else {
  8795. fmt.Println(err)
  8796. }
  8797. userJSONBytes, _ := json.Marshal(dat)
  8798. var res ResultFourteen
  8799. var res10265 ResultFourteen10265
  8800. if miConfig.Code == "H15049901371" {
  8801. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8802. utils.ErrorLog("解析失败:%v", err)
  8803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8804. return
  8805. }
  8806. res.ErrMsg = res10265.ErrMsg
  8807. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8808. res.Infcode = infocode
  8809. res.Output = res10265.Output
  8810. res.InfRefmsgid = res10265.InfRefmsgid
  8811. } else {
  8812. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8813. utils.ErrorLog("解析失败:%v", err)
  8814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8815. return
  8816. }
  8817. }
  8818. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8819. // utils.ErrorLog("解析失败:%v", err)
  8820. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8821. // return
  8822. //}
  8823. if res.Infcode == 0 {
  8824. psn_record.IsCancel = 2
  8825. service.CreatePsnNCDSRecord(&psn_record)
  8826. c.ServeSuccessJSON(map[string]interface{}{
  8827. "failed_code": 0,
  8828. "msg": "撤销备案成功",
  8829. })
  8830. } else {
  8831. c.ServeSuccessJSON(map[string]interface{}{
  8832. "failed_code": -10,
  8833. "msg": res.ErrMsg,
  8834. })
  8835. return
  8836. }
  8837. }
  8838. }
  8839. func (c *HisApiController) TestTest() {
  8840. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  8841. fmt.Println(patient.Iinfo)
  8842. }
  8843. type CustomData struct {
  8844. MsgId string
  8845. PsnNo string
  8846. Info string
  8847. }
  8848. func (c *HisApiController) ReversalData() {
  8849. var customData []*CustomData
  8850. custom := &CustomData{
  8851. MsgId: "H44022900158202103301714472004",
  8852. PsnNo: "44020000001101329945",
  8853. Info: "2207",
  8854. }
  8855. customData = append(customData, custom)
  8856. custom1 := &CustomData{
  8857. MsgId: "H4402290015820210330172057803",
  8858. PsnNo: "44020000001101161813",
  8859. Info: "2207",
  8860. }
  8861. customData = append(customData, custom1)
  8862. custom2 := &CustomData{
  8863. MsgId: "H44022900158202103301705198813",
  8864. PsnNo: "44190000133097375417",
  8865. Info: "2207",
  8866. }
  8867. customData = append(customData, custom2)
  8868. custom3 := &CustomData{
  8869. MsgId: "H44022900158202103301715524756",
  8870. PsnNo: "44020000001100187221",
  8871. Info: "2207",
  8872. }
  8873. customData = append(customData, custom3)
  8874. custom4 := &CustomData{
  8875. MsgId: "H44022900158202103301730376224",
  8876. PsnNo: "44020000001101959155",
  8877. Info: "2207",
  8878. }
  8879. customData = append(customData, custom4)
  8880. custom5 := &CustomData{
  8881. MsgId: "H44022900158202103301748008725",
  8882. PsnNo: "44020000001104246641",
  8883. Info: "2207",
  8884. }
  8885. customData = append(customData, custom5)
  8886. custom6 := &CustomData{
  8887. MsgId: "H44022900158202103301718096755",
  8888. PsnNo: "44020000001102211860",
  8889. Info: "2207",
  8890. }
  8891. customData = append(customData, custom6)
  8892. custom7 := &CustomData{
  8893. MsgId: "H44022900158202103301736551640",
  8894. PsnNo: "44020000001102687718",
  8895. Info: "2207",
  8896. }
  8897. customData = append(customData, custom7)
  8898. custom8 := &CustomData{
  8899. MsgId: "H44022900158202103301743097676",
  8900. PsnNo: "44020000001102127785",
  8901. Info: "2207",
  8902. }
  8903. customData = append(customData, custom8)
  8904. custom9 := &CustomData{
  8905. MsgId: "H44022900158202103301712304203",
  8906. PsnNo: "44020000001101518097",
  8907. Info: "2207",
  8908. }
  8909. customData = append(customData, custom9)
  8910. custom10 := &CustomData{
  8911. MsgId: "H44022900158202103301738448785",
  8912. PsnNo: "44020000001100500813",
  8913. Info: "2207",
  8914. }
  8915. customData = append(customData, custom10)
  8916. custom11 := &CustomData{
  8917. MsgId: "H44022900158202103301732455843",
  8918. PsnNo: "44020000001102690557",
  8919. Info: "2207",
  8920. }
  8921. customData = append(customData, custom11)
  8922. custom12 := &CustomData{
  8923. MsgId: "H44022900158202103301745421708",
  8924. PsnNo: "44020000001102211928",
  8925. Info: "2207",
  8926. }
  8927. customData = append(customData, custom12)
  8928. custom1212 := &CustomData{
  8929. MsgId: "H440229001582021033017351627",
  8930. PsnNo: "44020000001102481733",
  8931. Info: "2207",
  8932. }
  8933. customData = append(customData, custom1212)
  8934. custom13 := &CustomData{
  8935. MsgId: "H44022900158202103301740327951",
  8936. PsnNo: "44020000001103174866",
  8937. Info: "2207",
  8938. }
  8939. customData = append(customData, custom13)
  8940. custom14 := &CustomData{
  8941. MsgId: "H4402290015820210330174922668",
  8942. PsnNo: "44020000001102927272",
  8943. Info: "2207",
  8944. }
  8945. customData = append(customData, custom14)
  8946. custom15 := &CustomData{
  8947. MsgId: "H44022900158202103301752362273",
  8948. PsnNo: "44020000001102942890",
  8949. Info: "2207",
  8950. }
  8951. customData = append(customData, custom15)
  8952. custom16 := &CustomData{
  8953. MsgId: "H44022900158202103301751082917",
  8954. PsnNo: "44020000001101662162",
  8955. Info: "2207",
  8956. }
  8957. customData = append(customData, custom16)
  8958. custom17 := &CustomData{
  8959. MsgId: "H44022900158202103301754147728",
  8960. PsnNo: "44020000000229014511",
  8961. Info: "2207",
  8962. }
  8963. customData = append(customData, custom17)
  8964. adminUser := c.GetAdminUserInfo()
  8965. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8966. for _, item := range customData {
  8967. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  8968. fmt.Println(result)
  8969. }
  8970. }
  8971. func (c *HisApiController) GetAllopatry() {
  8972. year := c.GetString("year")
  8973. month := c.GetString("month")
  8974. admin_user_id, _ := c.GetInt64("admin_user_id")
  8975. adminUser := c.GetAdminUserInfo()
  8976. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8977. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8978. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  8979. var dat map[string]interface{}
  8980. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8981. fmt.Println(dat)
  8982. } else {
  8983. fmt.Println(err)
  8984. }
  8985. userJSONBytes, _ := json.Marshal(dat)
  8986. var res models.Result9001
  8987. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8988. utils.ErrorLog("解析失败:%v", err)
  8989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8990. return
  8991. }
  8992. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  8993. var dat2 map[string]interface{}
  8994. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8995. fmt.Println(dat)
  8996. } else {
  8997. fmt.Println(err)
  8998. }
  8999. userJSONBytes2, _ := json.Marshal(dat2)
  9000. var res2 models.Result3260
  9001. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9002. utils.ErrorLog("解析失败:%v", err)
  9003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9004. return
  9005. }
  9006. if res2.Infcode == 0 {
  9007. c.ServeSuccessJSON(map[string]interface{}{
  9008. "list": res2.Output.Data,
  9009. })
  9010. return
  9011. } else {
  9012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9013. return
  9014. }
  9015. }
  9016. func (c *HisApiController) ComfirmAllopatry() {
  9017. year := c.GetString("year")
  9018. month := c.GetString("month")
  9019. admin_user_id, _ := c.GetInt64("admin_user_id")
  9020. adminUser := c.GetAdminUserInfo()
  9021. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9022. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9023. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9024. var dat map[string]interface{}
  9025. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9026. fmt.Println(dat)
  9027. } else {
  9028. fmt.Println(err)
  9029. }
  9030. userJSONBytes, _ := json.Marshal(dat)
  9031. var res models.Result9001
  9032. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9033. utils.ErrorLog("解析失败:%v", err)
  9034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9035. return
  9036. }
  9037. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9038. var dat2 map[string]interface{}
  9039. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9040. fmt.Println(dat)
  9041. } else {
  9042. fmt.Println(err)
  9043. }
  9044. userJSONBytes2, _ := json.Marshal(dat2)
  9045. var res2 models.Result3260
  9046. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9047. utils.ErrorLog("解析失败:%v", err)
  9048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9049. return
  9050. }
  9051. if res2.Infcode == 0 {
  9052. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  9053. var dat map[string]interface{}
  9054. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9055. fmt.Println(dat)
  9056. } else {
  9057. fmt.Println(err)
  9058. }
  9059. userJSONBytes, _ := json.Marshal(dat)
  9060. var res3 models.Result3261
  9061. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  9062. utils.ErrorLog("解析失败:%v", err)
  9063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9064. return
  9065. }
  9066. if res3.Infcode == 0 {
  9067. record := &models.HisYidiClearRecord{
  9068. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9069. Ctime: time.Now().Unix(),
  9070. Mtime: time.Now().Unix(),
  9071. Status: 1,
  9072. MsgId: msgId,
  9073. }
  9074. service.SaveClearRecord(record)
  9075. c.ServeSuccessJSON(map[string]interface{}{
  9076. "msg": "提取成功",
  9077. })
  9078. }
  9079. }
  9080. }
  9081. func (c *HisApiController) RefundAllopatry() {
  9082. year := c.GetString("year")
  9083. month := c.GetString("month")
  9084. id, _ := c.GetInt64("id")
  9085. admin_user_id, _ := c.GetInt64("admin_user_id")
  9086. adminUser := c.GetAdminUserInfo()
  9087. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9088. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9089. record, _ := service.GetClearRecordById(id)
  9090. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  9091. var dat map[string]interface{}
  9092. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9093. fmt.Println(dat)
  9094. } else {
  9095. fmt.Println(err)
  9096. }
  9097. userJSONBytes, _ := json.Marshal(dat)
  9098. var empty ResultFourteen
  9099. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  9100. utils.ErrorLog("解析失败:%v", err)
  9101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9102. return
  9103. }
  9104. if empty.Infcode == 0 {
  9105. c.ServeSuccessJSON(map[string]interface{}{
  9106. "msg": "撤销成功",
  9107. })
  9108. return
  9109. }
  9110. }
  9111. func (c *HisApiController) ReversalOtherData() {
  9112. var customData []*CustomData
  9113. custom := &CustomData{
  9114. MsgId: "H44022900158202103301714472004",
  9115. PsnNo: "44020000001101329945",
  9116. Info: "2208",
  9117. }
  9118. customData = append(customData, custom)
  9119. custom1 := &CustomData{
  9120. MsgId: "H4402290015820210330172057803",
  9121. PsnNo: "44020000001101161813",
  9122. Info: "2208",
  9123. }
  9124. customData = append(customData, custom1)
  9125. custom2 := &CustomData{
  9126. MsgId: "H44022900158202103301705198813",
  9127. PsnNo: "44190000133097375417",
  9128. Info: "2208",
  9129. }
  9130. customData = append(customData, custom2)
  9131. custom3 := &CustomData{
  9132. MsgId: "H44022900158202103301715524756",
  9133. PsnNo: "44020000001100187221",
  9134. Info: "2208",
  9135. }
  9136. customData = append(customData, custom3)
  9137. custom4 := &CustomData{
  9138. MsgId: "H44022900158202103301730376224",
  9139. PsnNo: "44020000001101959155",
  9140. Info: "2208",
  9141. }
  9142. customData = append(customData, custom4)
  9143. custom5 := &CustomData{
  9144. MsgId: "H44022900158202103301748008725",
  9145. PsnNo: "44020000001104246641",
  9146. Info: "2208",
  9147. }
  9148. customData = append(customData, custom5)
  9149. custom6 := &CustomData{
  9150. MsgId: "H44022900158202103301718096755",
  9151. PsnNo: "44020000001102211860",
  9152. Info: "2208",
  9153. }
  9154. customData = append(customData, custom6)
  9155. custom7 := &CustomData{
  9156. MsgId: "H44022900158202103301736551640",
  9157. PsnNo: "44020000001102687718",
  9158. Info: "2208",
  9159. }
  9160. customData = append(customData, custom7)
  9161. custom8 := &CustomData{
  9162. MsgId: "H44022900158202103301743097676",
  9163. PsnNo: "44020000001102127785",
  9164. Info: "2208",
  9165. }
  9166. customData = append(customData, custom8)
  9167. custom9 := &CustomData{
  9168. MsgId: "H44022900158202103301712304203",
  9169. PsnNo: "44020000001101518097",
  9170. Info: "2208",
  9171. }
  9172. customData = append(customData, custom9)
  9173. custom10 := &CustomData{
  9174. MsgId: "H44022900158202103301738448785",
  9175. PsnNo: "44020000001100500813",
  9176. Info: "2208",
  9177. }
  9178. customData = append(customData, custom10)
  9179. custom11 := &CustomData{
  9180. MsgId: "H44022900158202103301732455843",
  9181. PsnNo: "44020000001102690557",
  9182. Info: "2208",
  9183. }
  9184. customData = append(customData, custom11)
  9185. custom12 := &CustomData{
  9186. MsgId: "H44022900158202103301745421708",
  9187. PsnNo: "44020000001102211928",
  9188. Info: "2208",
  9189. }
  9190. customData = append(customData, custom12)
  9191. custom1212 := &CustomData{
  9192. MsgId: "H440229001582021033017351627",
  9193. PsnNo: "44020000001102481733",
  9194. Info: "2208",
  9195. }
  9196. customData = append(customData, custom1212)
  9197. custom13 := &CustomData{
  9198. MsgId: "H44022900158202103301740327951",
  9199. PsnNo: "44020000001103174866",
  9200. Info: "2208",
  9201. }
  9202. customData = append(customData, custom13)
  9203. custom14 := &CustomData{
  9204. MsgId: "H4402290015820210330174922668",
  9205. PsnNo: "44020000001102927272",
  9206. Info: "2208",
  9207. }
  9208. customData = append(customData, custom14)
  9209. custom15 := &CustomData{
  9210. MsgId: "H44022900158202103301752362273",
  9211. PsnNo: "44020000001102942890",
  9212. Info: "2208",
  9213. }
  9214. customData = append(customData, custom15)
  9215. custom16 := &CustomData{
  9216. MsgId: "H44022900158202103301751082917",
  9217. PsnNo: "44020000001101662162",
  9218. Info: "2208",
  9219. }
  9220. customData = append(customData, custom16)
  9221. custom17 := &CustomData{
  9222. MsgId: "H44022900158202103301754147728",
  9223. PsnNo: "44020000000229014511",
  9224. Info: "2208",
  9225. }
  9226. customData = append(customData, custom17)
  9227. adminUser := c.GetAdminUserInfo()
  9228. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9229. for _, item := range customData {
  9230. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9231. fmt.Println(result)
  9232. }
  9233. }
  9234. func PathExists(path string) (bool, error) {
  9235. _, err := os.Stat(path)
  9236. if err == nil {
  9237. return true, nil
  9238. }
  9239. if os.IsNotExist(err) {
  9240. return false, nil
  9241. }
  9242. return false, err
  9243. }
  9244. //创建文件夹
  9245. func Mkdir(dir string) {
  9246. // 创建文件夹
  9247. exist, err := PathExists(dir)
  9248. if err != nil {
  9249. fmt.Println(err.Error())
  9250. } else {
  9251. if exist {
  9252. fmt.Println(dir + "文件夹已存在!")
  9253. } else {
  9254. // 文件夹名称,权限
  9255. err := os.Mkdir(dir, os.ModePerm)
  9256. if err != nil {
  9257. fmt.Println(dir+"文件夹创建失败:", err.Error())
  9258. } else {
  9259. fmt.Println(dir + "文件夹创建成功!")
  9260. }
  9261. }
  9262. }
  9263. }
  9264. //压缩文件
  9265. func Zip(srcFile string, destZip string) error {
  9266. zipfile, err := os.Create(destZip)
  9267. if err != nil {
  9268. return err
  9269. }
  9270. defer zipfile.Close()
  9271. archive := zip.NewWriter(zipfile)
  9272. defer archive.Close()
  9273. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  9274. if err != nil {
  9275. return err
  9276. }
  9277. header, err := zip.FileInfoHeader(info)
  9278. if err != nil {
  9279. return err
  9280. }
  9281. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  9282. // header.Name = path
  9283. if info.IsDir() {
  9284. header.Name += "/"
  9285. } else {
  9286. header.Method = zip.Deflate
  9287. }
  9288. writer, err := archive.CreateHeader(header)
  9289. if err != nil {
  9290. return err
  9291. }
  9292. if !info.IsDir() {
  9293. file, err := os.Open(path)
  9294. if err != nil {
  9295. return err
  9296. }
  9297. defer file.Close()
  9298. _, err = io.Copy(writer, file)
  9299. }
  9300. return err
  9301. })
  9302. return err
  9303. }
  9304. func ReadFile(filePath string) []byte {
  9305. f, err := os.Open(filePath)
  9306. if err != nil {
  9307. fmt.Println("read file fail", err)
  9308. return nil
  9309. }
  9310. defer f.Close()
  9311. fd, err := ioutil.ReadAll(f)
  9312. if err != nil {
  9313. fmt.Println("read to fd fail", err)
  9314. return nil
  9315. }
  9316. return fd
  9317. }
  9318. func saveLog(result string, request string, infno string, desc string) {
  9319. org_id, _ := beego.AppConfig.Int64("org_id")
  9320. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  9321. dir := miConfig.OrgName + "日志"
  9322. utils.Mkdir(dir)
  9323. month := time.Unix(1557042972, 0).Format("1")
  9324. year := time.Now().Format("2006")
  9325. month = time.Now().Format("01")
  9326. day := time.Now().Format("02")
  9327. hour := time.Now().Format("15")
  9328. min := time.Now().Format("04")
  9329. sec := time.Now().Format("05")
  9330. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  9331. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  9332. file_name := file + ".txt"
  9333. file_path := miConfig.OrgName + "日志" + "/" + file_name
  9334. exist, _ := utils.PathExists(file_path)
  9335. if exist { //存在
  9336. fmt.Println("存在")
  9337. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  9338. if err != nil {
  9339. fmt.Println("read fail")
  9340. }
  9341. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  9342. n, _ := f.Seek(0, 2)
  9343. _, err = f.WriteAt([]byte(content), n)
  9344. } else { //不存在
  9345. fmt.Println("文件不存在,创建文件")
  9346. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  9347. defer f.Close()
  9348. if err != nil {
  9349. } else {
  9350. _, err = f.Write([]byte("记录日志"))
  9351. }
  9352. }
  9353. }
  9354. type Charset string
  9355. const (
  9356. UTF8 = Charset("UTF-8")
  9357. GB18030 = Charset("GB18030")
  9358. )
  9359. func ConvertToString(src string, srcCode string, tagCode string) string {
  9360. srcCoder := mahonia.NewDecoder(srcCode)
  9361. srcResult := srcCoder.ConvertString(src)
  9362. tagCoder := mahonia.NewDecoder(tagCode)
  9363. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  9364. result := string(cdata)
  9365. return result
  9366. }