his_api_controller.go 383KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516
  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 + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "operator_id=" + strconv.FormatInt(admin_user_id, 10) + "operator=" + roles.UserName
  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 + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  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. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  377. var token string
  378. var res ResultTwo //1101结果
  379. var res10265 ResultTwo10265 //1101结果
  380. var card_info string //卡信息
  381. var busi_card_info string
  382. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  383. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  384. if status == "0" { //读卡成功
  385. if card_type == "1" {
  386. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  387. result, _ := json.Marshal(respJSON)
  388. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  389. utils.ErrorLog("解析失败:%v", err)
  390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  391. return
  392. }
  393. res.ErrMsg = res10265.ErrMsg
  394. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  395. res.Infcode = infocode
  396. res.Output = res10265.Output
  397. res.InfRefmsgid = res10265.InfRefmsgid
  398. } else {
  399. //var card_info string //卡信息
  400. //var busi_card_info string
  401. token = respJSON["data"].(map[string]interface{})["token"].(string)
  402. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  403. //fmt.Println(card_info)
  404. //fmt.Println(busi_card_info)
  405. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  406. result, _ := json.Marshal(respJSON)
  407. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  408. utils.ErrorLog("解析失败:%v", err)
  409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  410. return
  411. }
  412. res.ErrMsg = res10265.ErrMsg
  413. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  414. res.Infcode = infocode
  415. res.Output = res10265.Output
  416. res.InfRefmsgid = res10265.InfRefmsgid
  417. }
  418. if res.Infcode == 0 {
  419. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  420. if err == gorm.ErrRecordNotFound {
  421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  422. return
  423. } else if err != nil {
  424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  425. return
  426. } else {
  427. if card_type == "1" {
  428. bas := strings.Split(card_info, "|")
  429. basNumber := bas[2]
  430. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  431. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  432. infoStr := string(Iinfos)
  433. idetinfoStr := string(Idetinfos)
  434. psn := &models.HisPsn{
  435. PsnNo: res.Output.Baseinfo.PsnNo,
  436. Age: res.Output.Baseinfo.Age,
  437. PatientId: patient.ID,
  438. Certno: res.Output.Baseinfo.Certno,
  439. Brdy: res.Output.Baseinfo.Brdy,
  440. Gend: res.Output.Baseinfo.Gend,
  441. Naty: res.Output.Baseinfo.Naty,
  442. PsnCertType: res.Output.Baseinfo.PsnCertType,
  443. PsnName: res.Output.Baseinfo.PsnName,
  444. Idetinfo: idetinfoStr,
  445. Insuinfo: infoStr,
  446. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  447. CardInfo: card_info,
  448. VerifyNumber: busi_card_info,
  449. }
  450. service.CreateHisPsn(psn)
  451. c.ServeSuccessJSON(map[string]interface{}{
  452. "patient": patient,
  453. "number": basNumber,
  454. })
  455. } else {
  456. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  457. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  458. infoStr := string(Iinfos)
  459. idetinfoStr := string(Idetinfos)
  460. psn := &models.HisPsn{
  461. PsnNo: res.Output.Baseinfo.PsnNo,
  462. Age: res.Output.Baseinfo.Age,
  463. PatientId: patient.ID,
  464. Certno: res.Output.Baseinfo.Certno,
  465. Brdy: res.Output.Baseinfo.Brdy,
  466. Gend: res.Output.Baseinfo.Gend,
  467. Naty: res.Output.Baseinfo.Naty,
  468. PsnCertType: res.Output.Baseinfo.PsnCertType,
  469. PsnName: res.Output.Baseinfo.PsnName,
  470. Idetinfo: idetinfoStr,
  471. Insuinfo: infoStr,
  472. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  473. CardInfo: card_info,
  474. VerifyNumber: token,
  475. }
  476. service.CreateHisPsn(psn)
  477. c.ServeSuccessJSON(map[string]interface{}{
  478. "patient": patient,
  479. "number": token,
  480. })
  481. }
  482. }
  483. } else {
  484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  485. return
  486. }
  487. } else { //读卡失败
  488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  489. return
  490. }
  491. } else {
  492. if initFlag == 0 {
  493. c.TestGetBasBaseInit()
  494. }
  495. basStr := c.GetBasBaseInfo()
  496. if len(basStr) == 0 {
  497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  498. return
  499. }
  500. fmt.Println(basStr)
  501. bas := strings.Split(basStr, "|")
  502. basNumber := bas[1]
  503. fmt.Println(basNumber)
  504. card_sn := bas[3]
  505. fmt.Println(card_sn)
  506. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  507. var dat map[string]interface{}
  508. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  509. fmt.Println(dat)
  510. } else {
  511. fmt.Println(err)
  512. }
  513. userJSONBytes, _ := json.Marshal(dat)
  514. var res ResultTwo
  515. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  516. utils.ErrorLog("解析失败:%v", err)
  517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  518. return
  519. }
  520. if res.Infcode == 0 {
  521. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  522. if err == gorm.ErrRecordNotFound {
  523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  524. return
  525. } else if err != nil {
  526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  527. return
  528. } else {
  529. c.ServeSuccessJSON(map[string]interface{}{
  530. "patient": patient,
  531. "number": basNumber,
  532. })
  533. }
  534. } else {
  535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  536. return
  537. }
  538. break
  539. }
  540. case 2:
  541. SFZStr := c.GetSFZBaseInfo()
  542. id_card_str := strings.Split(SFZStr, "^")
  543. id_card_number := id_card_str[0]
  544. card_sn := ""
  545. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  546. var dat map[string]interface{}
  547. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  548. fmt.Println(dat)
  549. } else {
  550. fmt.Println(err)
  551. }
  552. userJSONBytes, _ := json.Marshal(dat)
  553. var res ResultTwo
  554. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  555. utils.ErrorLog("解析失败:%v", err)
  556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  557. return
  558. }
  559. if res.Infcode == 0 {
  560. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  561. if err == gorm.ErrRecordNotFound {
  562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  563. return
  564. } else if err != nil {
  565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  566. return
  567. } else {
  568. c.ServeSuccessJSON(map[string]interface{}{
  569. "patient": patient,
  570. "number": id_card_number,
  571. })
  572. }
  573. } else {
  574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  575. return
  576. }
  577. break
  578. case 3:
  579. break
  580. }
  581. }
  582. var initFlag int64 = 0
  583. func (c *HisApiController) TestGetBasBaseInit() {
  584. DllDef := syscall.MustLoadDLL("SSCard.dll")
  585. Iinit := DllDef.MustFindProc("Init")
  586. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  587. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  588. if ret != 0 {
  589. fmt.Println("SSCard的报错原因:", err)
  590. fmt.Println("SSCard的运算结果为:", ret)
  591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  592. return
  593. }
  594. result := int(ret)
  595. fmt.Println("SSCard的运算结果为1:", result)
  596. initFlag = 1
  597. return
  598. }
  599. func (c *HisApiController) GetSFZBaseInfo() string {
  600. DllDef := syscall.MustLoadDLL("SSCard.dll")
  601. readCard := DllDef.MustFindProc("ReadSFZ")
  602. if readCard == nil {
  603. fmt.Println("readcard is nil")
  604. readCard = DllDef.MustFindProc("ReadSFZ")
  605. }
  606. str := make([]byte, 256)
  607. str1 := make([]byte, 256)
  608. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  609. fmt.Println(r)
  610. return string(str)
  611. }
  612. func (c *HisApiController) GetBasBaseInfo() string {
  613. DllDef := syscall.MustLoadDLL("SSCard.dll")
  614. readCard := DllDef.MustFindProc("ReadCardBas")
  615. if readCard == nil {
  616. fmt.Println("readcard is nil")
  617. readCard = DllDef.MustFindProc("ReadCardBas")
  618. }
  619. str := make([]byte, 1024)
  620. str1 := make([]byte, 1024)
  621. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  622. fmt.Println(string(str1))
  623. fmt.Println(string(str))
  624. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  625. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  626. if ret2 != 0 {
  627. return ""
  628. }
  629. return string(str)
  630. }
  631. type CustomFundPay struct {
  632. FundPayType string `json:"fund_pay_type"`
  633. FundPayamt float64 `json:"fund_payamt"`
  634. }
  635. func (c *HisApiController) GetSettleList() {
  636. order_id, _ := c.GetInt64("order_id")
  637. admin_user_id, _ := c.GetInt64("admin_user_id")
  638. order, _ := service.GetHisOrderByIDTwo(order_id)
  639. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  640. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  641. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  642. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  643. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  644. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  645. if order.ID == 0 {
  646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  647. return
  648. }
  649. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  650. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  651. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  652. fmt.Println(count)
  653. var zero string
  654. number := count + 1
  655. if number >= 1000 {
  656. zero = "0000" + strconv.FormatInt(number, 10)
  657. } else if number >= 10000 {
  658. zero = "000" + strconv.FormatInt(number, 10)
  659. } else if number >= 100000 {
  660. zero = "00" + strconv.FormatInt(number, 10)
  661. } else if number >= 1000000 {
  662. zero = "0" + strconv.FormatInt(number, 10)
  663. } else {
  664. zero = strconv.FormatInt(number, 10)
  665. }
  666. fmt.Println(zero)
  667. struct4101 := service.Struct4101{
  668. PsnNo: order.PsnNo,
  669. MdtrtId: order.MdtrtId,
  670. SetlId: order.SetlId,
  671. PsnName: order.PsnName,
  672. Gend: order.Gend,
  673. Brdy: his.Brdy,
  674. Age: his.Age,
  675. Naty: order.Naty,
  676. PatnCertType: "01",
  677. Certno: order.Certno,
  678. Prfs: "90",
  679. ConerName: roles[0].UserName,
  680. PatnRlts: "99",
  681. ConerAddr: miConfig.OrgName,
  682. ConerTel: admin.Mobile,
  683. HiType: order.Insutype,
  684. Insuplc: miConfig.InsuplcAdmdvs,
  685. MaindiagFlag: "1",
  686. BillCode: last_order.FaPiaoCode,
  687. BillNo: zero,
  688. BizSn: order.Number,
  689. PsnSelfPay: order.PsnPartAmt,
  690. PsnOwnPay: order.PsnPartAmt,
  691. AcctPay: order.AcctPay,
  692. PsnCashpay: order.PsnCashPay,
  693. HiPaymtd: "1",
  694. Hsorg: miConfig.InsuplcAdmdvs,
  695. HsorgOpter: miConfig.InsuplcAdmdvs,
  696. MedinsFillPsn: curRoles.UserName,
  697. MedinsFillDept: depart.Name,
  698. IptMedType: "2",
  699. }
  700. struct4101.SetlBegnDate = order.SetlTime
  701. struct4101.SetlEndDate = order.SetlTime
  702. time_arr := strings.Split(order.SetlTime, " ")
  703. struct4101.AdmTime = time_arr[0]
  704. struct4101.AdmEndTime = time_arr[0]
  705. var rf []CustomFundPay
  706. json.Unmarshal([]byte(order.SetlDetail), &rf)
  707. var tempFunPays []service.CustomStruct
  708. for _, item := range rf {
  709. var tempFunPay service.CustomStruct
  710. tempFunPay.FundPayamt = item.FundPayamt
  711. tempFunPay.FundPayType = item.FundPayType
  712. tempFunPays = append(tempFunPays, tempFunPay)
  713. }
  714. struct4101.CustomStruct = tempFunPays
  715. var tempDiaginfos []service.DiaginfoStructTwo
  716. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  717. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  718. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  719. var config []*models.HisXtDiagnoseConfig
  720. for _, item := range diagnosis_ids {
  721. id, _ := strconv.ParseInt(item, 10, 64)
  722. diagnosisConfig, _ := service.FindDiagnoseById(id)
  723. config = append(config, &diagnosisConfig)
  724. }
  725. for index, item := range config {
  726. if index == 0 {
  727. var tempDiaginfo service.DiaginfoStructTwo
  728. tempDiaginfo.DiagCode = item.CountryCode
  729. tempDiaginfo.DiagName = item.CountryContentName
  730. tempDiaginfo.DiagType = "1"
  731. tempDiaginfo.MaindiagFlag = "1"
  732. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  733. } else {
  734. var tempDiaginfo service.DiaginfoStructTwo
  735. tempDiaginfo.DiagCode = item.CountryCode
  736. tempDiaginfo.DiagName = item.CountryContentName
  737. tempDiaginfo.DiagType = "2"
  738. tempDiaginfo.MaindiagFlag = "0"
  739. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  740. }
  741. }
  742. struct4101.Diseinfo = tempDiaginfos
  743. sickConfigTwo, _ := service.FindSickById(his.SickType)
  744. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  745. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  746. tempOpspdiseinfo2.OprnOprtCode = ""
  747. tempOpspdiseinfo2.OprnOprtName = ""
  748. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  749. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  750. var iteminfo service.IteminfoStruct
  751. var bedCostTotal float64 = 0 //床位总费
  752. var bedCostSelfTotal float64 = 0 //床位自费
  753. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  754. var operationCostTotal float64 = 0 //手术费
  755. var operationCostSelfTotal float64 = 0 //手术费
  756. var operationCostPartSelfTotal float64 = 0 //手术费
  757. var otherCostTotal float64 = 0 //其他费用
  758. var otherCostSelfTotal float64 = 0 //其他费用
  759. var otherCostPartSelfTotal float64 = 0 //其他费用
  760. var materialCostTotal float64 = 0 //材料费
  761. var materialCostSelfTotal float64 = 0 //材料费
  762. var materialCostPartSelfTotal float64 = 0 //材料费
  763. var westernMedicineCostTotal float64 = 0 //西药费
  764. var westernMedicineCostSelfTotal float64 = 0 //西药费
  765. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  766. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  767. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  768. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  769. var checkCostTotal float64 = 0 //检查费
  770. var checkCostSelfTotal float64 = 0 //检查费
  771. var checkCostPartSelfTotal float64 = 0 //检查费
  772. var laboratoryCostTotal float64 = 0 //化验费
  773. var laboratoryCostSelfTotal float64 = 0 //化验费
  774. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  775. var treatCostTotal float64 = 0 //治疗费用
  776. var treatCostSelfTotal float64 = 0 //治疗费用
  777. var treatCostPartSelfTotal float64 = 0 //治疗费用
  778. decimal.DivisionPrecision = 2
  779. var bed_fulamt_ownpay_amt float64 = 0
  780. var operation_fulamt_ownpay_amt float64 = 0
  781. var other_fulamt_ownpay_amt float64 = 0
  782. var westernMedicine_fulamt_ownpay_amt float64 = 0
  783. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  784. var check_fulamt_ownpay_amt float64 = 0
  785. var material_fulamt_ownpay_amt float64 = 0
  786. var laboratory_fulamt_ownpay_amt float64 = 0
  787. var treat_fulamt_ownpay_amt float64 = 0
  788. var bed_claa_sunmfee float64 = 0
  789. var bed_clab_amt float64 = 0
  790. var bed_other_amt float64 = 0
  791. var operation_claa_sunmfee float64 = 0
  792. var operation_clab_amt float64 = 0
  793. var operation_other_amt float64 = 0
  794. var other_claa_sunmfee float64 = 0
  795. var other_clab_amt float64 = 0
  796. var other_other_amt float64 = 0
  797. var westernMedicine_claa_sunmfee float64 = 0
  798. var westernMedicine_clab_amt float64 = 0
  799. var westernMedicine_other_amt float64 = 0
  800. var chineseTraditional_claa_sunmfee float64 = 0
  801. var chineseTraditional_clab_amt float64 = 0
  802. var chineseTraditional_other_amt float64 = 0
  803. var check_claa_sunmfee float64 = 0
  804. var check_clab_amt float64 = 0
  805. var check_other_amt float64 = 0
  806. var material_claa_sunmfee float64 = 0
  807. var material_clab_amt float64 = 0
  808. var material_other_amt float64 = 0
  809. var laboratory_claa_sunmfee float64 = 0
  810. var laboratory_clab_amt float64 = 0
  811. var laboratory_other_amt float64 = 0
  812. var treat_claa_sunmfee float64 = 0
  813. var treat_clab_amt float64 = 0
  814. var treat_other_amt float64 = 0
  815. for _, item := range order.HisOrderInfo {
  816. if item.MedChrgitmType == "01" { //床位费
  817. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  818. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  819. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  820. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  821. if item.ChrgitmLv == "1" {
  822. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  823. }
  824. if item.ChrgitmLv == "2" {
  825. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  826. }
  827. if item.ChrgitmLv == "3" {
  828. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  829. }
  830. }
  831. if item.MedChrgitmType == "03" { //检查费
  832. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  833. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  834. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  835. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  836. if item.ChrgitmLv == "1" {
  837. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  838. }
  839. if item.ChrgitmLv == "2" {
  840. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  841. }
  842. if item.ChrgitmLv == "3" {
  843. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  844. }
  845. }
  846. if item.MedChrgitmType == "04" { //化验费
  847. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  848. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  849. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  850. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  851. if item.ChrgitmLv == "1" {
  852. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  853. }
  854. if item.ChrgitmLv == "2" {
  855. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  856. }
  857. if item.ChrgitmLv == "3" {
  858. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  859. }
  860. }
  861. if item.MedChrgitmType == "05" { //治疗费
  862. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  863. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  864. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  865. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  866. if item.ChrgitmLv == "1" {
  867. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  868. }
  869. if item.ChrgitmLv == "2" {
  870. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  871. }
  872. if item.ChrgitmLv == "3" {
  873. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  874. }
  875. }
  876. if item.MedChrgitmType == "06" { //手术费
  877. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  878. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  879. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  880. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  881. if item.ChrgitmLv == "1" {
  882. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  883. }
  884. if item.ChrgitmLv == "2" {
  885. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  886. }
  887. if item.ChrgitmLv == "3" {
  888. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  889. }
  890. }
  891. if item.MedChrgitmType == "08" { //材料费
  892. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  893. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  894. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  895. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  896. if item.ChrgitmLv == "1" {
  897. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  898. }
  899. if item.ChrgitmLv == "2" {
  900. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  901. }
  902. if item.ChrgitmLv == "3" {
  903. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  904. }
  905. }
  906. if item.MedChrgitmType == "09" { //西药费
  907. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  908. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  909. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  910. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  911. if item.ChrgitmLv == "1" {
  912. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  913. }
  914. if item.ChrgitmLv == "2" {
  915. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  916. }
  917. if item.ChrgitmLv == "3" {
  918. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  919. }
  920. }
  921. if item.MedChrgitmType == "11" { //中成费
  922. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  923. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  924. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  925. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  926. if item.ChrgitmLv == "1" {
  927. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  928. }
  929. if item.ChrgitmLv == "2" {
  930. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  931. }
  932. if item.ChrgitmLv == "3" {
  933. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  934. }
  935. }
  936. if item.MedChrgitmType == "14" { //其他费
  937. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  938. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  939. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  940. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  941. if item.ChrgitmLv == "1" {
  942. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  943. }
  944. if item.ChrgitmLv == "2" {
  945. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  946. }
  947. if item.ChrgitmLv == "3" {
  948. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  949. }
  950. }
  951. }
  952. var iteminfoStructs []service.IteminfoStruct
  953. if bedCostTotal != 0 {
  954. iteminfo.MedChrgitm = "01"
  955. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  956. iteminfo.Amt = bedCostTotal
  957. iteminfo.ClaaSumfee = bed_claa_sunmfee
  958. iteminfo.ClabAmt = bed_clab_amt
  959. iteminfo.OthAmt = bed_other_amt
  960. iteminfoStructs = append(iteminfoStructs, iteminfo)
  961. }
  962. if checkCostTotal != 0 {
  963. iteminfo.MedChrgitm = "03"
  964. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  965. iteminfo.Amt = checkCostTotal
  966. iteminfo.ClaaSumfee = check_claa_sunmfee
  967. iteminfo.ClabAmt = check_clab_amt
  968. iteminfo.OthAmt = check_other_amt
  969. iteminfoStructs = append(iteminfoStructs, iteminfo)
  970. }
  971. if laboratoryCostTotal != 0 {
  972. iteminfo.MedChrgitm = "04"
  973. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  974. iteminfo.Amt = laboratoryCostTotal
  975. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  976. iteminfo.ClabAmt = laboratory_clab_amt
  977. iteminfo.OthAmt = laboratory_other_amt
  978. iteminfoStructs = append(iteminfoStructs, iteminfo)
  979. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  980. }
  981. if treatCostTotal != 0 {
  982. iteminfo.MedChrgitm = "05"
  983. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  984. iteminfo.Amt = treatCostTotal
  985. iteminfo.ClaaSumfee = treat_claa_sunmfee
  986. iteminfo.ClabAmt = treat_clab_amt
  987. iteminfo.OthAmt = treat_other_amt
  988. iteminfoStructs = append(iteminfoStructs, iteminfo)
  989. //(struct4101.IteminfoStruct, iteminfo)
  990. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  991. }
  992. if operationCostTotal != 0 {
  993. iteminfo.MedChrgitm = "06"
  994. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  995. iteminfo.Amt = operationCostTotal
  996. iteminfo.ClaaSumfee = operation_claa_sunmfee
  997. iteminfo.ClabAmt = operation_clab_amt
  998. iteminfo.OthAmt = operation_other_amt
  999. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1000. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1001. }
  1002. if materialCostTotal != 0 {
  1003. iteminfo.MedChrgitm = "08"
  1004. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1005. iteminfo.Amt = materialCostTotal
  1006. iteminfo.ClaaSumfee = material_claa_sunmfee
  1007. iteminfo.ClabAmt = material_clab_amt
  1008. iteminfo.OthAmt = material_other_amt
  1009. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1010. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1011. }
  1012. if westernMedicineCostTotal != 0 {
  1013. iteminfo.MedChrgitm = "09"
  1014. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1015. iteminfo.Amt = westernMedicineCostTotal
  1016. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1017. iteminfo.ClabAmt = westernMedicine_clab_amt
  1018. iteminfo.OthAmt = westernMedicine_other_amt
  1019. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1020. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1021. }
  1022. if chineseTraditionalMedicineCostTotal != 0 {
  1023. iteminfo.MedChrgitm = "11"
  1024. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1025. iteminfo.Amt = westernMedicineCostTotal
  1026. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1027. iteminfo.ClabAmt = westernMedicine_clab_amt
  1028. iteminfo.OthAmt = westernMedicine_other_amt
  1029. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1030. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1031. }
  1032. if otherCostTotal != 0 {
  1033. iteminfo.MedChrgitm = "14"
  1034. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1035. iteminfo.Amt = otherCostTotal
  1036. iteminfo.ClaaSumfee = other_claa_sunmfee
  1037. iteminfo.ClabAmt = other_clab_amt
  1038. iteminfo.OthAmt = other_other_amt
  1039. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1040. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1041. }
  1042. struct4101.IteminfoStruct = iteminfoStructs
  1043. struct4101.Ntly = "中国"
  1044. struct4101.AdmCaty = "A03.06"
  1045. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1046. fmt.Println(result)
  1047. var dat map[string]interface{}
  1048. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1049. fmt.Println(dat)
  1050. } else {
  1051. fmt.Println(err)
  1052. }
  1053. userJSONBytes, _ := json.Marshal(dat)
  1054. var res ResultSeventeen
  1055. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1056. utils.ErrorLog("解析失败:%v", err)
  1057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1058. return
  1059. }
  1060. if res.Infcode != 0 {
  1061. c.ServeSuccessJSON(map[string]interface{}{
  1062. "failed_code": -10,
  1063. "msg": res.ErrMsg,
  1064. })
  1065. return
  1066. } else {
  1067. order.FaPiaoNumber = zero
  1068. order.FaPiaoCode = last_order.FaPiaoCode
  1069. service.UpdateOrder(order)
  1070. hisFundSettleListResult := &models.HisFundSettleListResult{
  1071. Number: res.Output.SetlListId,
  1072. Status: 1,
  1073. Ctime: time.Now().Unix(),
  1074. Mtime: time.Now().Unix(),
  1075. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1076. IsUpload: 1,
  1077. OrderId: order_id,
  1078. }
  1079. service.CreateUploadRecord(hisFundSettleListResult)
  1080. c.ServeSuccessJSON(map[string]interface{}{
  1081. "msg": "上传成功",
  1082. "result": hisFundSettleListResult,
  1083. })
  1084. return
  1085. }
  1086. }
  1087. func (c *HisApiController) GetSettleListHospital() {
  1088. order_id, _ := c.GetInt64("order_id")
  1089. admin_user_id, _ := c.GetInt64("admin_user_id")
  1090. order, _ := service.GetHisOrderByIDTwo(order_id)
  1091. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1092. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1093. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1094. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1095. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1096. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1097. if order.ID == 0 {
  1098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1099. return
  1100. }
  1101. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1102. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1103. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1104. fmt.Println(count)
  1105. var zero string
  1106. number := count + 1
  1107. if number >= 1000 {
  1108. zero = "0000" + strconv.FormatInt(number, 10)
  1109. } else if number >= 10000 {
  1110. zero = "000" + strconv.FormatInt(number, 10)
  1111. } else if number >= 100000 {
  1112. zero = "00" + strconv.FormatInt(number, 10)
  1113. } else if number >= 1000000 {
  1114. zero = "0" + strconv.FormatInt(number, 10)
  1115. } else {
  1116. zero = strconv.FormatInt(number, 10)
  1117. }
  1118. fmt.Println(zero)
  1119. struct4101 := service.Struct4101{
  1120. PsnNo: order.PsnNo,
  1121. MdtrtId: order.MdtrtId,
  1122. SetlId: order.SetlId,
  1123. PsnName: order.PsnName,
  1124. Gend: order.Gend,
  1125. Brdy: his.Brdy,
  1126. Age: int64(order.Age),
  1127. Naty: order.Naty,
  1128. PatnCertType: "01",
  1129. Certno: order.Certno,
  1130. Prfs: "90",
  1131. ConerName: roles[0].UserName,
  1132. PatnRlts: "99",
  1133. ConerAddr: miConfig.OrgName,
  1134. ConerTel: admin.Mobile,
  1135. HiType: order.Insutype,
  1136. Insuplc: miConfig.InsuplcAdmdvs,
  1137. MaindiagFlag: "1",
  1138. BillCode: last_order.FaPiaoCode,
  1139. BillNo: zero,
  1140. BizSn: order.Number,
  1141. PsnSelfPay: order.PsnPartAmt,
  1142. PsnOwnPay: order.PsnPartAmt,
  1143. AcctPay: order.AcctPay,
  1144. PsnCashpay: order.PsnCashPay,
  1145. HiPaymtd: "1",
  1146. Hsorg: miConfig.InsuplcAdmdvs,
  1147. HsorgOpter: miConfig.InsuplcAdmdvs,
  1148. MedinsFillPsn: curRoles.UserName,
  1149. MedinsFillDept: depart.Name,
  1150. IptMedType: "2",
  1151. AdmTime: his.InHosptialTime,
  1152. AdmEndTime: his.OutHosptialTime,
  1153. }
  1154. struct4101.SetlBegnDate = order.SetlTime
  1155. struct4101.SetlEndDate = order.SetlTime
  1156. var rf []CustomFundPay
  1157. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1158. var tempFunPays []service.CustomStruct
  1159. for _, item := range rf {
  1160. var tempFunPay service.CustomStruct
  1161. tempFunPay.FundPayamt = item.FundPayamt
  1162. tempFunPay.FundPayType = item.FundPayType
  1163. tempFunPays = append(tempFunPays, tempFunPay)
  1164. }
  1165. struct4101.CustomStruct = tempFunPays
  1166. var tempDiaginfos []service.DiaginfoStructTwo
  1167. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1168. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1169. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1170. var config []*models.HisXtDiagnoseConfig
  1171. for _, item := range diagnosis_ids {
  1172. id, _ := strconv.ParseInt(item, 10, 64)
  1173. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1174. config = append(config, &diagnosisConfig)
  1175. }
  1176. for index, item := range config {
  1177. if index == 0 {
  1178. var tempDiaginfo service.DiaginfoStructTwo
  1179. tempDiaginfo.DiagCode = item.CountryCode
  1180. tempDiaginfo.DiagName = item.CountryContentName
  1181. tempDiaginfo.DiagType = "1"
  1182. tempDiaginfo.MaindiagFlag = "1"
  1183. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1184. } else {
  1185. var tempDiaginfo service.DiaginfoStructTwo
  1186. tempDiaginfo.DiagCode = item.CountryCode
  1187. tempDiaginfo.DiagName = item.CountryContentName
  1188. tempDiaginfo.DiagType = "2"
  1189. tempDiaginfo.MaindiagFlag = "0"
  1190. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1191. }
  1192. }
  1193. struct4101.Diseinfo = tempDiaginfos
  1194. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1195. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1196. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1197. tempOpspdiseinfo2.OprnOprtCode = ""
  1198. tempOpspdiseinfo2.OprnOprtName = ""
  1199. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1200. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1201. var iteminfo service.IteminfoStruct
  1202. var bedCostTotal float64 = 0 //床位总费
  1203. var bedCostSelfTotal float64 = 0 //床位自费
  1204. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1205. var operationCostTotal float64 = 0 //手术费
  1206. var operationCostSelfTotal float64 = 0 //手术费
  1207. var operationCostPartSelfTotal float64 = 0 //手术费
  1208. var otherCostTotal float64 = 0 //其他费用
  1209. var otherCostSelfTotal float64 = 0 //其他费用
  1210. var otherCostPartSelfTotal float64 = 0 //其他费用
  1211. var materialCostTotal float64 = 0 //材料费
  1212. var materialCostSelfTotal float64 = 0 //材料费
  1213. var materialCostPartSelfTotal float64 = 0 //材料费
  1214. var westernMedicineCostTotal float64 = 0 //西药费
  1215. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1216. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1217. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1218. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1219. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1220. var checkCostTotal float64 = 0 //检查费
  1221. var checkCostSelfTotal float64 = 0 //检查费
  1222. var checkCostPartSelfTotal float64 = 0 //检查费
  1223. var laboratoryCostTotal float64 = 0 //化验费
  1224. var laboratoryCostSelfTotal float64 = 0 //化验费
  1225. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1226. var treatCostTotal float64 = 0 //治疗费用
  1227. var treatCostSelfTotal float64 = 0 //治疗费用
  1228. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1229. decimal.DivisionPrecision = 2
  1230. var bed_fulamt_ownpay_amt float64 = 0
  1231. var operation_fulamt_ownpay_amt float64 = 0
  1232. var other_fulamt_ownpay_amt float64 = 0
  1233. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1234. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1235. var check_fulamt_ownpay_amt float64 = 0
  1236. var material_fulamt_ownpay_amt float64 = 0
  1237. var laboratory_fulamt_ownpay_amt float64 = 0
  1238. var treat_fulamt_ownpay_amt float64 = 0
  1239. var bed_claa_sunmfee float64 = 0
  1240. var bed_clab_amt float64 = 0
  1241. var bed_other_amt float64 = 0
  1242. var operation_claa_sunmfee float64 = 0
  1243. var operation_clab_amt float64 = 0
  1244. var operation_other_amt float64 = 0
  1245. var other_claa_sunmfee float64 = 0
  1246. var other_clab_amt float64 = 0
  1247. var other_other_amt float64 = 0
  1248. var westernMedicine_claa_sunmfee float64 = 0
  1249. var westernMedicine_clab_amt float64 = 0
  1250. var westernMedicine_other_amt float64 = 0
  1251. var chineseTraditional_claa_sunmfee float64 = 0
  1252. var chineseTraditional_clab_amt float64 = 0
  1253. var chineseTraditional_other_amt float64 = 0
  1254. var check_claa_sunmfee float64 = 0
  1255. var check_clab_amt float64 = 0
  1256. var check_other_amt float64 = 0
  1257. var material_claa_sunmfee float64 = 0
  1258. var material_clab_amt float64 = 0
  1259. var material_other_amt float64 = 0
  1260. var laboratory_claa_sunmfee float64 = 0
  1261. var laboratory_clab_amt float64 = 0
  1262. var laboratory_other_amt float64 = 0
  1263. var treat_claa_sunmfee float64 = 0
  1264. var treat_clab_amt float64 = 0
  1265. var treat_other_amt float64 = 0
  1266. for _, item := range order.HisOrderInfo {
  1267. if item.MedChrgitmType == "01" { //床位费
  1268. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1269. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1270. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1271. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1272. if item.ChrgitmLv == "1" {
  1273. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1274. }
  1275. if item.ChrgitmLv == "2" {
  1276. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1277. }
  1278. if item.ChrgitmLv == "3" {
  1279. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1280. }
  1281. }
  1282. if item.MedChrgitmType == "03" { //检查费
  1283. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1284. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1285. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1286. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1287. if item.ChrgitmLv == "1" {
  1288. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1289. }
  1290. if item.ChrgitmLv == "2" {
  1291. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1292. }
  1293. if item.ChrgitmLv == "3" {
  1294. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1295. }
  1296. }
  1297. if item.MedChrgitmType == "04" { //化验费
  1298. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1299. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1300. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1301. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1302. if item.ChrgitmLv == "1" {
  1303. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1304. }
  1305. if item.ChrgitmLv == "2" {
  1306. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1307. }
  1308. if item.ChrgitmLv == "3" {
  1309. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1310. }
  1311. }
  1312. if item.MedChrgitmType == "05" { //治疗费
  1313. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1314. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1315. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1316. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1317. if item.ChrgitmLv == "1" {
  1318. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1319. }
  1320. if item.ChrgitmLv == "2" {
  1321. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1322. }
  1323. if item.ChrgitmLv == "3" {
  1324. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1325. }
  1326. }
  1327. if item.MedChrgitmType == "06" { //手术费
  1328. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1329. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1330. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1331. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1332. if item.ChrgitmLv == "1" {
  1333. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1334. }
  1335. if item.ChrgitmLv == "2" {
  1336. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1337. }
  1338. if item.ChrgitmLv == "3" {
  1339. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1340. }
  1341. }
  1342. if item.MedChrgitmType == "08" { //材料费
  1343. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1344. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1345. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1346. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1347. if item.ChrgitmLv == "1" {
  1348. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1349. }
  1350. if item.ChrgitmLv == "2" {
  1351. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1352. }
  1353. if item.ChrgitmLv == "3" {
  1354. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1355. }
  1356. }
  1357. if item.MedChrgitmType == "09" { //西药费
  1358. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1359. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1360. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1361. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1362. if item.ChrgitmLv == "1" {
  1363. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1364. }
  1365. if item.ChrgitmLv == "2" {
  1366. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1367. }
  1368. if item.ChrgitmLv == "3" {
  1369. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1370. }
  1371. }
  1372. if item.MedChrgitmType == "11" { //中成费
  1373. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1374. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1375. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1376. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1377. if item.ChrgitmLv == "1" {
  1378. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1379. }
  1380. if item.ChrgitmLv == "2" {
  1381. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1382. }
  1383. if item.ChrgitmLv == "3" {
  1384. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1385. }
  1386. }
  1387. if item.MedChrgitmType == "14" { //其他费
  1388. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1389. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1390. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1391. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1392. if item.ChrgitmLv == "1" {
  1393. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1394. }
  1395. if item.ChrgitmLv == "2" {
  1396. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1397. }
  1398. if item.ChrgitmLv == "3" {
  1399. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1400. }
  1401. }
  1402. }
  1403. var iteminfoStructs []service.IteminfoStruct
  1404. if bedCostTotal != 0 {
  1405. iteminfo.MedChrgitm = "01"
  1406. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1407. iteminfo.Amt = bedCostTotal
  1408. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1409. iteminfo.ClabAmt = bed_clab_amt
  1410. iteminfo.OthAmt = bed_other_amt
  1411. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1412. }
  1413. if checkCostTotal != 0 {
  1414. iteminfo.MedChrgitm = "03"
  1415. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1416. iteminfo.Amt = checkCostTotal
  1417. iteminfo.ClaaSumfee = check_claa_sunmfee
  1418. iteminfo.ClabAmt = check_clab_amt
  1419. iteminfo.OthAmt = check_other_amt
  1420. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1421. }
  1422. if laboratoryCostTotal != 0 {
  1423. iteminfo.MedChrgitm = "04"
  1424. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1425. iteminfo.Amt = laboratoryCostTotal
  1426. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1427. iteminfo.ClabAmt = laboratory_clab_amt
  1428. iteminfo.OthAmt = laboratory_other_amt
  1429. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1430. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1431. }
  1432. if treatCostTotal != 0 {
  1433. iteminfo.MedChrgitm = "05"
  1434. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1435. iteminfo.Amt = treatCostTotal
  1436. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1437. iteminfo.ClabAmt = treat_clab_amt
  1438. iteminfo.OthAmt = treat_other_amt
  1439. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1440. //(struct4101.IteminfoStruct, iteminfo)
  1441. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1442. }
  1443. if operationCostTotal != 0 {
  1444. iteminfo.MedChrgitm = "06"
  1445. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1446. iteminfo.Amt = operationCostTotal
  1447. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1448. iteminfo.ClabAmt = operation_clab_amt
  1449. iteminfo.OthAmt = operation_other_amt
  1450. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1451. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1452. }
  1453. if materialCostTotal != 0 {
  1454. iteminfo.MedChrgitm = "08"
  1455. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1456. iteminfo.Amt = materialCostTotal
  1457. iteminfo.ClaaSumfee = material_claa_sunmfee
  1458. iteminfo.ClabAmt = material_clab_amt
  1459. iteminfo.OthAmt = material_other_amt
  1460. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1461. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1462. }
  1463. if westernMedicineCostTotal != 0 {
  1464. iteminfo.MedChrgitm = "09"
  1465. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1466. iteminfo.Amt = westernMedicineCostTotal
  1467. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1468. iteminfo.ClabAmt = westernMedicine_clab_amt
  1469. iteminfo.OthAmt = westernMedicine_other_amt
  1470. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1471. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1472. }
  1473. if chineseTraditionalMedicineCostTotal != 0 {
  1474. iteminfo.MedChrgitm = "11"
  1475. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1476. iteminfo.Amt = westernMedicineCostTotal
  1477. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1478. iteminfo.ClabAmt = westernMedicine_clab_amt
  1479. iteminfo.OthAmt = westernMedicine_other_amt
  1480. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1481. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1482. }
  1483. if otherCostTotal != 0 {
  1484. iteminfo.MedChrgitm = "14"
  1485. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1486. iteminfo.Amt = otherCostTotal
  1487. iteminfo.ClaaSumfee = other_claa_sunmfee
  1488. iteminfo.ClabAmt = other_clab_amt
  1489. iteminfo.OthAmt = other_other_amt
  1490. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1491. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1492. }
  1493. struct4101.IteminfoStruct = iteminfoStructs
  1494. struct4101.Ntly = "中国"
  1495. struct4101.AdmCaty = "A03.06"
  1496. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1497. fmt.Println(result)
  1498. var dat map[string]interface{}
  1499. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1500. fmt.Println(dat)
  1501. } else {
  1502. fmt.Println(err)
  1503. }
  1504. userJSONBytes, _ := json.Marshal(dat)
  1505. var res ResultSeventeen
  1506. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1507. utils.ErrorLog("解析失败:%v", err)
  1508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1509. return
  1510. }
  1511. if res.Infcode != 0 {
  1512. c.ServeSuccessJSON(map[string]interface{}{
  1513. "failed_code": -10,
  1514. "msg": res.ErrMsg,
  1515. })
  1516. return
  1517. } else {
  1518. order.FaPiaoNumber = zero
  1519. order.FaPiaoCode = last_order.FaPiaoCode
  1520. service.UpdateOrder(order)
  1521. hisFundSettleListResult := &models.HisFundSettleListResult{
  1522. Number: res.Output.SetlListId,
  1523. Status: 1,
  1524. Ctime: time.Now().Unix(),
  1525. Mtime: time.Now().Unix(),
  1526. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1527. IsUpload: 1,
  1528. OrderId: order_id,
  1529. }
  1530. service.CreateUploadRecord(hisFundSettleListResult)
  1531. c.ServeSuccessJSON(map[string]interface{}{
  1532. "msg": "上传成功",
  1533. "result": hisFundSettleListResult,
  1534. })
  1535. return
  1536. }
  1537. }
  1538. func (c *HisApiController) GetBatchSettleList() {
  1539. orders, _ := service.GetAllHisOrder(10106)
  1540. for _, item := range orders {
  1541. order_id := item.ID
  1542. order, _ := service.GetHisOrderByIDTwo(order_id)
  1543. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1544. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1545. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1546. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  1547. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1548. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1549. if order.ID == 0 {
  1550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1551. return
  1552. }
  1553. if his.BalanceAccountsType == 2 {
  1554. continue
  1555. }
  1556. struct4101 := service.Struct4101{
  1557. PsnNo: order.PsnNo,
  1558. MdtrtId: order.MdtrtId,
  1559. SetlId: order.SetlId,
  1560. PsnName: order.PsnName,
  1561. Gend: order.Gend,
  1562. Brdy: his.Brdy,
  1563. Age: his.Age,
  1564. Naty: order.Naty,
  1565. PatnCertType: "01",
  1566. Certno: order.Certno,
  1567. Prfs: "90",
  1568. ConerName: roles[0].UserName,
  1569. PatnRlts: "99",
  1570. ConerAddr: miConfig.OrgName,
  1571. ConerTel: admin.Mobile,
  1572. HiType: order.Insutype,
  1573. Insuplc: his.InsuplcAdmdvs,
  1574. MaindiagFlag: "1",
  1575. BillCode: order.FaPiaoCode,
  1576. BillNo: order.FaPiaoNumber,
  1577. BizSn: order.Number,
  1578. PsnSelfPay: order.PsnPartAmt,
  1579. PsnOwnPay: order.PsnPartAmt,
  1580. AcctPay: order.AcctPay,
  1581. PsnCashpay: order.PsnCashPay,
  1582. HiPaymtd: "1",
  1583. Hsorg: his.InsuplcAdmdvs,
  1584. HsorgOpter: his.InsuplcAdmdvs,
  1585. MedinsFillPsn: curRoles.UserName,
  1586. MedinsFillDept: depart.Name,
  1587. IptMedType: "2",
  1588. }
  1589. struct4101.SetlBegnDate = order.SetlTime
  1590. struct4101.SetlEndDate = order.SetlTime
  1591. //if order.SettleType == 1 {
  1592. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  1593. // dateStr := t.Format("2006-01-02")
  1594. // struct4101.SetlBegnDate = dateStr
  1595. // struct4101.SetlEndDate = dateStr
  1596. //} else {
  1597. // t := time.Unix(int64(order.SettleStartTime), 0)
  1598. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  1599. // dateStartStr := t.Format("2006-01-02")
  1600. // dateEndStr := t2.Format("2006-01-02")
  1601. // struct4101.SetlBegnDate = dateStartStr
  1602. // struct4101.SetlEndDate = dateEndStr
  1603. //}
  1604. var rf []CustomFundPay
  1605. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1606. var tempFunPays []service.CustomStruct
  1607. var tempFunPay610100 service.CustomStruct
  1608. for _, item := range rf {
  1609. if item.FundPayType == "610100" {
  1610. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  1611. tempFunPay610100.FundPayType = item.FundPayType
  1612. } else {
  1613. var tempFunPay service.CustomStruct
  1614. tempFunPay.FundPayamt = item.FundPayamt
  1615. tempFunPay.FundPayType = item.FundPayType
  1616. tempFunPays = append(tempFunPays, tempFunPay)
  1617. }
  1618. }
  1619. tempFunPays = append(tempFunPays, tempFunPay610100)
  1620. struct4101.CustomStruct = tempFunPays
  1621. var tempDiaginfos []service.DiaginfoStructTwo
  1622. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1623. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1624. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1625. var config []*models.HisXtDiagnoseConfig
  1626. for _, item := range diagnosis_ids {
  1627. id, _ := strconv.ParseInt(item, 10, 64)
  1628. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1629. config = append(config, &diagnosisConfig)
  1630. }
  1631. for index, item := range config {
  1632. if index == 0 {
  1633. var tempDiaginfo service.DiaginfoStructTwo
  1634. tempDiaginfo.DiagCode = item.CountryCode
  1635. tempDiaginfo.DiagName = item.CountryContentName
  1636. tempDiaginfo.DiagType = "1"
  1637. tempDiaginfo.MaindiagFlag = "1"
  1638. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1639. } else {
  1640. var tempDiaginfo service.DiaginfoStructTwo
  1641. tempDiaginfo.DiagCode = item.CountryCode
  1642. tempDiaginfo.DiagName = item.CountryContentName
  1643. tempDiaginfo.DiagType = "2"
  1644. tempDiaginfo.MaindiagFlag = "0"
  1645. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1646. }
  1647. }
  1648. struct4101.Diseinfo = tempDiaginfos
  1649. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1650. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1651. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1652. tempOpspdiseinfo2.OprnOprtCode = ""
  1653. tempOpspdiseinfo2.OprnOprtName = ""
  1654. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1655. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1656. var iteminfo service.IteminfoStruct
  1657. var bedCostTotal float64 = 0 //床位总费
  1658. var bedCostSelfTotal float64 = 0 //床位自费
  1659. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1660. var examineCostTotal float64 = 0 //诊查总费
  1661. var examineCostSelfTotal float64 = 0 //诊查自费
  1662. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  1663. var nursingCostTotal float64 = 0 //护理总费
  1664. var nursingCostSelfTotal float64 = 0 //护理自费
  1665. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  1666. var chineseMedicineCostTotal float64 = 0 //中成药
  1667. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  1668. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  1669. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  1670. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  1671. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  1672. var registerCostTotal float64 = 0 //一般诊疗费
  1673. var registerCostSelfTotal float64 = 0 //一般诊疗费
  1674. var registerPartSelfTotal float64 = 0 //一般诊疗费
  1675. var operationCostTotal float64 = 0 //手术费
  1676. var operationCostSelfTotal float64 = 0 //手术费
  1677. var operationCostPartSelfTotal float64 = 0 //手术费
  1678. var otherCostTotal float64 = 0 //其他费用
  1679. var otherCostSelfTotal float64 = 0 //其他费用
  1680. var otherCostPartSelfTotal float64 = 0 //其他费用
  1681. var materialCostTotal float64 = 0 //材料费
  1682. var materialCostSelfTotal float64 = 0 //材料费
  1683. var materialCostPartSelfTotal float64 = 0 //材料费
  1684. var westernMedicineCostTotal float64 = 0 //西药费
  1685. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1686. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1687. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1688. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1689. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1690. var checkCostTotal float64 = 0 //检查费
  1691. var checkCostSelfTotal float64 = 0 //检查费
  1692. var checkCostPartSelfTotal float64 = 0 //检查费
  1693. var laboratoryCostTotal float64 = 0 //化验费
  1694. var laboratoryCostSelfTotal float64 = 0 //化验费
  1695. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1696. var treatCostTotal float64 = 0 //治疗费用
  1697. var treatCostSelfTotal float64 = 0 //治疗费用
  1698. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1699. decimal.DivisionPrecision = 2
  1700. var bed_fulamt_ownpay_amt float64 = 0
  1701. var examine_fulamt_ownpay_amt float64 = 0
  1702. var nursing_fulamt_ownpay_amt float64 = 0
  1703. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  1704. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  1705. var register_fulamt_ownpay_amt float64 = 0
  1706. var operation_fulamt_ownpay_amt float64 = 0
  1707. var other_fulamt_ownpay_amt float64 = 0
  1708. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1709. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1710. var check_fulamt_ownpay_amt float64 = 0
  1711. var material_fulamt_ownpay_amt float64 = 0
  1712. var laboratory_fulamt_ownpay_amt float64 = 0
  1713. var treat_fulamt_ownpay_amt float64 = 0
  1714. var bed_claa_sunmfee float64 = 0
  1715. var bed_clab_amt float64 = 0
  1716. var bed_other_amt float64 = 0
  1717. var examine_claa_sunmfee float64 = 0
  1718. var examine_clab_amt float64 = 0
  1719. var examine_other_amt float64 = 0
  1720. var nursing_claa_sunmfee float64 = 0
  1721. var nursing_clab_amt float64 = 0
  1722. var nursing_other_amt float64 = 0
  1723. var chinese_medicine_claa_sunmfee float64 = 0
  1724. var chinese_medicine_clab_amt float64 = 0
  1725. var chinese_medicine_other_amt float64 = 0
  1726. var commonly_treatment_claa_sunmfee float64 = 0
  1727. var commonly_treatment_clab_amt float64 = 0
  1728. var commonly_treatment_other_amt float64 = 0
  1729. var operation_claa_sunmfee float64 = 0
  1730. var operation_clab_amt float64 = 0
  1731. var operation_other_amt float64 = 0
  1732. var other_claa_sunmfee float64 = 0
  1733. var other_clab_amt float64 = 0
  1734. var other_other_amt float64 = 0
  1735. var westernMedicine_claa_sunmfee float64 = 0
  1736. var westernMedicine_clab_amt float64 = 0
  1737. var westernMedicine_other_amt float64 = 0
  1738. var chineseTraditional_claa_sunmfee float64 = 0
  1739. var chineseTraditional_clab_amt float64 = 0
  1740. var chineseTraditional_other_amt float64 = 0
  1741. var check_claa_sunmfee float64 = 0
  1742. var check_clab_amt float64 = 0
  1743. var check_other_amt float64 = 0
  1744. var material_claa_sunmfee float64 = 0
  1745. var material_clab_amt float64 = 0
  1746. var material_other_amt float64 = 0
  1747. var laboratory_claa_sunmfee float64 = 0
  1748. var laboratory_clab_amt float64 = 0
  1749. var laboratory_other_amt float64 = 0
  1750. var treat_claa_sunmfee float64 = 0
  1751. var treat_clab_amt float64 = 0
  1752. var treat_other_amt float64 = 0
  1753. var register_claa_sunmfee float64 = 0
  1754. var register_clab_amt float64 = 0
  1755. var register_other_amt float64 = 0
  1756. for _, item := range order.HisOrderInfo {
  1757. if item.MedChrgitmType == "01" { //床位费
  1758. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1759. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1760. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1761. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1762. if item.ChrgitmLv == "1" {
  1763. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1764. }
  1765. if item.ChrgitmLv == "2" {
  1766. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1767. }
  1768. if item.ChrgitmLv == "3" {
  1769. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1770. }
  1771. }
  1772. if item.MedChrgitmType == "02" { //诊查
  1773. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1774. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1775. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1776. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1777. if item.ChrgitmLv == "1" {
  1778. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1779. }
  1780. if item.ChrgitmLv == "2" {
  1781. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1782. }
  1783. if item.ChrgitmLv == "3" {
  1784. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1785. }
  1786. }
  1787. if item.MedChrgitmType == "03" { //检查费
  1788. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1789. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1790. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1791. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1792. if item.ChrgitmLv == "1" {
  1793. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1794. }
  1795. if item.ChrgitmLv == "2" {
  1796. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1797. }
  1798. if item.ChrgitmLv == "3" {
  1799. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1800. }
  1801. }
  1802. if item.MedChrgitmType == "04" { //化验费
  1803. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1804. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1805. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1806. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1807. if item.ChrgitmLv == "1" {
  1808. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1809. }
  1810. if item.ChrgitmLv == "2" {
  1811. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1812. }
  1813. if item.ChrgitmLv == "3" {
  1814. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1815. }
  1816. }
  1817. if item.MedChrgitmType == "05" { //治疗费
  1818. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1819. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1820. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1821. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1822. if item.ChrgitmLv == "1" {
  1823. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1824. }
  1825. if item.ChrgitmLv == "2" {
  1826. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1827. }
  1828. if item.ChrgitmLv == "3" {
  1829. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1830. }
  1831. }
  1832. if item.MedChrgitmType == "06" { //手术费
  1833. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1834. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1835. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1836. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1837. if item.ChrgitmLv == "1" {
  1838. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1839. }
  1840. if item.ChrgitmLv == "2" {
  1841. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1842. }
  1843. if item.ChrgitmLv == "3" {
  1844. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1845. }
  1846. }
  1847. if item.MedChrgitmType == "07" { //手术费
  1848. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1849. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1850. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1851. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1852. if item.ChrgitmLv == "1" {
  1853. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1854. }
  1855. if item.ChrgitmLv == "2" {
  1856. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1857. }
  1858. if item.ChrgitmLv == "3" {
  1859. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1860. }
  1861. }
  1862. if item.MedChrgitmType == "08" { //材料费
  1863. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1864. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1865. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1866. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1867. if item.ChrgitmLv == "1" {
  1868. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1869. }
  1870. if item.ChrgitmLv == "2" {
  1871. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1872. }
  1873. if item.ChrgitmLv == "3" {
  1874. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1875. }
  1876. }
  1877. if item.MedChrgitmType == "09" { //西药费
  1878. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1879. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1880. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1881. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1882. if item.ChrgitmLv == "1" {
  1883. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1884. }
  1885. if item.ChrgitmLv == "2" {
  1886. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1887. }
  1888. if item.ChrgitmLv == "3" {
  1889. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1890. }
  1891. }
  1892. if item.MedChrgitmType == "10" { //中药饮片
  1893. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1894. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1895. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1896. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1897. if item.ChrgitmLv == "1" {
  1898. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1899. }
  1900. if item.ChrgitmLv == "2" {
  1901. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1902. }
  1903. if item.ChrgitmLv == "3" {
  1904. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1905. }
  1906. }
  1907. if item.MedChrgitmType == "11" { //中成费
  1908. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1909. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1910. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1911. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1912. if item.ChrgitmLv == "1" {
  1913. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1914. }
  1915. if item.ChrgitmLv == "2" {
  1916. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1917. }
  1918. if item.ChrgitmLv == "3" {
  1919. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1920. }
  1921. }
  1922. if item.MedChrgitmType == "12" { //中成费
  1923. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1924. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1925. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1926. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1927. if item.ChrgitmLv == "1" {
  1928. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1929. }
  1930. if item.ChrgitmLv == "2" {
  1931. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1932. }
  1933. if item.ChrgitmLv == "3" {
  1934. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1935. }
  1936. }
  1937. if item.MedChrgitmType == "13" { //中成费
  1938. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1939. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1940. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1941. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1942. if item.ChrgitmLv == "1" {
  1943. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1944. }
  1945. if item.ChrgitmLv == "2" {
  1946. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1947. }
  1948. if item.ChrgitmLv == "3" {
  1949. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1950. }
  1951. }
  1952. if item.MedChrgitmType == "14" { //其他费
  1953. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1954. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1955. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1956. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1957. if item.ChrgitmLv == "1" {
  1958. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1959. }
  1960. if item.ChrgitmLv == "2" {
  1961. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1962. }
  1963. if item.ChrgitmLv == "3" {
  1964. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1965. }
  1966. }
  1967. }
  1968. var iteminfoStructs []service.IteminfoStruct
  1969. if bedCostTotal != 0 {
  1970. iteminfo.MedChrgitm = "01"
  1971. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1972. iteminfo.Amt = bedCostTotal
  1973. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1974. iteminfo.ClabAmt = bed_clab_amt
  1975. iteminfo.OthAmt = bed_other_amt
  1976. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1977. }
  1978. if examineCostTotal != 0 {
  1979. iteminfo.MedChrgitm = "02"
  1980. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  1981. iteminfo.Amt = examineCostTotal
  1982. iteminfo.ClaaSumfee = examine_claa_sunmfee
  1983. iteminfo.ClabAmt = examine_clab_amt
  1984. iteminfo.OthAmt = examine_other_amt
  1985. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1986. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1987. }
  1988. if checkCostTotal != 0 {
  1989. iteminfo.MedChrgitm = "03"
  1990. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1991. iteminfo.Amt = checkCostTotal
  1992. iteminfo.ClaaSumfee = check_claa_sunmfee
  1993. iteminfo.ClabAmt = check_clab_amt
  1994. iteminfo.OthAmt = check_other_amt
  1995. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1996. }
  1997. if laboratoryCostTotal != 0 {
  1998. iteminfo.MedChrgitm = "04"
  1999. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2000. iteminfo.Amt = laboratoryCostTotal
  2001. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2002. iteminfo.ClabAmt = laboratory_clab_amt
  2003. iteminfo.OthAmt = laboratory_other_amt
  2004. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2005. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2006. }
  2007. if treatCostTotal != 0 {
  2008. iteminfo.MedChrgitm = "05"
  2009. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2010. iteminfo.Amt = treatCostTotal
  2011. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2012. iteminfo.ClabAmt = treat_clab_amt
  2013. iteminfo.OthAmt = treat_other_amt
  2014. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2015. //(struct4101.IteminfoStruct, iteminfo)
  2016. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2017. }
  2018. if operationCostTotal != 0 {
  2019. iteminfo.MedChrgitm = "06"
  2020. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2021. iteminfo.Amt = operationCostTotal
  2022. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2023. iteminfo.ClabAmt = operation_clab_amt
  2024. iteminfo.OthAmt = operation_other_amt
  2025. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2026. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2027. }
  2028. if nursingCostTotal != 0 {
  2029. iteminfo.MedChrgitm = "07"
  2030. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  2031. iteminfo.Amt = nursingCostTotal
  2032. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  2033. iteminfo.ClabAmt = nursing_clab_amt
  2034. iteminfo.OthAmt = nursing_other_amt
  2035. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2036. }
  2037. if materialCostTotal != 0 {
  2038. iteminfo.MedChrgitm = "08"
  2039. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2040. iteminfo.Amt = materialCostTotal
  2041. iteminfo.ClaaSumfee = material_claa_sunmfee
  2042. iteminfo.ClabAmt = material_clab_amt
  2043. iteminfo.OthAmt = material_other_amt
  2044. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2045. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2046. }
  2047. if westernMedicineCostTotal != 0 {
  2048. iteminfo.MedChrgitm = "09"
  2049. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2050. iteminfo.Amt = westernMedicineCostTotal
  2051. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2052. iteminfo.ClabAmt = westernMedicine_clab_amt
  2053. iteminfo.OthAmt = westernMedicine_other_amt
  2054. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2055. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2056. }
  2057. if chineseMedicineCostTotal != 0 {
  2058. iteminfo.MedChrgitm = "10"
  2059. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2060. iteminfo.Amt = chineseMedicineCostTotal
  2061. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2062. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2063. iteminfo.OthAmt = chinese_medicine_other_amt
  2064. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2065. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2066. }
  2067. if chineseTraditionalMedicineCostTotal != 0 {
  2068. iteminfo.MedChrgitm = "11"
  2069. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2070. iteminfo.Amt = westernMedicineCostTotal
  2071. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2072. iteminfo.ClabAmt = westernMedicine_clab_amt
  2073. iteminfo.OthAmt = westernMedicine_other_amt
  2074. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2075. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2076. }
  2077. if commonlyTreatmentCostTotal != 0 {
  2078. iteminfo.MedChrgitm = "12"
  2079. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2080. iteminfo.Amt = commonlyTreatmentCostTotal
  2081. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2082. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2083. iteminfo.OthAmt = commonly_treatment_other_amt
  2084. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2085. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2086. }
  2087. if registerCostTotal != 0 {
  2088. iteminfo.MedChrgitm = "13"
  2089. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2090. iteminfo.Amt = registerCostTotal
  2091. iteminfo.ClaaSumfee = register_claa_sunmfee
  2092. iteminfo.ClabAmt = register_clab_amt
  2093. iteminfo.OthAmt = register_other_amt
  2094. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2095. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2096. }
  2097. if otherCostTotal != 0 {
  2098. iteminfo.MedChrgitm = "14"
  2099. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2100. iteminfo.Amt = otherCostTotal
  2101. iteminfo.ClaaSumfee = other_claa_sunmfee
  2102. iteminfo.ClabAmt = other_clab_amt
  2103. iteminfo.OthAmt = other_other_amt
  2104. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2105. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2106. }
  2107. struct4101.IteminfoStruct = iteminfoStructs
  2108. struct4101.Ntly = "中国"
  2109. struct4101.AdmCaty = "A03.06"
  2110. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  2111. fmt.Println(result)
  2112. var dat map[string]interface{}
  2113. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2114. fmt.Println(dat)
  2115. } else {
  2116. fmt.Println(err)
  2117. }
  2118. userJSONBytes, _ := json.Marshal(dat)
  2119. var res ResultSeventeen
  2120. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2121. utils.ErrorLog("解析失败:%v", err)
  2122. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2123. adminUser := c.GetAdminUserInfo()
  2124. errlog := &models.HisOrderError{
  2125. UserOrgId: adminUser.CurrentOrgId,
  2126. Ctime: time.Now().Unix(),
  2127. Mtime: time.Now().Unix(),
  2128. ErrMsg: res.ErrMsg + "解析失败",
  2129. Status: 1,
  2130. PatientId: order_id,
  2131. Stage: 10106,
  2132. }
  2133. service.CreateErrMsgLog(errlog)
  2134. continue
  2135. }
  2136. if res.Infcode != 0 {
  2137. adminUser := c.GetAdminUserInfo()
  2138. errlog := &models.HisOrderError{
  2139. UserOrgId: adminUser.CurrentOrgId,
  2140. Ctime: time.Now().Unix(),
  2141. Mtime: time.Now().Unix(),
  2142. ErrMsg: res.ErrMsg,
  2143. Status: 1,
  2144. PatientId: order_id,
  2145. Stage: 10106,
  2146. }
  2147. service.CreateErrMsgLog(errlog)
  2148. continue
  2149. } else {
  2150. hisFundSettleListResult := &models.HisFundSettleListResult{
  2151. Number: res.Output.SetlListId,
  2152. Status: 1,
  2153. Ctime: time.Now().Unix(),
  2154. Mtime: time.Now().Unix(),
  2155. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2156. IsUpload: 1,
  2157. OrderId: order_id,
  2158. }
  2159. service.CreateUploadRecord(hisFundSettleListResult)
  2160. continue
  2161. }
  2162. }
  2163. }
  2164. func (c *HisApiController) GetOrgInfo() {
  2165. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2166. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2167. }
  2168. func (c *HisApiController) GetHisPatientInfo() {
  2169. medical_insurance_card := c.GetString("medical_insurance_card")
  2170. id_card_type, _ := c.GetInt64("id_card_type")
  2171. id_card := c.GetString("id_card")
  2172. adminInfo := c.GetAdminUserInfo()
  2173. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2174. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2175. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2176. IdCardNo := ""
  2177. if id_card_type == 1 {
  2178. IdCardNo = medical_insurance_card
  2179. } else if id_card_type == 2 {
  2180. IdCardNo = id_card
  2181. }
  2182. if config.IsOpen == 1 {
  2183. 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
  2184. resp, requestErr := http.Get(api)
  2185. if requestErr != nil {
  2186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2187. return
  2188. }
  2189. defer resp.Body.Close()
  2190. body, ioErr := ioutil.ReadAll(resp.Body)
  2191. if ioErr != nil {
  2192. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2194. return
  2195. }
  2196. var respJSON map[string]interface{}
  2197. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2198. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2200. return
  2201. }
  2202. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2203. userJSONBytes, _ := json.Marshal(userJSON)
  2204. var res ResultTwo
  2205. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2206. utils.ErrorLog("解析失败:%v", err)
  2207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2208. return
  2209. }
  2210. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2211. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2212. infoStr := string(Iinfos)
  2213. idetinfoStr := string(Idetinfos)
  2214. if res.Infcode == 0 {
  2215. his := models.VMHisPatient{
  2216. Status: 1,
  2217. Ctime: time.Now().Unix(),
  2218. Mtime: time.Now().Unix(),
  2219. PsnNo: res.Output.Baseinfo.PsnNo,
  2220. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2221. Certno: res.Output.Baseinfo.Certno,
  2222. PsnName: res.Output.Baseinfo.PsnName,
  2223. Gend: res.Output.Baseinfo.Gend,
  2224. Naty: res.Output.Baseinfo.Naty,
  2225. Brdy: res.Output.Baseinfo.Brdy,
  2226. Age: res.Output.Baseinfo.Age,
  2227. Iinfo: infoStr,
  2228. Idetinfo: idetinfoStr,
  2229. UserOrgId: adminInfo.CurrentOrgId,
  2230. IsReturn: 1,
  2231. IdCardType: id_card_type,
  2232. }
  2233. c.ServeSuccessJSON(map[string]interface{}{
  2234. "info": his,
  2235. })
  2236. } else {
  2237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2238. return
  2239. }
  2240. }
  2241. }
  2242. //func GetBasBaseInfo() (jsonStr string, err error) {
  2243. //
  2244. // handle := syscall.NewLazyDLL("SSCard.dll")
  2245. // add := handle.NewProc("ReadCardBas")
  2246. // str := make([]byte, 1024)
  2247. // str1 := make([]byte, 1024)
  2248. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2249. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  2250. //
  2251. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  2252. //
  2253. // fmt.Println("> Add(4,5)的结果为:", ret)
  2254. // handle.Release()
  2255. //
  2256. // return "", nil
  2257. //
  2258. //}
  2259. //func GetQRBaseInfo() (jsonStr string, err error) {
  2260. // handle := syscall.LoadDLL("SSCard.dll")
  2261. // ReadCardBas := handle.FindProc("GetQRBase")
  2262. //
  2263. // str := make([]byte, 256)
  2264. // str1 := make([]byte, 256)
  2265. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2266. //
  2267. // fmt.Println(string(str))
  2268. // fmt.Println(r)
  2269. // return string(str), nil
  2270. //}
  2271. //func CardInit() int {
  2272. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  2273. // add := DllTestDef.MustFindProc("Init")
  2274. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2275. // if err != nil {
  2276. // fmt.Println("SSCard的运算结果为:", ret)
  2277. // }
  2278. // result := int(ret)
  2279. // return result
  2280. //}
  2281. //func CardInit() int {
  2282. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2283. // if err != nil {
  2284. // fmt.Println("SSCard的运算结果为:", ret)
  2285. // }
  2286. // fmt.Println(err)
  2287. // result := int(ret)
  2288. // return result
  2289. //}
  2290. func IntPtr(n int) uintptr {
  2291. return uintptr(n)
  2292. }
  2293. func StrPtr(s string) uintptr {
  2294. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  2295. }
  2296. type Result2001 struct {
  2297. Cainfo interface{} `json:"cainfo"`
  2298. ErrMsg string `json:"err_msg"`
  2299. InfRefmsgid string `json:"inf_refmsgid"`
  2300. Infcode int64 `json:"infcode"`
  2301. Output struct {
  2302. Trtinfo struct {
  2303. PsnNo string `json:"psn_no"`
  2304. TrtChkType string `json:"trt_chk_type"`
  2305. FundPayType string `json:"fund_pay_type"`
  2306. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2307. Begndate string `json:"begndate"`
  2308. Enddate string `json:"enddate"`
  2309. TrtChkRslt string `json:"trt_chk_rslt"`
  2310. } `json:"trtinfo"`
  2311. } `json:"output"`
  2312. RefmsgTime string `json:"refmsg_time"`
  2313. RespondTime string `json:"respond_time"`
  2314. Signtype interface{} `json:"signtype"`
  2315. WarnMsg interface{} `json:"warn_msg"`
  2316. }
  2317. type Result2001Org10265 struct {
  2318. Cainfo interface{} `json:"cainfo"`
  2319. ErrMsg string `json:"err_msg"`
  2320. InfRefmsgid string `json:"inf_refmsgid"`
  2321. Infcode string `json:"infcode"`
  2322. Output struct {
  2323. Trtinfo struct {
  2324. PsnNo string `json:"psn_no"`
  2325. TrtChkType string `json:"trt_chk_type"`
  2326. FundPayType string `json:"fund_pay_type"`
  2327. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  2328. Begndate string `json:"begndate"`
  2329. Enddate string `json:"enddate"`
  2330. TrtChkRslt string `json:"trt_chk_rslt"`
  2331. } `json:"trtinfo"`
  2332. } `json:"output"`
  2333. RefmsgTime string `json:"refmsg_time"`
  2334. RespondTime string `json:"respond_time"`
  2335. Signtype interface{} `json:"signtype"`
  2336. WarnMsg interface{} `json:"warn_msg"`
  2337. }
  2338. type ResultTwo struct {
  2339. ErrMsg string `json:"err_msg"`
  2340. InfRefmsgid string `json:"inf_refmsgid"`
  2341. Infcode int64 `json:"infcode"`
  2342. Output struct {
  2343. Baseinfo struct {
  2344. Age float64 `json:"age"`
  2345. Brdy string `json:"brdy"`
  2346. Certno string `json:"certno"`
  2347. Gend string `json:"gend"`
  2348. Naty string `json:"naty"`
  2349. PsnCertType string `json:"psn_cert_type"`
  2350. PsnName string `json:"psn_name"`
  2351. PsnNo string `json:"psn_no"`
  2352. } `json:"baseinfo"`
  2353. Idetinfo []interface{} `json:"idetinfo"`
  2354. Iinfo []struct {
  2355. Balc float64 `json:"balc"`
  2356. CvlservFlag string `json:"cvlserv_flag"`
  2357. EmpName string `json:"emp_name"`
  2358. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2359. Insutype string `json:"insutype"`
  2360. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2361. PausInsuDate string `json:"paus_insu_date"`
  2362. PsnInsuDate string `json:"psn_insu_date"`
  2363. PsnInsuStas string `json:"psn_insu_stas"`
  2364. PsnType string `json:"psn_type"`
  2365. } `json:"insuinfo"`
  2366. } `json:"output"`
  2367. RefmsgTime string `json:"refmsg_time"`
  2368. RespondTime string `json:"respond_time"`
  2369. Signtype interface{} `json:"signtype"`
  2370. WarnInfo interface{} `json:"warn_info"`
  2371. }
  2372. type ResultTwo10265 struct {
  2373. ErrMsg string `json:"err_msg"`
  2374. InfRefmsgid string `json:"inf_refmsgid"`
  2375. Infcode string `json:"infcode"`
  2376. Output struct {
  2377. Baseinfo struct {
  2378. Age float64 `json:"age"`
  2379. Brdy string `json:"brdy"`
  2380. Certno string `json:"certno"`
  2381. Gend string `json:"gend"`
  2382. Naty string `json:"naty"`
  2383. PsnCertType string `json:"psn_cert_type"`
  2384. PsnName string `json:"psn_name"`
  2385. PsnNo string `json:"psn_no"`
  2386. } `json:"baseinfo"`
  2387. Idetinfo []interface{} `json:"idetinfo"`
  2388. Iinfo []struct {
  2389. Balc float64 `json:"balc"`
  2390. CvlservFlag string `json:"cvlserv_flag"`
  2391. EmpName string `json:"emp_name"`
  2392. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2393. Insutype string `json:"insutype"`
  2394. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2395. PausInsuDate string `json:"paus_insu_date"`
  2396. PsnInsuDate string `json:"psn_insu_date"`
  2397. PsnInsuStas string `json:"psn_insu_stas"`
  2398. PsnType string `json:"psn_type"`
  2399. } `json:"insuinfo"`
  2400. } `json:"output"`
  2401. RefmsgTime string `json:"refmsg_time"`
  2402. RespondTime string `json:"respond_time"`
  2403. Signtype interface{} `json:"signtype"`
  2404. WarnInfo interface{} `json:"warn_info"`
  2405. }
  2406. type ResultThree struct {
  2407. Cainfo interface{} `json:"cainfo"`
  2408. ErrMsg string `json:"err_msg"`
  2409. InfRefmsgid string `json:"inf_refmsgid"`
  2410. Infcode int64 `json:"infcode"`
  2411. Output struct {
  2412. Data struct {
  2413. IptOtpNo string `json:"ipt_otp_no"`
  2414. MdtrtID string `json:"mdtrt_id"`
  2415. PsnNo string `json:"psn_no"`
  2416. } `json:"data"`
  2417. } `json:"output"`
  2418. RefmsgTime string `json:"refmsg_time"`
  2419. RespondTime string `json:"respond_time"`
  2420. Signtype interface{} `json:"signtype"`
  2421. WarnMsg interface{} `json:"warn_msg"`
  2422. }
  2423. type ResultThree10265 struct {
  2424. Cainfo interface{} `json:"cainfo"`
  2425. ErrMsg string `json:"err_msg"`
  2426. InfRefmsgid string `json:"inf_refmsgid"`
  2427. Infcode string `json:"infcode"`
  2428. Output struct {
  2429. Data struct {
  2430. IptOtpNo string `json:"ipt_otp_no"`
  2431. MdtrtID string `json:"mdtrt_id"`
  2432. PsnNo string `json:"psn_no"`
  2433. } `json:"data"`
  2434. } `json:"output"`
  2435. RefmsgTime string `json:"refmsg_time"`
  2436. RespondTime string `json:"respond_time"`
  2437. Signtype interface{} `json:"signtype"`
  2438. WarnMsg interface{} `json:"warn_msg"`
  2439. }
  2440. type ResultFour struct {
  2441. Cainfo string `json:"cainfo"`
  2442. ErrMsg string `json:"err_msg"`
  2443. InfRefmsgid string `json:"inf_refmsgid"`
  2444. Infcode int64 `json:"infcode"`
  2445. Output struct {
  2446. Result []struct {
  2447. BasMednFlag string `json:"bas_medn_flag"`
  2448. ChldMedcFlag string `json:"chld_medc_flag"`
  2449. ChrgitmLv string `json:"chrgitm_lv"`
  2450. Cnt float64 `json:"cnt"`
  2451. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2452. DrtReimFlag string `json:"drt_reim_flag"`
  2453. FeedetlSn string `json:"feedetl_sn"`
  2454. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2455. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2456. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2457. ListSpItemFlag string `json:"list_sp_item_flag"`
  2458. LmtUsedFlag string `json:"lmt_used_flag"`
  2459. MedChrgitmType string `json:"med_chrgitm_type"`
  2460. Memo string `json:"memo"`
  2461. OverlmtAmt float64 `json:"overlmt_amt"`
  2462. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2463. Pric float64 `json:"pric"`
  2464. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2465. SelfpayProp float64 `json:"selfpay_prop"`
  2466. } `json:"result"`
  2467. } `json:"output"`
  2468. RefmsgTime string `json:"refmsg_time"`
  2469. RespondTime string `json:"respond_time"`
  2470. Signtype string `json:"signtype"`
  2471. WarnMsg string `json:"warn_msg"`
  2472. }
  2473. type ResultFour10265 struct {
  2474. Cainfo string `json:"cainfo"`
  2475. ErrMsg string `json:"err_msg"`
  2476. InfRefmsgid string `json:"inf_refmsgid"`
  2477. Infcode string `json:"infcode"`
  2478. Output struct {
  2479. Result []struct {
  2480. BasMednFlag string `json:"bas_medn_flag"`
  2481. ChldMedcFlag string `json:"chld_medc_flag"`
  2482. ChrgitmLv string `json:"chrgitm_lv"`
  2483. Cnt float64 `json:"cnt"`
  2484. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  2485. DrtReimFlag string `json:"drt_reim_flag"`
  2486. FeedetlSn string `json:"feedetl_sn"`
  2487. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2488. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  2489. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2490. ListSpItemFlag string `json:"list_sp_item_flag"`
  2491. LmtUsedFlag string `json:"lmt_used_flag"`
  2492. MedChrgitmType string `json:"med_chrgitm_type"`
  2493. Memo string `json:"memo"`
  2494. OverlmtAmt float64 `json:"overlmt_amt"`
  2495. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2496. Pric float64 `json:"pric"`
  2497. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  2498. SelfpayProp float64 `json:"selfpay_prop"`
  2499. } `json:"result"`
  2500. } `json:"output"`
  2501. RefmsgTime string `json:"refmsg_time"`
  2502. RespondTime string `json:"respond_time"`
  2503. Signtype string `json:"signtype"`
  2504. WarnMsg string `json:"warn_msg"`
  2505. }
  2506. type ResultFive struct {
  2507. Balc float64 `json:"balc"`
  2508. CvlservFlag string `json:"cvlserv_flag"`
  2509. EmpName string `json:"emp_name"`
  2510. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  2511. Insutype string `json:"insutype"`
  2512. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  2513. PausInsuDate string `json:"paus_insu_date"`
  2514. PsnInsuDate string `json:"psn_insu_date"`
  2515. PsnInsuStas string `json:"psn_insu_stas"`
  2516. PsnType string `json:"psn_type"`
  2517. }
  2518. type ResultSix struct {
  2519. Cainfo interface{} `json:"cainfo"`
  2520. ErrMsg string `json:"err_msg"`
  2521. InfRefmsgid string `json:"inf_refmsgid"`
  2522. Infcode int64 `json:"infcode"`
  2523. Output struct {
  2524. } `json:"output"`
  2525. RefmsgTime string `json:"refmsg_time"`
  2526. RespondTime string `json:"respond_time"`
  2527. Signtype interface{} `json:"signtype"`
  2528. WarnMsg interface{} `json:"warn_msg"`
  2529. }
  2530. type ResultSix10265 struct {
  2531. Cainfo interface{} `json:"cainfo"`
  2532. ErrMsg string `json:"err_msg"`
  2533. InfRefmsgid string `json:"inf_refmsgid"`
  2534. Infcode string `json:"infcode"`
  2535. Output struct {
  2536. } `json:"output"`
  2537. RefmsgTime string `json:"refmsg_time"`
  2538. RespondTime string `json:"respond_time"`
  2539. Signtype interface{} `json:"signtype"`
  2540. WarnMsg interface{} `json:"warn_msg"`
  2541. }
  2542. type ResultSeven struct {
  2543. Cainfo string `json:"cainfo"`
  2544. ErrMsg string `json:"err_msg"`
  2545. InfRefmsgid string `json:"inf_refmsgid"`
  2546. Infcode int64 `json:"infcode"`
  2547. Output struct {
  2548. Setldetail []interface{} `json:"setldetail"`
  2549. Setlinfo struct {
  2550. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2551. AcctPay float64 `json:"acct_pay"`
  2552. ActPayDedc float64 `json:"act_pay_dedc"`
  2553. Age float64 `json:"age"`
  2554. Balc float64 `json:"balc"`
  2555. Brdy string `json:"brdy"`
  2556. Certno string `json:"certno"`
  2557. ClrOptins string `json:"clr_optins"`
  2558. ClrType string `json:"clr_type"`
  2559. ClrWay string `json:"clr_way"`
  2560. CvlservFlag string `json:"cvlserv_flag"`
  2561. CvlservPay float64 `json:"cvlserv_pay"`
  2562. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2563. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2564. Gend string `json:"gend"`
  2565. HifesPay float64 `json:"hifes_pay"`
  2566. HifmiPay float64 `json:"hifmi_pay"`
  2567. HifpPay float64 `json:"hifp_pay"`
  2568. HospPartAmt float64 `json:"hosp_part_amt"`
  2569. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2570. Insutype string `json:"insutype"`
  2571. MafPay float64 `json:"maf_pay"`
  2572. MdtrtCertType string `json:"mdtrt_cert_type"`
  2573. HifobPay float64 `json:"hifob_pay"`
  2574. MdtrtID string `json:"mdtrt_id"`
  2575. MedType string `json:"med_type"`
  2576. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2577. MedinsSetlID string `json:"medins_setl_id"`
  2578. Naty string `json:"naty"`
  2579. OthPay float64 `json:"oth_pay"`
  2580. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2581. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2582. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2583. PsnCashPay float64 `json:"psn_cash_pay"`
  2584. PsnCertType string `json:"psn_cert_type"`
  2585. PsnName string `json:"psn_name"`
  2586. PsnNo string `json:"psn_no"`
  2587. PsnPartAmt float64 `json:"psn_part_amt"`
  2588. PsnType string `json:"psn_type"`
  2589. SetlID string `json:"setl_id"`
  2590. SetlTime string `json:"setl_time"`
  2591. } `json:"setlinfo"`
  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 ResultSeven10265 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. Setldetail []interface{} `json:"setldetail"`
  2605. Setlinfo struct {
  2606. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  2607. AcctPay float64 `json:"acct_pay"`
  2608. ActPayDedc float64 `json:"act_pay_dedc"`
  2609. Age float64 `json:"age"`
  2610. Balc float64 `json:"balc"`
  2611. Brdy string `json:"brdy"`
  2612. Certno string `json:"certno"`
  2613. ClrOptins string `json:"clr_optins"`
  2614. ClrType string `json:"clr_type"`
  2615. ClrWay string `json:"clr_way"`
  2616. CvlservFlag string `json:"cvlserv_flag"`
  2617. CvlservPay float64 `json:"cvlserv_pay"`
  2618. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2619. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2620. Gend string `json:"gend"`
  2621. HifesPay float64 `json:"hifes_pay"`
  2622. HifmiPay float64 `json:"hifmi_pay"`
  2623. HifpPay float64 `json:"hifp_pay"`
  2624. HospPartAmt float64 `json:"hosp_part_amt"`
  2625. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2626. Insutype string `json:"insutype"`
  2627. MafPay float64 `json:"maf_pay"`
  2628. MdtrtCertType string `json:"mdtrt_cert_type"`
  2629. HifobPay float64 `json:"hifob_pay"`
  2630. MdtrtID string `json:"mdtrt_id"`
  2631. MedType string `json:"med_type"`
  2632. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2633. MedinsSetlID string `json:"medins_setl_id"`
  2634. Naty string `json:"naty"`
  2635. OthPay float64 `json:"oth_pay"`
  2636. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2637. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2638. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2639. PsnCashPay float64 `json:"psn_cash_pay"`
  2640. PsnCertType string `json:"psn_cert_type"`
  2641. PsnName string `json:"psn_name"`
  2642. PsnNo string `json:"psn_no"`
  2643. PsnPartAmt float64 `json:"psn_part_amt"`
  2644. PsnType string `json:"psn_type"`
  2645. SetlID string `json:"setl_id"`
  2646. SetlTime string `json:"setl_time"`
  2647. } `json:"setlinfo"`
  2648. } `json:"output"`
  2649. RefmsgTime string `json:"refmsg_time"`
  2650. RespondTime string `json:"respond_time"`
  2651. Signtype interface{} `json:"signtype"`
  2652. WarnMsg interface{} `json:"warn_msg"`
  2653. }
  2654. type ResultEight struct {
  2655. Cainfo string `json:"cainfo"`
  2656. ErrMsg string `json:"err_msg"`
  2657. InfRefmsgid string `json:"inf_refmsgid"`
  2658. Infcode int64 `json:"infcode"`
  2659. Output struct {
  2660. Stmtinfo struct {
  2661. SetlOptins string `json:"setl_optins"`
  2662. StmtRslt string `json:"stmt_rslt"`
  2663. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2664. } `json:"stmtinfo"`
  2665. } `json:"output"`
  2666. RefmsgTime string `json:"refmsg_time"`
  2667. RespondTime string `json:"respond_time"`
  2668. Signtype interface{} `json:"signtype"`
  2669. WarnMsg interface{} `json:"warn_msg"`
  2670. }
  2671. type ResultEightFor10188 struct {
  2672. Cainfo string `json:"cainfo"`
  2673. ErrMsg string `json:"err_msg"`
  2674. InfRefmsgid string `json:"inf_refmsgid"`
  2675. Infcode string `json:"infcode"`
  2676. Output struct {
  2677. Stmtinfo struct {
  2678. SetlOptins string `json:"setl_optins"`
  2679. StmtRslt string `json:"stmt_rslt"`
  2680. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  2681. } `json:"stmtinfo"`
  2682. } `json:"output"`
  2683. RefmsgTime string `json:"refmsg_time"`
  2684. RespondTime string `json:"respond_time"`
  2685. Signtype interface{} `json:"signtype"`
  2686. WarnMsg interface{} `json:"warn_msg"`
  2687. }
  2688. type ResultNine struct {
  2689. Cainfo string `json:"cainfo"`
  2690. ErrMsg string `json:"err_msg"`
  2691. InfRefmsgid string `json:"inf_refmsgid"`
  2692. Infcode int64 `json:"infcode"`
  2693. Output struct {
  2694. FileQuryNo string `json:"file_qury_no"`
  2695. } `json:"output"`
  2696. RefmsgTime string `json:"refmsg_time"`
  2697. RespondTime string `json:"respond_time"`
  2698. Signtype interface{} `json:"signtype"`
  2699. WarnMsg interface{} `json:"warn_msg"`
  2700. }
  2701. type ResultTen struct {
  2702. Cainfo string `json:"cainfo"`
  2703. ErrMsg string `json:"err_msg"`
  2704. InfRefmsgid string `json:"inf_refmsgid"`
  2705. Infcode int64 `json:"infcode"`
  2706. Output struct {
  2707. DldEndtime string `json:"dld_endtime"`
  2708. FileQuryNo string `json:"file_qury_no"`
  2709. Filename string `json:"filename"`
  2710. } `json:"output"`
  2711. RefmsgTime string `json:"refmsg_time"`
  2712. RespondTime string `json:"respond_time"`
  2713. Signtype interface{} `json:"signtype"`
  2714. WarnMsg interface{} `json:"warn_msg"`
  2715. }
  2716. //type Autogenerated struct {
  2717. // Output struct {
  2718. // Setlinfo struct {
  2719. // SetlTime string `json:"setl_time"`
  2720. // CvlservPay float64 `json:"cvlserv_pay"`
  2721. // Year string `json:"year"`
  2722. // MedType string `json:"med_type"`
  2723. // PsnPay float64 `json:"psn_pay"`
  2724. // OpterID string `json:"opter_id"`
  2725. // Begndate string `json:"begndate"`
  2726. // FlxempeFlag string `json:"flxempe_flag"`
  2727. // HifmiPay float64 `json:"hifmi_pay"`
  2728. // PsnNo string `json:"psn_no"`
  2729. // ActPayDedc float64 `json:"act_pay_dedc"`
  2730. // MedinsSetlID interface{} `json:"medins_setl_id"`
  2731. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2732. // ClrWay string `json:"clr_way"`
  2733. // OthPay float64 `json:"oth_pay"`
  2734. // Gend string `json:"gend"`
  2735. // MdtrtID string `json:"mdtrt_id"`
  2736. // AcctPay float64 `json:"acct_pay"`
  2737. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  2738. // Insutype string `json:"insutype"`
  2739. // Invono interface{} `json:"invono"`
  2740. // Enddate string `json:"enddate"`
  2741. // CashPayamt float64 `json:"cash_payamt"`
  2742. // PsnType string `json:"psn_type"`
  2743. // FixmedinsName string `json:"fixmedins_name"`
  2744. // HifpPay float64 `json:"hifp_pay"`
  2745. // NewFlag interface{} `json:"new_flag"`
  2746. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2747. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  2748. // PayLoc string `json:"pay_loc"`
  2749. // ClrType string `json:"clr_type"`
  2750. // RefdSetlFlag string `json:"refd_setl_flag"`
  2751. // CvlservFlag string `json:"cvlserv_flag"`
  2752. // EmpName string `json:"emp_name"`
  2753. // Brdy string `json:"brdy"`
  2754. // Naty string `json:"naty"`
  2755. // Certno string `json:"certno"`
  2756. // DiseCode string `json:"dise_code"`
  2757. // FixmedinsCode string `json:"fixmedins_code"`
  2758. // DedcHospLv string `json:"dedc_hosp_lv"`
  2759. // OpterName string `json:"opter_name"`
  2760. // Balc float64 `json:"balc"`
  2761. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2762. // PsnCertType string `json:"psn_cert_type"`
  2763. // HifobPay float64 `json:"hifob_pay"`
  2764. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  2765. // HifesPay float64 `json:"hifes_pay"`
  2766. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2767. // OptTime string `json:"opt_time"`
  2768. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2769. // SetlID string `json:"setl_id"`
  2770. // MafPay float64 `json:"maf_pay"`
  2771. // PsnName string `json:"psn_name"`
  2772. // InsuOptins interface{} `json:"insu_optins"`
  2773. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2774. // ClrOptins string `json:"clr_optins"`
  2775. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2776. // DiseName string `json:"dise_name"`
  2777. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2778. // Age float64 `json:"age"`
  2779. // DtrtCertType string `json:"dtrt_cert_type"`
  2780. // HospLv string `json:"hosp_lv"`
  2781. // } `json:"setlinfo"`
  2782. // Setldetail []struct {
  2783. // FundPayType string `json:"fund_pay_type"`
  2784. // FundPayamt float64 `json:"fund_payamt"`
  2785. // SetlProcInfo interface{} `json:"setl_proc_info"`
  2786. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  2787. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  2788. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  2789. // PrefFundPay interface{} `json:"pref_fund_pay"`
  2790. // } `json:"setldetail"`
  2791. // } `json:"output"`
  2792. // Infcode int `json:"infcode"`
  2793. // WarnMsg interface{} `json:"warn_msg"`
  2794. // Cainfo interface{} `json:"cainfo"`
  2795. // ErrMsg interface{} `json:"err_msg"`
  2796. // RefmsgTime string `json:"refmsg_time"`
  2797. // Signtype interface{} `json:"signtype"`
  2798. // RespondTime string `json:"respond_time"`
  2799. // InfRefmsgid string `json:"inf_refmsgid"`
  2800. //}
  2801. type ResultEleven struct {
  2802. Cainfo string `json:"cainfo"`
  2803. ErrMsg string `json:"err_msg"`
  2804. InfRefmsgid string `json:"inf_refmsgid"`
  2805. Infcode int64 `json:"infcode"`
  2806. Output struct {
  2807. Setlinfo struct {
  2808. SetlTime string `json:"setl_time"`
  2809. CvlservPay float64 `json:"cvlserv_pay"`
  2810. Year string `json:"year"`
  2811. MedType string `json:"med_type"`
  2812. PsnPay float64 `json:"psn_pay"`
  2813. OpterID string `json:"opter_id"`
  2814. Begndate string `json:"begndate"`
  2815. FlxempeFlag string `json:"flxempe_flag"`
  2816. HifmiPay float64 `json:"hifmi_pay"`
  2817. PsnNo string `json:"psn_no"`
  2818. ActPayDedc float64 `json:"act_pay_dedc"`
  2819. MedinsSetlID interface{} `json:"medins_setl_id"`
  2820. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2821. ClrWay string `json:"clr_way"`
  2822. OthPay float64 `json:"oth_pay"`
  2823. Gend string `json:"gend"`
  2824. MdtrtID string `json:"mdtrt_id"`
  2825. AcctPay float64 `json:"acct_pay"`
  2826. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2827. Insutype string `json:"insutype"`
  2828. Invono interface{} `json:"invono"`
  2829. Enddate string `json:"enddate"`
  2830. CashPayamt float64 `json:"cash_payamt"`
  2831. PsnType string `json:"psn_type"`
  2832. FixmedinsName string `json:"fixmedins_name"`
  2833. HifpPay float64 `json:"hifp_pay"`
  2834. NewFlag interface{} `json:"new_flag"`
  2835. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2836. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2837. PayLoc string `json:"pay_loc"`
  2838. ClrType string `json:"clr_type"`
  2839. RefdSetlFlag string `json:"refd_setl_flag"`
  2840. CvlservFlag string `json:"cvlserv_flag"`
  2841. EmpName string `json:"emp_name"`
  2842. Brdy string `json:"brdy"`
  2843. Naty string `json:"naty"`
  2844. Certno string `json:"certno"`
  2845. DiseCode string `json:"dise_code"`
  2846. FixmedinsCode string `json:"fixmedins_code"`
  2847. DedcHospLv string `json:"dedc_hosp_lv"`
  2848. OpterName string `json:"opter_name"`
  2849. Balc float64 `json:"balc"`
  2850. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2851. PsnCertType string `json:"psn_cert_type"`
  2852. HifobPay float64 `json:"hifob_pay"`
  2853. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2854. HifesPay float64 `json:"hifes_pay"`
  2855. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2856. OptTime string `json:"opt_time"`
  2857. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2858. SetlID string `json:"setl_id"`
  2859. MafPay float64 `json:"maf_pay"`
  2860. PsnName string `json:"psn_name"`
  2861. InsuOptins interface{} `json:"insu_optins"`
  2862. PrefFundPay interface{} `json:"pref_fund_pay"`
  2863. ClrOptins string `json:"clr_optins"`
  2864. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2865. DiseName string `json:"dise_name"`
  2866. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2867. Age float64 `json:"age"`
  2868. DtrtCertType string `json:"dtrt_cert_type"`
  2869. HospLv string `json:"hosp_lv"`
  2870. } `json:"setlinfo"`
  2871. } `json:"output"`
  2872. RefmsgTime string `json:"refmsg_time"`
  2873. RespondTime string `json:"respond_time"`
  2874. Signtype interface{} `json:"signtype"`
  2875. WarnMsg interface{} `json:"warn_msg"`
  2876. }
  2877. type ResultEleven10265 struct {
  2878. Cainfo string `json:"cainfo"`
  2879. ErrMsg string `json:"err_msg"`
  2880. InfRefmsgid string `json:"inf_refmsgid"`
  2881. Infcode string `json:"infcode"`
  2882. Output struct {
  2883. Setlinfo struct {
  2884. SetlTime string `json:"setl_time"`
  2885. CvlservPay float64 `json:"cvlserv_pay"`
  2886. Year string `json:"year"`
  2887. MedType string `json:"med_type"`
  2888. PsnPay float64 `json:"psn_pay"`
  2889. OpterID string `json:"opter_id"`
  2890. Begndate string `json:"begndate"`
  2891. FlxempeFlag string `json:"flxempe_flag"`
  2892. HifmiPay float64 `json:"hifmi_pay"`
  2893. PsnNo string `json:"psn_no"`
  2894. ActPayDedc float64 `json:"act_pay_dedc"`
  2895. MedinsSetlID interface{} `json:"medins_setl_id"`
  2896. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  2897. ClrWay string `json:"clr_way"`
  2898. OthPay float64 `json:"oth_pay"`
  2899. Gend string `json:"gend"`
  2900. MdtrtID string `json:"mdtrt_id"`
  2901. AcctPay float64 `json:"acct_pay"`
  2902. InscpScpAmt float64 `json:"inscp_scp_amt"`
  2903. Insutype string `json:"insutype"`
  2904. Invono interface{} `json:"invono"`
  2905. Enddate string `json:"enddate"`
  2906. CashPayamt float64 `json:"cash_payamt"`
  2907. PsnType string `json:"psn_type"`
  2908. FixmedinsName string `json:"fixmedins_name"`
  2909. HifpPay float64 `json:"hifp_pay"`
  2910. NewFlag interface{} `json:"new_flag"`
  2911. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  2912. PreselfpayAmt float64 `json:"preselfpay_amt"`
  2913. PayLoc string `json:"pay_loc"`
  2914. ClrType string `json:"clr_type"`
  2915. RefdSetlFlag string `json:"refd_setl_flag"`
  2916. CvlservFlag string `json:"cvlserv_flag"`
  2917. EmpName string `json:"emp_name"`
  2918. Brdy string `json:"brdy"`
  2919. Naty string `json:"naty"`
  2920. Certno string `json:"certno"`
  2921. DiseCode string `json:"dise_code"`
  2922. FixmedinsCode string `json:"fixmedins_code"`
  2923. DedcHospLv string `json:"dedc_hosp_lv"`
  2924. OpterName string `json:"opter_name"`
  2925. Balc float64 `json:"balc"`
  2926. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  2927. PsnCertType string `json:"psn_cert_type"`
  2928. HifobPay float64 `json:"hifob_pay"`
  2929. MedfeeSumamt float64 `json:"medfee_sumamt"`
  2930. HifesPay float64 `json:"hifes_pay"`
  2931. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  2932. OptTime string `json:"opt_time"`
  2933. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  2934. SetlID string `json:"setl_id"`
  2935. MafPay float64 `json:"maf_pay"`
  2936. PsnName string `json:"psn_name"`
  2937. InsuOptins interface{} `json:"insu_optins"`
  2938. PrefFundPay interface{} `json:"pref_fund_pay"`
  2939. ClrOptins string `json:"clr_optins"`
  2940. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  2941. DiseName string `json:"dise_name"`
  2942. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  2943. Age float64 `json:"age"`
  2944. DtrtCertType string `json:"dtrt_cert_type"`
  2945. HospLv string `json:"hosp_lv"`
  2946. } `json:"setlinfo"`
  2947. } `json:"output"`
  2948. RefmsgTime string `json:"refmsg_time"`
  2949. RespondTime string `json:"respond_time"`
  2950. Signtype interface{} `json:"signtype"`
  2951. WarnMsg interface{} `json:"warn_msg"`
  2952. }
  2953. type ResultTwelve struct {
  2954. Cainfo string `json:"cainfo"`
  2955. ErrMsg string `json:"err_msg"`
  2956. InfRefmsgid string `json:"inf_refmsgid"`
  2957. Infcode int64 `json:"infcode"`
  2958. Output struct {
  2959. MdtrtId string `json:"mdtrt_id"`
  2960. ChrgBchno string `json:"chrg_bchno"`
  2961. PsnNo string `json:"psn_no"`
  2962. } `json:"output"`
  2963. RefmsgTime string `json:"refmsg_time"`
  2964. RespondTime string `json:"respond_time"`
  2965. Signtype interface{} `json:"signtype"`
  2966. WarnMsg interface{} `json:"warn_msg"`
  2967. }
  2968. type ResultThirteen struct {
  2969. ErrMsg string `json:"err_msg"`
  2970. InfRefmsgid string `json:"inf_refmsgid"`
  2971. Infcode int64 `json:"infcode"`
  2972. Output struct {
  2973. Result struct {
  2974. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2975. } `json:"result"`
  2976. } `json:"output"`
  2977. RefmsgTime string `json:"refmsg_time"`
  2978. RespondTime string `json:"respond_time"`
  2979. Signtype interface{} `json:"signtype"`
  2980. WarnInfo interface{} `json:"warn_info"`
  2981. }
  2982. type ResultThirteen10265 struct {
  2983. ErrMsg string `json:"err_msg"`
  2984. InfRefmsgid string `json:"inf_refmsgid"`
  2985. Infcode string `json:"infcode"`
  2986. Output struct {
  2987. Result struct {
  2988. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  2989. } `json:"result"`
  2990. } `json:"output"`
  2991. RefmsgTime string `json:"refmsg_time"`
  2992. RespondTime string `json:"respond_time"`
  2993. Signtype interface{} `json:"signtype"`
  2994. WarnInfo interface{} `json:"warn_info"`
  2995. }
  2996. type ResultFourteen struct {
  2997. ErrMsg string `json:"err_msg"`
  2998. InfRefmsgid string `json:"inf_refmsgid"`
  2999. Infcode int64 `json:"infcode"`
  3000. Output struct {
  3001. } `json:"output"`
  3002. RefmsgTime string `json:"refmsg_time"`
  3003. RespondTime string `json:"respond_time"`
  3004. Signtype interface{} `json:"signtype"`
  3005. WarnInfo interface{} `json:"warn_info"`
  3006. }
  3007. type ResultFourteen10265 struct {
  3008. ErrMsg string `json:"err_msg"`
  3009. InfRefmsgid string `json:"inf_refmsgid"`
  3010. Infcode string `json:"infcode"`
  3011. Output struct {
  3012. } `json:"output"`
  3013. RefmsgTime string `json:"refmsg_time"`
  3014. RespondTime string `json:"respond_time"`
  3015. Signtype interface{} `json:"signtype"`
  3016. WarnInfo interface{} `json:"warn_info"`
  3017. }
  3018. type ResultSixteen struct {
  3019. Cainfo string `json:"cainfo"`
  3020. ErrMsg string `json:"err_msg"`
  3021. InfRefmsgid string `json:"inf_refmsgid"`
  3022. Infcode int64 `json:"infcode"`
  3023. Output struct {
  3024. Setldetail []interface{} `json:"setldetail"`
  3025. Setlinfo struct {
  3026. MdtrtID string `json:"mdtrt_id"`
  3027. SetlID string `json:"setl_id"`
  3028. ClrOptins string `json:"clr_optins"`
  3029. SetlTime string `json:"setl_time"`
  3030. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3031. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3032. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3033. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3034. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3035. ActPayDedc float64 `json:"act_pay_dedc"`
  3036. HifpPay float64 `json:"hifp_pay"`
  3037. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3038. Lfpay float64 `json:"selfpay"`
  3039. CvlservPay float64 `json:"cvlserv_pay"`
  3040. HifesPay float64 `json:"hifes_pay"`
  3041. HifmiPay float64 `json:"hifmi_pay"`
  3042. HifobPay float64 `json:"hifob_pay"`
  3043. MafPay float64 `json:"maf_pay"`
  3044. OthPay float64 `json:"oth_pay"`
  3045. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3046. PsnPartAmt float64 `json:"psn_part_amt"`
  3047. AcctPay float64 `json:"acct_pay"`
  3048. Balc float64 `json:"balc"`
  3049. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3050. HospPartAmt float64 `json:"hosp_part_amt"`
  3051. MedinsSetlID string `json:"medins_setl_id"`
  3052. PdnCashPay string `json:"pdn_cash_pay"`
  3053. } `json:"setlinfo"`
  3054. } `json:"output"`
  3055. RefmsgTime string `json:"refmsg_time"`
  3056. RespondTime string `json:"respond_time"`
  3057. Signtype interface{} `json:"signtype"`
  3058. WarnMsg interface{} `json:"warn_msg"`
  3059. }
  3060. type ResultSixteen10265 struct {
  3061. Cainfo string `json:"cainfo"`
  3062. ErrMsg string `json:"err_msg"`
  3063. InfRefmsgid string `json:"inf_refmsgid"`
  3064. Infcode string `json:"infcode"`
  3065. Output struct {
  3066. Setldetail []interface{} `json:"setldetail"`
  3067. Setlinfo struct {
  3068. MdtrtID string `json:"mdtrt_id"`
  3069. SetlID string `json:"setl_id"`
  3070. ClrOptins string `json:"clr_optins"`
  3071. SetlTime string `json:"setl_time"`
  3072. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3073. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3074. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3075. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3076. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3077. ActPayDedc float64 `json:"act_pay_dedc"`
  3078. HifpPay float64 `json:"hifp_pay"`
  3079. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3080. Lfpay float64 `json:"selfpay"`
  3081. CvlservPay float64 `json:"cvlserv_pay"`
  3082. HifesPay float64 `json:"hifes_pay"`
  3083. HifmiPay float64 `json:"hifmi_pay"`
  3084. HifobPay float64 `json:"hifob_pay"`
  3085. MafPay float64 `json:"maf_pay"`
  3086. OthPay float64 `json:"oth_pay"`
  3087. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3088. PsnPartAmt float64 `json:"psn_part_amt"`
  3089. AcctPay float64 `json:"acct_pay"`
  3090. Balc float64 `json:"balc"`
  3091. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3092. HospPartAmt float64 `json:"hosp_part_amt"`
  3093. MedinsSetlID string `json:"medins_setl_id"`
  3094. PdnCashPay string `json:"pdn_cash_pay"`
  3095. } `json:"setlinfo"`
  3096. } `json:"output"`
  3097. RefmsgTime string `json:"refmsg_time"`
  3098. RespondTime string `json:"respond_time"`
  3099. Signtype interface{} `json:"signtype"`
  3100. WarnMsg interface{} `json:"warn_msg"`
  3101. }
  3102. type ResultSeventeen struct {
  3103. ErrMsg string `json:"err_msg"`
  3104. InfRefmsgid string `json:"inf_refmsgid"`
  3105. Infcode int64 `json:"infcode"`
  3106. Output struct {
  3107. SetlListId string `json:"setl_list_id"`
  3108. } `json:"output"`
  3109. RefmsgTime string `json:"refmsg_time"`
  3110. RespondTime string `json:"respond_time"`
  3111. Signtype string `json:"signtype"`
  3112. WarnInfo string `json:"warn_info"`
  3113. }
  3114. type Result90991 struct {
  3115. ErrMsg string `json:"err_msg"`
  3116. InfRefmsgid string `json:"inf_refmsgid"`
  3117. Infcode int64 `json:"infcode"`
  3118. Output struct {
  3119. Result struct {
  3120. PsnNo string `json:"psn_no"`
  3121. CardStat string `json:"card_stat"`
  3122. Certno string `json:"certno"`
  3123. PsnName string `json:"psn_name"`
  3124. CheckStat string `json:"check_stat"`
  3125. } `json:"result"`
  3126. } `json:"output"`
  3127. RefmsgTime string `json:"refmsg_time"`
  3128. RespondTime string `json:"respond_time"`
  3129. Signtype interface{} `json:"signtype"`
  3130. WarnInfo interface{} `json:"warn_info"`
  3131. }
  3132. type Result90100 struct {
  3133. ErrMsg string `json:"err_msg"`
  3134. InfRefmsgid string `json:"inf_refmsgid"`
  3135. Infcode int64 `json:"infcode"`
  3136. Output struct {
  3137. PoolareaNo string `json:"poolarea_no"`
  3138. PoolareaNoName string `json:"poolarea_no_name"`
  3139. Insutype string `json:"insutype"`
  3140. InsutypeName string `json:"insutype_name"`
  3141. ClctType string `json:"clct_type"`
  3142. ClctTypeName string `json:"clct_type_name"`
  3143. ClctFlag string `json:"clct_flag"`
  3144. ClctFlagName string `json:"clct_flag_name"`
  3145. AccrymBegn string `json:"accrym_begn"`
  3146. AccrymEnd string `json:"accrym_end"`
  3147. ClctTime string `json:"clct_time"`
  3148. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3149. } `json:"output"`
  3150. RefmsgTime string `json:"refmsg_time"`
  3151. RespondTime string `json:"respond_time"`
  3152. Signtype interface{} `json:"signtype"`
  3153. WarnInfo interface{} `json:"warn_info"`
  3154. }
  3155. type Custom struct {
  3156. DetItemFeeSumamt string
  3157. Cut string
  3158. FeedetlSn string
  3159. Price string
  3160. MedListCodg string
  3161. Type int64
  3162. AdviceId int64
  3163. ProjectId int64
  3164. ItemId int64
  3165. }
  3166. type Result5301 struct {
  3167. ErrMsg string `json:"err_msg"`
  3168. InfRefmsgid string `json:"inf_refmsgid"`
  3169. Infcode int64 `json:"infcode"`
  3170. Output struct {
  3171. Result []struct {
  3172. OpspDiseCode string `json:"opsp_dise_code"`
  3173. OpspDiseName string `json:"opsp_dise_name"`
  3174. Begndate string `json:"begndate"`
  3175. Enddate string `json:"enddate"`
  3176. } `json:"feedetail"`
  3177. } `json:"output"`
  3178. RefmsgTime string `json:"refmsg_time"`
  3179. RespondTime string `json:"respond_time"`
  3180. Signtype interface{} `json:"signtype"`
  3181. WarnInfo interface{} `json:"warn_info"`
  3182. }
  3183. type Result5301For10265 struct {
  3184. ErrMsg string `json:"err_msg"`
  3185. InfRefmsgid string `json:"inf_refmsgid"`
  3186. Infcode string `json:"infcode"`
  3187. Output struct {
  3188. Result []struct {
  3189. OpspDiseCode string `json:"opsp_dise_code"`
  3190. OpspDiseName string `json:"opsp_dise_name"`
  3191. Begndate string `json:"begndate"`
  3192. Enddate string `json:"enddate"`
  3193. } `json:"feedetail"`
  3194. } `json:"output"`
  3195. RefmsgTime string `json:"refmsg_time"`
  3196. RespondTime string `json:"respond_time"`
  3197. Signtype interface{} `json:"signtype"`
  3198. WarnInfo interface{} `json:"warn_info"`
  3199. }
  3200. //获取个人信息----挂号-----上传就诊信息
  3201. func (c *HisApiController) GetRegisterInfo() {
  3202. id, _ := c.GetInt64("id")
  3203. record_time := c.GetString("record_time")
  3204. settlementValue, _ := c.GetInt64("settlement_value")
  3205. medical_insurance_card := c.GetString("medical_insurance_card")
  3206. name := c.GetString("name")
  3207. id_card_type, _ := c.GetInt64("id_card_type")
  3208. certificates, _ := c.GetInt64("certificates")
  3209. medical_care, _ := c.GetInt64("medical_care")
  3210. birthday := c.GetString("birthday")
  3211. id_card := c.GetString("id_card")
  3212. register_type, _ := c.GetInt64("register")
  3213. doctor, _ := c.GetInt64("doctor")
  3214. department, _ := c.GetInt64("department")
  3215. gender, _ := c.GetInt64("sex")
  3216. registration_fee, _ := c.GetFloat("registration_fee")
  3217. medical_expenses, _ := c.GetFloat("medical_expenses")
  3218. social_type, _ := c.GetInt64("social_type")
  3219. med_type := c.GetString("social_type")
  3220. admin_user_id, _ := c.GetInt64("admin_user_id")
  3221. insuplc_admdvs := c.GetString("insuplc_admdvs")
  3222. timeLayout := "2006-01-02"
  3223. loc, _ := time.LoadLocation("Local")
  3224. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  3225. birthUnix := birthdays.Unix()
  3226. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3227. if err != nil {
  3228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3229. return
  3230. }
  3231. recordDateTime := theTime.Unix()
  3232. adminInfo := c.GetAdminUserInfo()
  3233. var patient service.Patients
  3234. if id == 0 {
  3235. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  3236. } else {
  3237. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  3238. }
  3239. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3240. if patientPrescription.ID == 0 {
  3241. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3242. }
  3243. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3244. if patient.ID == 0 {
  3245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  3246. return
  3247. }
  3248. if len(patient.IdCardNo) == 0 {
  3249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  3250. return
  3251. }
  3252. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3253. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  3254. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  3255. //就诊结算未完成,不能进行二次挂号
  3256. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  3257. if len(his) >= 1 {
  3258. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  3259. if len(his) >= 1 && order.ID == 0 {
  3260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  3261. return
  3262. }
  3263. }
  3264. //var register_log string
  3265. if config.IsOpen == 1 {
  3266. var res ResultTwo
  3267. var res10265 ResultTwo10265
  3268. var PsnNo string
  3269. var PsnCertType string
  3270. var Certno string
  3271. var PsnName string
  3272. var Gend string
  3273. var Naty string
  3274. var Brdy string
  3275. var Age float64
  3276. var infoStr string
  3277. var idetinfoStr string
  3278. var infocode int64
  3279. var verify_number string
  3280. fmt.Println(verify_number)
  3281. if miConfig.MdtrtareaAdmvs == "421300" {
  3282. psn_info, _ := service.GetPsnByPatientId(id)
  3283. PsnNo = psn_info.PsnNo
  3284. PsnCertType = psn_info.PsnCertType
  3285. Certno = psn_info.Certno
  3286. PsnName = psn_info.PsnName
  3287. Gend = psn_info.Gend
  3288. Naty = psn_info.Naty
  3289. Brdy = psn_info.Brdy
  3290. Age = psn_info.Age
  3291. infoStr = psn_info.Insuinfo
  3292. idetinfoStr = psn_info.Idetinfo
  3293. infocode = 0
  3294. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3295. psn_info, _ := service.GetPsnByPatientId(id)
  3296. PsnNo = psn_info.PsnNo
  3297. PsnCertType = psn_info.PsnCertType
  3298. Certno = psn_info.Certno
  3299. PsnName = psn_info.PsnName
  3300. Gend = psn_info.Gend
  3301. Naty = psn_info.Naty
  3302. Brdy = psn_info.Brdy
  3303. Age = psn_info.Age
  3304. infoStr = psn_info.Insuinfo
  3305. idetinfoStr = psn_info.Idetinfo
  3306. infocode = 0
  3307. verify_number = psn_info.VerifyNumber
  3308. } else {
  3309. var result string
  3310. var requestLog string
  3311. if miConfig.UserOrgId == 10138 {
  3312. 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)
  3313. } else {
  3314. 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)
  3315. }
  3316. saveLog(result, requestLog, "1101", "人员基本信息获取")
  3317. if miConfig.Code == "H15049901371" {
  3318. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3319. utils.ErrorLog("解析失败:%v", err)
  3320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3321. return
  3322. }
  3323. res.ErrMsg = res10265.ErrMsg
  3324. res.Output = res10265.Output
  3325. res.InfRefmsgid = res10265.InfRefmsgid
  3326. } else {
  3327. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3328. utils.ErrorLog("解析失败:%v", err)
  3329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3330. return
  3331. }
  3332. }
  3333. PsnNo = res.Output.Baseinfo.PsnNo
  3334. PsnCertType = res.Output.Baseinfo.PsnCertType
  3335. Certno = res.Output.Baseinfo.Certno
  3336. PsnName = res.Output.Baseinfo.PsnName
  3337. Gend = res.Output.Baseinfo.Gend
  3338. Naty = res.Output.Baseinfo.Naty
  3339. Brdy = res.Output.Baseinfo.Brdy
  3340. Age = res.Output.Baseinfo.Age
  3341. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3342. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3343. infoStr = string(Iinfos)
  3344. idetinfoStr = string(Idetinfos)
  3345. if miConfig.Code == "H15049901371" {
  3346. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  3347. } else {
  3348. infocode = res.Infcode
  3349. }
  3350. }
  3351. if infocode == 0 {
  3352. his := models.VMHisPatient{
  3353. Name: name,
  3354. Gender: gender,
  3355. Birthday: birthUnix,
  3356. MedicalTreatmentType: medical_care,
  3357. IdType: certificates,
  3358. IdCardNo: id_card,
  3359. BalanceAccountsType: settlementValue,
  3360. SocialType: social_type,
  3361. MedicalInsuranceNumber: medical_insurance_card,
  3362. RegisterType: register_type,
  3363. RegisterCost: registration_fee,
  3364. TreatmentCost: medical_expenses,
  3365. Status: 1,
  3366. Ctime: time.Now().Unix(),
  3367. Mtime: time.Now().Unix(),
  3368. PsnNo: PsnNo,
  3369. PsnCertType: PsnCertType,
  3370. Certno: Certno,
  3371. PsnName: PsnName,
  3372. Gend: Gend,
  3373. Naty: Naty,
  3374. Brdy: Brdy,
  3375. Age: Age,
  3376. Iinfo: infoStr,
  3377. Idetinfo: idetinfoStr,
  3378. PatientId: patient.ID,
  3379. RecordDate: theTime.Unix(),
  3380. UserOrgId: adminInfo.CurrentOrgId,
  3381. AdminUserId: admin_user_id,
  3382. IsReturn: 1,
  3383. IdCardType: id_card_type,
  3384. Doctor: doctor,
  3385. Departments: department,
  3386. }
  3387. timestamp := time.Now().Unix()
  3388. tempTime := time.Unix(timestamp, 0)
  3389. timeFormat := tempTime.Format("20060102150405")
  3390. chrgBchno := rand.Intn(100000) + 10000
  3391. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3392. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  3393. department, _ := service.GetDepartMentDetail(department)
  3394. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  3395. IdCardNo := ""
  3396. if id_card_type == 1 {
  3397. // IdCardNo = medical_insurance_card
  3398. IdCardNo = patient.IdCardNo
  3399. } else {
  3400. IdCardNo = patient.IdCardNo
  3401. }
  3402. var rf []*ResultFive
  3403. json.Unmarshal([]byte(his.Iinfo), &rf)
  3404. var insutypes []*ResultFive
  3405. var insutype string
  3406. var insuplc_admdvs_temp string
  3407. var is390 int = 0
  3408. var is310 int = 0
  3409. for _, item := range rf {
  3410. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3411. insutypes = append(insutypes, item)
  3412. }
  3413. }
  3414. if len(insutypes) == 1 {
  3415. insutype = insutypes[0].Insutype
  3416. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3417. } else {
  3418. for _, i := range insutypes {
  3419. if i.Insutype == "390" {
  3420. is390 = 1
  3421. }
  3422. if i.Insutype == "310" {
  3423. is310 = 1
  3424. }
  3425. }
  3426. }
  3427. if is390 == 1 {
  3428. insutype = "390"
  3429. }
  3430. if is310 == 1 {
  3431. insutype = "310"
  3432. }
  3433. if len(insutypes) == 0 {
  3434. insutype = "310"
  3435. }
  3436. if len(insutypes) == 2 {
  3437. insutype = med_type
  3438. }
  3439. if len(med_type) > 0 {
  3440. insutype = med_type
  3441. }
  3442. //for _, item := range rf {
  3443. // if item.Insutype == insutype {
  3444. // insuplc_admdvs = item.InsuplcAdmdvs
  3445. // }
  3446. //}
  3447. var infocode int64
  3448. var resThree ResultThree
  3449. var resThree10265 ResultThree10265
  3450. if len(insuplc_admdvs) == 0 {
  3451. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  3452. } else {
  3453. insuplc_admdvs_temp = insuplc_admdvs
  3454. }
  3455. if miConfig.MdtrtareaAdmvs == "421300" {
  3456. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  3457. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3458. "&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
  3459. resp, requestErr := http.Get(api)
  3460. if requestErr != nil {
  3461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3462. return
  3463. }
  3464. body, ioErr := ioutil.ReadAll(resp.Body)
  3465. if ioErr != nil {
  3466. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3468. return
  3469. }
  3470. var respJSON map[string]interface{}
  3471. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3474. return
  3475. }
  3476. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3477. result, _ := json.Marshal(respJSON)
  3478. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3479. utils.ErrorLog("解析失败:%v", err)
  3480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3481. return
  3482. }
  3483. infocode = resThree.Infcode
  3484. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3485. psn_info, _ := service.GetPsnByPatientId(id)
  3486. bas := strings.Split(psn_info.CardInfo, "|")
  3487. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  3488. var api string
  3489. if miConfig.MdtrtareaAdmvs == "320921" {
  3490. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3491. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3492. "&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
  3493. } else {
  3494. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + bas[2] + "&ipt_otp_no=" + ipt_otp_no +
  3495. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  3496. "&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
  3497. }
  3498. resp, requestErr := http.Get(api)
  3499. if requestErr != nil {
  3500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3501. return
  3502. }
  3503. body, ioErr := ioutil.ReadAll(resp.Body)
  3504. if ioErr != nil {
  3505. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3507. return
  3508. }
  3509. var respJSON map[string]interface{}
  3510. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3511. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3513. return
  3514. }
  3515. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3516. result, _ := json.Marshal(respJSON)
  3517. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3518. utils.ErrorLog("解析失败:%v", err)
  3519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3520. return
  3521. }
  3522. resThree.ErrMsg = resThree10265.ErrMsg
  3523. resThree.Output = resThree10265.Output
  3524. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3525. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3526. } else {
  3527. 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)
  3528. saveLog(result, requestLog, "2201", "挂号")
  3529. if miConfig.Code == "H15049901371" {
  3530. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  3531. utils.ErrorLog("解析失败:%v", err)
  3532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3533. return
  3534. }
  3535. resThree.ErrMsg = resThree10265.ErrMsg
  3536. resThree.Output = resThree10265.Output
  3537. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  3538. } else {
  3539. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  3540. utils.ErrorLog("解析失败:%v", err)
  3541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3542. return
  3543. }
  3544. }
  3545. if miConfig.Code == "H15049901371" {
  3546. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  3547. } else {
  3548. infocode = resThree.Infcode
  3549. }
  3550. }
  3551. if infocode != 0 {
  3552. adminUser := c.GetAdminUserInfo()
  3553. errlog := &models.HisOrderError{
  3554. UserOrgId: adminUser.CurrentOrgId,
  3555. Ctime: time.Now().Unix(),
  3556. Mtime: time.Now().Unix(),
  3557. ErrMsg: resThree.ErrMsg,
  3558. Status: 1,
  3559. PatientId: id,
  3560. RecordTime: recordDateTime,
  3561. Stage: 2,
  3562. }
  3563. service.CreateErrMsgLog(errlog)
  3564. c.ServeSuccessJSON(map[string]interface{}{
  3565. "failed_code": -10,
  3566. "msg": resThree.ErrMsg,
  3567. })
  3568. return
  3569. }
  3570. his.Number = resThree.Output.Data.MdtrtID
  3571. his.PsnNo = resThree.Output.Data.PsnNo
  3572. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  3573. his.IdCardNo = patient.IdCardNo
  3574. his.PhoneNumber = patient.Phone
  3575. his.UserOrgId = adminInfo.CurrentOrgId
  3576. his.Insutype = insutype
  3577. his.Ctime = time.Now().Unix()
  3578. his.Mtime = time.Now().Unix()
  3579. his.InsuplcAdmdvs = insuplc_admdvs_temp
  3580. his.Status = 1
  3581. service.UpdateHisPatientStatus(&his)
  3582. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  3583. c.ServeSuccessJSON(map[string]interface{}{
  3584. "his_info": his,
  3585. })
  3586. } else {
  3587. adminUser := c.GetAdminUserInfo()
  3588. errlog := &models.HisOrderError{
  3589. UserOrgId: adminUser.CurrentOrgId,
  3590. Ctime: time.Now().Unix(),
  3591. Mtime: time.Now().Unix(),
  3592. ErrMsg: res.ErrMsg,
  3593. Status: 1,
  3594. PatientId: id,
  3595. RecordTime: recordDateTime,
  3596. Stage: 1,
  3597. }
  3598. service.CreateErrMsgLog(errlog)
  3599. c.ServeSuccessJSON(map[string]interface{}{
  3600. "failed_code": -10,
  3601. "msg": res.ErrMsg,
  3602. })
  3603. return
  3604. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  3605. }
  3606. }
  3607. }
  3608. //上传明细----预结算----确认订单
  3609. func (c *HisApiController) GetUploadInfo() {
  3610. id, _ := c.GetInt64("id")
  3611. record_time := c.GetString("record_time")
  3612. his_patient_id, _ := c.GetInt64("his_patient_id")
  3613. order_id, _ := c.GetInt64("order_id")
  3614. pay_way, _ := c.GetInt64("pay_way")
  3615. pay_price, _ := c.GetFloat("pay_price")
  3616. pay_card_no := c.GetString("pay_card_no")
  3617. discount_price, _ := c.GetFloat("discount_price")
  3618. preferential_price, _ := c.GetFloat("preferential_price")
  3619. reality_price, _ := c.GetFloat("reality_price")
  3620. found_price, _ := c.GetFloat("found_price")
  3621. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3622. private_price, _ := c.GetFloat("private_price")
  3623. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3624. admin_user_id, _ := c.GetInt64("admin_user_id")
  3625. fapiao_code := c.GetString("fapiao_code")
  3626. fapiao_number := c.GetString("fapiao_number")
  3627. diagnosis_id := c.GetString("diagnosis")
  3628. sick_type, _ := c.GetInt64("sick_type")
  3629. reg_type, _ := c.GetInt64("p_type")
  3630. begin_time := c.GetString("begin_time")
  3631. id_str := c.GetString("ids")
  3632. ids_arr := strings.Split(id_str, ",")
  3633. timeLayout := "2006-01-02"
  3634. loc, _ := time.LoadLocation("Local")
  3635. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3636. if err != nil {
  3637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3638. return
  3639. }
  3640. recordDateTime := theTime.Unix()
  3641. adminUser := c.GetAdminUserInfo()
  3642. var tempOrder models.HisOrder
  3643. tempOrder, _ = service.GetHisOrderByID(order_id)
  3644. var prescriptions []*models.HisPrescription
  3645. var start_time int64
  3646. var end_time int64
  3647. //if adminUser.CurrentOrgId == 10106{
  3648. // if len(fapiao_code) == 0{
  3649. // fapiao_code = "144072080589"
  3650. // }
  3651. // if len(fapiao_number) == 0{
  3652. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  3653. // if order.ID == 0{
  3654. // fapiao_number = "00001520"
  3655. // }else{
  3656. // //fapiao_code = "00001520"
  3657. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  3658. // var zero string
  3659. // if fpNumber >= 1000{
  3660. // zero = "0000" + strconv.Itoa(fpNumber)
  3661. // }else if fpNumber >= 10000{
  3662. // zero = "000" + strconv.Itoa(fpNumber)
  3663. // } else if fpNumber >= 100000{
  3664. // zero = "00" + strconv.Itoa(fpNumber)
  3665. // } else if fpNumber >= 1000000{
  3666. // zero = "0" + strconv.Itoa(fpNumber)
  3667. // }else {
  3668. // zero = strconv.Itoa(fpNumber)
  3669. // }
  3670. // fapiao_number = zero
  3671. // }
  3672. // }
  3673. //}
  3674. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3675. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3676. var patientPrescription models.HisPrescriptionInfo
  3677. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3678. if patientPrescription.ID == 0 {
  3679. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3680. }
  3681. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3682. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  3683. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  3684. diagnosis_ids := strings.Split(diagnosis_id, ",")
  3685. var config []*models.HisXtDiagnoseConfig
  3686. for _, item := range diagnosis_ids {
  3687. id, _ := strconv.ParseInt(item, 10, 64)
  3688. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3689. config = append(config, &diagnosisConfig)
  3690. }
  3691. sickConfig, _ := service.FindSickById(sick_type)
  3692. //if tempOrder.ID == 0 {
  3693. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  3694. //}
  3695. if tempOrder.ID == 0 {
  3696. var result string
  3697. var requestLog string
  3698. var res2 ResultSix
  3699. var ressix10265 ResultSix10265
  3700. if miConfig.MdtrtareaAdmvs == "421300" {
  3701. data := make(map[string]interface{})
  3702. client := &http.Client{}
  3703. data["psn_no"] = his.PsnNo
  3704. data["mdtrt_id"] = his.Number
  3705. data["doctor"] = roles.UserName
  3706. data["department"] = department.Name
  3707. data["org_name"] = miConfig.OrgName
  3708. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3709. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3710. data["fixmedins_code"] = miConfig.Code
  3711. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3712. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3713. data["secret_key"] = miConfig.SecretKey
  3714. data["sick_code"] = sickConfig.CountryCode
  3715. data["sick_name"] = sickConfig.ClassName
  3716. data["dept"] = strconv.FormatInt(department.ID, 10)
  3717. data["config"] = config
  3718. data["begin_time"] = begin_time
  3719. bytesData, _ := json.Marshal(data)
  3720. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  3721. resp, _ := client.Do(req)
  3722. defer resp.Body.Close()
  3723. body, ioErr := ioutil.ReadAll(resp.Body)
  3724. if ioErr != nil {
  3725. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3727. return
  3728. }
  3729. var respJSON map[string]interface{}
  3730. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3733. return
  3734. }
  3735. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3736. userJSONBytes, _ := json.Marshal(respJSON)
  3737. fmt.Println("log")
  3738. fmt.Println(string(userJSONBytes))
  3739. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3740. utils.ErrorLog("解析失败:%v", err)
  3741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3742. return
  3743. }
  3744. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3745. //江苏地区国家医保医疗类别
  3746. //职工透析:医疗类别选特殊情况门诊9933
  3747. //居民血透门慢: 医疗类别选门诊慢病1402
  3748. //var med_type string
  3749. //if his.Insutype == "310" {
  3750. // if reg_type == 14 {
  3751. // med_type = "9933"
  3752. // } else if reg_type == 11 {
  3753. // med_type = "11"
  3754. //
  3755. // }
  3756. //} else if his.Insutype == "390" {
  3757. // if reg_type == 14 {
  3758. // med_type = "1402"
  3759. // } else if reg_type == 11 {
  3760. // med_type = "11"
  3761. // }
  3762. //}
  3763. data := make(map[string]interface{})
  3764. client := &http.Client{}
  3765. data["psn_no"] = his.PsnNo
  3766. data["mdtrt_id"] = his.Number
  3767. data["doctor"] = roles.UserName
  3768. data["department"] = department.Name
  3769. data["org_name"] = miConfig.OrgName
  3770. data["med_type"] = strconv.FormatInt(reg_type, 10)
  3771. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  3772. data["fixmedins_code"] = miConfig.Code
  3773. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3774. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3775. data["secret_key"] = miConfig.SecretKey
  3776. data["sick_code"] = sickConfig.CountryCode
  3777. data["sick_name"] = sickConfig.ClassName
  3778. data["url"] = miConfig.Url
  3779. data["ak"] = miConfig.AccessKey
  3780. data["begin_time"] = begin_time
  3781. data["cainfo"] = miConfig.Cainfo
  3782. data["dept"] = strconv.FormatInt(department.ID, 10)
  3783. data["config"] = config
  3784. bytesData, _ := json.Marshal(data)
  3785. var req *http.Request
  3786. if miConfig.MdtrtareaAdmvs == "320921" {
  3787. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3788. //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 +
  3789. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  3790. } else {
  3791. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  3792. }
  3793. resp, _ := client.Do(req)
  3794. defer resp.Body.Close()
  3795. body, ioErr := ioutil.ReadAll(resp.Body)
  3796. if ioErr != nil {
  3797. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3799. return
  3800. }
  3801. var respJSON map[string]interface{}
  3802. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3803. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3805. return
  3806. }
  3807. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3808. userJSONBytes, _ := json.Marshal(respJSON)
  3809. fmt.Println("log")
  3810. fmt.Println(string(userJSONBytes))
  3811. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  3812. utils.ErrorLog("解析失败:%v", err)
  3813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3814. return
  3815. }
  3816. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3817. res2.Output = ressix10265.Output
  3818. res2.ErrMsg = ressix10265.ErrMsg
  3819. res2.Cainfo = ressix10265.Cainfo
  3820. res2.WarnMsg = ressix10265.WarnMsg
  3821. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3822. res2.Infcode = infocode
  3823. } else {
  3824. if miConfig.MdtrtareaAdmvs == "440781" { //
  3825. 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)
  3826. } else {
  3827. if miConfig.Code == "H15049901371" {
  3828. //赤峰地区国家医保医疗类别
  3829. //职工透析:医疗类别选特殊情况门诊990502
  3830. //居民定额血透门慢: 医疗类别选门诊慢病140104
  3831. var med_type string
  3832. if his.Insutype == "390" {
  3833. if reg_type == 14 {
  3834. med_type = "9933"
  3835. } else if reg_type == 11 {
  3836. med_type = "11"
  3837. }
  3838. } else if his.Insutype == "310" {
  3839. if reg_type == 14 {
  3840. med_type = "990502"
  3841. } else if reg_type == 11 {
  3842. med_type = "11"
  3843. }
  3844. }
  3845. 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)
  3846. } else {
  3847. 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)
  3848. }
  3849. }
  3850. saveLog(result, requestLog, "2203", "上传就诊信息")
  3851. var respJSON2 map[string]interface{}
  3852. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3853. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3855. return
  3856. }
  3857. userJSONBytes2, _ := json.Marshal(respJSON2)
  3858. if miConfig.Code == "H15049901371" {
  3859. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  3860. utils.ErrorLog("解析失败:%v", err)
  3861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3862. return
  3863. }
  3864. res2.InfRefmsgid = ressix10265.InfRefmsgid
  3865. res2.Output = ressix10265.Output
  3866. res2.ErrMsg = ressix10265.ErrMsg
  3867. res2.Cainfo = ressix10265.Cainfo
  3868. res2.WarnMsg = ressix10265.WarnMsg
  3869. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  3870. res2.Infcode = infocode
  3871. } else {
  3872. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3873. utils.ErrorLog("解析失败:%v", err)
  3874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3875. return
  3876. }
  3877. }
  3878. }
  3879. if res2.Infcode != 0 {
  3880. adminUser := c.GetAdminUserInfo()
  3881. errlog := &models.HisOrderError{
  3882. UserOrgId: adminUser.CurrentOrgId,
  3883. Ctime: time.Now().Unix(),
  3884. Mtime: time.Now().Unix(),
  3885. ErrMsg: res2.ErrMsg,
  3886. Status: 1,
  3887. PatientId: id,
  3888. RecordTime: recordDateTime,
  3889. Stage: 3,
  3890. }
  3891. service.CreateErrMsgLog(errlog)
  3892. c.ServeSuccessJSON(map[string]interface{}{
  3893. "failed_code": -10,
  3894. "msg": res2.ErrMsg,
  3895. })
  3896. return
  3897. } else {
  3898. his.Diagnosis = diagnosis_id
  3899. his.SickType = sickConfig.ID
  3900. var p_type int64
  3901. if reg_type == 1111 || reg_type == 1112 {
  3902. p_type = 11
  3903. }
  3904. his.PType = fmt.Sprintf("%d", p_type)
  3905. service.UpdateHisPatientThree(&his)
  3906. data := make(map[string]interface{})
  3907. if settle_accounts_type == 1 { //日结
  3908. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  3909. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  3910. } else {
  3911. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  3912. }
  3913. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  3914. data["pre"] = prescriptions
  3915. } else { //月结
  3916. start_time_str := c.GetString("start_time")
  3917. end_time_str := c.GetString("end_time")
  3918. timeLayout := "2006-01-02"
  3919. loc, _ := time.LoadLocation("Local")
  3920. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3921. if err != nil {
  3922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3923. return
  3924. }
  3925. recordStartTime := theStartTime.Unix()
  3926. start_time = recordStartTime
  3927. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3928. if err != nil {
  3929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3930. return
  3931. }
  3932. recordEndTime := theEndTime.Unix()
  3933. end_time = recordEndTime
  3934. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  3935. data["pre"] = prescriptions
  3936. }
  3937. timestamp := time.Now().Unix()
  3938. tempTime := time.Unix(timestamp, 0)
  3939. timeFormat := tempTime.Format("20060102150405")
  3940. chrgBchno := rand.Intn(100000) + 10000
  3941. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  3942. strconv.FormatInt(his.PatientId, 10)
  3943. client := &http.Client{}
  3944. data["psn_no"] = his.PsnNo
  3945. data["mdtrt_id"] = his.Number
  3946. data["chrg_bchno"] = chrg_bchno
  3947. data["org_name"] = miConfig.OrgName
  3948. data["doctor"] = roles.UserName
  3949. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3950. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3951. data["fixmedins_code"] = miConfig.Code
  3952. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  3953. // data["dept_code"] = "15"
  3954. //} else {
  3955. data["dept_code"] = department.Number
  3956. //}
  3957. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  3958. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3959. data["secret_key"] = miConfig.SecretKey
  3960. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  3961. data["url"] = miConfig.Url
  3962. data["ak"] = miConfig.AccessKey
  3963. data["new_doctor_name"] = patientPrescription.Doctor
  3964. data["diag_code"] = sickConfig.CountryCode
  3965. data["cainfo"] = miConfig.Cainfo
  3966. var ids []int64
  3967. for _, item := range prescriptions {
  3968. ids = append(ids, item.ID)
  3969. }
  3970. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3971. if config.IsOpen == 1 { //对接了医保,走医保流程
  3972. var res ResultFour
  3973. var resFour10265 ResultFour10265
  3974. if miConfig.MdtrtareaAdmvs == "421300" {
  3975. bytesData, _ := json.Marshal(data)
  3976. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  3977. resp, _ := client.Do(req)
  3978. defer resp.Body.Close()
  3979. body, ioErr := ioutil.ReadAll(resp.Body)
  3980. if ioErr != nil {
  3981. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3983. return
  3984. }
  3985. var respJSON map[string]interface{}
  3986. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3989. return
  3990. }
  3991. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3992. userJSONBytes, _ := json.Marshal(respJSON)
  3993. fmt.Println("log")
  3994. fmt.Println(string(userJSONBytes))
  3995. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3996. utils.ErrorLog("解析失败:%v", err)
  3997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3998. return
  3999. }
  4000. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4001. bytesData, _ := json.Marshal(data)
  4002. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4003. resp, _ := client.Do(req)
  4004. defer resp.Body.Close()
  4005. body, ioErr := ioutil.ReadAll(resp.Body)
  4006. if ioErr != nil {
  4007. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4009. return
  4010. }
  4011. var respJSON map[string]interface{}
  4012. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4013. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4015. return
  4016. }
  4017. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4018. userJSONBytes, _ := json.Marshal(respJSON)
  4019. fmt.Println("log")
  4020. fmt.Println(string(userJSONBytes))
  4021. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4022. utils.ErrorLog("解析失败:%v", err)
  4023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4024. return
  4025. }
  4026. res.InfRefmsgid = resFour10265.InfRefmsgid
  4027. res.Output = resFour10265.Output
  4028. res.ErrMsg = resFour10265.ErrMsg
  4029. res.Cainfo = resFour10265.Cainfo
  4030. res.WarnMsg = resFour10265.WarnMsg
  4031. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4032. res.Infcode = infocode
  4033. } else {
  4034. if miConfig.Code == "H15049901371" {
  4035. 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)
  4036. var dat map[string]interface{}
  4037. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4038. fmt.Println(dat)
  4039. } else {
  4040. fmt.Println(err)
  4041. }
  4042. saveLog(result, request_log, "2204", "上传费用明细")
  4043. userJSONBytes, _ := json.Marshal(dat)
  4044. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4045. utils.ErrorLog("解析失败:%v", err)
  4046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4047. return
  4048. }
  4049. res.InfRefmsgid = resFour10265.InfRefmsgid
  4050. res.Output = resFour10265.Output
  4051. res.ErrMsg = resFour10265.ErrMsg
  4052. res.Cainfo = resFour10265.Cainfo
  4053. res.WarnMsg = resFour10265.WarnMsg
  4054. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4055. res.Infcode = infocode
  4056. } else {
  4057. 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)
  4058. var dat map[string]interface{}
  4059. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4060. fmt.Println(dat)
  4061. } else {
  4062. fmt.Println(err)
  4063. }
  4064. saveLog(result, request_log, "2204", "上传费用明细")
  4065. userJSONBytes, _ := json.Marshal(dat)
  4066. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4067. utils.ErrorLog("解析失败:%v", err)
  4068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4069. return
  4070. }
  4071. }
  4072. }
  4073. if res.Infcode == 0 {
  4074. order := &models.HisOrder{
  4075. UserOrgId: adminUser.CurrentOrgId,
  4076. HisPatientId: his.ID,
  4077. PatientId: his.PatientId,
  4078. SettleAccountsDate: recordDateTime,
  4079. MdtrtId: his.Number,
  4080. PsnNo: his.PsnNo,
  4081. MedType: strconv.FormatInt(reg_type, 10),
  4082. Ctime: time.Now().Unix(),
  4083. Mtime: time.Now().Unix(),
  4084. Status: 1,
  4085. Number: chrg_bchno,
  4086. Infcode: res.Infcode,
  4087. WarnMsg: res.WarnMsg,
  4088. Cainfo: res.Cainfo,
  4089. ErrMsg: res.ErrMsg,
  4090. RespondTime: res.RefmsgTime,
  4091. InfRefmsgid: res.InfRefmsgid,
  4092. OrderStatus: 1,
  4093. PayWay: pay_way,
  4094. PayPrice: pay_price,
  4095. PayCardNo: pay_card_no,
  4096. DiscountPrice: discount_price,
  4097. PreferentialPrice: preferential_price,
  4098. RealityPrice: reality_price,
  4099. FoundPrice: found_price,
  4100. MedicalInsurancePrice: medical_insurance_price,
  4101. PrivatePrice: private_price,
  4102. IsMedicineInsurance: 1,
  4103. SettleType: settle_accounts_type,
  4104. SettleStartTime: start_time,
  4105. SettleEndTime: end_time,
  4106. Creator: roles.AdminUserId,
  4107. Modify: roles.AdminUserId,
  4108. FaPiaoNumber: fapiao_number,
  4109. FaPiaoCode: fapiao_code,
  4110. PType: 2,
  4111. Diagnosis: diagnosis_id,
  4112. }
  4113. err = service.CreateOrder(order)
  4114. if err != nil {
  4115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4116. return
  4117. }
  4118. for _, item := range res.Output.Result {
  4119. temp := strings.Split(item.FeedetlSn, "-")
  4120. var advice_id int64 = 0
  4121. var project_id int64 = 0
  4122. var types int64 = 0
  4123. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4124. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4125. if temp[1] == "1" {
  4126. advice_id = id
  4127. project_id = 0
  4128. } else if temp[1] == "2" {
  4129. advice_id = 0
  4130. project_id = id
  4131. }
  4132. info := &models.HisOrderInfo{
  4133. OrderNumber: order.Number,
  4134. FeedetlSn: item.FeedetlSn,
  4135. UploadDate: time.Now().Unix(),
  4136. AdviceId: advice_id,
  4137. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4138. Cnt: item.Cnt,
  4139. Pric: float64(item.Pric),
  4140. PatientId: his.PatientId,
  4141. PricUplmtAmt: item.PricUplmtAmt,
  4142. SelfpayProp: item.SelfpayProp,
  4143. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4144. OverlmtAmt: item.OverlmtAmt,
  4145. PreselfpayAmt: item.PreselfpayAmt,
  4146. BasMednFlag: item.BasMednFlag,
  4147. MedChrgitmType: item.MedChrgitmType,
  4148. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4149. Status: 1,
  4150. Memo: item.Memo,
  4151. Mtime: time.Now().Unix(),
  4152. InscpScpAmt: item.InscpScpAmt,
  4153. DrtReimFlag: item.DrtReimFlag,
  4154. Ctime: time.Now().Unix(),
  4155. ListSpItemFlag: item.ListSpItemFlag,
  4156. ChldMedcFlag: item.ChldMedcFlag,
  4157. LmtUsedFlag: item.LmtUsedFlag,
  4158. ChrgitmLv: item.ChrgitmLv,
  4159. UserOrgId: adminUser.CurrentOrgId,
  4160. HisPatientId: his.ID,
  4161. OrderId: order.ID,
  4162. ProjectId: project_id,
  4163. Type: types,
  4164. }
  4165. service.CreateOrderInfo(info)
  4166. }
  4167. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4168. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4169. var total float64
  4170. for _, item := range prescriptions {
  4171. if item.Type == 1 { //药品
  4172. for _, subItem := range item.HisDoctorAdviceInfo {
  4173. total = total + (subItem.Price * subItem.PrescribingNumber)
  4174. }
  4175. }
  4176. if item.Type == 2 { //项目
  4177. for _, subItem := range item.HisPrescriptionProject {
  4178. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4179. total = total + (subItem.Price * cnt)
  4180. }
  4181. }
  4182. }
  4183. for _, item := range prescriptions {
  4184. for _, subItem := range item.HisAdditionalCharge {
  4185. total = total + (subItem.Price * float64(subItem.Count))
  4186. }
  4187. }
  4188. var allTotal string
  4189. if adminUser.CurrentOrgId == 9919 {
  4190. allTotal = fmt.Sprintf("%.4f", total)
  4191. } else {
  4192. allTotal = fmt.Sprintf("%.4f", total)
  4193. }
  4194. if res.Infcode == 0 {
  4195. var rf []*ResultFive
  4196. json.Unmarshal([]byte(his.Iinfo), &rf)
  4197. chrg_bchno := chrg_bchno
  4198. cert_no := his.Certno
  4199. var insutypes []string
  4200. var insutype string
  4201. var is390 int = 0
  4202. var is310 int = 0
  4203. for _, item := range rf {
  4204. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4205. insutypes = append(insutypes, item.Insutype)
  4206. }
  4207. }
  4208. if len(insutypes) == 1 {
  4209. insutype = insutypes[0]
  4210. } else {
  4211. for _, i := range insutypes {
  4212. if i == "390" {
  4213. is390 = 1
  4214. }
  4215. if i == "310" {
  4216. is310 = 1
  4217. }
  4218. }
  4219. }
  4220. if is390 == 1 {
  4221. insutype = "390"
  4222. }
  4223. if is310 == 1 {
  4224. insutype = "310"
  4225. }
  4226. if len(insutypes) == 0 {
  4227. insutype = "310"
  4228. }
  4229. if len(insutypes) == 2 {
  4230. insutype = strconv.FormatInt(his.SocialType, 10)
  4231. }
  4232. insutype = strconv.FormatInt(his.SocialType, 10)
  4233. //insutype = "390"
  4234. if his.IdCardType == 1 {
  4235. // cert_no = his.MedicalInsuranceNumber
  4236. cert_no = his.Certno
  4237. } else {
  4238. cert_no = his.Certno
  4239. }
  4240. var res ResultSeven
  4241. var resSeven10265 ResultSeven10265
  4242. var src_resquest string
  4243. var result2 string
  4244. var acct_used_flag string
  4245. fmt.Println("pay_way")
  4246. fmt.Println(pay_way)
  4247. fmt.Println("pay_way")
  4248. if pay_way == 4 {
  4249. acct_used_flag = "1"
  4250. } else {
  4251. acct_used_flag = "0"
  4252. }
  4253. if miConfig.MdtrtareaAdmvs == "421300" {
  4254. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4255. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4256. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4257. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4258. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4259. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4260. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4261. resp, requestErr := http.Get(api)
  4262. if requestErr != nil {
  4263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4264. return
  4265. }
  4266. body, ioErr := ioutil.ReadAll(resp.Body)
  4267. if ioErr != nil {
  4268. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4270. return
  4271. }
  4272. var respJSON map[string]interface{}
  4273. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4274. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4276. return
  4277. }
  4278. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4279. result, _ := json.Marshal(respJSON)
  4280. if miConfig.Code == "H15049901371" {
  4281. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4282. utils.ErrorLog("解析失败:%v", err)
  4283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4284. return
  4285. }
  4286. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4287. res.Output = resSeven10265.Output
  4288. res.ErrMsg = resSeven10265.ErrMsg
  4289. res.Cainfo = resSeven10265.Cainfo
  4290. res.WarnMsg = resSeven10265.WarnMsg
  4291. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4292. res.Infcode = infocode
  4293. } else {
  4294. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4295. utils.ErrorLog("解析失败:%v", err)
  4296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4297. return
  4298. }
  4299. }
  4300. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4301. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4302. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4303. //psn_info, _ := service.GetPsnByPatientId(id)
  4304. bas := strings.Split(psn_info.CardInfo, "|")
  4305. if his.IdCardType == 1 {
  4306. cert_no = bas[2]
  4307. } else {
  4308. cert_no = bas[1]
  4309. }
  4310. //江苏地区国家医保医疗类别
  4311. //职工透析:医疗类别选特殊情况门诊9933
  4312. //居民血透门慢: 医疗类别选门诊慢病1402
  4313. //var med_type string
  4314. //if his.Insutype == "310" {
  4315. // if reg_type == 14 {
  4316. // med_type = "9933"
  4317. // } else if reg_type == 11 {
  4318. // med_type = "11"
  4319. //
  4320. // }
  4321. //} else if his.Insutype == "390" {
  4322. // if reg_type == 14 {
  4323. // med_type = "1402"
  4324. // } else if reg_type == 11 {
  4325. // med_type = "11"
  4326. // }
  4327. //}
  4328. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4329. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4330. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4331. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4332. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4333. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4334. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4335. "&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
  4336. resp, requestErr := http.Get(api)
  4337. if requestErr != nil {
  4338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4339. return
  4340. }
  4341. body, ioErr := ioutil.ReadAll(resp.Body)
  4342. if ioErr != nil {
  4343. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4345. return
  4346. }
  4347. var respJSON map[string]interface{}
  4348. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4349. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4351. return
  4352. }
  4353. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4354. result, _ := json.Marshal(respJSON)
  4355. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4356. utils.ErrorLog("解析失败:%v", err)
  4357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4358. return
  4359. }
  4360. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4361. res.Output = resSeven10265.Output
  4362. res.ErrMsg = resSeven10265.ErrMsg
  4363. res.Cainfo = resSeven10265.Cainfo
  4364. res.WarnMsg = resSeven10265.WarnMsg
  4365. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4366. res.Infcode = infocode
  4367. } else {
  4368. if miConfig.Code == "H15049901371" {
  4369. //赤峰地区国家医保医疗类别
  4370. //职工透析:医疗类别选特殊情况门诊990502
  4371. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4372. var med_type string
  4373. if his.Insutype == "390" {
  4374. if reg_type == 14 {
  4375. med_type = "9933"
  4376. } else if reg_type == 11 {
  4377. med_type = "11"
  4378. }
  4379. } else if his.Insutype == "310" {
  4380. if reg_type == 14 {
  4381. med_type = "990502"
  4382. } else if reg_type == 11 {
  4383. med_type = "11"
  4384. }
  4385. }
  4386. 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)
  4387. } else {
  4388. 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)
  4389. }
  4390. //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)
  4391. var dat map[string]interface{}
  4392. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4393. fmt.Println(dat)
  4394. } else {
  4395. fmt.Println(err)
  4396. }
  4397. saveLog(result2, src_resquest, "2207", "结算")
  4398. userJSONBytes, _ := json.Marshal(dat)
  4399. if miConfig.Code == "H15049901371" {
  4400. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4401. utils.ErrorLog("解析失败:%v", err)
  4402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4403. return
  4404. }
  4405. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4406. res.Output = resSeven10265.Output
  4407. res.ErrMsg = resSeven10265.ErrMsg
  4408. res.Cainfo = resSeven10265.Cainfo
  4409. res.WarnMsg = resSeven10265.WarnMsg
  4410. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4411. res.Infcode = infocode
  4412. } else {
  4413. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4414. utils.ErrorLog("解析失败:%v", err)
  4415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4416. return
  4417. }
  4418. }
  4419. }
  4420. if res.Infcode != 0 {
  4421. errlog := &models.HisOrderError{
  4422. UserOrgId: adminUser.CurrentOrgId,
  4423. Ctime: time.Now().Unix(),
  4424. Mtime: time.Now().Unix(),
  4425. Number: chrg_bchno,
  4426. ErrMsg: res.ErrMsg,
  4427. Status: 1,
  4428. PatientId: id,
  4429. RecordTime: recordDateTime,
  4430. Stage: 6,
  4431. }
  4432. service.CreateErrMsgLog(errlog)
  4433. c.ServeSuccessJSON(map[string]interface{}{
  4434. "failed_code": -10,
  4435. "msg": res.ErrMsg,
  4436. })
  4437. return
  4438. } else {
  4439. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4440. order.OrderStatus = 2
  4441. order.Status = 1
  4442. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4443. order.SetlId = res.Output.Setlinfo.SetlID
  4444. order.PsnNo = res.Output.Setlinfo.PsnNo
  4445. order.PsnName = res.Output.Setlinfo.PsnName
  4446. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4447. order.Certno = res.Output.Setlinfo.Certno
  4448. order.Gend = res.Output.Setlinfo.Gend
  4449. order.Naty = res.Output.Setlinfo.Naty
  4450. order.Age = res.Output.Setlinfo.Age
  4451. order.Insutype = res.Output.Setlinfo.Insutype
  4452. order.PsnType = res.Output.Setlinfo.PsnType
  4453. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4454. order.SetlTime = res.Output.Setlinfo.SetlTime
  4455. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4456. if res.Output.Setlinfo.MedType == "140101" {
  4457. order.MedType = "14"
  4458. } else {
  4459. order.MedType = res.Output.Setlinfo.MedType
  4460. }
  4461. if reg_type == 1112 {
  4462. order.MedType = "1112"
  4463. }
  4464. if reg_type == 1111 {
  4465. order.MedType = "1111"
  4466. }
  4467. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4468. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4469. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4470. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4471. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4472. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4473. order.HifpPay = res.Output.Setlinfo.HifpPay
  4474. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4475. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4476. order.HifesPay = res.Output.Setlinfo.HifesPay
  4477. order.HifobPay = res.Output.Setlinfo.HifobPay
  4478. order.MafPay = res.Output.Setlinfo.MafPay
  4479. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4480. order.OthPay = res.Output.Setlinfo.OthPay
  4481. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4482. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4483. order.AcctPay = res.Output.Setlinfo.AcctPay
  4484. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4485. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4486. order.Balc = res.Output.Setlinfo.Balc
  4487. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4488. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4489. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4490. order.ClrType = res.Output.Setlinfo.ClrType
  4491. order.ClrWay = res.Output.Setlinfo.ClrWay
  4492. order.Creator = order.Creator
  4493. order.Modify = roles.AdminUserId
  4494. order.RequestLog = src_resquest
  4495. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4496. detailStr := string(setlDetail)
  4497. order.SetlDetail = detailStr
  4498. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4499. err = service.UpDateOrder(order)
  4500. if err == nil {
  4501. c.ServeSuccessJSON(map[string]interface{}{
  4502. "msg": "结算成功",
  4503. })
  4504. } else {
  4505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4506. return
  4507. }
  4508. }
  4509. } else {
  4510. adminUser := c.GetAdminUserInfo()
  4511. errlog := &models.HisOrderError{
  4512. UserOrgId: adminUser.CurrentOrgId,
  4513. Ctime: time.Now().Unix(),
  4514. Mtime: time.Now().Unix(),
  4515. ErrMsg: res.ErrMsg,
  4516. Status: 1,
  4517. PatientId: id,
  4518. RecordTime: recordDateTime,
  4519. Stage: 4,
  4520. }
  4521. service.CreateErrMsgLog(errlog)
  4522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  4523. return
  4524. }
  4525. } else {
  4526. adminUser := c.GetAdminUserInfo()
  4527. errlog := &models.HisOrderError{
  4528. UserOrgId: adminUser.CurrentOrgId,
  4529. Ctime: time.Now().Unix(),
  4530. Mtime: time.Now().Unix(),
  4531. ErrMsg: res.ErrMsg,
  4532. Status: 1,
  4533. PatientId: id,
  4534. RecordTime: recordDateTime,
  4535. Stage: 4,
  4536. }
  4537. service.CreateErrMsgLog(errlog)
  4538. c.ServeSuccessJSON(map[string]interface{}{
  4539. "failed_code": -10,
  4540. "msg": res.ErrMsg,
  4541. })
  4542. return
  4543. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  4544. //return
  4545. }
  4546. }
  4547. }
  4548. } else if tempOrder.ID > 0 {
  4549. if tempOrder.IsPre == 1 {
  4550. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  4551. var rf []*ResultFive
  4552. json.Unmarshal([]byte(his.Iinfo), &rf)
  4553. chrg_bchno := tempOrder.Number
  4554. cert_no := his.Certno
  4555. var insutypes []string
  4556. var insutype string
  4557. var is390 int = 0
  4558. var is310 int = 0
  4559. for _, item := range rf {
  4560. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4561. insutypes = append(insutypes, item.Insutype)
  4562. }
  4563. }
  4564. if len(insutypes) == 1 {
  4565. insutype = insutypes[0]
  4566. } else {
  4567. for _, i := range insutypes {
  4568. if i == "390" {
  4569. is390 = 1
  4570. }
  4571. if i == "310" {
  4572. is310 = 1
  4573. }
  4574. }
  4575. }
  4576. if is390 == 1 {
  4577. insutype = "390"
  4578. }
  4579. if is310 == 1 {
  4580. insutype = "310"
  4581. }
  4582. if len(insutypes) == 0 {
  4583. insutype = "310"
  4584. }
  4585. if len(insutypes) == 2 {
  4586. insutype = strconv.FormatInt(his.SocialType, 64)
  4587. }
  4588. //insutype = "390"
  4589. if his.IdCardType == 1 {
  4590. // cert_no = his.MedicalInsuranceNumber
  4591. cert_no = his.Certno
  4592. } else {
  4593. cert_no = his.Certno
  4594. }
  4595. var res ResultSeven
  4596. var resSeven10265 ResultSeven10265
  4597. var src_resquest string
  4598. var result2 string
  4599. var acct_used_flag string
  4600. fmt.Println("pay_way")
  4601. fmt.Println(pay_way)
  4602. fmt.Println("pay_way")
  4603. if pay_way == 4 {
  4604. acct_used_flag = "1"
  4605. } else {
  4606. acct_used_flag = "0"
  4607. }
  4608. if miConfig.MdtrtareaAdmvs == "421300" {
  4609. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4610. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4611. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4612. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4613. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4614. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4615. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4616. resp, requestErr := http.Get(api)
  4617. if requestErr != nil {
  4618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4619. return
  4620. }
  4621. body, ioErr := ioutil.ReadAll(resp.Body)
  4622. if ioErr != nil {
  4623. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4625. return
  4626. }
  4627. var respJSON map[string]interface{}
  4628. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4631. return
  4632. }
  4633. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4634. result, _ := json.Marshal(respJSON)
  4635. fmt.Println("log")
  4636. fmt.Println(string(result))
  4637. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4638. utils.ErrorLog("解析失败:%v", err)
  4639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4640. return
  4641. }
  4642. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4643. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  4644. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4645. //psn_info, _ := service.GetPsnByPatientId(id)
  4646. bas := strings.Split(psn_info.CardInfo, "|")
  4647. if his.IdCardType == 1 {
  4648. cert_no = bas[2]
  4649. } else {
  4650. cert_no = bas[1]
  4651. }
  4652. //江苏地区国家医保医疗类别
  4653. //职工透析:医疗类别选特殊情况门诊9933
  4654. //居民血透门慢: 医疗类别选门诊慢病1402
  4655. //var med_type string
  4656. //if his.Insutype == "310" {
  4657. // if reg_type == 14 {
  4658. // med_type = "9933"
  4659. // } else if reg_type == 11 {
  4660. // med_type = "11"
  4661. //
  4662. // }
  4663. //} else if his.Insutype == "390" {
  4664. // if reg_type == 14 {
  4665. // med_type = "1402"
  4666. // } else if reg_type == 11 {
  4667. // med_type = "11"
  4668. // }
  4669. //}
  4670. api := "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4671. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4672. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4673. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4674. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4675. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4676. "&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
  4677. resp, requestErr := http.Get(api)
  4678. if requestErr != nil {
  4679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4680. return
  4681. }
  4682. body, ioErr := ioutil.ReadAll(resp.Body)
  4683. if ioErr != nil {
  4684. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4686. return
  4687. }
  4688. var respJSON map[string]interface{}
  4689. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4692. return
  4693. }
  4694. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4695. result, _ := json.Marshal(respJSON)
  4696. fmt.Println("log")
  4697. fmt.Println(string(result))
  4698. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  4699. utils.ErrorLog("解析失败:%v", err)
  4700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4701. return
  4702. }
  4703. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4704. res.Output = resSeven10265.Output
  4705. res.ErrMsg = resSeven10265.ErrMsg
  4706. res.Cainfo = resSeven10265.Cainfo
  4707. res.WarnMsg = resSeven10265.WarnMsg
  4708. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4709. res.Infcode = infocode
  4710. } else {
  4711. var src_resquest string
  4712. if miConfig.Code == "H15049901371" {
  4713. //赤峰地区国家医保医疗类别
  4714. //职工透析:医疗类别选特殊情况门诊990502
  4715. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4716. var med_type string
  4717. if his.Insutype == "390" {
  4718. if reg_type == 14 {
  4719. med_type = "9933"
  4720. } else if reg_type == 11 {
  4721. med_type = "11"
  4722. }
  4723. } else if his.Insutype == "310" {
  4724. if reg_type == 14 {
  4725. med_type = "990502"
  4726. } else if reg_type == 11 {
  4727. med_type = "11"
  4728. }
  4729. }
  4730. 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)
  4731. } else {
  4732. 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)
  4733. }
  4734. var dat map[string]interface{}
  4735. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  4736. fmt.Println(dat)
  4737. } else {
  4738. fmt.Println(err)
  4739. }
  4740. saveLog(result2, src_resquest, "2207", "结算")
  4741. userJSONBytes, _ := json.Marshal(dat)
  4742. if miConfig.Code == "H15049901371" {
  4743. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  4744. utils.ErrorLog("解析失败:%v", err)
  4745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4746. return
  4747. }
  4748. res.InfRefmsgid = resSeven10265.InfRefmsgid
  4749. res.Output = resSeven10265.Output
  4750. res.ErrMsg = resSeven10265.ErrMsg
  4751. res.Cainfo = resSeven10265.Cainfo
  4752. res.WarnMsg = resSeven10265.WarnMsg
  4753. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  4754. res.Infcode = infocode
  4755. } else {
  4756. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4757. utils.ErrorLog("解析失败:%v", err)
  4758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4759. return
  4760. }
  4761. }
  4762. }
  4763. if res.Infcode != 0 {
  4764. errlog := &models.HisOrderError{
  4765. UserOrgId: adminUser.CurrentOrgId,
  4766. Ctime: time.Now().Unix(),
  4767. Mtime: time.Now().Unix(),
  4768. Number: chrg_bchno,
  4769. ErrMsg: res.ErrMsg,
  4770. Status: 1,
  4771. PatientId: id,
  4772. RecordTime: recordDateTime,
  4773. Stage: 6,
  4774. }
  4775. service.CreateErrMsgLog(errlog)
  4776. c.ServeSuccessJSON(map[string]interface{}{
  4777. "failed_code": -10,
  4778. "msg": res.ErrMsg,
  4779. })
  4780. return
  4781. } else {
  4782. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  4783. order.OrderStatus = 2
  4784. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  4785. order.SetlId = res.Output.Setlinfo.SetlID
  4786. order.PsnNo = res.Output.Setlinfo.PsnNo
  4787. order.PsnName = res.Output.Setlinfo.PsnName
  4788. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  4789. order.Certno = res.Output.Setlinfo.Certno
  4790. order.Gend = res.Output.Setlinfo.Gend
  4791. order.Naty = res.Output.Setlinfo.Naty
  4792. order.Age = res.Output.Setlinfo.Age
  4793. order.Insutype = res.Output.Setlinfo.Insutype
  4794. order.PsnType = res.Output.Setlinfo.PsnType
  4795. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  4796. order.SetlTime = res.Output.Setlinfo.SetlTime
  4797. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  4798. //order.MedType = res.Output.Setlinfo.MedType
  4799. if reg_type == 1112 {
  4800. order.MedType = "1112"
  4801. }
  4802. if reg_type == 1111 {
  4803. order.MedType = "1111"
  4804. }
  4805. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  4806. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  4807. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  4808. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  4809. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  4810. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  4811. order.HifpPay = res.Output.Setlinfo.HifpPay
  4812. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  4813. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  4814. order.HifesPay = res.Output.Setlinfo.HifesPay
  4815. order.HifobPay = res.Output.Setlinfo.HifobPay
  4816. order.MafPay = res.Output.Setlinfo.MafPay
  4817. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  4818. order.OthPay = res.Output.Setlinfo.OthPay
  4819. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  4820. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  4821. order.AcctPay = res.Output.Setlinfo.AcctPay
  4822. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  4823. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  4824. order.Balc = res.Output.Setlinfo.Balc
  4825. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  4826. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  4827. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  4828. order.ClrWay = res.Output.Setlinfo.ClrWay
  4829. order.Creator = order.Creator
  4830. order.Modify = roles.AdminUserId
  4831. order.RequestLog = src_resquest
  4832. order.Diagnosis = diagnosis_id
  4833. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  4834. detailStr := string(setlDetail)
  4835. order.SetlDetail = detailStr
  4836. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  4837. err = service.UpDateOrder(order)
  4838. if err == nil {
  4839. c.ServeSuccessJSON(map[string]interface{}{
  4840. "msg": "结算成功",
  4841. })
  4842. } else {
  4843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  4844. return
  4845. }
  4846. }
  4847. }
  4848. }
  4849. }
  4850. //func (c *HisApiController) GetPreUploadInfo() {
  4851. // id, _ := c.GetInt64("id")
  4852. // record_time := c.GetString("record_time")
  4853. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4854. // admin_user_id, _ := c.GetInt64("admin_user_id")
  4855. //
  4856. // timeLayout := "2006-01-02"
  4857. // loc, _ := time.LoadLocation("Local")
  4858. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4859. // if err != nil {
  4860. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4861. // return
  4862. // }
  4863. // recordDateTime := theTime.Unix()
  4864. // adminUser := c.GetAdminUserInfo()
  4865. //
  4866. // var prescriptions []*models.HisPrescription
  4867. //
  4868. // var start_time int64
  4869. // var end_time int64
  4870. //
  4871. // data := make(map[string]interface{})
  4872. // if settle_accounts_type == 1 { //日结
  4873. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  4874. // data["pre"] = prescriptions
  4875. //
  4876. // } else { //月结
  4877. // start_time_str := c.GetString("start_time")
  4878. // end_time_str := c.GetString("end_time")
  4879. // timeLayout := "2006-01-02"
  4880. // loc, _ := time.LoadLocation("Local")
  4881. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4882. // if err != nil {
  4883. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4884. // return
  4885. // }
  4886. // recordStartTime := theStartTime.Unix()
  4887. // start_time = recordStartTime
  4888. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4889. // if err != nil {
  4890. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4891. // return
  4892. // }
  4893. // recordEndTime := theEndTime.Unix()
  4894. // end_time = recordEndTime
  4895. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  4896. // data["pre"] = prescriptions
  4897. //
  4898. // }
  4899. //
  4900. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4901. //
  4902. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4903. // timestamp := time.Now().Unix()
  4904. // tempTime := time.Unix(timestamp, 0)
  4905. // timeFormat := tempTime.Format("20060102150405")
  4906. // chrgBchno := rand.Intn(100000) + 10000
  4907. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4908. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4909. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4910. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4911. // strconv.FormatInt(his.PatientId, 10)
  4912. // client := &http.Client{}
  4913. // data["psn_no"] = his.PsnNo
  4914. // data["mdtrt_id"] = his.Number
  4915. // data["chrg_bchno"] = chrg_bchno
  4916. // data["org_name"] = miConfig.OrgName
  4917. // data["doctor"] = roles.UserName
  4918. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4919. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4920. // data["fixmedins_code"] = miConfig.Code
  4921. // data["dept_code"] = department.Number
  4922. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  4923. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4924. // data["secret_key"] = miConfig.SecretKey
  4925. // var ids []int64
  4926. //
  4927. // for _, item := range prescriptions {
  4928. // ids = append(ids, item.ID)
  4929. // }
  4930. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4931. // if config.IsOpen == 1 { //对接了医保,走医保流程
  4932. // bytesData, _ := json.Marshal(data)
  4933. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  4934. // resp, _ := client.Do(req)
  4935. // defer resp.Body.Close()
  4936. // body, ioErr := ioutil.ReadAll(resp.Body)
  4937. // if ioErr != nil {
  4938. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4939. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4940. // return
  4941. // }
  4942. // var respJSON map[string]interface{}
  4943. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4944. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4945. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4946. // return
  4947. // }
  4948. //
  4949. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4950. // userJSONBytes, _ := json.Marshal(respJSON)
  4951. // var res ResultFour
  4952. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4953. // utils.ErrorLog("解析失败:%v", err)
  4954. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4955. // return
  4956. // }
  4957. //
  4958. // if res.Infcode == 0 {
  4959. // order := &models.HisOrder{
  4960. // UserOrgId: adminUser.CurrentOrgId,
  4961. // HisPatientId: his.ID,
  4962. // PatientId: his.PatientId,
  4963. // SettleAccountsDate: recordDateTime,
  4964. // Ctime: time.Now().Unix(),
  4965. // Mtime: time.Now().Unix(),
  4966. // Status: 1,
  4967. // Number: chrg_bchno,
  4968. // Infcode: res.Infcode,
  4969. // WarnMsg: res.WarnMsg,
  4970. // Cainfo: res.Cainfo,
  4971. // ErrMsg: res.ErrMsg,
  4972. // RespondTime: res.RefmsgTime,
  4973. // InfRefmsgid: res.InfRefmsgid,
  4974. // OrderStatus: 1,
  4975. // IsMedicineInsurance: 1,
  4976. // SettleType: settle_accounts_type,
  4977. // SettleStartTime: start_time,
  4978. // SettleEndTime: end_time,
  4979. // Creator: roles.ID,
  4980. // Modify: roles.ID,
  4981. // PType: 2,
  4982. // }
  4983. // err = service.CreateOrder(order)
  4984. // if err != nil {
  4985. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4986. // return
  4987. // }
  4988. //
  4989. // for _, item := range res.Output.Result {
  4990. // temp := strings.Split(item.FeedetlSn, "-")
  4991. // var advice_id int64 = 0
  4992. // var project_id int64 = 0
  4993. // var types int64 = 0
  4994. //
  4995. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  4996. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  4997. //
  4998. // if temp[1] == "1" {
  4999. // advice_id = id
  5000. // project_id = 0
  5001. // } else if temp[1] == "2" {
  5002. // advice_id = 0
  5003. // project_id = id
  5004. // }
  5005. //
  5006. // info := &models.HisOrderInfo{
  5007. // OrderNumber: order.Number,
  5008. // FeedetlSn: item.FeedetlSn,
  5009. // UploadDate: time.Now().Unix(),
  5010. // AdviceId: advice_id,
  5011. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  5012. // Cnt: item.Cnt,
  5013. // Pric: float64(item.Pric),
  5014. // PatientId: his.PatientId,
  5015. // PricUplmtAmt: item.PricUplmtAmt,
  5016. // SelfpayProp: item.SelfpayProp,
  5017. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5018. // OverlmtAmt: item.OverlmtAmt,
  5019. // PreselfpayAmt: item.PreselfpayAmt,
  5020. // BasMednFlag: item.BasMednFlag,
  5021. // MedChrgitmType: item.MedChrgitmType,
  5022. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  5023. // Status: 1,
  5024. // Memo: item.Memo,
  5025. // Mtime: time.Now().Unix(),
  5026. // InscpScpAmt: item.InscpScpAmt,
  5027. // DrtReimFlag: item.DrtReimFlag,
  5028. // Ctime: time.Now().Unix(),
  5029. // ListSpItemFlag: item.ListSpItemFlag,
  5030. // ChldMedcFlag: item.ChldMedcFlag,
  5031. // LmtUsedFlag: item.LmtUsedFlag,
  5032. // ChrgitmLv: item.ChrgitmLv,
  5033. // UserOrgId: adminUser.CurrentOrgId,
  5034. // HisPatientId: his.ID,
  5035. // OrderId: order.ID,
  5036. // ProjectId: project_id,
  5037. // Type: types,
  5038. // }
  5039. // service.CreateOrderInfo(info)
  5040. //
  5041. // }
  5042. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5043. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  5044. //
  5045. // var total float64
  5046. // for _, item := range prescriptions {
  5047. // if item.Type == 1 { //药品
  5048. // for _, subItem := range item.HisDoctorAdviceInfo {
  5049. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5050. // }
  5051. // }
  5052. // if item.Type == 2 { //项目
  5053. // for _, subItem := range item.HisPrescriptionProject {
  5054. // total = total + (subItem.Price * float64(subItem.Count))
  5055. // }
  5056. // }
  5057. // }
  5058. //
  5059. // for _, item := range prescriptions {
  5060. // for _, subItem := range item.HisAdditionalCharge {
  5061. // total = total + (subItem.Price * float64(subItem.Count))
  5062. // }
  5063. // }
  5064. //
  5065. // allTotal := fmt.Sprintf("%.2f", total)
  5066. // if res.Infcode == 0 {
  5067. // var rf []*ResultFive
  5068. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5069. // psn_no := his.PsnNo
  5070. // mdtrt_id := his.Number
  5071. // chrg_bchno := chrg_bchno
  5072. // cert_no := his.Certno
  5073. // insutype := rf[0].Insutype
  5074. //
  5075. // if his.IdCardType == 1 {
  5076. // cert_no = his.MedicalInsuranceNumber
  5077. //
  5078. // } else {
  5079. //
  5080. // cert_no = his.Certno
  5081. //
  5082. // }
  5083. //
  5084. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  5085. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  5086. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  5087. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  5088. // resp, requestErr := http.Get(api)
  5089. // if requestErr != nil {
  5090. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5091. // return
  5092. // }
  5093. // defer resp.Body.Close()
  5094. // body, ioErr := ioutil.ReadAll(resp.Body)
  5095. // if ioErr != nil {
  5096. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5097. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5098. // return
  5099. // }
  5100. // var respJSON map[string]interface{}
  5101. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5102. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5103. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5104. // return
  5105. // }
  5106. // fmt.Println(respJSON)
  5107. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5108. // userJSONBytes, _ := json.Marshal(respJSON)
  5109. // var res ResultSeven
  5110. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5111. // utils.ErrorLog("解析失败:%v", err)
  5112. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5113. // return
  5114. // }
  5115. // if res.Infcode != 0 {
  5116. // errlog := &models.HisOrderError{
  5117. // UserOrgId: adminUser.CurrentOrgId,
  5118. // Ctime: time.Now().Unix(),
  5119. // Mtime: time.Now().Unix(),
  5120. // Number: chrg_bchno,
  5121. // ErrMsg: res.ErrMsg,
  5122. // Status: 1,
  5123. // PatientId: id,
  5124. // RecordTime: recordDateTime,
  5125. // Stage: 7,
  5126. // }
  5127. // service.CreateErrMsgLog(errlog)
  5128. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5129. // return
  5130. // } else {
  5131. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5132. // order.OrderStatus = 1
  5133. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5134. // order.SetlId = res.Output.Setlinfo.SetlID
  5135. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5136. // order.PsnName = res.Output.Setlinfo.PsnName
  5137. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5138. // order.Certno = res.Output.Setlinfo.Certno
  5139. // order.Gend = res.Output.Setlinfo.Gend
  5140. // order.Naty = res.Output.Setlinfo.Naty
  5141. // order.Age = res.Output.Setlinfo.Age
  5142. // order.Insutype = res.Output.Setlinfo.Insutype
  5143. // order.PsnType = res.Output.Setlinfo.PsnType
  5144. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5145. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5146. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5147. // order.MedType = res.Output.Setlinfo.MedType
  5148. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5149. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5150. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5151. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5152. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5153. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5154. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5155. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5156. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5157. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5158. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5159. // order.MafPay = res.Output.Setlinfo.MafPay
  5160. // order.OthPay = res.Output.Setlinfo.OthPay
  5161. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5162. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5163. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5164. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5165. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5166. // order.Balc = res.Output.Setlinfo.Balc
  5167. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5168. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5169. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5170. // order.ClrWay = res.Output.Setlinfo.ClrWay
  5171. // order.Creator = order.Creator
  5172. // order.Modify = roles.ID
  5173. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5174. // detailStr := string(setlDetail)
  5175. // order.SetlDetail = detailStr
  5176. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5177. // err = service.UpDateOrder(order)
  5178. // if err == nil {
  5179. // c.ServeSuccessJSON(map[string]interface{}{
  5180. // "msg": "预结算成功",
  5181. // })
  5182. // } else {
  5183. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5184. // return
  5185. // }
  5186. // }
  5187. // } else {
  5188. // adminUser := c.GetAdminUserInfo()
  5189. // errlog := &models.HisOrderError{
  5190. // UserOrgId: adminUser.CurrentOrgId,
  5191. // Ctime: time.Now().Unix(),
  5192. // Mtime: time.Now().Unix(),
  5193. // ErrMsg: res.ErrMsg,
  5194. // Status: 1,
  5195. // PatientId: id,
  5196. // RecordTime: recordDateTime,
  5197. // Stage: 4,
  5198. // }
  5199. // service.CreateErrMsgLog(errlog)
  5200. //
  5201. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5202. // return
  5203. // }
  5204. // } else {
  5205. // adminUser := c.GetAdminUserInfo()
  5206. // errlog := &models.HisOrderError{
  5207. // UserOrgId: adminUser.CurrentOrgId,
  5208. // Ctime: time.Now().Unix(),
  5209. // Mtime: time.Now().Unix(),
  5210. // ErrMsg: res.ErrMsg,
  5211. // Status: 1,
  5212. // PatientId: id,
  5213. // RecordTime: recordDateTime,
  5214. // Stage: 4,
  5215. // }
  5216. // service.CreateErrMsgLog(errlog)
  5217. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5218. // return
  5219. // }
  5220. //
  5221. // } else {
  5222. // var total float64
  5223. // for _, item := range prescriptions {
  5224. // if item.Type == 1 { //药品
  5225. // for _, subItem := range item.HisDoctorAdviceInfo {
  5226. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5227. // }
  5228. // }
  5229. // if item.Type == 2 { //项目
  5230. // for _, subItem := range item.HisPrescriptionProject {
  5231. // total = total + (subItem.Price * float64(subItem.Count))
  5232. // }
  5233. // }
  5234. //
  5235. // for _, subItem := range item.HisAdditionalCharge {
  5236. // total = total + (subItem.Price * float64(subItem.Count))
  5237. // }
  5238. // }
  5239. //
  5240. // allTotal := fmt.Sprintf("%.2f", total)
  5241. // totals, _ := strconv.ParseFloat(allTotal, 64)
  5242. // order := &models.HisOrder{
  5243. // UserOrgId: adminUser.CurrentOrgId,
  5244. // HisPatientId: his.ID,
  5245. // PatientId: id,
  5246. // SettleAccountsDate: recordDateTime,
  5247. // Ctime: time.Now().Unix(),
  5248. // Mtime: time.Now().Unix(),
  5249. // Status: 1,
  5250. // OrderStatus: 2,
  5251. // Number: chrg_bchno,
  5252. // MedfeeSumamt: totals,
  5253. // }
  5254. // err = service.CreateOrder(order)
  5255. // if err != nil {
  5256. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5257. // return
  5258. // }
  5259. //
  5260. // var customs []*Custom
  5261. // for _, item := range prescriptions {
  5262. //
  5263. // if item.Type == 1 { //药品
  5264. // for _, subItem := range item.HisDoctorAdviceInfo {
  5265. // cus := &Custom{
  5266. // AdviceId: subItem.ID,
  5267. // ProjectId: 0,
  5268. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  5269. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  5270. // FeedetlSn: subItem.FeedetlSn,
  5271. // Price: fmt.Sprintf("%.2f", subItem.Price),
  5272. // MedListCodg: subItem.MedListCodg,
  5273. // Type: 1,
  5274. // }
  5275. // customs = append(customs, cus)
  5276. // }
  5277. // }
  5278. //
  5279. // if item.Type == 2 { //项目
  5280. // for _, subItem := range item.HisPrescriptionProject {
  5281. //
  5282. // cus := &Custom{
  5283. // AdviceId: 0,
  5284. // ProjectId: subItem.ID,
  5285. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  5286. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  5287. // FeedetlSn: subItem.FeedetlSn,
  5288. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  5289. // MedListCodg: subItem.MedListCodg,
  5290. // Type: 2,
  5291. // }
  5292. //
  5293. // customs = append(customs, cus)
  5294. // }
  5295. // }
  5296. //
  5297. // for _, item := range item.HisAdditionalCharge {
  5298. // cus := &Custom{
  5299. // ItemId: item.ID,
  5300. // AdviceId: 0,
  5301. // ProjectId: 0,
  5302. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  5303. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  5304. // FeedetlSn: item.FeedetlSn,
  5305. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  5306. // MedListCodg: item.XtHisAddtionConfig.Code,
  5307. // Type: 3,
  5308. // }
  5309. //
  5310. // customs = append(customs, cus)
  5311. // }
  5312. //
  5313. // }
  5314. //
  5315. // for _, item := range customs {
  5316. // var advice_id int64 = 0
  5317. // var project_id int64 = 0
  5318. // var item_id int64 = 0
  5319. //
  5320. // var types int64 = 0
  5321. //
  5322. // if item.Type == 1 {
  5323. // advice_id = item.AdviceId
  5324. // project_id = 0
  5325. // item_id = 0
  5326. // } else if item.Type == 2 {
  5327. // advice_id = 0
  5328. // item_id = 0
  5329. //
  5330. // project_id = item.ProjectId
  5331. // } else if item.Type == 3 {
  5332. // advice_id = 0
  5333. // item_id = item.ItemId
  5334. // project_id = 0
  5335. // }
  5336. //
  5337. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  5338. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  5339. // pric, _ := strconv.ParseFloat(item.Price, 32)
  5340. //
  5341. // info := &models.HisOrderInfo{
  5342. // OrderNumber: order.Number,
  5343. // UploadDate: time.Now().Unix(),
  5344. // AdviceId: advice_id,
  5345. // DetItemFeeSumamt: detItemFeeSumamt,
  5346. // Cnt: cut,
  5347. // Pric: pric,
  5348. // PatientId: id,
  5349. // Status: 1,
  5350. // Mtime: time.Now().Unix(),
  5351. // Ctime: time.Now().Unix(),
  5352. // UserOrgId: adminUser.CurrentOrgId,
  5353. // HisPatientId: his.ID,
  5354. // OrderId: order.ID,
  5355. // ProjectId: project_id,
  5356. // Type: types,
  5357. // ItemId: item_id,
  5358. // }
  5359. // service.CreateOrderInfo(info)
  5360. // }
  5361. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5362. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5363. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  5364. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5365. // if err == nil {
  5366. // c.ServeSuccessJSON(map[string]interface{}{
  5367. // "msg": "结算成功",
  5368. // })
  5369. // } else {
  5370. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5371. // return
  5372. // }
  5373. // }
  5374. //}
  5375. //上传明细-预结算-
  5376. func (c *HisApiController) GetPreUploadInfo() {
  5377. id, _ := c.GetInt64("id")
  5378. record_time := c.GetString("record_time")
  5379. his_patient_id, _ := c.GetInt64("his_patient_id")
  5380. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5381. admin_user_id, _ := c.GetInt64("admin_user_id")
  5382. diagnosis_id := c.GetString("diagnosis")
  5383. sick_type, _ := c.GetInt64("sick_type")
  5384. reg_type, _ := c.GetInt64("p_type")
  5385. begin_time := c.GetString("begin_time")
  5386. id_str := c.GetString("ids")
  5387. ids_arr := strings.Split(id_str, ",")
  5388. timeLayout := "2006-01-02"
  5389. loc, _ := time.LoadLocation("Local")
  5390. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5391. if err != nil {
  5392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5393. return
  5394. }
  5395. recordDateTime := theTime.Unix()
  5396. adminUser := c.GetAdminUserInfo()
  5397. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5398. var config []*models.HisXtDiagnoseConfig
  5399. for _, item := range diagnosis_ids {
  5400. id, _ := strconv.ParseInt(item, 10, 64)
  5401. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5402. config = append(config, &diagnosisConfig)
  5403. }
  5404. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  5405. sickConfig, _ := service.FindSickById(sick_type)
  5406. var prescriptions []*models.HisPrescription
  5407. var start_time int64
  5408. var end_time int64
  5409. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5410. fmt.Println(his_patient_id)
  5411. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5412. timestamp := time.Now().Unix()
  5413. tempTime := time.Unix(timestamp, 0)
  5414. timeFormat := tempTime.Format("20060102150405")
  5415. chrgBchno := rand.Intn(100000) + 10000
  5416. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5417. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5418. var patientPrescription models.HisPrescriptionInfo
  5419. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5420. if patientPrescription.ID == 0 {
  5421. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5422. }
  5423. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5424. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5425. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5426. strconv.FormatInt(his.PatientId, 10)
  5427. var res2 ResultSix
  5428. var resSix10265 ResultSix10265
  5429. var time_stamp string
  5430. if miConfig.MdtrtareaAdmvs == "421300" {
  5431. data := make(map[string]interface{})
  5432. client := &http.Client{}
  5433. data["psn_no"] = his.PsnNo
  5434. data["mdtrt_id"] = his.Number
  5435. data["doctor"] = roles.UserName
  5436. data["department"] = department.Name
  5437. data["org_name"] = miConfig.OrgName
  5438. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5439. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5440. data["fixmedins_code"] = miConfig.Code
  5441. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5442. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5443. data["secret_key"] = miConfig.SecretKey
  5444. data["sick_code"] = sickConfig.CountryCode
  5445. data["sick_name"] = sickConfig.ClassName
  5446. data["begin_time"] = begin_time
  5447. data["dept"] = strconv.FormatInt(department.ID, 10)
  5448. data["config"] = config
  5449. fmt.Println(data)
  5450. bytesData, _ := json.Marshal(data)
  5451. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5452. resp, _ := client.Do(req)
  5453. defer resp.Body.Close()
  5454. body, ioErr := ioutil.ReadAll(resp.Body)
  5455. if ioErr != nil {
  5456. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5458. return
  5459. }
  5460. var respJSON map[string]interface{}
  5461. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5462. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5464. return
  5465. }
  5466. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5467. userJSONBytes, _ := json.Marshal(respJSON)
  5468. fmt.Println("log")
  5469. fmt.Println(string(userJSONBytes))
  5470. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5471. utils.ErrorLog("解析失败:%v", err)
  5472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5473. return
  5474. }
  5475. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5476. //江苏地区国家医保医疗类别
  5477. //职工透析:医疗类别选特殊情况门诊9933
  5478. //居民血透门慢: 医疗类别选门诊慢病1402
  5479. //var med_type string
  5480. //if his.Insutype == "310" {
  5481. // if reg_type == 14 {
  5482. // med_type = "9933"
  5483. // } else if reg_type == 11 {
  5484. // med_type = "11"
  5485. //
  5486. // }
  5487. //} else if his.Insutype == "390" {
  5488. // if reg_type == 14 {
  5489. // med_type = "1402"
  5490. // } else if reg_type == 11 {
  5491. // med_type = "11"
  5492. // }
  5493. //}
  5494. data := make(map[string]interface{})
  5495. client := &http.Client{}
  5496. data["psn_no"] = his.PsnNo
  5497. data["mdtrt_id"] = his.Number
  5498. data["doctor"] = roles.UserName
  5499. data["department"] = department.Name
  5500. data["org_name"] = miConfig.OrgName
  5501. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5502. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5503. data["fixmedins_code"] = miConfig.Code
  5504. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5505. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5506. data["secret_key"] = miConfig.SecretKey
  5507. data["sick_code"] = sickConfig.CountryCode
  5508. data["sick_name"] = sickConfig.ClassName
  5509. data["begin_time"] = begin_time
  5510. data["dept"] = strconv.FormatInt(department.ID, 10)
  5511. data["config"] = config
  5512. data["url"] = miConfig.Url
  5513. data["ak"] = miConfig.AccessKey
  5514. data["cainfo"] = miConfig.Cainfo
  5515. bytesData, _ := json.Marshal(data)
  5516. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5517. resp, _ := client.Do(req)
  5518. defer resp.Body.Close()
  5519. body, ioErr := ioutil.ReadAll(resp.Body)
  5520. if ioErr != nil {
  5521. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5523. return
  5524. }
  5525. var respJSON map[string]interface{}
  5526. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5527. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5529. return
  5530. }
  5531. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  5532. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  5533. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  5534. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5535. userJSONBytes, _ := json.Marshal(respJSON)
  5536. fmt.Println("log")
  5537. fmt.Println(string(userJSONBytes))
  5538. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  5539. utils.ErrorLog("解析失败:%v", err)
  5540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5541. return
  5542. }
  5543. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5544. res2.Output = resSix10265.Output
  5545. res2.ErrMsg = resSix10265.ErrMsg
  5546. res2.Cainfo = resSix10265.Cainfo
  5547. res2.WarnMsg = resSix10265.WarnMsg
  5548. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5549. res2.Infcode = infocode
  5550. } else {
  5551. var result string
  5552. var requestLog string
  5553. if miConfig.MdtrtareaAdmvs == "440781" { //
  5554. 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)
  5555. } else {
  5556. if miConfig.Code == "H15049901371" {
  5557. //赤峰地区国家医保医疗类别
  5558. //职工透析:医疗类别选特殊情况门诊990502
  5559. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5560. var med_type string
  5561. if his.Insutype == "390" {
  5562. if reg_type == 14 {
  5563. med_type = "9933"
  5564. } else if reg_type == 11 {
  5565. med_type = "11"
  5566. }
  5567. } else if his.Insutype == "310" {
  5568. if reg_type == 14 {
  5569. med_type = "990502"
  5570. } else if reg_type == 11 {
  5571. med_type = "11"
  5572. }
  5573. }
  5574. 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)
  5575. } else {
  5576. 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)
  5577. }
  5578. saveLog(result, requestLog, "2203", "上传就诊信息")
  5579. var respJSON2 map[string]interface{}
  5580. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5581. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5583. return
  5584. }
  5585. userJSONBytes2, _ := json.Marshal(respJSON2)
  5586. if miConfig.Code == "H15049901371" {
  5587. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  5588. utils.ErrorLog("解析失败:%v", err)
  5589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5590. return
  5591. }
  5592. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5593. res2.Output = resSix10265.Output
  5594. res2.ErrMsg = resSix10265.ErrMsg
  5595. res2.Cainfo = resSix10265.Cainfo
  5596. res2.WarnMsg = resSix10265.WarnMsg
  5597. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5598. res2.Infcode = infocode
  5599. } else {
  5600. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5601. utils.ErrorLog("解析失败:%v", err)
  5602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5603. return
  5604. }
  5605. }
  5606. }
  5607. }
  5608. if res2.Infcode != 0 {
  5609. adminUser := c.GetAdminUserInfo()
  5610. errlog := &models.HisOrderError{
  5611. UserOrgId: adminUser.CurrentOrgId,
  5612. Ctime: time.Now().Unix(),
  5613. Mtime: time.Now().Unix(),
  5614. ErrMsg: res2.ErrMsg,
  5615. Status: 1,
  5616. PatientId: id,
  5617. RecordTime: recordDateTime,
  5618. Stage: 3,
  5619. }
  5620. service.CreateErrMsgLog(errlog)
  5621. c.ServeSuccessJSON(map[string]interface{}{
  5622. "failed_code": -10,
  5623. "msg": res2.ErrMsg,
  5624. })
  5625. return
  5626. } else {
  5627. his.Diagnosis = diagnosis_id
  5628. his.SickType = sickConfig.ID
  5629. his.PType = fmt.Sprintf("%d", reg_type)
  5630. service.UpdateHisPatientThree(&his)
  5631. data := make(map[string]interface{})
  5632. if settle_accounts_type == 1 { //日结
  5633. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5634. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5635. } else {
  5636. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5637. }
  5638. data["pre"] = prescriptions
  5639. } else { //月结
  5640. start_time_str := c.GetString("start_time")
  5641. end_time_str := c.GetString("end_time")
  5642. timeLayout := "2006-01-02"
  5643. loc, _ := time.LoadLocation("Local")
  5644. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5645. if err != nil {
  5646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5647. return
  5648. }
  5649. recordStartTime := theStartTime.Unix()
  5650. start_time = recordStartTime
  5651. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5652. if err != nil {
  5653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5654. return
  5655. }
  5656. recordEndTime := theEndTime.Unix()
  5657. end_time = recordEndTime
  5658. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5659. data["pre"] = prescriptions
  5660. }
  5661. client := &http.Client{}
  5662. data["psn_no"] = his.PsnNo
  5663. data["mdtrt_id"] = his.Number
  5664. data["chrg_bchno"] = chrg_bchno
  5665. data["org_name"] = miConfig.OrgName
  5666. data["doctor"] = roles.UserName
  5667. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5668. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5669. data["fixmedins_code"] = miConfig.Code
  5670. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5671. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5672. data["dept_code"] = "15"
  5673. } else {
  5674. data["dept_code"] = department.Number
  5675. }
  5676. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5677. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5678. data["secret_key"] = miConfig.SecretKey
  5679. data["url"] = miConfig.Url
  5680. data["ak"] = miConfig.AccessKey
  5681. data["new_doctor_name"] = patientPrescription.Doctor
  5682. data["diag_code"] = sickConfig.CountryCode
  5683. data["time_stamp"] = time_stamp
  5684. data["cainfo"] = miConfig.Cainfo
  5685. var ids []int64
  5686. for _, item := range prescriptions {
  5687. ids = append(ids, item.ID)
  5688. }
  5689. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5690. if config.IsOpen == 1 { //对接了医保,走医保流程
  5691. var res ResultFour
  5692. var resFour10265 ResultFour10265
  5693. if miConfig.MdtrtareaAdmvs == "421300" {
  5694. bytesData, _ := json.Marshal(data)
  5695. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5696. resp, _ := client.Do(req)
  5697. defer resp.Body.Close()
  5698. body, ioErr := ioutil.ReadAll(resp.Body)
  5699. if ioErr != nil {
  5700. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5702. return
  5703. }
  5704. var respJSON map[string]interface{}
  5705. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5706. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5708. return
  5709. }
  5710. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5711. userJSONBytes, _ := json.Marshal(respJSON)
  5712. fmt.Println("log")
  5713. fmt.Println(string(userJSONBytes))
  5714. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5715. utils.ErrorLog("解析失败:%v", err)
  5716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5717. return
  5718. }
  5719. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5720. bytesData, _ := json.Marshal(data)
  5721. req, _ := http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5722. resp, _ := client.Do(req)
  5723. defer resp.Body.Close()
  5724. body, ioErr := ioutil.ReadAll(resp.Body)
  5725. if ioErr != nil {
  5726. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5728. return
  5729. }
  5730. var respJSON map[string]interface{}
  5731. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5732. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5734. return
  5735. }
  5736. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5737. userJSONBytes, _ := json.Marshal(respJSON)
  5738. fmt.Println("log")
  5739. fmt.Println(string(userJSONBytes))
  5740. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5741. utils.ErrorLog("解析失败:%v", err)
  5742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5743. return
  5744. }
  5745. res.InfRefmsgid = resFour10265.InfRefmsgid
  5746. res.Output = resFour10265.Output
  5747. res.ErrMsg = resFour10265.ErrMsg
  5748. res.Cainfo = resFour10265.Cainfo
  5749. res.WarnMsg = resFour10265.WarnMsg
  5750. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5751. res.Infcode = infocode
  5752. } else {
  5753. if miConfig.Code == "H15049901371" {
  5754. 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)
  5755. var dat map[string]interface{}
  5756. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5757. fmt.Println(dat)
  5758. } else {
  5759. fmt.Println(err)
  5760. }
  5761. saveLog(result, request_log, "2204", "上传费用明细")
  5762. userJSONBytes, _ := json.Marshal(dat)
  5763. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5764. utils.ErrorLog("解析失败:%v", err)
  5765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5766. return
  5767. }
  5768. res.InfRefmsgid = resFour10265.InfRefmsgid
  5769. res.Output = resFour10265.Output
  5770. res.ErrMsg = resFour10265.ErrMsg
  5771. res.Cainfo = resFour10265.Cainfo
  5772. res.WarnMsg = resFour10265.WarnMsg
  5773. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5774. res.Infcode = infocode
  5775. } else {
  5776. 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)
  5777. var dat map[string]interface{}
  5778. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5779. fmt.Println(dat)
  5780. } else {
  5781. fmt.Println(err)
  5782. }
  5783. saveLog(result, request_log, "2204", "上传费用明细")
  5784. userJSONBytes, _ := json.Marshal(dat)
  5785. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5786. utils.ErrorLog("解析失败:%v", err)
  5787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5788. return
  5789. }
  5790. }
  5791. }
  5792. if res.Infcode == 0 {
  5793. order := &models.HisOrder{
  5794. UserOrgId: adminUser.CurrentOrgId,
  5795. HisPatientId: his.ID,
  5796. PatientId: his.PatientId,
  5797. SettleAccountsDate: recordDateTime,
  5798. Ctime: time.Now().Unix(),
  5799. Mtime: time.Now().Unix(),
  5800. MdtrtId: his.Number,
  5801. PsnNo: his.PsnNo,
  5802. MedType: strconv.FormatInt(reg_type, 10),
  5803. Status: 1,
  5804. Number: chrg_bchno,
  5805. Infcode: res.Infcode,
  5806. WarnMsg: res.WarnMsg,
  5807. Cainfo: res.Cainfo,
  5808. ErrMsg: res.ErrMsg,
  5809. RespondTime: res.RefmsgTime,
  5810. InfRefmsgid: res.InfRefmsgid,
  5811. OrderStatus: 1,
  5812. IsMedicineInsurance: 1,
  5813. SettleType: settle_accounts_type,
  5814. SettleStartTime: start_time,
  5815. SettleEndTime: end_time,
  5816. Creator: roles.AdminUserId,
  5817. Modify: roles.AdminUserId,
  5818. PType: 2,
  5819. Diagnosis: diagnosis_id,
  5820. }
  5821. err = service.CreateOrder(order)
  5822. if err != nil {
  5823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5824. return
  5825. }
  5826. for _, item := range res.Output.Result {
  5827. temp := strings.Split(item.FeedetlSn, "-")
  5828. var advice_id int64 = 0
  5829. var project_id int64 = 0
  5830. var types int64 = 0
  5831. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5832. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5833. if temp[1] == "1" {
  5834. advice_id = id
  5835. project_id = 0
  5836. } else if temp[1] == "2" {
  5837. advice_id = 0
  5838. project_id = id
  5839. }
  5840. info := &models.HisOrderInfo{
  5841. OrderNumber: order.Number,
  5842. FeedetlSn: item.FeedetlSn,
  5843. UploadDate: time.Now().Unix(),
  5844. AdviceId: advice_id,
  5845. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5846. Cnt: item.Cnt,
  5847. Pric: float64(item.Pric),
  5848. PatientId: his.PatientId,
  5849. PricUplmtAmt: item.PricUplmtAmt,
  5850. SelfpayProp: item.SelfpayProp,
  5851. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5852. OverlmtAmt: item.OverlmtAmt,
  5853. PreselfpayAmt: item.PreselfpayAmt,
  5854. BasMednFlag: item.BasMednFlag,
  5855. MedChrgitmType: item.MedChrgitmType,
  5856. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5857. Status: 1,
  5858. Memo: item.Memo,
  5859. Mtime: time.Now().Unix(),
  5860. InscpScpAmt: item.InscpScpAmt,
  5861. DrtReimFlag: item.DrtReimFlag,
  5862. Ctime: time.Now().Unix(),
  5863. ListSpItemFlag: item.ListSpItemFlag,
  5864. ChldMedcFlag: item.ChldMedcFlag,
  5865. LmtUsedFlag: item.LmtUsedFlag,
  5866. ChrgitmLv: item.ChrgitmLv,
  5867. UserOrgId: adminUser.CurrentOrgId,
  5868. HisPatientId: his.ID,
  5869. OrderId: order.ID,
  5870. ProjectId: project_id,
  5871. Type: types,
  5872. }
  5873. service.CreateOrderInfo(info)
  5874. }
  5875. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5876. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5877. var total float64
  5878. for _, item := range prescriptions {
  5879. if item.Type == 1 { //药品
  5880. for _, subItem := range item.HisDoctorAdviceInfo {
  5881. total = total + (subItem.Price * subItem.PrescribingNumber)
  5882. }
  5883. }
  5884. if item.Type == 2 { //项目
  5885. for _, subItem := range item.HisPrescriptionProject {
  5886. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5887. total = total + (subItem.Price * cnt)
  5888. }
  5889. }
  5890. }
  5891. for _, item := range prescriptions {
  5892. for _, subItem := range item.HisAdditionalCharge {
  5893. total = total + (subItem.Price * float64(subItem.Count))
  5894. }
  5895. }
  5896. allTotal := fmt.Sprintf("%.4f", total)
  5897. if res.Infcode == 0 {
  5898. var rf []*ResultFive
  5899. json.Unmarshal([]byte(his.Iinfo), &rf)
  5900. chrg_bchno := chrg_bchno
  5901. cert_no := his.Certno
  5902. var insutypes []string
  5903. var insutype string
  5904. var is390 int = 0
  5905. var is310 int = 0
  5906. for _, item := range rf {
  5907. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5908. insutypes = append(insutypes, item.Insutype)
  5909. }
  5910. }
  5911. if len(insutypes) == 1 {
  5912. insutype = insutypes[0]
  5913. } else {
  5914. for _, i := range insutypes {
  5915. if i == "390" {
  5916. is390 = 1
  5917. }
  5918. if i == "310" {
  5919. is310 = 1
  5920. }
  5921. }
  5922. }
  5923. if is390 == 1 {
  5924. insutype = "390"
  5925. }
  5926. if is310 == 1 {
  5927. insutype = "310"
  5928. }
  5929. if len(insutypes) == 0 {
  5930. insutype = "310"
  5931. }
  5932. if len(insutypes) == 2 {
  5933. insutype = strconv.FormatInt(his.SocialType, 64)
  5934. }
  5935. //insutype = "390"
  5936. if his.IdCardType == 1 {
  5937. cert_no = his.MedicalInsuranceNumber
  5938. } else {
  5939. cert_no = his.Certno
  5940. }
  5941. var res ResultSeven
  5942. var resSeven10265 ResultSeven10265
  5943. if miConfig.MdtrtareaAdmvs == "421300" {
  5944. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5945. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5946. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5947. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5948. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5949. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5950. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  5951. resp, requestErr := http.Get(api)
  5952. if requestErr != nil {
  5953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5954. return
  5955. }
  5956. body, ioErr := ioutil.ReadAll(resp.Body)
  5957. if ioErr != nil {
  5958. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5960. return
  5961. }
  5962. var respJSON map[string]interface{}
  5963. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5964. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5966. return
  5967. }
  5968. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5969. result, _ := json.Marshal(respJSON)
  5970. fmt.Println("log")
  5971. fmt.Println(string(result))
  5972. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5973. utils.ErrorLog("解析失败:%v", err)
  5974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5975. return
  5976. }
  5977. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5978. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5979. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5980. bas := strings.Split(psn_info.CardInfo, "|")
  5981. if his.IdCardType == 1 {
  5982. cert_no = bas[2]
  5983. } else {
  5984. cert_no = bas[1]
  5985. }
  5986. //江苏地区国家医保医疗类别
  5987. //职工透析:医疗类别选特殊情况门诊9933
  5988. //居民血透门慢: 医疗类别选门诊慢病1402
  5989. //var med_type string
  5990. //if his.Insutype == "310" {
  5991. // if reg_type == 14 {
  5992. // med_type = "9933"
  5993. // } else if reg_type == 11 {
  5994. // med_type = "11"
  5995. //
  5996. // }
  5997. //} else if his.Insutype == "390" {
  5998. // if reg_type == 14 {
  5999. // med_type = "1402"
  6000. // } else if reg_type == 11 {
  6001. // med_type = "11"
  6002. // }
  6003. //}
  6004. api := "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6005. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6006. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6007. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6008. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6009. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6010. "&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
  6011. resp, requestErr := http.Get(api)
  6012. if requestErr != nil {
  6013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6014. return
  6015. }
  6016. body, ioErr := ioutil.ReadAll(resp.Body)
  6017. if ioErr != nil {
  6018. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6020. return
  6021. }
  6022. var respJSON map[string]interface{}
  6023. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6024. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6026. return
  6027. }
  6028. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6029. result, _ := json.Marshal(respJSON)
  6030. fmt.Println("log")
  6031. fmt.Println(string(result))
  6032. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6033. utils.ErrorLog("解析失败:%v", err)
  6034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6035. return
  6036. }
  6037. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6038. res.Output = resSeven10265.Output
  6039. res.ErrMsg = resSeven10265.ErrMsg
  6040. res.Cainfo = resSeven10265.Cainfo
  6041. res.WarnMsg = resSeven10265.WarnMsg
  6042. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6043. res.Infcode = infocode
  6044. } else {
  6045. var result string
  6046. var request_log string
  6047. if miConfig.Code == "H15049901371" {
  6048. //赤峰地区国家医保医疗类别
  6049. //职工透析:医疗类别选特殊情况门诊990502
  6050. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6051. var med_type string
  6052. if his.Insutype == "390" {
  6053. if reg_type == 14 {
  6054. med_type = "9933"
  6055. } else if reg_type == 11 {
  6056. med_type = "11"
  6057. }
  6058. } else if his.Insutype == "310" {
  6059. if reg_type == 14 {
  6060. med_type = "990502"
  6061. } else if reg_type == 11 {
  6062. med_type = "11"
  6063. }
  6064. }
  6065. 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)
  6066. } else {
  6067. 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)
  6068. }
  6069. var dat map[string]interface{}
  6070. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6071. fmt.Println(dat)
  6072. } else {
  6073. fmt.Println(err)
  6074. }
  6075. saveLog(result, request_log, "2206", "预结算")
  6076. //userJSONBytes, _ := json.Marshal(dat)
  6077. //
  6078. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6079. // utils.ErrorLog("解析失败:%v", err)
  6080. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6081. // return
  6082. //}
  6083. userJSONBytes, _ := json.Marshal(dat)
  6084. if miConfig.Code == "H15049901371" {
  6085. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6086. utils.ErrorLog("解析失败:%v", err)
  6087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6088. return
  6089. }
  6090. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6091. res.Output = resSeven10265.Output
  6092. res.ErrMsg = resSeven10265.ErrMsg
  6093. res.Cainfo = resSeven10265.Cainfo
  6094. res.WarnMsg = resSeven10265.WarnMsg
  6095. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6096. res.Infcode = infocode
  6097. } else {
  6098. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6099. utils.ErrorLog("解析失败:%v", err)
  6100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6101. return
  6102. }
  6103. }
  6104. }
  6105. if res.Infcode != 0 {
  6106. errlog := &models.HisOrderError{
  6107. UserOrgId: adminUser.CurrentOrgId,
  6108. Ctime: time.Now().Unix(),
  6109. Mtime: time.Now().Unix(),
  6110. Number: chrg_bchno,
  6111. ErrMsg: res.ErrMsg,
  6112. Status: 1,
  6113. PatientId: id,
  6114. RecordTime: recordDateTime,
  6115. Stage: 20,
  6116. }
  6117. service.CreateErrMsgLog(errlog)
  6118. c.ServeSuccessJSON(map[string]interface{}{
  6119. "failed_code": -10,
  6120. "msg": res.ErrMsg,
  6121. })
  6122. return
  6123. } else {
  6124. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6125. order.OrderStatus = 1
  6126. order.IsPre = 1
  6127. order.Status = 1
  6128. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6129. order.SetlId = res.Output.Setlinfo.SetlID
  6130. order.PsnNo = res.Output.Setlinfo.PsnNo
  6131. order.PsnName = res.Output.Setlinfo.PsnName
  6132. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6133. order.Certno = res.Output.Setlinfo.Certno
  6134. order.Gend = res.Output.Setlinfo.Gend
  6135. order.Naty = res.Output.Setlinfo.Naty
  6136. order.Age = res.Output.Setlinfo.Age
  6137. order.Insutype = res.Output.Setlinfo.Insutype
  6138. order.PsnType = res.Output.Setlinfo.PsnType
  6139. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6140. order.SetlTime = res.Output.Setlinfo.SetlTime
  6141. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6142. if res.Output.Setlinfo.MedType == "140101" {
  6143. order.MedType = "14"
  6144. } else {
  6145. order.MedType = res.Output.Setlinfo.MedType
  6146. }
  6147. if reg_type == 1112 {
  6148. order.MedType = "1112"
  6149. }
  6150. if reg_type == 1111 {
  6151. order.MedType = "1111"
  6152. }
  6153. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6154. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6155. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6156. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6157. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6158. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6159. order.HifpPay = res.Output.Setlinfo.HifpPay
  6160. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6161. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6162. order.HifesPay = res.Output.Setlinfo.HifesPay
  6163. order.HifobPay = res.Output.Setlinfo.HifobPay
  6164. order.MafPay = res.Output.Setlinfo.MafPay
  6165. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6166. order.OthPay = res.Output.Setlinfo.OthPay
  6167. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6168. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6169. order.AcctPay = res.Output.Setlinfo.AcctPay
  6170. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6171. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6172. order.Balc = res.Output.Setlinfo.Balc
  6173. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6174. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6175. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6176. order.ClrWay = res.Output.Setlinfo.ClrWay
  6177. order.Creator = order.Creator
  6178. order.Modify = roles.AdminUserId
  6179. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6180. detailStr := string(setlDetail)
  6181. order.SetlDetail = detailStr
  6182. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6183. err = service.UpDateOrder(order)
  6184. if err == nil {
  6185. c.ServeSuccessJSON(map[string]interface{}{
  6186. "msg": "预结算成功",
  6187. })
  6188. } else {
  6189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6190. return
  6191. }
  6192. }
  6193. } else {
  6194. adminUser := c.GetAdminUserInfo()
  6195. errlog := &models.HisOrderError{
  6196. UserOrgId: adminUser.CurrentOrgId,
  6197. Ctime: time.Now().Unix(),
  6198. Mtime: time.Now().Unix(),
  6199. ErrMsg: res.ErrMsg,
  6200. Status: 1,
  6201. PatientId: id,
  6202. RecordTime: recordDateTime,
  6203. Stage: 4,
  6204. }
  6205. service.CreateErrMsgLog(errlog)
  6206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6207. return
  6208. }
  6209. } else {
  6210. adminUser := c.GetAdminUserInfo()
  6211. errlog := &models.HisOrderError{
  6212. UserOrgId: adminUser.CurrentOrgId,
  6213. Ctime: time.Now().Unix(),
  6214. Mtime: time.Now().Unix(),
  6215. ErrMsg: res.ErrMsg,
  6216. Status: 1,
  6217. PatientId: id,
  6218. RecordTime: recordDateTime,
  6219. Stage: 4,
  6220. }
  6221. service.CreateErrMsgLog(errlog)
  6222. c.ServeSuccessJSON(map[string]interface{}{
  6223. "failed_code": -10,
  6224. "msg": res.ErrMsg,
  6225. })
  6226. return
  6227. }
  6228. }
  6229. }
  6230. }
  6231. //func (c *HisApiController) GetSettleInfo() {
  6232. // id, _ := c.GetInt64("id")
  6233. // order_id, _ := c.GetInt64("order_id")
  6234. //
  6235. // record_time := c.GetString("record_time")
  6236. // pay_way, _ := c.GetInt64("pay_way")
  6237. // pay_price, _ := c.GetFloat("pay_price")
  6238. // pay_card_no := c.GetString("pay_card_no")
  6239. // discount_price, _ := c.GetFloat("discount_price")
  6240. // preferential_price, _ := c.GetFloat("preferential_price")
  6241. // reality_price, _ := c.GetFloat("reality_price")
  6242. // found_price, _ := c.GetFloat("found_price")
  6243. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  6244. // private_price, _ := c.GetFloat("private_price")
  6245. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6246. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6247. //
  6248. // timeLayout := "2006-01-02"
  6249. // loc, _ := time.LoadLocation("Local")
  6250. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6251. // if err != nil {
  6252. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6253. // return
  6254. // }
  6255. // recordDateTime := theTime.Unix()
  6256. // adminUser := c.GetAdminUserInfo()
  6257. //
  6258. // var prescriptions []*models.HisPrescription
  6259. //
  6260. // data := make(map[string]interface{})
  6261. // if settle_accounts_type == 1 { //日结
  6262. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6263. // data["pre"] = prescriptions
  6264. //
  6265. // } else { //月结
  6266. // start_time_str := c.GetString("start_time")
  6267. // end_time_str := c.GetString("end_time")
  6268. // timeLayout := "2006-01-02"
  6269. // loc, _ := time.LoadLocation("Local")
  6270. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6271. // if err != nil {
  6272. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6273. // return
  6274. // }
  6275. // recordStartTime := theStartTime.Unix()
  6276. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6277. // if err != nil {
  6278. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6279. // return
  6280. // }
  6281. // recordEndTime := theEndTime.Unix()
  6282. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6283. // data["pre"] = prescriptions
  6284. //
  6285. // }
  6286. //
  6287. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6288. //
  6289. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6290. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6291. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6292. // strconv.FormatInt(his.PatientId, 10)
  6293. //
  6294. // order_src, _ := service.GetHisOrderByID(order_id)
  6295. //
  6296. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6297. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6298. //
  6299. // var total float64
  6300. // for _, item := range prescriptions {
  6301. // if item.Type == 1 { //药品
  6302. // for _, subItem := range item.HisDoctorAdviceInfo {
  6303. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6304. // }
  6305. // }
  6306. // if item.Type == 2 { //项目
  6307. // for _, subItem := range item.HisPrescriptionProject {
  6308. // total = total + (subItem.Price * float64(subItem.Count))
  6309. // }
  6310. // }
  6311. // }
  6312. //
  6313. // for _, item := range prescriptions {
  6314. // for _, subItem := range item.HisAdditionalCharge {
  6315. // total = total + (subItem.Price * float64(subItem.Count))
  6316. // }
  6317. // }
  6318. //
  6319. // allTotal := fmt.Sprintf("%.2f", total)
  6320. // var rf []*ResultFive
  6321. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6322. // psn_no := order_src.PsnNo
  6323. // mdtrt_id := order_src.MdtrtId
  6324. // chrg_bchno := order_src.Number
  6325. // cert_no := order_src.Certno
  6326. // insutype := rf[0].Insutype
  6327. //
  6328. // if his.IdCardType == 1 {
  6329. // cert_no = his.MedicalInsuranceNumber
  6330. // } else {
  6331. // cert_no = his.Certno
  6332. // }
  6333. //
  6334. // 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)
  6335. // var dat map[string]interface{}
  6336. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6337. // fmt.Println(dat)
  6338. // } else {
  6339. // fmt.Println(err)
  6340. // }
  6341. //
  6342. // userJSONBytes, _ := json.Marshal(dat)
  6343. //
  6344. //
  6345. //
  6346. // var res ResultSeven
  6347. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6348. // utils.ErrorLog("解析失败:%v", err)
  6349. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6350. // return
  6351. // }
  6352. // if res.Infcode == -1 {
  6353. // errlog := &models.HisOrderError{
  6354. // UserOrgId: adminUser.CurrentOrgId,
  6355. // Ctime: time.Now().Unix(),
  6356. // Mtime: time.Now().Unix(),
  6357. // Number: chrg_bchno,
  6358. // ErrMsg: res.ErrMsg,
  6359. // Status: 1,
  6360. // PatientId: id,
  6361. // RecordTime: recordDateTime,
  6362. // Stage: 6,
  6363. // }
  6364. // service.CreateErrMsgLog(errlog)
  6365. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6366. // return
  6367. // } else {
  6368. // order_src.OrderStatus = 2
  6369. // order_src.PayWay = pay_way
  6370. // order_src.PayPrice = pay_price
  6371. // order_src.PayCardNo = pay_card_no
  6372. // order_src.DiscountPrice = discount_price
  6373. // order_src.PreferentialPrice = preferential_price
  6374. // order_src.RealityPrice = reality_price
  6375. // order_src.FoundPrice = found_price
  6376. // order_src.MedicalInsurancePrice = medical_insurance_price
  6377. // order_src.PrivatePrice = private_price
  6378. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  6379. // order_src.SetlId = res.Output.Setlinfo.SetlID
  6380. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  6381. // order_src.PsnName = res.Output.Setlinfo.PsnName
  6382. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  6383. // order_src.Certno = res.Output.Setlinfo.Certno
  6384. // order_src.Gend = res.Output.Setlinfo.Gend
  6385. // order_src.Naty = res.Output.Setlinfo.Naty
  6386. // order_src.Age = res.Output.Setlinfo.Age
  6387. // order_src.Insutype = res.Output.Setlinfo.Insutype
  6388. // order_src.PsnType = res.Output.Setlinfo.PsnType
  6389. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6390. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  6391. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6392. // order_src.MedType = res.Output.Setlinfo.MedType
  6393. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6394. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6395. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6396. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6397. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6398. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6399. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  6400. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  6401. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6402. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  6403. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  6404. // order_src.MafPay = res.Output.Setlinfo.MafPay
  6405. // order_src.OthPay = res.Output.Setlinfo.OthPay
  6406. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6407. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6408. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  6409. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6410. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6411. // order_src.Balc = res.Output.Setlinfo.Balc
  6412. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6413. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6414. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  6415. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  6416. // order_src.Creator = order_src.Creator
  6417. // order_src.Modify = roles.ID
  6418. // order_src.RequestLog = src_resquest
  6419. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6420. // detailStr := string(setlDetail)
  6421. // order_src.SetlDetail = detailStr
  6422. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6423. // err = service.UpDateOrder(order_src)
  6424. //
  6425. // if err == nil {
  6426. // c.ServeSuccessJSON(map[string]interface{}{
  6427. // "msg": "结算成功",
  6428. // })
  6429. // } else {
  6430. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6431. // return
  6432. // }
  6433. // }
  6434. // }
  6435. //}
  6436. //退款
  6437. func (c *HisApiController) Refund() {
  6438. order_id, _ := c.GetInt64("order_id")
  6439. admin_user_id, _ := c.GetInt64("admin_user_id")
  6440. adminUser := c.GetAdminUserInfo()
  6441. var order models.HisOrder
  6442. order, _ = service.GetHisOrderByID(order_id)
  6443. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6444. if order.ID == 0 {
  6445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6446. return
  6447. }
  6448. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6449. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6450. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6451. if config.IsOpen == 1 { //对接了医保,走医保流程
  6452. var res ResultSixteen
  6453. var resSixteen10265 ResultSixteen10265
  6454. var src_resquest string
  6455. var result string
  6456. if miConfig.MdtrtareaAdmvs == "421300" {
  6457. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  6458. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6459. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6460. resp3, requestErr3 := http.Get(api3)
  6461. if requestErr3 != nil {
  6462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6463. return
  6464. }
  6465. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6466. if ioErr3 != nil {
  6467. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6469. return
  6470. }
  6471. var respJSON3 map[string]interface{}
  6472. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6475. return
  6476. }
  6477. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6478. userJSONBytes3, _ := json.Marshal(respJSON3)
  6479. fmt.Println("log")
  6480. fmt.Println(string(userJSONBytes3))
  6481. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  6482. utils.ErrorLog("解析失败:%v", err)
  6483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6484. return
  6485. }
  6486. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6487. api3 := "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  6488. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6489. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6490. resp3, requestErr3 := http.Get(api3)
  6491. if requestErr3 != nil {
  6492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6493. return
  6494. }
  6495. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6496. if ioErr3 != nil {
  6497. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6499. return
  6500. }
  6501. var respJSON3 map[string]interface{}
  6502. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6503. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6505. return
  6506. }
  6507. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6508. userJSONBytes3, _ := json.Marshal(respJSON3)
  6509. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  6510. utils.ErrorLog("解析失败:%v", err)
  6511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6512. return
  6513. }
  6514. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6515. res.Output = resSixteen10265.Output
  6516. res.ErrMsg = resSixteen10265.ErrMsg
  6517. res.Cainfo = resSixteen10265.Cainfo
  6518. res.WarnMsg = resSixteen10265.WarnMsg
  6519. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6520. res.Infcode = infocode
  6521. } else {
  6522. if miConfig.Code == "H15049901371" {
  6523. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6524. var dat map[string]interface{}
  6525. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6526. fmt.Println(dat)
  6527. } else {
  6528. fmt.Println(err)
  6529. }
  6530. saveLog(result, src_resquest, "2208", "退费")
  6531. userJSONBytes, _ := json.Marshal(dat)
  6532. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  6533. utils.ErrorLog("解析失败:%v", err)
  6534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6535. return
  6536. }
  6537. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  6538. res.Output = resSixteen10265.Output
  6539. res.ErrMsg = resSixteen10265.ErrMsg
  6540. res.Cainfo = resSixteen10265.Cainfo
  6541. res.WarnMsg = resSixteen10265.WarnMsg
  6542. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  6543. res.Infcode = infocode
  6544. } else {
  6545. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  6546. var dat map[string]interface{}
  6547. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6548. fmt.Println(dat)
  6549. } else {
  6550. fmt.Println(err)
  6551. }
  6552. saveLog(result, src_resquest, "2208", "退费")
  6553. userJSONBytes, _ := json.Marshal(dat)
  6554. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6555. utils.ErrorLog("解析失败:%v", err)
  6556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6557. return
  6558. }
  6559. }
  6560. }
  6561. if res.Infcode == 0 {
  6562. var res2 ResultSix
  6563. var resSix10265 ResultSix10265
  6564. if miConfig.MdtrtareaAdmvs == "421300" {
  6565. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6566. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6567. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6568. resp3, requestErr3 := http.Get(api3)
  6569. if requestErr3 != nil {
  6570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6571. return
  6572. }
  6573. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6574. if ioErr3 != nil {
  6575. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6577. return
  6578. }
  6579. var respJSON3 map[string]interface{}
  6580. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6581. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6583. return
  6584. }
  6585. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6586. userJSONBytes3, _ := json.Marshal(respJSON3)
  6587. fmt.Println("log")
  6588. fmt.Println(string(userJSONBytes3))
  6589. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6590. utils.ErrorLog("解析失败:%v", err)
  6591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6592. return
  6593. }
  6594. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6595. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6596. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6597. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6598. resp3, requestErr3 := http.Get(api3)
  6599. if requestErr3 != nil {
  6600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6601. return
  6602. }
  6603. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6604. if ioErr3 != nil {
  6605. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6607. return
  6608. }
  6609. var respJSON3 map[string]interface{}
  6610. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6611. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6613. return
  6614. }
  6615. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6616. userJSONBytes3, _ := json.Marshal(respJSON3)
  6617. fmt.Println("log")
  6618. fmt.Println(string(userJSONBytes3))
  6619. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6620. utils.ErrorLog("解析失败:%v", err)
  6621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6622. return
  6623. }
  6624. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6625. res2.Output = resSix10265.Output
  6626. res2.ErrMsg = resSix10265.ErrMsg
  6627. res2.Cainfo = resSix10265.Cainfo
  6628. res2.WarnMsg = resSix10265.WarnMsg
  6629. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6630. res2.Infcode = infocode
  6631. } else {
  6632. if miConfig.Code == "H15049901371" {
  6633. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6634. var dat map[string]interface{}
  6635. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6636. fmt.Println(dat)
  6637. } else {
  6638. fmt.Println(err)
  6639. }
  6640. saveLog(result2, src_request, "2205", "撤销明细")
  6641. userJSONBytes, _ := json.Marshal(dat)
  6642. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6643. utils.ErrorLog("解析失败:%v", err)
  6644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6645. return
  6646. }
  6647. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6648. res2.Output = resSix10265.Output
  6649. res2.ErrMsg = resSix10265.ErrMsg
  6650. res2.Cainfo = resSix10265.Cainfo
  6651. res2.WarnMsg = resSix10265.WarnMsg
  6652. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6653. res2.Infcode = infocode
  6654. } else {
  6655. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  6656. var dat map[string]interface{}
  6657. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6658. fmt.Println(dat)
  6659. } else {
  6660. fmt.Println(err)
  6661. }
  6662. saveLog(result2, src_request, "2205", "撤销明细")
  6663. userJSONBytes, _ := json.Marshal(dat)
  6664. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6665. utils.ErrorLog("解析失败:%v", err)
  6666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6667. return
  6668. }
  6669. }
  6670. }
  6671. if res2.Infcode == 0 {
  6672. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  6673. if err == nil {
  6674. c.ServeSuccessJSON(map[string]interface{}{
  6675. "msg": "退费成功",
  6676. })
  6677. } else {
  6678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6679. return
  6680. }
  6681. } else {
  6682. c.ServeSuccessJSON(map[string]interface{}{
  6683. "code": -10,
  6684. "msg": res2.ErrMsg,
  6685. })
  6686. }
  6687. } else {
  6688. c.ServeSuccessJSON(map[string]interface{}{
  6689. "code": -10,
  6690. "msg": res.ErrMsg,
  6691. })
  6692. }
  6693. }
  6694. }
  6695. func (c *HisApiController) RefundNumber() {
  6696. record_time := c.GetString("record_time")
  6697. //patient_id, _ := c.GetInt64("patient_id")
  6698. admin_user_id, _ := c.GetInt64("admin_user_id")
  6699. his_patient_id, _ := c.GetInt64("id")
  6700. timeLayout := "2006-01-02"
  6701. loc, _ := time.LoadLocation("Local")
  6702. adminUser := c.GetAdminUserInfo()
  6703. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6704. fmt.Println(err)
  6705. if err != nil {
  6706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6707. return
  6708. }
  6709. recordDateTime := theTime.Unix()
  6710. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6711. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  6712. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6713. //order, _ := service.GetHisOrderByID(order_id)
  6714. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6715. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6716. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6717. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  6718. if count > 0 {
  6719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  6720. return
  6721. }
  6722. if config.IsOpen == 1 { //对接了医保,走医保流程
  6723. var res2 ResultSix
  6724. var resSix10265 ResultSix10265
  6725. if miConfig.MdtrtareaAdmvs == "421300" {
  6726. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  6727. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6728. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6729. resp3, requestErr3 := http.Get(api3)
  6730. if requestErr3 != nil {
  6731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6732. return
  6733. }
  6734. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6735. if ioErr3 != nil {
  6736. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6738. return
  6739. }
  6740. var respJSON3 map[string]interface{}
  6741. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6742. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6744. return
  6745. }
  6746. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6747. userJSONBytes3, _ := json.Marshal(respJSON3)
  6748. fmt.Println("log")
  6749. fmt.Println(string(userJSONBytes3))
  6750. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6751. utils.ErrorLog("解析失败:%v", err)
  6752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6753. return
  6754. }
  6755. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6756. api3 := "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  6757. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6758. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6759. resp3, requestErr3 := http.Get(api3)
  6760. if requestErr3 != nil {
  6761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6762. return
  6763. }
  6764. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6765. if ioErr3 != nil {
  6766. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6768. return
  6769. }
  6770. var respJSON3 map[string]interface{}
  6771. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6772. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6774. return
  6775. }
  6776. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6777. userJSONBytes3, _ := json.Marshal(respJSON3)
  6778. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6779. utils.ErrorLog("解析失败:%v", err)
  6780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6781. return
  6782. }
  6783. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6784. res2.Output = resSix10265.Output
  6785. res2.ErrMsg = resSix10265.ErrMsg
  6786. res2.Cainfo = resSix10265.Cainfo
  6787. res2.WarnMsg = resSix10265.WarnMsg
  6788. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6789. res2.Infcode = infocode
  6790. } else {
  6791. var api3 string
  6792. if miConfig.Code == "H15049901371" {
  6793. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6794. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6795. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6796. } else {
  6797. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  6798. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6799. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6800. }
  6801. resp3, requestErr3 := http.Get(api3)
  6802. if requestErr3 != nil {
  6803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6804. return
  6805. }
  6806. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6807. if ioErr3 != nil {
  6808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6810. return
  6811. }
  6812. var respJSON3 map[string]interface{}
  6813. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6814. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6816. return
  6817. }
  6818. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6819. userJSONBytes3, _ := json.Marshal(respJSON3)
  6820. if miConfig.Code == "H15049901371" {
  6821. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6822. utils.ErrorLog("解析失败:%v", err)
  6823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6824. return
  6825. }
  6826. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6827. res2.Output = resSix10265.Output
  6828. res2.ErrMsg = resSix10265.ErrMsg
  6829. res2.Cainfo = resSix10265.Cainfo
  6830. res2.WarnMsg = resSix10265.WarnMsg
  6831. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6832. res2.Infcode = infocode
  6833. } else {
  6834. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6835. utils.ErrorLog("解析失败:%v", err)
  6836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6837. return
  6838. }
  6839. }
  6840. }
  6841. if res2.Infcode == 0 {
  6842. if err == nil {
  6843. c.ServeSuccessJSON(map[string]interface{}{
  6844. "msg": "退号成功",
  6845. })
  6846. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  6847. } else {
  6848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6849. return
  6850. }
  6851. } else {
  6852. c.ServeSuccessJSON(map[string]interface{}{
  6853. "code": -10,
  6854. "msg": res2.ErrMsg,
  6855. })
  6856. }
  6857. } else {
  6858. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  6859. //if err == nil {
  6860. // c.ServeSuccessJSON(map[string]interface{}{
  6861. // "msg": "退费成功",
  6862. // })
  6863. //} else {
  6864. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6865. // return
  6866. //}
  6867. }
  6868. }
  6869. func (c *HisApiController) RefundDetail() {
  6870. order_id, _ := c.GetInt64("order_id")
  6871. //admin_user_id, _ := c.GetInt64("admin_user_id")
  6872. //his_patient_id, _ := c.GetInt64("his_patient_id")
  6873. number := c.GetString("number")
  6874. record_time := c.GetString("record_time")
  6875. patient_id, _ := c.GetInt64("patient_id")
  6876. timeLayout := "2006-01-02"
  6877. loc, _ := time.LoadLocation("Local")
  6878. adminUser := c.GetAdminUserInfo()
  6879. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6880. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6881. fmt.Println(err)
  6882. if err != nil {
  6883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6884. return
  6885. }
  6886. recordDateTime := theTime.Unix()
  6887. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6888. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6889. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6890. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6891. var order models.HisOrder
  6892. order, _ = service.GetHisOrderByID(order_id)
  6893. if order.ID == 0 {
  6894. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  6895. }
  6896. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6897. if config.IsOpen == 1 { //对接了医保,走医保流程
  6898. var res2 ResultSix
  6899. if miConfig.MdtrtareaAdmvs == "421300" {
  6900. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  6901. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6902. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6903. resp3, requestErr3 := http.Get(api3)
  6904. if requestErr3 != nil {
  6905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6906. return
  6907. }
  6908. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6909. if ioErr3 != nil {
  6910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6912. return
  6913. }
  6914. var respJSON3 map[string]interface{}
  6915. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6918. return
  6919. }
  6920. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6921. userJSONBytes3, _ := json.Marshal(respJSON3)
  6922. fmt.Println("log")
  6923. fmt.Println(string(userJSONBytes3))
  6924. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  6925. utils.ErrorLog("解析失败:%v", err)
  6926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6927. return
  6928. }
  6929. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6930. if err == nil {
  6931. c.ServeSuccessJSON(map[string]interface{}{
  6932. "msg": "撤销明细成功",
  6933. })
  6934. return
  6935. } else {
  6936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6937. return
  6938. }
  6939. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6940. var resSix10265 ResultSix10265
  6941. api3 := "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  6942. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6943. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  6944. resp3, requestErr3 := http.Get(api3)
  6945. if requestErr3 != nil {
  6946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6947. return
  6948. }
  6949. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  6950. if ioErr3 != nil {
  6951. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  6952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6953. return
  6954. }
  6955. var respJSON3 map[string]interface{}
  6956. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  6957. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6959. return
  6960. }
  6961. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6962. userJSONBytes3, _ := json.Marshal(respJSON3)
  6963. fmt.Println("log")
  6964. fmt.Println(string(userJSONBytes3))
  6965. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  6966. utils.ErrorLog("解析失败:%v", err)
  6967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6968. return
  6969. }
  6970. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6971. res2.Output = resSix10265.Output
  6972. res2.ErrMsg = resSix10265.ErrMsg
  6973. res2.Cainfo = resSix10265.Cainfo
  6974. res2.WarnMsg = resSix10265.WarnMsg
  6975. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6976. res2.Infcode = infocode
  6977. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  6978. if err == nil {
  6979. c.ServeSuccessJSON(map[string]interface{}{
  6980. "msg": "撤销明细成功",
  6981. })
  6982. return
  6983. } else {
  6984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6985. return
  6986. }
  6987. } else {
  6988. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  6989. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  6990. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6991. resp2, requestErr2 := http.Get(api2)
  6992. if requestErr2 != nil {
  6993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6994. return
  6995. }
  6996. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  6997. if ioErr2 != nil {
  6998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  6999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7000. return
  7001. }
  7002. var respJSON2 map[string]interface{}
  7003. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7006. return
  7007. }
  7008. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7009. if err == nil {
  7010. c.ServeSuccessJSON(map[string]interface{}{
  7011. "msg": "撤销明细成功",
  7012. })
  7013. return
  7014. } else {
  7015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7016. return
  7017. }
  7018. }
  7019. } else {
  7020. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7021. if err == nil {
  7022. c.ServeSuccessJSON(map[string]interface{}{
  7023. "msg": "退费成功",
  7024. })
  7025. } else {
  7026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7027. return
  7028. }
  7029. }
  7030. }
  7031. //对账
  7032. func (c *HisApiController) GetCheckAccount() {
  7033. start_time := c.GetString("start_time")
  7034. end_time := c.GetString("end_time")
  7035. insutype := c.GetString("insutype")
  7036. clr_type := c.GetString("clr_type")
  7037. clr_org := c.GetString("clr_optins")
  7038. admin_user_id, _ := c.GetInt64("admin_user_id")
  7039. adminUser := c.GetAdminUserInfo()
  7040. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7041. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7042. if len(clr_org) == 0 {
  7043. clr_org = miConfig.MdtrtareaAdmvs
  7044. }
  7045. timeLayout := "2006-01-02"
  7046. loc, _ := time.LoadLocation("Local")
  7047. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7048. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7049. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  7050. fixmedins_setl_cnt := int64(len(orders))
  7051. var medfee_sumamt float64
  7052. var acct_pay float64
  7053. var fund_pay_sumamt float64
  7054. for _, item := range orders {
  7055. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7056. acct_pay = acct_pay + item.AcctPay
  7057. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7058. }
  7059. var user_name string
  7060. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7061. if role.ID == 0 {
  7062. user_name = "xxx"
  7063. } else {
  7064. user_name = role.UserName
  7065. }
  7066. var res ResultEight
  7067. var res10188 ResultEightFor10188
  7068. if config.IsOpen == 1 {
  7069. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7070. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  7071. "insutype=" + insutype +
  7072. "&clr_type=" + "11" +
  7073. "&setl_optins=" + clr_org +
  7074. "&stmt_begndate=" + start_time +
  7075. "&stm_enddate=" + end_time +
  7076. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7077. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7078. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7079. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7080. "&fixmedins_code=" + miConfig.Code +
  7081. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7082. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7083. "&secret_key=" + miConfig.SecretKey +
  7084. "&org_name=" + miConfig.OrgName +
  7085. "&doctor=" + user_name +
  7086. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7087. fmt.Println(api)
  7088. resp, requestErr := http.Get(api)
  7089. if requestErr != nil {
  7090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7091. return
  7092. }
  7093. body, ioErr := ioutil.ReadAll(resp.Body)
  7094. fmt.Println(body)
  7095. if ioErr != nil {
  7096. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7098. return
  7099. }
  7100. var respJSON map[string]interface{}
  7101. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7102. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7104. return
  7105. }
  7106. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7107. userJSONBytes, _ := json.Marshal(respJSON)
  7108. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7109. utils.ErrorLog("解析失败:%v", err)
  7110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7111. return
  7112. }
  7113. res.InfRefmsgid = res10188.InfRefmsgid
  7114. res.Output = res10188.Output
  7115. res.ErrMsg = res10188.ErrMsg
  7116. res.Cainfo = res10188.Cainfo
  7117. res.WarnMsg = res10188.WarnMsg
  7118. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  7119. res.Infcode = infocode
  7120. } else {
  7121. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7122. "insutype=" + insutype +
  7123. "&clr_type=" + clr_type +
  7124. "&setl_optins=" + clr_org +
  7125. "&stmt_begndate=" + start_time +
  7126. "&stm_enddate=" + end_time +
  7127. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7128. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7129. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7130. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7131. "&fixmedins_code=" + miConfig.Code +
  7132. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7133. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7134. "&secret_key=" + miConfig.SecretKey +
  7135. "&org_name=" + miConfig.OrgName +
  7136. "&doctor=" + user_name
  7137. fmt.Println(api)
  7138. resp, requestErr := http.Get(api)
  7139. if requestErr != nil {
  7140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7141. return
  7142. }
  7143. body, ioErr := ioutil.ReadAll(resp.Body)
  7144. fmt.Println(body)
  7145. if ioErr != nil {
  7146. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7148. return
  7149. }
  7150. var respJSON map[string]interface{}
  7151. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7152. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7154. return
  7155. }
  7156. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7157. userJSONBytes, _ := json.Marshal(respJSON)
  7158. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7159. utils.ErrorLog("解析失败:%v", err)
  7160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7161. return
  7162. }
  7163. }
  7164. if res.Infcode == 0 {
  7165. if res.Output.Stmtinfo.StmtRslt == "0" {
  7166. micc := &models.MedicalInsuranceCostCompare{
  7167. StartTime: startime.Unix(),
  7168. EndTime: endtime.Unix(),
  7169. Insutype: insutype,
  7170. CheckType: 1,
  7171. Num: fixmedins_setl_cnt,
  7172. Mtime: time.Now().Unix(),
  7173. Status: 1,
  7174. UserOrgId: adminUser.CurrentOrgId,
  7175. CostTotal: medfee_sumamt,
  7176. FuncTotal: fund_pay_sumamt,
  7177. PsnPay: acct_pay,
  7178. Creator: admin_user_id,
  7179. Ctime: time.Now().Unix(),
  7180. ClrType: clr_type,
  7181. }
  7182. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  7183. if err == nil {
  7184. c.ServeSuccessJSON(map[string]interface{}{
  7185. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7186. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7187. })
  7188. } else {
  7189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7190. }
  7191. } else {
  7192. c.ServeSuccessJSON(map[string]interface{}{
  7193. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  7194. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  7195. })
  7196. }
  7197. } else {
  7198. c.ServeSuccessJSON(map[string]interface{}{
  7199. "code": -10,
  7200. "msg": res.ErrMsg,
  7201. })
  7202. }
  7203. }
  7204. }
  7205. func (c *HisApiController) Check310() {
  7206. adminUser := c.GetAdminUserInfo()
  7207. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7208. var user_name string
  7209. user_name = "高慧裕"
  7210. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7211. "insutype=" + "310" +
  7212. "&clr_type=" + "" +
  7213. "&setl_optins=" + "441202" +
  7214. "&stmt_begndate=" + "2022-03-01" +
  7215. "&stm_enddate=" + "2022-03-31" +
  7216. "&medfee_sumamt=" + "194930.12" +
  7217. "&fund_pay_sumamt=" + "188741.46" +
  7218. "&acct_pay=" + "0" +
  7219. "&fixmedins_setl_cnt=" + "452" +
  7220. "&fixmedins_code=" + miConfig.Code +
  7221. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7222. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7223. "&secret_key=" + miConfig.SecretKey +
  7224. "&org_name=" + miConfig.OrgName +
  7225. "&doctor=" + user_name
  7226. fmt.Println(api)
  7227. resp, requestErr := http.Get(api)
  7228. if requestErr != nil {
  7229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7230. return
  7231. }
  7232. body, ioErr := ioutil.ReadAll(resp.Body)
  7233. fmt.Println(body)
  7234. if ioErr != nil {
  7235. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7237. return
  7238. }
  7239. var respJSON map[string]interface{}
  7240. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7241. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7243. return
  7244. }
  7245. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7246. userJSONBytes, _ := json.Marshal(respJSON)
  7247. var res ResultEight
  7248. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7249. utils.ErrorLog("解析失败:%v", err)
  7250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7251. return
  7252. }
  7253. }
  7254. func (c *HisApiController) Check390() {
  7255. adminUser := c.GetAdminUserInfo()
  7256. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7257. var user_name string
  7258. user_name = "高慧裕"
  7259. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7260. "insutype=" + "390" +
  7261. "&clr_type=" + "" +
  7262. "&setl_optins=" + "441202" +
  7263. "&stmt_begndate=" + "2022-03-01" +
  7264. "&stm_enddate=" + "2022-03-31" +
  7265. "&medfee_sumamt=" + "1068448.89" +
  7266. "&fund_pay_sumamt=" + "1014677.62" +
  7267. "&acct_pay=" + "0" +
  7268. "&fixmedins_setl_cnt=" + "1950" +
  7269. "&fixmedins_code=" + miConfig.Code +
  7270. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7271. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7272. "&secret_key=" + miConfig.SecretKey +
  7273. "&org_name=" + miConfig.OrgName +
  7274. "&doctor=" + user_name
  7275. fmt.Println(api)
  7276. resp, requestErr := http.Get(api)
  7277. if requestErr != nil {
  7278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7279. return
  7280. }
  7281. body, ioErr := ioutil.ReadAll(resp.Body)
  7282. fmt.Println(body)
  7283. if ioErr != nil {
  7284. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7286. return
  7287. }
  7288. var respJSON map[string]interface{}
  7289. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7290. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7292. return
  7293. }
  7294. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7295. userJSONBytes, _ := json.Marshal(respJSON)
  7296. var res ResultEight
  7297. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7298. utils.ErrorLog("解析失败:%v", err)
  7299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7300. return
  7301. }
  7302. }
  7303. //对账明细
  7304. func (c *HisApiController) GetCheckDetailAccount() {
  7305. start_time := c.GetString("start_time")
  7306. end_time := c.GetString("end_time")
  7307. admin_user_id, _ := c.GetInt64("admin_user_id")
  7308. adminUser := c.GetAdminUserInfo()
  7309. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7310. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7311. timeLayout := "2006-01-02"
  7312. loc, _ := time.LoadLocation("Local")
  7313. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7314. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7315. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  7316. Mkdir(miConfig.OrgName)
  7317. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  7318. file_name := file + ".txt"
  7319. zip_name := file + ".zip"
  7320. zip_path := miConfig.OrgName + "/" + zip_name
  7321. file_path := miConfig.OrgName + "/" + file_name
  7322. decimal.DivisionPrecision = 2
  7323. var medfee_sumamt float64
  7324. var psn_cash_pay float64
  7325. var fund_pay_sumamt float64
  7326. fixmedins_setl_cnt := int64(len(orders))
  7327. for _, item := range orders {
  7328. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7329. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  7330. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7331. }
  7332. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  7333. defer f.Close()
  7334. if err != nil {
  7335. fmt.Println(err.Error())
  7336. } else {
  7337. for _, item := range orders {
  7338. var refd_setl_flag string
  7339. if item.OrderStatus == 2 {
  7340. refd_setl_flag = "0"
  7341. var str string
  7342. str = item.SetlId + " " +
  7343. item.MdtrtId + " " +
  7344. item.PsnNo + " " +
  7345. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7346. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7347. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  7348. _, err = f.Write([]byte(str))
  7349. }
  7350. if item.OrderStatus == 3 {
  7351. var str string
  7352. str = item.SetlId + " " +
  7353. item.MdtrtId + " " +
  7354. item.PsnNo + " " +
  7355. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  7356. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  7357. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  7358. _, err = f.Write([]byte(str))
  7359. var str2 string
  7360. str2 = item.SetlId + " " +
  7361. item.MdtrtId + " " +
  7362. item.PsnNo + " " +
  7363. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  7364. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  7365. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  7366. _, err = f.Write([]byte(str2))
  7367. }
  7368. }
  7369. }
  7370. Zip(file_path, zip_path)
  7371. fmt.Println(ReadFile(zip_path))
  7372. fmt.Println(string(ReadFile(zip_path)))
  7373. if config.IsOpen == 1 {
  7374. var user_name string
  7375. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7376. if role.ID == 0 {
  7377. user_name = "管理员"
  7378. } else {
  7379. user_name = role.UserName
  7380. }
  7381. baseParams := models.BaseParams{
  7382. SecretKey: miConfig.SecretKey,
  7383. FixmedinsCode: miConfig.Code,
  7384. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7385. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7386. OrgName: miConfig.OrgName,
  7387. Doctor: user_name,
  7388. }
  7389. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  7390. var dat map[string]interface{}
  7391. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7392. fmt.Println(dat)
  7393. } else {
  7394. fmt.Println(err)
  7395. }
  7396. userJSONBytes, _ := json.Marshal(dat)
  7397. var res ResultNine
  7398. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7399. utils.ErrorLog("解析失败:%v", err)
  7400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7401. return
  7402. }
  7403. if res.Infcode == 0 {
  7404. fileNo := res.Output.FileQuryNo
  7405. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  7406. "file_qury_no=" + fileNo +
  7407. "&setl_optins=" + "定点医保中心" +
  7408. "&stmt_begndate=" + start_time +
  7409. "&stm_enddate=" + end_time +
  7410. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7411. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7412. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  7413. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7414. "&fixmedins_code=" + miConfig.Code +
  7415. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7416. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7417. "&secret_key=" + miConfig.SecretKey +
  7418. "&org_name=" + miConfig.OrgName +
  7419. "&doctor=" + user_name
  7420. resp, requestErr := http.Get(api)
  7421. if requestErr != nil {
  7422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7423. return
  7424. }
  7425. body, ioErr := ioutil.ReadAll(resp.Body)
  7426. if ioErr != nil {
  7427. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7429. return
  7430. }
  7431. var respJSON map[string]interface{}
  7432. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7433. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7435. return
  7436. }
  7437. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7438. userJSONBytes, _ := json.Marshal(respJSON)
  7439. var res ResultTen
  7440. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7441. utils.ErrorLog("解析失败:%v", err)
  7442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7443. return
  7444. }
  7445. if res.Infcode == 0 {
  7446. service.Gdyb9102(baseParams, zip_name, fileNo)
  7447. micc := &models.MedicalInsuranceCostCompare{
  7448. StartTime: startime.Unix(),
  7449. EndTime: endtime.Unix(),
  7450. Insutype: "0",
  7451. CheckType: 2,
  7452. Num: fixmedins_setl_cnt,
  7453. Mtime: time.Now().Unix(),
  7454. Status: 1,
  7455. UserOrgId: adminUser.CurrentOrgId,
  7456. CostTotal: medfee_sumamt,
  7457. FuncTotal: fund_pay_sumamt,
  7458. PsnPay: psn_cash_pay,
  7459. Creator: admin_user_id,
  7460. Ctime: time.Now().Unix(),
  7461. }
  7462. service.CreateMedicalInsuranceCostCompareRecord(micc)
  7463. c.ServeSuccessJSON(map[string]interface{}{
  7464. "msg": "明细对账成功",
  7465. })
  7466. }
  7467. } else {
  7468. }
  7469. }
  7470. }
  7471. type CustomOrderInfo struct {
  7472. Name string
  7473. Spec string
  7474. Unit string
  7475. Count float64
  7476. Price float64
  7477. Total float64
  7478. }
  7479. func (c *HisApiController) GetSettleAccounts() {
  7480. //id, _ := c.GetInt64("id")
  7481. //record_time := c.GetString("record_time")
  7482. order_id, _ := c.GetInt64("order_id")
  7483. admin_user_id, _ := c.GetInt64("admin_user_id")
  7484. //timeLayout := "2006-01-02"
  7485. //loc, _ := time.LoadLocation("Local")
  7486. //
  7487. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7488. //if err != nil {
  7489. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7490. // return
  7491. //}
  7492. //recordDateTime := theTime.Unix()
  7493. adminUser := c.GetAdminUserInfo()
  7494. order, _ := service.GetHisOrderByID(order_id)
  7495. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7496. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  7497. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  7498. orderInfos = append(orderInfos, orderInfos_two...)
  7499. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  7500. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  7501. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  7502. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  7503. //var config []*models.HisXtDiagnoseConfig
  7504. var name string
  7505. for _, item := range diagnosis_ids {
  7506. id, _ := strconv.ParseInt(item, 10, 64)
  7507. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7508. if len(name) == 0 {
  7509. name = diagnosisConfig.ClassName
  7510. } else {
  7511. name = name + "," + diagnosisConfig.ClassName
  7512. }
  7513. }
  7514. var bedCostTotal float64 = 0 //床位总费
  7515. var bedCostSelfTotal float64 = 0 //床位自费
  7516. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  7517. var operationCostTotal float64 = 0 //手术费
  7518. var operationCostSelfTotal float64 = 0 //手术费
  7519. var operationCostPartSelfTotal float64 = 0 //手术费
  7520. var otherCostTotal float64 = 0 //其他费用
  7521. var otherCostSelfTotal float64 = 0 //其他费用
  7522. var otherCostPartSelfTotal float64 = 0 //其他费用
  7523. var materialCostTotal float64 = 0 //材料费
  7524. var materialCostSelfTotal float64 = 0 //材料费
  7525. var materialCostPartSelfTotal float64 = 0 //材料费
  7526. var westernMedicineCostTotal float64 = 0 //西药费
  7527. var westernMedicineCostSelfTotal float64 = 0 //西药费
  7528. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  7529. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  7530. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  7531. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  7532. var checkCostTotal float64 = 0 //检查费
  7533. var checkCostSelfTotal float64 = 0 //检查费
  7534. var checkCostPartSelfTotal float64 = 0 //检查费
  7535. var laboratoryCostTotal float64 = 0 //化验费
  7536. var laboratoryCostSelfTotal float64 = 0 //化验费
  7537. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  7538. var treatCostTotal float64 = 0 //治疗费用
  7539. var treatCostSelfTotal float64 = 0 //治疗费用
  7540. var treatCostPartSelfTotal float64 = 0 //治疗费用
  7541. decimal.DivisionPrecision = 2
  7542. for _, item := range orderInfos {
  7543. if item.MedChrgitmType == "01" { //床位费
  7544. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7545. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7546. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7547. }
  7548. if item.MedChrgitmType == "03" { //检查费
  7549. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7550. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7551. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7552. }
  7553. if item.MedChrgitmType == "04" { //化验费
  7554. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7555. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7556. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7557. }
  7558. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  7559. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7560. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7561. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7562. }
  7563. if item.MedChrgitmType == "06" { //手术费
  7564. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7565. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7566. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7567. }
  7568. if item.MedChrgitmType == "08" { //材料费
  7569. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7570. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7571. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7572. }
  7573. if item.MedChrgitmType == "09" { //西药费
  7574. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7575. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7576. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7577. }
  7578. if item.MedChrgitmType == "11" { //中成费
  7579. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7580. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7581. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7582. }
  7583. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" { //其他费
  7584. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7585. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7586. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7587. }
  7588. }
  7589. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7590. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7591. var user_name string
  7592. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7593. if role.ID == 0 {
  7594. user_name = "管理员"
  7595. } else {
  7596. user_name = role.UserName
  7597. }
  7598. baseParams := models.BaseParams{
  7599. SecretKey: miConfig.SecretKey,
  7600. FixmedinsCode: miConfig.Code,
  7601. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7602. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7603. OrgName: miConfig.OrgName,
  7604. Doctor: user_name,
  7605. }
  7606. businessParams := models.BusinessParams{
  7607. PsnNo: order.PsnNo,
  7608. MdtrtId: order.MdtrtId,
  7609. SetlId: order.SetlId,
  7610. }
  7611. var res ResultEleven
  7612. var resEleven10265 ResultEleven10265
  7613. if config.IsOpen == 1 {
  7614. if miConfig.MdtrtareaAdmvs == "421300" {
  7615. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7616. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7617. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7618. resp, requestErr := http.Get(api)
  7619. if requestErr != nil {
  7620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7621. return
  7622. }
  7623. body, ioErr := ioutil.ReadAll(resp.Body)
  7624. if ioErr != nil {
  7625. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7627. return
  7628. }
  7629. var respJSON map[string]interface{}
  7630. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7633. return
  7634. }
  7635. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7636. result, _ := json.Marshal(respJSON)
  7637. fmt.Println("log")
  7638. fmt.Println(string(result))
  7639. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7640. utils.ErrorLog("解析失败:%v", err)
  7641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7642. return
  7643. }
  7644. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7645. api := "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  7646. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  7647. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7648. resp, requestErr := http.Get(api)
  7649. if requestErr != nil {
  7650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7651. return
  7652. }
  7653. body, ioErr := ioutil.ReadAll(resp.Body)
  7654. if ioErr != nil {
  7655. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7657. return
  7658. }
  7659. var respJSON map[string]interface{}
  7660. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7661. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7663. return
  7664. }
  7665. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7666. result, _ := json.Marshal(respJSON)
  7667. fmt.Println("log")
  7668. fmt.Println(string(result))
  7669. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  7670. utils.ErrorLog("解析失败:%v", err)
  7671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7672. return
  7673. }
  7674. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7675. res.Output = resEleven10265.Output
  7676. res.ErrMsg = resEleven10265.ErrMsg
  7677. res.Cainfo = resEleven10265.Cainfo
  7678. res.WarnMsg = resEleven10265.WarnMsg
  7679. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7680. res.Infcode = infocode
  7681. } else {
  7682. //result2 := service.Gdyb1101()
  7683. result2 := service.Gdyb5204(baseParams, businessParams)
  7684. saveLog(result2, "", "5204", "查询")
  7685. result := service.Gdyb5203(baseParams, businessParams)
  7686. var dat map[string]interface{}
  7687. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7688. fmt.Println(dat)
  7689. } else {
  7690. fmt.Println(err)
  7691. }
  7692. userJSONBytes, _ := json.Marshal(dat)
  7693. if miConfig.Code == "H15049901371" {
  7694. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  7695. utils.ErrorLog("解析失败:%v", err)
  7696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7697. return
  7698. }
  7699. res.InfRefmsgid = resEleven10265.InfRefmsgid
  7700. res.Output = resEleven10265.Output
  7701. res.ErrMsg = resEleven10265.ErrMsg
  7702. res.Cainfo = resEleven10265.Cainfo
  7703. res.WarnMsg = resEleven10265.WarnMsg
  7704. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  7705. res.Infcode = infocode
  7706. } else {
  7707. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7708. utils.ErrorLog("解析失败:%v", err)
  7709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7710. return
  7711. }
  7712. }
  7713. }
  7714. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7715. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  7716. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  7717. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7718. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7719. var doctor_name string
  7720. if roles.ID == 0 {
  7721. doctor_name = "管理员"
  7722. } else {
  7723. doctor_name = roles.UserName
  7724. }
  7725. yiliao_leibie := ""
  7726. switch order.MedType {
  7727. case "11":
  7728. yiliao_leibie = "普通门诊"
  7729. break
  7730. case "12":
  7731. yiliao_leibie = "门诊挂号"
  7732. break
  7733. case "13":
  7734. yiliao_leibie = "急诊"
  7735. break
  7736. case "14":
  7737. yiliao_leibie = "门诊特殊病"
  7738. break
  7739. case "15":
  7740. yiliao_leibie = "门诊统筹"
  7741. break
  7742. case "16":
  7743. yiliao_leibie = "门诊慢性病"
  7744. break
  7745. case "21":
  7746. yiliao_leibie = "普通住院"
  7747. break
  7748. }
  7749. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7750. if res.Infcode == 0 {
  7751. c.ServeSuccessJSON(map[string]interface{}{
  7752. "diagnosis": name,
  7753. "order_infos": orderInfos,
  7754. "number": order.MdtrtId,
  7755. "date": order.SettleAccountsDate,
  7756. "charge_admin": charge_admin,
  7757. "printor_admin": printor_admin,
  7758. "info": res.Output.Setlinfo,
  7759. "bedCostTotal": bedCostTotal,
  7760. "bedCostSelfTotal": bedCostSelfTotal,
  7761. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  7762. "operationCostTotal": operationCostTotal,
  7763. "operationCostSelfTotal": operationCostSelfTotal,
  7764. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  7765. "otherCostTotal": otherCostTotal,
  7766. "otherCostSelfTotal": otherCostSelfTotal,
  7767. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  7768. "materialCostTotal": materialCostTotal,
  7769. "materialCostSelfTotal": materialCostSelfTotal,
  7770. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  7771. "westernMedicineCostTotal": westernMedicineCostTotal,
  7772. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  7773. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  7774. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  7775. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  7776. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  7777. "checkCostTotal": checkCostTotal,
  7778. "checkCostSelfTotal": checkCostSelfTotal,
  7779. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  7780. "laboratoryCostTotal": laboratoryCostTotal,
  7781. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  7782. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  7783. "treatCostTotal": treatCostTotal,
  7784. "treatCostSelfTotal": treatCostSelfTotal,
  7785. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  7786. "doctor_code": adminRole_two.DoctorCode,
  7787. "doctor_name": doctor_name,
  7788. "health_card_no": order.PsnNo,
  7789. "department": departments.Name,
  7790. "yiliao_leibie": yiliao_leibie,
  7791. "after_money": order.AccountPrice,
  7792. "patient": patient,
  7793. "org_name": miConfig.OrgName,
  7794. "org_code": miConfig.Code,
  7795. "order_number": order.Number,
  7796. "his_hospital": his_hospital,
  7797. "his": his,
  7798. //"check_order_info": cus_slice,
  7799. })
  7800. }
  7801. }
  7802. }
  7803. func (c *HisApiController) CheckTreatment() {
  7804. patient_id, _ := c.GetInt64("patient_id")
  7805. id_card_no := c.GetString("id_card_no")
  7806. insutype := c.GetString("insutype")
  7807. med_type := c.GetString("med_type")
  7808. admin_user_id, _ := c.GetInt64("admin_user_id")
  7809. adminUser := c.GetAdminUserInfo()
  7810. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  7811. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7812. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7813. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7814. if miConfig.MdtrtareaAdmvs == "421300" {
  7815. var res ResultTwo
  7816. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7817. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7818. "&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)
  7819. resp, requestErr := http.Get(api)
  7820. if requestErr != nil {
  7821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7822. return
  7823. }
  7824. body, ioErr := ioutil.ReadAll(resp.Body)
  7825. if ioErr != nil {
  7826. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7828. return
  7829. }
  7830. var respJSON map[string]interface{}
  7831. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7832. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7834. return
  7835. }
  7836. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7837. result, _ := json.Marshal(respJSON)
  7838. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7839. utils.ErrorLog("解析失败:%v", err)
  7840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7841. return
  7842. }
  7843. if res.Infcode == 0 {
  7844. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  7845. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7846. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  7847. resp, requestErr := http.Get(api)
  7848. if requestErr != nil {
  7849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7850. return
  7851. }
  7852. body, ioErr := ioutil.ReadAll(resp.Body)
  7853. if ioErr != nil {
  7854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7856. return
  7857. }
  7858. var respJSON map[string]interface{}
  7859. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7862. return
  7863. }
  7864. var res Result2001
  7865. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7866. result2, _ := json.Marshal(respJSON)
  7867. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  7868. utils.ErrorLog("解析失败:%v", err)
  7869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7870. return
  7871. }
  7872. if res.Infcode == 0 {
  7873. c.ServeSuccessJSON(map[string]interface{}{
  7874. "msg": res.Output.Trtinfo,
  7875. })
  7876. }
  7877. } else {
  7878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7879. return
  7880. }
  7881. } else {
  7882. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  7883. var dat map[string]interface{}
  7884. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7885. fmt.Println(dat)
  7886. } else {
  7887. fmt.Println(err)
  7888. }
  7889. userJSONBytes, _ := json.Marshal(dat)
  7890. var res ResultTwo
  7891. var res10265 ResultTwo10265
  7892. if miConfig.Code == "H15049901371" {
  7893. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7894. utils.ErrorLog("解析失败:%v", err)
  7895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7896. return
  7897. }
  7898. res.ErrMsg = res10265.ErrMsg
  7899. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7900. res.Infcode = infocode
  7901. res.Output = res10265.Output
  7902. res.InfRefmsgid = res10265.InfRefmsgid
  7903. } else {
  7904. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7905. utils.ErrorLog("解析失败:%v", err)
  7906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7907. return
  7908. }
  7909. }
  7910. var user_name string
  7911. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  7912. if role.ID == 0 {
  7913. user_name = "xxx"
  7914. } else {
  7915. user_name = role.UserName
  7916. }
  7917. baseParams := models.BaseParams{
  7918. SecretKey: miConfig.SecretKey,
  7919. FixmedinsCode: miConfig.Code,
  7920. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  7921. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  7922. OrgName: miConfig.OrgName,
  7923. Doctor: user_name,
  7924. }
  7925. if config.IsOpen == 1 {
  7926. if miConfig.Code == "H15049901371" {
  7927. if med_type == "14" {
  7928. if insutype == "390" {
  7929. med_type = "9933"
  7930. } else if insutype == "310" {
  7931. med_type = "990502"
  7932. }
  7933. } else if med_type == "11" {
  7934. med_type = "11"
  7935. }
  7936. }
  7937. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  7938. var dat map[string]interface{}
  7939. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7940. fmt.Println(dat)
  7941. } else {
  7942. fmt.Println(err)
  7943. }
  7944. var res Result2001
  7945. var res10265 Result2001Org10265
  7946. if miConfig.Code == "H15049901371" {
  7947. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7948. utils.ErrorLog("解析失败:%v", err)
  7949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7950. return
  7951. }
  7952. res.ErrMsg = res10265.ErrMsg
  7953. res.Output = res10265.Output
  7954. res.InfRefmsgid = res10265.InfRefmsgid
  7955. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7956. res.Infcode = infocode
  7957. } else {
  7958. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7959. utils.ErrorLog("解析失败:%v", err)
  7960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7961. return
  7962. }
  7963. }
  7964. if res.Infcode == 0 {
  7965. c.ServeSuccessJSON(map[string]interface{}{
  7966. "msg": res.Output.Trtinfo,
  7967. })
  7968. }
  7969. }
  7970. }
  7971. }
  7972. //func (c *HisApiController) PutRecord() {
  7973. // id, _ := c.GetInt64("id")
  7974. // record_time := c.GetString("record_time")
  7975. // timeLayout := "2006-01-02"
  7976. // loc, _ := time.LoadLocation("Local")
  7977. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7978. // if err != nil {
  7979. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7980. // return
  7981. // }
  7982. // recordDateTime := theTime.Unix()
  7983. //
  7984. // adminInfo := c.GetAdminUserInfo()
  7985. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  7986. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  7987. //
  7988. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7989. //
  7990. // fmt.Println(miConfig.SecretKey)
  7991. //
  7992. // if patient == nil {
  7993. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  7994. // return
  7995. // }
  7996. // if len(patient.IdCardNo) == 0 {
  7997. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  7998. // return
  7999. // }
  8000. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  8001. // if config.IsOpen == 1 {
  8002. // 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
  8003. // resp, requestErr := http.Get(api)
  8004. // if requestErr != nil {
  8005. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8006. // return
  8007. // }
  8008. // defer resp.Body.Close()
  8009. // body, ioErr := ioutil.ReadAll(resp.Body)
  8010. // if ioErr != nil {
  8011. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8012. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8013. // return
  8014. // }
  8015. // var respJSON map[string]interface{}
  8016. //
  8017. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8018. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8019. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8020. // return
  8021. // }
  8022. //
  8023. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8024. // userJSONBytes, _ := json.Marshal(userJSON)
  8025. // var res ResultTwo
  8026. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8027. // utils.ErrorLog("解析失败:%v", err)
  8028. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8029. // return
  8030. // }
  8031. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8032. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8033. // infoStr := string(Iinfos)
  8034. // idetinfoStr := string(Idetinfos)
  8035. //
  8036. // if res.Infcode == 0 {
  8037. // his := models.VMHisPatient{
  8038. // Status: 1,
  8039. // Ctime: time.Now().Unix(),
  8040. // Mtime: time.Now().Unix(),
  8041. // PsnNo: res.Output.Baseinfo.PsnNo,
  8042. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  8043. // Certno: res.Output.Baseinfo.Certno,
  8044. // PsnName: res.Output.Baseinfo.PsnName,
  8045. // Gend: res.Output.Baseinfo.Gend,
  8046. // Naty: res.Output.Baseinfo.Naty,
  8047. // Brdy: res.Output.Baseinfo.Brdy,
  8048. // Age: res.Output.Baseinfo.Age,
  8049. // Iinfo: infoStr,
  8050. // Idetinfo: idetinfoStr,
  8051. // PatientId: patient.ID,
  8052. // RecordDate: theTime.Unix(),
  8053. // UserOrgId: adminInfo.CurrentOrgId,
  8054. // AdminUserId: adminInfo.AdminUser.Id,
  8055. // IsReturn: 1,
  8056. // }
  8057. //
  8058. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  8059. // //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")
  8060. // //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")
  8061. //
  8062. // //var dat map[string]interface{}
  8063. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8064. // // fmt.Println(dat)
  8065. // //} else {
  8066. // // fmt.Println(err)
  8067. // //}
  8068. //
  8069. // var dat2 map[string]interface{}
  8070. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8071. // fmt.Println(dat2)
  8072. // } else {
  8073. // fmt.Println(err)
  8074. // }
  8075. //
  8076. // } else {
  8077. // adminUser := c.GetAdminUserInfo()
  8078. // errlog := &models.HisOrderError{
  8079. // UserOrgId: adminUser.CurrentOrgId,
  8080. // Ctime: time.Now().Unix(),
  8081. // Mtime: time.Now().Unix(),
  8082. // ErrMsg: res.ErrMsg,
  8083. // Status: 1,
  8084. // PatientId: id,
  8085. // RecordTime: recordDateTime,
  8086. // Stage: 1,
  8087. // }
  8088. // service.CreateErrMsgLog(errlog)
  8089. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  8090. // return
  8091. // }
  8092. // }
  8093. //
  8094. //}
  8095. //func (c *HisApiController) GetUploadDiag() {
  8096. // id, _ := c.GetInt64("id")
  8097. // record_time := c.GetString("record_time")
  8098. //
  8099. // diagnosis_id, _ := c.GetInt64("diagnosis")
  8100. // sick_type, _ := c.GetInt64("sick_type")
  8101. // reg_type, _ := c.GetInt64("reg_type")
  8102. //
  8103. // timeLayout := "2006-01-02"
  8104. // loc, _ := time.LoadLocation("Local")
  8105. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8106. // if err != nil {
  8107. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8108. // return
  8109. // }
  8110. //
  8111. // var patientPrescription models.HisPrescriptionInfo
  8112. // recordDateTime := theTime.Unix()
  8113. // adminInfo := c.GetAdminUserInfo()
  8114. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8115. //
  8116. // if patientPrescription.ID == 0 {
  8117. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8118. // }
  8119. //
  8120. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8121. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  8122. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8123. // sickConfig, _ := service.FindSickById(sick_type)
  8124. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8125. //
  8126. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  8127. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  8128. // "&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 +
  8129. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  8130. // resp2, requestErr2 := http.Get(api2)
  8131. // if requestErr2 != nil {
  8132. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8133. // return
  8134. // }
  8135. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8136. // if ioErr2 != nil {
  8137. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8138. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8139. // return
  8140. // }
  8141. // var respJSON2 map[string]interface{}
  8142. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8143. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8144. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8145. // return
  8146. // }
  8147. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8148. // userJSONBytes2, _ := json.Marshal(respJSON2)
  8149. //
  8150. // var res2 ResultSix
  8151. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  8152. // utils.ErrorLog("解析失败:%v", err)
  8153. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8154. // return
  8155. // }
  8156. // if res2.Infcode != 0 {
  8157. // adminUser := c.GetAdminUserInfo()
  8158. // errlog := &models.HisOrderError{
  8159. // UserOrgId: adminUser.CurrentOrgId,
  8160. // Ctime: time.Now().Unix(),
  8161. // Mtime: time.Now().Unix(),
  8162. // ErrMsg: res2.ErrMsg,
  8163. // Status: 1,
  8164. // PatientId: id,
  8165. // RecordTime: recordDateTime,
  8166. // Stage: 3,
  8167. // }
  8168. // service.CreateErrMsgLog(errlog)
  8169. //
  8170. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  8171. // return
  8172. // }
  8173. //
  8174. // c.ServeSuccessJSON(map[string]interface{}{
  8175. // "msg": "上传成功",
  8176. // })
  8177. //
  8178. //}
  8179. type QueryResult struct {
  8180. ID int64
  8181. Name string
  8182. Code string
  8183. List_type_code string
  8184. }
  8185. func (c *HisApiController) GetCheckCode() {
  8186. ids_str := c.GetString("ids")
  8187. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8188. ids_arr := strings.Split(ids_str, ",")
  8189. var queryResult []QueryResult
  8190. ids := make([]int64, 0)
  8191. for _, item := range ids_arr {
  8192. id, _ := strconv.ParseInt(item, 10, 64)
  8193. ids = append(ids, id)
  8194. }
  8195. if record_type == 1 {
  8196. drugs, _ := service.GetBatchDrugList(ids)
  8197. for _, item := range drugs {
  8198. result := QueryResult{
  8199. ID: item.ID,
  8200. Name: item.DrugName,
  8201. Code: item.MedicalInsuranceNumber,
  8202. List_type_code: "101",
  8203. }
  8204. queryResult = append(queryResult, result)
  8205. }
  8206. } else if record_type == 2 {
  8207. goods, _ := service.GetBatchGoodInformationList(ids)
  8208. for _, item := range goods {
  8209. result := QueryResult{
  8210. ID: item.ID,
  8211. Name: item.GoodName,
  8212. Code: item.MedicalInsuranceNumber,
  8213. List_type_code: "301",
  8214. }
  8215. queryResult = append(queryResult, result)
  8216. }
  8217. } else if record_type == 3 {
  8218. projects, _ := service.GetBathchMyPorjecgList(ids)
  8219. for _, item := range projects {
  8220. result := QueryResult{
  8221. ID: item.ID,
  8222. Name: item.ProjectName,
  8223. Code: item.MedicalCode,
  8224. List_type_code: "201",
  8225. }
  8226. queryResult = append(queryResult, result)
  8227. }
  8228. }
  8229. admin_user_id, _ := c.GetInt64("admin_user_id")
  8230. adminUser := c.GetAdminUserInfo()
  8231. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8232. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8233. var user_name string
  8234. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8235. if role.ID == 0 {
  8236. user_name = "xxx"
  8237. } else {
  8238. user_name = role.UserName
  8239. }
  8240. baseParams := &models.BaseParams{
  8241. SecretKey: miConfig.SecretKey,
  8242. FixmedinsCode: miConfig.Code,
  8243. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8244. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8245. OrgName: miConfig.OrgName,
  8246. Doctor: user_name,
  8247. }
  8248. if config.IsOpen == 1 {
  8249. for _, item := range queryResult {
  8250. var result string
  8251. if record_type == 1 {
  8252. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8253. } else if record_type == 2 {
  8254. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8255. } else if record_type == 3 {
  8256. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  8257. }
  8258. var dat map[string]interface{}
  8259. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8260. fmt.Println(dat)
  8261. } else {
  8262. fmt.Println(err)
  8263. }
  8264. userJSONBytes, _ := json.Marshal(dat)
  8265. var res ResultSix
  8266. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8267. utils.ErrorLog("解析失败:%v", err)
  8268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8269. return
  8270. }
  8271. if res.Infcode == 0 {
  8272. if record_type == 1 {
  8273. service.UpdateBaseDrugById(item.ID)
  8274. } else if record_type == 2 {
  8275. service.UpdateGoodInformaitonByDetail(item.ID)
  8276. } else if record_type == 3 {
  8277. service.UpdateProjectById(item.ID)
  8278. }
  8279. c.ServeSuccessJSON(map[string]interface{}{
  8280. "failed_code": 0,
  8281. "msg": "目录对照成功",
  8282. })
  8283. } else {
  8284. c.ServeSuccessJSON(map[string]interface{}{
  8285. "failed_code": -10,
  8286. "msg": res.ErrMsg,
  8287. })
  8288. }
  8289. }
  8290. }
  8291. }
  8292. func (c *HisApiController) UnCheckCode() {
  8293. ids_str := c.GetString("ids")
  8294. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  8295. admin_user_id, _ := c.GetInt64("admin_user_id")
  8296. ids_arr := strings.Split(ids_str, ",")
  8297. var queryResult []QueryResult
  8298. ids := make([]int64, 0)
  8299. for _, item := range ids_arr {
  8300. id, _ := strconv.ParseInt(item, 10, 64)
  8301. ids = append(ids, id)
  8302. }
  8303. if record_type == 1 {
  8304. drugs, _ := service.GetBatchDrugList(ids)
  8305. for _, item := range drugs {
  8306. result := QueryResult{
  8307. ID: item.ID,
  8308. Name: item.DrugName,
  8309. Code: item.MedicalInsuranceNumber,
  8310. List_type_code: "101",
  8311. }
  8312. queryResult = append(queryResult, result)
  8313. }
  8314. } else if record_type == 2 {
  8315. goods, _ := service.GetBatchGoodInformationList(ids)
  8316. for _, item := range goods {
  8317. result := QueryResult{
  8318. ID: item.ID,
  8319. Name: item.GoodName,
  8320. Code: item.MedicalInsuranceNumber,
  8321. List_type_code: "301",
  8322. }
  8323. queryResult = append(queryResult, result)
  8324. }
  8325. } else if record_type == 3 {
  8326. projects, _ := service.GetBathchMyPorjecgList(ids)
  8327. for _, item := range projects {
  8328. result := QueryResult{
  8329. ID: item.ID,
  8330. Name: item.ProjectName,
  8331. Code: item.MedicalCode,
  8332. List_type_code: "201",
  8333. }
  8334. queryResult = append(queryResult, result)
  8335. }
  8336. }
  8337. adminUser := c.GetAdminUserInfo()
  8338. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8339. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8340. var user_name string
  8341. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8342. if role.ID == 0 {
  8343. user_name = "xxx"
  8344. } else {
  8345. user_name = role.UserName
  8346. }
  8347. baseParams := &models.BaseParams{
  8348. SecretKey: miConfig.SecretKey,
  8349. FixmedinsCode: miConfig.Code,
  8350. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8351. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8352. OrgName: miConfig.OrgName,
  8353. Doctor: user_name,
  8354. }
  8355. if config.IsOpen == 1 {
  8356. for _, item := range queryResult {
  8357. var result string
  8358. if record_type == 1 {
  8359. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8360. } else if record_type == 2 {
  8361. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8362. } else if record_type == 3 {
  8363. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  8364. }
  8365. var dat2 map[string]interface{}
  8366. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  8367. fmt.Println(dat2)
  8368. } else {
  8369. fmt.Println(err)
  8370. }
  8371. userJSONBytes, _ := json.Marshal(dat2)
  8372. var res ResultSix
  8373. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8374. utils.ErrorLog("解析失败:%v", err)
  8375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8376. return
  8377. }
  8378. if res.Infcode == 0 {
  8379. if record_type == 1 {
  8380. service.UpdateDrugByIdDetail(item.ID)
  8381. } else if record_type == 2 {
  8382. service.UpdateGoodInfoById(item.ID)
  8383. } else if record_type == 3 {
  8384. service.UpdateMyProjectById(item.ID)
  8385. }
  8386. c.ServeSuccessJSON(map[string]interface{}{
  8387. "failed_code": 0,
  8388. "msg": "撤销目录对照成功",
  8389. })
  8390. } else {
  8391. c.ServeSuccessJSON(map[string]interface{}{
  8392. "failed_code": -10,
  8393. "msg": res.ErrMsg,
  8394. })
  8395. }
  8396. }
  8397. }
  8398. }
  8399. func (c *HisApiController) GetPatientInfo() {
  8400. id_card_no := c.GetString("id_card_no")
  8401. admin_user_id, _ := c.GetInt64("admin_user_id")
  8402. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8403. if patient.ID == 0 {
  8404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8405. return
  8406. }
  8407. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  8408. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  8409. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  8410. if config.IsOpen == 1 {
  8411. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8412. var dat map[string]interface{}
  8413. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8414. fmt.Println(dat)
  8415. } else {
  8416. fmt.Println(err)
  8417. }
  8418. userJSONBytes, _ := json.Marshal(dat)
  8419. var res ResultTwo
  8420. var res10265 ResultTwo10265
  8421. if miConfig.Code == "H15049901371" {
  8422. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8423. utils.ErrorLog("解析失败:%v", err)
  8424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8425. return
  8426. }
  8427. res.ErrMsg = res10265.ErrMsg
  8428. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8429. res.Infcode = infocode
  8430. res.Output = res10265.Output
  8431. res.InfRefmsgid = res10265.InfRefmsgid
  8432. } else {
  8433. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8434. utils.ErrorLog("解析失败:%v", err)
  8435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8436. return
  8437. }
  8438. }
  8439. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8440. // utils.ErrorLog("解析失败:%v", err)
  8441. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8442. // return
  8443. //}
  8444. if res.Infcode != 0 {
  8445. c.ServeSuccessJSON(map[string]interface{}{
  8446. "failed_code": -10,
  8447. "msg": res.ErrMsg,
  8448. })
  8449. } else {
  8450. c.ServeSuccessJSON(map[string]interface{}{
  8451. "failed_code": 0,
  8452. "info": res,
  8453. })
  8454. }
  8455. }
  8456. }
  8457. func (c *HisApiController) PsnPutOnRecord() {
  8458. record_type, _ := c.GetInt64("type")
  8459. patient_id, _ := c.GetInt64("patient_id")
  8460. admin_user_id, _ := c.GetInt64("admin_user_id")
  8461. start_time := c.GetString("start_time")
  8462. end_time := c.GetString("end_time")
  8463. adminUser := c.GetAdminUserInfo()
  8464. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8465. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8466. var patients []*models.Patients
  8467. if record_type == 1 { //全部备案
  8468. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  8469. patients = append(patients, patient...)
  8470. } else { //单个备案
  8471. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8472. patients = append(patients, patient)
  8473. }
  8474. var user_name string
  8475. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8476. if role.ID == 0 {
  8477. user_name = "xxx"
  8478. } else {
  8479. user_name = role.UserName
  8480. }
  8481. if config.IsOpen == 1 {
  8482. for _, item := range patients {
  8483. 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
  8484. resp, requestErr := http.Get(api)
  8485. if requestErr != nil {
  8486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8487. return
  8488. }
  8489. defer resp.Body.Close()
  8490. body, ioErr := ioutil.ReadAll(resp.Body)
  8491. if ioErr != nil {
  8492. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8494. return
  8495. }
  8496. var respJSON map[string]interface{}
  8497. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8498. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8500. return
  8501. }
  8502. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8503. userJSONBytes, _ := json.Marshal(userJSON)
  8504. var res ResultTwo
  8505. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8506. utils.ErrorLog("解析失败:%v", err)
  8507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8508. return
  8509. }
  8510. if res.Infcode == 0 {
  8511. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  8512. var dat map[string]interface{}
  8513. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8514. fmt.Println(dat)
  8515. } else {
  8516. fmt.Println(err)
  8517. }
  8518. userJSONBytes, _ := json.Marshal(dat)
  8519. var res2 ResultThirteen
  8520. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8521. utils.ErrorLog("解析失败:%v", err)
  8522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8523. return
  8524. }
  8525. if res2.Infcode == 0 {
  8526. psnResult := &models.GdybPsnRecord{
  8527. UserOrgId: adminUser.CurrentOrgId,
  8528. PatientId: item.ID,
  8529. PsnNo: res.Output.Baseinfo.PsnNo,
  8530. Ctime: time.Now().Unix(),
  8531. Mtime: time.Now().Unix(),
  8532. Status: 1,
  8533. IsCancel: 1,
  8534. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8535. }
  8536. service.CreatePsnRecord(psnResult)
  8537. } else {
  8538. c.ServeSuccessJSON(map[string]interface{}{
  8539. "failed_code": -10,
  8540. "msg": res2.ErrMsg,
  8541. })
  8542. return
  8543. }
  8544. }
  8545. }
  8546. }
  8547. }
  8548. func (c *HisApiController) PsnUnPutOnRecord() {
  8549. id, _ := c.GetInt64("id")
  8550. //record_type, _ := c.GetInt64("type")
  8551. admin_user_id, _ := c.GetInt64("admin_user_id")
  8552. adminUser := c.GetAdminUserInfo()
  8553. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8554. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8555. var user_name string
  8556. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8557. if role.ID == 0 {
  8558. user_name = "xxx"
  8559. } else {
  8560. user_name = role.UserName
  8561. }
  8562. psn_record, _ := service.GetPsnRecordById(id)
  8563. if psn_record.ID == 0 {
  8564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8565. return
  8566. }
  8567. if config.IsOpen == 1 {
  8568. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8569. var dat map[string]interface{}
  8570. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8571. fmt.Println(dat)
  8572. } else {
  8573. fmt.Println(err)
  8574. }
  8575. userJSONBytes, _ := json.Marshal(dat)
  8576. var res ResultFourteen
  8577. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8578. utils.ErrorLog("解析失败:%v", err)
  8579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8580. return
  8581. }
  8582. if res.Infcode == 0 {
  8583. psn_record.IsCancel = 2
  8584. service.CreatePsnRecord(&psn_record)
  8585. } else {
  8586. c.ServeSuccessJSON(map[string]interface{}{
  8587. "failed_code": -10,
  8588. "msg": res.ErrMsg,
  8589. })
  8590. return
  8591. }
  8592. }
  8593. }
  8594. func (c *HisApiController) PsnPutNCDSOnRecord() {
  8595. patient_id, _ := c.GetInt64("patient_id")
  8596. insutype_two := c.GetString("insutype")
  8597. psn_no := c.GetString("psn_no")
  8598. doctor_id, _ := c.GetInt64("doctor_id")
  8599. sick_id, _ := c.GetInt64("sick_id")
  8600. department_id, _ := c.GetInt64("department_id")
  8601. start_time := c.GetString("start_time")
  8602. end_time := c.GetString("end_time")
  8603. check_time := c.GetString("check_time")
  8604. adminUser := c.GetAdminUserInfo()
  8605. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8606. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8607. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8608. sick, _ := service.FindSickById(sick_id)
  8609. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8610. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  8611. var res ResultTwo
  8612. var res10265 ResultTwo10265
  8613. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8614. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  8615. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  8616. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  8617. "&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
  8618. resp, requestErr := http.Get(api)
  8619. if requestErr != nil {
  8620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8621. return
  8622. }
  8623. body, ioErr := ioutil.ReadAll(resp.Body)
  8624. if ioErr != nil {
  8625. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8627. return
  8628. }
  8629. var respJSON map[string]interface{}
  8630. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8633. return
  8634. }
  8635. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8636. result, _ := json.Marshal(respJSON)
  8637. fmt.Println("log")
  8638. fmt.Println(string(result))
  8639. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8640. utils.ErrorLog("解析失败:%v", err)
  8641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8642. return
  8643. }
  8644. res.ErrMsg = res10265.ErrMsg
  8645. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8646. res.Infcode = infocode
  8647. res.Output = res10265.Output
  8648. res.InfRefmsgid = res10265.InfRefmsgid
  8649. } else {
  8650. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8651. if miConfig.Code == "H15049901371" {
  8652. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8653. utils.ErrorLog("解析失败:%v", err)
  8654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8655. return
  8656. }
  8657. res.ErrMsg = res10265.ErrMsg
  8658. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8659. res.Infcode = infocode
  8660. res.Output = res10265.Output
  8661. res.InfRefmsgid = res10265.InfRefmsgid
  8662. } else {
  8663. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8664. utils.ErrorLog("解析失败:%v", err)
  8665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8666. return
  8667. }
  8668. }
  8669. }
  8670. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8671. infoStr := string(Iinfos)
  8672. var rf []*ResultFive
  8673. json.Unmarshal([]byte(infoStr), &rf)
  8674. var insuplc_admdvs string
  8675. var insutype string
  8676. var is390 int = 0
  8677. var is310 int = 0
  8678. var insutypes []*ResultFive
  8679. for _, item := range rf {
  8680. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8681. insutypes = append(insutypes, item)
  8682. }
  8683. }
  8684. if len(insutypes) == 1 {
  8685. insutype = insutypes[0].Insutype
  8686. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8687. } else {
  8688. for _, i := range insutypes {
  8689. if i.Insutype == "390" {
  8690. is390 = 1
  8691. }
  8692. if i.Insutype == "310" {
  8693. is310 = 1
  8694. }
  8695. }
  8696. }
  8697. if is390 == 1 {
  8698. insutype = "390"
  8699. }
  8700. if is310 == 1 {
  8701. insutype = "310"
  8702. }
  8703. if len(insutypes) == 2 {
  8704. insutype = insutype_two
  8705. }
  8706. if len(insutypes) == 0 {
  8707. insutype = "310"
  8708. }
  8709. insutype = insutype_two
  8710. fmt.Println(insutype)
  8711. for _, item := range rf {
  8712. fmt.Println(item.Insutype)
  8713. fmt.Println(insutype)
  8714. if item.Insutype == insutype {
  8715. fmt.Println(item.Insutype)
  8716. fmt.Println(insutype)
  8717. insuplc_admdvs = item.InsuplcAdmdvs
  8718. }
  8719. }
  8720. fmt.Println(insuplc_admdvs)
  8721. var res2 ResultThirteen
  8722. var res10265_2 ResultThirteen10265
  8723. if config.IsOpen == 1 {
  8724. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8725. } else {
  8726. 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)
  8727. var dat map[string]interface{}
  8728. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8729. fmt.Println(dat)
  8730. } else {
  8731. fmt.Println(err)
  8732. }
  8733. userJSONBytes, _ := json.Marshal(dat)
  8734. if miConfig.Code == "H15049901371" {
  8735. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  8736. utils.ErrorLog("解析失败:%v", err)
  8737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8738. return
  8739. }
  8740. res2.ErrMsg = res10265_2.ErrMsg
  8741. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  8742. res2.Infcode = infocode
  8743. res2.Output = res10265_2.Output
  8744. res2.InfRefmsgid = res10265_2.InfRefmsgid
  8745. } else {
  8746. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8747. utils.ErrorLog("解析失败:%v", err)
  8748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8749. return
  8750. }
  8751. }
  8752. }
  8753. if res2.Infcode == 0 {
  8754. psnResult := &models.GdybPsnNcdsRecord{
  8755. UserOrgId: adminUser.CurrentOrgId,
  8756. PatientId: patient.ID,
  8757. PsnNo: psn_no,
  8758. DoctorId: doctor.AdminUserId,
  8759. DepartmentId: department_id,
  8760. SickType: sick_id,
  8761. Insutype: insutype,
  8762. Ctime: time.Now().Unix(),
  8763. Mtime: time.Now().Unix(),
  8764. Status: 1,
  8765. IsCancel: 1,
  8766. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  8767. }
  8768. service.CreatePsnNCDSRecord(psnResult)
  8769. c.ServeSuccessJSON(map[string]interface{}{
  8770. "failed_code": 0,
  8771. "msg": "备案成功",
  8772. "result": psnResult,
  8773. })
  8774. } else {
  8775. c.ServeSuccessJSON(map[string]interface{}{
  8776. "failed_code": -10,
  8777. "msg": res2.ErrMsg,
  8778. })
  8779. return
  8780. }
  8781. }
  8782. }
  8783. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  8784. id, _ := c.GetInt64("id")
  8785. admin_user_id, _ := c.GetInt64("admin_user_id")
  8786. adminUser := c.GetAdminUserInfo()
  8787. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8788. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8789. //config, _ := service.Ge(adminUser.CurrentOrgId)
  8790. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  8791. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8792. //var user_name string
  8793. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8794. //if role.ID == 0 {
  8795. // user_name = "xxx"
  8796. //} else {
  8797. // user_name = role.UserName
  8798. //}
  8799. psn_record, _ := service.GetPsnNCDSRecordById(id)
  8800. if psn_record.ID == 0 {
  8801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  8802. return
  8803. }
  8804. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  8805. var res ResultTwo
  8806. var res10265 ResultTwo10265
  8807. if miConfig.Code == "H15049901371" {
  8808. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8809. utils.ErrorLog("解析失败:%v", err)
  8810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8811. return
  8812. }
  8813. res.ErrMsg = res10265.ErrMsg
  8814. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8815. res.Infcode = infocode
  8816. res.Output = res10265.Output
  8817. res.InfRefmsgid = res10265.InfRefmsgid
  8818. } else {
  8819. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8820. utils.ErrorLog("解析失败:%v", err)
  8821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8822. return
  8823. }
  8824. }
  8825. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8826. infoStr := string(Iinfos)
  8827. var rf []*ResultFive
  8828. json.Unmarshal([]byte(infoStr), &rf)
  8829. var insuplc_admdvs string
  8830. var insutype string
  8831. var is390 int = 0
  8832. var is310 int = 0
  8833. var insutypes []*ResultFive
  8834. for _, item := range rf {
  8835. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8836. insutypes = append(insutypes, item)
  8837. }
  8838. }
  8839. if len(insutypes) == 1 {
  8840. insutype = insutypes[0].Insutype
  8841. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8842. } else {
  8843. for _, i := range insutypes {
  8844. if i.Insutype == "390" {
  8845. is390 = 1
  8846. }
  8847. if i.Insutype == "310" {
  8848. is310 = 1
  8849. }
  8850. }
  8851. }
  8852. if is390 == 1 {
  8853. insutype = "390"
  8854. }
  8855. if is310 == 1 {
  8856. insutype = "310"
  8857. }
  8858. if len(insutypes) == 0 {
  8859. insutype = "310"
  8860. }
  8861. insutype = psn_record.Insutype
  8862. for _, item := range rf {
  8863. if item.Insutype == insutype {
  8864. insuplc_admdvs = item.InsuplcAdmdvs
  8865. }
  8866. }
  8867. if config.IsOpen == 1 {
  8868. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  8869. var dat map[string]interface{}
  8870. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8871. fmt.Println(dat)
  8872. } else {
  8873. fmt.Println(err)
  8874. }
  8875. userJSONBytes, _ := json.Marshal(dat)
  8876. var res ResultFourteen
  8877. var res10265 ResultFourteen10265
  8878. if miConfig.Code == "H15049901371" {
  8879. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8880. utils.ErrorLog("解析失败:%v", err)
  8881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8882. return
  8883. }
  8884. res.ErrMsg = res10265.ErrMsg
  8885. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8886. res.Infcode = infocode
  8887. res.Output = res10265.Output
  8888. res.InfRefmsgid = res10265.InfRefmsgid
  8889. } else {
  8890. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8891. utils.ErrorLog("解析失败:%v", err)
  8892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8893. return
  8894. }
  8895. }
  8896. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8897. // utils.ErrorLog("解析失败:%v", err)
  8898. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8899. // return
  8900. //}
  8901. if res.Infcode == 0 {
  8902. psn_record.IsCancel = 2
  8903. service.CreatePsnNCDSRecord(&psn_record)
  8904. c.ServeSuccessJSON(map[string]interface{}{
  8905. "failed_code": 0,
  8906. "msg": "撤销备案成功",
  8907. })
  8908. } else {
  8909. c.ServeSuccessJSON(map[string]interface{}{
  8910. "failed_code": -10,
  8911. "msg": res.ErrMsg,
  8912. })
  8913. return
  8914. }
  8915. }
  8916. }
  8917. func (c *HisApiController) TestTest() {
  8918. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  8919. fmt.Println(patient.Iinfo)
  8920. }
  8921. type CustomData struct {
  8922. MsgId string
  8923. PsnNo string
  8924. Info string
  8925. }
  8926. func (c *HisApiController) ReversalData() {
  8927. var customData []*CustomData
  8928. custom := &CustomData{
  8929. MsgId: "H44022900158202103301714472004",
  8930. PsnNo: "44020000001101329945",
  8931. Info: "2207",
  8932. }
  8933. customData = append(customData, custom)
  8934. custom1 := &CustomData{
  8935. MsgId: "H4402290015820210330172057803",
  8936. PsnNo: "44020000001101161813",
  8937. Info: "2207",
  8938. }
  8939. customData = append(customData, custom1)
  8940. custom2 := &CustomData{
  8941. MsgId: "H44022900158202103301705198813",
  8942. PsnNo: "44190000133097375417",
  8943. Info: "2207",
  8944. }
  8945. customData = append(customData, custom2)
  8946. custom3 := &CustomData{
  8947. MsgId: "H44022900158202103301715524756",
  8948. PsnNo: "44020000001100187221",
  8949. Info: "2207",
  8950. }
  8951. customData = append(customData, custom3)
  8952. custom4 := &CustomData{
  8953. MsgId: "H44022900158202103301730376224",
  8954. PsnNo: "44020000001101959155",
  8955. Info: "2207",
  8956. }
  8957. customData = append(customData, custom4)
  8958. custom5 := &CustomData{
  8959. MsgId: "H44022900158202103301748008725",
  8960. PsnNo: "44020000001104246641",
  8961. Info: "2207",
  8962. }
  8963. customData = append(customData, custom5)
  8964. custom6 := &CustomData{
  8965. MsgId: "H44022900158202103301718096755",
  8966. PsnNo: "44020000001102211860",
  8967. Info: "2207",
  8968. }
  8969. customData = append(customData, custom6)
  8970. custom7 := &CustomData{
  8971. MsgId: "H44022900158202103301736551640",
  8972. PsnNo: "44020000001102687718",
  8973. Info: "2207",
  8974. }
  8975. customData = append(customData, custom7)
  8976. custom8 := &CustomData{
  8977. MsgId: "H44022900158202103301743097676",
  8978. PsnNo: "44020000001102127785",
  8979. Info: "2207",
  8980. }
  8981. customData = append(customData, custom8)
  8982. custom9 := &CustomData{
  8983. MsgId: "H44022900158202103301712304203",
  8984. PsnNo: "44020000001101518097",
  8985. Info: "2207",
  8986. }
  8987. customData = append(customData, custom9)
  8988. custom10 := &CustomData{
  8989. MsgId: "H44022900158202103301738448785",
  8990. PsnNo: "44020000001100500813",
  8991. Info: "2207",
  8992. }
  8993. customData = append(customData, custom10)
  8994. custom11 := &CustomData{
  8995. MsgId: "H44022900158202103301732455843",
  8996. PsnNo: "44020000001102690557",
  8997. Info: "2207",
  8998. }
  8999. customData = append(customData, custom11)
  9000. custom12 := &CustomData{
  9001. MsgId: "H44022900158202103301745421708",
  9002. PsnNo: "44020000001102211928",
  9003. Info: "2207",
  9004. }
  9005. customData = append(customData, custom12)
  9006. custom1212 := &CustomData{
  9007. MsgId: "H440229001582021033017351627",
  9008. PsnNo: "44020000001102481733",
  9009. Info: "2207",
  9010. }
  9011. customData = append(customData, custom1212)
  9012. custom13 := &CustomData{
  9013. MsgId: "H44022900158202103301740327951",
  9014. PsnNo: "44020000001103174866",
  9015. Info: "2207",
  9016. }
  9017. customData = append(customData, custom13)
  9018. custom14 := &CustomData{
  9019. MsgId: "H4402290015820210330174922668",
  9020. PsnNo: "44020000001102927272",
  9021. Info: "2207",
  9022. }
  9023. customData = append(customData, custom14)
  9024. custom15 := &CustomData{
  9025. MsgId: "H44022900158202103301752362273",
  9026. PsnNo: "44020000001102942890",
  9027. Info: "2207",
  9028. }
  9029. customData = append(customData, custom15)
  9030. custom16 := &CustomData{
  9031. MsgId: "H44022900158202103301751082917",
  9032. PsnNo: "44020000001101662162",
  9033. Info: "2207",
  9034. }
  9035. customData = append(customData, custom16)
  9036. custom17 := &CustomData{
  9037. MsgId: "H44022900158202103301754147728",
  9038. PsnNo: "44020000000229014511",
  9039. Info: "2207",
  9040. }
  9041. customData = append(customData, custom17)
  9042. adminUser := c.GetAdminUserInfo()
  9043. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9044. for _, item := range customData {
  9045. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9046. fmt.Println(result)
  9047. }
  9048. }
  9049. func (c *HisApiController) GetAllopatry() {
  9050. year := c.GetString("year")
  9051. month := c.GetString("month")
  9052. admin_user_id, _ := c.GetInt64("admin_user_id")
  9053. adminUser := c.GetAdminUserInfo()
  9054. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9055. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9056. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9057. var dat map[string]interface{}
  9058. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9059. fmt.Println(dat)
  9060. } else {
  9061. fmt.Println(err)
  9062. }
  9063. userJSONBytes, _ := json.Marshal(dat)
  9064. var res models.Result9001
  9065. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9066. utils.ErrorLog("解析失败:%v", err)
  9067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9068. return
  9069. }
  9070. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9071. var dat2 map[string]interface{}
  9072. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9073. fmt.Println(dat)
  9074. } else {
  9075. fmt.Println(err)
  9076. }
  9077. userJSONBytes2, _ := json.Marshal(dat2)
  9078. var res2 models.Result3260
  9079. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9080. utils.ErrorLog("解析失败:%v", err)
  9081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9082. return
  9083. }
  9084. if res2.Infcode == 0 {
  9085. c.ServeSuccessJSON(map[string]interface{}{
  9086. "list": res2.Output.Data,
  9087. })
  9088. return
  9089. } else {
  9090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9091. return
  9092. }
  9093. }
  9094. func (c *HisApiController) ComfirmAllopatry() {
  9095. year := c.GetString("year")
  9096. month := c.GetString("month")
  9097. admin_user_id, _ := c.GetInt64("admin_user_id")
  9098. adminUser := c.GetAdminUserInfo()
  9099. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9100. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9101. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9102. var dat map[string]interface{}
  9103. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9104. fmt.Println(dat)
  9105. } else {
  9106. fmt.Println(err)
  9107. }
  9108. userJSONBytes, _ := json.Marshal(dat)
  9109. var res models.Result9001
  9110. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9111. utils.ErrorLog("解析失败:%v", err)
  9112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9113. return
  9114. }
  9115. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9116. var dat2 map[string]interface{}
  9117. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9118. fmt.Println(dat)
  9119. } else {
  9120. fmt.Println(err)
  9121. }
  9122. userJSONBytes2, _ := json.Marshal(dat2)
  9123. var res2 models.Result3260
  9124. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9125. utils.ErrorLog("解析失败:%v", err)
  9126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9127. return
  9128. }
  9129. if res2.Infcode == 0 {
  9130. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  9131. var dat map[string]interface{}
  9132. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9133. fmt.Println(dat)
  9134. } else {
  9135. fmt.Println(err)
  9136. }
  9137. userJSONBytes, _ := json.Marshal(dat)
  9138. var res3 models.Result3261
  9139. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  9140. utils.ErrorLog("解析失败:%v", err)
  9141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9142. return
  9143. }
  9144. if res3.Infcode == 0 {
  9145. record := &models.HisYidiClearRecord{
  9146. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9147. Ctime: time.Now().Unix(),
  9148. Mtime: time.Now().Unix(),
  9149. Status: 1,
  9150. MsgId: msgId,
  9151. }
  9152. service.SaveClearRecord(record)
  9153. c.ServeSuccessJSON(map[string]interface{}{
  9154. "msg": "提取成功",
  9155. })
  9156. }
  9157. }
  9158. }
  9159. func (c *HisApiController) RefundAllopatry() {
  9160. year := c.GetString("year")
  9161. month := c.GetString("month")
  9162. id, _ := c.GetInt64("id")
  9163. admin_user_id, _ := c.GetInt64("admin_user_id")
  9164. adminUser := c.GetAdminUserInfo()
  9165. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9166. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9167. record, _ := service.GetClearRecordById(id)
  9168. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  9169. var dat map[string]interface{}
  9170. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9171. fmt.Println(dat)
  9172. } else {
  9173. fmt.Println(err)
  9174. }
  9175. userJSONBytes, _ := json.Marshal(dat)
  9176. var empty ResultFourteen
  9177. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  9178. utils.ErrorLog("解析失败:%v", err)
  9179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9180. return
  9181. }
  9182. if empty.Infcode == 0 {
  9183. c.ServeSuccessJSON(map[string]interface{}{
  9184. "msg": "撤销成功",
  9185. })
  9186. return
  9187. }
  9188. }
  9189. func (c *HisApiController) ReversalOtherData() {
  9190. var customData []*CustomData
  9191. custom := &CustomData{
  9192. MsgId: "H44022900158202103301714472004",
  9193. PsnNo: "44020000001101329945",
  9194. Info: "2208",
  9195. }
  9196. customData = append(customData, custom)
  9197. custom1 := &CustomData{
  9198. MsgId: "H4402290015820210330172057803",
  9199. PsnNo: "44020000001101161813",
  9200. Info: "2208",
  9201. }
  9202. customData = append(customData, custom1)
  9203. custom2 := &CustomData{
  9204. MsgId: "H44022900158202103301705198813",
  9205. PsnNo: "44190000133097375417",
  9206. Info: "2208",
  9207. }
  9208. customData = append(customData, custom2)
  9209. custom3 := &CustomData{
  9210. MsgId: "H44022900158202103301715524756",
  9211. PsnNo: "44020000001100187221",
  9212. Info: "2208",
  9213. }
  9214. customData = append(customData, custom3)
  9215. custom4 := &CustomData{
  9216. MsgId: "H44022900158202103301730376224",
  9217. PsnNo: "44020000001101959155",
  9218. Info: "2208",
  9219. }
  9220. customData = append(customData, custom4)
  9221. custom5 := &CustomData{
  9222. MsgId: "H44022900158202103301748008725",
  9223. PsnNo: "44020000001104246641",
  9224. Info: "2208",
  9225. }
  9226. customData = append(customData, custom5)
  9227. custom6 := &CustomData{
  9228. MsgId: "H44022900158202103301718096755",
  9229. PsnNo: "44020000001102211860",
  9230. Info: "2208",
  9231. }
  9232. customData = append(customData, custom6)
  9233. custom7 := &CustomData{
  9234. MsgId: "H44022900158202103301736551640",
  9235. PsnNo: "44020000001102687718",
  9236. Info: "2208",
  9237. }
  9238. customData = append(customData, custom7)
  9239. custom8 := &CustomData{
  9240. MsgId: "H44022900158202103301743097676",
  9241. PsnNo: "44020000001102127785",
  9242. Info: "2208",
  9243. }
  9244. customData = append(customData, custom8)
  9245. custom9 := &CustomData{
  9246. MsgId: "H44022900158202103301712304203",
  9247. PsnNo: "44020000001101518097",
  9248. Info: "2208",
  9249. }
  9250. customData = append(customData, custom9)
  9251. custom10 := &CustomData{
  9252. MsgId: "H44022900158202103301738448785",
  9253. PsnNo: "44020000001100500813",
  9254. Info: "2208",
  9255. }
  9256. customData = append(customData, custom10)
  9257. custom11 := &CustomData{
  9258. MsgId: "H44022900158202103301732455843",
  9259. PsnNo: "44020000001102690557",
  9260. Info: "2208",
  9261. }
  9262. customData = append(customData, custom11)
  9263. custom12 := &CustomData{
  9264. MsgId: "H44022900158202103301745421708",
  9265. PsnNo: "44020000001102211928",
  9266. Info: "2208",
  9267. }
  9268. customData = append(customData, custom12)
  9269. custom1212 := &CustomData{
  9270. MsgId: "H440229001582021033017351627",
  9271. PsnNo: "44020000001102481733",
  9272. Info: "2208",
  9273. }
  9274. customData = append(customData, custom1212)
  9275. custom13 := &CustomData{
  9276. MsgId: "H44022900158202103301740327951",
  9277. PsnNo: "44020000001103174866",
  9278. Info: "2208",
  9279. }
  9280. customData = append(customData, custom13)
  9281. custom14 := &CustomData{
  9282. MsgId: "H4402290015820210330174922668",
  9283. PsnNo: "44020000001102927272",
  9284. Info: "2208",
  9285. }
  9286. customData = append(customData, custom14)
  9287. custom15 := &CustomData{
  9288. MsgId: "H44022900158202103301752362273",
  9289. PsnNo: "44020000001102942890",
  9290. Info: "2208",
  9291. }
  9292. customData = append(customData, custom15)
  9293. custom16 := &CustomData{
  9294. MsgId: "H44022900158202103301751082917",
  9295. PsnNo: "44020000001101662162",
  9296. Info: "2208",
  9297. }
  9298. customData = append(customData, custom16)
  9299. custom17 := &CustomData{
  9300. MsgId: "H44022900158202103301754147728",
  9301. PsnNo: "44020000000229014511",
  9302. Info: "2208",
  9303. }
  9304. customData = append(customData, custom17)
  9305. adminUser := c.GetAdminUserInfo()
  9306. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9307. for _, item := range customData {
  9308. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9309. fmt.Println(result)
  9310. }
  9311. }
  9312. func PathExists(path string) (bool, error) {
  9313. _, err := os.Stat(path)
  9314. if err == nil {
  9315. return true, nil
  9316. }
  9317. if os.IsNotExist(err) {
  9318. return false, nil
  9319. }
  9320. return false, err
  9321. }
  9322. //创建文件夹
  9323. func Mkdir(dir string) {
  9324. // 创建文件夹
  9325. exist, err := PathExists(dir)
  9326. if err != nil {
  9327. fmt.Println(err.Error())
  9328. } else {
  9329. if exist {
  9330. fmt.Println(dir + "文件夹已存在!")
  9331. } else {
  9332. // 文件夹名称,权限
  9333. err := os.Mkdir(dir, os.ModePerm)
  9334. if err != nil {
  9335. fmt.Println(dir+"文件夹创建失败:", err.Error())
  9336. } else {
  9337. fmt.Println(dir + "文件夹创建成功!")
  9338. }
  9339. }
  9340. }
  9341. }
  9342. //压缩文件
  9343. func Zip(srcFile string, destZip string) error {
  9344. zipfile, err := os.Create(destZip)
  9345. if err != nil {
  9346. return err
  9347. }
  9348. defer zipfile.Close()
  9349. archive := zip.NewWriter(zipfile)
  9350. defer archive.Close()
  9351. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  9352. if err != nil {
  9353. return err
  9354. }
  9355. header, err := zip.FileInfoHeader(info)
  9356. if err != nil {
  9357. return err
  9358. }
  9359. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  9360. // header.Name = path
  9361. if info.IsDir() {
  9362. header.Name += "/"
  9363. } else {
  9364. header.Method = zip.Deflate
  9365. }
  9366. writer, err := archive.CreateHeader(header)
  9367. if err != nil {
  9368. return err
  9369. }
  9370. if !info.IsDir() {
  9371. file, err := os.Open(path)
  9372. if err != nil {
  9373. return err
  9374. }
  9375. defer file.Close()
  9376. _, err = io.Copy(writer, file)
  9377. }
  9378. return err
  9379. })
  9380. return err
  9381. }
  9382. func ReadFile(filePath string) []byte {
  9383. f, err := os.Open(filePath)
  9384. if err != nil {
  9385. fmt.Println("read file fail", err)
  9386. return nil
  9387. }
  9388. defer f.Close()
  9389. fd, err := ioutil.ReadAll(f)
  9390. if err != nil {
  9391. fmt.Println("read to fd fail", err)
  9392. return nil
  9393. }
  9394. return fd
  9395. }
  9396. func saveLog(result string, request string, infno string, desc string) {
  9397. org_id, _ := beego.AppConfig.Int64("org_id")
  9398. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  9399. dir := miConfig.OrgName + "日志"
  9400. utils.Mkdir(dir)
  9401. month := time.Unix(1557042972, 0).Format("1")
  9402. year := time.Now().Format("2006")
  9403. month = time.Now().Format("01")
  9404. day := time.Now().Format("02")
  9405. hour := time.Now().Format("15")
  9406. min := time.Now().Format("04")
  9407. sec := time.Now().Format("05")
  9408. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  9409. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  9410. file_name := file + ".txt"
  9411. file_path := miConfig.OrgName + "日志" + "/" + file_name
  9412. exist, _ := utils.PathExists(file_path)
  9413. if exist { //存在
  9414. fmt.Println("存在")
  9415. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  9416. if err != nil {
  9417. fmt.Println("read fail")
  9418. }
  9419. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  9420. n, _ := f.Seek(0, 2)
  9421. _, err = f.WriteAt([]byte(content), n)
  9422. } else { //不存在
  9423. fmt.Println("文件不存在,创建文件")
  9424. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  9425. defer f.Close()
  9426. if err != nil {
  9427. } else {
  9428. _, err = f.Write([]byte("记录日志"))
  9429. }
  9430. }
  9431. }
  9432. type Charset string
  9433. const (
  9434. UTF8 = Charset("UTF-8")
  9435. GB18030 = Charset("GB18030")
  9436. )
  9437. func ConvertToString(src string, srcCode string, tagCode string) string {
  9438. srcCoder := mahonia.NewDecoder(srcCode)
  9439. srcResult := srcCoder.ConvertString(src)
  9440. tagCoder := mahonia.NewDecoder(tagCode)
  9441. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  9442. result := string(cdata)
  9443. return result
  9444. }