his_api_controller.go 1.2MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. //"github.com/tjfoc/gmsm/sm3"
  8. "math"
  9. //"crypto/x509/pkix"
  10. "encoding/json"
  11. "fmt"
  12. //"github.com/tjfoc/gmsm/sm2"
  13. //"github.com/tjfoc/gmsm/sm3"
  14. "gdyb/controllers"
  15. "gdyb/enums"
  16. "gdyb/models"
  17. "gdyb/service"
  18. "gdyb/utils"
  19. "github.com/astaxie/beego"
  20. "github.com/axgle/mahonia"
  21. "github.com/gorilla/websocket"
  22. "github.com/jinzhu/gorm"
  23. "github.com/shopspring/decimal"
  24. "io"
  25. "io/ioutil"
  26. //"math"
  27. "math/rand"
  28. "net/http"
  29. "net/url"
  30. "os"
  31. "path/filepath"
  32. "regexp"
  33. "strconv"
  34. "strings"
  35. "syscall"
  36. "time"
  37. "unsafe"
  38. "github.com/go-ole/go-ole"
  39. "github.com/go-ole/go-ole/oleutil"
  40. )
  41. type HisApiController struct {
  42. controllers.BaseAuthAPIController
  43. }
  44. func HisManagerApiRegistRouters() {
  45. //挂号
  46. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  47. //上传就诊信息-上传明细-结算
  48. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  49. //查询
  50. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  51. //对总账
  52. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  53. //对明细
  54. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  55. //退费,退明细
  56. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  57. //退号
  58. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  59. //退明细
  60. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  61. //上传就诊信息-上传明细-预结算
  62. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  63. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  64. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  65. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  66. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  67. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  68. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  69. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  70. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  71. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  72. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  73. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  74. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  75. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  76. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  77. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  78. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  79. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  80. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  81. //beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  82. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  83. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  84. beego.Router("/api/check", &HisApiController{}, "get:Check")
  85. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  86. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  87. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  88. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  89. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  90. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  91. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  92. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  93. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  94. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  95. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  96. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  97. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  98. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  99. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  100. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  101. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  102. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  103. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  104. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  105. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  106. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  107. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  108. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  109. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  110. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  111. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  112. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  113. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  114. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  115. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  116. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  117. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  118. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  119. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  120. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  121. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  122. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  123. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  124. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  125. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  126. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  127. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  128. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  129. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  130. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  131. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  132. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  133. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  134. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  135. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  136. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  137. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  138. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  139. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  140. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  141. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  142. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  143. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  144. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  145. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  146. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  147. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  148. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  149. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  150. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  151. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  152. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  153. }
  154. func (c *HisApiController)Get1318(){
  155. adminUser := c.GetAdminUserInfo()
  156. admin_user_id, _ := c.GetInt64("admin_user_id")
  157. code := c.GetString("code")
  158. code = ""
  159. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  160. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  161. api := ""
  162. if miConfig.MdtrtareaAdmvs == "320921" {
  163. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  164. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo+"&h_code="+code
  165. } else {
  166. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  167. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo+"&h_code="+code
  168. }
  169. resp, requestErr := http.Get(api)
  170. if requestErr != nil {
  171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  172. return
  173. }
  174. body, ioErr := ioutil.ReadAll(resp.Body)
  175. if ioErr != nil {
  176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  178. return
  179. }
  180. var respJSON map[string]interface{}
  181. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  184. return
  185. }
  186. //var res Result2406
  187. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  188. result, _ := json.Marshal(respJSON)
  189. if err := json.Unmarshal([]byte(result), &res); err != nil {
  190. utils.ErrorLog("解析失败:%v", err)
  191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  192. return
  193. }
  194. if res.Infcode == "0" {
  195. c.ServeSuccessJSON(map[string]interface{}{
  196. "result": "",
  197. })
  198. } else {
  199. c.ServeSuccessJSON(map[string]interface{}{
  200. "failed_code": -10,
  201. "msg": res.ErrMsg,
  202. })
  203. */return
  204. //}
  205. }
  206. func (c *HisApiController)Get2503(){
  207. adminUser := c.GetAdminUserInfo()
  208. admin_user_id, _ := c.GetInt64("admin_user_id")
  209. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  210. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  211. service.Gxyb2503(miConfig.OrgName,roles.UserName,miConfig.Code,miConfig.MdtrtareaAdmvs,miConfig.InsuplcAdmdvs,"",admin_user_id)
  212. }
  213. func (c *HisApiController) Get2406() {
  214. id, _ := c.GetInt64("id")
  215. record_time := c.GetString("record_time")
  216. his_patient_id, _ := c.GetInt64("his_patient_id")
  217. admin_user_id, _ := c.GetInt64("admin_user_id")
  218. diagnosis_id := c.GetString("diagnosis")
  219. timeLayout := "2006-01-02"
  220. loc, _ := time.LoadLocation("Local")
  221. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  222. if err != nil {
  223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  224. return
  225. }
  226. recordDateTime := theTime.Unix()
  227. adminUser := c.GetAdminUserInfo()
  228. diagnosis_ids := strings.Split(diagnosis_id, ",")
  229. var config []*models.HisXtDiagnoseConfig
  230. for _, item := range diagnosis_ids {
  231. id, _ := strconv.ParseInt(item, 10, 64)
  232. diagnosisConfig, _ := service.FindDiagnoseById(id)
  233. config = append(config, &diagnosisConfig)
  234. }
  235. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  236. fmt.Println(his_patient_id)
  237. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  238. //timestamp := time.Now().Unix()
  239. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  240. var patientPrescription models.HisPrescriptionInfo
  241. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  242. if patientPrescription.ID == 0 {
  243. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  244. }
  245. var res2 Result2406
  246. if miConfig.MdtrtareaAdmvs == "341203" {
  247. data := make(map[string]interface{})
  248. client := &http.Client{}
  249. data["psn_no"] = his.PsnNo
  250. data["mdtrt_id"] = his.Number
  251. data["operator"] = roles.UserName
  252. data["cert_no"] = his.IdCardNo
  253. data["org_name"] = miConfig.OrgName
  254. data["psn_name"] = his.Name
  255. data["ipt_otp_no"] = his.IptOtpNo
  256. data["ipt_psn_sp_flag_type"] = "0901"
  257. data["ipt_psn_sp_flag"] ="1"
  258. data["fixmedins_code"] = miConfig.Code
  259. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  260. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  261. data["url"] = miConfig.Url
  262. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  263. bytesData, _ := json.Marshal(data)
  264. var req *http.Request
  265. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  266. req, _ = http.NewRequest("POST", miConfig.SecretKey +"ahyb/2406", bytes.NewReader(bytesData))
  267. resp, _ := client.Do(req)
  268. defer resp.Body.Close()
  269. body, ioErr := ioutil.ReadAll(resp.Body)
  270. if ioErr != nil {
  271. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  273. return
  274. }
  275. var respJSON map[string]interface{}
  276. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  277. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  279. return
  280. }
  281. status := respJSON["data"].(map[string]interface{})["status"].(string)
  282. if status == "0"{
  283. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  284. c.ServeSuccessJSON(map[string]interface{}{
  285. "failed_code": -10,
  286. "msg": err_msg,
  287. })
  288. return
  289. }
  290. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  291. userJSONBytes, _ := json.Marshal(respJSON)
  292. fmt.Println("log")
  293. fmt.Println(string(userJSONBytes))
  294. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  295. utils.ErrorLog("解析失败:%v", err)
  296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  297. return
  298. }
  299. }
  300. if res2.Infcode != 0 {
  301. adminUser := c.GetAdminUserInfo()
  302. errlog := &models.HisOrderError{
  303. UserOrgId: adminUser.CurrentOrgId,
  304. Ctime: time.Now().Unix(),
  305. Mtime: time.Now().Unix(),
  306. ErrMsg: res2.ErrMsg,
  307. Status: 1,
  308. PatientId: id,
  309. RecordTime: recordDateTime,
  310. Stage: 3,
  311. }
  312. service.CreateErrMsgLog(errlog)
  313. c.ServeSuccessJSON(map[string]interface{}{
  314. "failed_code": -10,
  315. "msg": res2.ErrMsg,
  316. })
  317. return
  318. }else{
  319. c.ServeSuccessJSON(map[string]interface{}{
  320. "msg": "上传成功",
  321. })
  322. return
  323. }
  324. }
  325. func (c *HisApiController) Get4105() {
  326. }
  327. func (c *HisApiController) Post5302() {
  328. patient_id, _ := c.GetInt64("id")
  329. admin_user_id, _ := c.GetInt64("admin_user_id")
  330. p, _ := service.GetHisPatientById(patient_id)
  331. adminUser := c.GetAdminUserInfo()
  332. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  333. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  334. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  335. }
  336. func (c *HisApiController) Get4104() {
  337. }
  338. type Output struct {
  339. CertNo string `json:"certno"`
  340. PsnName string `json:"psn_name"`
  341. CardNo string `json:"card_no"`
  342. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  343. CardSN string `json:"card_sn"`
  344. PsnCertType string `json:"psn_cert_type"`
  345. MdtrtCertNo string `json:"mdtrt_cert_no"`
  346. MdtrtCertType string `json:"mdtrt_cert_type"`
  347. QRCode string `json:"qrCode"`
  348. EcToken string `json:"ecToken"`
  349. }
  350. type AHResponse struct {
  351. Body AHBody `json:"body"`
  352. Code int `json:"code"`
  353. CSBCode int `json:"csbCode"`
  354. Message string `json:"message"`
  355. RequestID string `json:"requestId"`
  356. State struct{} `json:"state"`
  357. }
  358. type AHBody struct {
  359. ErrMsg string `json:"err_msg"`
  360. InfRefMsgID string `json:"inf_refmsgid"`
  361. InfCode int `json:"infcode"`
  362. Output struct {
  363. Result []struct {
  364. BasMednFlag string `json:"bas_medn_flag"`
  365. ChldMedcFlag string `json:"chld_medc_flag"`
  366. ChrgitmLv string `json:"chrgitm_lv"`
  367. Cnt float64 `json:"cnt"`
  368. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  369. DrtReimFlag string `json:"drt_reim_flag"`
  370. FeedetlSn string `json:"feedetl_sn"`
  371. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  372. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  373. InscpScpAmt float64 `json:"inscp_scp_amt"`
  374. ListSpItemFlag string `json:"list_sp_item_flag"`
  375. LmtUsedFlag string `json:"lmt_used_flag"`
  376. MedChrgitmType string `json:"med_chrgitm_type"`
  377. Memo string `json:"memo"`
  378. OverlmtAmt float64 `json:"overlmt_amt"`
  379. PreselfpayAmt float64 `json:"preselfpay_amt"`
  380. Pric float64 `json:"pric"`
  381. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  382. SelfpayProp float64 `json:"selfpay_prop"`
  383. } `json:"result"`
  384. } `json:"output"`
  385. }
  386. type Response struct {
  387. Output Output `json:"output"`
  388. Infcode int `json:"infcode"`
  389. InfRefMsgID string `json:"inf_refmsgid"`
  390. RefMsgTime string `json:"refmsg_time"`
  391. RespondTime string `json:"respond_time"`
  392. ErrMsg string `json:"err_msg"`
  393. WarnMsg string `json:"warn_msg"`
  394. SignType string `json:"signtype"`
  395. CAInfo string `json:"cainfo"`
  396. }
  397. func (c *HisApiController) Getquerydata() {
  398. query_type, _ := c.GetInt64("type")
  399. refd_setl_flag := c.GetString("refd_setl_flag")
  400. med_type := c.GetString("med_type")
  401. //admin_user_id,_ := c.GetInt64("admin_user_id")
  402. cert_no := c.GetString("cert_no")
  403. psn_no := c.GetString("psn_no")
  404. start_time := c.GetString("start_time")
  405. end_time := c.GetString("end_time")
  406. page, _ := c.GetInt64("page")
  407. limit, _ := c.GetInt64("limit")
  408. var bp models.BusinessParams5262
  409. bp.RefdSetlFlag = refd_setl_flag
  410. bp.MedType = med_type
  411. bp.Certno = cert_no
  412. bp.Psnno = psn_no
  413. bp.QBegntime = start_time
  414. bp.QEndtime = end_time
  415. if query_type == 1 { //本地
  416. Post5262(c, bp, page, limit)
  417. } else { //异地
  418. Post5267(c, bp, page, limit)
  419. }
  420. }
  421. func (c *HisApiController) Drugscheck() {
  422. admin_user_id, _ := c.GetInt64("admin_user_id")
  423. adminUser := c.GetAdminUserInfo()
  424. var queryResult []QueryResult
  425. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  426. for _, item := range drugs {
  427. result := QueryResult{
  428. ID: item.ID,
  429. Name: item.DrugName,
  430. Code: item.MedicalInsuranceNumber,
  431. List_type_code: "101",
  432. }
  433. queryResult = append(queryResult, result)
  434. }
  435. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  436. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  437. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  438. for _, item := range queryResult {
  439. service.Hnyb3302(miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2022-01-26", "2099-12-31", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey)
  440. }
  441. }
  442. func (c *HisApiController) Goodcheck() {
  443. admin_user_id, _ := c.GetInt64("admin_user_id")
  444. adminUser := c.GetAdminUserInfo()
  445. var queryResult []QueryResult
  446. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  447. for _, item := range goods {
  448. result := QueryResult{
  449. ID: item.ID,
  450. Name: item.GoodName,
  451. Code: item.SocialSecurityDirectoryCode,
  452. List_type_code: "301",
  453. }
  454. queryResult = append(queryResult, result)
  455. }
  456. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  457. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  458. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  459. for _, item := range queryResult {
  460. service.Hnyb3302(miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2022-01-26", "2099-12-31", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey)
  461. //service.Hnyb3302(miConfig.OrgName,role.UserName,miConfig.Code,miConfig.InsuplcAdmdvs,miConfig.MdtrtareaAdmvs,miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2022-01-26", "2099-12-31", miConfig.Url,miConfig.AccessKey,miConfig.SecretKey)
  462. }
  463. }
  464. func (c *HisApiController) Projectcheck() {
  465. admin_user_id, _ := c.GetInt64("admin_user_id")
  466. adminUser := c.GetAdminUserInfo()
  467. var queryResult []QueryResult
  468. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  469. for _, item := range projects {
  470. result := QueryResult{
  471. ID: item.ID,
  472. Name: item.ProjectName,
  473. Code: item.MedicalCode,
  474. List_type_code: "201",
  475. }
  476. queryResult = append(queryResult, result)
  477. }
  478. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  479. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  480. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  481. for _, item := range queryResult {
  482. service.Hnyb3302(miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2022-01-26", "2099-12-31", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey)
  483. }
  484. }
  485. //func (c *HisApiController)CancleDia(){
  486. //
  487. // id, _ := c.GetInt64("id")
  488. // record_time := c.GetString("record_time")
  489. // his_patient_id, _ := c.GetInt64("his_patient_id")
  490. //
  491. // admin_user_id, _ := c.GetInt64("admin_user_id")
  492. //
  493. // diagnosis_id := c.GetString("diagnosis")
  494. // sick_type, _ := c.GetInt64("sick_type")
  495. // reg_type, _ := c.GetInt64("p_type")
  496. // begin_time := c.GetString("begin_time")
  497. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  498. //
  499. //
  500. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  501. //
  502. // fmt.Println(acct_used_flag)
  503. //
  504. //
  505. // timeLayout := "2006-01-02"
  506. // loc, _ := time.LoadLocation("Local")
  507. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  508. // if err != nil {
  509. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  510. // return
  511. // }
  512. // recordDateTime := theTime.Unix()
  513. // adminUser := c.GetAdminUserInfo()
  514. //
  515. //
  516. //
  517. //
  518. //
  519. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  520. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  521. // var patientPrescription models.HisPrescriptionInfo
  522. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  523. // if patientPrescription.ID == 0 {
  524. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  525. // }
  526. // //if patientPrescription.Do
  527. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  528. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  529. //
  530. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  531. //
  532. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  533. //
  534. // var config []*models.HisXtDiagnoseConfig
  535. // for _, item := range diagnosis_ids {
  536. // id, _ := strconv.ParseInt(item, 10, 64)
  537. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  538. // config = append(config, &diagnosisConfig)
  539. // }
  540. //
  541. // sickConfig, _ := service.FindSickById(sick_type)
  542. //
  543. //
  544. // data := make(map[string]interface{})
  545. // client := &http.Client{}
  546. // data["psn_no"] = his.PsnNo
  547. // data["mdtrt_id"] = his.Number
  548. // data["doctor"] = roles.UserName
  549. // data["department"] = department.Name
  550. // data["org_name"] = miConfig.OrgName
  551. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  552. // data["doctor_id"] = doctor_info.DoctorNumber
  553. // data["new_doctor_name"] = doctor_info.UserName
  554. // data["fixmedins_code"] = miConfig.Code
  555. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  556. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  557. // data["secret_key"] = miConfig.SecretKey
  558. // data["sick_code"] = sickConfig.CountryCode
  559. // data["sick_name"] = sickConfig.ClassName
  560. // data["url"] = miConfig.Url
  561. // data["ak"] = miConfig.AccessKey
  562. // data["begin_time"] = begin_time
  563. // data["cainfo"] = miConfig.Cainfo
  564. // data["is_vaild"] = "0"
  565. //
  566. // data["dept"] = strconv.FormatInt(department.ID, 10)
  567. // data["config"] = config
  568. // bytesData, _ := json.Marshal(data)
  569. //
  570. // var req *http.Request
  571. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  572. // resp, _ := client.Do(req)
  573. // defer resp.Body.Close()
  574. // body, ioErr := ioutil.ReadAll(resp.Body)
  575. // if ioErr != nil {
  576. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  577. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  578. // return
  579. // }
  580. // var respJSON map[string]interface{}
  581. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  582. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  583. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  584. // return
  585. // }
  586. //
  587. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  588. // userJSONBytes, _ := json.Marshal(respJSON)
  589. // fmt.Println("log")
  590. // fmt.Println(string(userJSONBytes))
  591. //
  592. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  593. // utils.ErrorLog("解析失败:%v", err)
  594. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  595. // return
  596. // }
  597. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  598. // res2.Output = ressix10265.Output
  599. // res2.ErrMsg = ressix10265.ErrMsg
  600. // res2.Cainfo = ressix10265.Cainfo
  601. // res2.WarnMsg = ressix10265.WarnMsg
  602. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  603. // res2.Infcode = infocode
  604. //
  605. //}
  606. func (c *HisApiController) Get4102() {
  607. order_id, _ := c.GetInt64("order_id")
  608. admin_user_id, _ := c.GetInt64("admin_user_id")
  609. stas_type := c.GetString("stas_type")
  610. order, _ := service.GetHisOrderByIDTwo(order_id)
  611. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  612. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  613. var pp models.PublicParams
  614. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  615. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  616. pp.FixmedinsName = miConfig.OrgName
  617. pp.FixmedinsCode = miConfig.Code
  618. pp.RequestUrl = miConfig.Url
  619. pp.Cainfo = miConfig.Cainfo
  620. pp.SecretKey = miConfig.SecretKey
  621. pp.AccessKey = miConfig.AccessKey
  622. pp.OpterName = curRoles.UserName
  623. if miConfig.MdtrtareaAdmvs == "350500" {
  624. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  625. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  626. saveLog(result, request, "4102", "清单确认")
  627. var dat map[string]interface{}
  628. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  629. fmt.Println(dat)
  630. } else {
  631. fmt.Println(err)
  632. }
  633. var empty ResultFourteen
  634. userJSONBytes, _ := json.Marshal(dat)
  635. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  636. utils.ErrorLog("解析失败:%v", err)
  637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  638. return
  639. }
  640. if empty.Infcode == 0 {
  641. c.ServeSuccessJSON(map[string]interface{}{
  642. "msg": "确认成功",
  643. })
  644. return
  645. }
  646. } else {
  647. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  648. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  649. result3, request3 := service.Jxyb4105(pp)
  650. saveLog(result, request, "4102", "清单确认")
  651. saveLog(result2, request2, "4103", "清单确认")
  652. saveLog(result3, request3, "4105", "清单统计")
  653. var dat map[string]interface{}
  654. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  655. fmt.Println(dat)
  656. } else {
  657. fmt.Println(err)
  658. }
  659. var empty ResultFourteen
  660. userJSONBytes, _ := json.Marshal(dat)
  661. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  662. utils.ErrorLog("解析失败:%v", err)
  663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  664. return
  665. }
  666. if empty.Infcode == 0 {
  667. c.ServeSuccessJSON(map[string]interface{}{
  668. "msg": "确认成功",
  669. })
  670. return
  671. }
  672. }
  673. }
  674. // 对账权限查询
  675. func (c *HisApiController) Get3260() {
  676. admin_user_id, _ := c.GetInt64("admin_user_id")
  677. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  678. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  679. var api string
  680. var res models.JSResult3260
  681. if miConfig.MdtrtareaAdmvs == "320921" {
  682. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  683. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  684. } else {
  685. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  686. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  687. }
  688. resp, requestErr := http.Get(api)
  689. if requestErr != nil {
  690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  691. return
  692. }
  693. body, ioErr := ioutil.ReadAll(resp.Body)
  694. if ioErr != nil {
  695. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  697. return
  698. }
  699. var respJSON map[string]interface{}
  700. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  703. return
  704. }
  705. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  706. result, _ := json.Marshal(respJSON)
  707. if err := json.Unmarshal([]byte(result), &res); err != nil {
  708. utils.ErrorLog("解析失败:%v", err)
  709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  710. return
  711. }
  712. if res.Infcode == "0" {
  713. c.ServeSuccessJSON(map[string]interface{}{
  714. "result": res.Output.Data,
  715. })
  716. } else {
  717. c.ServeSuccessJSON(map[string]interface{}{
  718. "failed_code": -10,
  719. "msg": res.ErrMsg,
  720. })
  721. return
  722. }
  723. }
  724. func (c *HisApiController) Get3261() {
  725. admin_user_id, _ := c.GetInt64("admin_user_id")
  726. //month := c.GetString("month")
  727. startTime := c.GetString("start_time")
  728. //endTime, _ := c.GetString("end_time")
  729. times := strings.Split(startTime, "-")
  730. stmt_mon := times[0] + times[1]
  731. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  732. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  733. var api string
  734. var res models.JSResult3261
  735. //var res10265 Result5301For10265
  736. if miConfig.MdtrtareaAdmvs == "320921" {
  737. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  738. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  739. } else {
  740. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  741. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  742. }
  743. resp, requestErr := http.Get(api)
  744. if requestErr != nil {
  745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  746. return
  747. }
  748. body, ioErr := ioutil.ReadAll(resp.Body)
  749. if ioErr != nil {
  750. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  752. return
  753. }
  754. var respJSON map[string]interface{}
  755. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  756. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  758. return
  759. }
  760. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  761. result, _ := json.Marshal(respJSON)
  762. if err := json.Unmarshal([]byte(result), &res); err != nil {
  763. utils.ErrorLog("解析失败:%v", err)
  764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  765. return
  766. }
  767. if res.Infcode == "0" {
  768. c.ServeSuccessJSON(map[string]interface{}{
  769. "result": res.Output,
  770. })
  771. } else {
  772. c.ServeSuccessJSON(map[string]interface{}{
  773. "failed_code": -10,
  774. "msg": res.ErrMsg,
  775. })
  776. return
  777. }
  778. }
  779. type TempFun struct {
  780. FundKey string
  781. FundCode string
  782. }
  783. func (c *HisApiController) Get3262() {
  784. admin_user_id, _ := c.GetInt64("admin_user_id")
  785. startTime := c.GetString("start_time")
  786. endTime := c.GetString("end_time")
  787. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  788. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  789. //timeLayout := "2006-01-02"
  790. //loc, _ := time.LoadLocation("Local")
  791. //var theStartTIme int64
  792. //if len(startTime) > 0 {
  793. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  794. // if err != nil {
  795. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  796. // return
  797. // }
  798. // theStartTIme = theTime.Unix()
  799. //}
  800. //var theEndtTIme int64
  801. //if len(endTime) > 0 {
  802. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  803. // if err != nil {
  804. // utils.ErrorLog(err.Error())
  805. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  806. // return
  807. // }
  808. // theEndtTIme = theTime.Unix()
  809. //}
  810. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  811. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  812. for _, team := range datas {
  813. fmt.Println(team.PsnTime)
  814. for _, team_two := range datas_two {
  815. fmt.Println(team_two.PsnTime)
  816. if team.FundKey == team_two.FundKey {
  817. fmt.Println(team_two.PsnTime)
  818. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  819. fmt.Println(team.PsnTime)
  820. }
  821. }
  822. }
  823. fmt.Println("1111")
  824. fmt.Println(datas)
  825. fmt.Println("1111")
  826. var twos []models.FixMonRecDetailFileInTwo
  827. for _, team := range datas {
  828. var two models.FixMonRecDetailFileInTwo
  829. two.MedType = team.MedType
  830. two.Insutype = team.Insutype
  831. two.PsnType = team.PsnType
  832. two.MedType = team.MedType
  833. two.FixBlngAdmdvs = "999999"
  834. two.InsuAdmdvs = "555555"
  835. two.PsnTime = team.PsnTime
  836. two.PsnCnt = team.PsnCnt
  837. two.FundKey = team.FundKey
  838. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  839. fps, _ := strconv.ParseFloat(team.Fund, 64)
  840. ia, _ := strconv.ParseFloat(team.Amt, 64)
  841. two.MedfeeSumAmt = ms
  842. two.InscpAmt = ia
  843. two.FundPaySumAmt = fps
  844. twos = append(twos, two)
  845. }
  846. //startTime := c.GetString("start_time")
  847. //endTime, _ := c.GetString("end_time")
  848. times := strings.Split(startTime, "-")
  849. stmt_mon := times[0] + times[1]
  850. var funs []models.FundDetail
  851. for _, item := range datas {
  852. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  853. funs = append(funs, fun...)
  854. }
  855. var funInfos []models.Fund
  856. //for _, item := range funs {
  857. // var rf []models.FundInfo
  858. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  859. // for _, subitem := range rf {
  860. // var fund models.Fund
  861. // fund.FundCode = subitem.FundPayType
  862. // fund.FundName = subitem.FundPayTypeName
  863. // fund.FundAmt = subitem.FundPayAmt
  864. // fund.FundKey = item.FundKey
  865. // fund.InsuAdmdvs = "555555"
  866. // fund.FixBlngAdmdvs = "999999"
  867. // funInfos = append(funInfos, fund)
  868. // }
  869. //}
  870. var tempFuns []TempFun
  871. for _, funInfo := range funInfos {
  872. var tempFun TempFun
  873. tempFun.FundKey = funInfo.FundKey
  874. tempFun.FundCode = funInfo.FundCode
  875. tempFuns = append(tempFuns, tempFun)
  876. }
  877. tempFuns = RemoveRepeatedFunElement(tempFuns)
  878. fmt.Println(tempFuns)
  879. var funInfosTwo []models.Fund
  880. decimal.DivisionPrecision = 2
  881. for _, item := range tempFuns {
  882. var fund models.Fund
  883. for _, subItem := range funInfos {
  884. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  885. fund.FundKey = subItem.FundKey
  886. fund.InsuAdmdvs = subItem.InsuAdmdvs
  887. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  888. fund.FundName = subItem.FundName
  889. fund.FundCode = subItem.FundCode
  890. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  891. }
  892. }
  893. funInfosTwo = append(funInfosTwo, fund)
  894. }
  895. fmt.Println("funInfosTwo")
  896. fmt.Println(funInfosTwo)
  897. var upld_btch string
  898. var empty models.JSResultEmpty
  899. data := make(map[string]interface{})
  900. data["org_name"] = miConfig.OrgName
  901. data["doctor"] = curRoles.UserName
  902. data["doctor_name"] = curRoles.UserName
  903. data["fixmedins_code"] = miConfig.Code
  904. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  905. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  906. data["secret_key"] = miConfig.SecretKey
  907. data["url"] = miConfig.Url
  908. data["ak"] = miConfig.AccessKey
  909. data["cainfo"] = miConfig.Cainfo
  910. data["datas"] = twos
  911. data["fund"] = funInfosTwo
  912. fmt.Println(twos)
  913. month := time.Unix(1557042972, 0).Format("1")
  914. year := time.Now().Format("2006")
  915. month = time.Now().Format("01")
  916. day := time.Now().Format("02")
  917. hour := time.Now().Format("15")
  918. min := time.Now().Format("04")
  919. sec := time.Now().Format("05")
  920. fix_fill_date := year + month + day + hour + min + sec
  921. data["fix_fill_dept"] = miConfig.OrgName
  922. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  923. data["fix_fill_psn"] = curRoles.UserName
  924. data["fix_fill_date"] = fix_fill_date
  925. data["stmt_loc"] = "2"
  926. data["setl_mon"] = stmt_mon
  927. upld_btch = "0"
  928. data["upld_btch"] = upld_btch
  929. //fmt.Println(data)
  930. client := &http.Client{}
  931. bytesData, _ := json.Marshal(data)
  932. var req *http.Request
  933. if miConfig.MdtrtareaAdmvs == "320921" {
  934. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  935. } else {
  936. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  937. }
  938. resp, _ := client.Do(req)
  939. defer resp.Body.Close()
  940. body, ioErr := ioutil.ReadAll(resp.Body)
  941. if ioErr != nil {
  942. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  944. }
  945. var respJSON map[string]interface{}
  946. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  947. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  949. }
  950. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  951. //fmt.Println(respJSON)
  952. result, _ := json.Marshal(respJSON)
  953. //fmt.Println(result)
  954. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  955. utils.ErrorLog("解析失败:%v", err)
  956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  957. }
  958. if empty.Infcode != "0" {
  959. c.ServeSuccessJSON(map[string]interface{}{
  960. "failed_code": -10,
  961. "msg": empty.ErrMsg,
  962. })
  963. return
  964. } else {
  965. c.ServeSuccessJSON(map[string]interface{}{
  966. "msg": "上传成功",
  967. })
  968. return
  969. }
  970. }
  971. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  972. newArr = make([]TempFun, 0)
  973. for i := 0; i < len(arr); i++ {
  974. repeat := false
  975. for j := i + 1; j < len(arr); j++ {
  976. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  977. repeat = true
  978. break
  979. }
  980. }
  981. if !repeat {
  982. newArr = append(newArr, arr[i])
  983. }
  984. }
  985. return
  986. }
  987. func (c *HisApiController) Get3263() {
  988. admin_user_id, _ := c.GetInt64("admin_user_id")
  989. startTime := c.GetString("start_time")
  990. //endTime, _ := c.GetString("end_time")
  991. times := strings.Split(startTime, "-")
  992. setl_mon := times[0] + times[1]
  993. upld_btch := "0"
  994. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  995. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  996. var result3263 models.JSResult3263
  997. data := make(map[string]interface{})
  998. data["org_name"] = miConfig.OrgName
  999. data["doctor"] = curRoles.UserName
  1000. data["doctor_name"] = curRoles.UserName
  1001. data["fixmedins_code"] = miConfig.Code
  1002. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1003. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1004. data["secret_key"] = miConfig.SecretKey
  1005. data["url"] = miConfig.Url
  1006. data["ak"] = miConfig.AccessKey
  1007. data["cainfo"] = miConfig.Cainfo
  1008. data["setl_mon"] = setl_mon
  1009. data["stmt_loc"] = "2"
  1010. data["upld_btch"] = upld_btch
  1011. client := &http.Client{}
  1012. bytesData, _ := json.Marshal(data)
  1013. var req *http.Request
  1014. if miConfig.MdtrtareaAdmvs == "320921" {
  1015. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1016. } else {
  1017. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1018. }
  1019. resp, _ := client.Do(req)
  1020. defer resp.Body.Close()
  1021. body, ioErr := ioutil.ReadAll(resp.Body)
  1022. if ioErr != nil {
  1023. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1025. }
  1026. var respJSON map[string]interface{}
  1027. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1030. }
  1031. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1032. fmt.Println(respJSON)
  1033. result, _ := json.Marshal(respJSON)
  1034. fmt.Println(result)
  1035. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1036. utils.ErrorLog("解析失败:%v", err)
  1037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1038. }
  1039. if result3263.Infcode != "0" {
  1040. c.ServeSuccessJSON(map[string]interface{}{
  1041. "failed_code": -10,
  1042. "msg": result3263.ErrMsg,
  1043. })
  1044. return
  1045. } else {
  1046. c.ServeSuccessJSON(map[string]interface{}{
  1047. "list": result3263.Output,
  1048. })
  1049. return
  1050. }
  1051. }
  1052. func (c *HisApiController) Get3264() {
  1053. admin_user_id, _ := c.GetInt64("admin_user_id")
  1054. startTime := c.GetString("start_time")
  1055. //endTime, _ := c.GetString("end_time")
  1056. times := strings.Split(startTime, "-")
  1057. setl_mon := times[0] + times[1]
  1058. upld_btch := "0"
  1059. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1060. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1061. //solidify_id := []
  1062. var result3263 models.JSResult3263
  1063. data := make(map[string]interface{})
  1064. data["org_name"] = miConfig.OrgName
  1065. data["doctor"] = curRoles.UserName
  1066. data["doctor_name"] = curRoles.UserName
  1067. data["fixmedins_code"] = miConfig.Code
  1068. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1069. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1070. data["secret_key"] = miConfig.SecretKey
  1071. data["url"] = miConfig.Url
  1072. data["ak"] = miConfig.AccessKey
  1073. data["cainfo"] = miConfig.Cainfo
  1074. data["setl_mon"] = setl_mon
  1075. data["stmt_loc"] = "2"
  1076. data["upld_btch"] = upld_btch
  1077. client := &http.Client{}
  1078. bytesData, _ := json.Marshal(data)
  1079. var req3263 *http.Request
  1080. if miConfig.MdtrtareaAdmvs == "320921" {
  1081. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1082. } else {
  1083. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1084. }
  1085. resp, _ := client.Do(req3263)
  1086. defer resp.Body.Close()
  1087. body, ioErr := ioutil.ReadAll(resp.Body)
  1088. if ioErr != nil {
  1089. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1091. }
  1092. var respJSON3263 map[string]interface{}
  1093. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  1094. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1096. }
  1097. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1098. fmt.Println(respJSON3263)
  1099. result, _ := json.Marshal(respJSON3263)
  1100. fmt.Println(result)
  1101. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1102. utils.ErrorLog("解析失败:%v", err)
  1103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1104. }
  1105. var ids []string
  1106. for _, item := range result3263.Output {
  1107. ids = append(ids, item.SolidifyID)
  1108. }
  1109. var empty models.JSResultEmpty
  1110. data2 := make(map[string]interface{})
  1111. data2["org_name"] = miConfig.OrgName
  1112. data2["doctor"] = curRoles.UserName
  1113. data2["doctor_name"] = curRoles.UserName
  1114. data2["fixmedins_code"] = miConfig.Code
  1115. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1116. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1117. data2["secret_key"] = miConfig.SecretKey
  1118. data2["url"] = miConfig.Url
  1119. data2["ak"] = miConfig.AccessKey
  1120. data2["cainfo"] = miConfig.Cainfo
  1121. data2["setl_mon"] = setl_mon
  1122. data2["stmt_loc"] = "2"
  1123. data2["upld_btch"] = upld_btch
  1124. data2["solidify_id"] = ids
  1125. client2 := &http.Client{}
  1126. bytesData2, _ := json.Marshal(data2)
  1127. var req *http.Request
  1128. if miConfig.MdtrtareaAdmvs == "320921" {
  1129. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1130. } else {
  1131. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1132. }
  1133. resp2, _ := client2.Do(req)
  1134. defer resp.Body.Close()
  1135. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1136. if ioErr2 != nil {
  1137. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1139. }
  1140. var respJSON map[string]interface{}
  1141. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  1142. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1144. }
  1145. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1146. fmt.Println(respJSON)
  1147. result2, _ := json.Marshal(respJSON)
  1148. fmt.Println(result2)
  1149. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  1150. utils.ErrorLog("解析失败:%v", err)
  1151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1152. }
  1153. if empty.Infcode != "0" {
  1154. c.ServeSuccessJSON(map[string]interface{}{
  1155. "failed_code": -10,
  1156. "msg": empty.ErrMsg,
  1157. })
  1158. return
  1159. } else {
  1160. c.ServeSuccessJSON(map[string]interface{}{
  1161. "msg": "",
  1162. })
  1163. return
  1164. }
  1165. }
  1166. func (c *HisApiController) Get3265() {
  1167. admin_user_id, _ := c.GetInt64("admin_user_id")
  1168. startTime := c.GetString("start_time")
  1169. //endTime, _ := c.GetString("end_time")
  1170. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1171. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1172. times := strings.Split(startTime, "-")
  1173. setl_mon := times[0] + times[1]
  1174. var upld_btch string
  1175. upld_btch = "0"
  1176. //var empty models.JSResultEmpty
  1177. var result3265 models.JSResult3264
  1178. var result3263 models.JSResult3263
  1179. data2 := make(map[string]interface{})
  1180. data2["org_name"] = miConfig.OrgName
  1181. data2["doctor"] = curRoles.UserName
  1182. data2["doctor_name"] = curRoles.UserName
  1183. data2["fixmedins_code"] = miConfig.Code
  1184. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1185. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1186. data2["secret_key"] = miConfig.SecretKey
  1187. data2["url"] = miConfig.Url
  1188. data2["ak"] = miConfig.AccessKey
  1189. data2["cainfo"] = miConfig.Cainfo
  1190. data2["setl_mon"] = setl_mon
  1191. data2["stmt_loc"] = "2"
  1192. data2["upld_btch"] = upld_btch
  1193. client2 := &http.Client{}
  1194. bytesData2, _ := json.Marshal(data2)
  1195. var req3263 *http.Request
  1196. if miConfig.MdtrtareaAdmvs == "320921" {
  1197. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1198. } else {
  1199. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1200. }
  1201. resp2, _ := client2.Do(req3263)
  1202. defer resp2.Body.Close()
  1203. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1204. if ioErr2 != nil {
  1205. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1207. }
  1208. var respJSON3263 map[string]interface{}
  1209. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1210. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1212. }
  1213. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1214. fmt.Println(respJSON3263)
  1215. result2, _ := json.Marshal(respJSON3263)
  1216. fmt.Println(result2)
  1217. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1218. utils.ErrorLog("解析失败:%v", err)
  1219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1220. }
  1221. var ids []string
  1222. for _, item := range result3263.Output {
  1223. ids = append(ids, item.SolidifyID)
  1224. }
  1225. data := make(map[string]interface{})
  1226. data["org_name"] = miConfig.OrgName
  1227. data["doctor"] = curRoles.UserName
  1228. data["doctor_name"] = curRoles.UserName
  1229. data["fixmedins_code"] = miConfig.Code
  1230. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1231. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1232. data["secret_key"] = miConfig.SecretKey
  1233. data["url"] = miConfig.Url
  1234. data["ak"] = miConfig.AccessKey
  1235. data["cainfo"] = miConfig.Cainfo
  1236. data["setl_mon"] = setl_mon
  1237. data["solidify_id"] = ids
  1238. month := time.Unix(1557042972, 0).Format("1")
  1239. year := time.Now().Format("2006")
  1240. month = time.Now().Format("01")
  1241. day := time.Now().Format("02")
  1242. hour := time.Now().Format("15")
  1243. min := time.Now().Format("04")
  1244. sec := time.Now().Format("05")
  1245. fix_fill_date := year + month + day + hour + min + sec
  1246. data["fix_fill_dept"] = miConfig.OrgName
  1247. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1248. data["fix_fill_psn"] = curRoles.UserName
  1249. data["fix_fill_date"] = fix_fill_date
  1250. data["stmt_loc"] = "2"
  1251. data["upld_btch"] = upld_btch
  1252. client := &http.Client{}
  1253. bytesData, _ := json.Marshal(data)
  1254. var req *http.Request
  1255. if miConfig.MdtrtareaAdmvs == "320921" {
  1256. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1257. } else {
  1258. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1259. }
  1260. resp, _ := client.Do(req)
  1261. defer resp.Body.Close()
  1262. body, ioErr := ioutil.ReadAll(resp.Body)
  1263. if ioErr != nil {
  1264. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1266. }
  1267. var respJSON map[string]interface{}
  1268. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1271. }
  1272. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1273. fmt.Println(respJSON)
  1274. result, _ := json.Marshal(respJSON)
  1275. fmt.Println(result)
  1276. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1277. utils.ErrorLog("解析失败:%v", err)
  1278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1279. }
  1280. if result3265.Infcode != "0" {
  1281. c.ServeSuccessJSON(map[string]interface{}{
  1282. "failed_code": -10,
  1283. "msg": result3265.ErrMsg,
  1284. })
  1285. return
  1286. } else {
  1287. c.ServeSuccessJSON(map[string]interface{}{
  1288. "info": result3265.Output,
  1289. })
  1290. return
  1291. }
  1292. }
  1293. func (c *HisApiController) Get3266() {
  1294. admin_user_id, _ := c.GetInt64("admin_user_id")
  1295. startTime := c.GetString("start_time")
  1296. //endTime, _ := c.GetString("end_time")
  1297. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1298. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1299. times := strings.Split(startTime, "-")
  1300. stmt_mon := times[0] + times[1]
  1301. var upld_btch string
  1302. //var empty models.JSResultEmpty
  1303. var result3265 models.JSResult3264
  1304. data := make(map[string]interface{})
  1305. data["org_name"] = miConfig.OrgName
  1306. data["doctor"] = curRoles.UserName
  1307. data["doctor_name"] = curRoles.UserName
  1308. data["fixmedins_code"] = miConfig.Code
  1309. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1310. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1311. data["secret_key"] = miConfig.SecretKey
  1312. data["url"] = miConfig.Url
  1313. data["ak"] = miConfig.AccessKey
  1314. data["cainfo"] = miConfig.Cainfo
  1315. data["setl_mon"] = stmt_mon
  1316. month := time.Unix(1557042972, 0).Format("1")
  1317. year := time.Now().Format("2006")
  1318. month = time.Now().Format("01")
  1319. day := time.Now().Format("02")
  1320. hour := time.Now().Format("15")
  1321. min := time.Now().Format("04")
  1322. sec := time.Now().Format("05")
  1323. fix_fill_date := year + month + day + hour + min + sec
  1324. data["fix_fill_dept"] = miConfig.OrgName
  1325. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1326. data["fix_fill_psn"] = curRoles.UserName
  1327. data["fix_fill_date"] = fix_fill_date
  1328. data["stmt_loc"] = "2"
  1329. upld_btch = "0"
  1330. data["upld_btch"] = upld_btch
  1331. client := &http.Client{}
  1332. bytesData, _ := json.Marshal(data)
  1333. var req *http.Request
  1334. if miConfig.MdtrtareaAdmvs == "320921" {
  1335. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  1336. } else {
  1337. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  1338. }
  1339. resp, _ := client.Do(req)
  1340. defer resp.Body.Close()
  1341. body, ioErr := ioutil.ReadAll(resp.Body)
  1342. if ioErr != nil {
  1343. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1345. }
  1346. var respJSON map[string]interface{}
  1347. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1350. }
  1351. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1352. fmt.Println(respJSON)
  1353. result, _ := json.Marshal(respJSON)
  1354. fmt.Println(result)
  1355. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1356. utils.ErrorLog("解析失败:%v", err)
  1357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1358. }
  1359. if result3265.Infcode != "0" {
  1360. c.ServeSuccessJSON(map[string]interface{}{
  1361. "failed_code": -10,
  1362. "msg": result3265.ErrMsg,
  1363. })
  1364. return
  1365. } else {
  1366. c.ServeSuccessJSON(map[string]interface{}{
  1367. "info": result3265.Output,
  1368. })
  1369. return
  1370. }
  1371. }
  1372. func (c *HisApiController) Get3267() {
  1373. admin_user_id, _ := c.GetInt64("admin_user_id")
  1374. startTime := c.GetString("start_time")
  1375. //endTime, _ := c.GetString("end_time")
  1376. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1377. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1378. times := strings.Split(startTime, "-")
  1379. setl_mon := times[0] + times[1]
  1380. var upld_btch string
  1381. //var empty models.JSResultEmpty
  1382. var result3265 models.JSResult3264
  1383. upld_btch = "0"
  1384. data := make(map[string]interface{})
  1385. data["org_name"] = miConfig.OrgName
  1386. data["doctor"] = curRoles.UserName
  1387. data["doctor_name"] = curRoles.UserName
  1388. data["fixmedins_code"] = miConfig.Code
  1389. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1390. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1391. data["secret_key"] = miConfig.SecretKey
  1392. data["url"] = miConfig.Url
  1393. data["ak"] = miConfig.AccessKey
  1394. data["cainfo"] = miConfig.Cainfo
  1395. data["setl_mon"] = setl_mon
  1396. data["stmt_loc"] = "2"
  1397. data["upld_btch"] = upld_btch
  1398. client := &http.Client{}
  1399. bytesData, _ := json.Marshal(data)
  1400. var req *http.Request
  1401. if miConfig.MdtrtareaAdmvs == "320921" {
  1402. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1403. } else {
  1404. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1405. }
  1406. resp, _ := client.Do(req)
  1407. defer resp.Body.Close()
  1408. body, ioErr := ioutil.ReadAll(resp.Body)
  1409. if ioErr != nil {
  1410. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1412. }
  1413. var respJSON map[string]interface{}
  1414. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1415. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1417. }
  1418. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1419. fmt.Println(respJSON)
  1420. result, _ := json.Marshal(respJSON)
  1421. fmt.Println(result)
  1422. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1423. utils.ErrorLog("解析失败:%v", err)
  1424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1425. }
  1426. if result3265.Infcode != "0" {
  1427. c.ServeSuccessJSON(map[string]interface{}{
  1428. "failed_code": -10,
  1429. "msg": result3265.ErrMsg,
  1430. })
  1431. return
  1432. } else {
  1433. c.ServeSuccessJSON(map[string]interface{}{
  1434. "info": result3265.Output.Data,
  1435. })
  1436. return
  1437. }
  1438. }
  1439. func (c *HisApiController) Get3268() {
  1440. admin_user_id, _ := c.GetInt64("admin_user_id")
  1441. startTime := c.GetString("start_time")
  1442. endTime := c.GetString("end_time")
  1443. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1444. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1445. times := strings.Split(startTime, "-")
  1446. setl_mon := times[0] + times[1]
  1447. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1448. var twos []models.FixMonRecDetailFileInTwo
  1449. var funs []models.FundDetail
  1450. for _, item := range datas {
  1451. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  1452. funs = append(funs, fun...)
  1453. }
  1454. var funInfos []models.Fund
  1455. //for _, item := range funs {
  1456. // var rf []models.FundInfo
  1457. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  1458. // for _, subitem := range rf {
  1459. // var fund models.Fund
  1460. // fund.FundCode = subitem.FundPayType
  1461. // fund.FundName = subitem.FundPayTypeName
  1462. // fund.FundAmt = subitem.FundPayAmt
  1463. // fund.FundKey = item.FundKey
  1464. // fund.InsuAdmdvs = "555555"
  1465. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  1466. // funInfos = append(funInfos, fund)
  1467. // }
  1468. //}
  1469. for _, team := range datas {
  1470. var two models.FixMonRecDetailFileInTwo
  1471. two.SetlDate = time.Now().Format("2006-01-02")
  1472. two.MedType = team.MedType
  1473. two.Insutype = team.Insutype
  1474. two.PsnType = team.PsnType
  1475. two.MedType = team.MedType
  1476. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  1477. two.InsuAdmdvs = team.InsuAdmdvs
  1478. two.PsnTime = team.PsnTime
  1479. two.PsnCnt = team.PsnCnt
  1480. two.FundKey = team.FundKey
  1481. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  1482. fps, _ := strconv.ParseFloat(team.Fund, 64)
  1483. ia, _ := strconv.ParseFloat(team.Amt, 64)
  1484. two.MedfeeSumAmt = ms
  1485. two.InscpAmt = ia
  1486. two.FundPaySumAmt = fps
  1487. twos = append(twos, two)
  1488. }
  1489. var upld_btch string
  1490. upld_btch = "0"
  1491. var empty models.JSResultEmpty
  1492. data := make(map[string]interface{})
  1493. data["org_name"] = miConfig.OrgName
  1494. data["doctor"] = curRoles.UserName
  1495. data["doctor_name"] = curRoles.UserName
  1496. data["fixmedins_code"] = miConfig.Code
  1497. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1498. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1499. data["secret_key"] = miConfig.SecretKey
  1500. data["url"] = miConfig.Url
  1501. data["ak"] = miConfig.AccessKey
  1502. data["cainfo"] = miConfig.Cainfo
  1503. data["datas"] = twos
  1504. data["fund"] = funInfos
  1505. data["setl_mon"] = setl_mon
  1506. month := time.Unix(1557042972, 0).Format("1")
  1507. year := time.Now().Format("2006")
  1508. month = time.Now().Format("01")
  1509. day := time.Now().Format("02")
  1510. hour := time.Now().Format("15")
  1511. min := time.Now().Format("04")
  1512. sec := time.Now().Format("05")
  1513. fix_fill_date := year + month + day + hour + min + sec
  1514. data["fix_fill_dept"] = miConfig.OrgName
  1515. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1516. data["fix_fill_psn"] = curRoles.UserName
  1517. data["fix_fill_date"] = fix_fill_date
  1518. data["stmt_loc"] = "2"
  1519. data["upld_btch"] = upld_btch
  1520. client := &http.Client{}
  1521. bytesData, _ := json.Marshal(data)
  1522. var req *http.Request
  1523. if miConfig.MdtrtareaAdmvs == "320921" {
  1524. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  1525. } else {
  1526. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  1527. }
  1528. resp, _ := client.Do(req)
  1529. defer resp.Body.Close()
  1530. body, ioErr := ioutil.ReadAll(resp.Body)
  1531. if ioErr != nil {
  1532. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1534. }
  1535. var respJSON map[string]interface{}
  1536. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1539. }
  1540. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1541. fmt.Println(respJSON)
  1542. result, _ := json.Marshal(respJSON)
  1543. fmt.Println(result)
  1544. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  1545. utils.ErrorLog("解析失败:%v", err)
  1546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1547. }
  1548. if empty.Infcode != "0" {
  1549. c.ServeSuccessJSON(map[string]interface{}{
  1550. "failed_code": -10,
  1551. "msg": empty.ErrMsg,
  1552. })
  1553. return
  1554. } else {
  1555. c.ServeSuccessJSON(map[string]interface{}{
  1556. "msg": "上传成功",
  1557. })
  1558. return
  1559. }
  1560. }
  1561. func (c *HisApiController) Get3269() {
  1562. admin_user_id, _ := c.GetInt64("admin_user_id")
  1563. startTime := c.GetString("start_time")
  1564. //endTime, _ := c.GetString("end_time")
  1565. times := strings.Split(startTime, "-")
  1566. setl_mon := times[0] + times[1]
  1567. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1568. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1569. var result3263 models.JSResult3263
  1570. data := make(map[string]interface{})
  1571. data["org_name"] = miConfig.OrgName
  1572. data["doctor"] = curRoles.UserName
  1573. data["doctor_name"] = curRoles.UserName
  1574. data["fixmedins_code"] = miConfig.Code
  1575. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1576. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1577. data["secret_key"] = miConfig.SecretKey
  1578. data["url"] = miConfig.Url
  1579. data["ak"] = miConfig.AccessKey
  1580. data["cainfo"] = miConfig.Cainfo
  1581. data["setl_mon"] = setl_mon
  1582. data["stmt_loc"] = "2"
  1583. client := &http.Client{}
  1584. bytesData, _ := json.Marshal(data)
  1585. var req *http.Request
  1586. if miConfig.MdtrtareaAdmvs == "320921" {
  1587. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  1588. } else {
  1589. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  1590. }
  1591. resp, _ := client.Do(req)
  1592. defer resp.Body.Close()
  1593. body, ioErr := ioutil.ReadAll(resp.Body)
  1594. if ioErr != nil {
  1595. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1597. }
  1598. var respJSON map[string]interface{}
  1599. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1600. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1602. }
  1603. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1604. fmt.Println(respJSON)
  1605. result, _ := json.Marshal(respJSON)
  1606. fmt.Println(result)
  1607. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1608. utils.ErrorLog("解析失败:%v", err)
  1609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1610. }
  1611. if result3263.Infcode != "0" {
  1612. c.ServeSuccessJSON(map[string]interface{}{
  1613. "failed_code": -10,
  1614. "msg": result3263.ErrMsg,
  1615. })
  1616. return
  1617. } else {
  1618. c.ServeSuccessJSON(map[string]interface{}{
  1619. "msg": "上传成功",
  1620. })
  1621. return
  1622. }
  1623. }
  1624. func (c *HisApiController) Get3270() {
  1625. admin_user_id, _ := c.GetInt64("admin_user_id")
  1626. startTime := c.GetString("start_time")
  1627. //endTime, _ := c.GetString("end_time")
  1628. times := strings.Split(startTime, "-")
  1629. setl_mon := times[0] + times[1]
  1630. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1631. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1632. var result3263 models.JSResult3263
  1633. data2 := make(map[string]interface{})
  1634. data2["org_name"] = miConfig.OrgName
  1635. data2["doctor"] = curRoles.UserName
  1636. data2["doctor_name"] = curRoles.UserName
  1637. data2["fixmedins_code"] = miConfig.Code
  1638. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1639. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1640. data2["secret_key"] = miConfig.SecretKey
  1641. data2["url"] = miConfig.Url
  1642. data2["ak"] = miConfig.AccessKey
  1643. data2["cainfo"] = miConfig.Cainfo
  1644. data2["setl_mon"] = setl_mon
  1645. data2["stmt_loc"] = "2"
  1646. client2 := &http.Client{}
  1647. bytesData2, _ := json.Marshal(data2)
  1648. var req3263 *http.Request
  1649. if miConfig.MdtrtareaAdmvs == "320921" {
  1650. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1651. } else {
  1652. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1653. }
  1654. resp2, _ := client2.Do(req3263)
  1655. defer resp2.Body.Close()
  1656. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1657. if ioErr2 != nil {
  1658. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1660. }
  1661. var respJSON3263 map[string]interface{}
  1662. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1665. }
  1666. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1667. fmt.Println(respJSON3263)
  1668. result2, _ := json.Marshal(respJSON3263)
  1669. fmt.Println(result2)
  1670. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1671. utils.ErrorLog("解析失败:%v", err)
  1672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1673. }
  1674. var ids []string
  1675. for _, item := range result3263.Output {
  1676. ids = append(ids, item.SolidifyID)
  1677. }
  1678. var result3264 models.JSResult3264
  1679. data := make(map[string]interface{})
  1680. data["org_name"] = miConfig.OrgName
  1681. data["doctor"] = curRoles.UserName
  1682. data["doctor_name"] = curRoles.UserName
  1683. data["fixmedins_code"] = miConfig.Code
  1684. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1685. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1686. data["secret_key"] = miConfig.SecretKey
  1687. data["url"] = miConfig.Url
  1688. data["ak"] = miConfig.AccessKey
  1689. data["cainfo"] = miConfig.Cainfo
  1690. data["setl_mon"] = setl_mon
  1691. data["stmt_loc"] = "2"
  1692. data["solidify_id"] = ids
  1693. client := &http.Client{}
  1694. bytesData, _ := json.Marshal(data)
  1695. var req *http.Request
  1696. if miConfig.MdtrtareaAdmvs == "320921" {
  1697. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  1698. } else {
  1699. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  1700. }
  1701. resp, _ := client.Do(req)
  1702. defer resp.Body.Close()
  1703. body, ioErr := ioutil.ReadAll(resp.Body)
  1704. if ioErr != nil {
  1705. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1707. }
  1708. var respJSON map[string]interface{}
  1709. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1710. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1712. }
  1713. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1714. fmt.Println(respJSON)
  1715. result, _ := json.Marshal(respJSON)
  1716. fmt.Println(result)
  1717. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  1718. utils.ErrorLog("解析失败:%v", err)
  1719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1720. }
  1721. if result3264.Infcode != "0" {
  1722. c.ServeSuccessJSON(map[string]interface{}{
  1723. "failed_code": -10,
  1724. "msg": result3264.ErrMsg,
  1725. })
  1726. return
  1727. } else {
  1728. c.ServeSuccessJSON(map[string]interface{}{
  1729. "info": result3264.Output,
  1730. })
  1731. return
  1732. }
  1733. }
  1734. func (c *HisApiController) Get3271() {
  1735. admin_user_id, _ := c.GetInt64("admin_user_id")
  1736. startTime := c.GetString("start_time")
  1737. //endTime, _ := c.GetString("end_time")
  1738. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1739. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1740. times := strings.Split(startTime, "-")
  1741. setl_mon := times[0] + times[1]
  1742. //var empty models.JSResultEmpty
  1743. var result3265 models.JSResult3264
  1744. var result3263 models.JSResult3263
  1745. data2 := make(map[string]interface{})
  1746. data2["org_name"] = miConfig.OrgName
  1747. data2["doctor"] = curRoles.UserName
  1748. data2["doctor_name"] = curRoles.UserName
  1749. data2["fixmedins_code"] = miConfig.Code
  1750. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1751. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1752. data2["secret_key"] = miConfig.SecretKey
  1753. data2["url"] = miConfig.Url
  1754. data2["ak"] = miConfig.AccessKey
  1755. data2["cainfo"] = miConfig.Cainfo
  1756. data2["setl_mon"] = setl_mon
  1757. data2["stmt_loc"] = "2"
  1758. client2 := &http.Client{}
  1759. bytesData2, _ := json.Marshal(data2)
  1760. var req3263 *http.Request
  1761. if miConfig.MdtrtareaAdmvs == "320921" {
  1762. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1763. } else {
  1764. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1765. }
  1766. resp2, _ := client2.Do(req3263)
  1767. defer resp2.Body.Close()
  1768. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1769. if ioErr2 != nil {
  1770. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1772. }
  1773. var respJSON3263 map[string]interface{}
  1774. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1775. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1777. }
  1778. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1779. fmt.Println(respJSON3263)
  1780. result2, _ := json.Marshal(respJSON3263)
  1781. fmt.Println(result2)
  1782. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1783. utils.ErrorLog("解析失败:%v", err)
  1784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1785. }
  1786. var ids []string
  1787. for _, item := range result3263.Output {
  1788. ids = append(ids, item.SolidifyID)
  1789. }
  1790. data := make(map[string]interface{})
  1791. data["org_name"] = miConfig.OrgName
  1792. data["doctor"] = curRoles.UserName
  1793. data["doctor_name"] = curRoles.UserName
  1794. data["fixmedins_code"] = miConfig.Code
  1795. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1796. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1797. data["secret_key"] = miConfig.SecretKey
  1798. data["url"] = miConfig.Url
  1799. data["ak"] = miConfig.AccessKey
  1800. data["cainfo"] = miConfig.Cainfo
  1801. data["setl_mon"] = setl_mon
  1802. data["solidify_id"] = ids
  1803. month := time.Unix(1557042972, 0).Format("1")
  1804. year := time.Now().Format("2006")
  1805. month = time.Now().Format("01")
  1806. day := time.Now().Format("02")
  1807. hour := time.Now().Format("15")
  1808. min := time.Now().Format("04")
  1809. sec := time.Now().Format("05")
  1810. fix_fill_date := year + month + day + hour + min + sec
  1811. data["fix_fill_dept"] = miConfig.OrgName
  1812. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1813. data["fix_fill_psn"] = curRoles.UserName
  1814. data["fix_fill_date"] = fix_fill_date
  1815. data["stmt_loc"] = "2"
  1816. client := &http.Client{}
  1817. bytesData, _ := json.Marshal(data)
  1818. var req *http.Request
  1819. if miConfig.MdtrtareaAdmvs == "320921" {
  1820. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  1821. } else {
  1822. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  1823. }
  1824. resp, _ := client.Do(req)
  1825. defer resp.Body.Close()
  1826. body, ioErr := ioutil.ReadAll(resp.Body)
  1827. if ioErr != nil {
  1828. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1830. }
  1831. var respJSON map[string]interface{}
  1832. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1835. }
  1836. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1837. fmt.Println(respJSON)
  1838. result, _ := json.Marshal(respJSON)
  1839. fmt.Println(result)
  1840. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1841. utils.ErrorLog("解析失败:%v", err)
  1842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1843. }
  1844. if result3265.Infcode != "0" {
  1845. c.ServeSuccessJSON(map[string]interface{}{
  1846. "failed_code": -10,
  1847. "msg": result3265.ErrMsg,
  1848. })
  1849. return
  1850. } else {
  1851. c.ServeSuccessJSON(map[string]interface{}{
  1852. "info": result3265.Output.Data,
  1853. })
  1854. return
  1855. }
  1856. }
  1857. func (c *HisApiController) Get3272() {
  1858. admin_user_id, _ := c.GetInt64("admin_user_id")
  1859. startTime := c.GetString("start_time")
  1860. //endTime, _ := c.GetString("end_time")
  1861. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1862. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1863. times := strings.Split(startTime, "-")
  1864. setl_mon := times[0] + times[1]
  1865. var upld_btch string
  1866. //var empty models.JSResultEmpty
  1867. var result3265 models.JSResult3264
  1868. data := make(map[string]interface{})
  1869. data["org_name"] = miConfig.OrgName
  1870. data["doctor"] = curRoles.UserName
  1871. data["doctor_name"] = curRoles.UserName
  1872. data["fixmedins_code"] = miConfig.Code
  1873. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1874. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1875. data["secret_key"] = miConfig.SecretKey
  1876. data["url"] = miConfig.Url
  1877. data["ak"] = miConfig.AccessKey
  1878. data["cainfo"] = miConfig.Cainfo
  1879. data["setl_mon"] = setl_mon
  1880. month := time.Unix(1557042972, 0).Format("1")
  1881. year := time.Now().Format("2006")
  1882. month = time.Now().Format("01")
  1883. day := time.Now().Format("02")
  1884. hour := time.Now().Format("15")
  1885. min := time.Now().Format("04")
  1886. sec := time.Now().Format("05")
  1887. fix_fill_date := year + month + day + hour + min + sec
  1888. data["fix_fill_dept"] = miConfig.OrgName
  1889. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1890. data["fix_fill_psn"] = curRoles.UserName
  1891. data["fix_fill_date"] = fix_fill_date
  1892. data["stmt_loc"] = "2"
  1893. data["upld_btch"] = upld_btch
  1894. client := &http.Client{}
  1895. bytesData, _ := json.Marshal(data)
  1896. var req *http.Request
  1897. if miConfig.MdtrtareaAdmvs == "320921" {
  1898. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  1899. } else {
  1900. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  1901. }
  1902. resp, _ := client.Do(req)
  1903. defer resp.Body.Close()
  1904. body, ioErr := ioutil.ReadAll(resp.Body)
  1905. if ioErr != nil {
  1906. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1908. }
  1909. var respJSON map[string]interface{}
  1910. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1913. }
  1914. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1915. fmt.Println(respJSON)
  1916. result, _ := json.Marshal(respJSON)
  1917. fmt.Println(result)
  1918. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1919. utils.ErrorLog("解析失败:%v", err)
  1920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1921. }
  1922. if result3265.Infcode != "0" {
  1923. c.ServeSuccessJSON(map[string]interface{}{
  1924. "failed_code": -10,
  1925. "msg": result3265.ErrMsg,
  1926. })
  1927. return
  1928. } else {
  1929. c.ServeSuccessJSON(map[string]interface{}{
  1930. "info": result3265.Output,
  1931. })
  1932. return
  1933. }
  1934. }
  1935. func (c *HisApiController) Get3273() {
  1936. admin_user_id, _ := c.GetInt64("admin_user_id")
  1937. startTime := c.GetString("start_time")
  1938. //endTime, _ := c.GetString("end_time")
  1939. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1940. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1941. times := strings.Split(startTime, "-")
  1942. setl_mon := times[0] + times[1]
  1943. var result3265 models.JSResult3264
  1944. data := make(map[string]interface{})
  1945. data["org_name"] = miConfig.OrgName
  1946. data["doctor"] = curRoles.UserName
  1947. data["doctor_name"] = curRoles.UserName
  1948. data["fixmedins_code"] = miConfig.Code
  1949. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1950. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1951. data["secret_key"] = miConfig.SecretKey
  1952. data["url"] = miConfig.Url
  1953. data["ak"] = miConfig.AccessKey
  1954. data["cainfo"] = miConfig.Cainfo
  1955. data["setl_mon"] = setl_mon
  1956. data["stmt_loc"] = "2"
  1957. client := &http.Client{}
  1958. bytesData, _ := json.Marshal(data)
  1959. var req *http.Request
  1960. if miConfig.MdtrtareaAdmvs == "320921" {
  1961. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  1962. } else {
  1963. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  1964. }
  1965. resp, _ := client.Do(req)
  1966. defer resp.Body.Close()
  1967. body, ioErr := ioutil.ReadAll(resp.Body)
  1968. if ioErr != nil {
  1969. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1971. }
  1972. var respJSON map[string]interface{}
  1973. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1974. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1976. }
  1977. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1978. fmt.Println(respJSON)
  1979. result, _ := json.Marshal(respJSON)
  1980. fmt.Println(result)
  1981. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1982. utils.ErrorLog("解析失败:%v", err)
  1983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1984. }
  1985. if result3265.Infcode != "0" {
  1986. c.ServeSuccessJSON(map[string]interface{}{
  1987. "failed_code": -10,
  1988. "msg": result3265.ErrMsg,
  1989. })
  1990. return
  1991. } else {
  1992. c.ServeSuccessJSON(map[string]interface{}{
  1993. "info": result3265.Output.Data,
  1994. })
  1995. return
  1996. }
  1997. }
  1998. func (c *HisApiController) Get3274() {
  1999. //if miConfig.MdtrtareaAdmvs == "320921" {
  2000. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2001. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2002. // "&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_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  2003. //
  2004. //} else {
  2005. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2006. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2007. // "&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_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  2008. //
  2009. //}
  2010. }
  2011. func (c *HisApiController) Get3275() {
  2012. //if miConfig.MdtrtareaAdmvs == "320921" {
  2013. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2014. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2015. // "&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_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  2016. //
  2017. //} else {
  2018. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2019. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2020. // "&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_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  2021. //
  2022. //}
  2023. }
  2024. func (c *HisApiController) Get3276() {
  2025. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2026. //month := c.GetString("month")
  2027. //
  2028. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2029. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2030. //var api string
  2031. //var res Result5301
  2032. //
  2033. //if miConfig.MdtrtareaAdmvs == "320921" {
  2034. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2035. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2036. //} else {
  2037. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2038. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2039. //}
  2040. //
  2041. //resp, requestErr := http.Get(api)
  2042. //if requestErr != nil {
  2043. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2044. // return
  2045. //}
  2046. //
  2047. //body, ioErr := ioutil.ReadAll(resp.Body)
  2048. //if ioErr != nil {
  2049. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2050. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2051. // return
  2052. //}
  2053. //var respJSON map[string]interface{}
  2054. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2055. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2056. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2057. // return
  2058. //}
  2059. //
  2060. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2061. //result, _ := json.Marshal(respJSON)
  2062. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2063. // utils.ErrorLog("解析失败:%v", err)
  2064. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2065. // return
  2066. //}
  2067. }
  2068. func (c *HisApiController) Get3277() {
  2069. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2070. //month := c.GetString("month")
  2071. //
  2072. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2073. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2074. //var api string
  2075. //var res Result5301
  2076. //
  2077. //if miConfig.MdtrtareaAdmvs == "320921" {
  2078. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2079. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2080. //} else {
  2081. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2082. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2083. //}
  2084. //
  2085. //resp, requestErr := http.Get(api)
  2086. //if requestErr != nil {
  2087. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2088. // return
  2089. //}
  2090. //
  2091. //body, ioErr := ioutil.ReadAll(resp.Body)
  2092. //if ioErr != nil {
  2093. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2094. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2095. // return
  2096. //}
  2097. //var respJSON map[string]interface{}
  2098. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2099. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2100. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2101. // return
  2102. //}
  2103. //
  2104. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2105. //result, _ := json.Marshal(respJSON)
  2106. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2107. // utils.ErrorLog("解析失败:%v", err)
  2108. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2109. // return
  2110. //}
  2111. }
  2112. func (c *HisApiController) GetCFYLJG001() {
  2113. admin_user_id, _ := c.GetInt64("admin_user_id")
  2114. patient_id, _ := c.GetInt64("patient_id")
  2115. his_patient_id, _ := c.GetInt64("his_patient_id")
  2116. record_time := c.GetString("record_time")
  2117. admin_user_id = 3626
  2118. //patient_id = 23834
  2119. //his_patient_id = 271193
  2120. //record_time = "2023-09-07"
  2121. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2122. psn, _ := service.GetPsnByPatientId(patient_id)
  2123. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  2124. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  2125. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2126. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2127. var cFYLJG001 models.CFYLJG001
  2128. timeLayout := "2006-01-02"
  2129. loc, _ := time.LoadLocation("Local")
  2130. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2131. if err != nil {
  2132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2133. return
  2134. }
  2135. recordDateTime := theTime.Unix()
  2136. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2137. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2138. for _, item := range prescriptions {
  2139. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  2140. if his.IdCardType == 1 {
  2141. bas := strings.Split(psn.CardInfo, "|")
  2142. basNumber := bas[1]
  2143. fmt.Println(basNumber)
  2144. card_sn := bas[3]
  2145. card_no := bas[2]
  2146. cFYLJG001.MdtrtCertType = "03"
  2147. cFYLJG001.CardSn = card_sn
  2148. cFYLJG001.MdtrtCertNo = card_no
  2149. cFYLJG001.EcToken = ""
  2150. cFYLJG001.AuthNo = ""
  2151. } else if his.IdCardType == 2 {
  2152. cFYLJG001.MdtrtCertType = "02"
  2153. cFYLJG001.CardSn = ""
  2154. cFYLJG001.MdtrtCertNo = his.IdCardNo
  2155. cFYLJG001.EcToken = ""
  2156. cFYLJG001.AuthNo = ""
  2157. } else if his.IdCardType == 4 {
  2158. cFYLJG001.MdtrtCertType = "01"
  2159. cFYLJG001.CardSn = ""
  2160. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  2161. cFYLJG001.EcToken = psn.VerifyNumber
  2162. cFYLJG001.AuthNo = ""
  2163. }
  2164. cFYLJG001.BizTypeCode = "01"
  2165. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  2166. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  2167. cFYLJG001.RxTypeCode = "1"
  2168. tempTime := time.Unix(item.PreTime, 0)
  2169. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2170. cFYLJG001.PrscTime = timeFormatOne
  2171. var count float64
  2172. if item.Type == 1 {
  2173. for _, sumItem := range item.HisDoctorAdviceInfo {
  2174. count = count + sumItem.PrescribingNumber
  2175. }
  2176. }
  2177. cFYLJG001.RxDrugCnt = count
  2178. cFYLJG001.ValiDays = "5"
  2179. ts := time.Unix(item.PreTime, 0)
  2180. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  2181. tempTime3 := time.Unix(record_time2, 0)
  2182. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  2183. cFYLJG001.ValiEndTime = timeFormat3
  2184. cFYLJG001.RxCotnFlag = "0"
  2185. for _, subItem := range item.HisDoctorAdviceInfo {
  2186. var drug models.RxDrug
  2187. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2188. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2189. drug.RxItemTypeCode = "11"
  2190. drug.DrugDosform = "乳膏剂" //TODO
  2191. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  2192. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  2193. }
  2194. drug.MedcWayDscr = subItem.DeliveryWay
  2195. tempTime2 := time.Unix(subItem.StartTime, 0)
  2196. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2197. drug.MedcBegntime = timeFormatTwo
  2198. if subItem.Day > 0 {
  2199. ts := time.Unix(subItem.StartTime, 0)
  2200. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  2201. tempTime4 := time.Unix(record_time, 0)
  2202. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  2203. drug.MedcEndtime = timeFormat5
  2204. } else {
  2205. tempTime2 := time.Unix(subItem.StartTime, 0)
  2206. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2207. drug.MedcEndtime = timeFormatTwo
  2208. }
  2209. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  2210. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  2211. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  2212. drug.DrugCnt = subItem.PrescribingNumber
  2213. drug.DrugDosunt = subItem.PrescribingNumberUnit
  2214. drug.DrugGenname = subItem.AdviceName
  2215. drug.MedcWayCodg = subItem.DeliveryWay
  2216. //drug.DrugTotlcnt = subItem.PrescribingNumber
  2217. drug.SinDoscnt = subItem.SingleDose
  2218. drug.SinDosunt = subItem.SingleDoseUnit
  2219. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  2220. drug.UsedFrquName = subItem.ExecutionFrequency
  2221. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2222. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  2223. drug.HospApprFlag = "1"
  2224. cFYLJG001.List = append(cFYLJG001.List, drug)
  2225. }
  2226. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  2227. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  2228. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  2229. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  2230. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  2231. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  2232. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  2233. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  2234. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  2235. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  2236. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2237. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  2238. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  2239. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  2240. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2241. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  2242. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  2243. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  2244. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  2245. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  2246. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  2247. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  2248. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  2249. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  2250. tempTime2 := time.Now().Unix()
  2251. tempTime6 := time.Unix(tempTime2, 0)
  2252. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  2253. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  2254. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  2255. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  2256. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  2257. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  2258. //memo := make(map[string]interface{})
  2259. //inputData := make(map[string]interface{}, 0)
  2260. //type MyData struct {
  2261. // Insutype string `json:"insutype"`
  2262. //}
  2263. //
  2264. // data := MyData{
  2265. // Insutype: his.Insutype,
  2266. //}
  2267. //
  2268. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  2269. var config []*models.HisXtDiagnoseConfig
  2270. for _, item := range diagnosis_ids {
  2271. id, _ := strconv.ParseInt(item, 10, 64)
  2272. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2273. config = append(config, &diagnosisConfig)
  2274. }
  2275. for index, subitem := range config {
  2276. if index == 0 {
  2277. var dia models.DiseInfo
  2278. dia.DiagType = "1"
  2279. dia.MaindiagFlag = "1"
  2280. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2281. dia.DiagCode = subitem.CountryCode
  2282. dia.DiagName = subitem.ClassName
  2283. dia.DiagDept = "肾内科"
  2284. dia.DiagDrNo = doctor.DoctorNumber
  2285. dia.DiagDrName = doctor.UserName
  2286. tempTime3 := time.Unix(item.PreTime, 0)
  2287. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2288. dia.DiagTime = timeFormatTwo
  2289. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2290. } else {
  2291. var dia models.DiseInfo
  2292. dia.DiagType = "1"
  2293. dia.MaindiagFlag = "0"
  2294. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2295. dia.DiagCode = subitem.CountryCode
  2296. dia.DiagName = subitem.ClassName
  2297. dia.DiagDept = "肾内科"
  2298. dia.DiagDrNo = doctor.DoctorNumber
  2299. dia.DiagDrName = doctor.UserName
  2300. tempTime3 := time.Unix(item.PreTime, 0)
  2301. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2302. dia.DiagTime = timeFormatTwo
  2303. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2304. }
  2305. }
  2306. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  2307. //saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  2308. }
  2309. }
  2310. func (c *HisApiController) GetCFYLJG002() {
  2311. admin_user_id, _ := c.GetInt64("admin_user_id")
  2312. id, _ := c.GetInt64("id")
  2313. admin_user_id = 3626
  2314. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2315. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2316. flow, _ := service.Getflow(id)
  2317. his, _ := service.GetHisPatientByNumber(flow.MID)
  2318. record_time := c.GetString("record_time")
  2319. patient_id, _ := c.GetInt64("patient_id")
  2320. //patient_id = 23834
  2321. //record_time = "2023-09-18"
  2322. timeLayout := "2006-01-02"
  2323. loc, _ := time.LoadLocation("Local")
  2324. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2325. if err != nil {
  2326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2327. return
  2328. }
  2329. recordDateTime := theTime.Unix()
  2330. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2331. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2332. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2333. dept, _ := service.GetDepartMentDetail(info.Departments)
  2334. inputData := make(map[string]interface{})
  2335. inputData["rxTraceCode"] = flow.RxTraceCode
  2336. inputData["hiRxno"] = flow.HiRxno
  2337. inputData["mdtrtId"] = flow.MID
  2338. inputData["patnName"] = his.PsnName
  2339. inputData["psnCertType"] = his.PsnCertType
  2340. inputData["certno"] = his.Certno
  2341. inputData["fixmedinsName"] = miConfig.OrgName
  2342. inputData["fixmedinsCode"] = miConfig.Code
  2343. inputData["drCode"] = doctor_info.DoctorNumber
  2344. inputData["prscDrName"] = doctor_info.UserName
  2345. inputData["pharDeptName"] = dept.Name
  2346. inputData["pharDeptCode"] = dept.Number
  2347. inputData["pharProfttlCodg"] = dept.Name
  2348. inputData["pharProfttlName"] = ""
  2349. inputData["pharCode"] = "HY440309002107"
  2350. inputData["pharCertType"] = "01"
  2351. inputData["pharCertno"] = "430482199408260023"
  2352. inputData["pharName"] = "彭斯遥"
  2353. inputData["pharPracCertNo"] = ""
  2354. tempTime2 := time.Unix(info.Ctime, 0)
  2355. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2356. inputData["pharChkTime"] = timeFormatTwo
  2357. bytesData, _ := json.Marshal(inputData)
  2358. fmt.Println(string(bytesData))
  2359. encoded := base64.StdEncoding.EncodeToString(bytesData)
  2360. //
  2361. //// 创建一个新的 PDF 文档
  2362. //pdf := gofpdf.New("P", "mm", "A4", "")
  2363. //
  2364. //// 添加一个页面
  2365. //pdf.AddPage()
  2366. //
  2367. //// 设置字体和字号
  2368. //pdf.SetFont("Arial", "B", 16)
  2369. //
  2370. //
  2371. //// 将签名后的信息添加到 PDF 文档中
  2372. //pdf.MultiCell(0, 10, string(bytesData), "", "L", false)
  2373. //
  2374. //// 保存 PDF 文件
  2375. //err = pdf.OutputFileAndClose("signed_data.pdf")
  2376. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  2377. if err != nil {
  2378. fmt.Println("Error reading PDF file:", err)
  2379. return
  2380. }
  2381. // 将 PDF 文件内容进行 Base64 编码
  2382. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  2383. fmt.Println(err)
  2384. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  2385. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  2386. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  2387. var res2 Result002
  2388. var respJSON2 map[string]interface{}
  2389. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2390. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2392. return
  2393. }
  2394. userJSONBytes2, _ := json.Marshal(respJSON2)
  2395. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2396. utils.ErrorLog("解析失败:%v", err)
  2397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2398. return
  2399. }
  2400. if res2.Infcode == 0 {
  2401. flow.Ctime = time.Now().Unix()
  2402. flow.SignDigest = res2.Output.SignDigest
  2403. flow.RxFile = res2.Output.RxFile
  2404. flow.MID = his.Number
  2405. flow.Status = 1
  2406. flow.DCode = doctor_info.DoctorNumber
  2407. flow.OriginalRxFile = rx_encoded
  2408. flow.OriginalValue = encoded
  2409. flow.SignCertDn = res2.Output.SignCertDn
  2410. flow.SignCertSn = res2.Output.SignCertSn
  2411. flow.Mtime = time.Now().Unix()
  2412. service.Saveflow(flow)
  2413. }
  2414. }
  2415. func (c *HisApiController) GetCFYLJG003() {
  2416. admin_user_id, _ := c.GetInt64("admin_user_id")
  2417. id, _ := c.GetInt64("id")
  2418. admin_user_id = 3626
  2419. //id = 3
  2420. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2421. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2422. flow, _ := service.Getflow(id)
  2423. his, _ := service.GetHisPatientByNumber(flow.MID)
  2424. record_time := c.GetString("record_time")
  2425. patient_id, _ := c.GetInt64("patient_id")
  2426. //patient_id = 23834
  2427. //record_time = "2023-09-18"
  2428. timeLayout := "2006-01-02"
  2429. loc, _ := time.LoadLocation("Local")
  2430. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2431. if err != nil {
  2432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2433. return
  2434. }
  2435. recordDateTime := theTime.Unix()
  2436. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2437. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2438. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2439. dept, _ := service.GetDepartMentDetail(info.Departments)
  2440. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  2441. var cFYLJG003 models.CFYLJG003
  2442. cFYLJG003.RxTraceCode = flow.RxTraceCode
  2443. cFYLJG003.HiRxno = flow.HiRxno
  2444. cFYLJG003.MdtrtID = flow.MID
  2445. cFYLJG003.PatnName = his.Name
  2446. cFYLJG003.Certno = his.Certno
  2447. cFYLJG003.FixmedinsName = miConfig.OrgName
  2448. cFYLJG003.FixmedinsCode = miConfig.Code
  2449. cFYLJG003.DrCode = doctor_info.DoctorNumber
  2450. cFYLJG003.PrscDrName = doctor_info.UserName
  2451. cFYLJG003.PharDeptName = dept.Name
  2452. cFYLJG003.PharDeptCode = dept.Number
  2453. cFYLJG003.PharCode = "HY440309002107"
  2454. cFYLJG003.PharCertType = "01"
  2455. cFYLJG003.PharCertno = "430482199408260023"
  2456. cFYLJG003.PharName = "彭斯遥"
  2457. cFYLJG003.PsnCertType = "01"
  2458. cFYLJG003.RxFile = flow.RxFile
  2459. cFYLJG003.SignDigest = flow.SignDigest
  2460. cFYLJG003.FixmedinsCode = miConfig.Code
  2461. cFYLJG003.PsnCertType = "01"
  2462. cFYLJG003.PharProfttlCodg = dept.Name
  2463. //inputData["pharProfttlCodg"] =dept.Name
  2464. tempTime2 := time.Unix(info.Ctime, 0)
  2465. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2466. cFYLJG003.PharChkTime = timeFormatTwo
  2467. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  2468. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  2469. }
  2470. func (c *HisApiController) GetCFYLJG004() {
  2471. admin_user_id, _ := c.GetInt64("admin_user_id")
  2472. id, _ := c.GetInt64("id")
  2473. admin_user_id = 3626
  2474. //id = 3
  2475. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2476. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2477. flow, _ := service.Getflow(id)
  2478. //his, _ := service.GetHisPatientByNumber(flow.MID)
  2479. record_time := c.GetString("record_time")
  2480. patient_id, _ := c.GetInt64("patient_id")
  2481. //patient_id = 23834
  2482. //record_time = "2023-09-18"
  2483. timeLayout := "2006-01-02"
  2484. loc, _ := time.LoadLocation("Local")
  2485. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2486. if err != nil {
  2487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2488. return
  2489. }
  2490. recordDateTime := theTime.Unix()
  2491. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2492. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2493. var cFYLJG004 models.CFYLJG004
  2494. cFYLJG004.HiRxno = flow.HiRxno
  2495. cFYLJG004.FixmedinsCode = miConfig.Code
  2496. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  2497. cFYLJG004.UndoDrCertType = "01"
  2498. cFYLJG004.UndoRea = "撤销处方"
  2499. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  2500. cFYLJG004.UndoDrName = doctor_info.UserName
  2501. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  2502. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  2503. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  2504. }
  2505. func (c *HisApiController) GetCFYLJG005() {
  2506. admin_user_id, _ := c.GetInt64("admin_user_id")
  2507. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2508. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2509. var cFYLJG005 models.CFYLJG005
  2510. id, _ := c.GetInt64("id")
  2511. patient_id, _ := c.GetInt64("patient_id")
  2512. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  2513. flow, _ := service.Getflow(id)
  2514. cFYLJG005.HiRxno = flow.HiRxno
  2515. cFYLJG005.MdtrtID = flow.MID
  2516. cFYLJG005.EcToken = ""
  2517. cFYLJG005.PsnName = patient.Name
  2518. cFYLJG005.PsnCertType = "01"
  2519. cFYLJG005.Certno = patient.IdCardNo
  2520. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  2521. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  2522. }
  2523. func (c *HisApiController) GetCFYLJG006() {
  2524. admin_user_id, _ := c.GetInt64("admin_user_id")
  2525. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2526. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2527. var cFYLJG006 models.CFYLJG006
  2528. id, _ := c.GetInt64("id")
  2529. patient_id, _ := c.GetInt64("patient_id")
  2530. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  2531. flow, _ := service.Getflow(id)
  2532. cFYLJG006.HiRxno = flow.HiRxno
  2533. cFYLJG006.MdtrtID = flow.MID
  2534. cFYLJG006.PsnName = patient.Name
  2535. cFYLJG006.PsnCertType = "01"
  2536. cFYLJG006.Certno = patient.IdCardNo
  2537. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  2538. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  2539. }
  2540. func (c *HisApiController) GetCFYLJG007() {
  2541. admin_user_id, _ := c.GetInt64("admin_user_id")
  2542. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2543. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2544. var cFYLJG007 models.CFYLJG007
  2545. id, _ := c.GetInt64("id")
  2546. patient_id, _ := c.GetInt64("patient_id")
  2547. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  2548. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  2549. flow, _ := service.Getflow(id)
  2550. his, _ := service.GetHisPatientByNumber(flow.MID)
  2551. cFYLJG007.HiRxno = flow.HiRxno
  2552. cFYLJG007.MdtrtID = flow.MID
  2553. cFYLJG007.PsnNo = his.PsnNo
  2554. cFYLJG007.PsnCertType = "01"
  2555. cFYLJG007.Certno = patient.IdCardNo
  2556. cFYLJG007.PsnName = patient.Name
  2557. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  2558. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  2559. }
  2560. func (c *HisApiController) GetCFYLJG008() {
  2561. admin_user_id, _ := c.GetInt64("admin_user_id")
  2562. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2563. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2564. var cFYLJG008 models.CFYLJG008
  2565. //id, _ := c.GetInt64("id")
  2566. patient_id, _ := c.GetInt64("patient_id")
  2567. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  2568. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  2569. //id = 3
  2570. //flow, _ := service.Getflow(id)
  2571. //his, _ := service.GetHisPatientByNumber(flow.MID)
  2572. //
  2573. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2574. //patient_id, _ := c.GetInt64("patient_id")
  2575. //his_patient_id, _ := c.GetInt64("his_patient_id")
  2576. record_time := c.GetString("record_time")
  2577. admin_user_id = 3626
  2578. patient_id = 19424
  2579. //his_patient_id = 263947
  2580. record_time = "2023-08-29"
  2581. timeLayout := "2006-01-02"
  2582. loc, _ := time.LoadLocation("Local")
  2583. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2584. if err != nil {
  2585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2586. return
  2587. }
  2588. recordDateTime := theTime.Unix()
  2589. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2590. cFYLJG008.FixmedinsName = ""
  2591. cFYLJG008.Lat = ""
  2592. cFYLJG008.Lng = ""
  2593. cFYLJG008.OrderType = "1"
  2594. cFYLJG008.PoolareaNo = ""
  2595. cFYLJG008.Lng = ""
  2596. cFYLJG008.PageNum = 1
  2597. cFYLJG008.PageSize = 10
  2598. var MPI models.MedinsProdInvChgDDTO
  2599. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  2600. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  2601. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  2602. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  2603. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  2604. }
  2605. func (c *HisApiController) GetBL4201A() {
  2606. order_id, _ := c.GetInt64("order_id")
  2607. admin_user_id, _ := c.GetInt64("admin_user_id")
  2608. order, _ := service.GetHisOrderByIDTwo(order_id)
  2609. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2610. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  2611. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  2612. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2613. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2614. department, _ := service.GetDepartMentDetail(his.Departments)
  2615. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  2616. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  2617. if order.ID == 0 {
  2618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2619. return
  2620. }
  2621. var struct4201A models.Struct4201A
  2622. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  2623. for _, items := range order_info {
  2624. memo := make(map[string]interface{})
  2625. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2626. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2627. fsiOPFLD.MedType = "14"
  2628. fsiOPFLD.BkkpSn = items.FeedetlSn
  2629. fsiOPFLD.FixmedinsCode = miConfig.Code
  2630. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2631. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2632. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2633. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2634. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2635. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2636. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2637. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2638. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2639. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2640. fsiOPFLD.BilgDeptName = department.Name
  2641. fsiOPFLD.BilgDeptCodg = department.Number
  2642. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2643. fsiOPFLD.BilgDrName = doctor.UserName
  2644. fsiOPFLD.MedChrgitmType = "09"
  2645. memo["hosp_appr_flag"] = "1"
  2646. memo["invoice_no"] = order.MdtrtId
  2647. memo["memo"] = "自费"
  2648. bytesData, _ := json.Marshal(memo)
  2649. fsiOPFLD.Memo = string(bytesData)
  2650. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2651. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2652. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2653. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2654. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2655. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2656. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2657. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2658. fsiOPFLD.BilgDeptName = department.Name
  2659. fsiOPFLD.BilgDeptCodg = department.Number
  2660. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2661. fsiOPFLD.BilgDrName = doctor.UserName
  2662. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2663. case 0:
  2664. break
  2665. case 1:
  2666. fsiOPFLD.MedChrgitmType = "14"
  2667. break
  2668. case 2:
  2669. fsiOPFLD.MedChrgitmType = "05"
  2670. break
  2671. case 3:
  2672. fsiOPFLD.MedChrgitmType = "03"
  2673. break
  2674. case 4:
  2675. fsiOPFLD.MedChrgitmType = "03"
  2676. break
  2677. case 5:
  2678. fsiOPFLD.MedChrgitmType = "08"
  2679. break
  2680. case 6:
  2681. fsiOPFLD.MedChrgitmType = "14"
  2682. break
  2683. case 7:
  2684. fsiOPFLD.MedChrgitmType = "14"
  2685. break
  2686. case 8:
  2687. fsiOPFLD.MedChrgitmType = "03"
  2688. break
  2689. case 9:
  2690. fsiOPFLD.MedChrgitmType = "14"
  2691. break
  2692. case 10:
  2693. fsiOPFLD.MedChrgitmType = "14"
  2694. break
  2695. case 11:
  2696. fsiOPFLD.MedChrgitmType = "06"
  2697. break
  2698. case 12:
  2699. fsiOPFLD.MedChrgitmType = "12"
  2700. break
  2701. case 13:
  2702. fsiOPFLD.MedChrgitmType = "01"
  2703. break
  2704. case 14:
  2705. fsiOPFLD.MedChrgitmType = "04"
  2706. break
  2707. case 15:
  2708. fsiOPFLD.MedChrgitmType = "14"
  2709. break
  2710. }
  2711. memo["hosp_appr_flag"] = "1"
  2712. memo["invoice_no"] = order.MdtrtId
  2713. memo["memo"] = "自费"
  2714. bytesData, _ := json.Marshal(memo)
  2715. fsiOPFLD.Memo = string(bytesData)
  2716. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2717. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  2718. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2719. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2720. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2721. fsiOPFLD.BilgDeptName = department.Name
  2722. fsiOPFLD.BilgDeptCodg = department.Number
  2723. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2724. fsiOPFLD.BilgDrName = doctor.UserName
  2725. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2726. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2727. fsiOPFLD.MedChrgitmType = "08"
  2728. memo["hosp_appr_flag"] = "1"
  2729. memo["invoice_no"] = order.MdtrtId
  2730. memo["memo"] = "自费"
  2731. bytesData, _ := json.Marshal(memo)
  2732. fsiOPFLD.Memo = string(bytesData)
  2733. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2734. }
  2735. }
  2736. }
  2737. for _, items := range order_info_two {
  2738. memo := make(map[string]interface{})
  2739. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2740. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2741. fsiOPFLD.MedType = "14"
  2742. fsiOPFLD.BkkpSn = items.FeedetlSn
  2743. fsiOPFLD.FixmedinsCode = miConfig.Code
  2744. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2745. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2746. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2747. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2748. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2749. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2750. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2751. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2752. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2753. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2754. fsiOPFLD.BilgDeptName = department.Name
  2755. fsiOPFLD.BilgDeptCodg = department.Number
  2756. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2757. fsiOPFLD.BilgDrName = doctor.UserName
  2758. fsiOPFLD.MedChrgitmType = "09"
  2759. memo["hosp_appr_flag"] = "1"
  2760. memo["invoice_no"] = order.MdtrtId
  2761. memo["memo"] = "自费"
  2762. bytesData, _ := json.Marshal(memo)
  2763. fsiOPFLD.Memo = string(bytesData)
  2764. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2765. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2766. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2767. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2768. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2769. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2770. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2771. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2772. fsiOPFLD.BilgDeptName = department.Name
  2773. fsiOPFLD.BilgDeptCodg = department.Number
  2774. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2775. fsiOPFLD.BilgDrName = doctor.UserName
  2776. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2777. case 0:
  2778. break
  2779. case 1:
  2780. fsiOPFLD.MedChrgitmType = "14"
  2781. break
  2782. case 2:
  2783. fsiOPFLD.MedChrgitmType = "05"
  2784. break
  2785. case 3:
  2786. fsiOPFLD.MedChrgitmType = "03"
  2787. break
  2788. case 4:
  2789. fsiOPFLD.MedChrgitmType = "03"
  2790. break
  2791. case 5:
  2792. fsiOPFLD.MedChrgitmType = "08"
  2793. break
  2794. case 6:
  2795. fsiOPFLD.MedChrgitmType = "14"
  2796. break
  2797. case 7:
  2798. fsiOPFLD.MedChrgitmType = "14"
  2799. break
  2800. case 8:
  2801. fsiOPFLD.MedChrgitmType = "03"
  2802. break
  2803. case 9:
  2804. fsiOPFLD.MedChrgitmType = "14"
  2805. break
  2806. case 10:
  2807. fsiOPFLD.MedChrgitmType = "14"
  2808. break
  2809. case 11:
  2810. fsiOPFLD.MedChrgitmType = "06"
  2811. break
  2812. case 12:
  2813. fsiOPFLD.MedChrgitmType = "12"
  2814. break
  2815. case 13:
  2816. fsiOPFLD.MedChrgitmType = "01"
  2817. break
  2818. case 14:
  2819. fsiOPFLD.MedChrgitmType = "04"
  2820. break
  2821. case 15:
  2822. fsiOPFLD.MedChrgitmType = "14"
  2823. break
  2824. }
  2825. memo["hosp_appr_flag"] = "1"
  2826. memo["invoice_no"] = order.MdtrtId
  2827. memo["memo"] = "自费"
  2828. bytesData, _ := json.Marshal(memo)
  2829. fsiOPFLD.Memo = string(bytesData)
  2830. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2831. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  2832. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2833. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2834. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2835. fsiOPFLD.BilgDeptName = department.Name
  2836. fsiOPFLD.BilgDeptCodg = department.Number
  2837. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2838. fsiOPFLD.BilgDrName = doctor.UserName
  2839. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2840. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2841. fsiOPFLD.MedChrgitmType = "08"
  2842. memo["hosp_appr_flag"] = "1"
  2843. memo["invoice_no"] = order.MdtrtId
  2844. memo["memo"] = "自费"
  2845. bytesData, _ := json.Marshal(memo)
  2846. fsiOPFLD.Memo = string(bytesData)
  2847. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2848. }
  2849. }
  2850. }
  2851. fmt.Println(fsiOPFLDs)
  2852. struct4201A.Fopfd = fsiOPFLDs
  2853. fmt.Println(struct4201A.Fopfd)
  2854. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  2855. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  2856. var res2 ResultSix
  2857. var respJSON2 map[string]interface{}
  2858. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2859. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2861. return
  2862. }
  2863. userJSONBytes2, _ := json.Marshal(respJSON2)
  2864. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2865. utils.ErrorLog("解析失败:%v", err)
  2866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2867. return
  2868. }
  2869. if res2.Infcode != 0 {
  2870. c.ServeSuccessJSON(map[string]interface{}{
  2871. "failed_code": -10,
  2872. "msg": res2.ErrMsg,
  2873. })
  2874. return
  2875. } else {
  2876. order.IsUploadOrderInfo = 1
  2877. service.UpdateOrder(order)
  2878. c.ServeSuccessJSON(map[string]interface{}{
  2879. "msg": "上传成功",
  2880. })
  2881. }
  2882. }
  2883. func (c *HisApiController) Get2505() {
  2884. admin_user_id, _ := c.GetInt64("admin_user_id")
  2885. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  2886. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2887. service.Gdyb2505("45000000000008100145868008", curRoles.UserName, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "2024-01-12 09:00:00", "2026-12-31 23:00:00", admin_user_id)
  2888. }
  2889. func (c *HisApiController) Get4201A() {
  2890. order_id, _ := c.GetInt64("order_id")
  2891. admin_user_id, _ := c.GetInt64("admin_user_id")
  2892. order, _ := service.GetHisOrderByIDTwo(order_id)
  2893. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2894. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  2895. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  2896. //order_info = append(order_info, order_info_two...)
  2897. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2898. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2899. department, _ := service.GetDepartMentDetail(his.Departments)
  2900. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  2901. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  2902. if order.ID == 0 {
  2903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2904. return
  2905. }
  2906. var struct4201A models.Struct4201A
  2907. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  2908. for _, items := range order_info {
  2909. memo := make(map[string]interface{})
  2910. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2911. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2912. fsiOPFLD.MedType = "14"
  2913. fsiOPFLD.BkkpSn = items.FeedetlSn
  2914. fsiOPFLD.FixmedinsCode = miConfig.Code
  2915. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2916. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2917. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2918. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2919. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2920. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2921. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2922. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2923. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2924. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2925. fsiOPFLD.BilgDeptName = department.Name
  2926. fsiOPFLD.BilgDeptCodg = department.Number
  2927. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2928. fsiOPFLD.BilgDrName = doctor.UserName
  2929. fsiOPFLD.MedChrgitmType = "09"
  2930. memo["hosp_appr_flag"] = "1"
  2931. memo["invoice_no"] = order.MdtrtId
  2932. memo["memo"] = "自费"
  2933. bytesData, _ := json.Marshal(memo)
  2934. fsiOPFLD.Memo = string(bytesData)
  2935. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2936. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2937. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2938. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2939. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2940. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2941. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2942. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2943. fsiOPFLD.BilgDeptName = department.Name
  2944. fsiOPFLD.BilgDeptCodg = department.Number
  2945. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2946. fsiOPFLD.BilgDrName = doctor.UserName
  2947. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2948. case 0:
  2949. break
  2950. case 1:
  2951. fsiOPFLD.MedChrgitmType = "14"
  2952. break
  2953. case 2:
  2954. fsiOPFLD.MedChrgitmType = "05"
  2955. break
  2956. case 3:
  2957. fsiOPFLD.MedChrgitmType = "03"
  2958. break
  2959. case 4:
  2960. fsiOPFLD.MedChrgitmType = "03"
  2961. break
  2962. case 5:
  2963. fsiOPFLD.MedChrgitmType = "08"
  2964. break
  2965. case 6:
  2966. fsiOPFLD.MedChrgitmType = "14"
  2967. break
  2968. case 7:
  2969. fsiOPFLD.MedChrgitmType = "14"
  2970. break
  2971. case 8:
  2972. fsiOPFLD.MedChrgitmType = "03"
  2973. break
  2974. case 9:
  2975. fsiOPFLD.MedChrgitmType = "14"
  2976. break
  2977. case 10:
  2978. fsiOPFLD.MedChrgitmType = "14"
  2979. break
  2980. case 11:
  2981. fsiOPFLD.MedChrgitmType = "06"
  2982. break
  2983. case 12:
  2984. fsiOPFLD.MedChrgitmType = "12"
  2985. break
  2986. case 13:
  2987. fsiOPFLD.MedChrgitmType = "01"
  2988. break
  2989. case 14:
  2990. fsiOPFLD.MedChrgitmType = "04"
  2991. break
  2992. case 15:
  2993. fsiOPFLD.MedChrgitmType = "14"
  2994. break
  2995. }
  2996. memo["hosp_appr_flag"] = "1"
  2997. memo["invoice_no"] = order.MdtrtId
  2998. memo["memo"] = "自费"
  2999. bytesData, _ := json.Marshal(memo)
  3000. fsiOPFLD.Memo = string(bytesData)
  3001. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3002. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3003. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3004. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3005. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3006. fsiOPFLD.BilgDeptName = department.Name
  3007. fsiOPFLD.BilgDeptCodg = department.Number
  3008. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3009. fsiOPFLD.BilgDrName = doctor.UserName
  3010. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3011. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3012. fsiOPFLD.MedChrgitmType = "08"
  3013. memo["hosp_appr_flag"] = "1"
  3014. memo["invoice_no"] = order.MdtrtId
  3015. memo["memo"] = "自费"
  3016. bytesData, _ := json.Marshal(memo)
  3017. fsiOPFLD.Memo = string(bytesData)
  3018. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3019. }
  3020. }
  3021. }
  3022. for _, items := range order_info_two {
  3023. memo := make(map[string]interface{})
  3024. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3025. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3026. fsiOPFLD.MedType = "14"
  3027. fsiOPFLD.BkkpSn = items.FeedetlSn
  3028. fsiOPFLD.FixmedinsCode = miConfig.Code
  3029. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3030. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3031. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3032. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3033. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3034. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3035. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3036. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3037. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3038. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3039. fsiOPFLD.BilgDeptName = department.Name
  3040. fsiOPFLD.BilgDeptCodg = department.Number
  3041. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3042. fsiOPFLD.BilgDrName = doctor.UserName
  3043. fsiOPFLD.MedChrgitmType = "09"
  3044. memo["hosp_appr_flag"] = "1"
  3045. memo["invoice_no"] = order.MdtrtId
  3046. memo["memo"] = "自费"
  3047. bytesData, _ := json.Marshal(memo)
  3048. fsiOPFLD.Memo = string(bytesData)
  3049. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3050. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3051. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3052. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3053. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3054. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3055. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3056. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3057. fsiOPFLD.BilgDeptName = department.Name
  3058. fsiOPFLD.BilgDeptCodg = department.Number
  3059. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3060. fsiOPFLD.BilgDrName = doctor.UserName
  3061. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3062. case 0:
  3063. break
  3064. case 1:
  3065. fsiOPFLD.MedChrgitmType = "14"
  3066. break
  3067. case 2:
  3068. fsiOPFLD.MedChrgitmType = "05"
  3069. break
  3070. case 3:
  3071. fsiOPFLD.MedChrgitmType = "03"
  3072. break
  3073. case 4:
  3074. fsiOPFLD.MedChrgitmType = "03"
  3075. break
  3076. case 5:
  3077. fsiOPFLD.MedChrgitmType = "08"
  3078. break
  3079. case 6:
  3080. fsiOPFLD.MedChrgitmType = "14"
  3081. break
  3082. case 7:
  3083. fsiOPFLD.MedChrgitmType = "14"
  3084. break
  3085. case 8:
  3086. fsiOPFLD.MedChrgitmType = "03"
  3087. break
  3088. case 9:
  3089. fsiOPFLD.MedChrgitmType = "14"
  3090. break
  3091. case 10:
  3092. fsiOPFLD.MedChrgitmType = "14"
  3093. break
  3094. case 11:
  3095. fsiOPFLD.MedChrgitmType = "06"
  3096. break
  3097. case 12:
  3098. fsiOPFLD.MedChrgitmType = "12"
  3099. break
  3100. case 13:
  3101. fsiOPFLD.MedChrgitmType = "01"
  3102. break
  3103. case 14:
  3104. fsiOPFLD.MedChrgitmType = "04"
  3105. break
  3106. case 15:
  3107. fsiOPFLD.MedChrgitmType = "14"
  3108. break
  3109. }
  3110. memo["hosp_appr_flag"] = "1"
  3111. memo["invoice_no"] = order.MdtrtId
  3112. memo["memo"] = "自费"
  3113. bytesData, _ := json.Marshal(memo)
  3114. fsiOPFLD.Memo = string(bytesData)
  3115. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3116. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3117. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3118. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3119. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3120. fsiOPFLD.BilgDeptName = department.Name
  3121. fsiOPFLD.BilgDeptCodg = department.Number
  3122. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3123. fsiOPFLD.BilgDrName = doctor.UserName
  3124. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3125. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3126. fsiOPFLD.MedChrgitmType = "08"
  3127. memo["hosp_appr_flag"] = "1"
  3128. memo["invoice_no"] = order.MdtrtId
  3129. memo["memo"] = "自费"
  3130. bytesData, _ := json.Marshal(memo)
  3131. fsiOPFLD.Memo = string(bytesData)
  3132. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3133. }
  3134. }
  3135. }
  3136. fmt.Println(fsiOPFLDs)
  3137. struct4201A.Fopfd = fsiOPFLDs
  3138. fmt.Println(struct4201A.Fopfd)
  3139. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  3140. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  3141. var res2 ResultSix
  3142. var respJSON2 map[string]interface{}
  3143. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3144. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3146. return
  3147. }
  3148. userJSONBytes2, _ := json.Marshal(respJSON2)
  3149. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3150. utils.ErrorLog("解析失败:%v", err)
  3151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3152. return
  3153. }
  3154. if res2.Infcode != 0 {
  3155. c.ServeSuccessJSON(map[string]interface{}{
  3156. "failed_code": -10,
  3157. "msg": res2.ErrMsg,
  3158. })
  3159. return
  3160. } else {
  3161. order.IsUploadOrderInfo = 1
  3162. service.UpdateOrder(order)
  3163. c.ServeSuccessJSON(map[string]interface{}{
  3164. "msg": "上传成功",
  3165. })
  3166. }
  3167. }
  3168. func (c *HisApiController) Get4202() {
  3169. order_id, _ := c.GetInt64("order_id")
  3170. admin_user_id, _ := c.GetInt64("admin_user_id")
  3171. order, _ := service.GetHisOrderByIDTwo(order_id)
  3172. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3173. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3174. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3175. if order.ID == 0 {
  3176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3177. return
  3178. }
  3179. var struct4202 models.Struct4202
  3180. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  3181. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  3182. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  3183. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  3184. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  3185. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  3186. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  3187. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  3188. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  3189. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  3190. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3191. var config []*models.HisXtDiagnoseConfig
  3192. for _, item := range diagnosis_ids {
  3193. id, _ := strconv.ParseInt(item, 10, 64)
  3194. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3195. config = append(config, &diagnosisConfig)
  3196. }
  3197. var tempDiaginfos []models.OwnPayPatnDiagListD
  3198. for index, item := range config {
  3199. if index == 0 {
  3200. var tempDiaginfo models.OwnPayPatnDiagListD
  3201. tempDiaginfo.InoutDiagType = "1"
  3202. tempDiaginfo.DiagCode = item.CountryCode
  3203. tempDiaginfo.DiagName = item.CountryContentName
  3204. tempDiaginfo.DiagType = "1"
  3205. tempDiaginfo.DiagSrtNo = "1"
  3206. tempDiaginfo.MaindiagFlag = "1"
  3207. tempDiaginfo.ValiFlag = "1"
  3208. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3209. } else {
  3210. var tempDiaginfo models.OwnPayPatnDiagListD
  3211. tempDiaginfo.DiagCode = item.CountryCode
  3212. tempDiaginfo.DiagName = item.CountryContentName
  3213. tempDiaginfo.DiagType = "2"
  3214. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  3215. tempDiaginfo.MaindiagFlag = "0"
  3216. tempDiaginfo.ValiFlag = "1"
  3217. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3218. }
  3219. }
  3220. struct4202.ODiagListD = tempDiaginfos
  3221. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  3222. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  3223. var res2 ResultSix
  3224. var respJSON2 map[string]interface{}
  3225. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3226. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3228. return
  3229. }
  3230. userJSONBytes2, _ := json.Marshal(respJSON2)
  3231. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3232. utils.ErrorLog("解析失败:%v", err)
  3233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3234. return
  3235. }
  3236. if res2.Infcode != 0 {
  3237. c.ServeSuccessJSON(map[string]interface{}{
  3238. "failed_code": -10,
  3239. "msg": res2.ErrMsg,
  3240. })
  3241. return
  3242. } else {
  3243. order.IsUploadDiagnose = 1
  3244. service.UpdateOrder(order)
  3245. c.ServeSuccessJSON(map[string]interface{}{
  3246. "msg": "上传成功",
  3247. })
  3248. }
  3249. }
  3250. func (c *HisApiController) Get4203() {
  3251. admin_user_id, _ := c.GetInt64("admin_user_id")
  3252. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3253. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3254. order_id, _ := c.GetInt64("order_id")
  3255. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  3256. number := ""
  3257. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3258. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3259. if his.ID == 0 {
  3260. number = hospital.Number
  3261. } else {
  3262. number = his.Number
  3263. }
  3264. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  3265. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  3266. var res2 ResultSix
  3267. var respJSON2 map[string]interface{}
  3268. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3271. return
  3272. }
  3273. userJSONBytes2, _ := json.Marshal(respJSON2)
  3274. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3275. utils.ErrorLog("解析失败:%v", err)
  3276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3277. return
  3278. }
  3279. if res2.Infcode != 0 {
  3280. c.ServeSuccessJSON(map[string]interface{}{
  3281. "failed_code": -10,
  3282. "msg": res2.ErrMsg,
  3283. })
  3284. return
  3285. } else {
  3286. order.IsUploadSuccess = 1
  3287. service.UpdateOrderTwo(order)
  3288. c.ServeSuccessJSON(map[string]interface{}{
  3289. "msg": "上传成功",
  3290. })
  3291. }
  3292. }
  3293. func (c *HisApiController) Get4205() {
  3294. order_id, _ := c.GetInt64("order_id")
  3295. admin_user_id, _ := c.GetInt64("admin_user_id")
  3296. fapiao_code := c.GetString("fapiao_code")
  3297. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  3298. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3299. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3300. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3301. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  3302. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  3303. //order_info = append(order_info, order_info_two...)
  3304. department, _ := service.GetDepartMentDetail(his.Departments)
  3305. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3306. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3307. if order.ID == 0 {
  3308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3309. return
  3310. }
  3311. var struct4201A models.Struct4201A
  3312. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3313. for _, items := range order_info {
  3314. memo := make(map[string]interface{})
  3315. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3316. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3317. fsiOPFLD.MedType = pre.MedType
  3318. fsiOPFLD.FixmedinsCode = miConfig.Code
  3319. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3320. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3321. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3322. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3323. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3324. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3325. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3326. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  3327. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3328. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3329. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3330. fsiOPFLD.BilgDeptName = department.Name
  3331. fsiOPFLD.BilgDeptCodg = department.Number
  3332. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3333. fsiOPFLD.BilgDrName = doctor.UserName
  3334. fsiOPFLD.MedChrgitmType = "09"
  3335. memo["hosp_appr_flag"] = "1"
  3336. memo["invoice_no"] = fapiao_code
  3337. memo["memo"] = "自费"
  3338. bytesData, _ := json.Marshal(memo)
  3339. fsiOPFLD.Memo = string(bytesData)
  3340. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3341. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3342. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  3343. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3344. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3345. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3346. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3347. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3348. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3349. fsiOPFLD.BilgDeptName = department.Name
  3350. fsiOPFLD.BilgDeptCodg = department.Number
  3351. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3352. fsiOPFLD.BilgDrName = doctor.UserName
  3353. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3354. case 0:
  3355. break
  3356. case 1:
  3357. fsiOPFLD.MedChrgitmType = "14"
  3358. break
  3359. case 2:
  3360. fsiOPFLD.MedChrgitmType = "05"
  3361. break
  3362. case 3:
  3363. fsiOPFLD.MedChrgitmType = "03"
  3364. break
  3365. case 4:
  3366. fsiOPFLD.MedChrgitmType = "03"
  3367. break
  3368. case 5:
  3369. fsiOPFLD.MedChrgitmType = "08"
  3370. break
  3371. case 6:
  3372. fsiOPFLD.MedChrgitmType = "14"
  3373. break
  3374. case 7:
  3375. fsiOPFLD.MedChrgitmType = "14"
  3376. break
  3377. case 8:
  3378. fsiOPFLD.MedChrgitmType = "03"
  3379. break
  3380. case 9:
  3381. fsiOPFLD.MedChrgitmType = "14"
  3382. break
  3383. case 10:
  3384. fsiOPFLD.MedChrgitmType = "14"
  3385. break
  3386. case 11:
  3387. fsiOPFLD.MedChrgitmType = "06"
  3388. break
  3389. case 12:
  3390. fsiOPFLD.MedChrgitmType = "12"
  3391. break
  3392. case 13:
  3393. fsiOPFLD.MedChrgitmType = "01"
  3394. break
  3395. case 14:
  3396. fsiOPFLD.MedChrgitmType = "04"
  3397. break
  3398. case 15:
  3399. fsiOPFLD.MedChrgitmType = "14"
  3400. break
  3401. }
  3402. memo["hosp_appr_flag"] = "1"
  3403. memo["invoice_no"] = fapiao_code
  3404. memo["memo"] = "自费"
  3405. bytesData, _ := json.Marshal(memo)
  3406. fsiOPFLD.Memo = string(bytesData)
  3407. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3408. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3409. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3410. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3411. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3412. fsiOPFLD.BilgDeptName = department.Name
  3413. fsiOPFLD.BilgDeptCodg = department.Number
  3414. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3415. fsiOPFLD.BilgDrName = doctor.UserName
  3416. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3417. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3418. fsiOPFLD.MedChrgitmType = "08"
  3419. memo["hosp_appr_flag"] = "1"
  3420. memo["invoice_no"] = fapiao_code
  3421. memo["memo"] = "自费"
  3422. bytesData, _ := json.Marshal(memo)
  3423. fsiOPFLD.Memo = string(bytesData)
  3424. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3425. }
  3426. }
  3427. }
  3428. for _, items := range order_info_two {
  3429. memo := make(map[string]interface{})
  3430. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3431. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3432. fsiOPFLD.MedType = pre.MedType
  3433. fsiOPFLD.BkkpSn = items.FeedetlSn
  3434. fsiOPFLD.FixmedinsCode = miConfig.Code
  3435. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3436. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3437. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3438. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3439. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3440. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3441. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3442. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3443. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3444. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3445. fsiOPFLD.BilgDeptName = department.Name
  3446. fsiOPFLD.BilgDeptCodg = department.Number
  3447. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3448. fsiOPFLD.BilgDrName = doctor.UserName
  3449. fsiOPFLD.MedChrgitmType = "09"
  3450. memo["hosp_appr_flag"] = "1"
  3451. memo["invoice_no"] = fapiao_code
  3452. memo["memo"] = "自费"
  3453. bytesData, _ := json.Marshal(memo)
  3454. fsiOPFLD.Memo = string(bytesData)
  3455. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3456. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3457. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  3458. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3459. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3460. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3461. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3462. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3463. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3464. fsiOPFLD.BilgDeptName = department.Name
  3465. fsiOPFLD.BilgDeptCodg = department.Number
  3466. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3467. fsiOPFLD.BilgDrName = doctor.UserName
  3468. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3469. case 0:
  3470. break
  3471. case 1:
  3472. fsiOPFLD.MedChrgitmType = "14"
  3473. break
  3474. case 2:
  3475. fsiOPFLD.MedChrgitmType = "05"
  3476. break
  3477. case 3:
  3478. fsiOPFLD.MedChrgitmType = "03"
  3479. break
  3480. case 4:
  3481. fsiOPFLD.MedChrgitmType = "03"
  3482. break
  3483. case 5:
  3484. fsiOPFLD.MedChrgitmType = "08"
  3485. break
  3486. case 6:
  3487. fsiOPFLD.MedChrgitmType = "14"
  3488. break
  3489. case 7:
  3490. fsiOPFLD.MedChrgitmType = "14"
  3491. break
  3492. case 8:
  3493. fsiOPFLD.MedChrgitmType = "03"
  3494. break
  3495. case 9:
  3496. fsiOPFLD.MedChrgitmType = "14"
  3497. break
  3498. case 10:
  3499. fsiOPFLD.MedChrgitmType = "14"
  3500. break
  3501. case 11:
  3502. fsiOPFLD.MedChrgitmType = "06"
  3503. break
  3504. case 12:
  3505. fsiOPFLD.MedChrgitmType = "12"
  3506. break
  3507. case 13:
  3508. fsiOPFLD.MedChrgitmType = "01"
  3509. break
  3510. case 14:
  3511. fsiOPFLD.MedChrgitmType = "04"
  3512. break
  3513. case 15:
  3514. fsiOPFLD.MedChrgitmType = "14"
  3515. break
  3516. }
  3517. memo["hosp_appr_flag"] = "1"
  3518. memo["invoice_no"] = fapiao_code
  3519. memo["memo"] = "自费"
  3520. bytesData, _ := json.Marshal(memo)
  3521. fsiOPFLD.Memo = string(bytesData)
  3522. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3523. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3524. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3525. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3526. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3527. fsiOPFLD.BilgDeptName = department.Name
  3528. fsiOPFLD.BilgDeptCodg = department.Number
  3529. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3530. fsiOPFLD.BilgDrName = doctor.UserName
  3531. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3532. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3533. fsiOPFLD.MedChrgitmType = "08"
  3534. memo["hosp_appr_flag"] = "1"
  3535. memo["invoice_no"] = fapiao_code
  3536. memo["memo"] = "自费"
  3537. bytesData, _ := json.Marshal(memo)
  3538. fsiOPFLD.Memo = string(bytesData)
  3539. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3540. }
  3541. }
  3542. }
  3543. fmt.Println(fsiOPFLDs)
  3544. struct4201A.Fopfd = fsiOPFLDs
  3545. fmt.Println(struct4201A.Fopfd)
  3546. var struct4202 models.Struct4202
  3547. timeLayout := "2006-01-02 15:04:05"
  3548. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  3549. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  3550. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  3551. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  3552. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  3553. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  3554. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  3555. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  3556. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  3557. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  3558. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  3559. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3560. var config []*models.HisXtDiagnoseConfig
  3561. for _, item := range diagnosis_ids {
  3562. id, _ := strconv.ParseInt(item, 10, 64)
  3563. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3564. config = append(config, &diagnosisConfig)
  3565. }
  3566. var tempDiaginfos []models.OwnPayPatnDiagListD
  3567. for index, item := range config {
  3568. if index == 0 {
  3569. var tempDiaginfo models.OwnPayPatnDiagListD
  3570. tempDiaginfo.InoutDiagType = "1"
  3571. tempDiaginfo.DiagCode = item.CountryCode
  3572. tempDiaginfo.DiagName = item.CountryContentName
  3573. tempDiaginfo.DiagType = "1"
  3574. tempDiaginfo.DiagSrtNo = "1"
  3575. tempDiaginfo.MaindiagFlag = "1"
  3576. tempDiaginfo.ValiFlag = "1"
  3577. tempDiaginfo.DiagDrName = doctor.UserName
  3578. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  3579. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  3580. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3581. } else {
  3582. var tempDiaginfo models.OwnPayPatnDiagListD
  3583. tempDiaginfo.DiagCode = item.CountryCode
  3584. tempDiaginfo.DiagName = item.CountryContentName
  3585. tempDiaginfo.DiagType = "2"
  3586. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  3587. tempDiaginfo.MaindiagFlag = "0"
  3588. tempDiaginfo.ValiFlag = "1"
  3589. tempDiaginfo.DiagDrName = doctor.UserName
  3590. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  3591. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  3592. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3593. }
  3594. }
  3595. struct4202.ODiagListD = tempDiaginfos
  3596. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  3597. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  3598. var res2 ResultSix
  3599. var respJSON2 map[string]interface{}
  3600. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3601. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3603. return
  3604. }
  3605. userJSONBytes2, _ := json.Marshal(respJSON2)
  3606. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3607. utils.ErrorLog("解析失败:%v", err)
  3608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3609. return
  3610. }
  3611. if res2.Infcode != 0 {
  3612. c.ServeSuccessJSON(map[string]interface{}{
  3613. "failed_code": -10,
  3614. "msg": res2.ErrMsg,
  3615. })
  3616. return
  3617. } else {
  3618. order.IsUploadDiagnose = 1
  3619. order.IsUploadOrderInfo = 1
  3620. service.UpdateOrderTwo(order)
  3621. c.ServeSuccessJSON(map[string]interface{}{
  3622. "msg": "上传成功",
  3623. })
  3624. }
  3625. }
  3626. func (c *HisApiController) Get4207() {
  3627. admin_user_id, _ := c.GetInt64("admin_user_id")
  3628. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3629. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3630. order_id, _ := c.GetInt64("order_id")
  3631. order, _ := service.GetHisOrderByIDTwo(order_id)
  3632. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3633. var struct4207 models.Struct4207
  3634. struct4207.PageNum = "1"
  3635. struct4207.PageSize = "1000"
  3636. struct4207.FixmedinsCode = miConfig.Code
  3637. struct4207.FixmedinsMdtrtID = order.Number
  3638. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  3639. saveLog(result, requestLog, "4207", "查询")
  3640. var res2 ResultSix
  3641. var respJSON2 map[string]interface{}
  3642. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3643. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3645. return
  3646. }
  3647. userJSONBytes2, _ := json.Marshal(respJSON2)
  3648. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3649. utils.ErrorLog("解析失败:%v", err)
  3650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3651. return
  3652. }
  3653. if res2.Infcode != 0 {
  3654. c.ServeSuccessJSON(map[string]interface{}{
  3655. "failed_code": -10,
  3656. "msg": res2.ErrMsg,
  3657. })
  3658. return
  3659. } else {
  3660. c.ServeSuccessJSON(map[string]interface{}{
  3661. "msg": "查询成功",
  3662. })
  3663. }
  3664. }
  3665. func (c *HisApiController) Get4208() {
  3666. admin_user_id, _ := c.GetInt64("admin_user_id")
  3667. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3668. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3669. order_id, _ := c.GetInt64("order_id")
  3670. order, _ := service.GetHisOrderByIDTwo(order_id)
  3671. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3672. var struct4208 models.Struct4208
  3673. struct4208.PageNum = "1"
  3674. struct4208.PageSize = "1000"
  3675. struct4208.PsnCertType = "01"
  3676. struct4208.Certno = his.Certno
  3677. struct4208.MedType = order.MedType
  3678. struct4208.PsnName = his.Name
  3679. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  3680. saveLog(result, requestLog, "4208", "查询")
  3681. var res2 ResultSix
  3682. var respJSON2 map[string]interface{}
  3683. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3684. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3686. return
  3687. }
  3688. userJSONBytes2, _ := json.Marshal(respJSON2)
  3689. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3690. utils.ErrorLog("解析失败:%v", err)
  3691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3692. return
  3693. }
  3694. if res2.Infcode != 0 {
  3695. c.ServeSuccessJSON(map[string]interface{}{
  3696. "failed_code": -10,
  3697. "msg": res2.ErrMsg,
  3698. })
  3699. return
  3700. } else {
  3701. c.ServeSuccessJSON(map[string]interface{}{
  3702. "msg": "查询成功",
  3703. })
  3704. }
  3705. }
  3706. func (c *HisApiController) Get4209() {
  3707. admin_user_id, _ := c.GetInt64("admin_user_id")
  3708. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3709. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3710. order_id, _ := c.GetInt64("order_id")
  3711. order, _ := service.GetHisOrderByIDTwo(order_id)
  3712. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3713. var struct4209 models.Struct4209
  3714. struct4209.FixmedinsMdtrtID = order.Number
  3715. struct4209.FixmedinsCode = miConfig.Code
  3716. struct4209.PageSize = "1000"
  3717. struct4209.PageNum = "1"
  3718. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  3719. saveLog(result, requestLog, "4209", "查询")
  3720. var res2 ResultSix
  3721. var respJSON2 map[string]interface{}
  3722. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3723. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3725. return
  3726. }
  3727. userJSONBytes2, _ := json.Marshal(respJSON2)
  3728. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3729. utils.ErrorLog("解析失败:%v", err)
  3730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3731. return
  3732. }
  3733. if res2.Infcode != 0 {
  3734. c.ServeSuccessJSON(map[string]interface{}{
  3735. "failed_code": -10,
  3736. "msg": res2.ErrMsg,
  3737. })
  3738. return
  3739. } else {
  3740. c.ServeSuccessJSON(map[string]interface{}{
  3741. "msg": "查询成功",
  3742. })
  3743. }
  3744. }
  3745. type Result3101 struct {
  3746. Infcode string `json:"infcode"`
  3747. InfRefmsgid string `json:"inf_refmsgid"`
  3748. RefmsgTime string `json:"refmsg_time"`
  3749. RespondTime string `json:"respond_time"`
  3750. Enctype string `json:"enctype"`
  3751. Signtype string `json:"signtype"`
  3752. ErrMsg string `json:"err_msg"`
  3753. Output struct {
  3754. Result []struct {
  3755. JudgeResultDetailDtos []struct {
  3756. VolaItemType string `json:"vola_item_type"`
  3757. MdtrtID string `json:"mdtrt_id"`
  3758. JrdID string `json:"jrd_id"`
  3759. PatnID string `json:"patn_id"`
  3760. RxID string `json:"rx_id"`
  3761. VolaAmt interface{} `json:"vola_amt"`
  3762. } `json:"judge_result_detail_dtos"`
  3763. RuleID string `json:"rule_id"`
  3764. VolaEvid string `json:"vola_evid"`
  3765. MdtrtID string `json:"mdtrt_id"`
  3766. RuleName string `json:"rule_name"`
  3767. VolaAmtStas string `json:"vola_amt_stas"`
  3768. JrID string `json:"jr_id"`
  3769. PatnID string `json:"patn_id"`
  3770. SevDeg string `json:"sev_deg"`
  3771. VolaAmt float64 `json:"vola_amt"`
  3772. VolaBhvrType string `json:"vola_bhvr_type"`
  3773. VolaCont string `json:"vola_cont"`
  3774. } `json:"result"`
  3775. } `json:"output"`
  3776. }
  3777. type Resultgd3101 struct {
  3778. Infcode int64 `json:"infcode"`
  3779. InfRefmsgid string `json:"inf_refmsgid"`
  3780. RefmsgTime string `json:"refmsg_time"`
  3781. RespondTime string `json:"respond_time"`
  3782. Enctype string `json:"enctype"`
  3783. Signtype string `json:"signtype"`
  3784. ErrMsg string `json:"err_msg"`
  3785. Output struct {
  3786. Result []struct {
  3787. JudgeResultDetailDtos []struct {
  3788. VolaItemType string `json:"vola_item_type"`
  3789. MdtrtID string `json:"mdtrt_id"`
  3790. JrdID string `json:"jrd_id"`
  3791. PatnID string `json:"patn_id"`
  3792. RxID string `json:"rx_id"`
  3793. VolaAmt interface{} `json:"vola_amt"`
  3794. } `json:"judge_result_detail_dtos"`
  3795. RuleID string `json:"rule_id"`
  3796. VolaEvid string `json:"vola_evid"`
  3797. MdtrtID string `json:"mdtrt_id"`
  3798. RuleName string `json:"rule_name"`
  3799. VolaAmtStas string `json:"vola_amt_stas"`
  3800. JrID string `json:"jr_id"`
  3801. PatnID string `json:"patn_id"`
  3802. SevDeg string `json:"sev_deg"`
  3803. VolaAmt float64 `json:"vola_amt"`
  3804. VolaBhvrType string `json:"vola_bhvr_type"`
  3805. VolaCont string `json:"vola_cont"`
  3806. } `json:"result"`
  3807. } `json:"output"`
  3808. }
  3809. func (c *HisApiController) ReadEleToken() {
  3810. admin_user_id, _ := c.GetInt64("admin_user_id")
  3811. his_patient_id, _ := c.GetInt64("his_patient_id")
  3812. adminUser := c.GetAdminUserInfo()
  3813. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3814. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3815. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3816. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3817. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  3818. if len(tokens) > 0 {
  3819. c.ServeSuccessJSON(map[string]interface{}{
  3820. "msg": "读取成功",
  3821. })
  3822. } else {
  3823. c.ServeSuccessJSON(map[string]interface{}{
  3824. "failed_code": -10,
  3825. "msg": "读取失败",
  3826. })
  3827. }
  3828. } else if miConfig.MdtrtareaAdmvs == "341203"{
  3829. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  3830. if len(tokens) > 0 {
  3831. c.ServeSuccessJSON(map[string]interface{}{
  3832. "msg": "读取成功",
  3833. })
  3834. } else {
  3835. c.ServeSuccessJSON(map[string]interface{}{
  3836. "failed_code": -10,
  3837. "msg": "读取失败",
  3838. })
  3839. }
  3840. } else if miConfig.MdtrtareaAdmvs == "150499" {
  3841. var api string
  3842. api = "http://172.16.13.254:9532/" + "nmyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  3843. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName + "&is_settle=1"
  3844. resp, requestErr := http.Get(api)
  3845. if requestErr != nil {
  3846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3847. }
  3848. body, ioErr := ioutil.ReadAll(resp.Body)
  3849. if ioErr != nil {
  3850. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3852. }
  3853. var respJSON map[string]interface{}
  3854. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3855. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3857. return
  3858. }
  3859. var status string
  3860. status = respJSON["data"].(map[string]interface{})["status"].(string)
  3861. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  3862. var token string
  3863. var res ResultTwo //1101结果
  3864. var res10265 ResultTwo10265 //1101结果
  3865. if status == "0" { //读卡成功
  3866. var card_info string //卡信息
  3867. var busi_card_info string
  3868. token = respJSON["data"].(map[string]interface{})["token"].(string)
  3869. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3870. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  3871. fmt.Println(card_info)
  3872. fmt.Println(busi_card_info)
  3873. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3874. result, _ := json.Marshal(respJSON)
  3875. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3876. utils.ErrorLog("解析失败:%v", err)
  3877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3878. return
  3879. }
  3880. res.ErrMsg = res10265.ErrMsg
  3881. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3882. res.Infcode = infocode
  3883. res.Output = res10265.Output
  3884. res.InfRefmsgid = res10265.InfRefmsgid
  3885. if res.Infcode == 0 {
  3886. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3887. if err == gorm.ErrRecordNotFound {
  3888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3889. return
  3890. } else if err != nil {
  3891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3892. return
  3893. } else {
  3894. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3895. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3896. infoStr := string(Iinfos)
  3897. idetinfoStr := string(Idetinfos)
  3898. psn := &models.HisPsn{
  3899. PsnNo: res.Output.Baseinfo.PsnNo,
  3900. PatientId: patient.ID,
  3901. Certno: res.Output.Baseinfo.Certno,
  3902. Gend: res.Output.Baseinfo.Gend,
  3903. Naty: res.Output.Baseinfo.Naty,
  3904. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3905. PsnName: res.Output.Baseinfo.PsnName,
  3906. Idetinfo: idetinfoStr,
  3907. Insuinfo: infoStr,
  3908. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3909. CardInfo: card_info,
  3910. VerifyNumber: token,
  3911. IdCardType: 4,
  3912. }
  3913. var rf []*ResultFive
  3914. json.Unmarshal([]byte(infoStr), &rf)
  3915. var insutypes []*ResultFive
  3916. var insutype string
  3917. var is390 int = 0
  3918. var is310 int = 0
  3919. for _, item := range rf {
  3920. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3921. insutypes = append(insutypes, item)
  3922. }
  3923. }
  3924. if len(insutypes) == 1 {
  3925. insutype = insutypes[0].Insutype
  3926. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3927. } else {
  3928. for _, i := range insutypes {
  3929. if i.Insutype == "390" {
  3930. is390 = 1
  3931. }
  3932. if i.Insutype == "310" {
  3933. is310 = 1
  3934. }
  3935. }
  3936. }
  3937. if is390 == 1 {
  3938. insutype = "390"
  3939. }
  3940. if is310 == 1 {
  3941. insutype = "310"
  3942. }
  3943. if len(insutypes) == 0 {
  3944. insutype = "310"
  3945. }
  3946. service.CreateHisPsn(psn)
  3947. c.ServeSuccessJSON(map[string]interface{}{
  3948. "patient": patient,
  3949. "number": token,
  3950. "insutype": insutype,
  3951. })
  3952. }
  3953. } else {
  3954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3955. return
  3956. }
  3957. } else { //读卡失败
  3958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3959. return
  3960. }
  3961. } else if miConfig.MdtrtareaAdmvs == "350500" {
  3962. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  3963. if len(errMsg) == 0 {
  3964. type ELeData struct {
  3965. Data struct {
  3966. IdNo string `json:"idNo"`
  3967. IdType string `json:"idType"`
  3968. UserName string `json:"userName"`
  3969. EcToken string `json:"ecToken"`
  3970. InsuOrg string `json:"insuOrg"`
  3971. Gender string `json:"gender"`
  3972. Birthday string `json:"birthday"`
  3973. Nationality string `json:"nationality"`
  3974. Email string `json:"email"`
  3975. Extra string `json:"extra"`
  3976. } `json:"data"`
  3977. Code int `json:"code"`
  3978. Message string `json:"message"`
  3979. }
  3980. var ele ELeData
  3981. err := json.Unmarshal([]byte(outPutInfo), &ele)
  3982. if err != nil {
  3983. utils.ErrorLog("解析失败:%v", err)
  3984. }
  3985. token := ele.Data.EcToken
  3986. if len(token) > 0 {
  3987. psn := &models.HisPsn{
  3988. PsnNo: his.PsnNo,
  3989. Age: 0,
  3990. PatientId: his.PatientId,
  3991. Certno: his.Certno,
  3992. Brdy: his.Brdy,
  3993. Gend: his.Gend,
  3994. Naty: his.Naty,
  3995. PsnCertType: his.PsnCertType,
  3996. PsnName: his.PsnName,
  3997. Idetinfo: his.Idetinfo,
  3998. Insuinfo: his.Iinfo,
  3999. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4000. CardInfo: outPutInfo,
  4001. VerifyNumber: token,
  4002. }
  4003. service.CreateHisPsn(psn)
  4004. }
  4005. if len(token) > 0 {
  4006. c.ServeSuccessJSON(map[string]interface{}{
  4007. "msg": "读取成功",
  4008. })
  4009. } else {
  4010. c.ServeSuccessJSON(map[string]interface{}{
  4011. "failed_code": -10,
  4012. "msg": "读取失败",
  4013. })
  4014. }
  4015. }
  4016. } else if miConfig.MdtrtareaAdmvs == "360302" {
  4017. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  4018. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  4019. type ELeData struct {
  4020. Data struct {
  4021. IdNo string `json:"idNo"`
  4022. IdType string `json:"idType"`
  4023. UserName string `json:"userName"`
  4024. EcToken string `json:"ecToken"`
  4025. InsuOrg string `json:"insuOrg"`
  4026. Gender string `json:"gender"`
  4027. Birthday string `json:"birthday"`
  4028. Nationality string `json:"nationality"`
  4029. Email string `json:"email"`
  4030. Extra string `json:"extra"`
  4031. } `json:"data"`
  4032. Code int `json:"code"`
  4033. Message string `json:"message"`
  4034. }
  4035. var ele ELeData
  4036. err := json.Unmarshal([]byte(result), &ele)
  4037. if err != nil {
  4038. utils.ErrorLog("解析失败:%v", err)
  4039. }
  4040. token := ele.Data.EcToken
  4041. token = Remove0000(token)
  4042. fmt.Println(ele.Data.UserName)
  4043. result2, requestLog2 := service.Jxyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  4044. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4045. var res ResultTwo
  4046. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4047. utils.ErrorLog("解析失败:%v", err)
  4048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4049. return
  4050. }
  4051. if res.Infcode == 0 {
  4052. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4053. if err == gorm.ErrRecordNotFound {
  4054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4055. return
  4056. } else if err != nil {
  4057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4058. return
  4059. } else {
  4060. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4061. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4062. infoStr := string(Iinfos)
  4063. idetinfoStr := string(Idetinfos)
  4064. psn := &models.HisPsn{
  4065. PsnNo: res.Output.Baseinfo.PsnNo,
  4066. PatientId: patient.ID,
  4067. Certno: res.Output.Baseinfo.Certno,
  4068. Gend: res.Output.Baseinfo.Gend,
  4069. Naty: res.Output.Baseinfo.Naty,
  4070. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4071. PsnName: res.Output.Baseinfo.PsnName,
  4072. Idetinfo: idetinfoStr,
  4073. Insuinfo: infoStr,
  4074. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4075. CardInfo: "",
  4076. VerifyNumber: token,
  4077. }
  4078. service.CreateHisPsn(psn)
  4079. c.ServeSuccessJSON(map[string]interface{}{
  4080. "patient": patient,
  4081. "number": token,
  4082. })
  4083. }
  4084. } else {
  4085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4086. return
  4087. }
  4088. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4089. idNo := c.GetString("idNo")
  4090. userName := c.GetString("userName")
  4091. ecToken := c.GetString("ecToken")
  4092. insuOrg := c.GetString("insuOrg")
  4093. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  4094. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4095. var res ResultTwo
  4096. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4097. utils.ErrorLog("解析失败:%v", err)
  4098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4099. return
  4100. }
  4101. if res.Infcode == 0 {
  4102. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4103. if err == gorm.ErrRecordNotFound {
  4104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4105. return
  4106. } else if err != nil {
  4107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4108. return
  4109. } else {
  4110. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4111. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4112. infoStr := string(Iinfos)
  4113. idetinfoStr := string(Idetinfos)
  4114. psn := &models.HisPsn{
  4115. PsnNo: res.Output.Baseinfo.PsnNo,
  4116. PatientId: patient.ID,
  4117. Certno: res.Output.Baseinfo.Certno,
  4118. Gend: res.Output.Baseinfo.Gend,
  4119. Naty: res.Output.Baseinfo.Naty,
  4120. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4121. PsnName: res.Output.Baseinfo.PsnName,
  4122. Idetinfo: idetinfoStr,
  4123. Insuinfo: infoStr,
  4124. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4125. CardInfo: "",
  4126. VerifyNumber: ecToken,
  4127. InsuplcAdmdvs: insuOrg,
  4128. }
  4129. service.CreateHisPsn(psn)
  4130. c.ServeSuccessJSON(map[string]interface{}{
  4131. "patient": patient,
  4132. "number": ecToken,
  4133. })
  4134. }
  4135. } else {
  4136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4137. return
  4138. }
  4139. } else if miConfig.MdtrtareaAdmvs == "450721" {
  4140. res := c.GetoleInfo()
  4141. if res.Infcode == 0 {
  4142. var result string
  4143. if res.Output.MdtrtCertType == "01" {
  4144. result = service.Gdyb1101d(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 4, res.Output.CardSN, 1, res.Output.PsnName, res.Output.EcToken, admin_user_id)
  4145. } else if res.Output.MdtrtCertType == "02" {
  4146. result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, res.Output.CardSN, 1, res.Output.PsnName, res.Output.CardNo, admin_user_id)
  4147. } else if res.Output.MdtrtCertType == "03" {
  4148. result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, res.Output.CardSN, 1, res.Output.PsnName, res.Output.CardNo, admin_user_id)
  4149. }
  4150. var dat map[string]interface{}
  4151. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4152. fmt.Println(dat)
  4153. } else {
  4154. fmt.Println(err)
  4155. }
  4156. userJSONBytes, _ := json.Marshal(dat)
  4157. var res2 ResultTwo
  4158. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4159. utils.ErrorLog("解析失败:%v", err)
  4160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4161. return
  4162. }
  4163. if res2.Infcode == 0 {
  4164. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  4165. if err == gorm.ErrRecordNotFound {
  4166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4167. return
  4168. } else if err != nil {
  4169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4170. return
  4171. } else {
  4172. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  4173. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  4174. infoStr := string(Iinfos)
  4175. idetinfoStr := string(Idetinfos)
  4176. var rf []*ResultFive
  4177. json.Unmarshal([]byte(infoStr), &rf)
  4178. var insutypes []*ResultFive
  4179. var insutype string
  4180. var is390 int = 0
  4181. var is310 int = 0
  4182. //var insuplc_admdvs string
  4183. for _, item := range rf {
  4184. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4185. insutypes = append(insutypes, item)
  4186. }
  4187. }
  4188. if len(insutypes) == 1 {
  4189. insutype = insutypes[0].Insutype
  4190. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4191. } else {
  4192. for _, i := range insutypes {
  4193. if i.Insutype == "390" {
  4194. is390 = 1
  4195. }
  4196. if i.Insutype == "310" {
  4197. is310 = 1
  4198. }
  4199. }
  4200. }
  4201. if is390 == 1 {
  4202. insutype = "390"
  4203. }
  4204. if is310 == 1 {
  4205. insutype = "310"
  4206. }
  4207. if len(insutypes) == 0 {
  4208. insutype = "310"
  4209. }
  4210. psn := &models.HisPsn{
  4211. PsnNo: res2.Output.Baseinfo.PsnNo,
  4212. PatientId: patient.ID,
  4213. Certno: res2.Output.Baseinfo.Certno,
  4214. Gend: res2.Output.Baseinfo.Gend,
  4215. Naty: res2.Output.Baseinfo.Naty,
  4216. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  4217. PsnName: res2.Output.Baseinfo.PsnName,
  4218. Idetinfo: idetinfoStr,
  4219. Insuinfo: infoStr,
  4220. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4221. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  4222. VerifyNumber: res.Output.EcToken,
  4223. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  4224. }
  4225. service.CreateHisPsn(psn)
  4226. c.ServeSuccessJSON(map[string]interface{}{
  4227. "patient": patient,
  4228. "number": res.Output.CardNo,
  4229. "insutype": insutype,
  4230. })
  4231. }
  4232. } else {
  4233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4234. return
  4235. }
  4236. } else {
  4237. c.ServeSuccessJSON(map[string]interface{}{
  4238. "failed_code": -10,
  4239. "msg": res.ErrMsg,
  4240. })
  4241. }
  4242. } else {
  4243. //if initFlag == 0 {
  4244. // c.TestGetBasBaseInit()
  4245. //}
  4246. //token := c.GetEleBaseInfo()
  4247. //token = Remove0000(token)
  4248. type ELeData struct {
  4249. Code string `json:"code"`
  4250. Data struct {
  4251. Aac002 string `json:"aac002"`
  4252. Aaz500 string `json:"aaz500"`
  4253. ActCardNo string `json:"actCardNo"`
  4254. Bab520 string `json:"bab520"`
  4255. Bkz543 string `json:"bkz543"`
  4256. BusinessType string `json:"businessType"`
  4257. CertfCodg string `json:"certfCodg"`
  4258. EcIndexNo string `json:"ecIndexNo"`
  4259. EcToken string `json:"ecToken"`
  4260. ID0000 string `json:"id0000"`
  4261. IDNo string `json:"idNo"`
  4262. IDType string `json:"idType"`
  4263. Idcode string `json:"idcode"`
  4264. IdentityToken string `json:"identity_token"`
  4265. InsuOrg string `json:"insuOrg"`
  4266. OfficeID string `json:"officeId"`
  4267. OfficeName string `json:"officeName"`
  4268. OperatorID string `json:"operatorId"`
  4269. OperatorName string `json:"operatorName"`
  4270. OrgID string `json:"orgId"`
  4271. UserName string `json:"userName"`
  4272. } `json:"data"`
  4273. Infno interface{} `json:"infno"`
  4274. Message string `json:"message"`
  4275. OrgID string `json:"orgId"`
  4276. TransType string `json:"transType"`
  4277. }
  4278. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  4279. fmt.Println(result)
  4280. outPutInfo := Remove0000(result)
  4281. fmt.Println(outPutInfo)
  4282. var ele ELeData
  4283. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4284. if err != nil {
  4285. utils.ErrorLog("解析失败:%v", err)
  4286. }
  4287. token := ele.Data.EcToken
  4288. var result2 string
  4289. var requestLog2 string
  4290. if len(token) > 0 {
  4291. if strings.Contains(ele.Data.IDNo, "HKG") {
  4292. result2, requestLog2 = service.Gdyb1101ForEleCert1111(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo,6)
  4293. }else{
  4294. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  4295. }
  4296. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4297. var res ResultTwo
  4298. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4299. utils.ErrorLog("解析失败:%v", err)
  4300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4301. return
  4302. }
  4303. if res.Infcode == 0 {
  4304. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4305. if err == gorm.ErrRecordNotFound {
  4306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4307. return
  4308. } else if err != nil {
  4309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4310. return
  4311. } else {
  4312. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4313. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4314. infoStr := string(Iinfos)
  4315. idetinfoStr := string(Idetinfos)
  4316. psn := &models.HisPsn{
  4317. PsnNo: res.Output.Baseinfo.PsnNo,
  4318. PatientId: patient.ID,
  4319. Certno: res.Output.Baseinfo.Certno,
  4320. Gend: res.Output.Baseinfo.Gend,
  4321. Naty: res.Output.Baseinfo.Naty,
  4322. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4323. PsnName: res.Output.Baseinfo.PsnName,
  4324. Idetinfo: idetinfoStr,
  4325. Insuinfo: infoStr,
  4326. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4327. CardInfo: "",
  4328. VerifyNumber: token,
  4329. }
  4330. service.CreateHisPsn(psn)
  4331. c.ServeSuccessJSON(map[string]interface{}{
  4332. "msg": "读取成功",
  4333. })
  4334. }
  4335. } else {
  4336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4337. return
  4338. }
  4339. } else {
  4340. c.ServeSuccessJSON(map[string]interface{}{
  4341. "failed_code": -10,
  4342. "msg": "读取失败",
  4343. })
  4344. }
  4345. }
  4346. }
  4347. func (c *HisApiController) ReadEleFace() {
  4348. admin_user_id, _ := c.GetInt64("admin_user_id")
  4349. //his_patient_id, _ := c.GetInt64("his_patient_id")
  4350. adminUser := c.GetAdminUserInfo()
  4351. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4352. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4353. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4354. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4355. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4356. if len(tokens) > 0 {
  4357. c.ServeSuccessJSON(map[string]interface{}{
  4358. "msg": "读取成功",
  4359. })
  4360. } else {
  4361. c.ServeSuccessJSON(map[string]interface{}{
  4362. "failed_code": -10,
  4363. "msg": "读取失败",
  4364. })
  4365. }
  4366. }
  4367. }
  4368. func (c *HisApiController) Get9001() {
  4369. adminUser := c.GetAdminUserInfo()
  4370. admin_user_id, _ := c.GetInt64("admin_user_id")
  4371. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4372. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4373. if miConfig.MdtrtareaAdmvs == "350500" {
  4374. service.GetFjAuthorizationInfo(miConfig.Code)
  4375. } else if miConfig.MdtrtareaAdmvs == "131023" {
  4376. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  4377. var dat map[string]interface{}
  4378. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4379. fmt.Println(dat)
  4380. } else {
  4381. fmt.Println(err)
  4382. }
  4383. userJSONBytes, _ := json.Marshal(dat)
  4384. var res models.Result9001
  4385. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4386. utils.ErrorLog("解析失败:%v", err)
  4387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4388. return
  4389. }
  4390. } else if miConfig.MdtrtareaAdmvs == "341203" {
  4391. fmt.Println(miConfig.SecretKey)
  4392. var res models.Result9001Two
  4393. api := miConfig.SecretKey + "ahyb/9001?org_name=" + miConfig.OrgName + "&opera_name=" + roles.UserName+"&opera_id="+strconv.FormatInt(admin_user_id, 10) + "&fixmedins_code=" + miConfig.Code +
  4394. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo="+miConfig.Cainfo+"&url="+miConfig.Url
  4395. resp, requestErr := http.Get(api)
  4396. if requestErr != nil {
  4397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4398. return
  4399. }
  4400. body, ioErr := ioutil.ReadAll(resp.Body)
  4401. if ioErr != nil {
  4402. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4404. return
  4405. }
  4406. var respJSON map[string]interface{}
  4407. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4408. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4410. return
  4411. }
  4412. status := respJSON["data"].(map[string]interface{})["status"].(string)
  4413. if status == "0"{
  4414. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  4415. c.ServeSuccessJSON(map[string]interface{}{
  4416. "failed_code": -10,
  4417. "msg": err_msg,
  4418. })
  4419. return
  4420. }
  4421. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4422. result, _ := json.Marshal(respJSON)
  4423. fmt.Println("log")
  4424. fmt.Println(string(result))
  4425. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4426. utils.ErrorLog("解析失败:%v", err)
  4427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4428. return
  4429. }
  4430. if res.Infcode == 0 {
  4431. sign := models.HisSignIn{
  4432. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4433. SignNo: res.Output.Signinoutb.SignNo,
  4434. SignTime: "",
  4435. Ctime: time.Now().Unix(),
  4436. Mtime: time.Now().Unix(),
  4437. Status: 1,
  4438. InputLog: "",
  4439. OutputLog: "",
  4440. FixmedinsCode: miConfig.Code,
  4441. }
  4442. err := service.CreateSignIn(&sign)
  4443. if err == nil {
  4444. c.ServeSuccessJSON(map[string]interface{}{
  4445. "msg": "签到成功",
  4446. })
  4447. }
  4448. } else {
  4449. c.ServeSuccessJSON(map[string]interface{}{
  4450. "failed_code": -10,
  4451. "msg": res.ErrMsg,
  4452. })
  4453. return
  4454. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4455. //return
  4456. }
  4457. }else {
  4458. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  4459. var dat map[string]interface{}
  4460. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4461. fmt.Println(dat)
  4462. } else {
  4463. fmt.Println(err)
  4464. }
  4465. userJSONBytes, _ := json.Marshal(dat)
  4466. var res models.Result9001
  4467. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4468. utils.ErrorLog("解析失败:%v", err)
  4469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4470. return
  4471. }
  4472. if res.Infcode == 0 {
  4473. sign := models.HisSignIn{
  4474. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4475. SignNo: res.Output.Signinoutb.SignNo,
  4476. SignTime: res.Output.Signinoutb.SignTime,
  4477. Ctime: time.Now().Unix(),
  4478. Mtime: time.Now().Unix(),
  4479. Status: 1,
  4480. InputLog: "",
  4481. OutputLog: "",
  4482. FixmedinsCode: miConfig.Code,
  4483. }
  4484. err := service.CreateSignIn(&sign)
  4485. if err == nil {
  4486. c.ServeSuccessJSON(map[string]interface{}{
  4487. "msg": "签到成功",
  4488. })
  4489. }
  4490. }
  4491. }
  4492. }
  4493. func Check3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res2 Result3101) {
  4494. var res Result3101
  4495. adminUser := c.GetAdminUserInfo()
  4496. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4497. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4498. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4499. //record_time := c.GetString("record_time")
  4500. //trig_scen := c.GetString("trig_scen")
  4501. timeLayout := "2006-01-02"
  4502. loc, _ := time.LoadLocation("Local")
  4503. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4504. if err != nil {
  4505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4506. return res
  4507. }
  4508. recordDateTime := theTime.Unix()
  4509. var patientPrescription models.HisPrescriptionInfo
  4510. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4511. //if patientPrescription.ID == 0 {
  4512. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4513. //}
  4514. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4515. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4516. //
  4517. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  4518. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4519. var pp models.PublicParams
  4520. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4521. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4522. pp.FixmedinsName = miConfig.OrgName
  4523. pp.FixmedinsCode = miConfig.Code
  4524. pp.RequestUrl = miConfig.Url
  4525. pp.Cainfo = miConfig.Cainfo
  4526. pp.SecretKey = miConfig.SecretKey
  4527. pp.AccessKey = miConfig.AccessKey
  4528. pp.OpterName = roles.UserName
  4529. var config []*models.HisXtDiagnoseConfig
  4530. for _, item := range diagnosis_ids {
  4531. id, _ := strconv.ParseInt(item, 10, 64)
  4532. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4533. config = append(config, &diagnosisConfig)
  4534. }
  4535. var pd models.PatientDtos
  4536. pd.PatnID = his.PsnNo
  4537. pd.PatnName = his.Name
  4538. pd.Gend = his.Gend
  4539. pd.Brdy = his.Brdy
  4540. pd.Poolarea = miConfig.MdtrtareaAdmvs
  4541. pd.CurrMdtrtID = his.Number
  4542. var fed models.FsiEncounterDtos
  4543. fed.MdtrtID = his.Number
  4544. fed.MedinsID = miConfig.Code
  4545. fed.MedinsName = miConfig.OrgName
  4546. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  4547. fed.MedMdtrtType = "1"
  4548. fed.MedinsType = "1"
  4549. fed.MedinsLv = "11"
  4550. tm := time.Unix(his.RecordDate, 0)
  4551. s_tm := tm.Format("2006-01-02 15:04:05")
  4552. fed.AdmDate = s_tm
  4553. fed.DscgDate = s_tm
  4554. fed.DscgMainDiseCodg = config[0].CountryCode
  4555. fed.DscgMainDiseName = config[0].CountryContentName
  4556. //诊断信息
  4557. var fdds []*models.FsiDiagnoseDtos
  4558. for index, item := range config {
  4559. if index == 0 {
  4560. var fdd models.FsiDiagnoseDtos
  4561. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  4562. fdd.InoutDiseType = "1"
  4563. fdd.MaindiseFlag = "1"
  4564. fdd.DiseDate = s_tm
  4565. fdd.DiasSrtNo = "1"
  4566. fdd.DiseName = item.CountryContentName
  4567. fdd.DiseCodg = item.CountryCode
  4568. fdds = append(fdds, &fdd)
  4569. } else {
  4570. var fdd models.FsiDiagnoseDtos
  4571. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  4572. fdd.InoutDiseType = "1"
  4573. fdd.MaindiseFlag = "1"
  4574. fdd.DiseDate = s_tm
  4575. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  4576. fdd.DiseName = item.CountryContentName
  4577. fdd.DiseCodg = item.CountryCode
  4578. fdds = append(fdds, &fdd)
  4579. }
  4580. }
  4581. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  4582. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  4583. fed.AdmDeptName = department.Name
  4584. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  4585. fed.DscgDeptName = department.Name
  4586. fed.MedMdtrtType = "1"
  4587. fed.MedType = "11"
  4588. //if his.Insutype == "390" {
  4589. // fed.MedType = "1402"
  4590. //} else {
  4591. // fed.MedType = "9933"
  4592. //}
  4593. var orders []*models.FsiOrderDtos
  4594. if trig_scen == "2" {
  4595. //处方医嘱信息
  4596. for _, item := range prescriptions {
  4597. for _, subItem := range item.HisDoctorAdviceInfo {
  4598. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4599. var order models.FsiOrderDtos
  4600. order.RxID = strconv.FormatInt(item.ID, 10)
  4601. order.Rxno = strconv.FormatInt(item.ID, 10)
  4602. order.LongDrordFlag = "0"
  4603. order.HilistType = "1"
  4604. order.ChrgType = "1"
  4605. order.DrordBhvr = "-"
  4606. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4607. order.HosplistName = subItem.BaseDrugLib.DrugName
  4608. order.HilistLv = "1"
  4609. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4610. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4611. order.HosplistName = subItem.BaseDrugLib.DrugName
  4612. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  4613. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4614. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  4615. order.OwnpayAmt = ""
  4616. order.SelfpayAmt = ""
  4617. order.Spec = ""
  4618. order.SpecUnt = ""
  4619. order.DrordBegnDate = s_tm
  4620. order.DrordStopDate = ""
  4621. order.DrordDrCodg = doctor_info.DoctorNumber
  4622. order.DrordDeptName = department.Name
  4623. order.DrordDeptCodg = department.Number
  4624. order.DrordDrName = doctor_info.UserName
  4625. order.DrordDrProfttl = "234"
  4626. order.CurrDrordFlag = "1"
  4627. orders = append(orders, &order)
  4628. }
  4629. }
  4630. for _, subItem := range item.HisPrescriptionProject {
  4631. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  4632. var order models.FsiOrderDtos
  4633. order.RxID = strconv.FormatInt(item.ID, 10)
  4634. order.Rxno = strconv.FormatInt(item.ID, 10)
  4635. order.LongDrordFlag = "0"
  4636. order.HilistType = "1"
  4637. order.ChrgType = "1"
  4638. order.DrordBhvr = "-"
  4639. order.HilistCode = subItem.HisProject.MedicalCode
  4640. order.HosplistName = subItem.HisProject.ProjectName
  4641. order.HilistLv = "1"
  4642. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4643. order.HosplistCode = subItem.HisProject.MedicalCode
  4644. order.HosplistName = subItem.HisProject.ProjectName
  4645. order.Cnt = subItem.Count
  4646. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4647. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4648. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  4649. order.OwnpayAmt = ""
  4650. order.SelfpayAmt = ""
  4651. order.Spec = ""
  4652. order.SpecUnt = ""
  4653. order.DrordBegnDate = s_tm
  4654. order.DrordStopDate = ""
  4655. order.DrordDrCodg = doctor_info.DoctorNumber
  4656. order.DrordDeptName = department.Name
  4657. order.DrordDeptCodg = department.Number
  4658. order.DrordDrName = doctor_info.UserName
  4659. order.DrordDrProfttl = "234"
  4660. order.CurrDrordFlag = "1"
  4661. orders = append(orders, &order)
  4662. }
  4663. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0{
  4664. var order models.FsiOrderDtos
  4665. order.RxID = strconv.FormatInt(item.ID, 10)
  4666. order.Rxno = strconv.FormatInt(item.ID, 10)
  4667. order.LongDrordFlag = "0"
  4668. order.HilistType = "1"
  4669. order.ChrgType = "1"
  4670. order.DrordBhvr = "-"
  4671. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4672. order.HosplistName = subItem.GoodInfo.GoodName
  4673. order.HilistLv = "1"
  4674. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4675. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4676. order.HosplistName = subItem.GoodInfo.GoodName
  4677. order.Cnt = subItem.Count
  4678. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4679. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4680. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  4681. order.OwnpayAmt = ""
  4682. order.SelfpayAmt = ""
  4683. order.Spec = ""
  4684. order.SpecUnt = ""
  4685. order.DrordBegnDate = s_tm
  4686. order.DrordStopDate = ""
  4687. order.DrordDrCodg = doctor_info.DoctorNumber
  4688. order.DrordDeptName = department.Name
  4689. order.DrordDeptCodg = department.Number
  4690. order.DrordDrName = doctor_info.UserName
  4691. order.DrordDrProfttl = "234"
  4692. order.CurrDrordFlag = "1"
  4693. orders = append(orders, &order)
  4694. }
  4695. }
  4696. }
  4697. //处方医嘱信息
  4698. }
  4699. fed.MatnStas = "0"
  4700. fed.MedfeeSumamt = "0"
  4701. fed.OwnpayAmt = "0"
  4702. fed.SelfpayAmt = "0"
  4703. fed.AcctPayamt = "0"
  4704. fed.MaAmt = "0"
  4705. fed.HifpPayamt = "0"
  4706. fed.SetlTotlnum = "1"
  4707. fed.Insutype = his.Insutype
  4708. fed.ReimFlag = "0"
  4709. fed.OutSetlFlag = "0"
  4710. var fopd []*models.FsiOperationDtosData
  4711. data := make(map[string]interface{})
  4712. data["fed"] = fed
  4713. data["fdd"] = fdds
  4714. data["fod"] = orders
  4715. data["pd"] = pd
  4716. data["pp"] = pp
  4717. data["fopd"] = fopd
  4718. data["trig_scen"] = trig_scen
  4719. fmt.Println(data)
  4720. fmt.Println(fed)
  4721. fmt.Println(fdds)
  4722. fmt.Println(orders)
  4723. fmt.Println(pd)
  4724. fmt.Println(pp)
  4725. fmt.Println(fopd)
  4726. client := &http.Client{}
  4727. bytesData, _ := json.Marshal(data)
  4728. var req *http.Request
  4729. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4730. if miConfig.MdtrtareaAdmvs == "320921" {
  4731. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  4732. } else {
  4733. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  4734. }
  4735. resp, _ := client.Do(req)
  4736. defer resp.Body.Close()
  4737. body, ioErr := ioutil.ReadAll(resp.Body)
  4738. if ioErr != nil {
  4739. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4741. return res
  4742. }
  4743. var respJSON map[string]interface{}
  4744. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4747. return res
  4748. }
  4749. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  4750. fmt.Println(respJSON)
  4751. result, _ := json.Marshal(respJSON)
  4752. fmt.Println(result)
  4753. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4754. utils.ErrorLog("解析失败:%v", err)
  4755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4756. return res
  4757. }
  4758. return res
  4759. } else {
  4760. //if miConfig.MdtrtareaAdmvs == "441202" {
  4761. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  4762. saveLog(output, input, "3101", "事前")
  4763. if err := json.Unmarshal([]byte(output), &res); err != nil {
  4764. utils.ErrorLog("解析失败:%v", err)
  4765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4766. return
  4767. }
  4768. return res
  4769. //}
  4770. }
  4771. }
  4772. func Check3101(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Result3101) {
  4773. adminUser := c.GetAdminUserInfo()
  4774. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4775. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4776. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4777. //record_time := c.GetString("record_time")
  4778. //trig_scen := c.GetString("trig_scen")
  4779. timeLayout := "2006-01-02"
  4780. loc, _ := time.LoadLocation("Local")
  4781. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4782. if err != nil {
  4783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4784. return res
  4785. }
  4786. recordDateTime := theTime.Unix()
  4787. var patientPrescription models.HisPrescriptionInfo
  4788. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4789. if patientPrescription.ID == 0 {
  4790. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4791. }
  4792. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4793. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4794. //
  4795. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  4796. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4797. var pp models.PublicParams
  4798. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4799. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4800. pp.FixmedinsName = miConfig.OrgName
  4801. pp.FixmedinsCode = miConfig.Code
  4802. pp.RequestUrl = miConfig.Url
  4803. pp.Cainfo = miConfig.Cainfo
  4804. pp.SecretKey = miConfig.SecretKey
  4805. pp.AccessKey = miConfig.AccessKey
  4806. pp.OpterName = roles.UserName
  4807. var config []*models.HisXtDiagnoseConfig
  4808. for _, item := range diagnosis_ids {
  4809. id, _ := strconv.ParseInt(item, 10, 64)
  4810. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4811. config = append(config, &diagnosisConfig)
  4812. }
  4813. var pd models.PatientDtos
  4814. pd.PatnID = his.PsnNo
  4815. pd.PatnName = his.Name
  4816. pd.Gend = his.Gend
  4817. pd.Brdy = his.Brdy
  4818. pd.Poolarea = his.InsuplcAdmdvs
  4819. pd.CurrMdtrtID = his.Number
  4820. var fed models.FsiEncounterDtos
  4821. fed.MdtrtID = his.Number
  4822. fed.MedinsID = miConfig.Code
  4823. fed.MedinsName = miConfig.OrgName
  4824. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  4825. fed.MedMdtrtType = "1"
  4826. fed.MedinsType = "1"
  4827. fed.MedinsLv = "11"
  4828. tm := time.Unix(his.RecordDate, 0)
  4829. s_tm := tm.Format("2006-01-02 15:04:05")
  4830. fed.AdmDate = s_tm
  4831. fed.DscgDate = s_tm
  4832. fed.DscgMainDiseCodg = config[0].CountryCode
  4833. fed.DscgMainDiseName = config[0].CountryContentName
  4834. //诊断信息
  4835. var fdds []*models.FsiDiagnoseDtos
  4836. for index, item := range config {
  4837. if index == 0 {
  4838. var fdd models.FsiDiagnoseDtos
  4839. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  4840. fdd.InoutDiseType = "1"
  4841. fdd.MaindiseFlag = "1"
  4842. fdd.DiseDate = s_tm
  4843. fdd.DiasSrtNo = "1"
  4844. fdd.DiseName = item.CountryContentName
  4845. fdd.DiseCodg = item.CountryCode
  4846. fdds = append(fdds, &fdd)
  4847. } else {
  4848. var fdd models.FsiDiagnoseDtos
  4849. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  4850. fdd.InoutDiseType = "1"
  4851. fdd.MaindiseFlag = "1"
  4852. fdd.DiseDate = s_tm
  4853. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  4854. fdd.DiseName = item.CountryContentName
  4855. fdd.DiseCodg = item.CountryCode
  4856. fdds = append(fdds, &fdd)
  4857. }
  4858. }
  4859. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  4860. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  4861. fed.AdmDeptName = department.Name
  4862. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  4863. fed.DscgDeptName = department.Name
  4864. fed.MedMdtrtType = "1"
  4865. fed.MedType = "11"
  4866. //if his.Insutype == "390" {
  4867. // fed.MedType = "1402"
  4868. //} else {
  4869. // fed.MedType = "9933"
  4870. //}
  4871. var orders []*models.FsiOrderDtos
  4872. if trig_scen == "2" {
  4873. //处方医嘱信息
  4874. for _, item := range prescriptions {
  4875. for _, subItem := range item.HisDoctorAdviceInfo {
  4876. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4877. var order models.FsiOrderDtos
  4878. order.RxID = strconv.FormatInt(item.ID, 10)
  4879. order.Rxno = strconv.FormatInt(item.ID, 10)
  4880. order.LongDrordFlag = "0"
  4881. order.HilistType = "1"
  4882. order.ChrgType = "1"
  4883. order.DrordBhvr = "-"
  4884. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4885. order.HosplistName = subItem.BaseDrugLib.DrugName
  4886. order.HilistLv = "1"
  4887. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4888. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4889. order.HosplistName = subItem.BaseDrugLib.DrugName
  4890. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  4891. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4892. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  4893. order.OwnpayAmt = ""
  4894. order.SelfpayAmt = ""
  4895. order.Spec = ""
  4896. order.SpecUnt = ""
  4897. order.DrordBegnDate = s_tm
  4898. order.DrordStopDate = ""
  4899. order.DrordDrCodg = doctor_info.DoctorNumber
  4900. order.DrordDeptName = department.Name
  4901. order.DrordDeptCodg = department.Number
  4902. order.DrordDrName = doctor_info.UserName
  4903. order.DrordDrProfttl = "234"
  4904. order.CurrDrordFlag = "1"
  4905. orders = append(orders, &order)
  4906. }
  4907. }
  4908. for _, subItem := range item.HisPrescriptionProject {
  4909. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  4910. var order models.FsiOrderDtos
  4911. order.RxID = strconv.FormatInt(item.ID, 10)
  4912. order.Rxno = strconv.FormatInt(item.ID, 10)
  4913. order.LongDrordFlag = "0"
  4914. order.HilistType = "1"
  4915. order.ChrgType = "1"
  4916. order.DrordBhvr = "-"
  4917. order.HilistCode = subItem.HisProject.MedicalCode
  4918. order.HosplistName = subItem.HisProject.ProjectName
  4919. order.HilistLv = "1"
  4920. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4921. order.HosplistCode = subItem.HisProject.MedicalCode
  4922. order.HosplistName = subItem.HisProject.ProjectName
  4923. order.Cnt = subItem.Count
  4924. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4925. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4926. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  4927. order.OwnpayAmt = ""
  4928. order.SelfpayAmt = ""
  4929. order.Spec = ""
  4930. order.SpecUnt = ""
  4931. order.DrordBegnDate = s_tm
  4932. order.DrordStopDate = ""
  4933. order.DrordDrCodg = doctor_info.DoctorNumber
  4934. order.DrordDeptName = department.Name
  4935. order.DrordDeptCodg = department.Number
  4936. order.DrordDrName = doctor_info.UserName
  4937. order.DrordDrProfttl = "234"
  4938. order.CurrDrordFlag = "1"
  4939. orders = append(orders, &order)
  4940. }
  4941. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  4942. var order models.FsiOrderDtos
  4943. order.RxID = strconv.FormatInt(item.ID, 10)
  4944. order.Rxno = strconv.FormatInt(item.ID, 10)
  4945. order.LongDrordFlag = "0"
  4946. order.HilistType = "1"
  4947. order.ChrgType = "1"
  4948. order.DrordBhvr = "-"
  4949. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4950. order.HosplistName = subItem.GoodInfo.GoodName
  4951. order.HilistLv = "1"
  4952. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4953. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4954. order.HosplistName = subItem.GoodInfo.GoodName
  4955. order.Cnt = subItem.Count
  4956. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4957. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4958. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  4959. order.OwnpayAmt = ""
  4960. order.SelfpayAmt = ""
  4961. order.Spec = ""
  4962. order.SpecUnt = ""
  4963. order.DrordBegnDate = s_tm
  4964. order.DrordStopDate = ""
  4965. order.DrordDrCodg = doctor_info.DoctorNumber
  4966. order.DrordDeptName = department.Name
  4967. order.DrordDeptCodg = department.Number
  4968. order.DrordDrName = doctor_info.UserName
  4969. order.DrordDrProfttl = "234"
  4970. order.CurrDrordFlag = "1"
  4971. orders = append(orders, &order)
  4972. }
  4973. }
  4974. }
  4975. //处方医嘱信息
  4976. }
  4977. fed.MatnStas = "0"
  4978. fed.MedfeeSumamt = "0"
  4979. fed.OwnpayAmt = "0"
  4980. fed.SelfpayAmt = "0"
  4981. fed.AcctPayamt = "0"
  4982. fed.MaAmt = "0"
  4983. fed.HifpPayamt = "0"
  4984. fed.SetlTotlnum = "1"
  4985. fed.Insutype = his.Insutype
  4986. fed.ReimFlag = "0"
  4987. fed.OutSetlFlag = "0"
  4988. var fopd []*models.FsiOperationDtosData
  4989. data := make(map[string]interface{})
  4990. data["fed"] = fed
  4991. data["fdd"] = fdds
  4992. data["fod"] = orders
  4993. data["pd"] = pd
  4994. data["pp"] = pp
  4995. data["fopd"] = fopd
  4996. data["trig_scen"] = trig_scen
  4997. fmt.Println(data)
  4998. fmt.Println(fed)
  4999. fmt.Println(fdds)
  5000. fmt.Println(orders)
  5001. fmt.Println(pd)
  5002. fmt.Println(pp)
  5003. fmt.Println(fopd)
  5004. client := &http.Client{}
  5005. bytesData, _ := json.Marshal(data)
  5006. var req *http.Request
  5007. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5008. if miConfig.MdtrtareaAdmvs == "320921" {
  5009. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5010. } else {
  5011. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5012. }
  5013. resp, _ := client.Do(req)
  5014. defer resp.Body.Close()
  5015. body, ioErr := ioutil.ReadAll(resp.Body)
  5016. if ioErr != nil {
  5017. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5019. return res
  5020. }
  5021. var respJSON map[string]interface{}
  5022. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5023. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5025. return res
  5026. }
  5027. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5028. fmt.Println(respJSON)
  5029. result, _ := json.Marshal(respJSON)
  5030. fmt.Println(result)
  5031. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5032. utils.ErrorLog("解析失败:%v", err)
  5033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5034. return res
  5035. }
  5036. return res
  5037. } else {
  5038. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5039. saveLog(output, input, "3101", "事前")
  5040. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5041. utils.ErrorLog("解析失败:%v", err)
  5042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5043. return
  5044. }
  5045. return res
  5046. }
  5047. return res
  5048. }
  5049. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  5050. ////patient_id, _ := c.GetInt64("patient_id")
  5051. //order_id, _ := c.GetInt64("order_id")
  5052. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  5053. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  5054. //trig_scen := c.GetString("trig_scen")
  5055. adminUser := c.GetAdminUserInfo()
  5056. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5057. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5058. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5059. record_time := c.GetString("record_time")
  5060. order, _ := service.GetHisOrderByID(order_id)
  5061. psn_info, _ := service.GetPsnByPatientId(patient_id)
  5062. timeLayout := "2006-01-02"
  5063. loc, _ := time.LoadLocation("Local")
  5064. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5065. if err != nil {
  5066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5067. return
  5068. }
  5069. recordDateTime := theTime.Unix()
  5070. var patientPrescription models.HisPrescriptionInfo
  5071. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5072. if patientPrescription.ID == 0 {
  5073. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5074. }
  5075. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5076. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5077. //
  5078. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5079. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5080. var pp models.PublicParams
  5081. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5082. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5083. pp.FixmedinsName = miConfig.OrgName
  5084. pp.FixmedinsCode = miConfig.Code
  5085. pp.RequestUrl = miConfig.Url
  5086. pp.Cainfo = miConfig.Cainfo
  5087. pp.SecretKey = miConfig.SecretKey
  5088. pp.AccessKey = miConfig.AccessKey
  5089. pp.OpterName = roles.UserName
  5090. var config []*models.HisXtDiagnoseConfig
  5091. for _, item := range diagnosis_ids {
  5092. id, _ := strconv.ParseInt(item, 10, 64)
  5093. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5094. config = append(config, &diagnosisConfig)
  5095. }
  5096. var pd models.PatientDtos
  5097. pd.PatnID = his.PsnNo
  5098. pd.PatnName = his.Name
  5099. pd.Gend = his.Gend
  5100. pd.Brdy = psn_info.Brdy
  5101. pd.Poolarea = his.InsuplcAdmdvs
  5102. pd.CurrMdtrtID = his.Number
  5103. var fed models.FsiEncounterDtos
  5104. fed.MdtrtID = his.Number
  5105. fed.MedinsID = miConfig.Code
  5106. fed.MedinsName = miConfig.OrgName
  5107. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5108. fed.MedMdtrtType = "1"
  5109. fed.MedinsType = "1"
  5110. fed.MedinsLv = "11"
  5111. tm := time.Unix(his.RecordDate, 0)
  5112. s_tm := tm.Format("2006-01-02 15:04:05")
  5113. fed.AdmDate = s_tm
  5114. fed.DscgDate = s_tm
  5115. fed.DscgMainDiseCodg = config[0].CountryCode
  5116. fed.DscgMainDiseName = config[0].CountryContentName
  5117. //诊断信息
  5118. var fdds []*models.FsiDiagnoseDtos
  5119. for index, item := range config {
  5120. if index == 0 {
  5121. var fdd models.FsiDiagnoseDtos
  5122. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5123. fdd.InoutDiseType = "1"
  5124. fdd.MaindiseFlag = "1"
  5125. fdd.DiseDate = s_tm
  5126. fdd.DiasSrtNo = "1"
  5127. fdd.DiseName = item.CountryContentName
  5128. fdd.DiseCodg = item.CountryCode
  5129. fdds = append(fdds, &fdd)
  5130. } else {
  5131. var fdd models.FsiDiagnoseDtos
  5132. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5133. fdd.InoutDiseType = "1"
  5134. fdd.MaindiseFlag = "1"
  5135. fdd.DiseDate = s_tm
  5136. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5137. fdd.DiseName = item.CountryContentName
  5138. fdd.DiseCodg = item.CountryCode
  5139. fdds = append(fdds, &fdd)
  5140. }
  5141. }
  5142. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5143. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5144. fed.AdmDeptName = department.Name
  5145. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5146. fed.DscgDeptName = department.Name
  5147. fed.MedType = order.MedType
  5148. //处方医嘱信息
  5149. var orders []*models.FsiOrderDtos
  5150. //for _, item := range prescriptions {
  5151. // for _, subItem := range item.HisDoctorAdviceInfo {
  5152. // var order models.FsiOrderDtos
  5153. // order.RxID = strconv.FormatInt(item.ID, 10)
  5154. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5155. // order.LongDrordFlag = "0"
  5156. // order.HilistType = "1"
  5157. // order.ChrgType = "1"
  5158. // order.DrordBhvr = "-"
  5159. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5160. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5161. // order.HilistLv = "1"
  5162. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5163. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5164. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5165. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  5166. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5167. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  5168. // order.OwnpayAmt = ""
  5169. // order.SelfpayAmt = ""
  5170. // order.Spec = ""
  5171. // order.SpecUnt = ""
  5172. // order.DrordBegnDate = s_tm
  5173. // order.DrordStopDate = ""
  5174. // order.DrordDrCodg = "1"
  5175. // order.DrordDeptName = department.Name
  5176. // order.DrordDrCodg = "1"
  5177. // order.DrordDrName = doctor_info.UserName
  5178. // order.DrordDrProfttl = ""
  5179. // order.CurrDrordFlag = "1"
  5180. // orders = append(orders, &order)
  5181. // }
  5182. // for _, subItem := range item.HisPrescriptionProject {
  5183. // if subItem.Type == 2 {
  5184. // var order models.FsiOrderDtos
  5185. // order.RxID = strconv.FormatInt(item.ID, 10)
  5186. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5187. // order.LongDrordFlag = "0"
  5188. // order.HilistType = "1"
  5189. // order.ChrgType = "1"
  5190. // order.DrordBhvr = "-"
  5191. // order.HilistCode = subItem.HisProject.MedicalCode
  5192. // order.HosplistName = subItem.HisProject.ProjectName
  5193. // order.HilistLv = "1"
  5194. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5195. // order.HosplistCode = subItem.HisProject.MedicalCode
  5196. // order.HosplistName = subItem.HisProject.ProjectName
  5197. // order.Cnt = subItem.Count
  5198. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5199. //
  5200. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5201. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  5202. // order.OwnpayAmt = ""
  5203. // order.SelfpayAmt = ""
  5204. // order.Spec = ""
  5205. // order.SpecUnt = ""
  5206. // order.DrordBegnDate = s_tm
  5207. // order.DrordStopDate = ""
  5208. // order.DrordDrCodg = "1"
  5209. // order.DrordDeptName = department.Name
  5210. // order.DrordDrCodg = "1"
  5211. // order.DrordDrName = doctor_info.UserName
  5212. // order.DrordDrProfttl = ""
  5213. // order.CurrDrordFlag = "1"
  5214. // orders = append(orders, &order)
  5215. //
  5216. // }
  5217. // if subItem.Type == 3 {
  5218. //
  5219. // var order models.FsiOrderDtos
  5220. // order.RxID = strconv.FormatInt(item.ID, 10)
  5221. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5222. // order.LongDrordFlag = "0"
  5223. // order.HilistType = "1"
  5224. // order.ChrgType = "1"
  5225. // order.DrordBhvr = "-"
  5226. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5227. // order.HosplistName = subItem.GoodInfo.GoodName
  5228. // order.HilistLv = "1"
  5229. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5230. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5231. // order.HosplistName = subItem.GoodInfo.GoodName
  5232. // order.Cnt = subItem.Count
  5233. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5234. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5235. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  5236. // order.OwnpayAmt = ""
  5237. // order.SelfpayAmt = ""
  5238. // order.Spec = ""
  5239. // order.SpecUnt = ""
  5240. // order.DrordBegnDate = s_tm
  5241. // order.DrordStopDate = ""
  5242. // order.DrordDrCodg = "1"
  5243. // order.DrordDeptName = department.Name
  5244. // order.DrordDrCodg = "1"
  5245. // order.DrordDrName = doctor_info.UserName
  5246. // order.DrordDrProfttl = ""
  5247. // order.CurrDrordFlag = "1"
  5248. // orders = append(orders, &order)
  5249. //
  5250. // }
  5251. // }
  5252. //}
  5253. for _, item := range prescriptions {
  5254. for _, subItem := range item.HisDoctorAdviceInfo {
  5255. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5256. var order models.FsiOrderDtos
  5257. order.RxID = strconv.FormatInt(item.ID, 10)
  5258. order.Rxno = strconv.FormatInt(item.ID, 10)
  5259. order.LongDrordFlag = "0"
  5260. order.HilistType = "1"
  5261. order.ChrgType = "1"
  5262. order.DrordBhvr = "-"
  5263. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5264. order.HosplistName = subItem.BaseDrugLib.DrugName
  5265. order.HilistLv = "1"
  5266. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5267. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5268. order.HosplistName = subItem.BaseDrugLib.DrugName
  5269. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5270. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5271. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5272. order.OwnpayAmt = ""
  5273. order.SelfpayAmt = ""
  5274. order.Spec = ""
  5275. order.SpecUnt = ""
  5276. order.DrordBegnDate = s_tm
  5277. order.DrordStopDate = ""
  5278. order.DrordDrCodg = doctor_info.DoctorNumber
  5279. order.DrordDeptName = department.Name
  5280. order.DrordDeptCodg = department.Number
  5281. order.DrordDrName = doctor_info.UserName
  5282. order.DrordDrProfttl = "234"
  5283. order.CurrDrordFlag = "1"
  5284. orders = append(orders, &order)
  5285. }
  5286. }
  5287. for _, subItem := range item.HisPrescriptionProject {
  5288. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5289. var order models.FsiOrderDtos
  5290. order.RxID = strconv.FormatInt(item.ID, 10)
  5291. order.Rxno = strconv.FormatInt(item.ID, 10)
  5292. order.LongDrordFlag = "0"
  5293. order.HilistType = "1"
  5294. order.ChrgType = "1"
  5295. order.DrordBhvr = "-"
  5296. order.HilistCode = subItem.HisProject.MedicalCode
  5297. order.HosplistName = subItem.HisProject.ProjectName
  5298. order.HilistLv = "1"
  5299. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5300. order.HosplistCode = subItem.HisProject.MedicalCode
  5301. order.HosplistName = subItem.HisProject.ProjectName
  5302. order.Cnt = subItem.Count
  5303. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5304. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5305. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5306. order.OwnpayAmt = ""
  5307. order.SelfpayAmt = ""
  5308. order.Spec = ""
  5309. order.SpecUnt = ""
  5310. order.DrordBegnDate = s_tm
  5311. order.DrordStopDate = ""
  5312. order.DrordDrCodg = doctor_info.DoctorNumber
  5313. order.DrordDeptName = department.Name
  5314. order.DrordDeptCodg = department.Number
  5315. order.DrordDrName = doctor_info.UserName
  5316. order.DrordDrProfttl = "234"
  5317. order.CurrDrordFlag = "1"
  5318. orders = append(orders, &order)
  5319. }
  5320. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5321. var order models.FsiOrderDtos
  5322. order.RxID = strconv.FormatInt(item.ID, 10)
  5323. order.Rxno = strconv.FormatInt(item.ID, 10)
  5324. order.LongDrordFlag = "0"
  5325. order.HilistType = "1"
  5326. order.ChrgType = "1"
  5327. order.DrordBhvr = "0"
  5328. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5329. order.HosplistName = subItem.GoodInfo.GoodName
  5330. order.HilistLv = "1"
  5331. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5332. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5333. order.HosplistName = subItem.GoodInfo.GoodName
  5334. order.Cnt = subItem.Count
  5335. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5336. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5337. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5338. order.OwnpayAmt = ""
  5339. order.SelfpayAmt = ""
  5340. order.Spec = ""
  5341. order.SpecUnt = ""
  5342. order.DrordBegnDate = s_tm
  5343. order.DrordStopDate = ""
  5344. order.DrordDrCodg = doctor_info.DoctorNumber
  5345. order.DrordDeptName = department.Name
  5346. order.DrordDeptCodg = department.Number
  5347. order.DrordDrName = doctor_info.UserName
  5348. order.DrordDrProfttl = "234"
  5349. order.CurrDrordFlag = "1"
  5350. orders = append(orders, &order)
  5351. }
  5352. }
  5353. }
  5354. //处方医嘱信息
  5355. fed.MatnStas = "0"
  5356. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  5357. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  5358. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  5359. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  5360. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  5361. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  5362. fed.SetlTotlnum = "1"
  5363. fed.Insutype = his.Insutype
  5364. fed.ReimFlag = "0"
  5365. fed.OutSetlFlag = "0"
  5366. var fopd []*models.FsiOperationDtosData
  5367. data := make(map[string]interface{})
  5368. data["fed"] = fed
  5369. data["fdd"] = fdds
  5370. data["fod"] = orders
  5371. data["pd"] = pd
  5372. data["pp"] = pp
  5373. data["fopd"] = fopd
  5374. data["trig_scen"] = trig_scen
  5375. client := &http.Client{}
  5376. bytesData, _ := json.Marshal(data)
  5377. var req *http.Request
  5378. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5379. if miConfig.MdtrtareaAdmvs == "320921" {
  5380. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  5381. } else {
  5382. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  5383. }
  5384. resp, _ := client.Do(req)
  5385. defer resp.Body.Close()
  5386. body, ioErr := ioutil.ReadAll(resp.Body)
  5387. if ioErr != nil {
  5388. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5390. return res
  5391. }
  5392. var respJSON map[string]interface{}
  5393. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5396. return res
  5397. }
  5398. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5399. result, _ := json.Marshal(respJSON)
  5400. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5401. utils.ErrorLog("解析失败:%v", err)
  5402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5403. return res
  5404. }
  5405. return res
  5406. } else {
  5407. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5408. saveLog(output, input, "3102", "事中")
  5409. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5410. utils.ErrorLog("解析失败:%v", err)
  5411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5412. return
  5413. }
  5414. return res
  5415. }
  5416. return res
  5417. }
  5418. func Checkgd3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res2 Resultgd3101) {
  5419. var res Resultgd3101
  5420. adminUser := c.GetAdminUserInfo()
  5421. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5422. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5423. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5424. //record_time := c.GetString("record_time")
  5425. //trig_scen := c.GetString("trig_scen")
  5426. psn_info, _ := service.GetPsnByPatientId(patient_id)
  5427. timeLayout := "2006-01-02"
  5428. loc, _ := time.LoadLocation("Local")
  5429. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5430. if err != nil {
  5431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5432. return res
  5433. }
  5434. recordDateTime := theTime.Unix()
  5435. var patientPrescription models.HisPrescriptionInfo
  5436. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5437. //if patientPrescription.ID == 0 {
  5438. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5439. //}
  5440. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5441. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5442. //
  5443. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5444. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5445. var pp models.PublicParams
  5446. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5447. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5448. pp.FixmedinsName = miConfig.OrgName
  5449. pp.FixmedinsCode = miConfig.Code
  5450. pp.RequestUrl = miConfig.Url
  5451. pp.Cainfo = miConfig.Cainfo
  5452. pp.SecretKey = miConfig.SecretKey
  5453. pp.AccessKey = miConfig.AccessKey
  5454. pp.OpterName = roles.UserName
  5455. var config []*models.HisXtDiagnoseConfig
  5456. for _, item := range diagnosis_ids {
  5457. id, _ := strconv.ParseInt(item, 10, 64)
  5458. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5459. config = append(config, &diagnosisConfig)
  5460. }
  5461. var pd models.PatientDtos
  5462. pd.PatnID = his.PsnNo
  5463. pd.PatnName = his.Name
  5464. pd.Gend = his.Gend
  5465. pd.Brdy = psn_info.Brdy
  5466. pd.Poolarea = miConfig.MdtrtareaAdmvs
  5467. pd.CurrMdtrtID = his.Number
  5468. var fed models.FsiEncounterDtos
  5469. fed.MdtrtID = his.Number
  5470. fed.MedinsID = miConfig.Code
  5471. fed.MedinsName = miConfig.OrgName
  5472. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5473. fed.MedMdtrtType = "1"
  5474. fed.MedinsType = "1"
  5475. fed.MedinsLv = "11"
  5476. tm := time.Unix(his.RecordDate, 0)
  5477. s_tm := tm.Format("2006-01-02 15:04:05")
  5478. fed.AdmDate = s_tm
  5479. fed.DscgDate = s_tm
  5480. fed.DscgMainDiseCodg = config[0].CountryCode
  5481. fed.DscgMainDiseName = config[0].CountryContentName
  5482. //诊断信息
  5483. var fdds []*models.FsiDiagnoseDtos
  5484. for index, item := range config {
  5485. if index == 0 {
  5486. var fdd models.FsiDiagnoseDtos
  5487. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5488. fdd.InoutDiseType = "1"
  5489. fdd.MaindiseFlag = "1"
  5490. fdd.DiseDate = s_tm
  5491. fdd.DiasSrtNo = "1"
  5492. fdd.DiseName = item.CountryContentName
  5493. fdd.DiseCodg = item.CountryCode
  5494. fdds = append(fdds, &fdd)
  5495. } else {
  5496. var fdd models.FsiDiagnoseDtos
  5497. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5498. fdd.InoutDiseType = "1"
  5499. fdd.MaindiseFlag = "1"
  5500. fdd.DiseDate = s_tm
  5501. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5502. fdd.DiseName = item.CountryContentName
  5503. fdd.DiseCodg = item.CountryCode
  5504. fdds = append(fdds, &fdd)
  5505. }
  5506. }
  5507. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5508. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5509. fed.AdmDeptName = department.Name
  5510. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5511. fed.DscgDeptName = department.Name
  5512. fed.MedMdtrtType = "1"
  5513. fed.MedType = "11"
  5514. //if his.Insutype == "390" {
  5515. // fed.MedType = "1402"
  5516. //} else {
  5517. // fed.MedType = "9933"
  5518. //}
  5519. var orders []*models.FsiOrderDtos
  5520. if trig_scen == "2" {
  5521. //处方医嘱信息
  5522. for _, item := range prescriptions {
  5523. for _, subItem := range item.HisDoctorAdviceInfo {
  5524. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5525. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  5526. var order models.FsiOrderDtos
  5527. order.RxID = strconv.FormatInt(item.ID, 10)
  5528. order.Rxno = strconv.FormatInt(item.ID, 10)
  5529. order.LongDrordFlag = "0"
  5530. order.HilistType = "1"
  5531. order.ChrgType = "1"
  5532. order.DrordBhvr = "0"
  5533. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5534. order.HosplistName = subItem.BaseDrugLib.DrugName
  5535. order.HilistLv = "1"
  5536. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5537. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5538. order.HosplistName = subItem.BaseDrugLib.DrugName
  5539. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5540. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5541. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5542. order.OwnpayAmt = ""
  5543. order.SelfpayAmt = ""
  5544. order.Spec = spec
  5545. order.SpecUnt = subItem.PrescribingNumberUnit
  5546. order.DrordBegnDate = s_tm
  5547. order.DrordStopDate = ""
  5548. order.DrordDrCodg = doctor_info.DoctorNumber
  5549. order.DrordDeptName = department.Name
  5550. order.DrordDeptCodg = department.Number
  5551. order.DrordDrName = doctor_info.UserName
  5552. order.DrordDrProfttl = "234"
  5553. order.CurrDrordFlag = "1"
  5554. orders = append(orders, &order)
  5555. }
  5556. }
  5557. for _, subItem := range item.HisPrescriptionProject {
  5558. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5559. var order models.FsiOrderDtos
  5560. order.RxID = strconv.FormatInt(item.ID, 10)
  5561. order.Rxno = strconv.FormatInt(item.ID, 10)
  5562. order.LongDrordFlag = "0"
  5563. order.HilistType = "1"
  5564. order.ChrgType = "1"
  5565. order.DrordBhvr = "0"
  5566. order.HilistCode = subItem.HisProject.MedicalCode
  5567. order.HosplistName = subItem.HisProject.ProjectName
  5568. order.HilistLv = "1"
  5569. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5570. order.HosplistCode = subItem.HisProject.MedicalCode
  5571. order.HosplistName = subItem.HisProject.ProjectName
  5572. order.Cnt = subItem.Count
  5573. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5574. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5575. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5576. order.OwnpayAmt = ""
  5577. order.SelfpayAmt = ""
  5578. order.Spec = subItem.Unit
  5579. order.SpecUnt = subItem.Unit
  5580. order.DrordBegnDate = s_tm
  5581. order.DrordStopDate = ""
  5582. order.DrordDrCodg = doctor_info.DoctorNumber
  5583. order.DrordDeptName = department.Name
  5584. order.DrordDeptCodg = department.Number
  5585. order.DrordDrName = doctor_info.UserName
  5586. order.DrordDrProfttl = "234"
  5587. order.CurrDrordFlag = "1"
  5588. orders = append(orders, &order)
  5589. }
  5590. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5591. var order models.FsiOrderDtos
  5592. order.RxID = strconv.FormatInt(item.ID, 10)
  5593. order.Rxno = strconv.FormatInt(item.ID, 10)
  5594. order.LongDrordFlag = "0"
  5595. order.HilistType = "1"
  5596. order.ChrgType = "1"
  5597. order.DrordBhvr = "0"
  5598. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5599. order.HosplistName = subItem.GoodInfo.GoodName
  5600. order.HilistLv = "1"
  5601. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5602. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5603. order.HosplistName = subItem.GoodInfo.GoodName
  5604. order.Cnt = subItem.Count
  5605. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5606. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5607. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5608. order.OwnpayAmt = ""
  5609. order.SelfpayAmt = ""
  5610. order.Spec = subItem.GoodInfo.SpecificationName
  5611. order.SpecUnt = subItem.Unit
  5612. order.DrordBegnDate = s_tm
  5613. order.DrordStopDate = ""
  5614. order.DrordDrCodg = doctor_info.DoctorNumber
  5615. order.DrordDeptName = department.Name
  5616. order.DrordDeptCodg = department.Number
  5617. order.DrordDrName = doctor_info.UserName
  5618. order.DrordDrProfttl = "234"
  5619. order.CurrDrordFlag = "1"
  5620. orders = append(orders, &order)
  5621. }
  5622. }
  5623. }
  5624. //处方医嘱信息
  5625. }
  5626. fed.MatnStas = "0"
  5627. fed.MedfeeSumamt = "0"
  5628. fed.OwnpayAmt = "0"
  5629. fed.SelfpayAmt = "0"
  5630. fed.AcctPayamt = "0"
  5631. fed.MaAmt = "0"
  5632. fed.HifpPayamt = "0"
  5633. fed.SetlTotlnum = "1"
  5634. fed.Insutype = his.Insutype
  5635. fed.ReimFlag = "0"
  5636. fed.OutSetlFlag = "0"
  5637. var fopd []*models.FsiOperationDtosData
  5638. data := make(map[string]interface{})
  5639. data["fed"] = fed
  5640. data["fdd"] = fdds
  5641. data["fod"] = orders
  5642. data["pd"] = pd
  5643. data["pp"] = pp
  5644. data["fopd"] = fopd
  5645. data["trig_scen"] = trig_scen
  5646. fmt.Println(data)
  5647. fmt.Println(fed)
  5648. fmt.Println(fdds)
  5649. fmt.Println(orders)
  5650. fmt.Println(pd)
  5651. fmt.Println(pp)
  5652. fmt.Println(fopd)
  5653. client := &http.Client{}
  5654. bytesData, _ := json.Marshal(data)
  5655. var req *http.Request
  5656. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5657. if miConfig.MdtrtareaAdmvs == "320921" {
  5658. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5659. } else {
  5660. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5661. }
  5662. resp, _ := client.Do(req)
  5663. defer resp.Body.Close()
  5664. body, ioErr := ioutil.ReadAll(resp.Body)
  5665. if ioErr != nil {
  5666. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5668. return res
  5669. }
  5670. var respJSON map[string]interface{}
  5671. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5674. return res
  5675. }
  5676. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5677. fmt.Println(respJSON)
  5678. result, _ := json.Marshal(respJSON)
  5679. fmt.Println(result)
  5680. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5681. utils.ErrorLog("解析失败:%v", err)
  5682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5683. return res
  5684. }
  5685. return res
  5686. } else {
  5687. //if miConfig.MdtrtareaAdmvs == "441202" {
  5688. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5689. saveLog(output, input, "3101", "事前")
  5690. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5691. utils.ErrorLog("解析失败:%v", err)
  5692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5693. return
  5694. }
  5695. return res
  5696. //}
  5697. }
  5698. }
  5699. func Checkgd3101(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Resultgd3101) {
  5700. adminUser := c.GetAdminUserInfo()
  5701. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5702. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5703. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5704. //record_time := c.GetString("record_time")
  5705. //trig_scen := c.GetString("trig_scen")
  5706. psn_info, _ := service.GetPsnByPatientId(patient_id)
  5707. timeLayout := "2006-01-02"
  5708. loc, _ := time.LoadLocation("Local")
  5709. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5710. if err != nil {
  5711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5712. return res
  5713. }
  5714. recordDateTime := theTime.Unix()
  5715. var patientPrescription models.HisPrescriptionInfo
  5716. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5717. if patientPrescription.ID == 0 {
  5718. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5719. }
  5720. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5721. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5722. //
  5723. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5724. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5725. var pp models.PublicParams
  5726. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5727. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5728. pp.FixmedinsName = miConfig.OrgName
  5729. pp.FixmedinsCode = miConfig.Code
  5730. pp.RequestUrl = miConfig.Url
  5731. pp.Cainfo = miConfig.Cainfo
  5732. pp.SecretKey = miConfig.SecretKey
  5733. pp.AccessKey = miConfig.AccessKey
  5734. pp.OpterName = roles.UserName
  5735. var config []*models.HisXtDiagnoseConfig
  5736. for _, item := range diagnosis_ids {
  5737. id, _ := strconv.ParseInt(item, 10, 64)
  5738. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5739. config = append(config, &diagnosisConfig)
  5740. }
  5741. var pd models.PatientDtos
  5742. pd.PatnID = his.PsnNo
  5743. pd.PatnName = his.Name
  5744. pd.Gend = his.Gend
  5745. pd.Brdy = psn_info.Brdy
  5746. pd.Poolarea = his.InsuplcAdmdvs
  5747. pd.CurrMdtrtID = his.Number
  5748. var fed models.FsiEncounterDtos
  5749. fed.MdtrtID = his.Number
  5750. fed.MedinsID = miConfig.Code
  5751. fed.MedinsName = miConfig.OrgName
  5752. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5753. fed.MedMdtrtType = "1"
  5754. fed.MedinsType = "1"
  5755. fed.MedinsLv = "11"
  5756. tm := time.Unix(his.RecordDate, 0)
  5757. s_tm := tm.Format("2006-01-02 15:04:05")
  5758. fed.AdmDate = s_tm
  5759. fed.DscgDate = s_tm
  5760. fed.DscgMainDiseCodg = config[0].CountryCode
  5761. fed.DscgMainDiseName = config[0].CountryContentName
  5762. //诊断信息
  5763. var fdds []*models.FsiDiagnoseDtos
  5764. for index, item := range config {
  5765. if index == 0 {
  5766. var fdd models.FsiDiagnoseDtos
  5767. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5768. fdd.InoutDiseType = "1"
  5769. fdd.MaindiseFlag = "1"
  5770. fdd.DiseDate = s_tm
  5771. fdd.DiasSrtNo = "1"
  5772. fdd.DiseName = item.CountryContentName
  5773. fdd.DiseCodg = item.CountryCode
  5774. fdds = append(fdds, &fdd)
  5775. } else {
  5776. var fdd models.FsiDiagnoseDtos
  5777. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5778. fdd.InoutDiseType = "1"
  5779. fdd.MaindiseFlag = "1"
  5780. fdd.DiseDate = s_tm
  5781. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5782. fdd.DiseName = item.CountryContentName
  5783. fdd.DiseCodg = item.CountryCode
  5784. fdds = append(fdds, &fdd)
  5785. }
  5786. }
  5787. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5788. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5789. fed.AdmDeptName = department.Name
  5790. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5791. fed.DscgDeptName = department.Name
  5792. fed.MedMdtrtType = "1"
  5793. fed.MedType = "11"
  5794. //if his.Insutype == "390" {
  5795. // fed.MedType = "1402"
  5796. //} else {
  5797. // fed.MedType = "9933"
  5798. //}
  5799. var orders []*models.FsiOrderDtos
  5800. if trig_scen == "2" {
  5801. //处方医嘱信息
  5802. for _, item := range prescriptions {
  5803. for _, subItem := range item.HisDoctorAdviceInfo {
  5804. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5805. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  5806. var order models.FsiOrderDtos
  5807. order.RxID = strconv.FormatInt(item.ID, 10)
  5808. order.Rxno = strconv.FormatInt(item.ID, 10)
  5809. order.LongDrordFlag = "0"
  5810. order.HilistType = "1"
  5811. order.ChrgType = "1"
  5812. order.DrordBhvr = "0"
  5813. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5814. order.HosplistName = subItem.BaseDrugLib.DrugName
  5815. order.HilistLv = "1"
  5816. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5817. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5818. order.HosplistName = subItem.BaseDrugLib.DrugName
  5819. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5820. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5821. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5822. order.OwnpayAmt = ""
  5823. order.SelfpayAmt = ""
  5824. order.Spec = spec
  5825. order.SpecUnt = subItem.PrescribingNumberUnit
  5826. order.DrordBegnDate = s_tm
  5827. order.DrordStopDate = ""
  5828. order.DrordDrCodg = doctor_info.DoctorNumber
  5829. order.DrordDeptName = department.Name
  5830. order.DrordDeptCodg = department.Number
  5831. order.DrordDrName = doctor_info.UserName
  5832. order.DrordDrProfttl = "234"
  5833. order.CurrDrordFlag = "1"
  5834. orders = append(orders, &order)
  5835. }
  5836. }
  5837. for _, subItem := range item.HisPrescriptionProject {
  5838. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5839. var order models.FsiOrderDtos
  5840. order.RxID = strconv.FormatInt(item.ID, 10)
  5841. order.Rxno = strconv.FormatInt(item.ID, 10)
  5842. order.LongDrordFlag = "0"
  5843. order.HilistType = "1"
  5844. order.ChrgType = "1"
  5845. order.DrordBhvr = "0"
  5846. order.HilistCode = subItem.HisProject.MedicalCode
  5847. order.HosplistName = subItem.HisProject.ProjectName
  5848. order.HilistLv = "1"
  5849. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5850. order.HosplistCode = subItem.HisProject.MedicalCode
  5851. order.HosplistName = subItem.HisProject.ProjectName
  5852. order.Cnt = subItem.Count
  5853. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5854. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5855. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5856. order.OwnpayAmt = ""
  5857. order.SelfpayAmt = ""
  5858. order.Spec = subItem.Unit
  5859. order.SpecUnt = subItem.Unit
  5860. order.DrordBegnDate = s_tm
  5861. order.DrordStopDate = ""
  5862. order.DrordDrCodg = doctor_info.DoctorNumber
  5863. order.DrordDeptName = department.Name
  5864. order.DrordDeptCodg = department.Number
  5865. order.DrordDrName = doctor_info.UserName
  5866. order.DrordDrProfttl = "234"
  5867. order.CurrDrordFlag = "1"
  5868. orders = append(orders, &order)
  5869. }
  5870. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0{
  5871. var order models.FsiOrderDtos
  5872. order.RxID = strconv.FormatInt(item.ID, 10)
  5873. order.Rxno = strconv.FormatInt(item.ID, 10)
  5874. order.LongDrordFlag = "0"
  5875. order.HilistType = "1"
  5876. order.ChrgType = "1"
  5877. order.DrordBhvr = "0"
  5878. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5879. order.HosplistName = subItem.GoodInfo.GoodName
  5880. order.HilistLv = "1"
  5881. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5882. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5883. order.HosplistName = subItem.GoodInfo.GoodName
  5884. order.Cnt = subItem.Count
  5885. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5886. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5887. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5888. order.OwnpayAmt = ""
  5889. order.SelfpayAmt = ""
  5890. order.Spec = subItem.GoodInfo.SpecificationName
  5891. order.SpecUnt = subItem.Unit
  5892. order.DrordBegnDate = s_tm
  5893. order.DrordStopDate = ""
  5894. order.DrordDrCodg = doctor_info.DoctorNumber
  5895. order.DrordDeptName = department.Name
  5896. order.DrordDeptCodg = department.Number
  5897. order.DrordDrName = doctor_info.UserName
  5898. order.DrordDrProfttl = "234"
  5899. order.CurrDrordFlag = "1"
  5900. orders = append(orders, &order)
  5901. }
  5902. }
  5903. }
  5904. //处方医嘱信息
  5905. }
  5906. fed.MatnStas = "0"
  5907. fed.MedfeeSumamt = "0"
  5908. fed.OwnpayAmt = "0"
  5909. fed.SelfpayAmt = "0"
  5910. fed.AcctPayamt = "0"
  5911. fed.MaAmt = "0"
  5912. fed.HifpPayamt = "0"
  5913. fed.SetlTotlnum = "1"
  5914. fed.Insutype = his.Insutype
  5915. fed.ReimFlag = "0"
  5916. fed.OutSetlFlag = "0"
  5917. var fopd []*models.FsiOperationDtosData
  5918. data := make(map[string]interface{})
  5919. data["fed"] = fed
  5920. data["fdd"] = fdds
  5921. data["fod"] = orders
  5922. data["pd"] = pd
  5923. data["pp"] = pp
  5924. data["fopd"] = fopd
  5925. data["trig_scen"] = trig_scen
  5926. fmt.Println(data)
  5927. fmt.Println(fed)
  5928. fmt.Println(fdds)
  5929. fmt.Println(orders)
  5930. fmt.Println(pd)
  5931. fmt.Println(pp)
  5932. fmt.Println(fopd)
  5933. client := &http.Client{}
  5934. bytesData, _ := json.Marshal(data)
  5935. var req *http.Request
  5936. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5937. if miConfig.MdtrtareaAdmvs == "320921" {
  5938. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5939. } else {
  5940. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5941. }
  5942. resp, _ := client.Do(req)
  5943. defer resp.Body.Close()
  5944. body, ioErr := ioutil.ReadAll(resp.Body)
  5945. if ioErr != nil {
  5946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5948. return res
  5949. }
  5950. var respJSON map[string]interface{}
  5951. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5954. return res
  5955. }
  5956. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5957. fmt.Println(respJSON)
  5958. result, _ := json.Marshal(respJSON)
  5959. fmt.Println(result)
  5960. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5961. utils.ErrorLog("解析失败:%v", err)
  5962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5963. return res
  5964. }
  5965. return res
  5966. } else {
  5967. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5968. saveLog(output, input, "3101", "事前")
  5969. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5970. utils.ErrorLog("解析失败:%v", err)
  5971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5972. return
  5973. }
  5974. return res
  5975. }
  5976. return res
  5977. }
  5978. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  5979. ////patient_id, _ := c.GetInt64("patient_id")
  5980. //order_id, _ := c.GetInt64("order_id")
  5981. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  5982. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  5983. //trig_scen := c.GetString("trig_scen")
  5984. psn_info, _ := service.GetPsnByPatientId(patient_id)
  5985. utils.ErrorLog("解析失败:%v", psn_info)
  5986. adminUser := c.GetAdminUserInfo()
  5987. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5988. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5989. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5990. record_time := c.GetString("record_time")
  5991. order, _ := service.GetHisOrderByID(order_id)
  5992. timeLayout := "2006-01-02"
  5993. loc, _ := time.LoadLocation("Local")
  5994. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5995. if err != nil {
  5996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5997. return
  5998. }
  5999. recordDateTime := theTime.Unix()
  6000. var patientPrescription models.HisPrescriptionInfo
  6001. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6002. if patientPrescription.ID == 0 {
  6003. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6004. }
  6005. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6006. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6007. //
  6008. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6009. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6010. var pp models.PublicParams
  6011. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6012. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6013. pp.FixmedinsName = miConfig.OrgName
  6014. pp.FixmedinsCode = miConfig.Code
  6015. pp.RequestUrl = miConfig.Url
  6016. pp.Cainfo = miConfig.Cainfo
  6017. pp.SecretKey = miConfig.SecretKey
  6018. pp.AccessKey = miConfig.AccessKey
  6019. pp.OpterName = roles.UserName
  6020. var config []*models.HisXtDiagnoseConfig
  6021. for _, item := range diagnosis_ids {
  6022. id, _ := strconv.ParseInt(item, 10, 64)
  6023. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6024. config = append(config, &diagnosisConfig)
  6025. }
  6026. var pd models.PatientDtos
  6027. pd.PatnID = his.PsnNo
  6028. pd.PatnName = his.Name
  6029. pd.Gend = his.Gend
  6030. pd.Brdy = psn_info.Brdy
  6031. pd.Poolarea = his.InsuplcAdmdvs
  6032. pd.CurrMdtrtID = his.Number
  6033. var fed models.FsiEncounterDtos
  6034. fed.MdtrtID = his.Number
  6035. fed.MedinsID = miConfig.Code
  6036. fed.MedinsName = miConfig.OrgName
  6037. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6038. fed.MedMdtrtType = "1"
  6039. fed.MedinsType = "1"
  6040. fed.MedinsLv = "11"
  6041. tm := time.Unix(his.RecordDate, 0)
  6042. s_tm := tm.Format("2006-01-02 15:04:05")
  6043. fed.AdmDate = s_tm
  6044. fed.DscgDate = s_tm
  6045. fed.DscgMainDiseCodg = config[0].CountryCode
  6046. fed.DscgMainDiseName = config[0].CountryContentName
  6047. //诊断信息
  6048. var fdds []*models.FsiDiagnoseDtos
  6049. for index, item := range config {
  6050. if index == 0 {
  6051. var fdd models.FsiDiagnoseDtos
  6052. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6053. fdd.InoutDiseType = "1"
  6054. fdd.MaindiseFlag = "1"
  6055. fdd.DiseDate = s_tm
  6056. fdd.DiasSrtNo = "1"
  6057. fdd.DiseName = item.CountryContentName
  6058. fdd.DiseCodg = item.CountryCode
  6059. fdds = append(fdds, &fdd)
  6060. } else {
  6061. var fdd models.FsiDiagnoseDtos
  6062. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6063. fdd.InoutDiseType = "1"
  6064. fdd.MaindiseFlag = "1"
  6065. fdd.DiseDate = s_tm
  6066. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6067. fdd.DiseName = item.CountryContentName
  6068. fdd.DiseCodg = item.CountryCode
  6069. fdds = append(fdds, &fdd)
  6070. }
  6071. }
  6072. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6073. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6074. fed.AdmDeptName = department.Name
  6075. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6076. fed.DscgDeptName = department.Name
  6077. fed.MedType = order.MedType
  6078. //处方医嘱信息
  6079. var orders []*models.FsiOrderDtos
  6080. //for _, item := range prescriptions {
  6081. // for _, subItem := range item.HisDoctorAdviceInfo {
  6082. // var order models.FsiOrderDtos
  6083. // order.RxID = strconv.FormatInt(item.ID, 10)
  6084. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6085. // order.LongDrordFlag = "0"
  6086. // order.HilistType = "1"
  6087. // order.ChrgType = "1"
  6088. // order.DrordBhvr = "-"
  6089. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6090. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6091. // order.HilistLv = "1"
  6092. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6093. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6094. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6095. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  6096. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6097. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  6098. // order.OwnpayAmt = ""
  6099. // order.SelfpayAmt = ""
  6100. // order.Spec = ""
  6101. // order.SpecUnt = ""
  6102. // order.DrordBegnDate = s_tm
  6103. // order.DrordStopDate = ""
  6104. // order.DrordDrCodg = "1"
  6105. // order.DrordDeptName = department.Name
  6106. // order.DrordDrCodg = "1"
  6107. // order.DrordDrName = doctor_info.UserName
  6108. // order.DrordDrProfttl = ""
  6109. // order.CurrDrordFlag = "1"
  6110. // orders = append(orders, &order)
  6111. // }
  6112. // for _, subItem := range item.HisPrescriptionProject {
  6113. // if subItem.Type == 2 {
  6114. // var order models.FsiOrderDtos
  6115. // order.RxID = strconv.FormatInt(item.ID, 10)
  6116. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6117. // order.LongDrordFlag = "0"
  6118. // order.HilistType = "1"
  6119. // order.ChrgType = "1"
  6120. // order.DrordBhvr = "-"
  6121. // order.HilistCode = subItem.HisProject.MedicalCode
  6122. // order.HosplistName = subItem.HisProject.ProjectName
  6123. // order.HilistLv = "1"
  6124. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6125. // order.HosplistCode = subItem.HisProject.MedicalCode
  6126. // order.HosplistName = subItem.HisProject.ProjectName
  6127. // order.Cnt = subItem.Count
  6128. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6129. //
  6130. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6131. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6132. // order.OwnpayAmt = ""
  6133. // order.SelfpayAmt = ""
  6134. // order.Spec = ""
  6135. // order.SpecUnt = ""
  6136. // order.DrordBegnDate = s_tm
  6137. // order.DrordStopDate = ""
  6138. // order.DrordDrCodg = "1"
  6139. // order.DrordDeptName = department.Name
  6140. // order.DrordDrCodg = "1"
  6141. // order.DrordDrName = doctor_info.UserName
  6142. // order.DrordDrProfttl = ""
  6143. // order.CurrDrordFlag = "1"
  6144. // orders = append(orders, &order)
  6145. //
  6146. // }
  6147. // if subItem.Type == 3 {
  6148. //
  6149. // var order models.FsiOrderDtos
  6150. // order.RxID = strconv.FormatInt(item.ID, 10)
  6151. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6152. // order.LongDrordFlag = "0"
  6153. // order.HilistType = "1"
  6154. // order.ChrgType = "1"
  6155. // order.DrordBhvr = "-"
  6156. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6157. // order.HosplistName = subItem.GoodInfo.GoodName
  6158. // order.HilistLv = "1"
  6159. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6160. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6161. // order.HosplistName = subItem.GoodInfo.GoodName
  6162. // order.Cnt = subItem.Count
  6163. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6164. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6165. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6166. // order.OwnpayAmt = ""
  6167. // order.SelfpayAmt = ""
  6168. // order.Spec = ""
  6169. // order.SpecUnt = ""
  6170. // order.DrordBegnDate = s_tm
  6171. // order.DrordStopDate = ""
  6172. // order.DrordDrCodg = "1"
  6173. // order.DrordDeptName = department.Name
  6174. // order.DrordDrCodg = "1"
  6175. // order.DrordDrName = doctor_info.UserName
  6176. // order.DrordDrProfttl = ""
  6177. // order.CurrDrordFlag = "1"
  6178. // orders = append(orders, &order)
  6179. //
  6180. // }
  6181. // }
  6182. //}
  6183. for _, item := range prescriptions {
  6184. for _, subItem := range item.HisDoctorAdviceInfo {
  6185. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6186. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6187. var order models.FsiOrderDtos
  6188. order.RxID = strconv.FormatInt(item.ID, 10)
  6189. order.Rxno = strconv.FormatInt(item.ID, 10)
  6190. order.LongDrordFlag = "0"
  6191. order.HilistType = "1"
  6192. order.ChrgType = "1"
  6193. order.DrordBhvr = "0"
  6194. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6195. order.HosplistName = subItem.BaseDrugLib.DrugName
  6196. order.HilistLv = "1"
  6197. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6198. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6199. order.HosplistName = subItem.BaseDrugLib.DrugName
  6200. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6201. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6202. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6203. order.OwnpayAmt = ""
  6204. order.SelfpayAmt = ""
  6205. order.Spec = spec
  6206. order.SpecUnt = subItem.PrescribingNumberUnit
  6207. order.DrordBegnDate = s_tm
  6208. order.DrordStopDate = ""
  6209. order.DrordDrCodg = doctor_info.DoctorNumber
  6210. order.DrordDeptName = department.Name
  6211. order.DrordDeptCodg = department.Number
  6212. order.DrordDrName = doctor_info.UserName
  6213. order.DrordDrProfttl = "234"
  6214. order.CurrDrordFlag = "1"
  6215. orders = append(orders, &order)
  6216. }
  6217. }
  6218. for _, subItem := range item.HisPrescriptionProject {
  6219. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6220. var order models.FsiOrderDtos
  6221. order.RxID = strconv.FormatInt(item.ID, 10)
  6222. order.Rxno = strconv.FormatInt(item.ID, 10)
  6223. order.LongDrordFlag = "0"
  6224. order.HilistType = "1"
  6225. order.ChrgType = "1"
  6226. order.DrordBhvr = "0"
  6227. order.HilistCode = subItem.HisProject.MedicalCode
  6228. order.HosplistName = subItem.HisProject.ProjectName
  6229. order.HilistLv = "1"
  6230. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6231. order.HosplistCode = subItem.HisProject.MedicalCode
  6232. order.HosplistName = subItem.HisProject.ProjectName
  6233. order.Cnt = subItem.Count
  6234. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6235. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6236. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6237. order.OwnpayAmt = ""
  6238. order.SelfpayAmt = ""
  6239. order.Spec = subItem.Unit
  6240. order.SpecUnt = subItem.Unit
  6241. order.DrordBegnDate = s_tm
  6242. order.DrordStopDate = ""
  6243. order.DrordDrCodg = doctor_info.DoctorNumber
  6244. order.DrordDeptName = department.Name
  6245. order.DrordDeptCodg = department.Number
  6246. order.DrordDrName = doctor_info.UserName
  6247. order.DrordDrProfttl = "234"
  6248. order.CurrDrordFlag = "1"
  6249. orders = append(orders, &order)
  6250. }
  6251. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6252. var order models.FsiOrderDtos
  6253. order.RxID = strconv.FormatInt(item.ID, 10)
  6254. order.Rxno = strconv.FormatInt(item.ID, 10)
  6255. order.LongDrordFlag = "0"
  6256. order.HilistType = "1"
  6257. order.ChrgType = "1"
  6258. order.DrordBhvr = "0"
  6259. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6260. order.HosplistName = subItem.GoodInfo.GoodName
  6261. order.HilistLv = "1"
  6262. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6263. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6264. order.HosplistName = subItem.GoodInfo.GoodName
  6265. order.Cnt = subItem.Count
  6266. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6267. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6268. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6269. order.OwnpayAmt = ""
  6270. order.SelfpayAmt = ""
  6271. order.Spec = subItem.GoodInfo.SpecificationName
  6272. order.SpecUnt = subItem.Unit
  6273. order.DrordBegnDate = s_tm
  6274. order.DrordStopDate = ""
  6275. order.DrordDrCodg = doctor_info.DoctorNumber
  6276. order.DrordDeptName = department.Name
  6277. order.DrordDeptCodg = department.Number
  6278. order.DrordDrName = doctor_info.UserName
  6279. order.DrordDrProfttl = "234"
  6280. order.CurrDrordFlag = "1"
  6281. orders = append(orders, &order)
  6282. }
  6283. }
  6284. }
  6285. //处方医嘱信息
  6286. fed.MatnStas = "0"
  6287. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  6288. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  6289. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  6290. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  6291. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  6292. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  6293. fed.SetlTotlnum = "1"
  6294. fed.Insutype = his.Insutype
  6295. fed.ReimFlag = "0"
  6296. fed.OutSetlFlag = "0"
  6297. var fopd []*models.FsiOperationDtosData
  6298. data := make(map[string]interface{})
  6299. data["fed"] = fed
  6300. data["fdd"] = fdds
  6301. data["fod"] = orders
  6302. data["pd"] = pd
  6303. data["pp"] = pp
  6304. data["fopd"] = fopd
  6305. data["trig_scen"] = trig_scen
  6306. client := &http.Client{}
  6307. bytesData, _ := json.Marshal(data)
  6308. var req *http.Request
  6309. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6310. if miConfig.MdtrtareaAdmvs == "320921" {
  6311. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6312. } else {
  6313. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6314. }
  6315. resp, _ := client.Do(req)
  6316. defer resp.Body.Close()
  6317. body, ioErr := ioutil.ReadAll(resp.Body)
  6318. if ioErr != nil {
  6319. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6321. return res
  6322. }
  6323. var respJSON map[string]interface{}
  6324. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6325. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6327. return res
  6328. }
  6329. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6330. result, _ := json.Marshal(respJSON)
  6331. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6332. utils.ErrorLog("解析失败:%v", err)
  6333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6334. return res
  6335. }
  6336. return res
  6337. } else {
  6338. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6339. saveLog(output, input, "3102", "事中")
  6340. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6341. utils.ErrorLog("解析失败:%v", err)
  6342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6343. return
  6344. }
  6345. return res
  6346. }
  6347. return res
  6348. }
  6349. func (c *HisApiController) Check() {
  6350. psn_no := c.GetString("psn_no")
  6351. in := c.GetString("in")
  6352. mt := c.GetString("mt")
  6353. baseParams := models.BaseParams{
  6354. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  6355. FixmedinsCode: "H15049901371",
  6356. InsuplcAdmdvs: "150499",
  6357. MdtrtareaAdmvs: "150499",
  6358. OrgName: "赤峰费森血液透析中心",
  6359. Doctor: "1111",
  6360. }
  6361. service.Gdyb2001(baseParams, psn_no, in, mt)
  6362. }
  6363. func (c *HisApiController) GetPsnNcdsInfo() {
  6364. admin_user_id, _ := c.GetInt64("admin_user_id")
  6365. patient_id, _ := c.GetInt64("patient_id")
  6366. id, _ := c.GetInt64("id")
  6367. adminUser := c.GetAdminUserInfo()
  6368. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6369. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6370. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  6371. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6372. psn_record, _ := service.GetPsnNCDSRecordById(id)
  6373. //
  6374. //if psn_record.ID == 0 {
  6375. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  6376. // return
  6377. //}
  6378. var res Result5301
  6379. var res10265 Result5301For10265
  6380. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6381. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6382. var api string
  6383. if miConfig.MdtrtareaAdmvs == "320921" {
  6384. api = "http://192.168.2.3:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  6385. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  6386. } else {
  6387. 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 +
  6388. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  6389. }
  6390. resp, requestErr := http.Get(api)
  6391. if requestErr != nil {
  6392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6393. return
  6394. }
  6395. body, ioErr := ioutil.ReadAll(resp.Body)
  6396. if ioErr != nil {
  6397. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6399. return
  6400. }
  6401. var respJSON map[string]interface{}
  6402. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6403. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6405. return
  6406. }
  6407. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6408. result, _ := json.Marshal(respJSON)
  6409. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6410. utils.ErrorLog("解析失败:%v", err)
  6411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6412. return
  6413. }
  6414. res.ErrMsg = res10265.ErrMsg
  6415. res.Output = res10265.Output
  6416. res.InfRefmsgid = res10265.InfRefmsgid
  6417. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  6418. res.Infcode = infocode
  6419. } else if miConfig.MdtrtareaAdmvs == "341203"{
  6420. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6421. var api string
  6422. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  6423. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  6424. resp, requestErr := http.Get(api)
  6425. if requestErr != nil {
  6426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6427. return
  6428. }
  6429. body, ioErr := ioutil.ReadAll(resp.Body)
  6430. if ioErr != nil {
  6431. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6433. return
  6434. }
  6435. var respJSON map[string]interface{}
  6436. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6437. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6439. return
  6440. }
  6441. status := respJSON["data"].(map[string]interface{})["status"].(string)
  6442. if status == "0"{
  6443. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  6444. c.ServeSuccessJSON(map[string]interface{}{
  6445. "failed_code": -10,
  6446. "msg": err_msg,
  6447. })
  6448. return
  6449. }
  6450. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6451. result, _ := json.Marshal(respJSON)
  6452. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6453. utils.ErrorLog("解析失败:%v", err)
  6454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6455. return
  6456. }
  6457. } else if miConfig.MdtrtareaAdmvs == "360302" {
  6458. p, _ := service.GetHisPatientById(patient_id)
  6459. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  6460. var dat map[string]interface{}
  6461. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6462. fmt.Println(dat)
  6463. } else {
  6464. fmt.Println(err)
  6465. }
  6466. userJSONBytes, _ := json.Marshal(dat)
  6467. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6468. utils.ErrorLog("解析失败:%v", err)
  6469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6470. return
  6471. }
  6472. } else if miConfig.MdtrtareaAdmvs == "430800" {
  6473. p, _ := service.GetHisPatientById(patient_id)
  6474. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  6475. var dat map[string]interface{}
  6476. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6477. fmt.Println(dat)
  6478. } else {
  6479. fmt.Println(err)
  6480. }
  6481. userJSONBytes, _ := json.Marshal(dat)
  6482. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6483. utils.ErrorLog("解析失败:%v", err)
  6484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6485. return
  6486. }
  6487. } else if miConfig.MdtrtareaAdmvs == "420200" {
  6488. p, _ := service.GetHisPatientById(patient_id)
  6489. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  6490. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  6491. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6492. resp, requestErr := http.Get(api)
  6493. if requestErr != nil {
  6494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6495. return
  6496. }
  6497. body, ioErr := ioutil.ReadAll(resp.Body)
  6498. if ioErr != nil {
  6499. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6501. return
  6502. }
  6503. var respJSON map[string]interface{}
  6504. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6507. return
  6508. }
  6509. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6510. result, _ := json.Marshal(respJSON)
  6511. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6512. utils.ErrorLog("解析失败:%v", err)
  6513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6514. return
  6515. }
  6516. } else if miConfig.MdtrtareaAdmvs == "421182" {
  6517. p, _ := service.GetHisPatientById(patient_id)
  6518. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  6519. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  6520. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6521. resp, requestErr := http.Get(api)
  6522. if requestErr != nil {
  6523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6524. return
  6525. }
  6526. body, ioErr := ioutil.ReadAll(resp.Body)
  6527. if ioErr != nil {
  6528. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6530. return
  6531. }
  6532. var respJSON map[string]interface{}
  6533. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6534. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6536. return
  6537. }
  6538. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6539. result, _ := json.Marshal(respJSON)
  6540. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6541. utils.ErrorLog("解析失败:%v", err)
  6542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6543. return
  6544. }
  6545. } else if miConfig.MdtrtareaAdmvs == "421300" {
  6546. p, _ := service.GetHisPatientById(patient_id)
  6547. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  6548. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  6549. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6550. resp, requestErr := http.Get(api)
  6551. if requestErr != nil {
  6552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6553. return
  6554. }
  6555. body, ioErr := ioutil.ReadAll(resp.Body)
  6556. if ioErr != nil {
  6557. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6559. return
  6560. }
  6561. var respJSON map[string]interface{}
  6562. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6565. return
  6566. }
  6567. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6568. result, _ := json.Marshal(respJSON)
  6569. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6570. utils.ErrorLog("解析失败:%v", err)
  6571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6572. return
  6573. }
  6574. } else if miConfig.MdtrtareaAdmvs == "441799" {
  6575. p, _ := service.GetHisPatientById(patient_id)
  6576. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  6577. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  6578. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6579. resp, requestErr := http.Get(api)
  6580. if requestErr != nil {
  6581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6582. return
  6583. }
  6584. body, ioErr := ioutil.ReadAll(resp.Body)
  6585. if ioErr != nil {
  6586. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6588. return
  6589. }
  6590. var respJSON map[string]interface{}
  6591. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6592. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6594. return
  6595. }
  6596. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6597. result, _ := json.Marshal(respJSON)
  6598. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6599. utils.ErrorLog("解析失败:%v", err)
  6600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6601. return
  6602. }
  6603. } else {
  6604. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  6605. var dat map[string]interface{}
  6606. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6607. fmt.Println(dat)
  6608. } else {
  6609. fmt.Println(err)
  6610. }
  6611. userJSONBytes, _ := json.Marshal(dat)
  6612. if miConfig.Code == "H15049901371" {
  6613. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  6614. utils.ErrorLog("解析失败:%v", err)
  6615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6616. return
  6617. }
  6618. res.InfRefmsgid = res10265.InfRefmsgid
  6619. res.Output = res10265.Output
  6620. res.ErrMsg = res10265.ErrMsg
  6621. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  6622. res.Infcode = infocode
  6623. } else {
  6624. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6625. utils.ErrorLog("解析失败:%v", err)
  6626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6627. return
  6628. }
  6629. }
  6630. }
  6631. if res.Infcode == 0 {
  6632. c.ServeSuccessJSON(map[string]interface{}{
  6633. "result": res.Output.Result,
  6634. })
  6635. }
  6636. }
  6637. func (c *HisApiController) CheckInsutype() {
  6638. his_patient_id, _ := c.GetInt64("his_patient_id")
  6639. admin_user_id, _ := c.GetInt64("admin_user_id")
  6640. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6641. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6642. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6643. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  6644. var dat map[string]interface{}
  6645. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6646. fmt.Println(dat)
  6647. } else {
  6648. fmt.Println(err)
  6649. }
  6650. userJSONBytes, _ := json.Marshal(dat)
  6651. var res Result90100
  6652. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6653. utils.ErrorLog("解析失败:%v", err)
  6654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6655. return
  6656. }
  6657. if res.Infcode != 0 {
  6658. c.ServeSuccessJSON(map[string]interface{}{
  6659. "failed_code": -10,
  6660. "msg": res.ErrMsg,
  6661. })
  6662. return
  6663. } else {
  6664. fmt.Println(res)
  6665. }
  6666. }
  6667. func (c *HisApiController) CheckCardPWD() {
  6668. card_pwd := c.GetString("card_pwd")
  6669. his_patient_id, _ := c.GetInt64("his_patient_id")
  6670. admin_user_id, _ := c.GetInt64("admin_user_id")
  6671. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6672. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6673. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6674. psn, _ := service.GetPsnByPatientId(his.PatientId)
  6675. bas := strings.Split(psn.CardInfo, "|")
  6676. basNumber := bas[2]
  6677. if psn.InsuplcAdmdvs[:4] == "4403" {
  6678. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  6679. var dat map[string]interface{}
  6680. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6681. fmt.Println(dat)
  6682. } else {
  6683. fmt.Println(err)
  6684. }
  6685. userJSONBytes, _ := json.Marshal(dat)
  6686. var res Result90991
  6687. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6688. utils.ErrorLog("解析失败:%v", err)
  6689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6690. return
  6691. }
  6692. if res.Infcode != 0 {
  6693. c.ServeSuccessJSON(map[string]interface{}{
  6694. "failed_code": -10,
  6695. "msg": res.ErrMsg,
  6696. })
  6697. return
  6698. } else {
  6699. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  6700. var msg string
  6701. switch res.Output.Result.CardStat {
  6702. case "00":
  6703. msg = "未激活"
  6704. break
  6705. case "10":
  6706. msg = "激活"
  6707. break
  6708. case "20":
  6709. msg = "窗口挂失"
  6710. break
  6711. case "21":
  6712. msg = "电话挂失"
  6713. break
  6714. case "22":
  6715. msg = "单位网上申报挂失"
  6716. break
  6717. case "23":
  6718. msg = "保健办挂失"
  6719. break
  6720. case "24":
  6721. msg = "个人网上挂失"
  6722. break
  6723. case "25":
  6724. msg = "网上服务大厅挂失"
  6725. break
  6726. case "30":
  6727. msg = "注销"
  6728. break
  6729. case "40":
  6730. msg = "回收"
  6731. break
  6732. case "99":
  6733. msg = "制卡中(无效卡)"
  6734. break
  6735. }
  6736. c.ServeSuccessJSON(map[string]interface{}{
  6737. "failed_code": -10,
  6738. "msg": msg,
  6739. })
  6740. return
  6741. } else {
  6742. c.ServeSuccessJSON(map[string]interface{}{
  6743. "msg": "校验成功",
  6744. })
  6745. return
  6746. }
  6747. }
  6748. } else {
  6749. c.ServeSuccessJSON(map[string]interface{}{
  6750. "msg": "校验成功",
  6751. })
  6752. return
  6753. }
  6754. }
  6755. func (c *HisApiController) CheckCardPWDTwo() {
  6756. //card_pwd := c.GetString("card_pwd")
  6757. //his_patient_id, _ := c.GetInt64("his_patient_id")
  6758. admin_user_id, _ := c.GetInt64("admin_user_id")
  6759. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6760. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6761. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  6762. var dat map[string]interface{}
  6763. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6764. fmt.Println(dat)
  6765. } else {
  6766. fmt.Println(err)
  6767. }
  6768. userJSONBytes, _ := json.Marshal(dat)
  6769. var res Result90991
  6770. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6771. utils.ErrorLog("解析失败:%v", err)
  6772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6773. return
  6774. }
  6775. if res.Infcode != 0 {
  6776. c.ServeSuccessJSON(map[string]interface{}{
  6777. "failed_code": -10,
  6778. "msg": res.ErrMsg,
  6779. })
  6780. return
  6781. } else {
  6782. if res.Output.Result.SscnoCheckStat == "0" {
  6783. var msg string
  6784. switch res.Output.Result.CardStat {
  6785. case "00":
  6786. msg = "未激活"
  6787. break
  6788. case "10":
  6789. msg = "激活"
  6790. break
  6791. case "20":
  6792. msg = "窗口挂失"
  6793. break
  6794. case "21":
  6795. msg = "电话挂失"
  6796. break
  6797. case "22":
  6798. msg = "单位网上申报挂失"
  6799. break
  6800. case "23":
  6801. msg = "保健办挂失"
  6802. break
  6803. case "24":
  6804. msg = "个人网上挂失"
  6805. break
  6806. case "25":
  6807. msg = "网上服务大厅挂失"
  6808. break
  6809. case "30":
  6810. msg = "注销"
  6811. break
  6812. case "40":
  6813. msg = "回收"
  6814. break
  6815. case "99":
  6816. msg = "制卡中(无效卡)"
  6817. break
  6818. }
  6819. c.ServeSuccessJSON(map[string]interface{}{
  6820. "failed_code": -10,
  6821. "msg": msg,
  6822. })
  6823. return
  6824. } else {
  6825. c.ServeSuccessJSON(map[string]interface{}{
  6826. "msg": "校验成功",
  6827. })
  6828. return
  6829. }
  6830. }
  6831. }
  6832. type ELeCertData struct {
  6833. Data struct {
  6834. Extra string `json:"extra"`
  6835. IDNo string `json:"idNo"`
  6836. IDType string `json:"idType"`
  6837. EcToken string `json:"ecToken"`
  6838. InsuOrg string `json:"insuOrg"`
  6839. UserName string `json:"userName"`
  6840. EcIndexNo string `json:"ecIndexNo"`
  6841. Gender string `json:"gender"`
  6842. Birthday string `json:"birthday"`
  6843. Nationality string `json:"nationality"`
  6844. Email string `json:"email"`
  6845. } `json:"OutData"`
  6846. }
  6847. func (c *HisApiController) ReadCard() {
  6848. id_card_type, _ := c.GetInt64("id_card_type")
  6849. admin_user_id, _ := c.GetInt64("admin_user_id")
  6850. certificates, _ := c.GetInt64("certificates")
  6851. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  6852. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6853. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6854. switch id_card_type {
  6855. case 1:
  6856. if miConfig.MdtrtareaAdmvs == "421300" {
  6857. var res ResultTwo
  6858. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  6859. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6860. "&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)
  6861. resp, requestErr := http.Get(api)
  6862. if requestErr != nil {
  6863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6864. return
  6865. }
  6866. body, ioErr := ioutil.ReadAll(resp.Body)
  6867. if ioErr != nil {
  6868. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6870. return
  6871. }
  6872. var respJSON map[string]interface{}
  6873. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6876. return
  6877. }
  6878. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6879. result, _ := json.Marshal(respJSON)
  6880. fmt.Println("log")
  6881. fmt.Println(string(result))
  6882. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6883. utils.ErrorLog("解析失败:%v", err)
  6884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6885. return
  6886. }
  6887. if res.Infcode == 0 {
  6888. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  6889. if err == gorm.ErrRecordNotFound {
  6890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  6891. return
  6892. } else if err != nil {
  6893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  6894. return
  6895. } else {
  6896. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  6897. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  6898. infoStr := string(Iinfos)
  6899. idetinfoStr := string(Idetinfos)
  6900. var rf []*ResultFive
  6901. json.Unmarshal([]byte(infoStr), &rf)
  6902. var insutypes []*ResultFive
  6903. var insutype string
  6904. var is390 int = 0
  6905. var is310 int = 0
  6906. for _, item := range rf {
  6907. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  6908. insutypes = append(insutypes, item)
  6909. }
  6910. }
  6911. if len(insutypes) == 1 {
  6912. insutype = insutypes[0].Insutype
  6913. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  6914. } else {
  6915. for _, i := range insutypes {
  6916. if i.Insutype == "390" {
  6917. is390 = 1
  6918. }
  6919. if i.Insutype == "310" {
  6920. is310 = 1
  6921. }
  6922. }
  6923. }
  6924. if is390 == 1 {
  6925. insutype = "390"
  6926. }
  6927. if is310 == 1 {
  6928. insutype = "310"
  6929. }
  6930. if len(insutypes) == 0 {
  6931. insutype = "390"
  6932. }
  6933. var insuplc_admdvs string
  6934. for _, item := range rf {
  6935. if item.Insutype == insutype {
  6936. insuplc_admdvs = item.InsuplcAdmdvs
  6937. }
  6938. }
  6939. if strings.Contains(insuplc_admdvs, "4213") {
  6940. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  6941. }
  6942. psn := &models.HisPsn{
  6943. PsnNo: res.Output.Baseinfo.PsnNo,
  6944. PatientId: patient.ID,
  6945. Certno: res.Output.Baseinfo.Certno,
  6946. Gend: res.Output.Baseinfo.Gend,
  6947. Naty: res.Output.Baseinfo.Naty,
  6948. PsnCertType: res.Output.Baseinfo.PsnCertType,
  6949. PsnName: res.Output.Baseinfo.PsnName,
  6950. Idetinfo: idetinfoStr,
  6951. Insuinfo: infoStr,
  6952. InsuplcAdmdvs:insuplc_admdvs,
  6953. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6954. }
  6955. service.CreateHisPsn(psn)
  6956. c.ServeSuccessJSON(map[string]interface{}{
  6957. "patient": patient,
  6958. "number": res.Output.Baseinfo.Certno,
  6959. })
  6960. }
  6961. } else {
  6962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  6963. return
  6964. }
  6965. } else if miConfig.MdtrtareaAdmvs == "420200" {
  6966. var res ResultTwo
  6967. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  6968. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6969. "&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)
  6970. resp, requestErr := http.Get(api)
  6971. if requestErr != nil {
  6972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6973. return
  6974. }
  6975. body, ioErr := ioutil.ReadAll(resp.Body)
  6976. if ioErr != nil {
  6977. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6979. return
  6980. }
  6981. var respJSON map[string]interface{}
  6982. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6983. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6985. return
  6986. }
  6987. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6988. result, _ := json.Marshal(respJSON)
  6989. fmt.Println("log")
  6990. fmt.Println(string(result))
  6991. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6992. utils.ErrorLog("解析失败:%v", err)
  6993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6994. return
  6995. }
  6996. if res.Infcode == 0 {
  6997. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  6998. if err == gorm.ErrRecordNotFound {
  6999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7000. return
  7001. } else if err != nil {
  7002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7003. return
  7004. } else {
  7005. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7006. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7007. infoStr := string(Iinfos)
  7008. idetinfoStr := string(Idetinfos)
  7009. psn := &models.HisPsn{
  7010. PsnNo: res.Output.Baseinfo.PsnNo,
  7011. PatientId: patient.ID,
  7012. Certno: res.Output.Baseinfo.Certno,
  7013. Gend: res.Output.Baseinfo.Gend,
  7014. Naty: res.Output.Baseinfo.Naty,
  7015. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7016. PsnName: res.Output.Baseinfo.PsnName,
  7017. Idetinfo: idetinfoStr,
  7018. Insuinfo: infoStr,
  7019. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7020. }
  7021. service.CreateHisPsn(psn)
  7022. var rf []*ResultFive
  7023. json.Unmarshal([]byte(infoStr), &rf)
  7024. var insutypes []*ResultFive
  7025. var insutype string
  7026. var is390 int = 0
  7027. var is310 int = 0
  7028. for _, item := range rf {
  7029. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7030. insutypes = append(insutypes, item)
  7031. }
  7032. }
  7033. if len(insutypes) == 1 {
  7034. insutype = insutypes[0].Insutype
  7035. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7036. } else {
  7037. for _, i := range insutypes {
  7038. if i.Insutype == "390" {
  7039. is390 = 1
  7040. }
  7041. if i.Insutype == "310" {
  7042. is310 = 1
  7043. }
  7044. }
  7045. }
  7046. if is390 == 1 {
  7047. insutype = "390"
  7048. }
  7049. if is310 == 1 {
  7050. insutype = "310"
  7051. }
  7052. if len(insutypes) == 0 {
  7053. insutype = "310"
  7054. }
  7055. c.ServeSuccessJSON(map[string]interface{}{
  7056. "patient": patient,
  7057. "number": res.Output.Baseinfo.Certno,
  7058. "insutype": insutype,
  7059. })
  7060. }
  7061. } else {
  7062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7063. return
  7064. }
  7065. }else if miConfig.MdtrtareaAdmvs == "421182" {
  7066. var res ResultTwo
  7067. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  7068. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7069. "&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)
  7070. resp, requestErr := http.Get(api)
  7071. if requestErr != nil {
  7072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7073. return
  7074. }
  7075. body, ioErr := ioutil.ReadAll(resp.Body)
  7076. if ioErr != nil {
  7077. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7079. return
  7080. }
  7081. var respJSON map[string]interface{}
  7082. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7083. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7085. return
  7086. }
  7087. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7088. result, _ := json.Marshal(respJSON)
  7089. fmt.Println("log")
  7090. fmt.Println(string(result))
  7091. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7092. utils.ErrorLog("解析失败:%v", err)
  7093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7094. return
  7095. }
  7096. if res.Infcode == 0 {
  7097. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7098. if err == gorm.ErrRecordNotFound {
  7099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7100. return
  7101. } else if err != nil {
  7102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7103. return
  7104. } else {
  7105. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7106. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7107. infoStr := string(Iinfos)
  7108. idetinfoStr := string(Idetinfos)
  7109. psn := &models.HisPsn{
  7110. PsnNo: res.Output.Baseinfo.PsnNo,
  7111. PatientId: patient.ID,
  7112. Certno: res.Output.Baseinfo.Certno,
  7113. Gend: res.Output.Baseinfo.Gend,
  7114. Naty: res.Output.Baseinfo.Naty,
  7115. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7116. PsnName: res.Output.Baseinfo.PsnName,
  7117. Idetinfo: idetinfoStr,
  7118. Insuinfo: infoStr,
  7119. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7120. }
  7121. service.CreateHisPsn(psn)
  7122. var rf []*ResultFive
  7123. json.Unmarshal([]byte(infoStr), &rf)
  7124. var insutypes []*ResultFive
  7125. var insutype string
  7126. var is390 int = 0
  7127. var is310 int = 0
  7128. for _, item := range rf {
  7129. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7130. insutypes = append(insutypes, item)
  7131. }
  7132. }
  7133. if len(insutypes) == 1 {
  7134. insutype = insutypes[0].Insutype
  7135. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7136. } else {
  7137. for _, i := range insutypes {
  7138. if i.Insutype == "390" {
  7139. is390 = 1
  7140. }
  7141. if i.Insutype == "310" {
  7142. is310 = 1
  7143. }
  7144. }
  7145. }
  7146. if is390 == 1 {
  7147. insutype = "390"
  7148. }
  7149. if is310 == 1 {
  7150. insutype = "310"
  7151. }
  7152. if len(insutypes) == 0 {
  7153. insutype = "310"
  7154. }
  7155. c.ServeSuccessJSON(map[string]interface{}{
  7156. "patient": patient,
  7157. "number": res.Output.Baseinfo.Certno,
  7158. "insutype": insutype,
  7159. })
  7160. }
  7161. } else {
  7162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7163. return
  7164. }
  7165. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7166. var api string
  7167. if miConfig.MdtrtareaAdmvs == "320921" {
  7168. api = "http://192.168.2.3:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  7169. "&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
  7170. fmt.Println(api)
  7171. } else {
  7172. 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 +
  7173. "&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)
  7174. }
  7175. resp, requestErr := http.Get(api)
  7176. if requestErr != nil {
  7177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7178. return
  7179. }
  7180. body, ioErr := ioutil.ReadAll(resp.Body)
  7181. if ioErr != nil {
  7182. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7184. return
  7185. }
  7186. var respJSON map[string]interface{}
  7187. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7188. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7190. return
  7191. }
  7192. var status string
  7193. status = respJSON["data"].(map[string]interface{})["status"].(string)
  7194. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  7195. //console.log()
  7196. fmt.Println("type===")
  7197. fmt.Println(card_type)
  7198. var token string
  7199. var res ResultTwo //1101结果
  7200. var res10265 ResultTwo10265 //1101结果
  7201. var card_info string //卡信息
  7202. var busi_card_info string
  7203. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  7204. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  7205. if status == "0" { //读卡成功
  7206. if card_type == "1" {
  7207. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  7208. result, _ := json.Marshal(respJSON)
  7209. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7210. utils.ErrorLog("解析失败:%v", err)
  7211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7212. return
  7213. }
  7214. res.ErrMsg = res10265.ErrMsg
  7215. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7216. res.Infcode = infocode
  7217. res.Output = res10265.Output
  7218. res.InfRefmsgid = res10265.InfRefmsgid
  7219. } else {
  7220. //var card_info string //卡信息
  7221. //var busi_card_info string
  7222. token = respJSON["data"].(map[string]interface{})["token"].(string)
  7223. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  7224. //fmt.Println(card_info)
  7225. //fmt.Println(busi_card_info)
  7226. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  7227. result, _ := json.Marshal(respJSON)
  7228. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7229. utils.ErrorLog("解析失败:%v", err)
  7230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7231. return
  7232. }
  7233. res.ErrMsg = res10265.ErrMsg
  7234. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7235. res.Infcode = infocode
  7236. res.Output = res10265.Output
  7237. res.InfRefmsgid = res10265.InfRefmsgid
  7238. }
  7239. if res.Infcode == 0 {
  7240. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7241. if err == gorm.ErrRecordNotFound {
  7242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7243. return
  7244. } else if err != nil {
  7245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7246. return
  7247. } else {
  7248. if card_type == "1" {
  7249. bas := strings.Split(card_info, "|")
  7250. basNumber := bas[2]
  7251. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7252. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7253. infoStr := string(Iinfos)
  7254. idetinfoStr := string(Idetinfos)
  7255. psn := &models.HisPsn{
  7256. PsnNo: res.Output.Baseinfo.PsnNo,
  7257. PatientId: patient.ID,
  7258. Certno: res.Output.Baseinfo.Certno,
  7259. //Brdy: res.Output.Baseinfo.Brdy,
  7260. Gend: res.Output.Baseinfo.Gend,
  7261. Naty: res.Output.Baseinfo.Naty,
  7262. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7263. PsnName: res.Output.Baseinfo.PsnName,
  7264. Idetinfo: idetinfoStr,
  7265. Insuinfo: infoStr,
  7266. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7267. CardInfo: card_info,
  7268. VerifyNumber: busi_card_info,
  7269. }
  7270. service.CreateHisPsn(psn)
  7271. var rf []*ResultFive
  7272. json.Unmarshal([]byte(infoStr), &rf)
  7273. var insutypes []*ResultFive
  7274. var insutype string
  7275. var is390 int = 0
  7276. var is310 int = 0
  7277. for _, item := range rf {
  7278. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7279. insutypes = append(insutypes, item)
  7280. }
  7281. }
  7282. if len(insutypes) == 1 {
  7283. insutype = insutypes[0].Insutype
  7284. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7285. } else {
  7286. for _, i := range insutypes {
  7287. if i.Insutype == "390" {
  7288. is390 = 1
  7289. }
  7290. if i.Insutype == "310" {
  7291. is310 = 1
  7292. }
  7293. }
  7294. }
  7295. if is390 == 1 {
  7296. insutype = "390"
  7297. }
  7298. if is310 == 1 {
  7299. insutype = "310"
  7300. }
  7301. if len(insutypes) == 0 {
  7302. insutype = "310"
  7303. }
  7304. c.ServeSuccessJSON(map[string]interface{}{
  7305. "patient": patient,
  7306. "number": basNumber,
  7307. "insutype": insutype,
  7308. })
  7309. } else {
  7310. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7311. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7312. infoStr := string(Iinfos)
  7313. idetinfoStr := string(Idetinfos)
  7314. psn := &models.HisPsn{
  7315. PsnNo: res.Output.Baseinfo.PsnNo,
  7316. PatientId: patient.ID,
  7317. Certno: res.Output.Baseinfo.Certno,
  7318. Gend: res.Output.Baseinfo.Gend,
  7319. Naty: res.Output.Baseinfo.Naty,
  7320. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7321. PsnName: res.Output.Baseinfo.PsnName,
  7322. Idetinfo: idetinfoStr,
  7323. Insuinfo: infoStr,
  7324. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7325. CardInfo: card_info,
  7326. VerifyNumber: token,
  7327. }
  7328. service.CreateHisPsn(psn)
  7329. c.ServeSuccessJSON(map[string]interface{}{
  7330. "patient": patient,
  7331. "number": token,
  7332. })
  7333. }
  7334. }
  7335. } else {
  7336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7337. return
  7338. }
  7339. } else { //读卡失败
  7340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7341. return
  7342. }
  7343. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7344. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  7345. cardnum = DeleteExtraSpaceTwo(cardnum)
  7346. cardCode = DeleteExtraSpaceTwo(cardCode)
  7347. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  7348. name = DeleteExtraSpaceTwo(name)
  7349. errmsg = DeleteExtraSpaceTwo(errmsg)
  7350. cardnum = Remove0000(cardnum)
  7351. cardCode = Remove0000(cardCode)
  7352. id_card_no = Remove0000(id_card_no)
  7353. name = Remove0000(name)
  7354. errmsg = Remove0000(errmsg)
  7355. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  7356. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  7357. //result2, requestLog2, errMsgLog2 := service.FJybidcomfirm(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, patient.Name)
  7358. //fmt.Println(result2)
  7359. //fmt.Println(requestLog2)
  7360. //fmt.Println(errMsgLog2)
  7361. result, requestLog, errMsgLog := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, "", miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, patient.Name, id_card_no)
  7362. saveLog(result, requestLog, "1101", "获取人员信息")
  7363. fmt.Println(errMsgLog)
  7364. if len(errMsgLog) > 0 {
  7365. } else {
  7366. var dat map[string]interface{}
  7367. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7368. fmt.Println(dat)
  7369. } else {
  7370. fmt.Println(err)
  7371. }
  7372. userJSONBytes, _ := json.Marshal(dat)
  7373. var res ResultTwo
  7374. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7375. utils.ErrorLog("解析失败:%v", err)
  7376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7377. return
  7378. }
  7379. res.ErrMsg = errMsgLog
  7380. if res.Infcode == 0 {
  7381. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  7382. if err == gorm.ErrRecordNotFound {
  7383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7384. return
  7385. } else if err != nil {
  7386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7387. return
  7388. } else {
  7389. fmt.Println(res)
  7390. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7391. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7392. infoStr := string(Iinfos)
  7393. idetinfoStr := string(Idetinfos)
  7394. var rf []*ResultFive
  7395. json.Unmarshal([]byte(infoStr), &rf)
  7396. var insutypes []*ResultFive
  7397. var insutype string
  7398. var is390 int = 0
  7399. var is310 int = 0
  7400. for _, item := range rf {
  7401. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  7402. insutypes = append(insutypes, item)
  7403. }
  7404. }
  7405. if len(insutypes) == 1 {
  7406. insutype = insutypes[0].Insutype
  7407. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7408. } else {
  7409. for _, i := range insutypes {
  7410. if i.Insutype == "390" {
  7411. is390 = 1
  7412. }
  7413. if i.Insutype == "310" {
  7414. is310 = 1
  7415. }
  7416. }
  7417. }
  7418. if is390 == 1 {
  7419. insutype = "390"
  7420. }
  7421. if is310 == 1 {
  7422. insutype = "310"
  7423. }
  7424. if len(insutypes) == 0 {
  7425. insutype = "390"
  7426. }
  7427. var insuplc_admdvs string
  7428. for _, item := range rf {
  7429. if item.Insutype == insutype {
  7430. insuplc_admdvs = item.InsuplcAdmdvs
  7431. }
  7432. }
  7433. psn := &models.HisPsn{
  7434. PsnNo: res.Output.Baseinfo.PsnNo,
  7435. PatientId: patient.ID,
  7436. Certno: res.Output.Baseinfo.Certno,
  7437. Gend: res.Output.Baseinfo.Gend,
  7438. Naty: res.Output.Baseinfo.Naty,
  7439. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7440. PsnName: res.Output.Baseinfo.PsnName,
  7441. Idetinfo: idetinfoStr,
  7442. Insuinfo: infoStr,
  7443. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7444. CardInfo: basStr,
  7445. VerifyNumber: "",
  7446. InsuplcAdmdvs: insuplc_admdvs,
  7447. }
  7448. service.CreateHisPsn(psn)
  7449. c.ServeSuccessJSON(map[string]interface{}{
  7450. "patient": patient,
  7451. "number": cardnum,
  7452. "insutype": insutype,
  7453. })
  7454. }
  7455. } else {
  7456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7457. return
  7458. }
  7459. }
  7460. } else if miConfig.MdtrtareaAdmvs == "360302" {
  7461. fmt.Println(initFlag)
  7462. fmt.Println("initFlag")
  7463. if initFlag == 0 {
  7464. c.TestGetJiangXiBasBaseInit()
  7465. }
  7466. basStr := c.GetBasBaseInfo()
  7467. if len(basStr) == 0 {
  7468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  7469. return
  7470. }
  7471. fmt.Println(basStr)
  7472. bas := strings.Split(basStr, "|")
  7473. basNumber := bas[1]
  7474. fmt.Println(basNumber)
  7475. card_sn := bas[3]
  7476. fmt.Println(card_sn)
  7477. result, _ := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "")
  7478. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  7479. var dat map[string]interface{}
  7480. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7481. fmt.Println(dat)
  7482. } else {
  7483. fmt.Println(err)
  7484. }
  7485. userJSONBytes, _ := json.Marshal(dat)
  7486. var res ResultTwo
  7487. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7488. utils.ErrorLog("解析失败:%v", err)
  7489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7490. return
  7491. }
  7492. if res.Infcode == 0 {
  7493. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  7494. if err == gorm.ErrRecordNotFound {
  7495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7496. return
  7497. } else if err != nil {
  7498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7499. return
  7500. } else {
  7501. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7502. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7503. infoStr := string(Iinfos)
  7504. idetinfoStr := string(Idetinfos)
  7505. var rf []*ResultFive
  7506. json.Unmarshal([]byte(infoStr), &rf)
  7507. var insutypes []*ResultFive
  7508. var insutype string
  7509. var is390 int = 0
  7510. var is310 int = 0
  7511. var insuplc_admdvs string
  7512. for _, item := range rf {
  7513. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7514. insutypes = append(insutypes, item)
  7515. }
  7516. }
  7517. if len(insutypes) == 1 {
  7518. insutype = insutypes[0].Insutype
  7519. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7520. } else {
  7521. for _, i := range insutypes {
  7522. if i.Insutype == "390" {
  7523. is390 = 1
  7524. }
  7525. if i.Insutype == "310" {
  7526. is310 = 1
  7527. }
  7528. }
  7529. }
  7530. if is390 == 1 {
  7531. insutype = "390"
  7532. }
  7533. if is310 == 1 {
  7534. insutype = "310"
  7535. }
  7536. if len(insutypes) == 0 {
  7537. insutype = "310"
  7538. }
  7539. for _, item := range rf {
  7540. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  7541. insuplc_admdvs = item.InsuplcAdmdvs
  7542. }
  7543. }
  7544. psn := &models.HisPsn{
  7545. PsnNo: res.Output.Baseinfo.PsnNo,
  7546. PatientId: patient.ID,
  7547. Certno: res.Output.Baseinfo.Certno,
  7548. Gend: res.Output.Baseinfo.Gend,
  7549. Naty: res.Output.Baseinfo.Naty,
  7550. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7551. PsnName: res.Output.Baseinfo.PsnName,
  7552. Idetinfo: idetinfoStr,
  7553. Insuinfo: infoStr,
  7554. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7555. CardInfo: basStr,
  7556. InsuplcAdmdvs: insuplc_admdvs,
  7557. VerifyNumber: "",
  7558. }
  7559. service.CreateHisPsn(psn)
  7560. c.ServeSuccessJSON(map[string]interface{}{
  7561. "patient": patient,
  7562. "number": basNumber,
  7563. "insutype": insutype,
  7564. })
  7565. }
  7566. } else {
  7567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7568. return
  7569. }
  7570. } else if miConfig.MdtrtareaAdmvs == "430800" {
  7571. fmt.Println(initFlag)
  7572. fmt.Println("initFlag")
  7573. if initFlag == 0 {
  7574. c.TestGetHnBasBaseInit()
  7575. }
  7576. basStr := c.GetBasBaseInfo()
  7577. if len(basStr) == 0 {
  7578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  7579. return
  7580. }
  7581. fmt.Println(basStr)
  7582. bas := strings.Split(basStr, "|")
  7583. basNumber := bas[1]
  7584. fmt.Println(basNumber)
  7585. card_sn := bas[3]
  7586. card_no := bas[2]
  7587. fmt.Println(card_sn)
  7588. name := bas[4]
  7589. name = ConvertToString(name, "gbk", "utf-8")
  7590. result, _ := service.Hnyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "", name, card_no)
  7591. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  7592. var dat map[string]interface{}
  7593. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7594. fmt.Println(dat)
  7595. } else {
  7596. fmt.Println(err)
  7597. }
  7598. userJSONBytes, _ := json.Marshal(dat)
  7599. var res ResultTwo
  7600. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7601. utils.ErrorLog("解析失败:%v", err)
  7602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7603. return
  7604. }
  7605. if res.Infcode == 0 {
  7606. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  7607. if err == gorm.ErrRecordNotFound {
  7608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7609. return
  7610. } else if err != nil {
  7611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7612. return
  7613. } else {
  7614. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7615. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7616. infoStr := string(Iinfos)
  7617. idetinfoStr := string(Idetinfos)
  7618. psn := &models.HisPsn{
  7619. PsnNo: res.Output.Baseinfo.PsnNo,
  7620. PatientId: patient.ID,
  7621. Certno: res.Output.Baseinfo.Certno,
  7622. Gend: res.Output.Baseinfo.Gend,
  7623. Naty: res.Output.Baseinfo.Naty,
  7624. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7625. PsnName: res.Output.Baseinfo.PsnName,
  7626. Idetinfo: idetinfoStr,
  7627. Insuinfo: infoStr,
  7628. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7629. CardInfo: basStr,
  7630. VerifyNumber: "",
  7631. }
  7632. service.CreateHisPsn(psn)
  7633. var rf []*ResultFive
  7634. json.Unmarshal([]byte(infoStr), &rf)
  7635. var insutypes []*ResultFive
  7636. var insutype string
  7637. var is390 int = 0
  7638. var is310 int = 0
  7639. for _, item := range rf {
  7640. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7641. insutypes = append(insutypes, item)
  7642. }
  7643. }
  7644. if len(insutypes) == 1 {
  7645. insutype = insutypes[0].Insutype
  7646. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7647. } else {
  7648. for _, i := range insutypes {
  7649. if i.Insutype == "390" {
  7650. is390 = 1
  7651. }
  7652. if i.Insutype == "310" {
  7653. is310 = 1
  7654. }
  7655. }
  7656. }
  7657. if is390 == 1 {
  7658. insutype = "390"
  7659. }
  7660. if is310 == 1 {
  7661. insutype = "310"
  7662. }
  7663. if len(insutypes) == 0 {
  7664. insutype = "310"
  7665. }
  7666. c.ServeSuccessJSON(map[string]interface{}{
  7667. "patient": patient,
  7668. "number": basNumber,
  7669. "insutype": insutype,
  7670. })
  7671. }
  7672. } else {
  7673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7674. return
  7675. }
  7676. } else if miConfig.MdtrtareaAdmvs == "150499" {
  7677. var api string
  7678. api = "http://172.16.13.254:9532/" + "nmyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  7679. "&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
  7680. fmt.Println(api)
  7681. resp, requestErr := http.Get(api)
  7682. if requestErr != nil {
  7683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7684. return
  7685. }
  7686. body, ioErr := ioutil.ReadAll(resp.Body)
  7687. if ioErr != nil {
  7688. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7690. return
  7691. }
  7692. var respJSON map[string]interface{}
  7693. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7694. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7696. return
  7697. }
  7698. var res ResultTwo //1101结果
  7699. var res10265 ResultTwo10265 //1101结果
  7700. var card_info string //卡信息
  7701. token := respJSON["data"].(map[string]interface{})["token"].(string)
  7702. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  7703. result, _ := json.Marshal(respJSON)
  7704. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7705. utils.ErrorLog("解析失败:%v", err)
  7706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7707. return
  7708. }
  7709. res.ErrMsg = res10265.ErrMsg
  7710. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7711. res.Infcode = infocode
  7712. res.Output = res10265.Output
  7713. res.InfRefmsgid = res10265.InfRefmsgid
  7714. if res.Infcode == 0 {
  7715. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7716. if err == gorm.ErrRecordNotFound {
  7717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7718. return
  7719. } else if err != nil {
  7720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7721. return
  7722. } else {
  7723. bas := strings.Split(card_info, "|")
  7724. basNumber := bas[2]
  7725. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7726. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7727. infoStr := string(Iinfos)
  7728. idetinfoStr := string(Idetinfos)
  7729. psn := &models.HisPsn{
  7730. PsnNo: res.Output.Baseinfo.PsnNo,
  7731. PatientId: patient.ID,
  7732. Certno: res.Output.Baseinfo.Certno,
  7733. Gend: res.Output.Baseinfo.Gend,
  7734. Naty: res.Output.Baseinfo.Naty,
  7735. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7736. PsnName: res.Output.Baseinfo.PsnName,
  7737. Idetinfo: idetinfoStr,
  7738. Insuinfo: infoStr,
  7739. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7740. CardInfo: card_info,
  7741. VerifyNumber: token,
  7742. }
  7743. service.CreateHisPsn(psn)
  7744. var rf []*ResultFive
  7745. json.Unmarshal([]byte(infoStr), &rf)
  7746. var insutypes []*ResultFive
  7747. var insutype string
  7748. var is390 int = 0
  7749. var is310 int = 0
  7750. for _, item := range rf {
  7751. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7752. insutypes = append(insutypes, item)
  7753. }
  7754. }
  7755. if len(insutypes) == 1 {
  7756. insutype = insutypes[0].Insutype
  7757. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7758. } else {
  7759. for _, i := range insutypes {
  7760. if i.Insutype == "390" {
  7761. is390 = 1
  7762. }
  7763. if i.Insutype == "310" {
  7764. is310 = 1
  7765. }
  7766. }
  7767. }
  7768. if is390 == 1 {
  7769. insutype = "390"
  7770. }
  7771. if is310 == 1 {
  7772. insutype = "310"
  7773. }
  7774. if len(insutypes) == 0 {
  7775. insutype = "310"
  7776. }
  7777. c.ServeSuccessJSON(map[string]interface{}{
  7778. "patient": patient,
  7779. "number": basNumber,
  7780. "insutype": insutype,
  7781. })
  7782. }
  7783. } else {
  7784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7785. return
  7786. }
  7787. } else if miConfig.MdtrtareaAdmvs == "450721" {
  7788. res := c.GetoleInfo()
  7789. if res.Infcode == 0 {
  7790. var result string
  7791. if res.Output.MdtrtCertType == "01" {
  7792. result = service.Gdyb1101d(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 4, res.Output.CardSN, certificates, res.Output.PsnName, res.Output.EcToken, admin_user_id)
  7793. } else if res.Output.MdtrtCertType == "02" {
  7794. result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, res.Output.CardSN, certificates, res.Output.PsnName, res.Output.CardNo, admin_user_id)
  7795. } else if res.Output.MdtrtCertType == "03" {
  7796. result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, res.Output.CardSN, certificates, res.Output.PsnName, res.Output.CardNo, admin_user_id)
  7797. }
  7798. var dat map[string]interface{}
  7799. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7800. fmt.Println(dat)
  7801. } else {
  7802. fmt.Println(err)
  7803. }
  7804. userJSONBytes, _ := json.Marshal(dat)
  7805. var res2 ResultTwo
  7806. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7807. utils.ErrorLog("解析失败:%v", err)
  7808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7809. return
  7810. }
  7811. if res2.Infcode == 0 {
  7812. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  7813. if err == gorm.ErrRecordNotFound {
  7814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7815. return
  7816. } else if err != nil {
  7817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7818. return
  7819. } else {
  7820. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  7821. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  7822. infoStr := string(Iinfos)
  7823. idetinfoStr := string(Idetinfos)
  7824. var rf []*ResultFive
  7825. json.Unmarshal([]byte(infoStr), &rf)
  7826. var insutypes []*ResultFive
  7827. var insutype string
  7828. var is390 int = 0
  7829. var is310 int = 0
  7830. //var insuplc_admdvs string
  7831. for _, item := range rf {
  7832. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7833. insutypes = append(insutypes, item)
  7834. }
  7835. }
  7836. if len(insutypes) == 1 {
  7837. insutype = insutypes[0].Insutype
  7838. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7839. } else {
  7840. for _, i := range insutypes {
  7841. if i.Insutype == "390" {
  7842. is390 = 1
  7843. }
  7844. if i.Insutype == "310" {
  7845. is310 = 1
  7846. }
  7847. }
  7848. }
  7849. if is390 == 1 {
  7850. insutype = "390"
  7851. }
  7852. if is310 == 1 {
  7853. insutype = "310"
  7854. }
  7855. if len(insutypes) == 0 {
  7856. insutype = "310"
  7857. }
  7858. psn := &models.HisPsn{
  7859. PsnNo: res2.Output.Baseinfo.PsnNo,
  7860. PatientId: patient.ID,
  7861. Certno: res2.Output.Baseinfo.Certno,
  7862. Gend: res2.Output.Baseinfo.Gend,
  7863. Naty: res2.Output.Baseinfo.Naty,
  7864. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  7865. PsnName: res2.Output.Baseinfo.PsnName,
  7866. Idetinfo: idetinfoStr,
  7867. Insuinfo: infoStr,
  7868. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7869. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  7870. VerifyNumber: res.Output.EcToken,
  7871. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  7872. }
  7873. if res.Output.MdtrtCertType == "01" {
  7874. psn.VerifyNumber = res.Output.EcToken
  7875. //result = service.Gdyb1101d(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 4, res.Output.CardSN, certificates, res.Output.PsnName, res.Output.EcToken,admin_user_id)
  7876. } else if res.Output.MdtrtCertType == "02" {
  7877. psn.VerifyNumber = res.Output.MdtrtCertNo
  7878. //result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, res.Output.CardSN, certificates, res.Output.PsnName, res.Output.CardNo,admin_user_id)
  7879. } else if res.Output.MdtrtCertType == "03" {
  7880. psn.VerifyNumber = res.Output.MdtrtCertNo
  7881. //result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, res.Output.CardSN, certificates, res.Output.PsnName, res.Output.CardNo,admin_user_id)
  7882. }
  7883. var balc float64
  7884. for _, item := range rf {
  7885. if item.Insutype == insutype{
  7886. balc =item.Balc
  7887. }
  7888. }
  7889. service.CreateHisPsn(psn)
  7890. c.ServeSuccessJSON(map[string]interface{}{
  7891. "patient": patient,
  7892. "number": res.Output.CardNo,
  7893. "insutype": insutype,
  7894. "blac":balc,
  7895. "desc":idetinfoStr,
  7896. })
  7897. }
  7898. } else {
  7899. c.ServeSuccessJSON(map[string]interface{}{
  7900. "failed_code": -10,
  7901. "msg": res2.ErrMsg,
  7902. })
  7903. }
  7904. } else {
  7905. c.ServeSuccessJSON(map[string]interface{}{
  7906. "failed_code": -10,
  7907. "msg": res.ErrMsg,
  7908. })
  7909. }
  7910. } else if miConfig.MdtrtareaAdmvs == "341203" {
  7911. var api string
  7912. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  7913. "&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
  7914. fmt.Println(api)
  7915. resp, requestErr := http.Get(api)
  7916. if requestErr != nil {
  7917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7918. return
  7919. }
  7920. body, ioErr := ioutil.ReadAll(resp.Body)
  7921. if ioErr != nil {
  7922. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7924. return
  7925. }
  7926. var respJSON map[string]interface{}
  7927. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7928. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7930. return
  7931. }
  7932. var status string
  7933. status = respJSON["data"].(map[string]interface{})["status"].(string)
  7934. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  7935. //console.log()
  7936. fmt.Println("type===")
  7937. fmt.Println(card_type)
  7938. var token string
  7939. var res ResultTwo //1101结果
  7940. //var res10265 ResultTwoesultTwo10265 //1101结果
  7941. var card_info string //卡信息
  7942. var busi_card_info string
  7943. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  7944. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  7945. if status == "0" { //读卡成功
  7946. if card_type == "1" {
  7947. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  7948. result, _ := json.Marshal(respJSON)
  7949. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7950. utils.ErrorLog("解析失败:%v", err)
  7951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7952. return
  7953. }
  7954. } else {
  7955. token = respJSON["data"].(map[string]interface{})["token"].(string)
  7956. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  7957. result, _ := json.Marshal(respJSON)
  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. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7966. if err == gorm.ErrRecordNotFound {
  7967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7968. return
  7969. } else if err != nil {
  7970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7971. return
  7972. } else {
  7973. if card_type == "1" {
  7974. bas := strings.Split(card_info, "|")
  7975. basNumber := bas[2]
  7976. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7977. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7978. infoStr := string(Iinfos)
  7979. idetinfoStr := string(Idetinfos)
  7980. psn := &models.HisPsn{
  7981. PsnNo: res.Output.Baseinfo.PsnNo,
  7982. PatientId: patient.ID,
  7983. Certno: res.Output.Baseinfo.Certno,
  7984. Gend: res.Output.Baseinfo.Gend,
  7985. Naty: res.Output.Baseinfo.Naty,
  7986. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7987. PsnName: res.Output.Baseinfo.PsnName,
  7988. Idetinfo: idetinfoStr,
  7989. Insuinfo: infoStr,
  7990. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7991. CardInfo: card_info,
  7992. VerifyNumber: busi_card_info,
  7993. }
  7994. service.CreateHisPsn(psn)
  7995. var rf []*ResultFive
  7996. json.Unmarshal([]byte(infoStr), &rf)
  7997. var insutypes []*ResultFive
  7998. var insutype string
  7999. var is390 int = 0
  8000. var is310 int = 0
  8001. for _, item := range rf {
  8002. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8003. insutypes = append(insutypes, item)
  8004. }
  8005. }
  8006. if len(insutypes) == 1 {
  8007. insutype = insutypes[0].Insutype
  8008. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8009. } else {
  8010. for _, i := range insutypes {
  8011. if i.Insutype == "390" {
  8012. is390 = 1
  8013. }
  8014. if i.Insutype == "310" {
  8015. is310 = 1
  8016. }
  8017. }
  8018. }
  8019. if is390 == 1 {
  8020. insutype = "390"
  8021. }
  8022. if is310 == 1 {
  8023. insutype = "310"
  8024. }
  8025. if len(insutypes) == 0 {
  8026. insutype = "310"
  8027. }
  8028. c.ServeSuccessJSON(map[string]interface{}{
  8029. "patient": patient,
  8030. "number": basNumber,
  8031. "insutype": insutype,
  8032. })
  8033. } else {
  8034. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8035. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8036. infoStr := string(Iinfos)
  8037. idetinfoStr := string(Idetinfos)
  8038. psn := &models.HisPsn{
  8039. PsnNo: res.Output.Baseinfo.PsnNo,
  8040. PatientId: patient.ID,
  8041. Certno: res.Output.Baseinfo.Certno,
  8042. Gend: res.Output.Baseinfo.Gend,
  8043. Naty: res.Output.Baseinfo.Naty,
  8044. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8045. PsnName: res.Output.Baseinfo.PsnName,
  8046. Idetinfo: idetinfoStr,
  8047. Insuinfo: infoStr,
  8048. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8049. CardInfo: card_info,
  8050. VerifyNumber: token,
  8051. }
  8052. service.CreateHisPsn(psn)
  8053. c.ServeSuccessJSON(map[string]interface{}{
  8054. "patient": patient,
  8055. "number": token,
  8056. })
  8057. }
  8058. }
  8059. } else {
  8060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8061. return
  8062. }
  8063. } else { //读卡失败
  8064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8065. return
  8066. }
  8067. } else {
  8068. if initFlag == 0 {
  8069. c.TestGetBasBaseInit()
  8070. }
  8071. basStr := c.GetBasBaseInfo()
  8072. if len(basStr) == 0 {
  8073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8074. return
  8075. }
  8076. fmt.Println(basStr)
  8077. bas := strings.Split(basStr, "|")
  8078. basNumber := bas[1]
  8079. fmt.Println(basNumber)
  8080. card_sn := bas[3]
  8081. fmt.Println(card_sn)
  8082. cardNumber := bas[2]
  8083. fmt.Println(cardNumber)
  8084. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  8085. var result string
  8086. if bas[0][:2] == "44" {
  8087. result = service.Gdyb1101f(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, bas[0], miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, patient.Name, cardNumber)
  8088. } else {
  8089. result = service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, bas[0], miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, patient.Name, cardNumber, admin_user_id)
  8090. }
  8091. var dat map[string]interface{}
  8092. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8093. fmt.Println(dat)
  8094. } else {
  8095. fmt.Println(err)
  8096. }
  8097. userJSONBytes, _ := json.Marshal(dat)
  8098. var res ResultTwo
  8099. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8100. utils.ErrorLog("解析失败:%v", err)
  8101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8102. return
  8103. }
  8104. if res.Infcode == 0 {
  8105. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8106. if err == gorm.ErrRecordNotFound {
  8107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8108. return
  8109. } else if err != nil {
  8110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8111. return
  8112. } else {
  8113. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8114. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8115. infoStr := string(Iinfos)
  8116. idetinfoStr := string(Idetinfos)
  8117. var rf []*ResultFive
  8118. json.Unmarshal([]byte(infoStr), &rf)
  8119. var insutypes []*ResultFive
  8120. var insutype string
  8121. var is390 int = 0
  8122. var is310 int = 0
  8123. var insuplc_admdvs string
  8124. for _, item := range rf {
  8125. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8126. insutypes = append(insutypes, item)
  8127. }
  8128. }
  8129. if len(insutypes) == 1 {
  8130. insutype = insutypes[0].Insutype
  8131. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8132. } else {
  8133. for _, i := range insutypes {
  8134. if i.Insutype == "390" {
  8135. is390 = 1
  8136. }
  8137. if i.Insutype == "310" {
  8138. is310 = 1
  8139. }
  8140. }
  8141. }
  8142. if is390 == 1 {
  8143. insutype = "390"
  8144. }
  8145. if is310 == 1 {
  8146. insutype = "310"
  8147. }
  8148. if len(insutypes) == 0 {
  8149. insutype = "310"
  8150. }
  8151. for _, item := range rf {
  8152. if item.Insutype == insutype {
  8153. insuplc_admdvs = item.InsuplcAdmdvs
  8154. }
  8155. }
  8156. psn := &models.HisPsn{
  8157. PsnNo: res.Output.Baseinfo.PsnNo,
  8158. PatientId: patient.ID,
  8159. Certno: res.Output.Baseinfo.Certno,
  8160. Gend: res.Output.Baseinfo.Gend,
  8161. Naty: res.Output.Baseinfo.Naty,
  8162. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8163. PsnName: res.Output.Baseinfo.PsnName,
  8164. Idetinfo: idetinfoStr,
  8165. Insuinfo: infoStr,
  8166. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8167. CardInfo: basStr,
  8168. VerifyNumber: "",
  8169. InsuplcAdmdvs: insuplc_admdvs,
  8170. }
  8171. service.CreateHisPsn(psn)
  8172. c.ServeSuccessJSON(map[string]interface{}{
  8173. "patient": patient,
  8174. "number": basNumber,
  8175. })
  8176. }
  8177. } else {
  8178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8179. return
  8180. }
  8181. break
  8182. }
  8183. case 2:
  8184. if miConfig.MdtrtareaAdmvs == "430800" {
  8185. if initFlag == 0 {
  8186. c.TestGetHnBasBaseInit()
  8187. }
  8188. SFZStr := c.GetSFZBaseInfo()
  8189. if len(SFZStr) == 0 {
  8190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8191. return
  8192. }
  8193. fmt.Println(SFZStr)
  8194. id_card_str := strings.Split(SFZStr, "^")
  8195. card_no := id_card_str[0]
  8196. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  8197. //name := id_card_str[1]
  8198. //name = ConvertToString(name, "gbk", "utf-8")
  8199. result, _ := service.Hnyb1101(card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "", patient.Name, card_no)
  8200. var dat map[string]interface{}
  8201. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8202. fmt.Println(dat)
  8203. } else {
  8204. fmt.Println(err)
  8205. }
  8206. userJSONBytes, _ := json.Marshal(dat)
  8207. var res ResultTwo
  8208. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8209. utils.ErrorLog("解析失败:%v", err)
  8210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8211. return
  8212. }
  8213. if res.Infcode == 0 {
  8214. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  8215. if err == gorm.ErrRecordNotFound {
  8216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8217. return
  8218. } else if err != nil {
  8219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8220. return
  8221. } else {
  8222. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8223. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8224. infoStr := string(Iinfos)
  8225. idetinfoStr := string(Idetinfos)
  8226. var rf []*ResultFive
  8227. json.Unmarshal([]byte(infoStr), &rf)
  8228. var insutypes []*ResultFive
  8229. var insutype string
  8230. var is390 int = 0
  8231. var is310 int = 0
  8232. for _, item := range rf {
  8233. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8234. insutypes = append(insutypes, item)
  8235. }
  8236. }
  8237. if len(insutypes) == 1 {
  8238. insutype = insutypes[0].Insutype
  8239. } else {
  8240. for _, i := range insutypes {
  8241. if i.Insutype == "390" {
  8242. is390 = 1
  8243. }
  8244. if i.Insutype == "310" {
  8245. is310 = 1
  8246. }
  8247. }
  8248. }
  8249. if is390 == 1 {
  8250. insutype = "390"
  8251. }
  8252. if is310 == 1 {
  8253. insutype = "310"
  8254. }
  8255. if len(insutypes) == 0 {
  8256. insutype = "310"
  8257. }
  8258. var InsuplcAdmdvs string
  8259. for _, item := range rf {
  8260. if item.Insutype == insutype{
  8261. InsuplcAdmdvs = item.InsuplcAdmdvs
  8262. }
  8263. }
  8264. psn := &models.HisPsn{
  8265. PsnNo: res.Output.Baseinfo.PsnNo,
  8266. PatientId: patient.ID,
  8267. Certno: res.Output.Baseinfo.Certno,
  8268. Gend: res.Output.Baseinfo.Gend,
  8269. Naty: res.Output.Baseinfo.Naty,
  8270. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8271. PsnName: res.Output.Baseinfo.PsnName,
  8272. Idetinfo: idetinfoStr,
  8273. Insuinfo: infoStr,
  8274. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8275. CardInfo: SFZStr,
  8276. VerifyNumber: "",
  8277. InsuplcAdmdvs:InsuplcAdmdvs,
  8278. }
  8279. service.CreateHisPsn(psn)
  8280. c.ServeSuccessJSON(map[string]interface{}{
  8281. "patient": patient,
  8282. "number": card_no,
  8283. "insutype": insutype,
  8284. })
  8285. }
  8286. } else {
  8287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8288. return
  8289. }
  8290. } else if miConfig.MdtrtareaAdmvs == "420200" {
  8291. var res ResultTwo
  8292. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  8293. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8294. "&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)
  8295. resp, requestErr := http.Get(api)
  8296. if requestErr != nil {
  8297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8298. return
  8299. }
  8300. body, ioErr := ioutil.ReadAll(resp.Body)
  8301. if ioErr != nil {
  8302. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8304. return
  8305. }
  8306. var respJSON map[string]interface{}
  8307. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8308. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8310. return
  8311. }
  8312. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8313. result, _ := json.Marshal(respJSON)
  8314. fmt.Println("log")
  8315. fmt.Println(string(result))
  8316. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8317. utils.ErrorLog("解析失败:%v", err)
  8318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8319. return
  8320. }
  8321. if res.Infcode == 0 {
  8322. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8323. if err == gorm.ErrRecordNotFound {
  8324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8325. return
  8326. } else if err != nil {
  8327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8328. return
  8329. } else {
  8330. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8331. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8332. infoStr := string(Iinfos)
  8333. idetinfoStr := string(Idetinfos)
  8334. psn := &models.HisPsn{
  8335. PsnNo: res.Output.Baseinfo.PsnNo,
  8336. PatientId: patient.ID,
  8337. Certno: res.Output.Baseinfo.Certno,
  8338. Gend: res.Output.Baseinfo.Gend,
  8339. Naty: res.Output.Baseinfo.Naty,
  8340. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8341. PsnName: res.Output.Baseinfo.PsnName,
  8342. Idetinfo: idetinfoStr,
  8343. Insuinfo: infoStr,
  8344. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8345. }
  8346. service.CreateHisPsn(psn)
  8347. c.ServeSuccessJSON(map[string]interface{}{
  8348. "patient": patient,
  8349. "number": res.Output.Baseinfo.Certno,
  8350. })
  8351. }
  8352. } else {
  8353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8354. return
  8355. }
  8356. } else if miConfig.MdtrtareaAdmvs == "421182" {
  8357. var res ResultTwo
  8358. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  8359. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8360. "&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)
  8361. resp, requestErr := http.Get(api)
  8362. if requestErr != nil {
  8363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8364. return
  8365. }
  8366. body, ioErr := ioutil.ReadAll(resp.Body)
  8367. if ioErr != nil {
  8368. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8370. return
  8371. }
  8372. var respJSON map[string]interface{}
  8373. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8374. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8376. return
  8377. }
  8378. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8379. result, _ := json.Marshal(respJSON)
  8380. fmt.Println("log")
  8381. fmt.Println(string(result))
  8382. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8383. utils.ErrorLog("解析失败:%v", err)
  8384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8385. return
  8386. }
  8387. if res.Infcode == 0 {
  8388. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8389. if err == gorm.ErrRecordNotFound {
  8390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8391. return
  8392. } else if err != nil {
  8393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8394. return
  8395. } else {
  8396. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8397. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8398. infoStr := string(Iinfos)
  8399. idetinfoStr := string(Idetinfos)
  8400. psn := &models.HisPsn{
  8401. PsnNo: res.Output.Baseinfo.PsnNo,
  8402. PatientId: patient.ID,
  8403. Certno: res.Output.Baseinfo.Certno,
  8404. Gend: res.Output.Baseinfo.Gend,
  8405. Naty: res.Output.Baseinfo.Naty,
  8406. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8407. PsnName: res.Output.Baseinfo.PsnName,
  8408. Idetinfo: idetinfoStr,
  8409. Insuinfo: infoStr,
  8410. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8411. }
  8412. service.CreateHisPsn(psn)
  8413. c.ServeSuccessJSON(map[string]interface{}{
  8414. "patient": patient,
  8415. "number": res.Output.Baseinfo.Certno,
  8416. })
  8417. }
  8418. } else {
  8419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8420. return
  8421. }
  8422. }else if miConfig.MdtrtareaAdmvs == "450721" {
  8423. res := c.GetoleInfo()
  8424. if res.Infcode == 0 {
  8425. var result string
  8426. if res.Output.MdtrtCertType == "01" {
  8427. result = service.Gdyb1101d(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 4, res.Output.CardSN, 1, res.Output.PsnName, res.Output.EcToken, admin_user_id)
  8428. } else if res.Output.MdtrtCertType == "02" {
  8429. result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, res.Output.CardSN, 1, res.Output.PsnName, res.Output.CardNo, admin_user_id)
  8430. } else if res.Output.MdtrtCertType == "03" {
  8431. result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, res.Output.CardSN, 1, res.Output.PsnName, res.Output.CardNo, admin_user_id)
  8432. }
  8433. var dat map[string]interface{}
  8434. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8435. fmt.Println(dat)
  8436. } else {
  8437. fmt.Println(err)
  8438. }
  8439. userJSONBytes, _ := json.Marshal(dat)
  8440. var res2 ResultTwo
  8441. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8442. utils.ErrorLog("解析失败:%v", err)
  8443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8444. return
  8445. }
  8446. if res2.Infcode == 0 {
  8447. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  8448. if err == gorm.ErrRecordNotFound {
  8449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8450. return
  8451. } else if err != nil {
  8452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8453. return
  8454. } else {
  8455. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  8456. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  8457. infoStr := string(Iinfos)
  8458. idetinfoStr := string(Idetinfos)
  8459. var rf []*ResultFive
  8460. json.Unmarshal([]byte(infoStr), &rf)
  8461. var insutypes []*ResultFive
  8462. var insutype string
  8463. var is390 int = 0
  8464. var is310 int = 0
  8465. //var insuplc_admdvs string
  8466. for _, item := range rf {
  8467. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8468. insutypes = append(insutypes, item)
  8469. }
  8470. }
  8471. if len(insutypes) == 1 {
  8472. insutype = insutypes[0].Insutype
  8473. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8474. } else {
  8475. for _, i := range insutypes {
  8476. if i.Insutype == "390" {
  8477. is390 = 1
  8478. }
  8479. if i.Insutype == "310" {
  8480. is310 = 1
  8481. }
  8482. }
  8483. }
  8484. if is390 == 1 {
  8485. insutype = "390"
  8486. }
  8487. if is310 == 1 {
  8488. insutype = "310"
  8489. }
  8490. if len(insutypes) == 0 {
  8491. insutype = "310"
  8492. }
  8493. psn := &models.HisPsn{
  8494. PsnNo: res2.Output.Baseinfo.PsnNo,
  8495. PatientId: patient.ID,
  8496. //Brdy: res2.Output.Baseinfo.Brdy,
  8497. Certno: res2.Output.Baseinfo.Certno,
  8498. Gend: res2.Output.Baseinfo.Gend,
  8499. Naty: res2.Output.Baseinfo.Naty,
  8500. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  8501. PsnName: res2.Output.Baseinfo.PsnName,
  8502. Idetinfo: idetinfoStr,
  8503. Insuinfo: infoStr,
  8504. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8505. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  8506. VerifyNumber: res.Output.EcToken,
  8507. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  8508. }
  8509. service.CreateHisPsn(psn)
  8510. var balc float64
  8511. for _, item := range rf {
  8512. if item.Insutype == insutype{
  8513. balc =item.Balc
  8514. }
  8515. }
  8516. c.ServeSuccessJSON(map[string]interface{}{
  8517. "patient": patient,
  8518. "number": res.Output.CardNo,
  8519. "insutype": insutype,
  8520. "blac":balc,
  8521. "desc":idetinfoStr,
  8522. })
  8523. }
  8524. } else {
  8525. c.ServeSuccessJSON(map[string]interface{}{
  8526. "failed_code": -10,
  8527. "msg": res2.ErrMsg,
  8528. })
  8529. }
  8530. } else {
  8531. c.ServeSuccessJSON(map[string]interface{}{
  8532. "failed_code": -10,
  8533. "msg": res.ErrMsg,
  8534. })
  8535. }
  8536. } else {
  8537. SFZStr := c.GetSFZBaseInfo()
  8538. id_card_str := strings.Split(SFZStr, "^")
  8539. id_card_number := id_card_str[0]
  8540. card_sn := ""
  8541. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, "", "", admin_user_id)
  8542. var dat map[string]interface{}
  8543. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8544. fmt.Println(dat)
  8545. } else {
  8546. fmt.Println(err)
  8547. }
  8548. userJSONBytes, _ := json.Marshal(dat)
  8549. var res ResultTwo
  8550. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8551. utils.ErrorLog("解析失败:%v", err)
  8552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8553. return
  8554. }
  8555. if res.Infcode == 0 {
  8556. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  8557. if err == gorm.ErrRecordNotFound {
  8558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8559. return
  8560. } else if err != nil {
  8561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8562. return
  8563. } else {
  8564. c.ServeSuccessJSON(map[string]interface{}{
  8565. "patient": patient,
  8566. "number": id_card_number,
  8567. })
  8568. }
  8569. } else {
  8570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8571. return
  8572. }
  8573. }
  8574. break
  8575. case 3:
  8576. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8577. var api string
  8578. if miConfig.MdtrtareaAdmvs == "320921" {
  8579. api = "http://192.168.2.3:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  8580. "&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
  8581. fmt.Println(api)
  8582. } else {
  8583. 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 +
  8584. "&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)
  8585. }
  8586. resp, requestErr := http.Get(api)
  8587. if requestErr != nil {
  8588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8589. return
  8590. }
  8591. body, ioErr := ioutil.ReadAll(resp.Body)
  8592. if ioErr != nil {
  8593. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8595. return
  8596. }
  8597. var respJSON map[string]interface{}
  8598. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8599. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8601. return
  8602. }
  8603. var status string
  8604. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8605. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8606. var token string
  8607. var res ResultTwo //1101结果
  8608. var res10265 ResultTwo10265 //1101结果
  8609. var card_info string //卡信息
  8610. var busi_card_info string
  8611. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8612. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8613. if status == "0" { //读卡成功
  8614. if card_type == "1" {
  8615. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8616. result, _ := json.Marshal(respJSON)
  8617. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8618. utils.ErrorLog("解析失败:%v", err)
  8619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8620. return
  8621. }
  8622. res.ErrMsg = res10265.ErrMsg
  8623. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8624. res.Infcode = infocode
  8625. res.Output = res10265.Output
  8626. res.InfRefmsgid = res10265.InfRefmsgid
  8627. } else {
  8628. //var card_info string //卡信息
  8629. //var busi_card_info string
  8630. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8631. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8632. //fmt.Println(card_info)
  8633. //fmt.Println(busi_card_info)
  8634. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8635. result, _ := json.Marshal(respJSON)
  8636. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8637. utils.ErrorLog("解析失败:%v", err)
  8638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8639. return
  8640. }
  8641. res.ErrMsg = res10265.ErrMsg
  8642. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8643. res.Infcode = infocode
  8644. res.Output = res10265.Output
  8645. res.InfRefmsgid = res10265.InfRefmsgid
  8646. }
  8647. if res.Infcode == 0 {
  8648. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8649. if err == gorm.ErrRecordNotFound {
  8650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8651. return
  8652. } else if err != nil {
  8653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8654. return
  8655. } else {
  8656. if card_type == "1" {
  8657. bas := strings.Split(card_info, "|")
  8658. basNumber := bas[2]
  8659. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8660. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8661. infoStr := string(Iinfos)
  8662. idetinfoStr := string(Idetinfos)
  8663. psn := &models.HisPsn{
  8664. PsnNo: res.Output.Baseinfo.PsnNo,
  8665. PatientId: patient.ID,
  8666. Certno: res.Output.Baseinfo.Certno,
  8667. //Brdy: res.Output.Baseinfo.Brdy,
  8668. Gend: res.Output.Baseinfo.Gend,
  8669. Naty: res.Output.Baseinfo.Naty,
  8670. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8671. PsnName: res.Output.Baseinfo.PsnName,
  8672. Idetinfo: idetinfoStr,
  8673. Insuinfo: infoStr,
  8674. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8675. CardInfo: card_info,
  8676. VerifyNumber: busi_card_info,
  8677. }
  8678. service.CreateHisPsn(psn)
  8679. c.ServeSuccessJSON(map[string]interface{}{
  8680. "patient": patient,
  8681. "number": basNumber,
  8682. })
  8683. } else {
  8684. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8685. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8686. infoStr := string(Iinfos)
  8687. idetinfoStr := string(Idetinfos)
  8688. psn := &models.HisPsn{
  8689. PsnNo: res.Output.Baseinfo.PsnNo,
  8690. PatientId: patient.ID,
  8691. Certno: res.Output.Baseinfo.Certno,
  8692. Gend: res.Output.Baseinfo.Gend,
  8693. Naty: res.Output.Baseinfo.Naty,
  8694. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8695. PsnName: res.Output.Baseinfo.PsnName,
  8696. Idetinfo: idetinfoStr,
  8697. Insuinfo: infoStr,
  8698. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8699. CardInfo: card_info,
  8700. VerifyNumber: token,
  8701. }
  8702. service.CreateHisPsn(psn)
  8703. var rf []*ResultFive
  8704. json.Unmarshal([]byte(infoStr), &rf)
  8705. var insutypes []*ResultFive
  8706. var insutype string
  8707. var is390 int = 0
  8708. var is310 int = 0
  8709. for _, item := range rf {
  8710. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8711. insutypes = append(insutypes, item)
  8712. }
  8713. }
  8714. if len(insutypes) == 1 {
  8715. insutype = insutypes[0].Insutype
  8716. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8717. } else {
  8718. for _, i := range insutypes {
  8719. if i.Insutype == "390" {
  8720. is390 = 1
  8721. }
  8722. if i.Insutype == "310" {
  8723. is310 = 1
  8724. }
  8725. }
  8726. }
  8727. if is390 == 1 {
  8728. insutype = "390"
  8729. }
  8730. if is310 == 1 {
  8731. insutype = "310"
  8732. }
  8733. if len(insutypes) == 0 {
  8734. insutype = "310"
  8735. }
  8736. c.ServeSuccessJSON(map[string]interface{}{
  8737. "patient": patient,
  8738. "number": token,
  8739. "insutype": insutype,
  8740. })
  8741. }
  8742. }
  8743. } else {
  8744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8745. return
  8746. }
  8747. } else { //读卡失败
  8748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8749. return
  8750. }
  8751. }
  8752. break
  8753. case 4:
  8754. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8755. var api string
  8756. if miConfig.MdtrtareaAdmvs == "320921" {
  8757. api = "http://192.168.2.3:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  8758. "&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
  8759. fmt.Println(api)
  8760. } else {
  8761. 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 +
  8762. "&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)
  8763. }
  8764. resp, requestErr := http.Get(api)
  8765. if requestErr != nil {
  8766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8767. return
  8768. }
  8769. body, ioErr := ioutil.ReadAll(resp.Body)
  8770. if ioErr != nil {
  8771. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8773. return
  8774. }
  8775. var respJSON map[string]interface{}
  8776. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8777. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8779. return
  8780. }
  8781. var status string
  8782. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8783. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8784. var token string
  8785. var res ResultTwo //1101结果
  8786. var res10265 ResultTwo10265 //1101结果
  8787. if status == "0" { //读卡成功
  8788. var card_info string //卡信息
  8789. var busi_card_info string
  8790. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8791. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8792. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8793. fmt.Println(card_info)
  8794. fmt.Println(busi_card_info)
  8795. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8796. result, _ := json.Marshal(respJSON)
  8797. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8798. utils.ErrorLog("解析失败:%v", err)
  8799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8800. return
  8801. }
  8802. res.ErrMsg = res10265.ErrMsg
  8803. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8804. res.Infcode = infocode
  8805. res.Output = res10265.Output
  8806. res.InfRefmsgid = res10265.InfRefmsgid
  8807. if res.Infcode == 0 {
  8808. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8809. if err == gorm.ErrRecordNotFound {
  8810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8811. return
  8812. } else if err != nil {
  8813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8814. return
  8815. } else {
  8816. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8817. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8818. infoStr := string(Iinfos)
  8819. idetinfoStr := string(Idetinfos)
  8820. psn := &models.HisPsn{
  8821. PsnNo: res.Output.Baseinfo.PsnNo,
  8822. PatientId: patient.ID,
  8823. Certno: res.Output.Baseinfo.Certno,
  8824. //Brdy: res.Output.Baseinfo.Brdy,
  8825. Gend: res.Output.Baseinfo.Gend,
  8826. Naty: res.Output.Baseinfo.Naty,
  8827. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8828. PsnName: res.Output.Baseinfo.PsnName,
  8829. Idetinfo: idetinfoStr,
  8830. Insuinfo: infoStr,
  8831. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8832. CardInfo: card_info,
  8833. VerifyNumber: token,
  8834. }
  8835. var rf []*ResultFive
  8836. json.Unmarshal([]byte(infoStr), &rf)
  8837. var insutypes []*ResultFive
  8838. var insutype string
  8839. var is390 int = 0
  8840. var is310 int = 0
  8841. for _, item := range rf {
  8842. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8843. insutypes = append(insutypes, item)
  8844. }
  8845. }
  8846. if len(insutypes) == 1 {
  8847. insutype = insutypes[0].Insutype
  8848. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8849. } else {
  8850. for _, i := range insutypes {
  8851. if i.Insutype == "390" {
  8852. is390 = 1
  8853. }
  8854. if i.Insutype == "310" {
  8855. is310 = 1
  8856. }
  8857. }
  8858. }
  8859. if is390 == 1 {
  8860. insutype = "390"
  8861. }
  8862. if is310 == 1 {
  8863. insutype = "310"
  8864. }
  8865. if len(insutypes) == 0 {
  8866. insutype = "310"
  8867. }
  8868. service.CreateHisPsn(psn)
  8869. c.ServeSuccessJSON(map[string]interface{}{
  8870. "patient": patient,
  8871. "number": token,
  8872. "insutype": insutype,
  8873. })
  8874. }
  8875. } else {
  8876. c.ServeSuccessJSON(map[string]interface{}{
  8877. "failed_code": -10,
  8878. "msg": res.ErrMsg,
  8879. })
  8880. }
  8881. } else { //读卡失败
  8882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8883. return
  8884. }
  8885. } else if miConfig.MdtrtareaAdmvs == "341203"{
  8886. var api string
  8887. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  8888. "&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
  8889. resp, requestErr := http.Get(api)
  8890. if requestErr != nil {
  8891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8892. return
  8893. }
  8894. body, ioErr := ioutil.ReadAll(resp.Body)
  8895. if ioErr != nil {
  8896. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8898. return
  8899. }
  8900. var respJSON map[string]interface{}
  8901. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8902. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8904. return
  8905. }
  8906. var status string
  8907. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8908. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8909. var token string
  8910. var res ResultTwo //1101结果
  8911. if status == "1" { //读卡成功
  8912. var card_info string //卡信息
  8913. var busi_card_info string
  8914. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8915. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8916. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8917. fmt.Println(card_info)
  8918. fmt.Println(busi_card_info)
  8919. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8920. result, _ := json.Marshal(respJSON)
  8921. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8922. utils.ErrorLog("解析失败:%v", err)
  8923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8924. return
  8925. }
  8926. if res.Infcode == 0 {
  8927. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8928. if err == gorm.ErrRecordNotFound {
  8929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8930. return
  8931. } else if err != nil {
  8932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8933. return
  8934. } else {
  8935. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8936. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8937. infoStr := string(Iinfos)
  8938. idetinfoStr := string(Idetinfos)
  8939. psn := &models.HisPsn{
  8940. PsnNo: res.Output.Baseinfo.PsnNo,
  8941. PatientId: patient.ID,
  8942. Certno: res.Output.Baseinfo.Certno,
  8943. Gend: res.Output.Baseinfo.Gend,
  8944. Naty: res.Output.Baseinfo.Naty,
  8945. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8946. PsnName: res.Output.Baseinfo.PsnName,
  8947. Idetinfo: idetinfoStr,
  8948. Insuinfo: infoStr,
  8949. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8950. CardInfo: card_info,
  8951. VerifyNumber: token,
  8952. }
  8953. var rf []*ResultFive
  8954. json.Unmarshal([]byte(infoStr), &rf)
  8955. var insutypes []*ResultFive
  8956. var insutype string
  8957. var is390 int = 0
  8958. var is310 int = 0
  8959. for _, item := range rf {
  8960. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8961. insutypes = append(insutypes, item)
  8962. }
  8963. }
  8964. if len(insutypes) == 1 {
  8965. insutype = insutypes[0].Insutype
  8966. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8967. } else {
  8968. for _, i := range insutypes {
  8969. if i.Insutype == "390" {
  8970. is390 = 1
  8971. }
  8972. if i.Insutype == "310" {
  8973. is310 = 1
  8974. }
  8975. }
  8976. }
  8977. if is390 == 1 {
  8978. insutype = "390"
  8979. }
  8980. if is310 == 1 {
  8981. insutype = "310"
  8982. }
  8983. if len(insutypes) == 0 {
  8984. insutype = "310"
  8985. }
  8986. service.CreateHisPsn(psn)
  8987. c.ServeSuccessJSON(map[string]interface{}{
  8988. "patient": patient,
  8989. "number": token,
  8990. "insutype": insutype,
  8991. })
  8992. }
  8993. } else {
  8994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8995. return
  8996. }
  8997. } else { //读卡失败
  8998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8999. return
  9000. }
  9001. }else if miConfig.MdtrtareaAdmvs == "430800" {
  9002. idNo := c.GetString("idNo")
  9003. userName := c.GetString("userName")
  9004. ecToken := c.GetString("ecToken")
  9005. insuOrg := c.GetString("insuOrg")
  9006. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9007. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9008. var res ResultTwo
  9009. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9010. utils.ErrorLog("解析失败:%v", err)
  9011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9012. return
  9013. }
  9014. if res.Infcode == 0 {
  9015. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9016. if err == gorm.ErrRecordNotFound {
  9017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9018. return
  9019. } else if err != nil {
  9020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9021. return
  9022. } else {
  9023. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9024. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9025. infoStr := string(Iinfos)
  9026. idetinfoStr := string(Idetinfos)
  9027. psn := &models.HisPsn{
  9028. PsnNo: res.Output.Baseinfo.PsnNo,
  9029. PatientId: patient.ID,
  9030. Certno: res.Output.Baseinfo.Certno,
  9031. Gend: res.Output.Baseinfo.Gend,
  9032. Naty: res.Output.Baseinfo.Naty,
  9033. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9034. PsnName: res.Output.Baseinfo.PsnName,
  9035. Idetinfo: idetinfoStr,
  9036. Insuinfo: infoStr,
  9037. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9038. CardInfo: "",
  9039. Stage: "1",
  9040. VerifyNumber: ecToken,
  9041. InsuplcAdmdvs: insuOrg,
  9042. }
  9043. service.CreateHisPsn(psn)
  9044. var rf []*ResultFive
  9045. json.Unmarshal([]byte(infoStr), &rf)
  9046. var insutypes []*ResultFive
  9047. var insutype string
  9048. var is390 int = 0
  9049. var is310 int = 0
  9050. for _, item := range rf {
  9051. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9052. insutypes = append(insutypes, item)
  9053. }
  9054. }
  9055. if len(insutypes) == 1 {
  9056. insutype = insutypes[0].Insutype
  9057. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9058. } else {
  9059. for _, i := range insutypes {
  9060. if i.Insutype == "390" {
  9061. is390 = 1
  9062. }
  9063. if i.Insutype == "310" {
  9064. is310 = 1
  9065. }
  9066. }
  9067. }
  9068. if is390 == 1 {
  9069. insutype = "390"
  9070. }
  9071. if is310 == 1 {
  9072. insutype = "310"
  9073. }
  9074. if len(insutypes) == 0 {
  9075. insutype = "310"
  9076. }
  9077. c.ServeSuccessJSON(map[string]interface{}{
  9078. "patient": patient,
  9079. "number": ecToken,
  9080. "insutype": insutype,
  9081. })
  9082. }
  9083. } else {
  9084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9085. return
  9086. }
  9087. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9088. //if initFlag == 0 {
  9089. //c.TestGetJiangXiBasBaseInit()
  9090. //}
  9091. //if initEleFlag == 0 {
  9092. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9093. //}
  9094. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  9095. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  9096. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9097. type ELeData struct {
  9098. Data struct {
  9099. IdNo string `json:"idNo"`
  9100. IdType string `json:"idType"`
  9101. UserName string `json:"userName"`
  9102. EcToken string `json:"ecToken"`
  9103. InsuOrg string `json:"insuOrg"`
  9104. Gender string `json:"gender"`
  9105. Birthday string `json:"birthday"`
  9106. Nationality string `json:"nationality"`
  9107. Email string `json:"email"`
  9108. Extra string `json:"extra"`
  9109. } `json:"data"`
  9110. Code int `json:"code"`
  9111. Message string `json:"message"`
  9112. }
  9113. var ele ELeData
  9114. err := json.Unmarshal([]byte(result), &ele)
  9115. if err != nil {
  9116. utils.ErrorLog("解析失败:%v", err)
  9117. }
  9118. token := ele.Data.EcToken
  9119. token = Remove0000(token)
  9120. result2, requestLog2 := service.Jxyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  9121. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9122. var res ResultTwo
  9123. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9124. utils.ErrorLog("解析失败:%v", err)
  9125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9126. return
  9127. }
  9128. if res.Infcode == 0 {
  9129. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9130. if err == gorm.ErrRecordNotFound {
  9131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9132. return
  9133. } else if err != nil {
  9134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9135. return
  9136. } else {
  9137. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9138. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9139. infoStr := string(Iinfos)
  9140. idetinfoStr := string(Idetinfos)
  9141. psn := &models.HisPsn{
  9142. PsnNo: res.Output.Baseinfo.PsnNo,
  9143. PatientId: patient.ID,
  9144. Certno: res.Output.Baseinfo.Certno,
  9145. Gend: res.Output.Baseinfo.Gend,
  9146. Naty: res.Output.Baseinfo.Naty,
  9147. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9148. PsnName: res.Output.Baseinfo.PsnName,
  9149. Idetinfo: idetinfoStr,
  9150. Insuinfo: infoStr,
  9151. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9152. CardInfo: "",
  9153. VerifyNumber: token,
  9154. }
  9155. service.CreateHisPsn(psn)
  9156. var rf []*ResultFive
  9157. json.Unmarshal([]byte(infoStr), &rf)
  9158. var insutypes []*ResultFive
  9159. var insutype string
  9160. var is390 int = 0
  9161. var is310 int = 0
  9162. for _, item := range rf {
  9163. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9164. insutypes = append(insutypes, item)
  9165. }
  9166. }
  9167. if len(insutypes) == 1 {
  9168. insutype = insutypes[0].Insutype
  9169. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9170. } else {
  9171. for _, i := range insutypes {
  9172. if i.Insutype == "390" {
  9173. is390 = 1
  9174. }
  9175. if i.Insutype == "310" {
  9176. is310 = 1
  9177. }
  9178. }
  9179. }
  9180. if is390 == 1 {
  9181. insutype = "390"
  9182. }
  9183. if is310 == 1 {
  9184. insutype = "310"
  9185. }
  9186. if len(insutypes) == 0 {
  9187. insutype = "310"
  9188. }
  9189. c.ServeSuccessJSON(map[string]interface{}{
  9190. "patient": patient,
  9191. "number": token,
  9192. "insutype": insutype,
  9193. })
  9194. }
  9195. } else {
  9196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9197. return
  9198. }
  9199. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9200. //if initFlag == 0 {
  9201. c.TestGetJiangXiBasBaseInit()
  9202. //}
  9203. //if initEleFlag == 0 {
  9204. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9205. //}
  9206. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9207. type ELeData struct {
  9208. Data struct {
  9209. IdNo string `json:"idNo"`
  9210. IdType string `json:"idType"`
  9211. UserName string `json:"userName"`
  9212. EcToken string `json:"ecToken"`
  9213. InsuOrg string `json:"insuOrg"`
  9214. Gender string `json:"gender"`
  9215. Birthday string `json:"birthday"`
  9216. Nationality string `json:"nationality"`
  9217. Email string `json:"email"`
  9218. Extra string `json:"extra"`
  9219. } `json:"data"`
  9220. Code int `json:"code"`
  9221. Message string `json:"message"`
  9222. }
  9223. var ele ELeData
  9224. err := json.Unmarshal([]byte(json_result), &ele)
  9225. if err != nil {
  9226. utils.ErrorLog("解析失败:%v", err)
  9227. }
  9228. token := ele.Data.EcToken
  9229. token = Remove0000(token)
  9230. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  9231. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9232. var res ResultTwo
  9233. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9234. utils.ErrorLog("解析失败:%v", err)
  9235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9236. return
  9237. }
  9238. if res.Infcode == 0 {
  9239. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9240. if err == gorm.ErrRecordNotFound {
  9241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9242. return
  9243. } else if err != nil {
  9244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9245. return
  9246. } else {
  9247. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9248. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9249. infoStr := string(Iinfos)
  9250. idetinfoStr := string(Idetinfos)
  9251. psn := &models.HisPsn{
  9252. PsnNo: res.Output.Baseinfo.PsnNo,
  9253. PatientId: patient.ID,
  9254. Certno: res.Output.Baseinfo.Certno,
  9255. Gend: res.Output.Baseinfo.Gend,
  9256. Naty: res.Output.Baseinfo.Naty,
  9257. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9258. PsnName: res.Output.Baseinfo.PsnName,
  9259. Idetinfo: idetinfoStr,
  9260. Insuinfo: infoStr,
  9261. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9262. CardInfo: "",
  9263. VerifyNumber: token,
  9264. }
  9265. service.CreateHisPsn(psn)
  9266. var rf []*ResultFive
  9267. json.Unmarshal([]byte(infoStr), &rf)
  9268. var insutypes []*ResultFive
  9269. var insutype string
  9270. var is390 int = 0
  9271. var is310 int = 0
  9272. for _, item := range rf {
  9273. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9274. insutypes = append(insutypes, item)
  9275. }
  9276. }
  9277. if len(insutypes) == 1 {
  9278. insutype = insutypes[0].Insutype
  9279. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9280. } else {
  9281. for _, i := range insutypes {
  9282. if i.Insutype == "390" {
  9283. is390 = 1
  9284. }
  9285. if i.Insutype == "310" {
  9286. is310 = 1
  9287. }
  9288. }
  9289. }
  9290. if is390 == 1 {
  9291. insutype = "390"
  9292. }
  9293. if is310 == 1 {
  9294. insutype = "310"
  9295. }
  9296. if len(insutypes) == 0 {
  9297. insutype = "310"
  9298. }
  9299. c.ServeSuccessJSON(map[string]interface{}{
  9300. "patient": patient,
  9301. "number": token,
  9302. "insutype": insutype,
  9303. })
  9304. }
  9305. } else {
  9306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9307. return
  9308. }
  9309. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9310. type ELeData struct {
  9311. Code string `json:"code"`
  9312. Data struct {
  9313. Aac002 string `json:"aac002"`
  9314. Aaz500 string `json:"aaz500"`
  9315. ActCardNo string `json:"actCardNo"`
  9316. Bab520 string `json:"bab520"`
  9317. Bkz543 string `json:"bkz543"`
  9318. BusinessType string `json:"businessType"`
  9319. CertfCodg string `json:"certfCodg"`
  9320. EcIndexNo string `json:"ecIndexNo"`
  9321. EcToken string `json:"ecToken"`
  9322. ID0000 string `json:"id0000"`
  9323. IDNo string `json:"idNo"`
  9324. IDType string `json:"idType"`
  9325. Idcode string `json:"idcode"`
  9326. IdentityToken string `json:"identity_token"`
  9327. InsuOrg string `json:"insuOrg"`
  9328. OfficeID string `json:"officeId"`
  9329. OfficeName string `json:"officeName"`
  9330. OperatorID string `json:"operatorId"`
  9331. OperatorName string `json:"operatorName"`
  9332. OrgID string `json:"orgId"`
  9333. UserName string `json:"userName"`
  9334. } `json:"data"`
  9335. Infno interface{} `json:"infno"`
  9336. Message string `json:"message"`
  9337. OrgID string `json:"orgId"`
  9338. TransType string `json:"transType"`
  9339. }
  9340. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  9341. outPutInfo = Remove0000(outPutInfo)
  9342. if len(outPutInfo) > 0 {
  9343. var ele ELeData
  9344. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9345. if err != nil {
  9346. utils.ErrorLog("解析失败:%v", err)
  9347. }
  9348. token := ele.Data.EcToken
  9349. fmt.Println(inputInfo)
  9350. fmt.Println(outPutInfo)
  9351. result, requestLog, errMsgLog := service.FJyb1101ForEleToken(ele.Data.IDNo, miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, id_card_type, "", 1, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, token, ele.Data.UserName)
  9352. saveLog(result, requestLog, "1101", "获取人员信息")
  9353. var dat map[string]interface{}
  9354. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9355. fmt.Println(dat)
  9356. } else {
  9357. fmt.Println(err)
  9358. }
  9359. userJSONBytes, _ := json.Marshal(dat)
  9360. var res ResultTwo
  9361. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9362. utils.ErrorLog("解析失败:%v", err)
  9363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9364. return
  9365. }
  9366. res.ErrMsg = errMsgLog
  9367. if res.Infcode == 0 {
  9368. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  9369. if err == gorm.ErrRecordNotFound {
  9370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9371. return
  9372. } else if err != nil {
  9373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9374. return
  9375. } else {
  9376. fmt.Println(res)
  9377. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9378. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9379. infoStr := string(Iinfos)
  9380. idetinfoStr := string(Idetinfos)
  9381. psn := &models.HisPsn{
  9382. PsnNo: res.Output.Baseinfo.PsnNo,
  9383. PatientId: patient.ID,
  9384. Certno: res.Output.Baseinfo.Certno,
  9385. Gend: res.Output.Baseinfo.Gend,
  9386. Naty: res.Output.Baseinfo.Naty,
  9387. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9388. PsnName: res.Output.Baseinfo.PsnName,
  9389. Idetinfo: idetinfoStr,
  9390. Insuinfo: infoStr,
  9391. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9392. CardInfo: outPutInfo,
  9393. VerifyNumber: token,
  9394. InsuplcAdmdvs: ele.Data.InsuOrg,
  9395. }
  9396. service.CreateHisPsn(psn)
  9397. var rf []*ResultFive
  9398. json.Unmarshal([]byte(infoStr), &rf)
  9399. var insutypes []*ResultFive
  9400. var insutype string
  9401. var is390 int = 0
  9402. var is310 int = 0
  9403. for _, item := range rf {
  9404. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  9405. insutypes = append(insutypes, item)
  9406. }
  9407. }
  9408. if len(insutypes) == 1 {
  9409. insutype = insutypes[0].Insutype
  9410. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9411. } else {
  9412. for _, i := range insutypes {
  9413. if i.Insutype == "390" {
  9414. is390 = 1
  9415. }
  9416. if i.Insutype == "310" {
  9417. is310 = 1
  9418. }
  9419. }
  9420. }
  9421. if is390 == 1 {
  9422. insutype = "390"
  9423. }
  9424. if is310 == 1 {
  9425. insutype = "310"
  9426. }
  9427. if len(insutypes) == 0 {
  9428. insutype = "310"
  9429. }
  9430. c.ServeSuccessJSON(map[string]interface{}{
  9431. "patient": patient,
  9432. "number": token,
  9433. "insutype": insutype,
  9434. })
  9435. }
  9436. } else {
  9437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9438. return
  9439. }
  9440. }
  9441. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9442. var api string
  9443. api = "http://172.16.13.254:9532/" + "nmyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  9444. "&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
  9445. resp, requestErr := http.Get(api)
  9446. if requestErr != nil {
  9447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9448. return
  9449. }
  9450. body, ioErr := ioutil.ReadAll(resp.Body)
  9451. if ioErr != nil {
  9452. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9454. return
  9455. }
  9456. var respJSON map[string]interface{}
  9457. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9460. return
  9461. }
  9462. var status string
  9463. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9464. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9465. var token string
  9466. var res ResultTwo //1101结果
  9467. var res10265 ResultTwo10265 //1101结果
  9468. if status == "0" { //读卡成功
  9469. var card_info string //卡信息
  9470. var busi_card_info string
  9471. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9472. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9473. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9474. fmt.Println(card_info)
  9475. fmt.Println(busi_card_info)
  9476. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9477. result, _ := json.Marshal(respJSON)
  9478. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9479. utils.ErrorLog("解析失败:%v", err)
  9480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9481. return
  9482. }
  9483. res.ErrMsg = res10265.ErrMsg
  9484. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9485. res.Infcode = infocode
  9486. res.Output = res10265.Output
  9487. res.InfRefmsgid = res10265.InfRefmsgid
  9488. if res.Infcode == 0 {
  9489. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9490. if err == gorm.ErrRecordNotFound {
  9491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9492. return
  9493. } else if err != nil {
  9494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9495. return
  9496. } else {
  9497. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9498. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9499. infoStr := string(Iinfos)
  9500. idetinfoStr := string(Idetinfos)
  9501. psn := &models.HisPsn{
  9502. PsnNo: res.Output.Baseinfo.PsnNo,
  9503. PatientId: patient.ID,
  9504. Certno: res.Output.Baseinfo.Certno,
  9505. Gend: res.Output.Baseinfo.Gend,
  9506. Naty: res.Output.Baseinfo.Naty,
  9507. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9508. PsnName: res.Output.Baseinfo.PsnName,
  9509. Idetinfo: idetinfoStr,
  9510. Insuinfo: infoStr,
  9511. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9512. CardInfo: card_info,
  9513. VerifyNumber: token,
  9514. }
  9515. var rf []*ResultFive
  9516. json.Unmarshal([]byte(infoStr), &rf)
  9517. var insutypes []*ResultFive
  9518. var insutype string
  9519. var is390 int = 0
  9520. var is310 int = 0
  9521. for _, item := range rf {
  9522. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9523. insutypes = append(insutypes, item)
  9524. }
  9525. }
  9526. if len(insutypes) == 1 {
  9527. insutype = insutypes[0].Insutype
  9528. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9529. } else {
  9530. for _, i := range insutypes {
  9531. if i.Insutype == "390" {
  9532. is390 = 1
  9533. }
  9534. if i.Insutype == "310" {
  9535. is310 = 1
  9536. }
  9537. }
  9538. }
  9539. if is390 == 1 {
  9540. insutype = "390"
  9541. }
  9542. if is310 == 1 {
  9543. insutype = "310"
  9544. }
  9545. if len(insutypes) == 0 {
  9546. insutype = "310"
  9547. }
  9548. service.CreateHisPsn(psn)
  9549. c.ServeSuccessJSON(map[string]interface{}{
  9550. "patient": patient,
  9551. "number": token,
  9552. "insutype": insutype,
  9553. })
  9554. }
  9555. } else {
  9556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9557. return
  9558. }
  9559. } else { //读卡失败
  9560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9561. return
  9562. }
  9563. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9564. res := c.GetoleInfo()
  9565. if res.Infcode == 0 {
  9566. var result string
  9567. if res.Output.MdtrtCertType == "01" {
  9568. result = service.Gdyb1101d(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 4, res.Output.CardSN, 1, res.Output.PsnName, res.Output.EcToken, admin_user_id)
  9569. } else if res.Output.MdtrtCertType == "02" {
  9570. result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, res.Output.CardSN, 1, res.Output.PsnName, res.Output.CardNo, admin_user_id)
  9571. } else if res.Output.MdtrtCertType == "03" {
  9572. result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, res.Output.CardSN, 1, res.Output.PsnName, res.Output.CardNo, admin_user_id)
  9573. }
  9574. var dat map[string]interface{}
  9575. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9576. fmt.Println(dat)
  9577. } else {
  9578. fmt.Println(err)
  9579. }
  9580. userJSONBytes, _ := json.Marshal(dat)
  9581. var res2 ResultTwo
  9582. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9583. utils.ErrorLog("解析失败:%v", err)
  9584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9585. return
  9586. }
  9587. if res2.Infcode == 0 {
  9588. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9589. if err == gorm.ErrRecordNotFound {
  9590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9591. return
  9592. } else if err != nil {
  9593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9594. return
  9595. } else {
  9596. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9597. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9598. infoStr := string(Iinfos)
  9599. idetinfoStr := string(Idetinfos)
  9600. var rf []*ResultFive
  9601. json.Unmarshal([]byte(infoStr), &rf)
  9602. var insutypes []*ResultFive
  9603. var insutype string
  9604. var is390 int = 0
  9605. var is310 int = 0
  9606. //var insuplc_admdvs string
  9607. for _, item := range rf {
  9608. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9609. insutypes = append(insutypes, item)
  9610. }
  9611. }
  9612. if len(insutypes) == 1 {
  9613. insutype = insutypes[0].Insutype
  9614. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9615. } else {
  9616. for _, i := range insutypes {
  9617. if i.Insutype == "390" {
  9618. is390 = 1
  9619. }
  9620. if i.Insutype == "310" {
  9621. is310 = 1
  9622. }
  9623. }
  9624. }
  9625. if is390 == 1 {
  9626. insutype = "390"
  9627. }
  9628. if is310 == 1 {
  9629. insutype = "310"
  9630. }
  9631. if len(insutypes) == 0 {
  9632. insutype = "310"
  9633. }
  9634. psn := &models.HisPsn{
  9635. PsnNo: res2.Output.Baseinfo.PsnNo,
  9636. PatientId: patient.ID,
  9637. Certno: res2.Output.Baseinfo.Certno,
  9638. Gend: res2.Output.Baseinfo.Gend,
  9639. Naty: res2.Output.Baseinfo.Naty,
  9640. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9641. PsnName: res2.Output.Baseinfo.PsnName,
  9642. Idetinfo: idetinfoStr,
  9643. Insuinfo: infoStr,
  9644. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9645. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9646. VerifyNumber: res.Output.EcToken,
  9647. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9648. }
  9649. if res.Output.MdtrtCertType == "01" {
  9650. psn.VerifyNumber = res.Output.EcToken
  9651. //result = service.Gdyb1101d(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 4, res.Output.CardSN, 1, res.Output.PsnName, res.Output.EcToken,admin_user_id)
  9652. } else if res.Output.MdtrtCertType == "02" {
  9653. psn.VerifyNumber = res.Output.CardNo
  9654. //result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, res.Output.CardSN, 1, res.Output.PsnName, res.Output.CardNo,admin_user_id)
  9655. } else if res.Output.MdtrtCertType == "03" {
  9656. psn.VerifyNumber = res.Output.MdtrtCertNo
  9657. //result = service.Gdyb1101B(res.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, res.Output.CardSN, 1, res.Output.PsnName, res.Output.CardNo,admin_user_id)
  9658. }
  9659. service.CreateHisPsn(psn)
  9660. var balc float64
  9661. for _, item := range rf {
  9662. if item.Insutype == insutype{
  9663. balc =item.Balc
  9664. }
  9665. }
  9666. c.ServeSuccessJSON(map[string]interface{}{
  9667. "patient": patient,
  9668. "number": res.Output.CardNo,
  9669. "insutype": insutype,
  9670. "blac":balc,
  9671. "desc":idetinfoStr,
  9672. })
  9673. }
  9674. } else {
  9675. c.ServeSuccessJSON(map[string]interface{}{
  9676. "failed_code": -10,
  9677. "msg": res2.ErrMsg,
  9678. })
  9679. }
  9680. } else {
  9681. c.ServeSuccessJSON(map[string]interface{}{
  9682. "failed_code": -10,
  9683. "msg": res.ErrMsg,
  9684. })
  9685. }
  9686. } else {
  9687. type ELeData struct {
  9688. Code string `json:"code"`
  9689. Data struct {
  9690. Aac002 string `json:"aac002"`
  9691. Aaz500 string `json:"aaz500"`
  9692. ActCardNo string `json:"actCardNo"`
  9693. Bab520 string `json:"bab520"`
  9694. Bkz543 string `json:"bkz543"`
  9695. BusinessType string `json:"businessType"`
  9696. CertfCodg string `json:"certfCodg"`
  9697. EcIndexNo string `json:"ecIndexNo"`
  9698. EcToken string `json:"ecToken"`
  9699. ID0000 string `json:"id0000"`
  9700. IDNo string `json:"idNo"`
  9701. IDType string `json:"idType"`
  9702. Idcode string `json:"idcode"`
  9703. IdentityToken string `json:"identity_token"`
  9704. InsuOrg string `json:"insuOrg"`
  9705. OfficeID string `json:"officeId"`
  9706. OfficeName string `json:"officeName"`
  9707. OperatorID string `json:"operatorId"`
  9708. OperatorName string `json:"operatorName"`
  9709. OrgID string `json:"orgId"`
  9710. UserName string `json:"userName"`
  9711. } `json:"data"`
  9712. Infno interface{} `json:"infno"`
  9713. Message string `json:"message"`
  9714. OrgID string `json:"orgId"`
  9715. TransType string `json:"transType"`
  9716. }
  9717. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  9718. fmt.Println(result)
  9719. outPutInfo := Remove0000(result)
  9720. fmt.Println(outPutInfo)
  9721. if len(outPutInfo) > 0 {
  9722. var ele ELeData
  9723. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9724. if err != nil {
  9725. utils.ErrorLog("解析失败:%v", err)
  9726. }
  9727. token := ele.Data.EcToken
  9728. fmt.Println(outPutInfo)
  9729. result, requestLog := service.Gdyb1101ForEleCert1111(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo,certificates)
  9730. saveLog(result, requestLog, "1101", "获取人员信息")
  9731. var dat map[string]interface{}
  9732. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9733. fmt.Println(dat)
  9734. } else {
  9735. fmt.Println(err)
  9736. }
  9737. userJSONBytes, _ := json.Marshal(dat)
  9738. var res ResultTwo
  9739. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9740. utils.ErrorLog("解析失败:%v", err)
  9741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9742. return
  9743. }
  9744. if res.Infcode == 0 {
  9745. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  9746. if err == gorm.ErrRecordNotFound {
  9747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9748. return
  9749. } else if err != nil {
  9750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9751. return
  9752. } else {
  9753. fmt.Println(res)
  9754. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9755. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9756. infoStr := string(Iinfos)
  9757. idetinfoStr := string(Idetinfos)
  9758. psn := &models.HisPsn{
  9759. PsnNo: res.Output.Baseinfo.PsnNo,
  9760. PatientId: patient.ID,
  9761. Certno: res.Output.Baseinfo.Certno,
  9762. Gend: res.Output.Baseinfo.Gend,
  9763. Naty: res.Output.Baseinfo.Naty,
  9764. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9765. PsnName: res.Output.Baseinfo.PsnName,
  9766. Idetinfo: idetinfoStr,
  9767. Insuinfo: infoStr,
  9768. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9769. CardInfo: outPutInfo,
  9770. VerifyNumber: token,
  9771. InsuplcAdmdvs: ele.Data.InsuOrg,
  9772. }
  9773. service.CreateHisPsn(psn)
  9774. var rf []*ResultFive
  9775. json.Unmarshal([]byte(infoStr), &rf)
  9776. var insutypes []*ResultFive
  9777. var insutype string
  9778. var is390 int = 0
  9779. var is310 int = 0
  9780. for _, item := range rf {
  9781. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9782. insutypes = append(insutypes, item)
  9783. }
  9784. }
  9785. if len(insutypes) == 1 {
  9786. insutype = insutypes[0].Insutype
  9787. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9788. } else {
  9789. for _, i := range insutypes {
  9790. if i.Insutype == "390" {
  9791. is390 = 1
  9792. }
  9793. if i.Insutype == "310" {
  9794. is310 = 1
  9795. }
  9796. }
  9797. }
  9798. if is390 == 1 {
  9799. insutype = "390"
  9800. }
  9801. if is310 == 1 {
  9802. insutype = "310"
  9803. }
  9804. if len(insutypes) == 0 {
  9805. insutype = "310"
  9806. }
  9807. c.ServeSuccessJSON(map[string]interface{}{
  9808. "patient": patient,
  9809. "number": token,
  9810. "insutype": insutype,
  9811. })
  9812. }
  9813. } else {
  9814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9815. return
  9816. }
  9817. }
  9818. //fmt.Println(result)
  9819. //
  9820. //if initFlag == 0 {
  9821. // c.TestGetBasBaseInit()
  9822. //}
  9823. //token := c.GetEleBaseInfo()
  9824. //
  9825. //token = Remove0000(token)
  9826. //
  9827. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  9828. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  9829. ////
  9830. //var res ResultTwo
  9831. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9832. // utils.ErrorLog("解析失败:%v", err)
  9833. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9834. // return
  9835. //}
  9836. //
  9837. //if res.Infcode == 0 {
  9838. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9839. // if err == gorm.ErrRecordNotFound {
  9840. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9841. // return
  9842. // } else if err != nil {
  9843. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9844. // return
  9845. //
  9846. // } else {
  9847. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9848. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9849. // infoStr := string(Iinfos)
  9850. // idetinfoStr := string(Idetinfos)
  9851. //
  9852. //
  9853. //
  9854. //
  9855. // var rf []*ResultFive
  9856. // json.Unmarshal([]byte(infoStr), &rf)
  9857. //
  9858. // var insutypes []*ResultFive
  9859. // var insutype string
  9860. // var is390 int = 0
  9861. // var is310 int = 0
  9862. // var insuplc_admdvs string
  9863. //
  9864. // for _, item := range rf {
  9865. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9866. // insutypes = append(insutypes, item)
  9867. // }
  9868. // }
  9869. //
  9870. // if len(insutypes) == 1 {
  9871. // insutype = insutypes[0].Insutype
  9872. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9873. // } else {
  9874. // for _, i := range insutypes {
  9875. // if i.Insutype == "390" {
  9876. // is390 = 1
  9877. // }
  9878. //
  9879. // if i.Insutype == "310" {
  9880. // is310 = 1
  9881. // }
  9882. // }
  9883. // }
  9884. // if is390 == 1 {
  9885. // insutype = "390"
  9886. // }
  9887. //
  9888. // if is310 == 1 {
  9889. // insutype = "310"
  9890. // }
  9891. // if len(insutypes) == 0 {
  9892. // insutype = "310"
  9893. // }
  9894. // for _, item := range rf {
  9895. // if item.Insutype == insutype {
  9896. // insuplc_admdvs = item.InsuplcAdmdvs
  9897. // }
  9898. // }
  9899. // psn := &models.HisPsn{
  9900. // PsnNo: res.Output.Baseinfo.PsnNo,
  9901. // Age: res.Output.Baseinfo.Age,
  9902. // PatientId: patient.ID,
  9903. // Certno: res.Output.Baseinfo.Certno,
  9904. // Brdy: res.Output.Baseinfo.Brdy,
  9905. // Gend: res.Output.Baseinfo.Gend,
  9906. // Naty: res.Output.Baseinfo.Naty,
  9907. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9908. // PsnName: res.Output.Baseinfo.PsnName,
  9909. // Idetinfo: idetinfoStr,
  9910. // Insuinfo: infoStr,
  9911. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9912. // CardInfo: "",
  9913. // VerifyNumber: token,
  9914. // InsuplcAdmdvs: insuplc_admdvs,
  9915. // }
  9916. // service.CreateHisPsn(psn)
  9917. //
  9918. // c.ServeSuccessJSON(map[string]interface{}{
  9919. // "patient": patient,
  9920. // "number": token,
  9921. // })
  9922. // }
  9923. //} else {
  9924. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9925. // return
  9926. //}
  9927. }
  9928. break
  9929. case 5:
  9930. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9931. var api string
  9932. if miConfig.MdtrtareaAdmvs == "320921" {
  9933. api = "http://192.168.2.3:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  9934. "&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
  9935. fmt.Println(api)
  9936. } else {
  9937. 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 +
  9938. "&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)
  9939. }
  9940. resp, requestErr := http.Get(api)
  9941. if requestErr != nil {
  9942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9943. return
  9944. }
  9945. body, ioErr := ioutil.ReadAll(resp.Body)
  9946. if ioErr != nil {
  9947. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9949. return
  9950. }
  9951. var respJSON map[string]interface{}
  9952. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9953. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9955. return
  9956. }
  9957. var status string
  9958. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9959. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9960. var token string
  9961. var res ResultTwo //1101结果
  9962. var res10265 ResultTwo10265 //1101结果
  9963. if status == "0" { //读卡成功
  9964. var card_info string //卡信息
  9965. //var busi_card_info string
  9966. var auth_info string
  9967. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9968. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9969. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9970. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  9971. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9972. result, _ := json.Marshal(respJSON)
  9973. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9974. utils.ErrorLog("解析失败:%v", err)
  9975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9976. return
  9977. }
  9978. res.ErrMsg = res10265.ErrMsg
  9979. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9980. res.Infcode = infocode
  9981. res.Output = res10265.Output
  9982. res.InfRefmsgid = res10265.InfRefmsgid
  9983. if res.Infcode == 0 {
  9984. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9985. if err == gorm.ErrRecordNotFound {
  9986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9987. return
  9988. } else if err != nil {
  9989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9990. return
  9991. } else {
  9992. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9993. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9994. infoStr := string(Iinfos)
  9995. idetinfoStr := string(Idetinfos)
  9996. psn := &models.HisPsn{
  9997. PsnNo: res.Output.Baseinfo.PsnNo,
  9998. PatientId: patient.ID,
  9999. Certno: res.Output.Baseinfo.Certno,
  10000. Gend: res.Output.Baseinfo.Gend,
  10001. //Brdy: res.Output.Baseinfo.Brdy,
  10002. Naty: res.Output.Baseinfo.Naty,
  10003. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10004. PsnName: res.Output.Baseinfo.PsnName,
  10005. Idetinfo: idetinfoStr,
  10006. Insuinfo: infoStr,
  10007. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10008. CardInfo: card_info,
  10009. VerifyNumber: token,
  10010. AuthInfo: auth_info,
  10011. }
  10012. var rf []*ResultFive
  10013. json.Unmarshal([]byte(infoStr), &rf)
  10014. var insutypes []*ResultFive
  10015. var insutype string
  10016. var is390 int = 0
  10017. var is310 int = 0
  10018. for _, item := range rf {
  10019. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10020. insutypes = append(insutypes, item)
  10021. }
  10022. }
  10023. if len(insutypes) == 1 {
  10024. insutype = insutypes[0].Insutype
  10025. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10026. } else {
  10027. for _, i := range insutypes {
  10028. if i.Insutype == "390" {
  10029. is390 = 1
  10030. }
  10031. if i.Insutype == "310" {
  10032. is310 = 1
  10033. }
  10034. }
  10035. }
  10036. if is390 == 1 {
  10037. insutype = "390"
  10038. }
  10039. if is310 == 1 {
  10040. insutype = "310"
  10041. }
  10042. if len(insutypes) == 0 {
  10043. insutype = "310"
  10044. }
  10045. service.CreateHisPsn(psn)
  10046. c.ServeSuccessJSON(map[string]interface{}{
  10047. "patient": patient,
  10048. "number": token,
  10049. "insutype": insutype,
  10050. })
  10051. }
  10052. } else {
  10053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10054. return
  10055. }
  10056. } else { //读卡失败
  10057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10058. return
  10059. }
  10060. }
  10061. break
  10062. }
  10063. }
  10064. var initFlag int64 = 0
  10065. var initEleFlag int64 = 0
  10066. func (c *HisApiController) TestGetBasBaseInit() {
  10067. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10068. Iinit := DllDef.MustFindProc("Init")
  10069. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10070. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  10071. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  10072. if ret != 0 {
  10073. fmt.Println("SSCard的报错原因:", err)
  10074. fmt.Println("SSCard的运算结果为:", ret)
  10075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10076. return
  10077. }
  10078. result := int(ret)
  10079. fmt.Println("SSCard的运算结果为1:", result)
  10080. initFlag = 1
  10081. return
  10082. }
  10083. func (c *HisApiController) HandleJiangXiReadCard() {
  10084. fmt.Println("~~~~~~")
  10085. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10086. admin_user_id, _ := c.GetInt64("admin_user_id")
  10087. id_card_type, _ := c.GetInt64("id_card_type")
  10088. //certificates, _ := c.GetInt64("certificates")
  10089. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10090. if initFlag == 0 {
  10091. c.TestGetJiangXiBasBaseInit()
  10092. }
  10093. basStr := c.GetBasBaseInfo()
  10094. if len(basStr) == 0 {
  10095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10096. return
  10097. }
  10098. fmt.Println(basStr)
  10099. bas := strings.Split(basStr, "|")
  10100. basNumber := bas[1]
  10101. fmt.Println(basNumber)
  10102. card_sn := bas[3]
  10103. fmt.Println(card_sn)
  10104. result, _ := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, "1", miConfig.Url, miConfig.AccessKey, "")
  10105. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  10106. var dat map[string]interface{}
  10107. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10108. fmt.Println(dat)
  10109. } else {
  10110. fmt.Println(err)
  10111. }
  10112. userJSONBytes, _ := json.Marshal(dat)
  10113. var res ResultTwo
  10114. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10115. utils.ErrorLog("解析失败:%v", err)
  10116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10117. return
  10118. }
  10119. if res.Infcode == 0 {
  10120. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  10121. if err == gorm.ErrRecordNotFound {
  10122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10123. return
  10124. } else if err != nil {
  10125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10126. return
  10127. } else {
  10128. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10129. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10130. infoStr := string(Iinfos)
  10131. idetinfoStr := string(Idetinfos)
  10132. psn := &models.HisPsn{
  10133. PsnNo: res.Output.Baseinfo.PsnNo,
  10134. PatientId: patient.ID,
  10135. Certno: res.Output.Baseinfo.Certno,
  10136. Gend: res.Output.Baseinfo.Gend,
  10137. Naty: res.Output.Baseinfo.Naty,
  10138. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10139. PsnName: res.Output.Baseinfo.PsnName,
  10140. Idetinfo: idetinfoStr,
  10141. Insuinfo: infoStr,
  10142. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10143. CardInfo: basStr,
  10144. VerifyNumber: "",
  10145. }
  10146. service.CreateHisPsn(psn)
  10147. c.ServeSuccessJSON(map[string]interface{}{
  10148. "patient": patient,
  10149. "number": basNumber,
  10150. })
  10151. }
  10152. } else {
  10153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10154. return
  10155. }
  10156. }
  10157. func (c *HisApiController) TestGetHnBasBaseInit() {
  10158. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10159. Iinit := DllDef.MustFindProc("Init")
  10160. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10161. //http://10.77.211.236/CSB/hsa-fsi-1303
  10162. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  10163. if ret != 0 {
  10164. fmt.Println("SSCard的报错原因:", err)
  10165. fmt.Println("SSCard的运算结果为:", ret)
  10166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10167. return
  10168. }
  10169. result := int(ret)
  10170. fmt.Println("SSCard的运算结果为1:", result)
  10171. initFlag = 1
  10172. return
  10173. }
  10174. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  10175. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10176. Iinit := DllDef.MustFindProc("Init")
  10177. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10178. //http://10.77.211.236/CSB/hsa-fsi-1303
  10179. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  10180. if ret != 0 {
  10181. fmt.Println("SSCard的报错原因:", err)
  10182. fmt.Println("SSCard的运算结果为:", ret)
  10183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10184. return
  10185. }
  10186. result := int(ret)
  10187. fmt.Println("SSCard的运算结果为1:", result)
  10188. initFlag = 1
  10189. return
  10190. }
  10191. func (c *HisApiController) GetSFZBaseInfo() string {
  10192. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10193. readCard := DllDef.MustFindProc("ReadSFZ")
  10194. if readCard == nil {
  10195. fmt.Println("readcard is nil")
  10196. readCard = DllDef.MustFindProc("ReadSFZ")
  10197. }
  10198. str := make([]byte, 8096)
  10199. str1 := make([]byte, 8096)
  10200. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  10201. fmt.Println(r)
  10202. return Remove0000(string(str))
  10203. }
  10204. func (c *HisApiController) GetEleBaseInfo() string {
  10205. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10206. readCard := DllDef.MustFindProc("GetQRBase")
  10207. fmt.Println(readCard)
  10208. if readCard == nil {
  10209. fmt.Println("readcard is nil")
  10210. readCard = DllDef.MustFindProc("GetQRBase")
  10211. }
  10212. str := make([]byte, 1024)
  10213. str1 := make([]byte, 1024)
  10214. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  10215. fmt.Println(ret2)
  10216. fmt.Println(string(str1))
  10217. fmt.Println(string(str))
  10218. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10219. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  10220. if ret2 != 0 {
  10221. return ""
  10222. }
  10223. return string(str)
  10224. }
  10225. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  10226. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  10227. readCard := DllDef.MustFindProc("NationEcTrans")
  10228. fmt.Println(readCard)
  10229. fmt.Println("!!!!!")
  10230. pBusiCardInfo := make([]byte, 2048)
  10231. input := make(map[string]interface{})
  10232. inputData := make(map[string]interface{})
  10233. inputData["orgId"] = code
  10234. inputData["businessType"] = "01101"
  10235. inputData["operatorId"] = "1"
  10236. inputData["operatorName"] = "admin"
  10237. inputData["officeId"] = "001"
  10238. inputData["officeName"] = "血透室"
  10239. inputData["deviceType"] = ""
  10240. input["data"] = inputData
  10241. input["orgId"] = code
  10242. input["transType"] = "ec.query"
  10243. bytesData, _ := json.Marshal(input)
  10244. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  10245. fmt.Println(ret2)
  10246. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  10247. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  10248. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  10249. }
  10250. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  10251. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  10252. readCard := DllDef.MustFindProc("NationEcTrans")
  10253. fmt.Println(readCard)
  10254. fmt.Println("!!!!!")
  10255. pBusiCardInfo := make([]byte, 2048)
  10256. input := make(map[string]interface{})
  10257. inputData := make(map[string]interface{})
  10258. inputData["orgId"] = code
  10259. inputData["businessType"] = "01101"
  10260. inputData["operatorId"] = "9"
  10261. inputData["operatorName"] = "admin"
  10262. inputData["officeId"] = "001"
  10263. inputData["officeName"] = "血透室"
  10264. inputData["deviceType"] = ""
  10265. input["data"] = inputData
  10266. input["orgId"] = code
  10267. input["transType"] = "ec.query"
  10268. bytesData, _ := json.Marshal(input)
  10269. ret2, _, _ := readCard.Call(StrPtr("http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  10270. fmt.Println(ret2)
  10271. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  10272. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  10273. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  10274. }
  10275. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  10276. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  10277. readCard := DllDef.MustFindProc("NationEcTrans")
  10278. fmt.Println(readCard)
  10279. fmt.Println("!!!!!")
  10280. pBusiCardInfo := make([]byte, 2048)
  10281. input := make(map[string]interface{})
  10282. inputData := make(map[string]interface{})
  10283. inputData["orgId"] = code
  10284. inputData["businessType"] = "01301"
  10285. inputData["operatorId"] = "9"
  10286. inputData["operatorName"] = "admin"
  10287. inputData["officeId"] = "001"
  10288. inputData["officeName"] = "血透室"
  10289. inputData["deviceType"] = ""
  10290. input["data"] = inputData
  10291. input["orgId"] = code
  10292. input["transType"] = "ec.query"
  10293. bytesData, _ := json.Marshal(input)
  10294. ret2, _, _ := readCard.Call(StrPtr("http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  10295. fmt.Println(ret2)
  10296. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  10297. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  10298. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  10299. }
  10300. func GetJxEleBaseInfo(org_id int64) string {
  10301. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10302. readCard := DllDef.MustFindProc("NationEcTrans")
  10303. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10304. if readCard == nil {
  10305. fmt.Println("readcard is nil")
  10306. readCard = DllDef.MustFindProc("NationEcTrans")
  10307. }
  10308. str1 := make([]byte, 1024)
  10309. data := make(map[string]interface{})
  10310. inputData := make(map[string]interface{})
  10311. inputData["orgId"] = miConfig.Code
  10312. inputData["businessType"] = "01101"
  10313. inputData["operatorId"] = "test001"
  10314. inputData["operatorName"] = "cn"
  10315. inputData["officeId"] = "32760"
  10316. inputData["officeName"] = "waike"
  10317. inputData["deviceType"] = ""
  10318. data["data"] = inputData
  10319. data["transType"] = "ec.query"
  10320. data["extra "] = ""
  10321. data["orgId"] = miConfig.Code
  10322. bytesData, _ := json.Marshal(data)
  10323. //bytesData, _ := json.Marshal(data)
  10324. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  10325. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  10326. fmt.Println(ret2)
  10327. fmt.Println(string(str1))
  10328. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10329. if ret2 != 0 {
  10330. return ""
  10331. }
  10332. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  10333. }
  10334. func GetJxEleBaseInitInfo(org_id int64) string {
  10335. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10336. readCard := DllDef.MustFindProc("NationEcTrans")
  10337. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10338. if readCard == nil {
  10339. fmt.Println("readcard is nil")
  10340. readCard = DllDef.MustFindProc("NationEcTrans")
  10341. }
  10342. str1 := make([]byte, 2048)
  10343. data := make(map[string]interface{})
  10344. inputData := make(map[string]interface{})
  10345. inputData["orgId"] = miConfig.Code
  10346. inputData["businessType"] = "01101"
  10347. inputData["operatorId"] = "1"
  10348. inputData["operatorName"] = "huangchuang"
  10349. inputData["officeId"] = "101"
  10350. inputData["officeName"] = "xuetou"
  10351. inputData["deviceType"] = ""
  10352. data["data"] = inputData
  10353. data["transType"] = "ec.query"
  10354. data["orgId"] = miConfig.Code
  10355. bytesData, _ := json.Marshal(data)
  10356. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  10357. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  10358. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  10359. fmt.Println(ret2)
  10360. fmt.Println(string(str1))
  10361. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10362. if ret2 != 0 {
  10363. return ""
  10364. }
  10365. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  10366. initEleFlag = 1
  10367. }
  10368. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  10369. }
  10370. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  10371. // // 构建命令
  10372. // cmd := exec.Command("python", "b.py")
  10373. //
  10374. // // 执行命令并等待完成
  10375. // output, err := cmd.CombinedOutput()
  10376. // if err != nil {
  10377. // fmt.Println("Error executing Python script:", err)
  10378. // return
  10379. // }
  10380. //
  10381. // // 打印Python脚本的输出
  10382. // fmt.Println(string(output))
  10383. //}
  10384. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  10385. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  10386. readCard := DllDef.MustFindProc("gxyb_call")
  10387. if readCard == nil {
  10388. fmt.Println("readcard is nil")
  10389. readCard = DllDef.MustFindProc("gxyb_call")
  10390. }
  10391. str := make([]byte, 1024)
  10392. str1 := make([]byte, 1024)
  10393. //data := make(map[string]interface{})
  10394. currentTime := time.Now()
  10395. // 格式化时间为 "YYYYMMDDHH24MISS"
  10396. formattedTime := currentTime.Format("20060102150405")
  10397. inputData := make(map[string]interface{})
  10398. inputData2 := make(map[string]interface{})
  10399. inputData["transNo"] = "1401"
  10400. inputData["transType"] = "passwordCheck"
  10401. inputData["timestamp"] = formattedTime
  10402. inputData2["fixmedinsCode"] = code
  10403. inputData2["psnNo"] = ""
  10404. inputData["data"] = inputData2
  10405. jsonBytes, err := json.Marshal(inputData)
  10406. if err != nil {
  10407. fmt.Println("Error encoding map to JSON:", err)
  10408. }
  10409. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  10410. fmt.Println(string(str1))
  10411. fmt.Println(string(str))
  10412. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10413. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  10414. if ret2 != 0 {
  10415. return ""
  10416. }
  10417. return string(str)
  10418. }
  10419. func (c *HisApiController) GetoleInfo() Response {
  10420. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  10421. defer ole.CoUninitialize()
  10422. // Replace with the ProgID or CLSID of your COM object
  10423. progID := "YinHai.XJ.Actual.Interface.New"
  10424. // Create COM object
  10425. unknown, err := oleutil.CreateObject(progID)
  10426. if err != nil {
  10427. fmt.Println("Unable to create COM object:", err)
  10428. }
  10429. defer unknown.Release()
  10430. // Query for the IDispatch interface
  10431. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  10432. if err != nil {
  10433. fmt.Println("Unable to get IDispatch interface:", err)
  10434. }
  10435. defer dispatch.Release()
  10436. // Prepare parameters
  10437. transNo := "1401"
  10438. transType := "passwordCheck"
  10439. timestamp := time.Now().Unix()
  10440. fixmedinsCode := "H45072101171"
  10441. psnNo := ""
  10442. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  10443. result2 := ""
  10444. // Call COM object's method using the IDispatch interface
  10445. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  10446. fmt.Println(resulr)
  10447. fmt.Println(result2)
  10448. if err != nil {
  10449. fmt.Println("调用COM对象方法失败:", err)
  10450. }
  10451. var response Response
  10452. err2 := json.Unmarshal([]byte(result2), &response)
  10453. if err2 != nil {
  10454. fmt.Println("解析JSON失败:", err)
  10455. }
  10456. return response
  10457. }
  10458. func (c *HisApiController) GetBasBaseInfo() string {
  10459. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10460. readCard := DllDef.MustFindProc("ReadCardBas")
  10461. if readCard == nil {
  10462. fmt.Println("readcard is nil")
  10463. readCard = DllDef.MustFindProc("ReadCardBas")
  10464. }
  10465. str := make([]byte, 1024)
  10466. str1 := make([]byte, 1024)
  10467. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  10468. fmt.Println(string(str1))
  10469. fmt.Println(string(str))
  10470. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10471. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  10472. if ret2 != 0 {
  10473. return ""
  10474. }
  10475. return string(str)
  10476. }
  10477. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  10478. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  10479. readCard := DllDef.MustFindProc("read_cardinfo")
  10480. if readCard == nil {
  10481. fmt.Println("readcard is nil")
  10482. readCard = DllDef.MustFindProc("read_cardinfo")
  10483. }
  10484. str := make([]byte, 1024) //卡号
  10485. str1 := make([]byte, 1024) //卡识别码
  10486. str2 := make([]byte, 1024) //身份证号
  10487. str3 := make([]byte, 1024) //姓名
  10488. str4 := make([]byte, 1024) //错误信息
  10489. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])), (uintptr)(unsafe.Pointer(&str2[0])), (uintptr)(unsafe.Pointer(&str3[0])), (uintptr)(unsafe.Pointer(&str4[0])))
  10490. fmt.Println(string(str1))
  10491. fmt.Println(string(str))
  10492. fmt.Println(string(str2))
  10493. fmt.Println(string(str3))
  10494. fmt.Println(string(str4))
  10495. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10496. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  10497. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  10498. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  10499. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  10500. if ret2 != 0 {
  10501. return "", "", "", "", ""
  10502. }
  10503. return string(str), string(str1), string(str2), string(str3), string(str4)
  10504. }
  10505. type CustomFundPay struct {
  10506. FundPayType string `json:"fund_pay_type"`
  10507. FundPayamt float64 `json:"fund_payamt"`
  10508. InscpScpAmt float64 `json:"inscp_scp_amt"`
  10509. }
  10510. //func (c *HisApiController) GetBatchSettleList() {
  10511. // start_time_str := c.GetString("start_time")
  10512. // //end_time_str := c.GetString("end_time")
  10513. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10514. //
  10515. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  10516. //
  10517. // for _, item := range orders {
  10518. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  10519. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  10520. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  10521. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  10522. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10523. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  10524. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10525. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  10526. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  10527. //
  10528. // if order.ID == 0 {
  10529. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  10530. // return
  10531. // }
  10532. //
  10533. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  10534. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  10535. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  10536. // //fmt.Println(count)
  10537. // //var zero string
  10538. // //number := count + 1
  10539. // //if number >= 1000 {
  10540. // // zero = "0000" + strconv.FormatInt(number, 10)
  10541. // //} else if number >= 10000 {
  10542. // // zero = "000" + strconv.FormatInt(number, 10)
  10543. // //} else if number >= 100000 {
  10544. // // zero = "00" + strconv.FormatInt(number, 10)
  10545. // //} else if number >= 1000000 {
  10546. // // zero = "0" + strconv.FormatInt(number, 10)
  10547. // //} else {
  10548. // // zero = strconv.FormatInt(number, 10)
  10549. // //}
  10550. // //fmt.Println(zero)
  10551. //
  10552. // struct4101 := service.Struct4101{
  10553. // PsnNo: order.PsnNo,
  10554. // MdtrtId: order.MdtrtId,
  10555. // SetlId: order.SetlId,
  10556. // PsnName: order.PsnName,
  10557. // Gend: order.Gend,
  10558. // Brdy: his.Brdy,
  10559. // Age: his.Age,
  10560. // Naty: order.Naty,
  10561. // PatnCertType: "01",
  10562. // Certno: order.Certno,
  10563. // Prfs: "90",
  10564. // ConerName: roles[0].UserName,
  10565. // PatnRlts: "99",
  10566. // ConerAddr: miConfig.OrgName,
  10567. // ConerTel: admin.Mobile,
  10568. // HiType: order.Insutype,
  10569. // Insuplc: miConfig.InsuplcAdmdvs,
  10570. // MaindiagFlag: "1",
  10571. // BillCode: order.SetlId,
  10572. // BillNo: order.SetlId,
  10573. // BizSn: order.Number,
  10574. // PsnSelfPay: order.PsnPartAmt,
  10575. // PsnOwnPay: order.PsnPartAmt,
  10576. // AcctPay: order.AcctPay,
  10577. // PsnCashpay: order.PsnCashPay,
  10578. // HiPaymtd: "1",
  10579. // Hsorg: miConfig.InsuplcAdmdvs,
  10580. // HsorgOpter: miConfig.InsuplcAdmdvs,
  10581. // MedinsFillPsn: curRoles.UserName,
  10582. // MedinsFillDept: miConfig.OrgName,
  10583. // IptMedType: "2",
  10584. // }
  10585. // struct4101.SetlBegnDate = order.SetlTime
  10586. // struct4101.SetlEndDate = order.SetlTime
  10587. // time_arr := strings.Split(order.SetlTime, " ")
  10588. // struct4101.AdmTime = time_arr[0]
  10589. // struct4101.AdmEndTime = time_arr[0]
  10590. //
  10591. // var rf []CustomFundPay
  10592. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  10593. //
  10594. // var tempFunPays []service.CustomStruct
  10595. // for _, item := range rf {
  10596. // var tempFunPay service.CustomStruct
  10597. // tempFunPay.FundPayamt = item.FundPayamt
  10598. // tempFunPay.FundPayType = item.FundPayType
  10599. // tempFunPays = append(tempFunPays, tempFunPay)
  10600. // }
  10601. // struct4101.CustomStruct = tempFunPays
  10602. //
  10603. // var tempDiaginfos []service.DiaginfoStructTwo
  10604. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  10605. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  10606. //
  10607. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10608. // var config []*models.HisXtDiagnoseConfig
  10609. // for _, item := range diagnosis_ids {
  10610. // id, _ := strconv.ParseInt(item, 10, 64)
  10611. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  10612. // config = append(config, &diagnosisConfig)
  10613. // }
  10614. //
  10615. // for index, item := range config {
  10616. // if index == 0 {
  10617. // var tempDiaginfo service.DiaginfoStructTwo
  10618. // tempDiaginfo.DiagCode = item.CountryCode
  10619. // tempDiaginfo.DiagName = item.CountryContentName
  10620. // tempDiaginfo.DiagType = "1"
  10621. // tempDiaginfo.MaindiagFlag = "1"
  10622. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  10623. // } else {
  10624. // var tempDiaginfo service.DiaginfoStructTwo
  10625. // tempDiaginfo.DiagCode = item.CountryCode
  10626. // tempDiaginfo.DiagName = item.CountryContentName
  10627. // tempDiaginfo.DiagType = "1"
  10628. // tempDiaginfo.MaindiagFlag = "0"
  10629. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  10630. // }
  10631. // }
  10632. // struct4101.Diseinfo = tempDiaginfos
  10633. //
  10634. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  10635. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  10636. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  10637. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  10638. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  10639. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  10640. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  10641. //
  10642. // var iteminfo service.IteminfoStruct
  10643. //
  10644. // var bedCostTotal float64 = 0 //床位总费
  10645. // var bedCostSelfTotal float64 = 0 //床位自费
  10646. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  10647. //
  10648. // var operationCostTotal float64 = 0 //手术费
  10649. // var operationCostSelfTotal float64 = 0 //手术费
  10650. // var operationCostPartSelfTotal float64 = 0 //手术费
  10651. //
  10652. // var otherCostTotal float64 = 0 //其他费用
  10653. // var otherCostSelfTotal float64 = 0 //其他费用
  10654. // var otherCostPartSelfTotal float64 = 0 //其他费用
  10655. //
  10656. // var materialCostTotal float64 = 0 //材料费
  10657. // var materialCostSelfTotal float64 = 0 //材料费
  10658. // var materialCostPartSelfTotal float64 = 0 //材料费
  10659. //
  10660. // var westernMedicineCostTotal float64 = 0 //西药费
  10661. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  10662. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  10663. //
  10664. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  10665. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  10666. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  10667. //
  10668. // var checkCostTotal float64 = 0 //检查费
  10669. // var checkCostSelfTotal float64 = 0 //检查费
  10670. // var checkCostPartSelfTotal float64 = 0 //检查费
  10671. //
  10672. // var laboratoryCostTotal float64 = 0 //化验费
  10673. // var laboratoryCostSelfTotal float64 = 0 //化验费
  10674. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  10675. //
  10676. // var treatCostTotal float64 = 0 //治疗费用
  10677. // var treatCostSelfTotal float64 = 0 //治疗费用
  10678. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  10679. //
  10680. // decimal.DivisionPrecision = 2
  10681. //
  10682. // var bed_fulamt_ownpay_amt float64 = 0
  10683. // var operation_fulamt_ownpay_amt float64 = 0
  10684. // var other_fulamt_ownpay_amt float64 = 0
  10685. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  10686. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  10687. // var check_fulamt_ownpay_amt float64 = 0
  10688. // var material_fulamt_ownpay_amt float64 = 0
  10689. // var laboratory_fulamt_ownpay_amt float64 = 0
  10690. // var treat_fulamt_ownpay_amt float64 = 0
  10691. //
  10692. // var bed_claa_sunmfee float64 = 0
  10693. // var bed_clab_amt float64 = 0
  10694. // var bed_other_amt float64 = 0
  10695. //
  10696. // var operation_claa_sunmfee float64 = 0
  10697. // var operation_clab_amt float64 = 0
  10698. // var operation_other_amt float64 = 0
  10699. //
  10700. // var other_claa_sunmfee float64 = 0
  10701. // var other_clab_amt float64 = 0
  10702. // var other_other_amt float64 = 0
  10703. //
  10704. // var westernMedicine_claa_sunmfee float64 = 0
  10705. // var westernMedicine_clab_amt float64 = 0
  10706. // var westernMedicine_other_amt float64 = 0
  10707. //
  10708. // var chineseTraditional_claa_sunmfee float64 = 0
  10709. // var chineseTraditional_clab_amt float64 = 0
  10710. // var chineseTraditional_other_amt float64 = 0
  10711. //
  10712. // var check_claa_sunmfee float64 = 0
  10713. // var check_clab_amt float64 = 0
  10714. // var check_other_amt float64 = 0
  10715. //
  10716. // var material_claa_sunmfee float64 = 0
  10717. // var material_clab_amt float64 = 0
  10718. // var material_other_amt float64 = 0
  10719. //
  10720. // var laboratory_claa_sunmfee float64 = 0
  10721. // var laboratory_clab_amt float64 = 0
  10722. // var laboratory_other_amt float64 = 0
  10723. //
  10724. // var treat_claa_sunmfee float64 = 0
  10725. // var treat_clab_amt float64 = 0
  10726. // var treat_other_amt float64 = 0
  10727. //
  10728. // for _, item := range order.HisOrderInfo {
  10729. // if item.MedChrgitmType == "01" { //床位费
  10730. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10731. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10732. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10733. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10734. // if item.ChrgitmLv == "1" {
  10735. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10736. // }
  10737. // if item.ChrgitmLv == "2" {
  10738. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10739. //
  10740. // }
  10741. // if item.ChrgitmLv == "3" {
  10742. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10743. // }
  10744. //
  10745. // }
  10746. //
  10747. // if item.MedChrgitmType == "03" { //检查费
  10748. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10749. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10750. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10751. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10752. // if item.ChrgitmLv == "1" {
  10753. //
  10754. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10755. //
  10756. // }
  10757. // if item.ChrgitmLv == "2" {
  10758. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10759. //
  10760. // }
  10761. // if item.ChrgitmLv == "3" {
  10762. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10763. // }
  10764. // }
  10765. //
  10766. // if item.MedChrgitmType == "04" { //化验费
  10767. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10768. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10769. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10770. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10771. // if item.ChrgitmLv == "1" {
  10772. //
  10773. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10774. //
  10775. // }
  10776. // if item.ChrgitmLv == "2" {
  10777. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10778. //
  10779. // }
  10780. // if item.ChrgitmLv == "3" {
  10781. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10782. // }
  10783. // }
  10784. //
  10785. // if item.MedChrgitmType == "05" { //治疗费
  10786. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10787. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10788. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10789. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10790. // if item.ChrgitmLv == "1" {
  10791. //
  10792. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10793. //
  10794. // }
  10795. // if item.ChrgitmLv == "2" {
  10796. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10797. //
  10798. // }
  10799. // if item.ChrgitmLv == "3" {
  10800. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10801. // }
  10802. // }
  10803. //
  10804. // if item.MedChrgitmType == "06" { //手术费
  10805. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10806. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10807. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10808. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10809. //
  10810. // if item.ChrgitmLv == "1" {
  10811. //
  10812. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10813. //
  10814. // }
  10815. // if item.ChrgitmLv == "2" {
  10816. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10817. //
  10818. // }
  10819. // if item.ChrgitmLv == "3" {
  10820. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10821. // }
  10822. // }
  10823. //
  10824. // if item.MedChrgitmType == "08" { //材料费
  10825. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10826. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10827. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10828. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10829. // if item.ChrgitmLv == "1" {
  10830. //
  10831. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10832. //
  10833. // }
  10834. // if item.ChrgitmLv == "2" {
  10835. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10836. //
  10837. // }
  10838. // if item.ChrgitmLv == "3" {
  10839. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10840. // }
  10841. // }
  10842. //
  10843. // if item.MedChrgitmType == "09" { //西药费
  10844. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10845. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10846. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10847. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10848. // if item.ChrgitmLv == "1" {
  10849. //
  10850. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10851. //
  10852. // }
  10853. // if item.ChrgitmLv == "2" {
  10854. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10855. //
  10856. // }
  10857. // if item.ChrgitmLv == "3" {
  10858. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10859. // }
  10860. // }
  10861. //
  10862. // if item.MedChrgitmType == "11" { //中成费
  10863. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10864. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10865. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10866. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10867. // if item.ChrgitmLv == "1" {
  10868. //
  10869. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10870. //
  10871. // }
  10872. // if item.ChrgitmLv == "2" {
  10873. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10874. //
  10875. // }
  10876. // if item.ChrgitmLv == "3" {
  10877. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10878. // }
  10879. // }
  10880. //
  10881. // if item.MedChrgitmType == "14" { //其他费
  10882. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10883. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10884. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10885. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10886. // if item.ChrgitmLv == "1" {
  10887. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10888. //
  10889. // }
  10890. // if item.ChrgitmLv == "2" {
  10891. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10892. //
  10893. // }
  10894. // if item.ChrgitmLv == "3" {
  10895. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10896. // }
  10897. // }
  10898. //
  10899. // }
  10900. //
  10901. // var iteminfoStructs []service.IteminfoStruct
  10902. //
  10903. // if bedCostTotal != 0 {
  10904. // iteminfo.MedChrgitm = "01"
  10905. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  10906. // iteminfo.Amt = bedCostTotal
  10907. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  10908. // iteminfo.ClabAmt = bed_clab_amt
  10909. // iteminfo.OthAmt = bed_other_amt
  10910. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  10911. // }
  10912. //
  10913. // if checkCostTotal != 0 {
  10914. // iteminfo.MedChrgitm = "03"
  10915. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  10916. // iteminfo.Amt = checkCostTotal
  10917. // iteminfo.ClaaSumfee = check_claa_sunmfee
  10918. // iteminfo.ClabAmt = check_clab_amt
  10919. // iteminfo.OthAmt = check_other_amt
  10920. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  10921. //
  10922. // }
  10923. //
  10924. // if laboratoryCostTotal != 0 {
  10925. // iteminfo.MedChrgitm = "04"
  10926. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  10927. // iteminfo.Amt = laboratoryCostTotal
  10928. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  10929. // iteminfo.ClabAmt = laboratory_clab_amt
  10930. // iteminfo.OthAmt = laboratory_other_amt
  10931. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  10932. //
  10933. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  10934. //
  10935. // }
  10936. //
  10937. // if treatCostTotal != 0 {
  10938. // iteminfo.MedChrgitm = "05"
  10939. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  10940. // iteminfo.Amt = treatCostTotal
  10941. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  10942. // iteminfo.ClabAmt = treat_clab_amt
  10943. // iteminfo.OthAmt = treat_other_amt
  10944. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  10945. // //(struct4101.IteminfoStruct, iteminfo)
  10946. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  10947. // }
  10948. //
  10949. // if operationCostTotal != 0 {
  10950. // iteminfo.MedChrgitm = "06"
  10951. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  10952. // iteminfo.Amt = operationCostTotal
  10953. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  10954. // iteminfo.ClabAmt = operation_clab_amt
  10955. // iteminfo.OthAmt = operation_other_amt
  10956. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  10957. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  10958. // }
  10959. //
  10960. // if materialCostTotal != 0 {
  10961. // iteminfo.MedChrgitm = "08"
  10962. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  10963. // iteminfo.Amt = materialCostTotal
  10964. // iteminfo.ClaaSumfee = material_claa_sunmfee
  10965. // iteminfo.ClabAmt = material_clab_amt
  10966. // iteminfo.OthAmt = material_other_amt
  10967. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  10968. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  10969. // }
  10970. //
  10971. // if westernMedicineCostTotal != 0 {
  10972. // iteminfo.MedChrgitm = "09"
  10973. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  10974. // iteminfo.Amt = westernMedicineCostTotal
  10975. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  10976. // iteminfo.ClabAmt = westernMedicine_clab_amt
  10977. // iteminfo.OthAmt = westernMedicine_other_amt
  10978. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  10979. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  10980. //
  10981. // }
  10982. // if chineseTraditionalMedicineCostTotal != 0 {
  10983. // iteminfo.MedChrgitm = "11"
  10984. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  10985. // iteminfo.Amt = westernMedicineCostTotal
  10986. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  10987. // iteminfo.ClabAmt = westernMedicine_clab_amt
  10988. // iteminfo.OthAmt = westernMedicine_other_amt
  10989. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  10990. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  10991. //
  10992. // }
  10993. // if otherCostTotal != 0 {
  10994. // iteminfo.MedChrgitm = "14"
  10995. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  10996. // iteminfo.Amt = otherCostTotal
  10997. // iteminfo.ClaaSumfee = other_claa_sunmfee
  10998. // iteminfo.ClabAmt = other_clab_amt
  10999. // iteminfo.OthAmt = other_other_amt
  11000. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11001. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11002. //
  11003. // }
  11004. // struct4101.IteminfoStruct = iteminfoStructs
  11005. // struct4101.Ntly = "中国"
  11006. // struct4101.AdmCaty = "A03.06"
  11007. //
  11008. // struct4101.DoctorName = doctor.UserName
  11009. // struct4101.DoctorCode = doctor.DoctorNumber
  11010. //
  11011. // var res ResultSeventeen
  11012. //
  11013. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11014. // struct4101.BillCode = order.Number
  11015. // struct4101.BillNo = order.SetlId
  11016. // var resOther ResultSeventeenOther
  11017. // var pp models.PublicParams
  11018. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11019. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11020. // pp.FixmedinsName = miConfig.OrgName
  11021. // pp.FixmedinsCode = miConfig.Code
  11022. // pp.RequestUrl = miConfig.Url
  11023. // pp.Cainfo = miConfig.Cainfo
  11024. // pp.SecretKey = miConfig.SecretKey
  11025. // pp.AccessKey = miConfig.AccessKey
  11026. // pp.OpterName = curRoles.UserName
  11027. //
  11028. // client := &http.Client{}
  11029. // var req *http.Request
  11030. // data := make(map[string]interface{})
  11031. // data["struct4101"] = struct4101
  11032. // data["pp"] = pp
  11033. // bytesData, _ := json.Marshal(data)
  11034. // if miConfig.MdtrtareaAdmvs == "320921" {
  11035. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  11036. // } else {
  11037. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  11038. // }
  11039. // resp, _ := client.Do(req)
  11040. // defer resp.Body.Close()
  11041. // body, ioErr := ioutil.ReadAll(resp.Body)
  11042. // if ioErr != nil {
  11043. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11044. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11045. // return
  11046. // }
  11047. // var respJSON map[string]interface{}
  11048. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11049. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11050. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11051. // return
  11052. // }
  11053. //
  11054. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11055. // userJSONBytes, _ := json.Marshal(respJSON)
  11056. // fmt.Println("log")
  11057. // fmt.Println(string(userJSONBytes))
  11058. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  11059. // utils.ErrorLog("解析失败:%v", err)
  11060. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11061. // return
  11062. // }
  11063. // res.InfRefmsgid = resOther.InfRefmsgid
  11064. // res.Output = resOther.Output
  11065. // res.ErrMsg = resOther.ErrMsg
  11066. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  11067. // res.Infcode = infocode
  11068. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  11069. //
  11070. // var pp models.PublicParams
  11071. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11072. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11073. // pp.FixmedinsName = miConfig.OrgName
  11074. // pp.FixmedinsCode = miConfig.Code
  11075. // pp.RequestUrl = miConfig.Url
  11076. // pp.Cainfo = miConfig.Cainfo
  11077. // pp.SecretKey = miConfig.SecretKey
  11078. // pp.AccessKey = miConfig.AccessKey
  11079. // pp.OpterName = curRoles.UserName
  11080. // result, _ := service.Jxyb4101(struct4101, pp)
  11081. // var dat map[string]interface{}
  11082. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11083. // fmt.Println(dat)
  11084. // } else {
  11085. // fmt.Println(err)
  11086. // }
  11087. // userJSONBytes, _ := json.Marshal(dat)
  11088. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11089. // utils.ErrorLog("解析失败:%v", err)
  11090. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11091. // return
  11092. // }
  11093. //
  11094. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  11095. // var pp models.PublicParams
  11096. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11097. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11098. // pp.FixmedinsName = miConfig.OrgName
  11099. // pp.FixmedinsCode = miConfig.Code
  11100. // pp.RequestUrl = miConfig.Url
  11101. // pp.Cainfo = miConfig.Cainfo
  11102. // pp.SecretKey = miConfig.SecretKey
  11103. // pp.AccessKey = miConfig.AccessKey
  11104. // pp.OpterName = curRoles.UserName
  11105. // result, _ := service.Hnyb4101(struct4101, pp)
  11106. // var dat map[string]interface{}
  11107. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11108. // fmt.Println(dat)
  11109. // } else {
  11110. // fmt.Println(err)
  11111. // }
  11112. // userJSONBytes, _ := json.Marshal(dat)
  11113. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11114. // utils.ErrorLog("解析失败:%v", err)
  11115. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11116. // return
  11117. // }
  11118. //
  11119. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  11120. // var resOther ResultSeventeenOther
  11121. //
  11122. // var pp models.PublicParams
  11123. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11124. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11125. // pp.FixmedinsName = miConfig.OrgName
  11126. // pp.FixmedinsCode = miConfig.Code
  11127. // pp.RequestUrl = miConfig.Url
  11128. // pp.Cainfo = miConfig.Cainfo
  11129. // pp.SecretKey = miConfig.SecretKey
  11130. // pp.AccessKey = miConfig.AccessKey
  11131. // pp.OpterName = curRoles.UserName
  11132. // client := &http.Client{}
  11133. // var req *http.Request
  11134. // data := make(map[string]interface{})
  11135. // data["struct4101"] = struct4101
  11136. // data["pp"] = pp
  11137. // bytesData, _ := json.Marshal(data)
  11138. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  11139. // resp, _ := client.Do(req)
  11140. // defer resp.Body.Close()
  11141. // body, ioErr := ioutil.ReadAll(resp.Body)
  11142. // if ioErr != nil {
  11143. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11144. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11145. // return
  11146. // }
  11147. // var respJSON map[string]interface{}
  11148. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11149. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11150. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11151. // return
  11152. // }
  11153. //
  11154. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11155. // userJSONBytes, _ := json.Marshal(respJSON)
  11156. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  11157. // utils.ErrorLog("解析失败:%v", err)
  11158. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11159. // return
  11160. // }
  11161. // res.InfRefmsgid = resOther.InfRefmsgid
  11162. // res.Output = resOther.Output
  11163. // res.ErrMsg = resOther.ErrMsg
  11164. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  11165. // res.Infcode = infocode
  11166. //
  11167. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  11168. // var pp models.PublicParams
  11169. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11170. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11171. // pp.FixmedinsName = miConfig.OrgName
  11172. // pp.FixmedinsCode = miConfig.Code
  11173. // pp.RequestUrl = miConfig.Url
  11174. // pp.Cainfo = miConfig.Cainfo
  11175. // pp.SecretKey = miConfig.SecretKey
  11176. // pp.AccessKey = miConfig.AccessKey
  11177. // pp.OpterName = curRoles.UserName
  11178. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  11179. // fmt.Println(requestLog)
  11180. // fmt.Println(errMsgLog)
  11181. //
  11182. // saveLog(result, requestLog, "4101a", "上传清单")
  11183. //
  11184. // var dat map[string]interface{}
  11185. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11186. // fmt.Println(dat)
  11187. // } else {
  11188. // fmt.Println(err)
  11189. // }
  11190. // userJSONBytes, _ := json.Marshal(dat)
  11191. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11192. // utils.ErrorLog("解析失败:%v", err)
  11193. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11194. // return
  11195. // }
  11196. //
  11197. // } else {
  11198. //
  11199. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  11200. // var dat map[string]interface{}
  11201. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11202. // fmt.Println(dat)
  11203. // } else {
  11204. // fmt.Println(err)
  11205. // }
  11206. // userJSONBytes, _ := json.Marshal(dat)
  11207. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11208. // utils.ErrorLog("解析失败:%v", err)
  11209. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11210. // return
  11211. // }
  11212. // }
  11213. //
  11214. // if res.Infcode != 0 {
  11215. // adminUser := c.GetAdminUserInfo()
  11216. // errlog := &models.HisOrderError{
  11217. // UserOrgId: adminUser.CurrentOrgId,
  11218. // Ctime: time.Now().Unix(),
  11219. // Mtime: time.Now().Unix(),
  11220. // ErrMsg: res.ErrMsg,
  11221. // Status: 1,
  11222. // PatientId: order.ID,
  11223. // Stage: 10265,
  11224. // }
  11225. // service.CreateErrMsgLog(errlog)
  11226. // continue
  11227. // } else {
  11228. // //order.FaPiaoNumber = zero
  11229. // //order.FaPiaoCode = last_order.FaPiaoCode
  11230. // //service.UpdateOrder(order)
  11231. // hisFundSettleListResult := &models.HisFundSettleListResult{
  11232. // Number: res.Output.SetlListId,
  11233. // Status: 1,
  11234. // Ctime: time.Now().Unix(),
  11235. // Mtime: time.Now().Unix(),
  11236. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11237. // IsUpload: 1,
  11238. // OrderId: order.ID,
  11239. // }
  11240. // service.CreateUploadRecord(hisFundSettleListResult)
  11241. // c.ServeSuccessJSON(map[string]interface{}{
  11242. // "msg": "上传成功",
  11243. // "result": hisFundSettleListResult,
  11244. // })
  11245. // continue
  11246. // }
  11247. // }
  11248. //}
  11249. func (c *HisApiController) GetbatchSettleList() {
  11250. //order_id, _ := c.GetInt64("order_id")
  11251. admin_user_id, _ := c.GetInt64("admin_user_id")
  11252. orders, _ := service.GetAllHisOrderTwo10485()
  11253. for _, item := range orders {
  11254. order, _ := service.GetHisOrderByIDTwo(item.ID)
  11255. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  11256. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11257. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  11258. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11259. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  11260. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11261. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  11262. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  11263. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  11264. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  11265. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  11266. //fmt.Println(count)
  11267. //var zero string
  11268. //number := count + 1
  11269. //if number >= 1000 {
  11270. // zero = "0000" + strconv.FormatInt(number, 10)
  11271. //} else if number >= 10000 {
  11272. // zero = "000" + strconv.FormatInt(number, 10)
  11273. //} else if number >= 100000 {
  11274. // zero = "00" + strconv.FormatInt(number, 10)
  11275. //} else if number >= 1000000 {
  11276. // zero = "0" + strconv.FormatInt(number, 10)
  11277. //} else {
  11278. // zero = strconv.FormatInt(number, 10)
  11279. //}
  11280. //fmt.Println(zero)
  11281. struct4101 := service.Struct4101{
  11282. PsnNo: order.PsnNo,
  11283. MdtrtId: order.MdtrtId,
  11284. SetlId: order.SetlId,
  11285. PsnName: order.PsnName,
  11286. Gend: order.Gend,
  11287. Brdy: his.Brdy,
  11288. Age: his.Age,
  11289. Naty: order.Naty,
  11290. PatnCertType: "01",
  11291. Certno: order.Certno,
  11292. Prfs: "90",
  11293. ConerName: roles[0].UserName,
  11294. PatnRlts: "99",
  11295. ConerAddr: miConfig.OrgName,
  11296. ConerTel: admin.Mobile,
  11297. HiType: order.Insutype,
  11298. Insuplc: miConfig.InsuplcAdmdvs,
  11299. MaindiagFlag: "1",
  11300. BillCode: order.SetlId,
  11301. BillNo: order.SetlId,
  11302. BizSn: order.Number,
  11303. PsnSelfPay: order.PsnPartAmt,
  11304. PsnOwnPay: order.PsnPartAmt,
  11305. AcctPay: order.AcctPay,
  11306. PsnCashpay: order.PsnCashPay,
  11307. HiPaymtd: "1",
  11308. Hsorg: miConfig.InsuplcAdmdvs,
  11309. HsorgOpter: miConfig.InsuplcAdmdvs,
  11310. MedinsFillPsn: curRoles.UserName,
  11311. MedinsFillDept: miConfig.OrgName,
  11312. IptMedType: "2",
  11313. }
  11314. struct4101.SetlBegnDate = order.SetlTime
  11315. struct4101.SetlEndDate = order.SetlTime
  11316. time_arr := strings.Split(order.SetlTime, " ")
  11317. struct4101.AdmTime = time_arr[0]
  11318. struct4101.AdmEndTime = time_arr[0]
  11319. //var rf []CustomFundPay
  11320. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  11321. //
  11322. //var tempFunPays []service.CustomStruct
  11323. //for _, item := range rf {
  11324. // var tempFunPay service.CustomStruct
  11325. // tempFunPay.FundPayamt = item.FundPayamt
  11326. // tempFunPay.FundPayType = item.FundPayType
  11327. // tempFunPays = append(tempFunPays, tempFunPay)
  11328. //}
  11329. //struct4101.CustomStruct = tempFunPays
  11330. var tempDiaginfos []service.DiaginfoStructTwo
  11331. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  11332. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  11333. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11334. var config []*models.HisXtDiagnoseConfig
  11335. for _, item := range diagnosis_ids {
  11336. id, _ := strconv.ParseInt(item, 10, 64)
  11337. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11338. config = append(config, &diagnosisConfig)
  11339. }
  11340. for index, item := range config {
  11341. if index == 0 {
  11342. var tempDiaginfo service.DiaginfoStructTwo
  11343. tempDiaginfo.DiagCode = item.CountryCode
  11344. tempDiaginfo.DiagName = item.CountryContentName
  11345. tempDiaginfo.DiagType = "1"
  11346. tempDiaginfo.MaindiagFlag = "1"
  11347. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11348. } else {
  11349. var tempDiaginfo service.DiaginfoStructTwo
  11350. tempDiaginfo.DiagCode = item.CountryCode
  11351. tempDiaginfo.DiagName = item.CountryContentName
  11352. tempDiaginfo.DiagType = "1"
  11353. tempDiaginfo.MaindiagFlag = "0"
  11354. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11355. }
  11356. }
  11357. struct4101.Diseinfo = tempDiaginfos
  11358. sickConfigTwo, _ := service.FindSickById(his.SickType)
  11359. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  11360. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  11361. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  11362. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  11363. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  11364. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  11365. var iteminfo service.IteminfoStruct
  11366. var bedCostTotal float64 = 0 //床位总费
  11367. var bedCostSelfTotal float64 = 0 //床位自费
  11368. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11369. var operationCostTotal float64 = 0 //手术费
  11370. var operationCostSelfTotal float64 = 0 //手术费
  11371. var operationCostPartSelfTotal float64 = 0 //手术费
  11372. var otherCostTotal float64 = 0 //其他费用
  11373. var otherCostSelfTotal float64 = 0 //其他费用
  11374. var otherCostPartSelfTotal float64 = 0 //其他费用
  11375. var materialCostTotal float64 = 0 //材料费
  11376. var materialCostSelfTotal float64 = 0 //材料费
  11377. var materialCostPartSelfTotal float64 = 0 //材料费
  11378. var westernMedicineCostTotal float64 = 0 //西药费
  11379. var westernMedicineCostSelfTotal float64 = 0 //西药费
  11380. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11381. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11382. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11383. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11384. var checkCostTotal float64 = 0 //检查费
  11385. var checkCostSelfTotal float64 = 0 //检查费
  11386. var checkCostPartSelfTotal float64 = 0 //检查费
  11387. var laboratoryCostTotal float64 = 0 //化验费
  11388. var laboratoryCostSelfTotal float64 = 0 //化验费
  11389. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  11390. var treatCostTotal float64 = 0 //治疗费用
  11391. var treatCostSelfTotal float64 = 0 //治疗费用
  11392. var treatCostPartSelfTotal float64 = 0 //治疗费用
  11393. decimal.DivisionPrecision = 2
  11394. var bed_fulamt_ownpay_amt float64 = 0
  11395. var operation_fulamt_ownpay_amt float64 = 0
  11396. var other_fulamt_ownpay_amt float64 = 0
  11397. var westernMedicine_fulamt_ownpay_amt float64 = 0
  11398. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  11399. var check_fulamt_ownpay_amt float64 = 0
  11400. var material_fulamt_ownpay_amt float64 = 0
  11401. var laboratory_fulamt_ownpay_amt float64 = 0
  11402. var treat_fulamt_ownpay_amt float64 = 0
  11403. var bed_claa_sunmfee float64 = 0
  11404. var bed_clab_amt float64 = 0
  11405. var bed_other_amt float64 = 0
  11406. var operation_claa_sunmfee float64 = 0
  11407. var operation_clab_amt float64 = 0
  11408. var operation_other_amt float64 = 0
  11409. var other_claa_sunmfee float64 = 0
  11410. var other_clab_amt float64 = 0
  11411. var other_other_amt float64 = 0
  11412. var westernMedicine_claa_sunmfee float64 = 0
  11413. var westernMedicine_clab_amt float64 = 0
  11414. var westernMedicine_other_amt float64 = 0
  11415. var chineseTraditional_claa_sunmfee float64 = 0
  11416. var chineseTraditional_clab_amt float64 = 0
  11417. var chineseTraditional_other_amt float64 = 0
  11418. var check_claa_sunmfee float64 = 0
  11419. var check_clab_amt float64 = 0
  11420. var check_other_amt float64 = 0
  11421. var material_claa_sunmfee float64 = 0
  11422. var material_clab_amt float64 = 0
  11423. var material_other_amt float64 = 0
  11424. var laboratory_claa_sunmfee float64 = 0
  11425. var laboratory_clab_amt float64 = 0
  11426. var laboratory_other_amt float64 = 0
  11427. var treat_claa_sunmfee float64 = 0
  11428. var treat_clab_amt float64 = 0
  11429. var treat_other_amt float64 = 0
  11430. for _, item := range order.HisOrderInfo {
  11431. if item.MedChrgitmType == "01" { //床位费
  11432. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11433. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11434. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11435. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11436. if item.ChrgitmLv == "1" {
  11437. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11438. }
  11439. if item.ChrgitmLv == "2" {
  11440. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11441. }
  11442. if item.ChrgitmLv == "3" {
  11443. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11444. }
  11445. }
  11446. if item.MedChrgitmType == "03" { //检查费
  11447. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11448. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11449. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11450. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11451. if item.ChrgitmLv == "1" {
  11452. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11453. }
  11454. if item.ChrgitmLv == "2" {
  11455. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11456. }
  11457. if item.ChrgitmLv == "3" {
  11458. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11459. }
  11460. }
  11461. if item.MedChrgitmType == "04" { //化验费
  11462. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11463. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11464. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11465. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11466. if item.ChrgitmLv == "1" {
  11467. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11468. }
  11469. if item.ChrgitmLv == "2" {
  11470. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11471. }
  11472. if item.ChrgitmLv == "3" {
  11473. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11474. }
  11475. }
  11476. if item.MedChrgitmType == "05" { //治疗费
  11477. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11478. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11479. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11480. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11481. if item.ChrgitmLv == "1" {
  11482. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11483. }
  11484. if item.ChrgitmLv == "2" {
  11485. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11486. }
  11487. if item.ChrgitmLv == "3" {
  11488. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11489. }
  11490. }
  11491. if item.MedChrgitmType == "06" { //手术费
  11492. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11493. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11494. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11495. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11496. if item.ChrgitmLv == "1" {
  11497. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11498. }
  11499. if item.ChrgitmLv == "2" {
  11500. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11501. }
  11502. if item.ChrgitmLv == "3" {
  11503. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11504. }
  11505. }
  11506. if item.MedChrgitmType == "08" { //材料费
  11507. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11508. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11509. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11510. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11511. if item.ChrgitmLv == "1" {
  11512. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11513. }
  11514. if item.ChrgitmLv == "2" {
  11515. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11516. }
  11517. if item.ChrgitmLv == "3" {
  11518. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11519. }
  11520. }
  11521. if item.MedChrgitmType == "09" { //西药费
  11522. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11523. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11524. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11525. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11526. if item.ChrgitmLv == "1" {
  11527. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11528. }
  11529. if item.ChrgitmLv == "2" {
  11530. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11531. }
  11532. if item.ChrgitmLv == "3" {
  11533. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11534. }
  11535. }
  11536. if item.MedChrgitmType == "11" { //中成费
  11537. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11538. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11539. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11540. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11541. if item.ChrgitmLv == "1" {
  11542. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11543. }
  11544. if item.ChrgitmLv == "2" {
  11545. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11546. }
  11547. if item.ChrgitmLv == "3" {
  11548. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11549. }
  11550. }
  11551. if item.MedChrgitmType == "14" { //其他费
  11552. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11553. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11554. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11555. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11556. if item.ChrgitmLv == "1" {
  11557. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11558. }
  11559. if item.ChrgitmLv == "2" {
  11560. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11561. }
  11562. if item.ChrgitmLv == "3" {
  11563. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11564. }
  11565. }
  11566. }
  11567. var iteminfoStructs []service.IteminfoStruct
  11568. if bedCostTotal != 0 {
  11569. iteminfo.MedChrgitm = "01"
  11570. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  11571. iteminfo.Amt = bedCostTotal
  11572. iteminfo.ClaaSumfee = bed_claa_sunmfee
  11573. iteminfo.ClabAmt = bed_clab_amt
  11574. iteminfo.OthAmt = bed_other_amt
  11575. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11576. }
  11577. if checkCostTotal != 0 {
  11578. iteminfo.MedChrgitm = "03"
  11579. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  11580. iteminfo.Amt = checkCostTotal
  11581. iteminfo.ClaaSumfee = check_claa_sunmfee
  11582. iteminfo.ClabAmt = check_clab_amt
  11583. iteminfo.OthAmt = check_other_amt
  11584. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11585. }
  11586. if laboratoryCostTotal != 0 {
  11587. iteminfo.MedChrgitm = "04"
  11588. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  11589. iteminfo.Amt = laboratoryCostTotal
  11590. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  11591. iteminfo.ClabAmt = laboratory_clab_amt
  11592. iteminfo.OthAmt = laboratory_other_amt
  11593. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11594. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11595. }
  11596. if treatCostTotal != 0 {
  11597. iteminfo.MedChrgitm = "05"
  11598. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  11599. iteminfo.Amt = treatCostTotal
  11600. iteminfo.ClaaSumfee = treat_claa_sunmfee
  11601. iteminfo.ClabAmt = treat_clab_amt
  11602. iteminfo.OthAmt = treat_other_amt
  11603. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11604. //(struct4101.IteminfoStruct, iteminfo)
  11605. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11606. }
  11607. if operationCostTotal != 0 {
  11608. iteminfo.MedChrgitm = "06"
  11609. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  11610. iteminfo.Amt = operationCostTotal
  11611. iteminfo.ClaaSumfee = operation_claa_sunmfee
  11612. iteminfo.ClabAmt = operation_clab_amt
  11613. iteminfo.OthAmt = operation_other_amt
  11614. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11615. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11616. }
  11617. if materialCostTotal != 0 {
  11618. iteminfo.MedChrgitm = "08"
  11619. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  11620. iteminfo.Amt = materialCostTotal
  11621. iteminfo.ClaaSumfee = material_claa_sunmfee
  11622. iteminfo.ClabAmt = material_clab_amt
  11623. iteminfo.OthAmt = material_other_amt
  11624. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11625. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11626. }
  11627. if westernMedicineCostTotal != 0 {
  11628. iteminfo.MedChrgitm = "09"
  11629. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  11630. iteminfo.Amt = westernMedicineCostTotal
  11631. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  11632. iteminfo.ClabAmt = westernMedicine_clab_amt
  11633. iteminfo.OthAmt = westernMedicine_other_amt
  11634. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11635. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11636. }
  11637. if chineseTraditionalMedicineCostTotal != 0 {
  11638. iteminfo.MedChrgitm = "11"
  11639. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  11640. iteminfo.Amt = westernMedicineCostTotal
  11641. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  11642. iteminfo.ClabAmt = westernMedicine_clab_amt
  11643. iteminfo.OthAmt = westernMedicine_other_amt
  11644. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11645. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11646. }
  11647. if otherCostTotal != 0 {
  11648. iteminfo.MedChrgitm = "14"
  11649. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  11650. iteminfo.Amt = otherCostTotal
  11651. iteminfo.ClaaSumfee = other_claa_sunmfee
  11652. iteminfo.ClabAmt = other_clab_amt
  11653. iteminfo.OthAmt = other_other_amt
  11654. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11655. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11656. }
  11657. struct4101.IteminfoStruct = iteminfoStructs
  11658. struct4101.Ntly = "中国"
  11659. struct4101.AdmCaty = "A03.06"
  11660. struct4101.DoctorName = doctor.UserName
  11661. struct4101.DoctorCode = doctor.DoctorNumber
  11662. var res ResultSeventeen
  11663. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11664. struct4101.BillCode = order.Number
  11665. struct4101.BillNo = order.SetlId
  11666. var resOther ResultSeventeenOther
  11667. var pp models.PublicParams
  11668. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11669. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11670. pp.FixmedinsName = miConfig.OrgName
  11671. pp.FixmedinsCode = miConfig.Code
  11672. pp.RequestUrl = miConfig.Url
  11673. pp.Cainfo = miConfig.Cainfo
  11674. pp.SecretKey = miConfig.SecretKey
  11675. pp.AccessKey = miConfig.AccessKey
  11676. pp.OpterName = curRoles.UserName
  11677. client := &http.Client{}
  11678. var req *http.Request
  11679. data := make(map[string]interface{})
  11680. data["struct4101"] = struct4101
  11681. data["pp"] = pp
  11682. bytesData, _ := json.Marshal(data)
  11683. if miConfig.MdtrtareaAdmvs == "320921" {
  11684. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  11685. } else {
  11686. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  11687. }
  11688. resp, _ := client.Do(req)
  11689. defer resp.Body.Close()
  11690. body, ioErr := ioutil.ReadAll(resp.Body)
  11691. if ioErr != nil {
  11692. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11694. return
  11695. }
  11696. var respJSON map[string]interface{}
  11697. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11700. return
  11701. }
  11702. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11703. userJSONBytes, _ := json.Marshal(respJSON)
  11704. fmt.Println("log")
  11705. fmt.Println(string(userJSONBytes))
  11706. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  11707. utils.ErrorLog("解析失败:%v", err)
  11708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11709. return
  11710. }
  11711. res.InfRefmsgid = resOther.InfRefmsgid
  11712. res.Output = resOther.Output
  11713. res.ErrMsg = resOther.ErrMsg
  11714. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  11715. res.Infcode = infocode
  11716. } else if miConfig.MdtrtareaAdmvs == "360302" {
  11717. var pp models.PublicParams
  11718. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11719. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11720. pp.FixmedinsName = miConfig.OrgName
  11721. pp.FixmedinsCode = miConfig.Code
  11722. pp.RequestUrl = miConfig.Url
  11723. pp.Cainfo = miConfig.Cainfo
  11724. pp.SecretKey = miConfig.SecretKey
  11725. pp.AccessKey = miConfig.AccessKey
  11726. pp.OpterName = curRoles.UserName
  11727. result, _ := service.Jxyb4101(struct4101, pp)
  11728. var dat map[string]interface{}
  11729. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11730. fmt.Println(dat)
  11731. } else {
  11732. fmt.Println(err)
  11733. }
  11734. userJSONBytes, _ := json.Marshal(dat)
  11735. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11736. utils.ErrorLog("解析失败:%v", err)
  11737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11738. return
  11739. }
  11740. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11741. var pp models.PublicParams
  11742. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11743. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11744. pp.FixmedinsName = miConfig.OrgName
  11745. pp.FixmedinsCode = miConfig.Code
  11746. pp.RequestUrl = miConfig.Url
  11747. pp.Cainfo = miConfig.Cainfo
  11748. pp.SecretKey = miConfig.SecretKey
  11749. pp.AccessKey = miConfig.AccessKey
  11750. pp.OpterName = curRoles.UserName
  11751. result, _ := service.Hnyb4101(struct4101, pp)
  11752. var dat map[string]interface{}
  11753. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11754. fmt.Println(dat)
  11755. } else {
  11756. fmt.Println(err)
  11757. }
  11758. userJSONBytes, _ := json.Marshal(dat)
  11759. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11760. utils.ErrorLog("解析失败:%v", err)
  11761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11762. return
  11763. }
  11764. } else if miConfig.MdtrtareaAdmvs == "150499" {
  11765. var resOther ResultSeventeenOther
  11766. var pp models.PublicParams
  11767. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11768. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11769. pp.FixmedinsName = miConfig.OrgName
  11770. pp.FixmedinsCode = miConfig.Code
  11771. pp.RequestUrl = miConfig.Url
  11772. pp.Cainfo = miConfig.Cainfo
  11773. pp.SecretKey = miConfig.SecretKey
  11774. pp.AccessKey = miConfig.AccessKey
  11775. pp.OpterName = curRoles.UserName
  11776. client := &http.Client{}
  11777. var req *http.Request
  11778. data := make(map[string]interface{})
  11779. data["struct4101"] = struct4101
  11780. data["pp"] = pp
  11781. bytesData, _ := json.Marshal(data)
  11782. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  11783. resp, _ := client.Do(req)
  11784. defer resp.Body.Close()
  11785. body, ioErr := ioutil.ReadAll(resp.Body)
  11786. if ioErr != nil {
  11787. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11789. return
  11790. }
  11791. var respJSON map[string]interface{}
  11792. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11793. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11795. return
  11796. }
  11797. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11798. userJSONBytes, _ := json.Marshal(respJSON)
  11799. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  11800. utils.ErrorLog("解析失败:%v", err)
  11801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11802. return
  11803. }
  11804. res.InfRefmsgid = resOther.InfRefmsgid
  11805. res.Output = resOther.Output
  11806. res.ErrMsg = resOther.ErrMsg
  11807. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  11808. res.Infcode = infocode
  11809. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11810. var pp models.PublicParams
  11811. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11812. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11813. pp.FixmedinsName = miConfig.OrgName
  11814. pp.FixmedinsCode = miConfig.Code
  11815. pp.RequestUrl = miConfig.Url
  11816. pp.Cainfo = miConfig.Cainfo
  11817. pp.SecretKey = miConfig.SecretKey
  11818. pp.AccessKey = miConfig.AccessKey
  11819. pp.OpterName = curRoles.UserName
  11820. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  11821. fmt.Println(requestLog)
  11822. fmt.Println(errMsgLog)
  11823. saveLog(result, requestLog, "4101a", "上传清单")
  11824. var dat map[string]interface{}
  11825. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11826. fmt.Println(dat)
  11827. } else {
  11828. fmt.Println(err)
  11829. }
  11830. userJSONBytes, _ := json.Marshal(dat)
  11831. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11832. utils.ErrorLog("解析失败:%v", err)
  11833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11834. return
  11835. }
  11836. } else if miConfig.MdtrtareaAdmvs == "441799" {
  11837. var pp models.PublicParams
  11838. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11839. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11840. pp.FixmedinsName = miConfig.OrgName
  11841. pp.FixmedinsCode = miConfig.Code
  11842. pp.RequestUrl = miConfig.Url
  11843. pp.Cainfo = miConfig.Cainfo
  11844. pp.SecretKey = miConfig.SecretKey
  11845. pp.AccessKey = miConfig.AccessKey
  11846. pp.OpterName = curRoles.UserName
  11847. client := &http.Client{}
  11848. var req *http.Request
  11849. data := make(map[string]interface{})
  11850. data["struct4101"] = struct4101
  11851. data["pp"] = pp
  11852. bytesData, _ := json.Marshal(data)
  11853. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  11854. resp, _ := client.Do(req)
  11855. defer resp.Body.Close()
  11856. body, ioErr := ioutil.ReadAll(resp.Body)
  11857. if ioErr != nil {
  11858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11860. return
  11861. }
  11862. var respJSON map[string]interface{}
  11863. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11866. return
  11867. }
  11868. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11869. userJSONBytes, _ := json.Marshal(respJSON)
  11870. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11871. utils.ErrorLog("解析失败:%v", err)
  11872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11873. return
  11874. }
  11875. } else {
  11876. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  11877. var dat map[string]interface{}
  11878. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11879. fmt.Println(dat)
  11880. } else {
  11881. fmt.Println(err)
  11882. }
  11883. userJSONBytes, _ := json.Marshal(dat)
  11884. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11885. utils.ErrorLog("解析失败:%v", err)
  11886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11887. return
  11888. }
  11889. }
  11890. if res.Infcode != 0 {
  11891. errlog := &models.HisOrderError{
  11892. UserOrgId: order.UserOrgId,
  11893. Ctime: time.Now().Unix(),
  11894. Mtime: time.Now().Unix(),
  11895. ErrMsg: res.ErrMsg + "解析失败",
  11896. Status: 1,
  11897. PatientId: order.ID,
  11898. Stage: 10485,
  11899. }
  11900. service.CreateErrMsgLog(errlog)
  11901. continue
  11902. //c.ServeSuccessJSON(map[string]interface{}{
  11903. // "failed_code": -10,
  11904. // "msg": res.ErrMsg,
  11905. //})
  11906. } else {
  11907. //order.FaPiaoNumber = zero
  11908. //order.FaPiaoCode = last_order.FaPiaoCode
  11909. //service.UpdateOrder(order)
  11910. hisFundSettleListResult := &models.HisFundSettleListResult{
  11911. Number: res.Output.SetlListId,
  11912. Status: 1,
  11913. Ctime: time.Now().Unix(),
  11914. Mtime: time.Now().Unix(),
  11915. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11916. IsUpload: 1,
  11917. OrderId: order.ID,
  11918. }
  11919. service.CreateUploadRecord(hisFundSettleListResult)
  11920. continue
  11921. }
  11922. }
  11923. }
  11924. func (c *HisApiController) GetSettleList() {
  11925. order_id, _ := c.GetInt64("order_id")
  11926. admin_user_id, _ := c.GetInt64("admin_user_id")
  11927. order, _ := service.GetHisOrderByIDTwo(order_id)
  11928. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  11929. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11930. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  11931. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11932. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  11933. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11934. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  11935. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  11936. if order.ID == 0 {
  11937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  11938. return
  11939. }
  11940. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  11941. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  11942. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  11943. //fmt.Println(count)
  11944. //var zero string
  11945. //number := count + 1
  11946. //if number >= 1000 {
  11947. // zero = "0000" + strconv.FormatInt(number, 10)
  11948. //} else if number >= 10000 {
  11949. // zero = "000" + strconv.FormatInt(number, 10)
  11950. //} else if number >= 100000 {
  11951. // zero = "00" + strconv.FormatInt(number, 10)
  11952. //} else if number >= 1000000 {
  11953. // zero = "0" + strconv.FormatInt(number, 10)
  11954. //} else {
  11955. // zero = strconv.FormatInt(number, 10)
  11956. //}
  11957. //fmt.Println(zero)
  11958. struct4101 := service.Struct4101{
  11959. PsnNo: order.PsnNo,
  11960. MdtrtId: order.MdtrtId,
  11961. SetlId: order.SetlId,
  11962. PsnName: order.PsnName,
  11963. Gend: order.Gend,
  11964. Brdy: his.Brdy,
  11965. Age: his.Age,
  11966. Naty: order.Naty,
  11967. PatnCertType: "01",
  11968. Certno: order.Certno,
  11969. Prfs: "90",
  11970. ConerName: roles[0].UserName,
  11971. PatnRlts: "99",
  11972. ConerAddr: miConfig.OrgName,
  11973. ConerTel: admin.Mobile,
  11974. HiType: order.Insutype,
  11975. Insuplc: miConfig.InsuplcAdmdvs,
  11976. MaindiagFlag: "1",
  11977. BillCode: order.SetlId,
  11978. BillNo: order.SetlId,
  11979. BizSn: order.Number,
  11980. PsnSelfPay: order.PsnPartAmt,
  11981. PsnOwnPay: order.PsnPartAmt,
  11982. AcctPay: order.AcctPay,
  11983. PsnCashpay: order.PsnCashPay,
  11984. HiPaymtd: "1",
  11985. Hsorg: miConfig.InsuplcAdmdvs,
  11986. HsorgOpter: miConfig.InsuplcAdmdvs,
  11987. MedinsFillPsn: curRoles.UserName,
  11988. MedinsFillDept: miConfig.OrgName,
  11989. IptMedType: "2",
  11990. }
  11991. struct4101.SetlBegnDate = order.SetlTime
  11992. struct4101.SetlEndDate = order.SetlTime
  11993. time_arr := strings.Split(order.SetlTime, " ")
  11994. struct4101.AdmTime = time_arr[0]
  11995. struct4101.AdmEndTime = time_arr[0]
  11996. //
  11997. //var rf []CustomFundPay
  11998. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  11999. //
  12000. //var tempFunPays []service.CustomStruct
  12001. //for _, item := range rf {
  12002. // var tempFunPay service.CustomStruct
  12003. // tempFunPay.FundPayamt = item.FundPayamt
  12004. // tempFunPay.FundPayType = item.FundPayType
  12005. // tempFunPays = append(tempFunPays, tempFunPay)
  12006. //}
  12007. //struct4101.CustomStruct = tempFunPays
  12008. var tempDiaginfos []service.DiaginfoStructTwo
  12009. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  12010. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  12011. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  12012. var config []*models.HisXtDiagnoseConfig
  12013. for _, item := range diagnosis_ids {
  12014. id, _ := strconv.ParseInt(item, 10, 64)
  12015. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12016. config = append(config, &diagnosisConfig)
  12017. }
  12018. if miConfig.Code == "H15049901371" {
  12019. //for _, item := range config {
  12020. // if item.ID == 138 {
  12021. diagnosisConfig, _ := service.FindDiagnoseById(138)
  12022. var tempDiaginfo service.DiaginfoStructTwo
  12023. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  12024. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  12025. tempDiaginfo.DiagType = "1"
  12026. tempDiaginfo.MaindiagFlag = "1"
  12027. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12028. //}
  12029. //}
  12030. for _, item := range config {
  12031. if item.ID != 138 {
  12032. var tempDiaginfo service.DiaginfoStructTwo
  12033. tempDiaginfo.DiagCode = item.CountryCode
  12034. tempDiaginfo.DiagName = item.CountryContentName
  12035. tempDiaginfo.DiagType = "1"
  12036. tempDiaginfo.MaindiagFlag = "0"
  12037. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12038. }
  12039. }
  12040. } else {
  12041. for index, item := range config {
  12042. if index == 0 {
  12043. var tempDiaginfo service.DiaginfoStructTwo
  12044. tempDiaginfo.DiagCode = item.CountryCode
  12045. tempDiaginfo.DiagName = item.CountryContentName
  12046. tempDiaginfo.DiagType = "1"
  12047. tempDiaginfo.MaindiagFlag = "1"
  12048. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12049. } else {
  12050. var tempDiaginfo service.DiaginfoStructTwo
  12051. tempDiaginfo.DiagCode = item.CountryCode
  12052. tempDiaginfo.DiagName = item.CountryContentName
  12053. tempDiaginfo.DiagType = "1"
  12054. tempDiaginfo.MaindiagFlag = "0"
  12055. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12056. }
  12057. }
  12058. }
  12059. struct4101.Diseinfo = tempDiaginfos
  12060. sickConfigTwo, _ := service.FindSickById(his.SickType)
  12061. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  12062. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  12063. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  12064. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  12065. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  12066. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  12067. var iteminfo service.IteminfoStruct
  12068. var bedCostTotal float64 = 0 //床位总费
  12069. var bedCostSelfTotal float64 = 0 //床位自费
  12070. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  12071. var operationCostTotal float64 = 0 //手术费
  12072. var operationCostSelfTotal float64 = 0 //手术费
  12073. var operationCostPartSelfTotal float64 = 0 //手术费
  12074. var otherCostTotal float64 = 0 //其他费用
  12075. var otherCostSelfTotal float64 = 0 //其他费用
  12076. var otherCostPartSelfTotal float64 = 0 //其他费用
  12077. var materialCostTotal float64 = 0 //材料费
  12078. var materialCostSelfTotal float64 = 0 //材料费
  12079. var materialCostPartSelfTotal float64 = 0 //材料费
  12080. var westernMedicineCostTotal float64 = 0 //西药费
  12081. var westernMedicineCostSelfTotal float64 = 0 //西药费
  12082. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12083. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12084. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12085. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12086. var checkCostTotal float64 = 0 //检查费
  12087. var checkCostSelfTotal float64 = 0 //检查费
  12088. var checkCostPartSelfTotal float64 = 0 //检查费
  12089. var laboratoryCostTotal float64 = 0 //化验费
  12090. var laboratoryCostSelfTotal float64 = 0 //化验费
  12091. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12092. var treatCostTotal float64 = 0 //治疗费用
  12093. var treatCostSelfTotal float64 = 0 //治疗费用
  12094. var treatCostPartSelfTotal float64 = 0 //治疗费用
  12095. decimal.DivisionPrecision = 2
  12096. var bed_fulamt_ownpay_amt float64 = 0
  12097. var operation_fulamt_ownpay_amt float64 = 0
  12098. var other_fulamt_ownpay_amt float64 = 0
  12099. var westernMedicine_fulamt_ownpay_amt float64 = 0
  12100. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  12101. var check_fulamt_ownpay_amt float64 = 0
  12102. var material_fulamt_ownpay_amt float64 = 0
  12103. var laboratory_fulamt_ownpay_amt float64 = 0
  12104. var treat_fulamt_ownpay_amt float64 = 0
  12105. var bed_claa_sunmfee float64 = 0
  12106. var bed_clab_amt float64 = 0
  12107. var bed_other_amt float64 = 0
  12108. var operation_claa_sunmfee float64 = 0
  12109. var operation_clab_amt float64 = 0
  12110. var operation_other_amt float64 = 0
  12111. var other_claa_sunmfee float64 = 0
  12112. var other_clab_amt float64 = 0
  12113. var other_other_amt float64 = 0
  12114. var westernMedicine_claa_sunmfee float64 = 0
  12115. var westernMedicine_clab_amt float64 = 0
  12116. var westernMedicine_other_amt float64 = 0
  12117. var chineseTraditional_claa_sunmfee float64 = 0
  12118. var chineseTraditional_clab_amt float64 = 0
  12119. var chineseTraditional_other_amt float64 = 0
  12120. var check_claa_sunmfee float64 = 0
  12121. var check_clab_amt float64 = 0
  12122. var check_other_amt float64 = 0
  12123. var material_claa_sunmfee float64 = 0
  12124. var material_clab_amt float64 = 0
  12125. var material_other_amt float64 = 0
  12126. var laboratory_claa_sunmfee float64 = 0
  12127. var laboratory_clab_amt float64 = 0
  12128. var laboratory_other_amt float64 = 0
  12129. var treat_claa_sunmfee float64 = 0
  12130. var treat_clab_amt float64 = 0
  12131. var treat_other_amt float64 = 0
  12132. for _, item := range order.HisOrderInfo {
  12133. if item.MedChrgitmType == "01" { //床位费
  12134. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12135. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12136. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12137. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12138. if item.ChrgitmLv == "1" {
  12139. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12140. }
  12141. if item.ChrgitmLv == "2" {
  12142. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12143. }
  12144. if item.ChrgitmLv == "3" {
  12145. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12146. }
  12147. }
  12148. if item.MedChrgitmType == "03" { //检查费
  12149. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12150. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12151. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12152. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12153. if item.ChrgitmLv == "1" {
  12154. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12155. }
  12156. if item.ChrgitmLv == "2" {
  12157. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12158. }
  12159. if item.ChrgitmLv == "3" {
  12160. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12161. }
  12162. }
  12163. if item.MedChrgitmType == "04" { //化验费
  12164. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12165. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12166. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12167. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12168. if item.ChrgitmLv == "1" {
  12169. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12170. }
  12171. if item.ChrgitmLv == "2" {
  12172. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12173. }
  12174. if item.ChrgitmLv == "3" {
  12175. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12176. }
  12177. }
  12178. if item.MedChrgitmType == "05" { //治疗费
  12179. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12180. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12181. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12182. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12183. if item.ChrgitmLv == "1" {
  12184. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12185. }
  12186. if item.ChrgitmLv == "2" {
  12187. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12188. }
  12189. if item.ChrgitmLv == "3" {
  12190. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12191. }
  12192. }
  12193. if item.MedChrgitmType == "06" { //手术费
  12194. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12195. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12196. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12197. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12198. if item.ChrgitmLv == "1" {
  12199. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12200. }
  12201. if item.ChrgitmLv == "2" {
  12202. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12203. }
  12204. if item.ChrgitmLv == "3" {
  12205. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12206. }
  12207. }
  12208. if item.MedChrgitmType == "08" { //材料费
  12209. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12210. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12211. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12212. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12213. if item.ChrgitmLv == "1" {
  12214. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12215. }
  12216. if item.ChrgitmLv == "2" {
  12217. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12218. }
  12219. if item.ChrgitmLv == "3" {
  12220. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12221. }
  12222. }
  12223. if item.MedChrgitmType == "09" { //西药费
  12224. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12225. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12226. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12227. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12228. if item.ChrgitmLv == "1" {
  12229. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12230. }
  12231. if item.ChrgitmLv == "2" {
  12232. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12233. }
  12234. if item.ChrgitmLv == "3" {
  12235. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12236. }
  12237. }
  12238. if item.MedChrgitmType == "11" { //中成费
  12239. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12240. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12241. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12242. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12243. if item.ChrgitmLv == "1" {
  12244. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12245. }
  12246. if item.ChrgitmLv == "2" {
  12247. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12248. }
  12249. if item.ChrgitmLv == "3" {
  12250. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12251. }
  12252. }
  12253. if item.MedChrgitmType == "14" { //其他费
  12254. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12255. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12256. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12257. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12258. if item.ChrgitmLv == "1" {
  12259. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12260. }
  12261. if item.ChrgitmLv == "2" {
  12262. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12263. }
  12264. if item.ChrgitmLv == "3" {
  12265. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12266. }
  12267. }
  12268. }
  12269. var iteminfoStructs []service.IteminfoStruct
  12270. if bedCostTotal != 0 {
  12271. iteminfo.MedChrgitm = "01"
  12272. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12273. iteminfo.Amt = bedCostTotal
  12274. iteminfo.ClaaSumfee = bed_claa_sunmfee
  12275. iteminfo.ClabAmt = bed_clab_amt
  12276. iteminfo.OthAmt = bed_other_amt
  12277. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12278. }
  12279. if checkCostTotal != 0 {
  12280. iteminfo.MedChrgitm = "03"
  12281. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12282. iteminfo.Amt = checkCostTotal
  12283. iteminfo.ClaaSumfee = check_claa_sunmfee
  12284. iteminfo.ClabAmt = check_clab_amt
  12285. iteminfo.OthAmt = check_other_amt
  12286. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12287. }
  12288. if laboratoryCostTotal != 0 {
  12289. iteminfo.MedChrgitm = "04"
  12290. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  12291. iteminfo.Amt = laboratoryCostTotal
  12292. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  12293. iteminfo.ClabAmt = laboratory_clab_amt
  12294. iteminfo.OthAmt = laboratory_other_amt
  12295. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12296. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12297. }
  12298. if treatCostTotal != 0 {
  12299. iteminfo.MedChrgitm = "05"
  12300. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  12301. iteminfo.Amt = treatCostTotal
  12302. iteminfo.ClaaSumfee = treat_claa_sunmfee
  12303. iteminfo.ClabAmt = treat_clab_amt
  12304. iteminfo.OthAmt = treat_other_amt
  12305. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12306. //(struct4101.IteminfoStruct, iteminfo)
  12307. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12308. }
  12309. if operationCostTotal != 0 {
  12310. iteminfo.MedChrgitm = "06"
  12311. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12312. iteminfo.Amt = operationCostTotal
  12313. iteminfo.ClaaSumfee = operation_claa_sunmfee
  12314. iteminfo.ClabAmt = operation_clab_amt
  12315. iteminfo.OthAmt = operation_other_amt
  12316. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12317. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12318. }
  12319. if materialCostTotal != 0 {
  12320. iteminfo.MedChrgitm = "08"
  12321. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  12322. iteminfo.Amt = materialCostTotal
  12323. iteminfo.ClaaSumfee = material_claa_sunmfee
  12324. iteminfo.ClabAmt = material_clab_amt
  12325. iteminfo.OthAmt = material_other_amt
  12326. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12327. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12328. }
  12329. if westernMedicineCostTotal != 0 {
  12330. iteminfo.MedChrgitm = "09"
  12331. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12332. iteminfo.Amt = westernMedicineCostTotal
  12333. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12334. iteminfo.ClabAmt = westernMedicine_clab_amt
  12335. iteminfo.OthAmt = westernMedicine_other_amt
  12336. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12337. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12338. }
  12339. if chineseTraditionalMedicineCostTotal != 0 {
  12340. iteminfo.MedChrgitm = "11"
  12341. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12342. iteminfo.Amt = westernMedicineCostTotal
  12343. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12344. iteminfo.ClabAmt = westernMedicine_clab_amt
  12345. iteminfo.OthAmt = westernMedicine_other_amt
  12346. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12347. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12348. }
  12349. if otherCostTotal != 0 {
  12350. iteminfo.MedChrgitm = "14"
  12351. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12352. iteminfo.Amt = otherCostTotal
  12353. iteminfo.ClaaSumfee = other_claa_sunmfee
  12354. iteminfo.ClabAmt = other_clab_amt
  12355. iteminfo.OthAmt = other_other_amt
  12356. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12357. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12358. }
  12359. struct4101.IteminfoStruct = iteminfoStructs
  12360. struct4101.Ntly = "中国"
  12361. struct4101.AdmCaty = "A03.06"
  12362. struct4101.DoctorName = doctor.UserName
  12363. struct4101.DoctorCode = doctor.DoctorNumber
  12364. var res ResultSeventeen
  12365. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12366. struct4101.BillCode = order.Number
  12367. struct4101.BillNo = order.SetlId
  12368. var resOther ResultSeventeenOther
  12369. var pp models.PublicParams
  12370. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12371. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12372. pp.FixmedinsName = miConfig.OrgName
  12373. pp.FixmedinsCode = miConfig.Code
  12374. pp.RequestUrl = miConfig.Url
  12375. pp.Cainfo = miConfig.Cainfo
  12376. pp.SecretKey = miConfig.SecretKey
  12377. pp.AccessKey = miConfig.AccessKey
  12378. pp.OpterName = curRoles.UserName
  12379. client := &http.Client{}
  12380. var req *http.Request
  12381. data := make(map[string]interface{})
  12382. data["struct4101"] = struct4101
  12383. data["pp"] = pp
  12384. bytesData, _ := json.Marshal(data)
  12385. if miConfig.MdtrtareaAdmvs == "320921" {
  12386. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12387. } else {
  12388. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12389. }
  12390. resp, _ := client.Do(req)
  12391. defer resp.Body.Close()
  12392. body, ioErr := ioutil.ReadAll(resp.Body)
  12393. if ioErr != nil {
  12394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12396. return
  12397. }
  12398. var respJSON map[string]interface{}
  12399. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12402. return
  12403. }
  12404. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12405. userJSONBytes, _ := json.Marshal(respJSON)
  12406. fmt.Println("log")
  12407. fmt.Println(string(userJSONBytes))
  12408. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12409. utils.ErrorLog("解析失败:%v", err)
  12410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12411. return
  12412. }
  12413. res.InfRefmsgid = resOther.InfRefmsgid
  12414. res.Output = resOther.Output
  12415. res.ErrMsg = resOther.ErrMsg
  12416. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12417. res.Infcode = infocode
  12418. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12419. var pp models.PublicParams
  12420. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12421. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12422. pp.FixmedinsName = miConfig.OrgName
  12423. pp.FixmedinsCode = miConfig.Code
  12424. pp.RequestUrl = miConfig.Url
  12425. pp.Cainfo = miConfig.Cainfo
  12426. pp.SecretKey = miConfig.SecretKey
  12427. pp.AccessKey = miConfig.AccessKey
  12428. pp.OpterName = curRoles.UserName
  12429. result, _ := service.Jxyb4101(struct4101, pp)
  12430. var dat map[string]interface{}
  12431. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12432. fmt.Println(dat)
  12433. } else {
  12434. fmt.Println(err)
  12435. }
  12436. userJSONBytes, _ := json.Marshal(dat)
  12437. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12438. utils.ErrorLog("解析失败:%v", err)
  12439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12440. return
  12441. }
  12442. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12443. var pp models.PublicParams
  12444. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12445. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12446. pp.FixmedinsName = miConfig.OrgName
  12447. pp.FixmedinsCode = miConfig.Code
  12448. pp.RequestUrl = miConfig.Url
  12449. pp.Cainfo = miConfig.Cainfo
  12450. pp.SecretKey = miConfig.SecretKey
  12451. pp.AccessKey = miConfig.AccessKey
  12452. pp.OpterName = curRoles.UserName
  12453. result, _ := service.Hnyb4101(struct4101, pp)
  12454. var dat map[string]interface{}
  12455. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12456. fmt.Println(dat)
  12457. } else {
  12458. fmt.Println(err)
  12459. }
  12460. userJSONBytes, _ := json.Marshal(dat)
  12461. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12462. utils.ErrorLog("解析失败:%v", err)
  12463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12464. return
  12465. }
  12466. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12467. var resOther ResultSeventeenOther
  12468. var pp models.PublicParams
  12469. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12470. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12471. pp.FixmedinsName = miConfig.OrgName
  12472. pp.FixmedinsCode = miConfig.Code
  12473. pp.RequestUrl = miConfig.Url
  12474. pp.Cainfo = miConfig.Cainfo
  12475. pp.SecretKey = miConfig.SecretKey
  12476. pp.AccessKey = miConfig.AccessKey
  12477. pp.OpterName = curRoles.UserName
  12478. client := &http.Client{}
  12479. var req *http.Request
  12480. data := make(map[string]interface{})
  12481. data["struct4101"] = struct4101
  12482. data["pp"] = pp
  12483. bytesData, _ := json.Marshal(data)
  12484. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  12485. resp, _ := client.Do(req)
  12486. defer resp.Body.Close()
  12487. body, ioErr := ioutil.ReadAll(resp.Body)
  12488. if ioErr != nil {
  12489. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12491. return
  12492. }
  12493. var respJSON map[string]interface{}
  12494. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12495. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12497. return
  12498. }
  12499. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12500. userJSONBytes, _ := json.Marshal(respJSON)
  12501. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12502. utils.ErrorLog("解析失败:%v", err)
  12503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12504. return
  12505. }
  12506. res.InfRefmsgid = resOther.InfRefmsgid
  12507. res.Output = resOther.Output
  12508. res.ErrMsg = resOther.ErrMsg
  12509. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12510. res.Infcode = infocode
  12511. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12512. var pp models.PublicParams
  12513. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12514. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12515. pp.FixmedinsName = miConfig.OrgName
  12516. pp.FixmedinsCode = miConfig.Code
  12517. pp.RequestUrl = miConfig.Url
  12518. pp.Cainfo = miConfig.Cainfo
  12519. pp.SecretKey = miConfig.SecretKey
  12520. pp.AccessKey = miConfig.AccessKey
  12521. pp.OpterName = curRoles.UserName
  12522. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  12523. fmt.Println(requestLog)
  12524. fmt.Println(errMsgLog)
  12525. saveLog(result, requestLog, "4101a", "上传清单")
  12526. var dat map[string]interface{}
  12527. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12528. fmt.Println(dat)
  12529. } else {
  12530. fmt.Println(err)
  12531. }
  12532. userJSONBytes, _ := json.Marshal(dat)
  12533. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12534. utils.ErrorLog("解析失败:%v", err)
  12535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12536. return
  12537. }
  12538. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12539. var pp models.PublicParams
  12540. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12541. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12542. pp.FixmedinsName = miConfig.OrgName
  12543. pp.FixmedinsCode = miConfig.Code
  12544. pp.RequestUrl = miConfig.Url
  12545. pp.Cainfo = miConfig.Cainfo
  12546. pp.SecretKey = miConfig.SecretKey
  12547. pp.AccessKey = miConfig.AccessKey
  12548. pp.OpterName = curRoles.UserName
  12549. client := &http.Client{}
  12550. var req *http.Request
  12551. data := make(map[string]interface{})
  12552. data["struct4101"] = struct4101
  12553. data["pp"] = pp
  12554. bytesData, _ := json.Marshal(data)
  12555. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  12556. resp, _ := client.Do(req)
  12557. defer resp.Body.Close()
  12558. body, ioErr := ioutil.ReadAll(resp.Body)
  12559. if ioErr != nil {
  12560. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12562. return
  12563. }
  12564. var respJSON map[string]interface{}
  12565. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12566. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12568. return
  12569. }
  12570. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12571. userJSONBytes, _ := json.Marshal(respJSON)
  12572. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12573. utils.ErrorLog("解析失败:%v", err)
  12574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12575. return
  12576. }
  12577. } else {
  12578. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  12579. var dat map[string]interface{}
  12580. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12581. fmt.Println(dat)
  12582. } else {
  12583. fmt.Println(err)
  12584. }
  12585. userJSONBytes, _ := json.Marshal(dat)
  12586. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12587. utils.ErrorLog("解析失败:%v", err)
  12588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12589. return
  12590. }
  12591. }
  12592. if res.Infcode != 0 {
  12593. c.ServeSuccessJSON(map[string]interface{}{
  12594. "failed_code": -10,
  12595. "msg": res.ErrMsg,
  12596. })
  12597. return
  12598. } else {
  12599. //order.FaPiaoNumber = zero
  12600. //order.FaPiaoCode = last_order.FaPiaoCode
  12601. //service.UpdateOrder(order)
  12602. hisFundSettleListResult := &models.HisFundSettleListResult{
  12603. Number: res.Output.SetlListId,
  12604. Status: 1,
  12605. Ctime: time.Now().Unix(),
  12606. Mtime: time.Now().Unix(),
  12607. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12608. IsUpload: 1,
  12609. OrderId: order_id,
  12610. }
  12611. service.CreateUploadRecord(hisFundSettleListResult)
  12612. c.ServeSuccessJSON(map[string]interface{}{
  12613. "msg": "上传成功",
  12614. "result": hisFundSettleListResult,
  12615. })
  12616. return
  12617. }
  12618. }
  12619. func (c *HisApiController) GetSettleListHospital() {
  12620. order_id, _ := c.GetInt64("order_id")
  12621. admin_user_id, _ := c.GetInt64("admin_user_id")
  12622. order, _ := service.GetHisOrderByIDTwo(order_id)
  12623. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  12624. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  12625. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  12626. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12627. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  12628. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12629. if order.ID == 0 {
  12630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  12631. return
  12632. }
  12633. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  12634. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  12635. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  12636. fmt.Println(count)
  12637. var zero string
  12638. number := count + 1
  12639. if number >= 1000 {
  12640. zero = "0000" + strconv.FormatInt(number, 10)
  12641. } else if number >= 10000 {
  12642. zero = "000" + strconv.FormatInt(number, 10)
  12643. } else if number >= 100000 {
  12644. zero = "00" + strconv.FormatInt(number, 10)
  12645. } else if number >= 1000000 {
  12646. zero = "0" + strconv.FormatInt(number, 10)
  12647. } else {
  12648. zero = strconv.FormatInt(number, 10)
  12649. }
  12650. fmt.Println(zero)
  12651. struct4101 := service.Struct4101{
  12652. PsnNo: order.PsnNo,
  12653. MdtrtId: order.MdtrtId,
  12654. SetlId: order.SetlId,
  12655. PsnName: order.PsnName,
  12656. Gend: order.Gend,
  12657. Brdy: his.Brdy,
  12658. Age: int64(order.Age),
  12659. Naty: order.Naty,
  12660. PatnCertType: "01",
  12661. Certno: order.Certno,
  12662. Prfs: "90",
  12663. ConerName: roles[0].UserName,
  12664. PatnRlts: "99",
  12665. ConerAddr: miConfig.OrgName,
  12666. ConerTel: admin.Mobile,
  12667. HiType: order.Insutype,
  12668. Insuplc: miConfig.InsuplcAdmdvs,
  12669. MaindiagFlag: "1",
  12670. BillCode: order.SetlId,
  12671. BillNo: order.SetlId,
  12672. BizSn: order.Number,
  12673. PsnSelfPay: order.PsnPartAmt,
  12674. PsnOwnPay: order.PsnPartAmt,
  12675. AcctPay: order.AcctPay,
  12676. PsnCashpay: order.PsnCashPay,
  12677. HiPaymtd: "1",
  12678. Hsorg: miConfig.InsuplcAdmdvs,
  12679. HsorgOpter: miConfig.InsuplcAdmdvs,
  12680. MedinsFillPsn: curRoles.UserName,
  12681. MedinsFillDept: depart.Name,
  12682. IptMedType: "2",
  12683. AdmTime: his.InHosptialTime,
  12684. AdmEndTime: his.OutHosptialTime,
  12685. }
  12686. struct4101.SetlBegnDate = order.SetlTime
  12687. struct4101.SetlEndDate = order.SetlTime
  12688. //var rf []CustomFundPay
  12689. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  12690. //
  12691. //var tempFunPays []service.CustomStruct
  12692. //for _, item := range rf {
  12693. // var tempFunPay service.CustomStruct
  12694. // tempFunPay.FundPayamt = item.FundPayamt
  12695. // tempFunPay.FundPayType = item.FundPayType
  12696. // tempFunPays = append(tempFunPays, tempFunPay)
  12697. //}
  12698. //struct4101.CustomStruct = tempFunPays
  12699. var tempDiaginfos []service.DiaginfoStructTwo
  12700. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  12701. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  12702. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  12703. //for _, item := range infos {
  12704. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  12705. //}
  12706. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  12707. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  12708. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12709. fmt.Println(diagnosis_ids_arr)
  12710. if order.UserOrgId == 10210 {
  12711. var diagnosis_ids_arr_two []int64
  12712. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  12713. var config []*models.HisXtDiagnoseConfig
  12714. for _, id := range diagnosis_ids_arr_two {
  12715. //id, _ := strconv.ParseInt(item, 10, 64)
  12716. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12717. if diagnosisConfig.ID > 0 {
  12718. config = append(config, &diagnosisConfig)
  12719. }
  12720. }
  12721. for index, item := range config {
  12722. if item.ID > 0 {
  12723. if index == 0 {
  12724. var tempDiaginfo service.DiaginfoStructTwo
  12725. tempDiaginfo.DiagCode = item.CountryCode
  12726. tempDiaginfo.DiagName = item.CountryContentName
  12727. tempDiaginfo.DiagType = "1"
  12728. tempDiaginfo.MaindiagFlag = "1"
  12729. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12730. } else {
  12731. var tempDiaginfo service.DiaginfoStructTwo
  12732. tempDiaginfo.DiagCode = item.CountryCode
  12733. tempDiaginfo.DiagName = item.CountryContentName
  12734. tempDiaginfo.DiagType = "1"
  12735. tempDiaginfo.MaindiagFlag = "0"
  12736. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12737. }
  12738. }
  12739. }
  12740. struct4101.Diseinfo = tempDiaginfos
  12741. } else {
  12742. var config []*models.HisXtDiagnoseConfig
  12743. for _, item := range diagnosis_ids_arr {
  12744. id, _ := strconv.ParseInt(item, 10, 64)
  12745. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12746. if diagnosisConfig.ID > 0 {
  12747. config = append(config, &diagnosisConfig)
  12748. }
  12749. }
  12750. for index, item := range config {
  12751. if item.ID > 0 {
  12752. if index == 0 {
  12753. var tempDiaginfo service.DiaginfoStructTwo
  12754. tempDiaginfo.DiagCode = item.CountryCode
  12755. tempDiaginfo.DiagName = item.CountryContentName
  12756. tempDiaginfo.DiagType = "1"
  12757. tempDiaginfo.MaindiagFlag = "1"
  12758. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12759. } else {
  12760. var tempDiaginfo service.DiaginfoStructTwo
  12761. tempDiaginfo.DiagCode = item.CountryCode
  12762. tempDiaginfo.DiagName = item.CountryContentName
  12763. tempDiaginfo.DiagType = "1"
  12764. tempDiaginfo.MaindiagFlag = "0"
  12765. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12766. }
  12767. }
  12768. }
  12769. struct4101.Diseinfo = tempDiaginfos
  12770. }
  12771. sickConfigTwo, _ := service.FindSickById(his.SickType)
  12772. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  12773. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  12774. tempOpspdiseinfo2.OprnOprtCode = ""
  12775. tempOpspdiseinfo2.OprnOprtName = ""
  12776. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  12777. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  12778. var iteminfo service.IteminfoStruct
  12779. var bedCostTotal float64 = 0 //床位总费
  12780. var bedCostSelfTotal float64 = 0 //床位自费
  12781. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  12782. var operationCostTotal float64 = 0 //手术费
  12783. var operationCostSelfTotal float64 = 0 //手术费
  12784. var operationCostPartSelfTotal float64 = 0 //手术费
  12785. var otherCostTotal float64 = 0 //其他费用
  12786. var otherCostSelfTotal float64 = 0 //其他费用
  12787. var otherCostPartSelfTotal float64 = 0 //其他费用
  12788. var materialCostTotal float64 = 0 //材料费
  12789. var materialCostSelfTotal float64 = 0 //材料费
  12790. var materialCostPartSelfTotal float64 = 0 //材料费
  12791. var westernMedicineCostTotal float64 = 0 //西药费
  12792. var westernMedicineCostSelfTotal float64 = 0 //西药费
  12793. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12794. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12795. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12796. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12797. var checkCostTotal float64 = 0 //检查费
  12798. var checkCostSelfTotal float64 = 0 //检查费
  12799. var checkCostPartSelfTotal float64 = 0 //检查费
  12800. var laboratoryCostTotal float64 = 0 //化验费
  12801. var laboratoryCostSelfTotal float64 = 0 //化验费
  12802. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12803. var treatCostTotal float64 = 0 //治疗费用
  12804. var treatCostSelfTotal float64 = 0 //治疗费用
  12805. var treatCostPartSelfTotal float64 = 0 //治疗费用
  12806. decimal.DivisionPrecision = 2
  12807. var bed_fulamt_ownpay_amt float64 = 0
  12808. var operation_fulamt_ownpay_amt float64 = 0
  12809. var other_fulamt_ownpay_amt float64 = 0
  12810. var westernMedicine_fulamt_ownpay_amt float64 = 0
  12811. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  12812. var check_fulamt_ownpay_amt float64 = 0
  12813. var material_fulamt_ownpay_amt float64 = 0
  12814. var laboratory_fulamt_ownpay_amt float64 = 0
  12815. var treat_fulamt_ownpay_amt float64 = 0
  12816. var bed_claa_sunmfee float64 = 0
  12817. var bed_clab_amt float64 = 0
  12818. var bed_other_amt float64 = 0
  12819. var operation_claa_sunmfee float64 = 0
  12820. var operation_clab_amt float64 = 0
  12821. var operation_other_amt float64 = 0
  12822. var other_claa_sunmfee float64 = 0
  12823. var other_clab_amt float64 = 0
  12824. var other_other_amt float64 = 0
  12825. var westernMedicine_claa_sunmfee float64 = 0
  12826. var westernMedicine_clab_amt float64 = 0
  12827. var westernMedicine_other_amt float64 = 0
  12828. var chineseTraditional_claa_sunmfee float64 = 0
  12829. var chineseTraditional_clab_amt float64 = 0
  12830. var chineseTraditional_other_amt float64 = 0
  12831. var check_claa_sunmfee float64 = 0
  12832. var check_clab_amt float64 = 0
  12833. var check_other_amt float64 = 0
  12834. var material_claa_sunmfee float64 = 0
  12835. var material_clab_amt float64 = 0
  12836. var material_other_amt float64 = 0
  12837. var laboratory_claa_sunmfee float64 = 0
  12838. var laboratory_clab_amt float64 = 0
  12839. var laboratory_other_amt float64 = 0
  12840. var treat_claa_sunmfee float64 = 0
  12841. var treat_clab_amt float64 = 0
  12842. var treat_other_amt float64 = 0
  12843. for _, item := range order.HisOrderInfo {
  12844. if item.MedChrgitmType == "01" { //床位费
  12845. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12846. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12847. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12848. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12849. if item.ChrgitmLv == "1" {
  12850. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12851. }
  12852. if item.ChrgitmLv == "2" {
  12853. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12854. }
  12855. if item.ChrgitmLv == "3" {
  12856. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12857. }
  12858. }
  12859. if item.MedChrgitmType == "03" { //检查费
  12860. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12861. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12862. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12863. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12864. if item.ChrgitmLv == "1" {
  12865. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12866. }
  12867. if item.ChrgitmLv == "2" {
  12868. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12869. }
  12870. if item.ChrgitmLv == "3" {
  12871. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12872. }
  12873. }
  12874. if item.MedChrgitmType == "04" { //化验费
  12875. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12876. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12877. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12878. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12879. if item.ChrgitmLv == "1" {
  12880. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12881. }
  12882. if item.ChrgitmLv == "2" {
  12883. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12884. }
  12885. if item.ChrgitmLv == "3" {
  12886. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12887. }
  12888. }
  12889. if item.MedChrgitmType == "05" { //治疗费
  12890. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12891. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12892. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12893. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12894. if item.ChrgitmLv == "1" {
  12895. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12896. }
  12897. if item.ChrgitmLv == "2" {
  12898. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12899. }
  12900. if item.ChrgitmLv == "3" {
  12901. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12902. }
  12903. }
  12904. if item.MedChrgitmType == "06" { //手术费
  12905. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12906. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12907. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12908. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12909. if item.ChrgitmLv == "1" {
  12910. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12911. }
  12912. if item.ChrgitmLv == "2" {
  12913. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12914. }
  12915. if item.ChrgitmLv == "3" {
  12916. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12917. }
  12918. }
  12919. if item.MedChrgitmType == "08" { //材料费
  12920. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12921. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12922. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12923. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12924. if item.ChrgitmLv == "1" {
  12925. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12926. }
  12927. if item.ChrgitmLv == "2" {
  12928. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12929. }
  12930. if item.ChrgitmLv == "3" {
  12931. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12932. }
  12933. }
  12934. if item.MedChrgitmType == "09" { //西药费
  12935. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12936. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12937. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12938. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12939. if item.ChrgitmLv == "1" {
  12940. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12941. }
  12942. if item.ChrgitmLv == "2" {
  12943. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12944. }
  12945. if item.ChrgitmLv == "3" {
  12946. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12947. }
  12948. }
  12949. if item.MedChrgitmType == "11" { //中成费
  12950. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12951. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12952. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12953. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12954. if item.ChrgitmLv == "1" {
  12955. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12956. }
  12957. if item.ChrgitmLv == "2" {
  12958. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12959. }
  12960. if item.ChrgitmLv == "3" {
  12961. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12962. }
  12963. }
  12964. if item.MedChrgitmType == "14" { //其他费
  12965. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12966. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12967. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12968. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12969. if item.ChrgitmLv == "1" {
  12970. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12971. }
  12972. if item.ChrgitmLv == "2" {
  12973. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12974. }
  12975. if item.ChrgitmLv == "3" {
  12976. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12977. }
  12978. }
  12979. }
  12980. var iteminfoStructs []service.IteminfoStruct
  12981. if bedCostTotal != 0 {
  12982. iteminfo.MedChrgitm = "01"
  12983. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12984. iteminfo.Amt = bedCostTotal
  12985. iteminfo.ClaaSumfee = bed_claa_sunmfee
  12986. iteminfo.ClabAmt = bed_clab_amt
  12987. iteminfo.OthAmt = bed_other_amt
  12988. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12989. }
  12990. if checkCostTotal != 0 {
  12991. iteminfo.MedChrgitm = "03"
  12992. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12993. iteminfo.Amt = checkCostTotal
  12994. iteminfo.ClaaSumfee = check_claa_sunmfee
  12995. iteminfo.ClabAmt = check_clab_amt
  12996. iteminfo.OthAmt = check_other_amt
  12997. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12998. }
  12999. if laboratoryCostTotal != 0 {
  13000. iteminfo.MedChrgitm = "04"
  13001. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  13002. iteminfo.Amt = laboratoryCostTotal
  13003. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  13004. iteminfo.ClabAmt = laboratory_clab_amt
  13005. iteminfo.OthAmt = laboratory_other_amt
  13006. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13007. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13008. }
  13009. if treatCostTotal != 0 {
  13010. iteminfo.MedChrgitm = "05"
  13011. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  13012. iteminfo.Amt = treatCostTotal
  13013. iteminfo.ClaaSumfee = treat_claa_sunmfee
  13014. iteminfo.ClabAmt = treat_clab_amt
  13015. iteminfo.OthAmt = treat_other_amt
  13016. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13017. //(struct4101.IteminfoStruct, iteminfo)
  13018. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13019. }
  13020. if operationCostTotal != 0 {
  13021. iteminfo.MedChrgitm = "06"
  13022. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13023. iteminfo.Amt = operationCostTotal
  13024. iteminfo.ClaaSumfee = operation_claa_sunmfee
  13025. iteminfo.ClabAmt = operation_clab_amt
  13026. iteminfo.OthAmt = operation_other_amt
  13027. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13028. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13029. }
  13030. if materialCostTotal != 0 {
  13031. iteminfo.MedChrgitm = "08"
  13032. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  13033. iteminfo.Amt = materialCostTotal
  13034. iteminfo.ClaaSumfee = material_claa_sunmfee
  13035. iteminfo.ClabAmt = material_clab_amt
  13036. iteminfo.OthAmt = material_other_amt
  13037. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13038. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13039. }
  13040. if westernMedicineCostTotal != 0 {
  13041. iteminfo.MedChrgitm = "09"
  13042. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13043. iteminfo.Amt = westernMedicineCostTotal
  13044. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13045. iteminfo.ClabAmt = westernMedicine_clab_amt
  13046. iteminfo.OthAmt = westernMedicine_other_amt
  13047. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13048. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13049. }
  13050. if chineseTraditionalMedicineCostTotal != 0 {
  13051. iteminfo.MedChrgitm = "11"
  13052. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13053. iteminfo.Amt = westernMedicineCostTotal
  13054. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13055. iteminfo.ClabAmt = westernMedicine_clab_amt
  13056. iteminfo.OthAmt = westernMedicine_other_amt
  13057. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13058. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13059. }
  13060. if otherCostTotal != 0 {
  13061. iteminfo.MedChrgitm = "14"
  13062. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  13063. iteminfo.Amt = otherCostTotal
  13064. iteminfo.ClaaSumfee = other_claa_sunmfee
  13065. iteminfo.ClabAmt = other_clab_amt
  13066. iteminfo.OthAmt = other_other_amt
  13067. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13068. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13069. }
  13070. struct4101.IteminfoStruct = iteminfoStructs
  13071. struct4101.Ntly = "中国"
  13072. struct4101.AdmCaty = "A03.06"
  13073. var resOther ResultSeventeenOther
  13074. var res ResultSeventeen
  13075. if miConfig.MdtrtareaAdmvs == "150499" {
  13076. var pp models.PublicParams
  13077. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13078. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13079. pp.FixmedinsName = miConfig.OrgName
  13080. pp.FixmedinsCode = miConfig.Code
  13081. pp.RequestUrl = miConfig.Url
  13082. pp.Cainfo = miConfig.Cainfo
  13083. pp.SecretKey = miConfig.SecretKey
  13084. pp.AccessKey = miConfig.AccessKey
  13085. pp.OpterName = curRoles.UserName
  13086. client := &http.Client{}
  13087. var req *http.Request
  13088. data := make(map[string]interface{})
  13089. data["struct4101"] = struct4101
  13090. data["pp"] = pp
  13091. bytesData, _ := json.Marshal(data)
  13092. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  13093. resp, _ := client.Do(req)
  13094. defer resp.Body.Close()
  13095. body, ioErr := ioutil.ReadAll(resp.Body)
  13096. if ioErr != nil {
  13097. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13099. return
  13100. }
  13101. var respJSON map[string]interface{}
  13102. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13103. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13105. return
  13106. }
  13107. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13108. userJSONBytes, _ := json.Marshal(respJSON)
  13109. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13110. utils.ErrorLog("解析失败:%v", err)
  13111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13112. return
  13113. }
  13114. res.InfRefmsgid = resOther.InfRefmsgid
  13115. res.Output = resOther.Output
  13116. res.ErrMsg = resOther.ErrMsg
  13117. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13118. res.Infcode = infocode
  13119. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13120. var pp models.PublicParams
  13121. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13122. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13123. pp.FixmedinsName = miConfig.OrgName
  13124. pp.FixmedinsCode = miConfig.Code
  13125. pp.RequestUrl = miConfig.Url
  13126. pp.Cainfo = miConfig.Cainfo
  13127. pp.SecretKey = miConfig.SecretKey
  13128. pp.AccessKey = miConfig.AccessKey
  13129. pp.OpterName = curRoles.UserName
  13130. result, _ := service.Jxyb4101(struct4101, pp)
  13131. var dat map[string]interface{}
  13132. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13133. fmt.Println(dat)
  13134. } else {
  13135. fmt.Println(err)
  13136. }
  13137. userJSONBytes, _ := json.Marshal(dat)
  13138. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13139. utils.ErrorLog("解析失败:%v", err)
  13140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13141. return
  13142. }
  13143. } else {
  13144. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  13145. var dat map[string]interface{}
  13146. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13147. fmt.Println(dat)
  13148. } else {
  13149. fmt.Println(err)
  13150. }
  13151. userJSONBytes, _ := json.Marshal(dat)
  13152. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13153. utils.ErrorLog("解析失败:%v", err)
  13154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13155. return
  13156. }
  13157. }
  13158. if res.Infcode != 0 {
  13159. c.ServeSuccessJSON(map[string]interface{}{
  13160. "failed_code": -10,
  13161. "msg": res.ErrMsg,
  13162. })
  13163. return
  13164. } else {
  13165. if miConfig.MdtrtareaAdmvs != "150499" {
  13166. order.FaPiaoNumber = zero
  13167. order.FaPiaoCode = last_order.FaPiaoCode
  13168. service.UpdateOrder(order)
  13169. }
  13170. hisFundSettleListResult := &models.HisFundSettleListResult{
  13171. Number: res.Output.SetlListId,
  13172. Status: 1,
  13173. Ctime: time.Now().Unix(),
  13174. Mtime: time.Now().Unix(),
  13175. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13176. IsUpload: 1,
  13177. OrderId: order_id,
  13178. }
  13179. service.CreateUploadRecord(hisFundSettleListResult)
  13180. c.ServeSuccessJSON(map[string]interface{}{
  13181. "msg": "上传成功",
  13182. "result": hisFundSettleListResult,
  13183. })
  13184. return
  13185. }
  13186. }
  13187. //func (c *HisApiController) GetBatchSettleList() {
  13188. // orders, _ := service.GetAllHisOrder(10106)
  13189. // for _, item := range orders {
  13190. // order_id := item.ID
  13191. // order, _ := service.GetHisOrderByIDTwo(order_id)
  13192. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13193. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13194. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13195. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  13196. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13197. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13198. //
  13199. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  13200. //
  13201. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  13202. //
  13203. // if order.ID == 0 {
  13204. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  13205. // return
  13206. // }
  13207. // if his.BalanceAccountsType == 2 {
  13208. // continue
  13209. // }
  13210. // struct4101 := service.Struct4101{
  13211. // PsnNo: order.PsnNo,
  13212. // MdtrtId: order.MdtrtId,
  13213. // SetlId: order.SetlId,
  13214. // PsnName: order.PsnName,
  13215. // Gend: order.Gend,
  13216. // Brdy: his.Brdy,
  13217. // Age: his.Age,
  13218. // Naty: order.Naty,
  13219. // PatnCertType: "01",
  13220. // Certno: order.Certno,
  13221. // Prfs: "90",
  13222. // ConerName: roles[0].UserName,
  13223. // PatnRlts: "99",
  13224. // ConerAddr: miConfig.OrgName,
  13225. // ConerTel: admin.Mobile,
  13226. // HiType: order.Insutype,
  13227. // Insuplc: his.InsuplcAdmdvs,
  13228. // MaindiagFlag: "1",
  13229. // BillCode: order.SetlId,
  13230. // BillNo: order.SetlId,
  13231. // BizSn: order.Number,
  13232. // PsnSelfPay: order.PsnPartAmt,
  13233. // PsnOwnPay: order.PsnPartAmt,
  13234. // AcctPay: order.AcctPay,
  13235. // PsnCashpay: order.PsnCashPay,
  13236. // HiPaymtd: "1",
  13237. // Hsorg: his.InsuplcAdmdvs,
  13238. // HsorgOpter: his.InsuplcAdmdvs,
  13239. // MedinsFillPsn: curRoles.UserName,
  13240. // MedinsFillDept: depart.Name,
  13241. // IptMedType: "2",
  13242. // }
  13243. // struct4101.SetlBegnDate = order.SetlTime
  13244. // struct4101.SetlEndDate = order.SetlTime
  13245. // //if order.SettleType == 1 {
  13246. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  13247. // // dateStr := t.Format("2006-01-02")
  13248. // // struct4101.SetlBegnDate = dateStr
  13249. // // struct4101.SetlEndDate = dateStr
  13250. // //} else {
  13251. // // t := time.Unix(int64(order.SettleStartTime), 0)
  13252. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  13253. // // dateStartStr := t.Format("2006-01-02")
  13254. // // dateEndStr := t2.Format("2006-01-02")
  13255. // // struct4101.SetlBegnDate = dateStartStr
  13256. // // struct4101.SetlEndDate = dateEndStr
  13257. // //}
  13258. //
  13259. // var rf []CustomFundPay
  13260. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  13261. //
  13262. // var tempFunPays []service.CustomStruct
  13263. // var tempFunPay610100 service.CustomStruct
  13264. //
  13265. // for _, item := range rf {
  13266. // if item.FundPayType == "610100" {
  13267. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  13268. // tempFunPay610100.FundPayType = item.FundPayType
  13269. // } else {
  13270. // var tempFunPay service.CustomStruct
  13271. // tempFunPay.FundPayamt = item.FundPayamt
  13272. // tempFunPay.FundPayType = item.FundPayType
  13273. // tempFunPays = append(tempFunPays, tempFunPay)
  13274. // }
  13275. // }
  13276. // tempFunPays = append(tempFunPays, tempFunPay610100)
  13277. // struct4101.CustomStruct = tempFunPays
  13278. //
  13279. // var tempDiaginfos []service.DiaginfoStructTwo
  13280. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13281. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13282. //
  13283. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  13284. // var config []*models.HisXtDiagnoseConfig
  13285. // for _, item := range diagnosis_ids {
  13286. // id, _ := strconv.ParseInt(item, 10, 64)
  13287. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  13288. // config = append(config, &diagnosisConfig)
  13289. // }
  13290. //
  13291. // for index, item := range config {
  13292. // if index == 0 {
  13293. // var tempDiaginfo service.DiaginfoStructTwo
  13294. // tempDiaginfo.DiagCode = item.CountryCode
  13295. // tempDiaginfo.DiagName = item.CountryContentName
  13296. // tempDiaginfo.DiagType = "1"
  13297. // tempDiaginfo.MaindiagFlag = "1"
  13298. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13299. // } else {
  13300. //
  13301. // var tempDiaginfo service.DiaginfoStructTwo
  13302. // tempDiaginfo.DiagCode = item.CountryCode
  13303. // tempDiaginfo.DiagName = item.CountryContentName
  13304. // tempDiaginfo.DiagType = "2"
  13305. // tempDiaginfo.MaindiagFlag = "0"
  13306. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13307. // }
  13308. // }
  13309. // struct4101.Diseinfo = tempDiaginfos
  13310. //
  13311. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  13312. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13313. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13314. // tempOpspdiseinfo2.OprnOprtCode = ""
  13315. // tempOpspdiseinfo2.OprnOprtName = ""
  13316. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13317. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13318. //
  13319. // var iteminfo service.IteminfoStruct
  13320. //
  13321. // var bedCostTotal float64 = 0 //床位总费
  13322. // var bedCostSelfTotal float64 = 0 //床位自费
  13323. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13324. //
  13325. // var examineCostTotal float64 = 0 //诊查总费
  13326. // var examineCostSelfTotal float64 = 0 //诊查自费
  13327. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  13328. //
  13329. // var nursingCostTotal float64 = 0 //护理总费
  13330. // var nursingCostSelfTotal float64 = 0 //护理自费
  13331. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  13332. //
  13333. // var chineseMedicineCostTotal float64 = 0 //中成药
  13334. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  13335. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  13336. //
  13337. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  13338. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  13339. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  13340. //
  13341. // var registerCostTotal float64 = 0 //一般诊疗费
  13342. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  13343. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  13344. //
  13345. // var operationCostTotal float64 = 0 //手术费
  13346. // var operationCostSelfTotal float64 = 0 //手术费
  13347. // var operationCostPartSelfTotal float64 = 0 //手术费
  13348. //
  13349. // var otherCostTotal float64 = 0 //其他费用
  13350. // var otherCostSelfTotal float64 = 0 //其他费用
  13351. // var otherCostPartSelfTotal float64 = 0 //其他费用
  13352. //
  13353. // var materialCostTotal float64 = 0 //材料费
  13354. // var materialCostSelfTotal float64 = 0 //材料费
  13355. // var materialCostPartSelfTotal float64 = 0 //材料费
  13356. //
  13357. // var westernMedicineCostTotal float64 = 0 //西药费
  13358. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  13359. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13360. //
  13361. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13362. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13363. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13364. //
  13365. // var checkCostTotal float64 = 0 //检查费
  13366. // var checkCostSelfTotal float64 = 0 //检查费
  13367. // var checkCostPartSelfTotal float64 = 0 //检查费
  13368. //
  13369. // var laboratoryCostTotal float64 = 0 //化验费
  13370. // var laboratoryCostSelfTotal float64 = 0 //化验费
  13371. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13372. //
  13373. // var treatCostTotal float64 = 0 //治疗费用
  13374. // var treatCostSelfTotal float64 = 0 //治疗费用
  13375. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  13376. //
  13377. // decimal.DivisionPrecision = 2
  13378. //
  13379. // var bed_fulamt_ownpay_amt float64 = 0
  13380. //
  13381. // var examine_fulamt_ownpay_amt float64 = 0
  13382. //
  13383. // var nursing_fulamt_ownpay_amt float64 = 0
  13384. //
  13385. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  13386. //
  13387. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  13388. //
  13389. // var register_fulamt_ownpay_amt float64 = 0
  13390. //
  13391. // var operation_fulamt_ownpay_amt float64 = 0
  13392. // var other_fulamt_ownpay_amt float64 = 0
  13393. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  13394. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13395. // var check_fulamt_ownpay_amt float64 = 0
  13396. // var material_fulamt_ownpay_amt float64 = 0
  13397. // var laboratory_fulamt_ownpay_amt float64 = 0
  13398. // var treat_fulamt_ownpay_amt float64 = 0
  13399. //
  13400. // var bed_claa_sunmfee float64 = 0
  13401. // var bed_clab_amt float64 = 0
  13402. // var bed_other_amt float64 = 0
  13403. //
  13404. // var examine_claa_sunmfee float64 = 0
  13405. // var examine_clab_amt float64 = 0
  13406. // var examine_other_amt float64 = 0
  13407. //
  13408. // var nursing_claa_sunmfee float64 = 0
  13409. // var nursing_clab_amt float64 = 0
  13410. // var nursing_other_amt float64 = 0
  13411. //
  13412. // var chinese_medicine_claa_sunmfee float64 = 0
  13413. // var chinese_medicine_clab_amt float64 = 0
  13414. // var chinese_medicine_other_amt float64 = 0
  13415. //
  13416. // var commonly_treatment_claa_sunmfee float64 = 0
  13417. // var commonly_treatment_clab_amt float64 = 0
  13418. // var commonly_treatment_other_amt float64 = 0
  13419. //
  13420. // var operation_claa_sunmfee float64 = 0
  13421. // var operation_clab_amt float64 = 0
  13422. // var operation_other_amt float64 = 0
  13423. //
  13424. // var other_claa_sunmfee float64 = 0
  13425. // var other_clab_amt float64 = 0
  13426. // var other_other_amt float64 = 0
  13427. //
  13428. // var westernMedicine_claa_sunmfee float64 = 0
  13429. // var westernMedicine_clab_amt float64 = 0
  13430. // var westernMedicine_other_amt float64 = 0
  13431. //
  13432. // var chineseTraditional_claa_sunmfee float64 = 0
  13433. // var chineseTraditional_clab_amt float64 = 0
  13434. // var chineseTraditional_other_amt float64 = 0
  13435. //
  13436. // var check_claa_sunmfee float64 = 0
  13437. // var check_clab_amt float64 = 0
  13438. // var check_other_amt float64 = 0
  13439. //
  13440. // var material_claa_sunmfee float64 = 0
  13441. // var material_clab_amt float64 = 0
  13442. // var material_other_amt float64 = 0
  13443. //
  13444. // var laboratory_claa_sunmfee float64 = 0
  13445. // var laboratory_clab_amt float64 = 0
  13446. // var laboratory_other_amt float64 = 0
  13447. //
  13448. // var treat_claa_sunmfee float64 = 0
  13449. // var treat_clab_amt float64 = 0
  13450. // var treat_other_amt float64 = 0
  13451. //
  13452. // var register_claa_sunmfee float64 = 0
  13453. // var register_clab_amt float64 = 0
  13454. // var register_other_amt float64 = 0
  13455. //
  13456. // for _, item := range order.HisOrderInfo {
  13457. // if item.MedChrgitmType == "01" { //床位费
  13458. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13459. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13460. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13461. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13462. // if item.ChrgitmLv == "1" {
  13463. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13464. // }
  13465. // if item.ChrgitmLv == "2" {
  13466. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13467. //
  13468. // }
  13469. // if item.ChrgitmLv == "3" {
  13470. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13471. // }
  13472. //
  13473. // }
  13474. //
  13475. // if item.MedChrgitmType == "02" { //诊查
  13476. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13477. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13478. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13479. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13480. // if item.ChrgitmLv == "1" {
  13481. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13482. // }
  13483. // if item.ChrgitmLv == "2" {
  13484. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13485. //
  13486. // }
  13487. // if item.ChrgitmLv == "3" {
  13488. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13489. // }
  13490. //
  13491. // }
  13492. //
  13493. // if item.MedChrgitmType == "03" { //检查费
  13494. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13495. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13496. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13497. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13498. // if item.ChrgitmLv == "1" {
  13499. //
  13500. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13501. //
  13502. // }
  13503. // if item.ChrgitmLv == "2" {
  13504. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13505. //
  13506. // }
  13507. // if item.ChrgitmLv == "3" {
  13508. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13509. // }
  13510. // }
  13511. //
  13512. // if item.MedChrgitmType == "04" { //化验费
  13513. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13514. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13515. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13516. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13517. // if item.ChrgitmLv == "1" {
  13518. //
  13519. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13520. //
  13521. // }
  13522. // if item.ChrgitmLv == "2" {
  13523. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13524. //
  13525. // }
  13526. // if item.ChrgitmLv == "3" {
  13527. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13528. // }
  13529. // }
  13530. //
  13531. // if item.MedChrgitmType == "05" { //治疗费
  13532. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13533. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13534. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13535. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13536. // if item.ChrgitmLv == "1" {
  13537. //
  13538. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13539. //
  13540. // }
  13541. // if item.ChrgitmLv == "2" {
  13542. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13543. //
  13544. // }
  13545. // if item.ChrgitmLv == "3" {
  13546. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13547. // }
  13548. // }
  13549. //
  13550. // if item.MedChrgitmType == "06" { //手术费
  13551. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13552. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13553. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13554. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13555. //
  13556. // if item.ChrgitmLv == "1" {
  13557. //
  13558. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13559. //
  13560. // }
  13561. // if item.ChrgitmLv == "2" {
  13562. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13563. //
  13564. // }
  13565. // if item.ChrgitmLv == "3" {
  13566. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13567. // }
  13568. // }
  13569. //
  13570. // if item.MedChrgitmType == "07" { //手术费
  13571. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13572. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13573. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13574. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13575. //
  13576. // if item.ChrgitmLv == "1" {
  13577. //
  13578. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13579. //
  13580. // }
  13581. // if item.ChrgitmLv == "2" {
  13582. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13583. //
  13584. // }
  13585. // if item.ChrgitmLv == "3" {
  13586. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13587. // }
  13588. // }
  13589. //
  13590. // if item.MedChrgitmType == "08" { //材料费
  13591. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13592. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13593. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13594. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13595. // if item.ChrgitmLv == "1" {
  13596. //
  13597. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13598. //
  13599. // }
  13600. // if item.ChrgitmLv == "2" {
  13601. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13602. //
  13603. // }
  13604. // if item.ChrgitmLv == "3" {
  13605. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13606. // }
  13607. // }
  13608. // if item.MedChrgitmType == "09" { //西药费
  13609. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13610. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13611. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13612. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13613. // if item.ChrgitmLv == "1" {
  13614. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13615. // }
  13616. // if item.ChrgitmLv == "2" {
  13617. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13618. // }
  13619. // if item.ChrgitmLv == "3" {
  13620. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13621. // }
  13622. // }
  13623. // if item.MedChrgitmType == "10" { //中药饮片
  13624. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13625. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13626. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13627. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13628. // if item.ChrgitmLv == "1" {
  13629. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13630. // }
  13631. // if item.ChrgitmLv == "2" {
  13632. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13633. // }
  13634. // if item.ChrgitmLv == "3" {
  13635. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13636. // }
  13637. // }
  13638. //
  13639. // if item.MedChrgitmType == "11" { //中成费
  13640. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13641. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13642. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13643. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13644. // if item.ChrgitmLv == "1" {
  13645. //
  13646. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13647. //
  13648. // }
  13649. // if item.ChrgitmLv == "2" {
  13650. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13651. //
  13652. // }
  13653. // if item.ChrgitmLv == "3" {
  13654. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13655. // }
  13656. // }
  13657. //
  13658. // if item.MedChrgitmType == "12" { //中成费
  13659. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13660. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13661. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13662. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13663. // if item.ChrgitmLv == "1" {
  13664. //
  13665. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13666. //
  13667. // }
  13668. // if item.ChrgitmLv == "2" {
  13669. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13670. //
  13671. // }
  13672. // if item.ChrgitmLv == "3" {
  13673. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13674. // }
  13675. // }
  13676. //
  13677. // if item.MedChrgitmType == "13" { //中成费
  13678. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13679. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13680. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13681. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13682. // if item.ChrgitmLv == "1" {
  13683. //
  13684. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13685. //
  13686. // }
  13687. // if item.ChrgitmLv == "2" {
  13688. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13689. //
  13690. // }
  13691. // if item.ChrgitmLv == "3" {
  13692. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13693. // }
  13694. // }
  13695. //
  13696. // if item.MedChrgitmType == "14" { //其他费
  13697. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13698. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13699. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13700. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13701. // if item.ChrgitmLv == "1" {
  13702. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13703. //
  13704. // }
  13705. // if item.ChrgitmLv == "2" {
  13706. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13707. //
  13708. // }
  13709. // if item.ChrgitmLv == "3" {
  13710. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13711. // }
  13712. // }
  13713. //
  13714. // }
  13715. //
  13716. // var iteminfoStructs []service.IteminfoStruct
  13717. //
  13718. // if bedCostTotal != 0 {
  13719. // iteminfo.MedChrgitm = "01"
  13720. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13721. // iteminfo.Amt = bedCostTotal
  13722. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  13723. // iteminfo.ClabAmt = bed_clab_amt
  13724. // iteminfo.OthAmt = bed_other_amt
  13725. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13726. // }
  13727. //
  13728. // if examineCostTotal != 0 {
  13729. // iteminfo.MedChrgitm = "02"
  13730. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  13731. // iteminfo.Amt = examineCostTotal
  13732. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  13733. // iteminfo.ClabAmt = examine_clab_amt
  13734. // iteminfo.OthAmt = examine_other_amt
  13735. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13736. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13737. // }
  13738. //
  13739. // if checkCostTotal != 0 {
  13740. // iteminfo.MedChrgitm = "03"
  13741. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  13742. // iteminfo.Amt = checkCostTotal
  13743. // iteminfo.ClaaSumfee = check_claa_sunmfee
  13744. // iteminfo.ClabAmt = check_clab_amt
  13745. // iteminfo.OthAmt = check_other_amt
  13746. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13747. //
  13748. // }
  13749. //
  13750. // if laboratoryCostTotal != 0 {
  13751. // iteminfo.MedChrgitm = "04"
  13752. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  13753. // iteminfo.Amt = laboratoryCostTotal
  13754. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  13755. // iteminfo.ClabAmt = laboratory_clab_amt
  13756. // iteminfo.OthAmt = laboratory_other_amt
  13757. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13758. //
  13759. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13760. //
  13761. // }
  13762. //
  13763. // if treatCostTotal != 0 {
  13764. // iteminfo.MedChrgitm = "05"
  13765. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  13766. // iteminfo.Amt = treatCostTotal
  13767. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  13768. // iteminfo.ClabAmt = treat_clab_amt
  13769. // iteminfo.OthAmt = treat_other_amt
  13770. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13771. // //(struct4101.IteminfoStruct, iteminfo)
  13772. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13773. // }
  13774. //
  13775. // if operationCostTotal != 0 {
  13776. // iteminfo.MedChrgitm = "06"
  13777. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13778. // iteminfo.Amt = operationCostTotal
  13779. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  13780. // iteminfo.ClabAmt = operation_clab_amt
  13781. // iteminfo.OthAmt = operation_other_amt
  13782. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13783. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13784. // }
  13785. //
  13786. // if nursingCostTotal != 0 {
  13787. // iteminfo.MedChrgitm = "07"
  13788. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  13789. // iteminfo.Amt = nursingCostTotal
  13790. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  13791. // iteminfo.ClabAmt = nursing_clab_amt
  13792. // iteminfo.OthAmt = nursing_other_amt
  13793. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13794. // }
  13795. //
  13796. // if materialCostTotal != 0 {
  13797. // iteminfo.MedChrgitm = "08"
  13798. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  13799. // iteminfo.Amt = materialCostTotal
  13800. // iteminfo.ClaaSumfee = material_claa_sunmfee
  13801. // iteminfo.ClabAmt = material_clab_amt
  13802. // iteminfo.OthAmt = material_other_amt
  13803. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13804. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13805. // }
  13806. //
  13807. // if westernMedicineCostTotal != 0 {
  13808. // iteminfo.MedChrgitm = "09"
  13809. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13810. // iteminfo.Amt = westernMedicineCostTotal
  13811. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13812. // iteminfo.ClabAmt = westernMedicine_clab_amt
  13813. // iteminfo.OthAmt = westernMedicine_other_amt
  13814. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13815. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13816. //
  13817. // }
  13818. //
  13819. // if chineseMedicineCostTotal != 0 {
  13820. // iteminfo.MedChrgitm = "10"
  13821. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  13822. // iteminfo.Amt = chineseMedicineCostTotal
  13823. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  13824. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  13825. // iteminfo.OthAmt = chinese_medicine_other_amt
  13826. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13827. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13828. //
  13829. // }
  13830. //
  13831. // if chineseTraditionalMedicineCostTotal != 0 {
  13832. // iteminfo.MedChrgitm = "11"
  13833. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13834. // iteminfo.Amt = westernMedicineCostTotal
  13835. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13836. // iteminfo.ClabAmt = westernMedicine_clab_amt
  13837. // iteminfo.OthAmt = westernMedicine_other_amt
  13838. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13839. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13840. //
  13841. // }
  13842. //
  13843. // if commonlyTreatmentCostTotal != 0 {
  13844. // iteminfo.MedChrgitm = "12"
  13845. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  13846. // iteminfo.Amt = commonlyTreatmentCostTotal
  13847. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  13848. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  13849. // iteminfo.OthAmt = commonly_treatment_other_amt
  13850. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13851. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13852. //
  13853. // }
  13854. //
  13855. // if registerCostTotal != 0 {
  13856. // iteminfo.MedChrgitm = "13"
  13857. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  13858. // iteminfo.Amt = registerCostTotal
  13859. // iteminfo.ClaaSumfee = register_claa_sunmfee
  13860. // iteminfo.ClabAmt = register_clab_amt
  13861. // iteminfo.OthAmt = register_other_amt
  13862. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13863. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13864. //
  13865. // }
  13866. //
  13867. // if otherCostTotal != 0 {
  13868. // iteminfo.MedChrgitm = "14"
  13869. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  13870. // iteminfo.Amt = otherCostTotal
  13871. // iteminfo.ClaaSumfee = other_claa_sunmfee
  13872. // iteminfo.ClabAmt = other_clab_amt
  13873. // iteminfo.OthAmt = other_other_amt
  13874. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13875. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13876. //
  13877. // }
  13878. // struct4101.IteminfoStruct = iteminfoStructs
  13879. // time_arr := strings.Split(order.SetlTime, " ")
  13880. // struct4101.AdmTime = time_arr[0]
  13881. // struct4101.AdmEndTime = time_arr[0]
  13882. //
  13883. // struct4101.DoctorName = doctor.UserName
  13884. // struct4101.DoctorCode = doctor.DoctorNumber
  13885. //
  13886. // struct4101.Ntly = "中国"
  13887. // struct4101.AdmCaty = "A03.06"
  13888. // var res ResultSeventeen
  13889. // if miConfig.MdtrtareaAdmvs == "421300" {
  13890. // data := make(map[string]interface{})
  13891. // data["struct4101"] = struct4101
  13892. // data["secret_key"] = miConfig.SecretKey
  13893. // data["org_name"] = miConfig.OrgName
  13894. // data["opera"] = curRoles.UserName
  13895. // data["code"] = miConfig.Code
  13896. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  13897. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  13898. //
  13899. // client := &http.Client{}
  13900. // bytesData, _ := json.Marshal(data)
  13901. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  13902. // resp, _ := client.Do(req)
  13903. // defer resp.Body.Close()
  13904. // body, ioErr := ioutil.ReadAll(resp.Body)
  13905. // if ioErr != nil {
  13906. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13907. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13908. // return
  13909. // }
  13910. // var respJSON map[string]interface{}
  13911. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13912. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13913. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13914. // return
  13915. // }
  13916. //
  13917. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13918. // userJSONBytes, _ := json.Marshal(respJSON)
  13919. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13920. // utils.ErrorLog("解析失败:%v", err)
  13921. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13922. // adminUser := c.GetAdminUserInfo()
  13923. // errlog := &models.HisOrderError{
  13924. // UserOrgId: adminUser.CurrentOrgId,
  13925. // Ctime: time.Now().Unix(),
  13926. // Mtime: time.Now().Unix(),
  13927. // ErrMsg: res.ErrMsg + "解析失败",
  13928. // Status: 1,
  13929. // PatientId: order_id,
  13930. // Stage: 10088,
  13931. // }
  13932. // service.CreateErrMsgLog(errlog)
  13933. // continue
  13934. // }
  13935. //
  13936. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  13937. // data := make(map[string]interface{})
  13938. // data["struct4101"] = struct4101
  13939. // data["secret_key"] = miConfig.SecretKey
  13940. // data["org_name"] = miConfig.OrgName
  13941. // data["opera"] = curRoles.UserName
  13942. // data["code"] = miConfig.Code
  13943. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  13944. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  13945. //
  13946. // client := &http.Client{}
  13947. // bytesData, _ := json.Marshal(data)
  13948. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  13949. // resp, _ := client.Do(req)
  13950. // defer resp.Body.Close()
  13951. // body, ioErr := ioutil.ReadAll(resp.Body)
  13952. // if ioErr != nil {
  13953. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13954. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13955. // return
  13956. // }
  13957. // var respJSON map[string]interface{}
  13958. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13959. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13960. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13961. // return
  13962. // }
  13963. //
  13964. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13965. // userJSONBytes, _ := json.Marshal(respJSON)
  13966. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13967. // utils.ErrorLog("解析失败:%v", err)
  13968. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13969. // adminUser := c.GetAdminUserInfo()
  13970. // errlog := &models.HisOrderError{
  13971. // UserOrgId: adminUser.CurrentOrgId,
  13972. // Ctime: time.Now().Unix(),
  13973. // Mtime: time.Now().Unix(),
  13974. // ErrMsg: res.ErrMsg + "解析失败",
  13975. // Status: 1,
  13976. // PatientId: order_id,
  13977. // Stage: 10088,
  13978. // }
  13979. // service.CreateErrMsgLog(errlog)
  13980. // continue
  13981. // }
  13982. //
  13983. // } else {
  13984. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  13985. // fmt.Println(result)
  13986. //
  13987. // var dat map[string]interface{}
  13988. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13989. // fmt.Println(dat)
  13990. // } else {
  13991. // fmt.Println(err)
  13992. // }
  13993. // userJSONBytes, _ := json.Marshal(dat)
  13994. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13995. // utils.ErrorLog("解析失败:%v", err)
  13996. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13997. // adminUser := c.GetAdminUserInfo()
  13998. // errlog := &models.HisOrderError{
  13999. // UserOrgId: adminUser.CurrentOrgId,
  14000. // Ctime: time.Now().Unix(),
  14001. // Mtime: time.Now().Unix(),
  14002. // ErrMsg: res.ErrMsg + "解析失败",
  14003. // Status: 1,
  14004. // PatientId: order_id,
  14005. // Stage: 10106,
  14006. // }
  14007. // service.CreateErrMsgLog(errlog)
  14008. // continue
  14009. // }
  14010. // }
  14011. //
  14012. // if res.Infcode != 0 {
  14013. // adminUser := c.GetAdminUserInfo()
  14014. // errlog := &models.HisOrderError{
  14015. // UserOrgId: adminUser.CurrentOrgId,
  14016. // Ctime: time.Now().Unix(),
  14017. // Mtime: time.Now().Unix(),
  14018. // ErrMsg: res.ErrMsg,
  14019. // Status: 1,
  14020. // PatientId: order_id,
  14021. // Stage: 10106,
  14022. // }
  14023. // service.CreateErrMsgLog(errlog)
  14024. // continue
  14025. // } else {
  14026. // hisFundSettleListResult := &models.HisFundSettleListResult{
  14027. // Number: res.Output.SetlListId,
  14028. // Status: 1,
  14029. // Ctime: time.Now().Unix(),
  14030. // Mtime: time.Now().Unix(),
  14031. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14032. // IsUpload: 1,
  14033. // OrderId: order_id,
  14034. // }
  14035. // service.CreateUploadRecord(hisFundSettleListResult)
  14036. // continue
  14037. // }
  14038. // }
  14039. //}
  14040. func (c *HisApiController) GetOrgInfo() {
  14041. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  14042. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  14043. }
  14044. func (c *HisApiController) GetHisPatientInfo() {
  14045. medical_insurance_card := c.GetString("medical_insurance_card")
  14046. id_card_type, _ := c.GetInt64("id_card_type")
  14047. id_card := c.GetString("id_card")
  14048. adminInfo := c.GetAdminUserInfo()
  14049. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  14050. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  14051. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  14052. IdCardNo := ""
  14053. if id_card_type == 1 {
  14054. IdCardNo = medical_insurance_card
  14055. } else if id_card_type == 2 {
  14056. IdCardNo = id_card
  14057. }
  14058. if config.IsOpen == 1 {
  14059. 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
  14060. resp, requestErr := http.Get(api)
  14061. if requestErr != nil {
  14062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14063. return
  14064. }
  14065. defer resp.Body.Close()
  14066. body, ioErr := ioutil.ReadAll(resp.Body)
  14067. if ioErr != nil {
  14068. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14070. return
  14071. }
  14072. var respJSON map[string]interface{}
  14073. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14074. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14076. return
  14077. }
  14078. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14079. userJSONBytes, _ := json.Marshal(userJSON)
  14080. var res ResultTwo
  14081. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14082. utils.ErrorLog("解析失败:%v", err)
  14083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14084. return
  14085. }
  14086. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14087. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14088. infoStr := string(Iinfos)
  14089. idetinfoStr := string(Idetinfos)
  14090. if res.Infcode == 0 {
  14091. his := models.VMHisPatient{
  14092. Status: 1,
  14093. Ctime: time.Now().Unix(),
  14094. Mtime: time.Now().Unix(),
  14095. PsnNo: res.Output.Baseinfo.PsnNo,
  14096. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14097. Certno: res.Output.Baseinfo.Certno,
  14098. PsnName: res.Output.Baseinfo.PsnName,
  14099. Gend: res.Output.Baseinfo.Gend,
  14100. Naty: res.Output.Baseinfo.Naty,
  14101. Iinfo: infoStr,
  14102. Idetinfo: idetinfoStr,
  14103. UserOrgId: adminInfo.CurrentOrgId,
  14104. IsReturn: 1,
  14105. IdCardType: id_card_type,
  14106. }
  14107. c.ServeSuccessJSON(map[string]interface{}{
  14108. "info": his,
  14109. })
  14110. } else {
  14111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14112. return
  14113. }
  14114. }
  14115. }
  14116. //func GetBasBaseInfo() (jsonStr string, err error) {
  14117. //
  14118. // handle := syscall.NewLazyDLL("SSCard.dll")
  14119. // add := handle.NewProc("ReadCardBas")
  14120. // str := make([]byte, 1024)
  14121. // str1 := make([]byte, 1024)
  14122. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  14123. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  14124. //
  14125. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  14126. //
  14127. // fmt.Println("> Add(4,5)的结果为:", ret)
  14128. // handle.Release()
  14129. //
  14130. // return "", nil
  14131. //
  14132. //}
  14133. //func GetQRBaseInfo() (jsonStr string, err error) {
  14134. // handle := syscall.LoadDLL("SSCard.dll")
  14135. // ReadCardBas := handle.FindProc("GetQRBase")
  14136. //
  14137. // str := make([]byte, 256)
  14138. // str1 := make([]byte, 256)
  14139. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  14140. //
  14141. // fmt.Println(string(str))
  14142. // fmt.Println(r)
  14143. // return string(str), nil
  14144. //}
  14145. //func CardInit() int {
  14146. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  14147. // add := DllTestDef.MustFindProc("Init")
  14148. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  14149. // if err != nil {
  14150. // fmt.Println("SSCard的运算结果为:", ret)
  14151. // }
  14152. // result := int(ret)
  14153. // return result
  14154. //}
  14155. //func CardInit() int {
  14156. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  14157. // if err != nil {
  14158. // fmt.Println("SSCard的运算结果为:", ret)
  14159. // }
  14160. // fmt.Println(err)
  14161. // result := int(ret)
  14162. // return result
  14163. //}
  14164. func IntPtr(n int) uintptr {
  14165. return uintptr(n)
  14166. }
  14167. func StrPtr(s string) uintptr {
  14168. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  14169. }
  14170. type Result2001 struct {
  14171. Cainfo interface{} `json:"cainfo"`
  14172. ErrMsg string `json:"err_msg"`
  14173. InfRefmsgid string `json:"inf_refmsgid"`
  14174. Infcode int64 `json:"infcode"`
  14175. Output struct {
  14176. Trtinfo struct {
  14177. PsnNo string `json:"psn_no"`
  14178. TrtChkType string `json:"trt_chk_type"`
  14179. FundPayType string `json:"fund_pay_type"`
  14180. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  14181. Begndate string `json:"begndate"`
  14182. Enddate string `json:"enddate"`
  14183. TrtChkRslt string `json:"trt_chk_rslt"`
  14184. } `json:"trtinfo"`
  14185. } `json:"output"`
  14186. RefmsgTime string `json:"refmsg_time"`
  14187. RespondTime string `json:"respond_time"`
  14188. Signtype interface{} `json:"signtype"`
  14189. WarnMsg interface{} `json:"warn_msg"`
  14190. }
  14191. type Result2001Org10265 struct {
  14192. Cainfo interface{} `json:"cainfo"`
  14193. ErrMsg string `json:"err_msg"`
  14194. InfRefmsgid string `json:"inf_refmsgid"`
  14195. Infcode string `json:"infcode"`
  14196. Output struct {
  14197. Trtinfo struct {
  14198. PsnNo string `json:"psn_no"`
  14199. TrtChkType string `json:"trt_chk_type"`
  14200. FundPayType string `json:"fund_pay_type"`
  14201. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  14202. Begndate string `json:"begndate"`
  14203. Enddate string `json:"enddate"`
  14204. TrtChkRslt string `json:"trt_chk_rslt"`
  14205. } `json:"trtinfo"`
  14206. } `json:"output"`
  14207. RefmsgTime string `json:"refmsg_time"`
  14208. RespondTime string `json:"respond_time"`
  14209. Signtype interface{} `json:"signtype"`
  14210. WarnMsg interface{} `json:"warn_msg"`
  14211. }
  14212. type ResultTwo struct {
  14213. ErrMsg string `json:"err_msg"`
  14214. InfRefmsgid string `json:"inf_refmsgid"`
  14215. Infcode int64 `json:"infcode"`
  14216. Output struct {
  14217. Baseinfo struct {
  14218. //Brdy string `json:"brdy"`
  14219. Certno string `json:"certno"`
  14220. Gend string `json:"gend"`
  14221. Naty string `json:"naty"`
  14222. PsnCertType string `json:"psn_cert_type"`
  14223. PsnName string `json:"psn_name"`
  14224. PsnNo string `json:"psn_no"`
  14225. } `json:"baseinfo"`
  14226. Idetinfo []interface{} `json:"idetinfo"`
  14227. Iinfo []struct {
  14228. Balc float64 `json:"balc"`
  14229. CvlservFlag string `json:"cvlserv_flag"`
  14230. EmpName string `json:"emp_name"`
  14231. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  14232. Insutype string `json:"insutype"`
  14233. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  14234. //PausInsuDate string `json:"paus_insu_date"`
  14235. //PsnInsuDate string `json:"psn_insu_date"`
  14236. PsnInsuStas string `json:"psn_insu_stas"`
  14237. PsnType string `json:"psn_type"`
  14238. } `json:"insuinfo"`
  14239. } `json:"output"`
  14240. RefmsgTime string `json:"refmsg_time"`
  14241. RespondTime string `json:"respond_time"`
  14242. Signtype interface{} `json:"signtype"`
  14243. WarnInfo interface{} `json:"warn_info"`
  14244. }
  14245. type ResultTwo10265 struct {
  14246. ErrMsg string `json:"err_msg"`
  14247. InfRefmsgid string `json:"inf_refmsgid"`
  14248. Infcode string `json:"infcode"`
  14249. Output struct {
  14250. Baseinfo struct {
  14251. //Brdy string `json:"brdy"`
  14252. Certno string `json:"certno"`
  14253. Gend string `json:"gend"`
  14254. Naty string `json:"naty"`
  14255. PsnCertType string `json:"psn_cert_type"`
  14256. PsnName string `json:"psn_name"`
  14257. PsnNo string `json:"psn_no"`
  14258. } `json:"baseinfo"`
  14259. Idetinfo []interface{} `json:"idetinfo"`
  14260. Iinfo []struct {
  14261. Balc float64 `json:"balc"`
  14262. CvlservFlag string `json:"cvlserv_flag"`
  14263. EmpName string `json:"emp_name"`
  14264. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  14265. Insutype string `json:"insutype"`
  14266. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  14267. PsnInsuStas string `json:"psn_insu_stas"`
  14268. PsnType string `json:"psn_type"`
  14269. } `json:"insuinfo"`
  14270. } `json:"output"`
  14271. RefmsgTime string `json:"refmsg_time"`
  14272. RespondTime string `json:"respond_time"`
  14273. Signtype interface{} `json:"signtype"`
  14274. WarnInfo interface{} `json:"warn_info"`
  14275. }
  14276. type ResultThree struct {
  14277. Cainfo interface{} `json:"cainfo"`
  14278. ErrMsg string `json:"err_msg"`
  14279. InfRefmsgid string `json:"inf_refmsgid"`
  14280. Infcode int64 `json:"infcode"`
  14281. Output struct {
  14282. Data struct {
  14283. IptOtpNo string `json:"ipt_otp_no"`
  14284. MdtrtID string `json:"mdtrt_id"`
  14285. PsnNo string `json:"psn_no"`
  14286. } `json:"data"`
  14287. } `json:"output"`
  14288. RefmsgTime string `json:"refmsg_time"`
  14289. RespondTime string `json:"respond_time"`
  14290. Signtype interface{} `json:"signtype"`
  14291. WarnMsg interface{} `json:"warn_msg"`
  14292. }
  14293. type ResultThree10265 struct {
  14294. Cainfo interface{} `json:"cainfo"`
  14295. ErrMsg string `json:"err_msg"`
  14296. InfRefmsgid string `json:"inf_refmsgid"`
  14297. Infcode string `json:"infcode"`
  14298. Output struct {
  14299. Data struct {
  14300. IptOtpNo string `json:"ipt_otp_no"`
  14301. MdtrtID string `json:"mdtrt_id"`
  14302. PsnNo string `json:"psn_no"`
  14303. } `json:"data"`
  14304. } `json:"output"`
  14305. RefmsgTime string `json:"refmsg_time"`
  14306. RespondTime string `json:"respond_time"`
  14307. Signtype interface{} `json:"signtype"`
  14308. WarnMsg interface{} `json:"warn_msg"`
  14309. }
  14310. type ResultFour struct {
  14311. Cainfo string `json:"cainfo"`
  14312. ErrMsg string `json:"err_msg"`
  14313. InfRefmsgid string `json:"inf_refmsgid"`
  14314. Infcode int64 `json:"infcode"`
  14315. Output struct {
  14316. Result []struct {
  14317. BasMednFlag string `json:"bas_medn_flag"`
  14318. ChldMedcFlag string `json:"chld_medc_flag"`
  14319. ChrgitmLv string `json:"chrgitm_lv"`
  14320. Cnt float64 `json:"cnt"`
  14321. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  14322. DrtReimFlag string `json:"drt_reim_flag"`
  14323. FeedetlSn string `json:"feedetl_sn"`
  14324. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14325. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  14326. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14327. ListSpItemFlag string `json:"list_sp_item_flag"`
  14328. LmtUsedFlag string `json:"lmt_used_flag"`
  14329. MedChrgitmType string `json:"med_chrgitm_type"`
  14330. Memo string `json:"memo"`
  14331. OverlmtAmt float64 `json:"overlmt_amt"`
  14332. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14333. Pric float64 `json:"pric"`
  14334. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  14335. SelfpayProp float64 `json:"selfpay_prop"`
  14336. } `json:"result"`
  14337. } `json:"output"`
  14338. RefmsgTime string `json:"refmsg_time"`
  14339. RespondTime string `json:"respond_time"`
  14340. Signtype string `json:"signtype"`
  14341. WarnMsg string `json:"warn_msg"`
  14342. }
  14343. type ResultFour10265 struct {
  14344. Cainfo string `json:"cainfo"`
  14345. ErrMsg string `json:"err_msg"`
  14346. InfRefmsgid string `json:"inf_refmsgid"`
  14347. Infcode string `json:"infcode"`
  14348. Output struct {
  14349. Result []struct {
  14350. BasMednFlag string `json:"bas_medn_flag"`
  14351. ChldMedcFlag string `json:"chld_medc_flag"`
  14352. ChrgitmLv string `json:"chrgitm_lv"`
  14353. Cnt float64 `json:"cnt"`
  14354. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  14355. DrtReimFlag string `json:"drt_reim_flag"`
  14356. FeedetlSn string `json:"feedetl_sn"`
  14357. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14358. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  14359. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14360. ListSpItemFlag string `json:"list_sp_item_flag"`
  14361. LmtUsedFlag string `json:"lmt_used_flag"`
  14362. MedChrgitmType string `json:"med_chrgitm_type"`
  14363. Memo string `json:"memo"`
  14364. OverlmtAmt float64 `json:"overlmt_amt"`
  14365. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14366. Pric float64 `json:"pric"`
  14367. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  14368. SelfpayProp float64 `json:"selfpay_prop"`
  14369. } `json:"result"`
  14370. } `json:"output"`
  14371. RefmsgTime string `json:"refmsg_time"`
  14372. RespondTime string `json:"respond_time"`
  14373. Signtype string `json:"signtype"`
  14374. WarnMsg string `json:"warn_msg"`
  14375. }
  14376. type ResultMemo struct {
  14377. InsuAdmdvs string `json:"insuAdmdvs"`
  14378. }
  14379. // [{"begntime":"2022-01-01 00:00:00","endtime":"2022-12-31 00:00:00","memo":"{\"matIdetCode\":\"20\",\"insuAdmdvs\":\"350481\"}","psn_idet_type":"23","psn_type_lv":null}]
  14380. type ResultIDInfo struct {
  14381. Begntime string `json:"begntime"`
  14382. Endtime string `json:"endtime"`
  14383. Memo string `json:"memo"`
  14384. }
  14385. type ResultFive struct {
  14386. Balc float64 `json:"balc"`
  14387. CvlservFlag string `json:"cvlserv_flag"`
  14388. EmpName string `json:"emp_name"`
  14389. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  14390. Insutype string `json:"insutype"`
  14391. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  14392. PausInsuDate string `json:"paus_insu_date"`
  14393. PsnInsuDate string `json:"psn_insu_date"`
  14394. PsnInsuStas string `json:"psn_insu_stas"`
  14395. PsnType string `json:"psn_type"`
  14396. }
  14397. type ResultSix struct {
  14398. Cainfo interface{} `json:"cainfo"`
  14399. ErrMsg string `json:"err_msg"`
  14400. InfRefmsgid string `json:"inf_refmsgid"`
  14401. Infcode int64 `json:"infcode"`
  14402. Output struct {
  14403. } `json:"output"`
  14404. RefmsgTime string `json:"refmsg_time"`
  14405. RespondTime string `json:"respond_time"`
  14406. Signtype interface{} `json:"signtype"`
  14407. WarnMsg interface{} `json:"warn_msg"`
  14408. }
  14409. type Result2406 struct {
  14410. Cainfo interface{} `json:"cainfo"`
  14411. ErrMsg string `json:"err_msg"`
  14412. InfRefmsgid string `json:"inf_refmsgid"`
  14413. Infcode int64 `json:"infcode"`
  14414. Output struct {
  14415. Result struct {
  14416. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  14417. } `json:"result"`
  14418. } `json:"output"`
  14419. RefmsgTime string `json:"refmsg_time"`
  14420. RespondTime string `json:"respond_time"`
  14421. Signtype interface{} `json:"signtype"`
  14422. WarnMsg interface{} `json:"warn_msg"`
  14423. }
  14424. type GZResultSix struct {
  14425. Cainfo interface{} `json:"cainfo"`
  14426. ErrMsg string `json:"err_msg"`
  14427. InfRefmsgid string `json:"inf_refmsgid"`
  14428. Infcode int64 `json:"infcode"`
  14429. Output string `json:"output"`
  14430. RefmsgTime string `json:"refmsg_time"`
  14431. RespondTime string `json:"respond_time"`
  14432. Signtype interface{} `json:"signtype"`
  14433. WarnMsg interface{} `json:"warn_msg"`
  14434. }
  14435. type ResultSix10265 struct {
  14436. Cainfo interface{} `json:"cainfo"`
  14437. ErrMsg string `json:"err_msg"`
  14438. InfRefmsgid string `json:"inf_refmsgid"`
  14439. Infcode string `json:"infcode"`
  14440. Output struct {
  14441. } `json:"output"`
  14442. RefmsgTime string `json:"refmsg_time"`
  14443. RespondTime string `json:"respond_time"`
  14444. Signtype interface{} `json:"signtype"`
  14445. WarnMsg interface{} `json:"warn_msg"`
  14446. }
  14447. type ResultSeven struct {
  14448. Cainfo string `json:"cainfo"`
  14449. ErrMsg string `json:"err_msg"`
  14450. InfRefmsgid string `json:"inf_refmsgid"`
  14451. Infcode int64 `json:"infcode"`
  14452. Output struct {
  14453. Setlinfo struct {
  14454. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  14455. AcctPay float64 `json:"acct_pay"`
  14456. ActPayDedc float64 `json:"act_pay_dedc"`
  14457. Age float64 `json:"age"`
  14458. Balc float64 `json:"balc"`
  14459. Certno string `json:"certno"`
  14460. ClrOptins string `json:"clr_optins"`
  14461. ClrType string `json:"clr_type"`
  14462. ClrWay string `json:"clr_way"`
  14463. CvlservFlag string `json:"cvlserv_flag"`
  14464. CvlservPay float64 `json:"cvlserv_pay"`
  14465. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14466. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  14467. Gend string `json:"gend"`
  14468. HifesPay float64 `json:"hifes_pay"`
  14469. HifmiPay float64 `json:"hifmi_pay"`
  14470. HifpPay float64 `json:"hifp_pay"`
  14471. HospPartAmt float64 `json:"hosp_part_amt"`
  14472. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14473. Insutype string `json:"insutype"`
  14474. MafPay float64 `json:"maf_pay"`
  14475. MdtrtCertType string `json:"mdtrt_cert_type"`
  14476. HifobPay float64 `json:"hifob_pay"`
  14477. MdtrtID string `json:"mdtrt_id"`
  14478. MedType string `json:"med_type"`
  14479. MedfeeSumamt float64 `json:"medfee_sumamt"`
  14480. MedinsSetlID string `json:"medins_setl_id"`
  14481. Naty string `json:"naty"`
  14482. OthPay float64 `json:"oth_pay"`
  14483. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  14484. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  14485. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14486. PsnCashPay float64 `json:"psn_cash_pay"`
  14487. PsnCertType string `json:"psn_cert_type"`
  14488. PsnName string `json:"psn_name"`
  14489. PsnNo string `json:"psn_no"`
  14490. PsnPartAmt float64 `json:"psn_part_amt"`
  14491. PsnType string `json:"psn_type"`
  14492. SetlID string `json:"setl_id"`
  14493. SetlTime string `json:"setl_time"`
  14494. } `json:"setlinfo"`
  14495. Setldetail interface{} `json:"setldetail"`
  14496. } `json:"output"`
  14497. RefmsgTime string `json:"refmsg_time"`
  14498. RespondTime string `json:"respond_time"`
  14499. Signtype interface{} `json:"signtype"`
  14500. WarnMsg interface{} `json:"warn_msg"`
  14501. }
  14502. type ResultSevenAH struct {
  14503. Cainfo string `json:"cainfo"`
  14504. ErrMsg string `json:"err_msg"`
  14505. InfRefmsgid string `json:"inf_refmsgid"`
  14506. Infcode int64 `json:"infcode"`
  14507. Output struct {
  14508. Setlinfo struct {
  14509. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  14510. AcctPay float64 `json:"acct_pay"`
  14511. ActPayDedc float64 `json:"act_pay_dedc"`
  14512. Age float64 `json:"age"`
  14513. Balc float64 `json:"balc"`
  14514. Certno string `json:"certno"`
  14515. ClrOptins string `json:"clr_optins"`
  14516. ClrType string `json:"clr_type"`
  14517. ClrWay string `json:"clr_way"`
  14518. CvlservFlag string `json:"cvlserv_flag"`
  14519. CvlservPay float64 `json:"cvlserv_pay"`
  14520. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14521. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  14522. Gend string `json:"gend"`
  14523. HifesPay float64 `json:"hifes_pay"`
  14524. HifmiPay float64 `json:"hifmi_pay"`
  14525. HifpPay float64 `json:"hifp_pay"`
  14526. HospPartAmt float64 `json:"hosp_part_amt"`
  14527. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14528. Insutype string `json:"insutype"`
  14529. MafPay float64 `json:"maf_pay"`
  14530. MdtrtCertType string `json:"mdtrt_cert_type"`
  14531. HifobPay float64 `json:"hifob_pay"`
  14532. MdtrtID string `json:"mdtrt_id"`
  14533. MedType string `json:"med_type"`
  14534. MedfeeSumamt float64 `json:"medfee_sumamt"`
  14535. MedinsSetlID string `json:"medins_setl_id"`
  14536. Naty string `json:"naty"`
  14537. OthPay float64 `json:"oth_pay"`
  14538. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  14539. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  14540. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14541. PsnCashPay float64 `json:"psn_cash_pay"`
  14542. PsnCertType string `json:"psn_cert_type"`
  14543. PsnName string `json:"psn_name"`
  14544. PsnNo string `json:"psn_no"`
  14545. PsnPartAmt float64 `json:"psn_part_amt"`
  14546. PsnType string `json:"psn_type"`
  14547. SetlID string `json:"setl_id"`
  14548. SetlTime int64 `json:"setl_time"`
  14549. } `json:"setlinfo"`
  14550. Setldetail interface{} `json:"setldetail"`
  14551. } `json:"output"`
  14552. RefmsgTime string `json:"refmsg_time"`
  14553. RespondTime string `json:"respond_time"`
  14554. Signtype interface{} `json:"signtype"`
  14555. WarnMsg interface{} `json:"warn_msg"`
  14556. }
  14557. type ResultSeven10265 struct {
  14558. Cainfo string `json:"cainfo"`
  14559. ErrMsg string `json:"err_msg"`
  14560. InfRefmsgid string `json:"inf_refmsgid"`
  14561. Infcode string `json:"infcode"`
  14562. Output struct {
  14563. Setlinfo struct {
  14564. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  14565. AcctPay float64 `json:"acct_pay"`
  14566. ActPayDedc float64 `json:"act_pay_dedc"`
  14567. Age float64 `json:"age"`
  14568. Balc float64 `json:"balc"`
  14569. Certno string `json:"certno"`
  14570. ClrOptins string `json:"clr_optins"`
  14571. ClrType string `json:"clr_type"`
  14572. ClrWay string `json:"clr_way"`
  14573. CvlservFlag string `json:"cvlserv_flag"`
  14574. CvlservPay float64 `json:"cvlserv_pay"`
  14575. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14576. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  14577. Gend string `json:"gend"`
  14578. HifesPay float64 `json:"hifes_pay"`
  14579. HifmiPay float64 `json:"hifmi_pay"`
  14580. HifpPay float64 `json:"hifp_pay"`
  14581. HospPartAmt float64 `json:"hosp_part_amt"`
  14582. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14583. Insutype string `json:"insutype"`
  14584. MafPay float64 `json:"maf_pay"`
  14585. MdtrtCertType string `json:"mdtrt_cert_type"`
  14586. HifobPay float64 `json:"hifob_pay"`
  14587. MdtrtID string `json:"mdtrt_id"`
  14588. MedType string `json:"med_type"`
  14589. MedfeeSumamt float64 `json:"medfee_sumamt"`
  14590. MedinsSetlID string `json:"medins_setl_id"`
  14591. Naty string `json:"naty"`
  14592. OthPay float64 `json:"oth_pay"`
  14593. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  14594. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  14595. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14596. PsnCashPay float64 `json:"psn_cash_pay"`
  14597. PsnCertType string `json:"psn_cert_type"`
  14598. PsnName string `json:"psn_name"`
  14599. PsnNo string `json:"psn_no"`
  14600. PsnPartAmt float64 `json:"psn_part_amt"`
  14601. PsnType string `json:"psn_type"`
  14602. SetlID string `json:"setl_id"`
  14603. SetlTime string `json:"setl_time"`
  14604. } `json:"setlinfo"`
  14605. Setldetail interface{} `json:"setldetail"`
  14606. } `json:"output"`
  14607. RefmsgTime string `json:"refmsg_time"`
  14608. RespondTime string `json:"respond_time"`
  14609. Signtype interface{} `json:"signtype"`
  14610. WarnMsg interface{} `json:"warn_msg"`
  14611. }
  14612. type ResultSeven10265Two struct {
  14613. Cainfo string `json:"cainfo"`
  14614. ErrMsg string `json:"err_msg"`
  14615. InfRefmsgid string `json:"inf_refmsgid"`
  14616. Infcode string `json:"infcode"`
  14617. Output struct {
  14618. Setlinfo struct {
  14619. AcctMulaidPay string `json:"acct_mulaid_pay"`
  14620. AcctPay float64 `json:"acct_pay"`
  14621. ActPayDedc float64 `json:"act_pay_dedc"`
  14622. Age float64 `json:"age"`
  14623. Balc float64 `json:"balc"`
  14624. Certno string `json:"certno"`
  14625. ClrOptins string `json:"clr_optins"`
  14626. ClrType string `json:"clr_type"`
  14627. ClrWay string `json:"clr_way"`
  14628. CvlservFlag string `json:"cvlserv_flag"`
  14629. CvlservPay float64 `json:"cvlserv_pay"`
  14630. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14631. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  14632. Gend string `json:"gend"`
  14633. HifesPay float64 `json:"hifes_pay"`
  14634. HifmiPay float64 `json:"hifmi_pay"`
  14635. HifpPay float64 `json:"hifp_pay"`
  14636. HospPartAmt string `json:"hosp_part_amt"`
  14637. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14638. Insutype string `json:"insutype"`
  14639. MafPay float64 `json:"maf_pay"`
  14640. MdtrtCertType string `json:"mdtrt_cert_type"`
  14641. HifobPay float64 `json:"hifob_pay"`
  14642. MdtrtID string `json:"mdtrt_id"`
  14643. MedType string `json:"med_type"`
  14644. MedfeeSumamt float64 `json:"medfee_sumamt"`
  14645. MedinsSetlID string `json:"medins_setl_id"`
  14646. Naty string `json:"naty"`
  14647. OthPay float64 `json:"oth_pay"`
  14648. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  14649. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  14650. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14651. PsnCashPay float64 `json:"psn_cash_pay"`
  14652. PsnCertType string `json:"psn_cert_type"`
  14653. PsnName string `json:"psn_name"`
  14654. PsnNo string `json:"psn_no"`
  14655. PsnPartAmt float64 `json:"psn_part_amt"`
  14656. PsnType string `json:"psn_type"`
  14657. SetlID string `json:"setl_id"`
  14658. SetlTime string `json:"setl_time"`
  14659. } `json:"setlinfo"`
  14660. Setldetail interface{} `json:"setldetail"`
  14661. } `json:"output"`
  14662. RefmsgTime string `json:"refmsg_time"`
  14663. RespondTime string `json:"respond_time"`
  14664. Signtype interface{} `json:"signtype"`
  14665. WarnMsg interface{} `json:"warn_msg"`
  14666. }
  14667. type GZResultSeven10265Two struct {
  14668. Cainfo string `json:"cainfo"`
  14669. ErrMsg string `json:"err_msg"`
  14670. InfRefmsgid string `json:"inf_refmsgid"`
  14671. Infcode int64 `json:"infcode"`
  14672. Output struct {
  14673. Setlinfo struct {
  14674. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  14675. AcctPay float64 `json:"acct_pay"`
  14676. ActPayDedc float64 `json:"act_pay_dedc"`
  14677. Age float64 `json:"age"`
  14678. Balc float64 `json:"balc"`
  14679. Certno string `json:"certno"`
  14680. ClrOptins string `json:"clr_optins"`
  14681. ClrType string `json:"clr_type"`
  14682. ClrWay string `json:"clr_way"`
  14683. CvlservFlag string `json:"cvlserv_flag"`
  14684. CvlservPay float64 `json:"cvlserv_pay"`
  14685. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14686. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  14687. Gend string `json:"gend"`
  14688. HifesPay float64 `json:"hifes_pay"`
  14689. HifmiPay float64 `json:"hifmi_pay"`
  14690. HifpPay float64 `json:"hifp_pay"`
  14691. HospPartAmt float64 `json:"hosp_part_amt"`
  14692. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14693. Insutype string `json:"insutype"`
  14694. MafPay float64 `json:"maf_pay"`
  14695. MdtrtCertType string `json:"mdtrt_cert_type"`
  14696. HifobPay float64 `json:"hifob_pay"`
  14697. MdtrtID string `json:"mdtrt_id"`
  14698. MedType string `json:"med_type"`
  14699. MedfeeSumamt float64 `json:"medfee_sumamt"`
  14700. MedinsSetlID string `json:"medins_setl_id"`
  14701. Naty string `json:"naty"`
  14702. OthPay float64 `json:"oth_pay"`
  14703. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  14704. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  14705. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14706. PsnCashPay float64 `json:"psn_cash_pay"`
  14707. PsnCertType string `json:"psn_cert_type"`
  14708. PsnName string `json:"psn_name"`
  14709. PsnNo string `json:"psn_no"`
  14710. PsnPartAmt float64 `json:"psn_part_amt"`
  14711. PsnType string `json:"psn_type"`
  14712. SetlID string `json:"setl_id"`
  14713. SetlTime string `json:"setl_time"`
  14714. } `json:"setlinfo"`
  14715. Setldetail interface{} `json:"setldetail"`
  14716. } `json:"output"`
  14717. RefmsgTime string `json:"refmsg_time"`
  14718. RespondTime string `json:"respond_time"`
  14719. Signtype interface{} `json:"signtype"`
  14720. WarnMsg interface{} `json:"warn_msg"`
  14721. }
  14722. type ResultEight struct {
  14723. Cainfo string `json:"cainfo"`
  14724. ErrMsg string `json:"err_msg"`
  14725. InfRefmsgid string `json:"inf_refmsgid"`
  14726. Infcode int64 `json:"infcode"`
  14727. Output struct {
  14728. Stmtinfo struct {
  14729. SetlOptins string `json:"setl_optins"`
  14730. StmtRslt string `json:"stmt_rslt"`
  14731. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  14732. } `json:"stmtinfo"`
  14733. } `json:"output"`
  14734. RefmsgTime string `json:"refmsg_time"`
  14735. RespondTime string `json:"respond_time"`
  14736. Signtype interface{} `json:"signtype"`
  14737. WarnMsg interface{} `json:"warn_msg"`
  14738. }
  14739. type ResultEightFor10188 struct {
  14740. Cainfo string `json:"cainfo"`
  14741. ErrMsg string `json:"err_msg"`
  14742. InfRefmsgid string `json:"inf_refmsgid"`
  14743. Infcode string `json:"infcode"`
  14744. Output struct {
  14745. Stmtinfo struct {
  14746. SetlOptins string `json:"setl_optins"`
  14747. StmtRslt string `json:"stmt_rslt"`
  14748. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  14749. } `json:"stmtinfo"`
  14750. } `json:"output"`
  14751. RefmsgTime string `json:"refmsg_time"`
  14752. RespondTime string `json:"respond_time"`
  14753. Signtype interface{} `json:"signtype"`
  14754. WarnMsg interface{} `json:"warn_msg"`
  14755. }
  14756. type ResultNine struct {
  14757. Cainfo string `json:"cainfo"`
  14758. ErrMsg string `json:"err_msg"`
  14759. InfRefmsgid string `json:"inf_refmsgid"`
  14760. Infcode int64 `json:"infcode"`
  14761. Output struct {
  14762. FileQuryNo string `json:"file_qury_no"`
  14763. } `json:"output"`
  14764. RefmsgTime string `json:"refmsg_time"`
  14765. RespondTime string `json:"respond_time"`
  14766. Signtype interface{} `json:"signtype"`
  14767. WarnMsg interface{} `json:"warn_msg"`
  14768. }
  14769. type ResultTen struct {
  14770. Cainfo string `json:"cainfo"`
  14771. ErrMsg string `json:"err_msg"`
  14772. InfRefmsgid string `json:"inf_refmsgid"`
  14773. Infcode int64 `json:"infcode"`
  14774. Output struct {
  14775. Fileinfo struct {
  14776. DldEndtime string `json:"dld_endtime"`
  14777. FileQuryNo string `json:"file_qury_no"`
  14778. Filename string `json:"filename"`
  14779. } `json:"fileinfo"`
  14780. } `json:"output"`
  14781. RefmsgTime string `json:"refmsg_time"`
  14782. RespondTime string `json:"respond_time"`
  14783. Signtype interface{} `json:"signtype"`
  14784. WarnMsg interface{} `json:"warn_msg"`
  14785. }
  14786. type Result5262 struct {
  14787. ErrMsg string `json:"err_msg"`
  14788. InfRefmsgid string `json:"inf_refmsgid"`
  14789. Infcode int64 `json:"infcode"`
  14790. Output struct {
  14791. PageInfo struct {
  14792. Size int `json:"size"`
  14793. RecordCounts int `json:"record_counts"`
  14794. } `json:"page_info"`
  14795. Idetinfo []interface{} `json:"idetinfo"`
  14796. Result []struct {
  14797. SetlID string `json:"setl_id"`
  14798. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  14799. MdtrtID string `json:"mdtrt_id"`
  14800. InitSetlID string `json:"init_setl_id,omitempty"`
  14801. PsnNo string `json:"psn_no"`
  14802. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  14803. PsnName string `json:"psn_name"`
  14804. PsnCertType string `json:"psn_cert_type"`
  14805. Certno string `json:"certno"`
  14806. Gend string `json:"gend,omitempty"`
  14807. Naty string `json:"naty,omitempty"`
  14808. Brdy string `json:"brdy,omitempty"`
  14809. Age float64 `json:"age,omitempty"`
  14810. Insutype string `json:"insutype,omitempty"`
  14811. PsnType string `json:"psn_type"`
  14812. CvlservFlag string `json:"cvlserv_flag"`
  14813. CvlservLv string `json:"cvlserv_lv,omitempty"`
  14814. SpPsnType string `json:"sp_psn_type,omitempty"`
  14815. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  14816. ClctGrde string `json:"clct_grde,omitempty"`
  14817. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  14818. NwbFlag string `json:"nwb_flag,omitempty"`
  14819. InsuAdmdvs string `json:"insu_admdvs"`
  14820. EmpNo string `json:"emp_no,omitempty"`
  14821. EmpName string `json:"emp_name,omitempty"`
  14822. EmpType string `json:"emp_type,omitempty"`
  14823. EconType string `json:"econ_type,omitempty"`
  14824. AfilIndu string `json:"afil_indu,omitempty"`
  14825. AfilRlts string `json:"afil_rlts,omitempty"`
  14826. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  14827. PayLoc string `json:"pay_loc,omitempty"`
  14828. FixmedinsCode string `json:"fixmedins_code"`
  14829. FixmedinsName string `json:"fixmedins_name"`
  14830. HospLv string `json:"hosp_lv,omitempty"`
  14831. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  14832. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  14833. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  14834. Begndate string `json:"begndate"`
  14835. Enddate string `json:"enddate"`
  14836. SetlTime string `json:"setl_time"`
  14837. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  14838. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  14839. MedType string `json:"med_type"`
  14840. SetlType string `json:"setl_type,omitempty"`
  14841. ClrType string `json:"clr_type,omitempty"`
  14842. ClrWay string `json:"clr_way,omitempty"`
  14843. PsnSetlway string `json:"psn_setlway,omitempty"`
  14844. ClrOptins string `json:"clr_optins,omitempty"`
  14845. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  14846. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  14847. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  14848. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  14849. InscpAmt float64 `json:"inscp_amt,omitempty"`
  14850. DedcStd float64 `json:"dedc_std,omitempty"`
  14851. CrtDedc float64 `json:"crt_dedc,omitempty"`
  14852. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  14853. HifpPay float64 `json:"hifp_pay,omitempty"`
  14854. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  14855. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  14856. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  14857. HifesPay float64 `json:"hifes_pay,omitempty"`
  14858. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  14859. HifobPay float64 `json:"hifob_pay,omitempty"`
  14860. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  14861. MafPay float64 `json:"maf_pay,omitempty"`
  14862. OthfundPay float64 `json:"othfund_pay,omitempty"`
  14863. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  14864. PsnPay float64 `json:"psn_pay,omitempty"`
  14865. AcctPay float64 `json:"acct_pay,omitempty"`
  14866. CashPayamt float64 `json:"cash_payamt,omitempty"`
  14867. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  14868. Balc float64 `json:"balc,omitempty"`
  14869. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  14870. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  14871. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  14872. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  14873. Year string `json:"year,omitempty"`
  14874. DiseNo string `json:"dise_no,omitempty"`
  14875. DiseName string `json:"dise_name,omitempty"`
  14876. Invono string `json:"invono,omitempty"`
  14877. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  14878. ValiFlag string `json:"vali_flag,omitempty"`
  14879. Memo string `json:"memo,omitempty"`
  14880. Rid string `json:"rid"`
  14881. UpdtTime string `json:"updt_time,omitempty"`
  14882. CrterID string `json:"crter_id,omitempty"`
  14883. CrterName string `json:"crter_name,omitempty"`
  14884. CrteTime string `json:"crte_time,omitempty"`
  14885. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  14886. OpterID string `json:"opter_id,omitempty"`
  14887. OpterName string `json:"opter_name,omitempty"`
  14888. OptTime string `json:"opt_time,omitempty"`
  14889. OptinsNo string `json:"optins_no,omitempty"`
  14890. PoolareaNo string `json:"poolarea_no,omitempty"`
  14891. } `json:"result"`
  14892. } `json:"output"`
  14893. RefmsgTime string `json:"refmsg_time"`
  14894. RespondTime string `json:"respond_time"`
  14895. Signtype interface{} `json:"signtype"`
  14896. WarnInfo interface{} `json:"warn_info"`
  14897. }
  14898. type Result5267 struct {
  14899. ErrMsg string `json:"err_msg"`
  14900. InfRefmsgid string `json:"inf_refmsgid"`
  14901. Infcode int64 `json:"infcode"`
  14902. Output struct {
  14903. PageInfo struct {
  14904. Size int `json:"size"`
  14905. RecordCounts int `json:"record_counts"`
  14906. } `json:"pageinfo"`
  14907. Result []struct {
  14908. SetlID string `json:"setl_id"`
  14909. ClrOptins string `json:"clr_optins"`
  14910. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  14911. MdtrtID string `json:"mdtrt_id"`
  14912. InitSetlID string `json:"init_setl_id,omitempty"`
  14913. PsnNo string `json:"psn_no"`
  14914. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  14915. PsnName string `json:"psn_name"`
  14916. PsnCertType string `json:"psn_cert_type"`
  14917. Certno string `json:"certno"`
  14918. Gend string `json:"gend,omitempty"`
  14919. Naty string `json:"naty,omitempty"`
  14920. Brdy string `json:"brdy,omitempty"`
  14921. Age float64 `json:"age,omitempty"`
  14922. Insutype string `json:"insutype,omitempty"`
  14923. PsnType string `json:"psn_type"`
  14924. CvlservFlag string `json:"cvlserv_flag"`
  14925. CvlservLv string `json:"cvlserv_lv,omitempty"`
  14926. SpPsnType string `json:"sp_psn_type,omitempty"`
  14927. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  14928. ClctGrde string `json:"clct_grde,omitempty"`
  14929. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  14930. NwbFlag string `json:"nwb_flag,omitempty"`
  14931. InsuAdmdvs string `json:"insu_admdvs"`
  14932. EmpNo string `json:"emp_no,omitempty"`
  14933. EmpName string `json:"emp_name,omitempty"`
  14934. EmpType string `json:"emp_type,omitempty"`
  14935. EconType string `json:"econ_type,omitempty"`
  14936. AfilIndu string `json:"afil_indu,omitempty"`
  14937. AfilRlts string `json:"afil_rlts,omitempty"`
  14938. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  14939. PayLoc string `json:"pay_loc,omitempty"`
  14940. FixmedinsCode string `json:"fixmedins_code"`
  14941. FixmedinsName string `json:"fixmedins_name"`
  14942. HospLv string `json:"hosp_lv,omitempty"`
  14943. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  14944. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  14945. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  14946. Begndate string `json:"begndate,omitempty"`
  14947. Enddate string `json:"enddate,omitempty"`
  14948. SetlTime string `json:"setl_time,omitempty"`
  14949. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  14950. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  14951. MedType string `json:"med_type"`
  14952. SetlType string `json:"setl_type,omitempty"`
  14953. ClrType string `json:"clr_type,omitempty"`
  14954. ClrWay string `json:"clr_way,omitempty"`
  14955. PsnSetlway string `json:"psn_setlway,omitempty"`
  14956. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  14957. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  14958. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  14959. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  14960. InscpAmt float64 `json:"inscp_amt,omitempty"`
  14961. DedcStd float64 `json:"dedc_std,omitempty"`
  14962. CrtDedc float64 `json:"crt_dedc,omitempty"`
  14963. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  14964. HifpPay float64 `json:"hifp_pay,omitempty"`
  14965. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  14966. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  14967. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  14968. HifesPay float64 `json:"hifes_pay,omitempty"`
  14969. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  14970. HifobPay float64 `json:"hifob_pay,omitempty"`
  14971. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  14972. MafPay float64 `json:"maf_pay,omitempty"`
  14973. OthfundPay float64 `json:"othfund_pay,omitempty"`
  14974. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  14975. PsnPay float64 `json:"psn_pay,omitempty"`
  14976. AcctPay float64 `json:"acct_pay,omitempty"`
  14977. CashPayamt float64 `json:"cash_payamt,omitempty"`
  14978. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  14979. Balc float64 `json:"balc,omitempty"`
  14980. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  14981. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  14982. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  14983. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  14984. Year string `json:"year,omitempty"`
  14985. DiseNo string `json:"dise_no,omitempty"`
  14986. DiseName string `json:"dise_name,omitempty"`
  14987. Invono string `json:"invono,omitempty"`
  14988. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  14989. Memo string `json:"memo,omitempty"`
  14990. UpdtTime string `json:"updt_time,omitempty"`
  14991. OpterID string `json:"opter_id,omitempty"`
  14992. OpterName string `json:"opter_name,omitempty"`
  14993. OptTime string `json:"opt_time,omitempty"`
  14994. OptinsNo string `json:"optins_no,omitempty"`
  14995. PoolareaNo string `json:"poolarea_no,omitempty"`
  14996. } `json:"result"`
  14997. } `json:"output"`
  14998. RefmsgTime string `json:"refmsg_time"`
  14999. RespondTime string `json:"respond_time"`
  15000. Signtype interface{} `json:"signtype"`
  15001. WarnInfo interface{} `json:"warn_info"`
  15002. }
  15003. // type Autogenerated struct {
  15004. // Output struct {
  15005. // Setlinfo struct {
  15006. // SetlTime string `json:"setl_time"`
  15007. // CvlservPay float64 `json:"cvlserv_pay"`
  15008. // Year string `json:"year"`
  15009. // MedType string `json:"med_type"`
  15010. // PsnPay float64 `json:"psn_pay"`
  15011. // OpterID string `json:"opter_id"`
  15012. // Begndate string `json:"begndate"`
  15013. // FlxempeFlag string `json:"flxempe_flag"`
  15014. // HifmiPay float64 `json:"hifmi_pay"`
  15015. // PsnNo string `json:"psn_no"`
  15016. // ActPayDedc float64 `json:"act_pay_dedc"`
  15017. // MedinsSetlID interface{} `json:"medins_setl_id"`
  15018. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  15019. // ClrWay string `json:"clr_way"`
  15020. // OthPay float64 `json:"oth_pay"`
  15021. // Gend string `json:"gend"`
  15022. // MdtrtID string `json:"mdtrt_id"`
  15023. // AcctPay float64 `json:"acct_pay"`
  15024. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  15025. // Insutype string `json:"insutype"`
  15026. // Invono interface{} `json:"invono"`
  15027. // Enddate string `json:"enddate"`
  15028. // CashPayamt float64 `json:"cash_payamt"`
  15029. // PsnType string `json:"psn_type"`
  15030. // FixmedinsName string `json:"fixmedins_name"`
  15031. // HifpPay float64 `json:"hifp_pay"`
  15032. // NewFlag interface{} `json:"new_flag"`
  15033. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15034. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  15035. // PayLoc string `json:"pay_loc"`
  15036. // ClrType string `json:"clr_type"`
  15037. // RefdSetlFlag string `json:"refd_setl_flag"`
  15038. // CvlservFlag string `json:"cvlserv_flag"`
  15039. // EmpName string `json:"emp_name"`
  15040. // Brdy string `json:"brdy"`
  15041. // Naty string `json:"naty"`
  15042. // Certno string `json:"certno"`
  15043. // DiseCode string `json:"dise_code"`
  15044. // FixmedinsCode string `json:"fixmedins_code"`
  15045. // DedcHospLv string `json:"dedc_hosp_lv"`
  15046. // OpterName string `json:"opter_name"`
  15047. // Balc float64 `json:"balc"`
  15048. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  15049. // PsnCertType string `json:"psn_cert_type"`
  15050. // HifobPay float64 `json:"hifob_pay"`
  15051. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  15052. // HifesPay float64 `json:"hifes_pay"`
  15053. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15054. // OptTime string `json:"opt_time"`
  15055. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15056. // SetlID string `json:"setl_id"`
  15057. // MafPay float64 `json:"maf_pay"`
  15058. // PsnName string `json:"psn_name"`
  15059. // InsuOptins interface{} `json:"insu_optins"`
  15060. // PrefFundPay interface{} `json:"pref_fund_pay"`
  15061. // ClrOptins string `json:"clr_optins"`
  15062. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15063. // DiseName string `json:"dise_name"`
  15064. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  15065. // Age float64 `json:"age"`
  15066. // DtrtCertType string `json:"dtrt_cert_type"`
  15067. // HospLv string `json:"hosp_lv"`
  15068. // } `json:"setlinfo"`
  15069. // Setldetail []struct {
  15070. // FundPayType string `json:"fund_pay_type"`
  15071. // FundPayamt float64 `json:"fund_payamt"`
  15072. // SetlProcInfo interface{} `json:"setl_proc_info"`
  15073. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  15074. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  15075. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  15076. // PrefFundPay interface{} `json:"pref_fund_pay"`
  15077. // } `json:"setldetail"`
  15078. // } `json:"output"`
  15079. // Infcode int `json:"infcode"`
  15080. // WarnMsg interface{} `json:"warn_msg"`
  15081. // Cainfo interface{} `json:"cainfo"`
  15082. // ErrMsg interface{} `json:"err_msg"`
  15083. // RefmsgTime string `json:"refmsg_time"`
  15084. // Signtype interface{} `json:"signtype"`
  15085. // RespondTime string `json:"respond_time"`
  15086. // InfRefmsgid string `json:"inf_refmsgid"`
  15087. // }
  15088. type Result002 struct {
  15089. Cainfo interface{} `json:"cainfo"`
  15090. ErrMsg string `json:"err_msg"`
  15091. InfRefmsgid string `json:"inf_refmsgid"`
  15092. Infcode int64 `json:"infcode"`
  15093. Output struct {
  15094. RxFile string `json:"rx_file"`
  15095. SignDigest string `json:"sign_digest"`
  15096. SignCertSn string `json:"sign_cert_sn"`
  15097. SignCertDn string `json:"sign_cert_dn"`
  15098. } `json:"output"`
  15099. RefmsgTime string `json:"refmsg_time"`
  15100. RespondTime string `json:"respond_time"`
  15101. Signtype interface{} `json:"signtype"`
  15102. WarnMsg interface{} `json:"warn_msg"`
  15103. }
  15104. type Result003 struct {
  15105. Cainfo interface{} `json:"cainfo"`
  15106. ErrMsg string `json:"err_msg"`
  15107. InfRefmsgid string `json:"inf_refmsgid"`
  15108. Infcode int64 `json:"infcode"`
  15109. Output struct {
  15110. HiRxno string `json:"hi_rxno"`
  15111. RxStasCodg string `json:"rx_stas_codg"`
  15112. RxStasName string `json:"rx_stas_name"`
  15113. } `json:"output"`
  15114. RefmsgTime string `json:"refmsg_time"`
  15115. RespondTime string `json:"respond_time"`
  15116. Signtype interface{} `json:"signtype"`
  15117. WarnMsg interface{} `json:"warn_msg"`
  15118. }
  15119. type ResultEleven struct {
  15120. Cainfo string `json:"cainfo"`
  15121. ErrMsg string `json:"err_msg"`
  15122. InfRefmsgid string `json:"inf_refmsgid"`
  15123. Infcode int64 `json:"infcode"`
  15124. Output struct {
  15125. Setlinfo struct {
  15126. SetlTime string `json:"setl_time"`
  15127. CvlservPay float64 `json:"cvlserv_pay"`
  15128. Year string `json:"year"`
  15129. MedType string `json:"med_type"`
  15130. PsnPay float64 `json:"psn_pay"`
  15131. OpterID string `json:"opter_id"`
  15132. Begndate string `json:"begndate"`
  15133. FlxempeFlag string `json:"flxempe_flag"`
  15134. HifmiPay float64 `json:"hifmi_pay"`
  15135. PsnNo string `json:"psn_no"`
  15136. ActPayDedc float64 `json:"act_pay_dedc"`
  15137. MedinsSetlID interface{} `json:"medins_setl_id"`
  15138. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  15139. ClrWay string `json:"clr_way"`
  15140. OthPay float64 `json:"oth_pay"`
  15141. Gend string `json:"gend"`
  15142. MdtrtID string `json:"mdtrt_id"`
  15143. AcctPay float64 `json:"acct_pay"`
  15144. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15145. Insutype string `json:"insutype"`
  15146. Invono interface{} `json:"invono"`
  15147. Enddate string `json:"enddate"`
  15148. CashPayamt float64 `json:"cash_payamt"`
  15149. PsnType string `json:"psn_type"`
  15150. FixmedinsName string `json:"fixmedins_name"`
  15151. HifpPay float64 `json:"hifp_pay"`
  15152. NewFlag interface{} `json:"new_flag"`
  15153. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15154. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15155. PayLoc string `json:"pay_loc"`
  15156. ClrType string `json:"clr_type"`
  15157. RefdSetlFlag string `json:"refd_setl_flag"`
  15158. CvlservFlag string `json:"cvlserv_flag"`
  15159. EmpName string `json:"emp_name"`
  15160. Brdy string `json:"brdy"`
  15161. Naty string `json:"naty"`
  15162. Certno string `json:"certno"`
  15163. DiseCode string `json:"dise_code"`
  15164. FixmedinsCode string `json:"fixmedins_code"`
  15165. DedcHospLv string `json:"dedc_hosp_lv"`
  15166. OpterName string `json:"opter_name"`
  15167. Balc float64 `json:"balc"`
  15168. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  15169. PsnCertType string `json:"psn_cert_type"`
  15170. HifobPay float64 `json:"hifob_pay"`
  15171. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15172. HifesPay float64 `json:"hifes_pay"`
  15173. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15174. OptTime string `json:"opt_time"`
  15175. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15176. SetlID string `json:"setl_id"`
  15177. MafPay float64 `json:"maf_pay"`
  15178. PsnName string `json:"psn_name"`
  15179. InsuOptins interface{} `json:"insu_optins"`
  15180. PrefFundPay interface{} `json:"pref_fund_pay"`
  15181. ClrOptins string `json:"clr_optins"`
  15182. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15183. DiseName string `json:"dise_name"`
  15184. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  15185. Age float64 `json:"age"`
  15186. DtrtCertType string `json:"dtrt_cert_type"`
  15187. HospLv string `json:"hosp_lv"`
  15188. PsnCashPay float64 `json:"psn_cash_pay"`
  15189. } `json:"setlinfo"`
  15190. } `json:"output"`
  15191. RefmsgTime string `json:"refmsg_time"`
  15192. RespondTime string `json:"respond_time"`
  15193. Signtype interface{} `json:"signtype"`
  15194. WarnMsg interface{} `json:"warn_msg"`
  15195. }
  15196. type ResultElevenah struct {
  15197. Cainfo string `json:"cainfo"`
  15198. ErrMsg string `json:"err_msg"`
  15199. InfRefmsgid string `json:"inf_refmsgid"`
  15200. Infcode int64 `json:"infcode"`
  15201. Output struct {
  15202. Setlinfo struct {
  15203. SetlTime int64 `json:"setl_time"`
  15204. CvlservPay float64 `json:"cvlserv_pay"`
  15205. Year string `json:"year"`
  15206. MedType string `json:"med_type"`
  15207. PsnPay float64 `json:"psn_pay"`
  15208. OpterID string `json:"opter_id"`
  15209. Begndate int64 `json:"begndate"`
  15210. FlxempeFlag string `json:"flxempe_flag"`
  15211. HifmiPay float64 `json:"hifmi_pay"`
  15212. PsnNo string `json:"psn_no"`
  15213. ActPayDedc float64 `json:"act_pay_dedc"`
  15214. MedinsSetlID interface{} `json:"medins_setl_id"`
  15215. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  15216. ClrWay string `json:"clr_way"`
  15217. OthPay float64 `json:"oth_pay"`
  15218. Gend string `json:"gend"`
  15219. MdtrtID string `json:"mdtrt_id"`
  15220. AcctPay float64 `json:"acct_pay"`
  15221. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15222. Insutype string `json:"insutype"`
  15223. Invono interface{} `json:"invono"`
  15224. Enddate int64 `json:"enddate"`
  15225. CashPayamt float64 `json:"cash_payamt"`
  15226. PsnType string `json:"psn_type"`
  15227. FixmedinsName string `json:"fixmedins_name"`
  15228. HifpPay float64 `json:"hifp_pay"`
  15229. NewFlag interface{} `json:"new_flag"`
  15230. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15231. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15232. PayLoc string `json:"pay_loc"`
  15233. ClrType string `json:"clr_type"`
  15234. RefdSetlFlag string `json:"refd_setl_flag"`
  15235. CvlservFlag string `json:"cvlserv_flag"`
  15236. EmpName string `json:"emp_name"`
  15237. Brdy int64 `json:"brdy"`
  15238. Naty string `json:"naty"`
  15239. Certno string `json:"certno"`
  15240. DiseCode string `json:"dise_code"`
  15241. FixmedinsCode string `json:"fixmedins_code"`
  15242. DedcHospLv string `json:"dedc_hosp_lv"`
  15243. OpterName string `json:"opter_name"`
  15244. Balc float64 `json:"balc"`
  15245. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  15246. PsnCertType string `json:"psn_cert_type"`
  15247. HifobPay float64 `json:"hifob_pay"`
  15248. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15249. HifesPay float64 `json:"hifes_pay"`
  15250. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15251. OptTime int64 `json:"opt_time"`
  15252. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15253. SetlID string `json:"setl_id"`
  15254. MafPay float64 `json:"maf_pay"`
  15255. PsnName string `json:"psn_name"`
  15256. InsuOptins interface{} `json:"insu_optins"`
  15257. PrefFundPay interface{} `json:"pref_fund_pay"`
  15258. ClrOptins string `json:"clr_optins"`
  15259. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15260. DiseName string `json:"dise_name"`
  15261. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  15262. Age float64 `json:"age"`
  15263. DtrtCertType string `json:"dtrt_cert_type"`
  15264. HospLv string `json:"hosp_lv"`
  15265. PsnCashPay float64 `json:"psn_cash_pay"`
  15266. } `json:"setlinfo"`
  15267. } `json:"output"`
  15268. RefmsgTime string `json:"refmsg_time"`
  15269. RespondTime string `json:"respond_time"`
  15270. Signtype interface{} `json:"signtype"`
  15271. WarnMsg interface{} `json:"warn_msg"`
  15272. }
  15273. type ResultEleven10265 struct {
  15274. Cainfo string `json:"cainfo"`
  15275. ErrMsg string `json:"err_msg"`
  15276. InfRefmsgid string `json:"inf_refmsgid"`
  15277. Infcode string `json:"infcode"`
  15278. Output struct {
  15279. Setlinfo struct {
  15280. SetlTime string `json:"setl_time"`
  15281. CvlservPay float64 `json:"cvlserv_pay"`
  15282. Year string `json:"year"`
  15283. MedType string `json:"med_type"`
  15284. PsnPay float64 `json:"psn_pay"`
  15285. OpterID string `json:"opter_id"`
  15286. Begndate string `json:"begndate"`
  15287. FlxempeFlag string `json:"flxempe_flag"`
  15288. HifmiPay float64 `json:"hifmi_pay"`
  15289. PsnNo string `json:"psn_no"`
  15290. ActPayDedc float64 `json:"act_pay_dedc"`
  15291. MedinsSetlID interface{} `json:"medins_setl_id"`
  15292. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  15293. ClrWay string `json:"clr_way"`
  15294. OthPay float64 `json:"oth_pay"`
  15295. Gend string `json:"gend"`
  15296. MdtrtID string `json:"mdtrt_id"`
  15297. AcctPay float64 `json:"acct_pay"`
  15298. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15299. Insutype string `json:"insutype"`
  15300. Invono interface{} `json:"invono"`
  15301. Enddate string `json:"enddate"`
  15302. CashPayamt float64 `json:"cash_payamt"`
  15303. PsnType string `json:"psn_type"`
  15304. FixmedinsName string `json:"fixmedins_name"`
  15305. HifpPay float64 `json:"hifp_pay"`
  15306. NewFlag interface{} `json:"new_flag"`
  15307. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15308. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15309. PayLoc string `json:"pay_loc"`
  15310. ClrType string `json:"clr_type"`
  15311. RefdSetlFlag string `json:"refd_setl_flag"`
  15312. CvlservFlag string `json:"cvlserv_flag"`
  15313. EmpName string `json:"emp_name"`
  15314. Brdy string `json:"brdy"`
  15315. Naty string `json:"naty"`
  15316. Certno string `json:"certno"`
  15317. DiseCode string `json:"dise_code"`
  15318. FixmedinsCode string `json:"fixmedins_code"`
  15319. DedcHospLv string `json:"dedc_hosp_lv"`
  15320. OpterName string `json:"opter_name"`
  15321. Balc float64 `json:"balc"`
  15322. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  15323. PsnCertType string `json:"psn_cert_type"`
  15324. HifobPay float64 `json:"hifob_pay"`
  15325. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15326. HifesPay float64 `json:"hifes_pay"`
  15327. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15328. OptTime string `json:"opt_time"`
  15329. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15330. SetlID string `json:"setl_id"`
  15331. MafPay float64 `json:"maf_pay"`
  15332. PsnName string `json:"psn_name"`
  15333. InsuOptins interface{} `json:"insu_optins"`
  15334. PrefFundPay interface{} `json:"pref_fund_pay"`
  15335. ClrOptins string `json:"clr_optins"`
  15336. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15337. DiseName string `json:"dise_name"`
  15338. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  15339. Age float64 `json:"age"`
  15340. DtrtCertType string `json:"dtrt_cert_type"`
  15341. HospLv string `json:"hosp_lv"`
  15342. PsnCashPay float64 `json:"psn_cash_pay"`
  15343. } `json:"setlinfo"`
  15344. } `json:"output"`
  15345. RefmsgTime string `json:"refmsg_time"`
  15346. RespondTime string `json:"respond_time"`
  15347. Signtype interface{} `json:"signtype"`
  15348. WarnMsg interface{} `json:"warn_msg"`
  15349. }
  15350. type ResultTwelve struct {
  15351. Cainfo string `json:"cainfo"`
  15352. ErrMsg string `json:"err_msg"`
  15353. InfRefmsgid string `json:"inf_refmsgid"`
  15354. Infcode int64 `json:"infcode"`
  15355. Output struct {
  15356. MdtrtId string `json:"mdtrt_id"`
  15357. ChrgBchno string `json:"chrg_bchno"`
  15358. PsnNo string `json:"psn_no"`
  15359. } `json:"output"`
  15360. RefmsgTime string `json:"refmsg_time"`
  15361. RespondTime string `json:"respond_time"`
  15362. Signtype interface{} `json:"signtype"`
  15363. WarnMsg interface{} `json:"warn_msg"`
  15364. }
  15365. type ResultThirteen struct {
  15366. ErrMsg string `json:"err_msg"`
  15367. InfRefmsgid string `json:"inf_refmsgid"`
  15368. Infcode int64 `json:"infcode"`
  15369. Output struct {
  15370. Result struct {
  15371. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  15372. } `json:"result"`
  15373. } `json:"output"`
  15374. RefmsgTime string `json:"refmsg_time"`
  15375. RespondTime string `json:"respond_time"`
  15376. Signtype interface{} `json:"signtype"`
  15377. WarnInfo interface{} `json:"warn_info"`
  15378. }
  15379. type ResultThirteen10265 struct {
  15380. ErrMsg string `json:"err_msg"`
  15381. InfRefmsgid string `json:"inf_refmsgid"`
  15382. Infcode string `json:"infcode"`
  15383. Output struct {
  15384. Result struct {
  15385. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  15386. } `json:"result"`
  15387. } `json:"output"`
  15388. RefmsgTime string `json:"refmsg_time"`
  15389. RespondTime string `json:"respond_time"`
  15390. Signtype interface{} `json:"signtype"`
  15391. WarnInfo interface{} `json:"warn_info"`
  15392. }
  15393. type ResultFourteen struct {
  15394. ErrMsg string `json:"err_msg"`
  15395. InfRefmsgid string `json:"inf_refmsgid"`
  15396. Infcode int64 `json:"infcode"`
  15397. Output struct {
  15398. } `json:"output"`
  15399. RefmsgTime string `json:"refmsg_time"`
  15400. RespondTime string `json:"respond_time"`
  15401. Signtype interface{} `json:"signtype"`
  15402. WarnInfo interface{} `json:"warn_info"`
  15403. }
  15404. type ResultCFYLJG001 struct {
  15405. ErrMsg string `json:"err_msg"`
  15406. InfRefmsgid string `json:"inf_refmsgid"`
  15407. Infcode int64 `json:"infcode"`
  15408. Output struct {
  15409. RxTraceCode string `json:"rx_trace_code"`
  15410. HiRxno string `json:"hi_rxno"`
  15411. } `json:"output"`
  15412. RefmsgTime string `json:"refmsg_time"`
  15413. RespondTime string `json:"respond_time"`
  15414. Signtype interface{} `json:"signtype"`
  15415. WarnInfo interface{} `json:"warn_info"`
  15416. }
  15417. type ResultCFYLJG007 struct {
  15418. ErrMsg string `json:"err_msg"`
  15419. InfRefmsgid string `json:"inf_refmsgid"`
  15420. Infcode int64 `json:"infcode"`
  15421. Output struct {
  15422. } `json:"output"`
  15423. RefmsgTime string `json:"refmsg_time"`
  15424. RespondTime string `json:"respond_time"`
  15425. Signtype interface{} `json:"signtype"`
  15426. WarnInfo interface{} `json:"warn_info"`
  15427. }
  15428. type ResultCFYLJG002 struct {
  15429. ErrMsg string `json:"err_msg"`
  15430. InfRefmsgid string `json:"inf_refmsgid"`
  15431. Infcode int64 `json:"infcode"`
  15432. Output struct {
  15433. RxFile string `json:"rx_file"`
  15434. SignDigest string `json:"sign_digest"`
  15435. SignCertSn string `json:"sign_cert_sn"`
  15436. SignCertDn string `json:"sign_cert_dn"`
  15437. } `json:"output"`
  15438. RefmsgTime string `json:"refmsg_time"`
  15439. RespondTime string `json:"respond_time"`
  15440. Signtype interface{} `json:"signtype"`
  15441. WarnInfo interface{} `json:"warn_info"`
  15442. }
  15443. type ResultCFYLJG003 struct {
  15444. ErrMsg string `json:"err_msg"`
  15445. InfRefmsgid string `json:"inf_refmsgid"`
  15446. Infcode int64 `json:"infcode"`
  15447. Output struct {
  15448. HiRxno string `json:"hi_rxno"`
  15449. RxStasCodg string `json:"rx_stas_codg"`
  15450. RxStasName string `json:"rx_stas_name"`
  15451. } `json:"output"`
  15452. RefmsgTime string `json:"refmsg_time"`
  15453. RespondTime string `json:"respond_time"`
  15454. Signtype interface{} `json:"signtype"`
  15455. WarnInfo interface{} `json:"warn_info"`
  15456. }
  15457. type ResultCFYLJG004 struct {
  15458. ErrMsg string `json:"err_msg"`
  15459. InfRefmsgid string `json:"inf_refmsgid"`
  15460. Infcode int64 `json:"infcode"`
  15461. Output struct {
  15462. HiRxno string `json:"hi_rxno"`
  15463. RxStasCodg string `json:"rx_stas_codg"`
  15464. RxStasName string `json:"rx_stas_name"`
  15465. } `json:"output"`
  15466. RefmsgTime string `json:"refmsg_time"`
  15467. RespondTime string `json:"respond_time"`
  15468. Signtype interface{} `json:"signtype"`
  15469. WarnInfo interface{} `json:"warn_info"`
  15470. }
  15471. type ResultCFYLJG005 struct {
  15472. ErrMsg string `json:"err_msg"`
  15473. InfRefmsgid string `json:"inf_refmsgid"`
  15474. Infcode int64 `json:"infcode"`
  15475. Output struct {
  15476. HiRxNo string `json:"hi_rxno"`
  15477. FixMedinsCode string `json:"fixmedins_code"`
  15478. FixMedinsName string `json:"fixmedins_name"`
  15479. RxStasCodg string `json:"rx_stas_codg"`
  15480. RxStasName string `json:"rx_stas_name"`
  15481. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  15482. RxUserdStasName string `json:"rx_userd_stas_name"`
  15483. PrscTime string `json:"prsc_time"`
  15484. RxDrugCnt float64 `json:"rx_drug_cnt"`
  15485. RxUsedWayCodg string `json:"rx_used_way_codg"`
  15486. RxUsedWayName string `json:"rx_used_way_name"`
  15487. RxFrquCodg string `json:"rx_frqu_codg"`
  15488. RxFrquName string `json:"rx_frqu_name"`
  15489. RxDosunt string `json:"rx_dosunt"`
  15490. RxDoscnt float64 `json:"rx_doscnt"`
  15491. RxDrordDscr string `json:"rx_drord_dscr"`
  15492. ValiDays int64 `json:"vali_days"`
  15493. ValiEndTime string `json:"vali_end_time"`
  15494. ReptFlag string `json:"rept_flag"`
  15495. MaxReptCnt int64 `json:"max_rept_cnt"`
  15496. ReptdCnt int64 `json:"reptd_cnt"`
  15497. MinInrvDays int64 `json:"min_inrv_days"`
  15498. RxTypeCode string `json:"rx_type_code"`
  15499. RxTypeName string `json:"rx_type_name"`
  15500. LongRxFlag string `json:"long_rx_flag"`
  15501. RxDetlList []struct {
  15502. MedListCodg string `json:"med_list_codg"`
  15503. MedinsListCodg string `json:"medins_list_codg"`
  15504. HospPrepFlag string `json:"hosp_prep_flag"`
  15505. RxItemTypeCode string `json:"rx_item_type_code"`
  15506. RxItemTypeName string `json:"rx_item_type_name"`
  15507. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  15508. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  15509. TcmHerbFoote string `json:"tcmherb_foote"`
  15510. MednTypeCode string `json:"medn_type_code"`
  15511. MednTypeName string `json:"medn_type_name"`
  15512. MainMedcFlag string `json:"main_medc_flag"`
  15513. UrgtFlag string `json:"urgt_flag"`
  15514. BasMednFlag string `json:"bas_medn_flag"`
  15515. ImpDrugFlag string `json:"imp_drug_flag"`
  15516. ProdBarc string `json:"prod_barc"`
  15517. DrugProdname string `json:"drug_prodname"`
  15518. GennameCodg string `json:"genname_codg"`
  15519. DrugGenname string `json:"drug_genname"`
  15520. DrugDosform string `json:"drug_dosform"`
  15521. DrugSpec string `json:"drug_spec"`
  15522. PrdrName string `json:"prdr_name"`
  15523. MedcWayCodg string `json:"medc_way_codg"`
  15524. MedcWayDscr string `json:"medc_way_dscr"`
  15525. MedcBegntime string `json:"medc_begntime"`
  15526. MedcEndtime string `json:"medc_endtime"`
  15527. MedcDays float64 `json:"medc_days"`
  15528. DrugPric float64 `json:"drug_pric"`
  15529. DrugSumamt float64 `json:"drug_sumamt"`
  15530. DrugCnt float64 `json:"drug_cnt"`
  15531. DrugDosunt string `json:"drug_dosunt"`
  15532. SinDoscnt float64 `json:"sin_doscnt"`
  15533. SinDosunt string `json:"sin_dosunt"`
  15534. UsedFrquCodg string `json:"used_frqu_codg"`
  15535. UsedFrquName string `json:"used_frqu_name"`
  15536. DrugTotlcnt float64 `json:"drug_totlcnt"`
  15537. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  15538. DiseCodg string `json:"dise_codg"`
  15539. HospApprFlag string `json:"hosp_appr_flag"`
  15540. } `json:"rx_detl_list"`
  15541. RxOtpinfo struct {
  15542. MedType string `json:"med_type"`
  15543. IptOtpNo string `json:"ipt_otp_no"`
  15544. OtpIptFlag string `json:"otp_ipt_flag"`
  15545. PatnName string `json:"patn_name"`
  15546. PatnAge float64 `json:"patn_age"`
  15547. PatnHgt float64 `json:"patn_hgt"`
  15548. PatnWt float64 `json:"patn_wt"`
  15549. Gend string `json:"gend"`
  15550. GesoVal float64 `json:"geso_val"`
  15551. NwbFlag string `json:"nwb_flag"`
  15552. NwbAge string `json:"nwb_age"`
  15553. SuckPrdFlag string `json:"suck_prd_flag"`
  15554. AlgsHis string `json:"algs_his"`
  15555. Insutype string `json:"insutype"`
  15556. PrscDeptName string `json:"prsc_dept_name"`
  15557. PrscDrName string `json:"prsc_dr_name"`
  15558. PharName string `json:"phar_name"`
  15559. PharChkTime string `json:"phar_chk_time"`
  15560. MdtrtTime string `json:"mdtrt_time"`
  15561. DiseCodg string `json:"dise_codg"`
  15562. DiseName string `json:"dise_name"`
  15563. SpDiseFlag string `json:"sp_dise_flag"`
  15564. MaindiagCode string `json:"maindiag_code"`
  15565. MaindiagName string `json:"maindiag_name"`
  15566. DiseCondDscr string `json:"dise_cond_dscr"`
  15567. FstdiagFlag string `json:"fstdiag_flag"`
  15568. } `json:"rx_otpinfo"`
  15569. RxDiseList []struct {
  15570. DiagType string `json:"diag_type"`
  15571. MaindiagFlag string `json:"maindiag_flag"`
  15572. DiagSrtNo string `json:"diag_srt_no"`
  15573. DiagCode string `json:"diag_code"`
  15574. DiagName string `json:"diag_name"`
  15575. DiagDept string `json:"diag_dept"`
  15576. DiagDrNo string `json:"diag_dr_no"`
  15577. DiagDrName string `json:"diag_dr_name"`
  15578. DiagTime string `json:"diag_time"`
  15579. TcmDiseCode string `json:"tcm_dise_code"`
  15580. TcmDiseName string `json:"tcm_dise_name"`
  15581. TcmSympCode string `json:"tcmsymp_code"`
  15582. TcmSymp string `json:"tcmsymp"`
  15583. } `json:"rx_dise_list"`
  15584. } `json:"output"`
  15585. RefmsgTime string `json:"refmsg_time"`
  15586. RespondTime string `json:"respond_time"`
  15587. Signtype interface{} `json:"signtype"`
  15588. WarnInfo interface{} `json:"warn_info"`
  15589. }
  15590. type ResultCFYLJG006 struct {
  15591. ErrMsg string `json:"err_msg"`
  15592. InfRefmsgid string `json:"inf_refmsgid"`
  15593. Infcode int64 `json:"infcode"`
  15594. Output struct {
  15595. HiRxNo string `json:"hi_rxno"`
  15596. PharCode string `json:"phar_code"`
  15597. PharName string `json:"phar_name"`
  15598. RxChkOpnn string `json:"rx_chk_opnn"`
  15599. RxChkTime string `json:"rx_chk_time"`
  15600. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  15601. RxChkStasName string `json:"rx_chk_stas_name"`
  15602. RxStasCodg string `json:"rx_stas_codg"`
  15603. RxStasName string `json:"rx_stas_name"`
  15604. } `json:"output"`
  15605. RefmsgTime string `json:"refmsg_time"`
  15606. RespondTime string `json:"respond_time"`
  15607. Signtype interface{} `json:"signtype"`
  15608. WarnInfo interface{} `json:"warn_info"`
  15609. }
  15610. type ResultFourteen10265 struct {
  15611. ErrMsg string `json:"err_msg"`
  15612. InfRefmsgid string `json:"inf_refmsgid"`
  15613. Infcode string `json:"infcode"`
  15614. Output struct {
  15615. } `json:"output"`
  15616. RefmsgTime string `json:"refmsg_time"`
  15617. RespondTime string `json:"respond_time"`
  15618. Signtype interface{} `json:"signtype"`
  15619. WarnInfo interface{} `json:"warn_info"`
  15620. }
  15621. type ResultSixteen struct {
  15622. Cainfo string `json:"cainfo"`
  15623. ErrMsg string `json:"err_msg"`
  15624. InfRefmsgid string `json:"inf_refmsgid"`
  15625. Infcode int64 `json:"infcode"`
  15626. Output struct {
  15627. Setlinfo struct {
  15628. MdtrtID string `json:"mdtrt_id"`
  15629. SetlID string `json:"setl_id"`
  15630. ClrOptins string `json:"clr_optins"`
  15631. SetlTime string `json:"setl_time"`
  15632. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15633. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15634. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15635. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15636. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15637. ActPayDedc float64 `json:"act_pay_dedc"`
  15638. HifpPay float64 `json:"hifp_pay"`
  15639. PoolPropSe float64 `json:"pool_prop_selfpay"`
  15640. Lfpay float64 `json:"selfpay"`
  15641. CvlservPay float64 `json:"cvlserv_pay"`
  15642. HifesPay float64 `json:"hifes_pay"`
  15643. HifmiPay float64 `json:"hifmi_pay"`
  15644. HifobPay float64 `json:"hifob_pay"`
  15645. MafPay float64 `json:"maf_pay"`
  15646. OthPay float64 `json:"oth_pay"`
  15647. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15648. PsnPartAmt float64 `json:"psn_part_amt"`
  15649. AcctPay float64 `json:"acct_pay"`
  15650. Balc float64 `json:"balc"`
  15651. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15652. HospPartAmt float64 `json:"hosp_part_amt"`
  15653. MedinsSetlID string `json:"medins_setl_id"`
  15654. PdnCashPay string `json:"pdn_cash_pay"`
  15655. } `json:"setlinfo"`
  15656. } `json:"output"`
  15657. RefmsgTime string `json:"refmsg_time"`
  15658. RespondTime string `json:"respond_time"`
  15659. Signtype interface{} `json:"signtype"`
  15660. WarnMsg interface{} `json:"warn_msg"`
  15661. }
  15662. type ResultSixteen10265 struct {
  15663. Cainfo string `json:"cainfo"`
  15664. ErrMsg string `json:"err_msg"`
  15665. InfRefmsgid string `json:"inf_refmsgid"`
  15666. Infcode string `json:"infcode"`
  15667. Output struct {
  15668. Setlinfo struct {
  15669. MdtrtID string `json:"mdtrt_id"`
  15670. SetlID string `json:"setl_id"`
  15671. ClrOptins string `json:"clr_optins"`
  15672. SetlTime string `json:"setl_time"`
  15673. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15674. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15675. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15676. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15677. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15678. ActPayDedc float64 `json:"act_pay_dedc"`
  15679. HifpPay float64 `json:"hifp_pay"`
  15680. PoolPropSe float64 `json:"pool_prop_selfpay"`
  15681. Lfpay float64 `json:"selfpay"`
  15682. CvlservPay float64 `json:"cvlserv_pay"`
  15683. HifesPay float64 `json:"hifes_pay"`
  15684. HifmiPay float64 `json:"hifmi_pay"`
  15685. HifobPay float64 `json:"hifob_pay"`
  15686. MafPay float64 `json:"maf_pay"`
  15687. OthPay float64 `json:"oth_pay"`
  15688. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15689. PsnPartAmt float64 `json:"psn_part_amt"`
  15690. AcctPay float64 `json:"acct_pay"`
  15691. Balc float64 `json:"balc"`
  15692. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15693. HospPartAmt float64 `json:"hosp_part_amt"`
  15694. MedinsSetlID string `json:"medins_setl_id"`
  15695. PdnCashPay string `json:"pdn_cash_pay"`
  15696. } `json:"setlinfo"`
  15697. } `json:"output"`
  15698. RefmsgTime string `json:"refmsg_time"`
  15699. RespondTime string `json:"respond_time"`
  15700. Signtype interface{} `json:"signtype"`
  15701. WarnMsg interface{} `json:"warn_msg"`
  15702. }
  15703. type ResultSixteen10265Two struct {
  15704. Cainfo string `json:"cainfo"`
  15705. ErrMsg string `json:"err_msg"`
  15706. InfRefmsgid string `json:"inf_refmsgid"`
  15707. Infcode string `json:"infcode"`
  15708. Output struct {
  15709. Setlinfo interface{} `json:"setlinfo"`
  15710. } `json:"output"`
  15711. RefmsgTime string `json:"refmsg_time"`
  15712. RespondTime string `json:"respond_time"`
  15713. Signtype interface{} `json:"signtype"`
  15714. WarnMsg interface{} `json:"warn_msg"`
  15715. }
  15716. type ResultgzSixteen10265Two struct {
  15717. Cainfo string `json:"cainfo"`
  15718. ErrMsg string `json:"err_msg"`
  15719. InfRefmsgid string `json:"inf_refmsgid"`
  15720. Infcode int64 `json:"infcode"`
  15721. Output struct {
  15722. Setlinfo interface{} `json:"setlinfo"`
  15723. } `json:"output"`
  15724. RefmsgTime string `json:"refmsg_time"`
  15725. RespondTime string `json:"respond_time"`
  15726. Signtype interface{} `json:"signtype"`
  15727. WarnMsg interface{} `json:"warn_msg"`
  15728. }
  15729. type ResultSeventeen struct {
  15730. ErrMsg string `json:"err_msg"`
  15731. InfRefmsgid string `json:"inf_refmsgid"`
  15732. Infcode int64 `json:"infcode"`
  15733. Output struct {
  15734. SetlListId string `json:"setl_list_id"`
  15735. } `json:"output"`
  15736. RefmsgTime string `json:"refmsg_time"`
  15737. RespondTime string `json:"respond_time"`
  15738. Signtype string `json:"signtype"`
  15739. WarnInfo string `json:"warn_info"`
  15740. }
  15741. type ResultSeventeenOther struct {
  15742. ErrMsg string `json:"err_msg"`
  15743. InfRefmsgid string `json:"inf_refmsgid"`
  15744. Infcode string `json:"infcode"`
  15745. Output struct {
  15746. SetlListId string `json:"setl_list_id"`
  15747. } `json:"output"`
  15748. RefmsgTime string `json:"refmsg_time"`
  15749. RespondTime string `json:"respond_time"`
  15750. Signtype string `json:"signtype"`
  15751. WarnInfo string `json:"warn_info"`
  15752. }
  15753. type Result90991 struct {
  15754. ErrMsg string `json:"err_msg"`
  15755. InfRefmsgid string `json:"inf_refmsgid"`
  15756. Infcode int64 `json:"infcode"`
  15757. Output struct {
  15758. Result struct {
  15759. PsnNo string `json:"psn_no"`
  15760. CardStat string `json:"card_stat"`
  15761. Certno string `json:"certno"`
  15762. PsnName string `json:"psn_name"`
  15763. CheckStat string `json:"check_stat"`
  15764. SscnoCheckStat string `json:"sscno_check_stat"`
  15765. } `json:"result"`
  15766. } `json:"output"`
  15767. RefmsgTime string `json:"refmsg_time"`
  15768. RespondTime string `json:"respond_time"`
  15769. Signtype interface{} `json:"signtype"`
  15770. WarnInfo interface{} `json:"warn_info"`
  15771. }
  15772. type Result90100 struct {
  15773. ErrMsg string `json:"err_msg"`
  15774. InfRefmsgid string `json:"inf_refmsgid"`
  15775. Infcode int64 `json:"infcode"`
  15776. Output struct {
  15777. PoolareaNo string `json:"poolarea_no"`
  15778. PoolareaNoName string `json:"poolarea_no_name"`
  15779. Insutype string `json:"insutype"`
  15780. InsutypeName string `json:"insutype_name"`
  15781. ClctType string `json:"clct_type"`
  15782. ClctTypeName string `json:"clct_type_name"`
  15783. ClctFlag string `json:"clct_flag"`
  15784. ClctFlagName string `json:"clct_flag_name"`
  15785. AccrymBegn string `json:"accrym_begn"`
  15786. AccrymEnd string `json:"accrym_end"`
  15787. ClctTime string `json:"clct_time"`
  15788. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  15789. } `json:"output"`
  15790. RefmsgTime string `json:"refmsg_time"`
  15791. RespondTime string `json:"respond_time"`
  15792. Signtype interface{} `json:"signtype"`
  15793. WarnInfo interface{} `json:"warn_info"`
  15794. }
  15795. type Custom struct {
  15796. DetItemFeeSumamt string
  15797. Cut string
  15798. FeedetlSn string
  15799. Price string
  15800. MedListCodg string
  15801. Type int64
  15802. AdviceId int64
  15803. ProjectId int64
  15804. ItemId int64
  15805. }
  15806. type Result5301 struct {
  15807. ErrMsg string `json:"err_msg"`
  15808. InfRefmsgid string `json:"inf_refmsgid"`
  15809. Infcode int64 `json:"infcode"`
  15810. Output struct {
  15811. Result []struct {
  15812. OpspDiseCode string `json:"opsp_dise_code"`
  15813. OpspDiseName string `json:"opsp_dise_name"`
  15814. Begndate string `json:"begndate"`
  15815. Enddate string `json:"enddate"`
  15816. } `json:"feedetail"`
  15817. } `json:"output"`
  15818. RefmsgTime string `json:"refmsg_time"`
  15819. RespondTime string `json:"respond_time"`
  15820. Signtype interface{} `json:"signtype"`
  15821. WarnInfo interface{} `json:"warn_info"`
  15822. }
  15823. type Result5301For10265 struct {
  15824. ErrMsg string `json:"err_msg"`
  15825. InfRefmsgid string `json:"inf_refmsgid"`
  15826. Infcode string `json:"infcode"`
  15827. Output struct {
  15828. Result []struct {
  15829. OpspDiseCode string `json:"opsp_dise_code"`
  15830. OpspDiseName string `json:"opsp_dise_name"`
  15831. Begndate string `json:"begndate"`
  15832. Enddate string `json:"enddate"`
  15833. } `json:"feedetail"`
  15834. } `json:"output"`
  15835. RefmsgTime string `json:"refmsg_time"`
  15836. RespondTime string `json:"respond_time"`
  15837. Signtype interface{} `json:"signtype"`
  15838. WarnInfo interface{} `json:"warn_info"`
  15839. }
  15840. //获取个人信息----挂号-----上传就诊信息
  15841. func (c *HisApiController) GetRegisterInfo() {
  15842. id, _ := c.GetInt64("id")
  15843. record_time := c.GetString("record_time")
  15844. settlementValue, _ := c.GetInt64("settlement_value")
  15845. medical_insurance_card := c.GetString("medical_insurance_card")
  15846. name := c.GetString("name")
  15847. id_card_type, _ := c.GetInt64("id_card_type")
  15848. certificates, _ := c.GetInt64("certificates")
  15849. medical_care, _ := c.GetInt64("medical_care")
  15850. birthday := c.GetString("birthday")
  15851. id_card := c.GetString("id_card")
  15852. register_type, _ := c.GetInt64("register")
  15853. doctor, _ := c.GetInt64("doctor")
  15854. department, _ := c.GetInt64("department")
  15855. gender, _ := c.GetInt64("sex")
  15856. registration_fee, _ := c.GetFloat("registration_fee")
  15857. medical_expenses, _ := c.GetFloat("medical_expenses")
  15858. social_type, _ := c.GetInt64("social_type")
  15859. admin_user_id, _ := c.GetInt64("admin_user_id")
  15860. insuplc_admdvs := c.GetString("insuplc_admdvs")
  15861. mdtrt_type := c.GetString("mdtrt_type")
  15862. if id_card_type == 5{
  15863. id_card_type = 4
  15864. }
  15865. timeLayout := "2006-01-02"
  15866. loc, _ := time.LoadLocation("Local")
  15867. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  15868. birthUnix := birthdays.Unix()
  15869. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  15870. if err != nil {
  15871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  15872. return
  15873. }
  15874. recordDateTime := theTime.Unix()
  15875. adminInfo := c.GetAdminUserInfo()
  15876. var patient service.Patients
  15877. if id == 0 {
  15878. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  15879. } else {
  15880. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  15881. }
  15882. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  15883. if patientPrescription.ID == 0 {
  15884. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  15885. }
  15886. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  15887. if patient.ID == 0 {
  15888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  15889. return
  15890. }
  15891. if len(patient.IdCardNo) == 0 {
  15892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  15893. return
  15894. }
  15895. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  15896. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  15897. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  15898. //就诊结算未完成,不能进行二次挂号
  15899. //his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  15900. //if len(his) >= 1 {
  15901. // order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  15902. // if len(his) >= 1 && order.ID == 0 {
  15903. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  15904. // return
  15905. // }
  15906. //}
  15907. //var register_log string
  15908. if config.IsOpen == 1 {
  15909. var res ResultTwo
  15910. var res10265 ResultTwo10265
  15911. var PsnNo string
  15912. var PsnCertType string
  15913. var Certno string
  15914. var PsnName string
  15915. var Gend string
  15916. var Naty string
  15917. var Brdy string
  15918. var Age float64
  15919. var infoStr string
  15920. var idetinfoStr string
  15921. var infocode int64
  15922. var verify_number string
  15923. fmt.Println(verify_number)
  15924. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" {
  15925. psn_info, _ := service.GetPsnByPatientId(id)
  15926. PsnNo = psn_info.PsnNo
  15927. PsnCertType = psn_info.PsnCertType
  15928. Certno = psn_info.Certno
  15929. PsnName = psn_info.PsnName
  15930. Gend = psn_info.Gend
  15931. Naty = psn_info.Naty
  15932. Brdy = psn_info.Brdy
  15933. Age = psn_info.Age
  15934. infoStr = psn_info.Insuinfo
  15935. idetinfoStr = psn_info.Idetinfo
  15936. infocode = 0
  15937. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15938. psn_info, _ := service.GetPsnByPatientId(id)
  15939. PsnNo = psn_info.PsnNo
  15940. PsnCertType = psn_info.PsnCertType
  15941. Certno = psn_info.Certno
  15942. PsnName = psn_info.PsnName
  15943. Gend = psn_info.Gend
  15944. Naty = psn_info.Naty
  15945. Brdy = psn_info.Brdy
  15946. Age = psn_info.Age
  15947. infoStr = psn_info.Insuinfo
  15948. idetinfoStr = psn_info.Idetinfo
  15949. infocode = 0
  15950. verify_number = psn_info.VerifyNumber
  15951. } else if miConfig.MdtrtareaAdmvs == "150499" {
  15952. if id_card_type == 2 {
  15953. //请求内网数据
  15954. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  15955. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  15956. "&insuplc_admdvs=" + insuplc_admdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(2, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&name=" + patient.Name
  15957. resp, requestErr := http.Get(api)
  15958. if requestErr != nil {
  15959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15960. return
  15961. }
  15962. body, ioErr := ioutil.ReadAll(resp.Body)
  15963. if ioErr != nil {
  15964. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15966. return
  15967. }
  15968. var respJSON map[string]interface{}
  15969. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15970. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15972. return
  15973. }
  15974. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15975. result_byte, _ := json.Marshal(respJSON)
  15976. result := string(result_byte)
  15977. var dat map[string]interface{}
  15978. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15979. fmt.Println(dat)
  15980. } else {
  15981. fmt.Println(err)
  15982. }
  15983. userJSONBytes, _ := json.Marshal(dat)
  15984. var res ResultTwo
  15985. var resTwo10265 ResultTwo10265
  15986. if miConfig.Code == "H15049901371" {
  15987. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  15988. utils.ErrorLog("解析失败:%v", err)
  15989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15990. return
  15991. }
  15992. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  15993. res.Infcode = Infcode
  15994. res.ErrMsg = resTwo10265.ErrMsg
  15995. res.Output = resTwo10265.Output
  15996. res.InfRefmsgid = resTwo10265.InfRefmsgid
  15997. res.RespondTime = resTwo10265.RespondTime
  15998. res.WarnInfo = resTwo10265.WarnInfo
  15999. } else {
  16000. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16001. utils.ErrorLog("解析失败:%v", err)
  16002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16003. return
  16004. }
  16005. }
  16006. //var insutypes []string
  16007. //var insutype string
  16008. //var is390 int = 0
  16009. //var is310 int = 0
  16010. //for _, item := range res.Output.Iinfo {
  16011. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16012. // insutypes = append(insutypes, item.Insutype)
  16013. // }
  16014. //}
  16015. //if len(insutypes) == 1 {
  16016. // insutype = insutypes[0]
  16017. //} else {
  16018. // for _, i := range insutypes {
  16019. // if i == "390" {
  16020. // is390 = 1
  16021. // }
  16022. //
  16023. // if i == "310" {
  16024. // is310 = 1
  16025. // }
  16026. // }
  16027. //}
  16028. //if is390 == 1 {
  16029. // insutype = "390"
  16030. //}
  16031. //if is310 == 1 {
  16032. // insutype = "310"
  16033. //}
  16034. //if len(insutypes) == 0 {
  16035. // insutype = "310"
  16036. //}
  16037. PsnNo = res.Output.Baseinfo.PsnNo
  16038. PsnCertType = res.Output.Baseinfo.PsnCertType
  16039. Certno = res.Output.Baseinfo.Certno
  16040. PsnName = res.Output.Baseinfo.PsnName
  16041. Gend = res.Output.Baseinfo.Gend
  16042. Naty = res.Output.Baseinfo.Naty
  16043. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16044. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16045. infoStr = string(Iinfos)
  16046. idetinfoStr = string(Idetinfos)
  16047. infocode = res.Infcode
  16048. //infocode = 0
  16049. //verify_number = psn_info.VerifyNumber
  16050. } else {
  16051. psn_info, _ := service.GetPsnByPatientId(id)
  16052. PsnNo = psn_info.PsnNo
  16053. PsnCertType = psn_info.PsnCertType
  16054. Certno = psn_info.Certno
  16055. PsnName = psn_info.PsnName
  16056. Gend = psn_info.Gend
  16057. Naty = psn_info.Naty
  16058. Brdy = psn_info.Brdy
  16059. Age = psn_info.Age
  16060. infoStr = psn_info.Insuinfo
  16061. idetinfoStr = psn_info.Idetinfo
  16062. infocode = 0
  16063. verify_number = psn_info.VerifyNumber
  16064. }
  16065. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16066. if id_card_type == 1 {
  16067. psn_info, _ := service.GetPsnByPatientId(id)
  16068. PsnNo = psn_info.PsnNo
  16069. PsnCertType = psn_info.PsnCertType
  16070. Certno = psn_info.Certno
  16071. PsnName = psn_info.PsnName
  16072. Gend = psn_info.Gend
  16073. Naty = psn_info.Naty
  16074. Brdy = psn_info.Brdy
  16075. Age = psn_info.Age
  16076. infoStr = psn_info.Insuinfo
  16077. idetinfoStr = psn_info.Idetinfo
  16078. infocode = 0
  16079. verify_number = psn_info.VerifyNumber
  16080. } else if id_card_type == 2 {
  16081. result, requestLog, errMsgLog := service.FJyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, patient.IdCardNo, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, "", id_card)
  16082. fmt.Println(errMsgLog)
  16083. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16084. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16085. utils.ErrorLog("解析失败:%v", err)
  16086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16087. return
  16088. }
  16089. PsnNo = res.Output.Baseinfo.PsnNo
  16090. PsnCertType = res.Output.Baseinfo.PsnCertType
  16091. Certno = res.Output.Baseinfo.Certno
  16092. PsnName = res.Output.Baseinfo.PsnName
  16093. Gend = res.Output.Baseinfo.Gend
  16094. Naty = res.Output.Baseinfo.Naty
  16095. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16096. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16097. infoStr = string(Iinfos)
  16098. idetinfoStr = string(Idetinfos)
  16099. infocode = res.Infcode
  16100. }
  16101. } else if miConfig.MdtrtareaAdmvs == "360302" {
  16102. if id_card_type == 1 {
  16103. psn_info, _ := service.GetPsnByPatientId(id)
  16104. PsnNo = psn_info.PsnNo
  16105. PsnCertType = psn_info.PsnCertType
  16106. Certno = psn_info.Certno
  16107. PsnName = psn_info.PsnName
  16108. Gend = psn_info.Gend
  16109. Naty = psn_info.Naty
  16110. Brdy = psn_info.Brdy
  16111. Age = psn_info.Age
  16112. infoStr = psn_info.Insuinfo
  16113. idetinfoStr = psn_info.Idetinfo
  16114. infocode = 0
  16115. verify_number = psn_info.VerifyNumber
  16116. } else if id_card_type == 2 {
  16117. result, requestLog := service.Jxyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "")
  16118. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16119. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16120. utils.ErrorLog("解析失败:%v", err)
  16121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16122. return
  16123. }
  16124. PsnNo = res.Output.Baseinfo.PsnNo
  16125. PsnCertType = res.Output.Baseinfo.PsnCertType
  16126. Certno = res.Output.Baseinfo.Certno
  16127. PsnName = res.Output.Baseinfo.PsnName
  16128. Gend = res.Output.Baseinfo.Gend
  16129. Naty = res.Output.Baseinfo.Naty
  16130. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16131. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16132. infoStr = string(Iinfos)
  16133. idetinfoStr = string(Idetinfos)
  16134. infocode = res.Infcode
  16135. }else{
  16136. psn_info, _ := service.GetPsnByPatientId(id)
  16137. PsnNo = psn_info.PsnNo
  16138. PsnCertType = psn_info.PsnCertType
  16139. Certno = psn_info.Certno
  16140. PsnName = psn_info.PsnName
  16141. Gend = psn_info.Gend
  16142. Naty = psn_info.Naty
  16143. Brdy = psn_info.Brdy
  16144. Age = psn_info.Age
  16145. infoStr = psn_info.Insuinfo
  16146. idetinfoStr = psn_info.Idetinfo
  16147. infocode = 0
  16148. verify_number = psn_info.VerifyNumber
  16149. }
  16150. } else if miConfig.MdtrtareaAdmvs == "341203" {
  16151. psn_info, _ := service.GetPsnByPatientId(id)
  16152. PsnNo = psn_info.PsnNo
  16153. PsnCertType = psn_info.PsnCertType
  16154. Certno = psn_info.Certno
  16155. PsnName = psn_info.PsnName
  16156. Gend = psn_info.Gend
  16157. Naty = psn_info.Naty
  16158. Brdy = psn_info.Brdy
  16159. Age = psn_info.Age
  16160. infoStr = psn_info.Insuinfo
  16161. idetinfoStr = psn_info.Idetinfo
  16162. infocode = 0
  16163. verify_number = psn_info.VerifyNumber
  16164. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16165. if id_card_type == 1 {
  16166. psn_info, _ := service.GetPsnByPatientId(id)
  16167. PsnNo = psn_info.PsnNo
  16168. PsnCertType = psn_info.PsnCertType
  16169. Certno = psn_info.Certno
  16170. PsnName = psn_info.PsnName
  16171. Gend = psn_info.Gend
  16172. Naty = psn_info.Naty
  16173. Brdy = psn_info.Brdy
  16174. Age = psn_info.Age
  16175. infoStr = psn_info.Insuinfo
  16176. idetinfoStr = psn_info.Idetinfo
  16177. infocode = 0
  16178. verify_number = psn_info.VerifyNumber
  16179. } else if id_card_type == 2 {
  16180. result, requestLog := service.Hnyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", "1", miConfig.Url, miConfig.AccessKey, "", "", Certno)
  16181. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16182. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16183. utils.ErrorLog("解析失败:%v", err)
  16184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16185. return
  16186. }
  16187. PsnNo = res.Output.Baseinfo.PsnNo
  16188. PsnCertType = res.Output.Baseinfo.PsnCertType
  16189. Certno = res.Output.Baseinfo.Certno
  16190. PsnName = res.Output.Baseinfo.PsnName
  16191. Gend = res.Output.Baseinfo.Gend
  16192. Naty = res.Output.Baseinfo.Naty
  16193. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16194. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16195. infoStr = string(Iinfos)
  16196. idetinfoStr = string(Idetinfos)
  16197. infocode = res.Infcode
  16198. } else if id_card_type == 4 {
  16199. psn_info, _ := service.GetPsnByPatientId(id)
  16200. PsnNo = psn_info.PsnNo
  16201. PsnCertType = psn_info.PsnCertType
  16202. Certno = psn_info.Certno
  16203. PsnName = psn_info.PsnName
  16204. Gend = psn_info.Gend
  16205. Naty = psn_info.Naty
  16206. Brdy = psn_info.Brdy
  16207. Age = psn_info.Age
  16208. infoStr = psn_info.Insuinfo
  16209. idetinfoStr = psn_info.Idetinfo
  16210. infocode = 0
  16211. verify_number = psn_info.VerifyNumber
  16212. }
  16213. } else if miConfig.MdtrtareaAdmvs == "131023" {
  16214. var result string
  16215. var requestLog string
  16216. result, requestLog = service.HeBeiyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), "")
  16217. if id_card_type == 4 {
  16218. psn_info, _ := service.GetPsnByPatientId(id)
  16219. PsnNo = psn_info.PsnNo
  16220. PsnCertType = psn_info.PsnCertType
  16221. Certno = psn_info.Certno
  16222. PsnName = psn_info.PsnName
  16223. Gend = psn_info.Gend
  16224. Naty = psn_info.Naty
  16225. Brdy = psn_info.Brdy
  16226. Age = psn_info.Age
  16227. infoStr = psn_info.Insuinfo
  16228. idetinfoStr = psn_info.Idetinfo
  16229. infocode = 0
  16230. verify_number = psn_info.VerifyNumber
  16231. } else {
  16232. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16233. if miConfig.Code == "H15049901371" {
  16234. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16235. utils.ErrorLog("解析失败:%v", err)
  16236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16237. return
  16238. }
  16239. res.ErrMsg = res10265.ErrMsg
  16240. res.Output = res10265.Output
  16241. res.InfRefmsgid = res10265.InfRefmsgid
  16242. } else {
  16243. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16244. utils.ErrorLog("解析失败:%v", err)
  16245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16246. return
  16247. }
  16248. }
  16249. PsnNo = res.Output.Baseinfo.PsnNo
  16250. PsnCertType = res.Output.Baseinfo.PsnCertType
  16251. Certno = res.Output.Baseinfo.Certno
  16252. PsnName = res.Output.Baseinfo.PsnName
  16253. Gend = res.Output.Baseinfo.Gend
  16254. Naty = res.Output.Baseinfo.Naty
  16255. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16256. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16257. infoStr = string(Iinfos)
  16258. idetinfoStr = string(Idetinfos)
  16259. if miConfig.Code == "H15049901371" {
  16260. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  16261. } else {
  16262. infocode = res.Infcode
  16263. }
  16264. }
  16265. } else if miConfig.MdtrtareaAdmvs == "441799" {
  16266. psn_info, _ := service.GetPsnByPatientId(id)
  16267. PsnNo = psn_info.PsnNo
  16268. PsnCertType = psn_info.PsnCertType
  16269. Certno = psn_info.Certno
  16270. PsnName = psn_info.PsnName
  16271. Gend = psn_info.Gend
  16272. Naty = psn_info.Naty
  16273. Brdy = psn_info.Brdy
  16274. Age = psn_info.Age
  16275. infoStr = psn_info.Insuinfo
  16276. idetinfoStr = psn_info.Idetinfo
  16277. infocode = 0
  16278. verify_number = psn_info.VerifyNumber
  16279. } else if miConfig.MdtrtareaAdmvs == "450721" {
  16280. psn_info, _ := service.GetPsnByPatientId(id)
  16281. PsnNo = psn_info.PsnNo
  16282. PsnCertType = psn_info.PsnCertType
  16283. Certno = psn_info.Certno
  16284. PsnName = psn_info.PsnName
  16285. Gend = psn_info.Gend
  16286. Naty = psn_info.Naty
  16287. Brdy = psn_info.Brdy
  16288. Age = psn_info.Age
  16289. infoStr = psn_info.Insuinfo
  16290. idetinfoStr = psn_info.Idetinfo
  16291. infocode = 0
  16292. verify_number = psn_info.VerifyNumber
  16293. } else {
  16294. var result string
  16295. var requestLog string
  16296. //if miConfig.UserOrgId == 10138 {
  16297. if id_card_type != 4 || id_card_type != 1 {
  16298. var insa string
  16299. if len(patient.InsuplcAdmdvs) > 0 {
  16300. insa = patient.InsuplcAdmdvs
  16301. } else {
  16302. insa = miConfig.InsuplcAdmdvs
  16303. }
  16304. //psn_info, _ := service.GetPsnByPatientId(id)
  16305. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  16306. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, insa, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name, record_time, admin_user_id)
  16307. }
  16308. //}
  16309. //else {
  16310. // var insa string
  16311. // if len(patient.InsuplcAdmdvs) > 0 {
  16312. // insa = patient.InsuplcAdmdvs
  16313. // } else {
  16314. // insa = miConfig.InsuplcAdmdvs
  16315. // }
  16316. // result, requestLog = service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, insa, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  16317. //}
  16318. if id_card_type == 4 || id_card_type == 1 {
  16319. psn_info, _ := service.GetPsnByPatientId(id)
  16320. PsnNo = psn_info.PsnNo
  16321. PsnCertType = psn_info.PsnCertType
  16322. Certno = psn_info.Certno
  16323. PsnName = psn_info.PsnName
  16324. Gend = psn_info.Gend
  16325. Naty = psn_info.Naty
  16326. Brdy = psn_info.Brdy
  16327. Age = psn_info.Age
  16328. infoStr = psn_info.Insuinfo
  16329. idetinfoStr = psn_info.Idetinfo
  16330. infocode = 0
  16331. verify_number = psn_info.VerifyNumber
  16332. } else {
  16333. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16334. if miConfig.Code == "H15049901371" {
  16335. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16336. utils.ErrorLog("解析失败:%v", err)
  16337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16338. return
  16339. }
  16340. res.ErrMsg = res10265.ErrMsg
  16341. res.Output = res10265.Output
  16342. res.InfRefmsgid = res10265.InfRefmsgid
  16343. } else {
  16344. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16345. utils.ErrorLog("解析失败:%v", err)
  16346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16347. return
  16348. }
  16349. }
  16350. PsnNo = res.Output.Baseinfo.PsnNo
  16351. PsnCertType = res.Output.Baseinfo.PsnCertType
  16352. Certno = res.Output.Baseinfo.Certno
  16353. PsnName = res.Output.Baseinfo.PsnName
  16354. Gend = res.Output.Baseinfo.Gend
  16355. Naty = res.Output.Baseinfo.Naty
  16356. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16357. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16358. infoStr = string(Iinfos)
  16359. idetinfoStr = string(Idetinfos)
  16360. if miConfig.Code == "H15049901371" {
  16361. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  16362. } else {
  16363. infocode = res.Infcode
  16364. }
  16365. }
  16366. }
  16367. if infocode == 0 {
  16368. his := models.VMHisPatient{
  16369. Name: name,
  16370. Gender: gender,
  16371. Birthday: birthUnix,
  16372. MedicalTreatmentType: medical_care,
  16373. IdType: certificates,
  16374. IdCardNo: id_card,
  16375. BalanceAccountsType: settlementValue,
  16376. SocialType: social_type,
  16377. MedicalInsuranceNumber: medical_insurance_card,
  16378. RegisterType: register_type,
  16379. RegisterCost: registration_fee,
  16380. TreatmentCost: medical_expenses,
  16381. Status: 1,
  16382. Ctime: time.Now().Unix(),
  16383. Mtime: time.Now().Unix(),
  16384. PsnNo: PsnNo,
  16385. PsnCertType: PsnCertType,
  16386. Certno: Certno,
  16387. PsnName: PsnName,
  16388. Gend: Gend,
  16389. Naty: Naty,
  16390. Brdy: Brdy,
  16391. Age: Age,
  16392. Iinfo: infoStr,
  16393. Idetinfo: idetinfoStr,
  16394. PatientId: patient.ID,
  16395. RecordDate: theTime.Unix(),
  16396. UserOrgId: adminInfo.CurrentOrgId,
  16397. AdminUserId: admin_user_id,
  16398. IsReturn: 1,
  16399. IdCardType: id_card_type,
  16400. Doctor: doctor,
  16401. Departments: department,
  16402. MdtrtGrpType: mdtrt_type,
  16403. }
  16404. timestamp := time.Now().Unix()
  16405. tempTime := time.Unix(timestamp, 0)
  16406. timeFormat := tempTime.Format("20060102150405")
  16407. chrgBchno := rand.Intn(100000) + 10000
  16408. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  16409. his.Number = ipt_otp_no
  16410. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  16411. department, _ := service.GetDepartMentDetail(department)
  16412. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  16413. IdCardNo := ""
  16414. if id_card_type == 1 {
  16415. // IdCardNo = medical_insurance_card
  16416. IdCardNo = patient.IdCardNo
  16417. } else {
  16418. IdCardNo = patient.IdCardNo
  16419. }
  16420. var rf []*ResultFive
  16421. json.Unmarshal([]byte(his.Iinfo), &rf)
  16422. var insutypes []*ResultFive
  16423. var insutype string
  16424. var insuplc_admdvs_temp string
  16425. var is390 int = 0
  16426. var is310 int = 0
  16427. for _, item := range rf {
  16428. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16429. insutypes = append(insutypes, item)
  16430. }
  16431. }
  16432. if len(insutypes) == 1 {
  16433. insutype = insutypes[0].Insutype
  16434. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16435. if insutype == "390" {
  16436. is390 = 1
  16437. }
  16438. if insutype == "310" {
  16439. is310 = 1
  16440. }
  16441. } else {
  16442. for _, i := range insutypes {
  16443. if i.Insutype == "390" {
  16444. is390 = 1
  16445. }
  16446. if i.Insutype == "310" {
  16447. is310 = 1
  16448. }
  16449. }
  16450. }
  16451. if is390 == 1 {
  16452. insutype = "390"
  16453. }
  16454. if is310 == 1 {
  16455. insutype = "310"
  16456. }
  16457. fmt.Println(social_type)
  16458. if social_type > 0 {
  16459. insutype = strconv.FormatInt(social_type, 10)
  16460. }
  16461. var infocode int64
  16462. var resThree ResultThree
  16463. var resThree10265 ResultThree10265
  16464. if len(insuplc_admdvs) == 0 {
  16465. psn_info, _ := service.GetPsnByPatientId(id)
  16466. //if len(psn_info.InsuplcAdmdvs) > 0 {
  16467. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  16468. //}
  16469. } else {
  16470. insuplc_admdvs_temp = insuplc_admdvs
  16471. }
  16472. if miConfig.MdtrtareaAdmvs == "421300" {
  16473. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  16474. psn_info, _ := service.GetPsnByPatientId(id)
  16475. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  16476. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  16477. "&insuplc_admdvs=" + psn_info.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + hb_doctor_info.DoctorNumber + "&doctor_name=" + hb_doctor_info.UserName + "&opter=" + roles.UserName
  16478. resp, requestErr := http.Get(api)
  16479. if requestErr != nil {
  16480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16481. return
  16482. }
  16483. body, ioErr := ioutil.ReadAll(resp.Body)
  16484. if ioErr != nil {
  16485. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16487. return
  16488. }
  16489. var respJSON map[string]interface{}
  16490. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16491. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16493. return
  16494. }
  16495. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16496. result, _ := json.Marshal(respJSON)
  16497. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  16498. utils.ErrorLog("解析失败:%v", err)
  16499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16500. return
  16501. }
  16502. infocode = resThree.Infcode
  16503. } else if miConfig.MdtrtareaAdmvs == "420200" {
  16504. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  16505. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  16506. // insuplc_admdvs_temp =
  16507. //}
  16508. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  16509. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  16510. //}
  16511. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  16512. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  16513. "&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=" + hb_doctor_info.DoctorNumber + "&doctor_name=" + hb_doctor_info.UserName + "&opter=" + roles.UserName
  16514. resp, requestErr := http.Get(api)
  16515. if requestErr != nil {
  16516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16517. return
  16518. }
  16519. body, ioErr := ioutil.ReadAll(resp.Body)
  16520. if ioErr != nil {
  16521. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16523. return
  16524. }
  16525. var respJSON map[string]interface{}
  16526. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16527. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16529. return
  16530. }
  16531. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16532. result, _ := json.Marshal(respJSON)
  16533. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  16534. utils.ErrorLog("解析失败:%v", err)
  16535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16536. return
  16537. }
  16538. infocode = resThree.Infcode
  16539. } else if miConfig.MdtrtareaAdmvs == "421182" {
  16540. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  16541. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  16542. // insuplc_admdvs_temp =
  16543. //}
  16544. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  16545. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  16546. //}
  16547. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  16548. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  16549. "&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=" + hb_doctor_info.DoctorNumber + "&doctor_name=" + hb_doctor_info.UserName + "&opter=" + roles.UserName
  16550. resp, requestErr := http.Get(api)
  16551. if requestErr != nil {
  16552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16553. return
  16554. }
  16555. body, ioErr := ioutil.ReadAll(resp.Body)
  16556. if ioErr != nil {
  16557. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16559. return
  16560. }
  16561. var respJSON map[string]interface{}
  16562. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16565. return
  16566. }
  16567. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16568. result, _ := json.Marshal(respJSON)
  16569. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  16570. utils.ErrorLog("解析失败:%v", err)
  16571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16572. return
  16573. }
  16574. infocode = resThree.Infcode
  16575. }else if miConfig.MdtrtareaAdmvs == "150499" {
  16576. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  16577. psn_info, _ := service.GetPsnByPatientId(id)
  16578. var verify_number string
  16579. if id_card_type == 4 {
  16580. verify_number = psn_info.VerifyNumber
  16581. } else if id_card_type == 1 {
  16582. bas := strings.Split(psn_info.CardInfo, "|")
  16583. cardNumber := bas[2]
  16584. verify_number = cardNumber
  16585. }
  16586. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  16587. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  16588. "&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=" + hb_doctor_info.DoctorNumber + "&doctor_name=" + hb_doctor_info.UserName + "&opter=" + roles.UserName + "&verify_number=" + verify_number
  16589. resp, requestErr := http.Get(api)
  16590. if requestErr != nil {
  16591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16592. return
  16593. }
  16594. body, ioErr := ioutil.ReadAll(resp.Body)
  16595. if ioErr != nil {
  16596. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16598. return
  16599. }
  16600. var respJSON map[string]interface{}
  16601. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16602. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16604. return
  16605. }
  16606. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16607. result, _ := json.Marshal(respJSON)
  16608. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  16609. // utils.ErrorLog("解析失败:%v", err)
  16610. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16611. // return
  16612. //}
  16613. //infocode = resThree.Infcode
  16614. //result, _ := json.Marshal(respJSON)
  16615. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  16616. utils.ErrorLog("解析失败:%v", err)
  16617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16618. return
  16619. }
  16620. resThree.ErrMsg = resThree10265.ErrMsg
  16621. resThree.Output = resThree10265.Output
  16622. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  16623. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  16624. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16625. psn_info, _ := service.GetPsnByPatientId(id)
  16626. his.PsnNo = psn_info.PsnNo
  16627. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  16628. var cert_no string
  16629. if id_card_type == 3 {
  16630. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  16631. cert_no = IdCardNo
  16632. } else if id_card_type == 4 {
  16633. cert_no = IdCardNo
  16634. psn_info.VerifyNumber = psn_info.VerifyNumber
  16635. } else {
  16636. bas := strings.Split(psn_info.CardInfo, "|")
  16637. cert_no = bas[2]
  16638. }
  16639. var hisPrescription []*models.HisPrescription
  16640. for _, item := range rf {
  16641. if item.Insutype == insutype {
  16642. //insuplc_admdvs = item.InsuplcAdmdvs
  16643. his.InsuplcAdmdvs = insuplc_admdvs
  16644. }
  16645. }
  16646. his.Insutype = insutype
  16647. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  16648. fmt.Println(res3101)
  16649. fmt.Println(res3101.Infcode)
  16650. if res3101.Infcode == "0" {
  16651. fmt.Println("33333333")
  16652. if len(res3101.Output.Result) > 0 {
  16653. fmt.Println("222222")
  16654. for _, item := range res3101.Output.Result {
  16655. if len(res3101.ErrMsg) == 0 {
  16656. res3101.ErrMsg = item.VolaCont
  16657. } else {
  16658. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  16659. }
  16660. }
  16661. c.ServeSuccessJSON(map[string]interface{}{
  16662. "failed_code": -10,
  16663. "msg": res3101.ErrMsg,
  16664. })
  16665. return
  16666. } else {
  16667. fmt.Println("11111")
  16668. var api string
  16669. if miConfig.MdtrtareaAdmvs == "320921" {
  16670. ipt_otp_no = timeFormat
  16671. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  16672. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  16673. "&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_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  16674. } else {
  16675. ipt_otp_no = timeFormat
  16676. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  16677. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  16678. "&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_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  16679. }
  16680. resp, requestErr := http.Get(api)
  16681. if requestErr != nil {
  16682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16683. return
  16684. }
  16685. body, ioErr := ioutil.ReadAll(resp.Body)
  16686. if ioErr != nil {
  16687. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16689. return
  16690. }
  16691. var respJSON map[string]interface{}
  16692. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16693. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16695. return
  16696. }
  16697. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16698. result, _ := json.Marshal(respJSON)
  16699. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  16700. utils.ErrorLog("解析失败:%v", err)
  16701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16702. return
  16703. }
  16704. resThree.ErrMsg = resThree10265.ErrMsg
  16705. resThree.Output = resThree10265.Output
  16706. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  16707. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  16708. }
  16709. } else if res3101.Infcode != "0" {
  16710. c.ServeSuccessJSON(map[string]interface{}{
  16711. "failed_code": -10,
  16712. "msg": res3101.ErrMsg,
  16713. })
  16714. return
  16715. }
  16716. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16717. psn_info, _ := service.GetPsnByPatientId(id)
  16718. var cert_no string
  16719. if id_card_type == 1 {
  16720. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  16721. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  16722. } else if id_card_type == 4 {
  16723. cert_no = psn_info.VerifyNumber
  16724. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  16725. } else {
  16726. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  16727. cert_no = psn_info.VerifyNumber
  16728. }
  16729. result, requestLog, _ := service.FJyb2201(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, doctor_info.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, roles.UserName, doctor_info.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, cert_no, record_time)
  16730. saveLog(result, requestLog, "2201", "挂号")
  16731. if miConfig.Code == "H15049901371" {
  16732. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  16733. utils.ErrorLog("解析失败:%v", err)
  16734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16735. return
  16736. }
  16737. resThree.ErrMsg = resThree10265.ErrMsg
  16738. resThree.Output = resThree10265.Output
  16739. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  16740. } else {
  16741. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  16742. utils.ErrorLog("解析失败:%v", err)
  16743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16744. return
  16745. }
  16746. }
  16747. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  16748. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  16749. psn_info, _ := service.GetPsnByPatientId(id)
  16750. var result string
  16751. var requestLog string
  16752. if id_card_type == 1 {
  16753. bas := strings.Split(psn_info.CardInfo, "|")
  16754. basNumber := bas[2]
  16755. card_sn := bas[3]
  16756. result, requestLog = service.Jxyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn,"01",IdCardNo,"15",psn_info.PsnName)
  16757. saveLog(result, requestLog, "2201A", "挂号")
  16758. } else if id_card_type == 2 {
  16759. result, requestLog = service.Jxyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, IdCardNo, "", "","","","","",)
  16760. saveLog(result, requestLog, "2201A", "挂号")
  16761. } else {
  16762. result, requestLog = service.Jxyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "", "","01",IdCardNo,"15",psn_info.PsnName)
  16763. saveLog(result, requestLog, "2201A", "挂号")
  16764. }
  16765. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  16766. utils.ErrorLog("解析失败:%v", err)
  16767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16768. return
  16769. }
  16770. infocode = resThree.Infcode
  16771. } else if miConfig.MdtrtareaAdmvs == "341203" {
  16772. psn_info, _ := service.GetPsnByPatientId(id)
  16773. his.PsnNo = psn_info.PsnNo
  16774. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  16775. var cert_no string
  16776. if id_card_type == 1 {
  16777. bas := strings.Split(psn_info.CardInfo, "|")
  16778. cert_no = bas[2]
  16779. } else if id_card_type == 4 {
  16780. cert_no = IdCardNo
  16781. psn_info.VerifyNumber = psn_info.VerifyNumber
  16782. } else {
  16783. cert_no = IdCardNo
  16784. psn_info.VerifyNumber = cert_no
  16785. }
  16786. for _, item := range rf {
  16787. if item.Insutype == insutype {
  16788. his.InsuplcAdmdvs = insuplc_admdvs
  16789. }
  16790. }
  16791. his.Insutype = insutype
  16792. var api string
  16793. ipt_otp_no = timeFormat
  16794. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  16795. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  16796. "&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_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  16797. resp, requestErr := http.Get(api)
  16798. if requestErr != nil {
  16799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16800. return
  16801. }
  16802. body, ioErr := ioutil.ReadAll(resp.Body)
  16803. if ioErr != nil {
  16804. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16806. return
  16807. }
  16808. var respJSON map[string]interface{}
  16809. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16810. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16812. return
  16813. }
  16814. status := respJSON["data"].(map[string]interface{})["status"].(string)
  16815. if status == "0"{
  16816. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  16817. c.ServeSuccessJSON(map[string]interface{}{
  16818. "failed_code": -10,
  16819. "msg": err_msg,
  16820. })
  16821. return
  16822. }
  16823. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16824. result, _ := json.Marshal(respJSON)
  16825. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  16826. utils.ErrorLog("解析失败:%v", err)
  16827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16828. return
  16829. }
  16830. infocode = resThree.Infcode
  16831. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16832. psn_info, _ := service.GetPsnByPatientId(id)
  16833. var result string
  16834. var requestLog string
  16835. if id_card_type == 1 {
  16836. bas := strings.Split(psn_info.CardInfo, "|")
  16837. basNumber := bas[2]
  16838. card_sn := bas[3]
  16839. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, miConfig.MdtrtareaAdmvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn)
  16840. saveLog(result, requestLog, "2201A", "挂号")
  16841. } else if id_card_type == 2 {
  16842. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, psn_info.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, IdCardNo, "", "")
  16843. saveLog(result, requestLog, "2201A", "挂号")
  16844. } else {
  16845. result, requestLog = service.Hnyb2201(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "", "")
  16846. saveLog(result, requestLog, "2201A", "挂号")
  16847. }
  16848. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  16849. utils.ErrorLog("解析失败:%v", err)
  16850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16851. return
  16852. }
  16853. infocode = resThree.Infcode
  16854. } else if miConfig.MdtrtareaAdmvs == "131023" {
  16855. psn_info, _ := service.GetPsnByPatientId(id)
  16856. result, requestLog := service.HeBeiyb2201A(PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time, psn_info.VerifyNumber)
  16857. saveLog(result, requestLog, "2201A", "挂号")
  16858. if miConfig.Code == "H15049901371" {
  16859. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  16860. utils.ErrorLog("解析失败:%v", err)
  16861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16862. return
  16863. }
  16864. resThree.ErrMsg = resThree10265.ErrMsg
  16865. resThree.Output = resThree10265.Output
  16866. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  16867. } else {
  16868. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  16869. utils.ErrorLog("解析失败:%v", err)
  16870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16871. return
  16872. }
  16873. }
  16874. if miConfig.Code == "H15049901371" {
  16875. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  16876. } else {
  16877. infocode = resThree.Infcode
  16878. }
  16879. } else {
  16880. psn_info, _ := service.GetPsnByPatientId(id)
  16881. if id_card_type == 4 || id_card_type == 1 {
  16882. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  16883. }
  16884. var rf []*ResultFive
  16885. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  16886. var insutypes []*ResultFive
  16887. var insutype string
  16888. var is390 int = 0
  16889. var is310 int = 0
  16890. for _, item := range rf {
  16891. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16892. insutypes = append(insutypes, item)
  16893. }
  16894. }
  16895. if len(insutypes) == 1 {
  16896. insutype = insutypes[0].Insutype
  16897. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16898. } else {
  16899. for _, i := range insutypes {
  16900. if i.Insutype == "390" {
  16901. is390 = 1
  16902. }
  16903. if i.Insutype == "310" {
  16904. is310 = 1
  16905. }
  16906. }
  16907. }
  16908. if is390 == 1 {
  16909. insutype = "390"
  16910. }
  16911. if is310 == 1 {
  16912. insutype = "310"
  16913. }
  16914. fmt.Println(len(insutypes))
  16915. if len(insutypes) == 0 {
  16916. for index, item := range rf {
  16917. if index == 0 {
  16918. insutype = item.Insutype
  16919. insuplc_admdvs = item.InsuplcAdmdvs
  16920. }
  16921. }
  16922. fmt.Println(insutype)
  16923. fmt.Println(insuplc_admdvs)
  16924. }
  16925. if social_type > 0 {
  16926. insutype = strconv.FormatInt(social_type, 10)
  16927. }
  16928. fmt.Println("--------")
  16929. fmt.Println(psn_info)
  16930. fmt.Println(psn_info.PsnNo)
  16931. if miConfig.MdtrtareaAdmvs == "441202" {
  16932. var hisPrescription []*models.HisPrescription
  16933. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  16934. if res3101.Infcode == 0 {
  16935. fmt.Println("33333333")
  16936. if len(res3101.Output.Result) > 0 {
  16937. fmt.Println("222222")
  16938. for _, item := range res3101.Output.Result {
  16939. if len(res3101.ErrMsg) == 0 {
  16940. res3101.ErrMsg = item.VolaCont
  16941. } else {
  16942. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  16943. }
  16944. }
  16945. c.ServeSuccessJSON(map[string]interface{}{
  16946. "failed_code": -10,
  16947. "msg": res3101.ErrMsg,
  16948. })
  16949. return
  16950. } else {
  16951. hour := time.Now().Format("15")
  16952. min := time.Now().Format("04")
  16953. sec := time.Now().Format("05")
  16954. record_time_two := record_time + " " + hour +":"+ min+":"+ sec
  16955. fmt.Println(record_time_two)
  16956. result, requestLog := service.Gdyb2201A(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time_two, psn_info.VerifyNumber, admin_user_id)
  16957. saveLog(result, requestLog, "2201A", "挂号")
  16958. if miConfig.Code == "H15049901371" {
  16959. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  16960. utils.ErrorLog("解析失败:%v", err)
  16961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16962. return
  16963. }
  16964. resThree.ErrMsg = resThree10265.ErrMsg
  16965. resThree.Output = resThree10265.Output
  16966. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  16967. } else {
  16968. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  16969. utils.ErrorLog("解析失败:%v", err)
  16970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16971. return
  16972. }
  16973. }
  16974. if miConfig.Code == "H15049901371" {
  16975. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  16976. } else {
  16977. infocode = resThree.Infcode
  16978. }
  16979. }
  16980. } else if res3101.Infcode != 0 {
  16981. c.ServeSuccessJSON(map[string]interface{}{
  16982. "failed_code": -10,
  16983. "msg": res3101.ErrMsg,
  16984. })
  16985. return
  16986. }
  16987. } else if miConfig.MdtrtareaAdmvs == "441799" {
  16988. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  16989. psn_info, _ := service.GetPsnByPatientId(id)
  16990. var verify_number string
  16991. if id_card_type == 4 {
  16992. verify_number = psn_info.VerifyNumber
  16993. } else if id_card_type == 1 {
  16994. bas := strings.Split(psn_info.CardInfo, "|")
  16995. cardNumber := bas[2]
  16996. verify_number = cardNumber
  16997. } else {
  16998. verify_number = psn_info.Certno
  16999. }
  17000. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17001. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17002. "&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_info.DoctorNumber + "&doctor_name=" + doctor_info.UserName + "&verify_number=" + verify_number + "&record_time=" + record_time
  17003. resp, requestErr := http.Get(api)
  17004. if requestErr != nil {
  17005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17006. return
  17007. }
  17008. body, ioErr := ioutil.ReadAll(resp.Body)
  17009. if ioErr != nil {
  17010. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17012. return
  17013. }
  17014. var respJSON map[string]interface{}
  17015. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17016. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17018. return
  17019. }
  17020. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17021. result, _ := json.Marshal(respJSON)
  17022. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17023. utils.ErrorLog("解析失败:%v", err)
  17024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17025. return
  17026. }
  17027. infocode = resThree.Infcode
  17028. } else {
  17029. hour := time.Now().Format("15")
  17030. min := time.Now().Format("04")
  17031. sec := time.Now().Format("05")
  17032. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  17033. if id_card_type == 1 {
  17034. for _, item := range rf {
  17035. if item.Insutype == strconv.FormatInt(social_type, 10) {
  17036. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  17037. insuplc_admdvs_temp = item.InsuplcAdmdvs
  17038. } else if strconv.FormatInt(social_type, 10) == "390" {
  17039. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17040. } else {
  17041. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17042. }
  17043. }
  17044. }
  17045. }
  17046. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  17047. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17048. }
  17049. if id_card_type == 1 {
  17050. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  17051. bas := strings.Split(psn_info.CardInfo, "|")
  17052. basNumber := bas[1]
  17053. IdCardNo = basNumber
  17054. }
  17055. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  17056. IdCardNo = psn_info.VerifyNumber
  17057. }
  17058. result, requestLog := service.Gdyb2201A(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time_two, psn_info.VerifyNumber, admin_user_id)
  17059. saveLog(result, requestLog, "2201A", "挂号")
  17060. if miConfig.Code == "H15049901371" {
  17061. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17062. utils.ErrorLog("解析失败:%v", err)
  17063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17064. return
  17065. }
  17066. resThree.ErrMsg = resThree10265.ErrMsg
  17067. resThree.Output = resThree10265.Output
  17068. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17069. } else {
  17070. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17071. utils.ErrorLog("解析失败:%v", err)
  17072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17073. return
  17074. }
  17075. }
  17076. if miConfig.Code == "H15049901371" {
  17077. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17078. } else {
  17079. infocode = resThree.Infcode
  17080. }
  17081. }
  17082. }
  17083. if infocode != 0 {
  17084. adminUser := c.GetAdminUserInfo()
  17085. errlog := &models.HisOrderError{
  17086. UserOrgId: adminUser.CurrentOrgId,
  17087. Ctime: time.Now().Unix(),
  17088. Mtime: time.Now().Unix(),
  17089. ErrMsg: resThree.ErrMsg,
  17090. Status: 1,
  17091. PatientId: id,
  17092. RecordTime: recordDateTime,
  17093. Stage: 2,
  17094. }
  17095. service.CreateErrMsgLog(errlog)
  17096. c.ServeSuccessJSON(map[string]interface{}{
  17097. "failed_code": -10,
  17098. "msg": resThree.ErrMsg,
  17099. })
  17100. return
  17101. }
  17102. his.Number = resThree.Output.Data.MdtrtID
  17103. his.PsnNo = resThree.Output.Data.PsnNo
  17104. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  17105. his.IdCardNo = patient.IdCardNo
  17106. his.PhoneNumber = patient.Phone
  17107. his.UserOrgId = adminInfo.CurrentOrgId
  17108. his.Insutype = insutype
  17109. his.Ctime = time.Now().Unix()
  17110. his.Mtime = time.Now().Unix()
  17111. his.InsuplcAdmdvs = insuplc_admdvs_temp
  17112. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  17113. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  17114. }
  17115. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  17116. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  17117. }
  17118. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  17119. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  17120. }
  17121. his.Status = 1
  17122. his.MdtrtGrpType = mdtrt_type
  17123. service.UpdateHisPatientStatus(&his)
  17124. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  17125. c.ServeSuccessJSON(map[string]interface{}{
  17126. "his_info": his,
  17127. })
  17128. } else {
  17129. adminUser := c.GetAdminUserInfo()
  17130. errlog := &models.HisOrderError{
  17131. UserOrgId: adminUser.CurrentOrgId,
  17132. Ctime: time.Now().Unix(),
  17133. Mtime: time.Now().Unix(),
  17134. ErrMsg: res.ErrMsg,
  17135. Status: 1,
  17136. PatientId: id,
  17137. RecordTime: recordDateTime,
  17138. Stage: 1,
  17139. }
  17140. service.CreateErrMsgLog(errlog)
  17141. c.ServeSuccessJSON(map[string]interface{}{
  17142. "failed_code": -10,
  17143. "msg": res.ErrMsg,
  17144. })
  17145. return
  17146. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  17147. }
  17148. }
  17149. }
  17150. func (c *HisApiController) GetUploadInfo() {
  17151. id, _ := c.GetInt64("id")
  17152. record_time := c.GetString("record_time")
  17153. his_patient_id, _ := c.GetInt64("his_patient_id")
  17154. order_id, _ := c.GetInt64("order_id")
  17155. pay_way, _ := c.GetInt64("pay_way")
  17156. pay_ways := c.GetString("pay_ways")
  17157. oth_desc := c.GetString("oth_desc")
  17158. pay_price, _ := c.GetFloat("pay_price")
  17159. pay_card_no := c.GetString("pay_card_no")
  17160. discount_price, _ := c.GetFloat("discount_price")
  17161. preferential_price, _ := c.GetFloat("preferential_price")
  17162. reality_price, _ := c.GetFloat("reality_price")
  17163. found_price, _ := c.GetFloat("found_price")
  17164. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  17165. private_price, _ := c.GetFloat("private_price")
  17166. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  17167. admin_user_id, _ := c.GetInt64("admin_user_id")
  17168. fapiao_code := c.GetString("fapiao_code")
  17169. fapiao_number := c.GetString("fapiao_number")
  17170. diagnosis_id := c.GetString("diagnosis")
  17171. sick_type, _ := c.GetInt64("sick_type")
  17172. reg_type, _ := c.GetInt64("p_type")
  17173. begin_time := c.GetString("begin_time")
  17174. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  17175. cash_pay := c.GetString("cash_pay")
  17176. band_card_pay := c.GetString("band_card_pay")
  17177. wechat_pay := c.GetString("wechat_pay")
  17178. ali_pay := c.GetString("ali_pay")
  17179. jifen_pay := c.GetString("jifen_pay")
  17180. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  17181. fmt.Println(acct_used_flag)
  17182. id_str := c.GetString("ids")
  17183. ids_arr := strings.Split(id_str, ",")
  17184. timeLayout := "2006-01-02"
  17185. loc, _ := time.LoadLocation("Local")
  17186. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  17187. if err != nil {
  17188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17189. return
  17190. }
  17191. recordDateTime := theTime.Unix()
  17192. adminUser := c.GetAdminUserInfo()
  17193. var tempOrder models.HisOrder
  17194. tempOrder, _ = service.GetHisOrderByID(order_id)
  17195. var prescriptions []*models.HisPrescription
  17196. var start_time int64
  17197. var end_time int64
  17198. //押金模块
  17199. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  17200. tmp_decimal := c.GetString("tmp_decimal")
  17201. var decimal float64 //本次使用的押金
  17202. var errmsg error
  17203. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  17204. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  17205. return
  17206. }
  17207. if len(tmp_decimal) > 0 {
  17208. if tmp_decimal[0] == 45 {
  17209. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  17210. return
  17211. }
  17212. }
  17213. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  17214. fmt.Println(errs)
  17215. decimal = tt
  17216. //if adminUser.CurrentOrgId == 10106{
  17217. // if len(fapiao_code) == 0{
  17218. // fapiao_code = "144072080589"
  17219. // }
  17220. // if len(fapiao_number) == 0{
  17221. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  17222. // if order.ID == 0{
  17223. // fapiao_number = "00001520"
  17224. // }else{
  17225. // //fapiao_code = "00001520"
  17226. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  17227. // var zero string
  17228. // if fpNumber >= 1000{
  17229. // zero = "0000" + strconv.Itoa(fpNumber)
  17230. // }else if fpNumber >= 10000{
  17231. // zero = "000" + strconv.Itoa(fpNumber)
  17232. // } else if fpNumber >= 100000{
  17233. // zero = "00" + strconv.Itoa(fpNumber)
  17234. // } else if fpNumber >= 1000000{
  17235. // zero = "0" + strconv.Itoa(fpNumber)
  17236. // }else {
  17237. // zero = strconv.Itoa(fpNumber)
  17238. // }
  17239. // fapiao_number = zero
  17240. // }
  17241. // }
  17242. //}
  17243. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17244. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  17245. var patientPrescription models.HisPrescriptionInfo
  17246. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  17247. if patientPrescription.ID == 0 {
  17248. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  17249. }
  17250. //if patientPrescription.Do
  17251. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17252. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  17253. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  17254. diagnosis_ids := strings.Split(diagnosis_id, ",")
  17255. var config []*models.HisXtDiagnoseConfig
  17256. for _, item := range diagnosis_ids {
  17257. id, _ := strconv.ParseInt(item, 10, 64)
  17258. diagnosisConfig, _ := service.FindDiagnoseById(id)
  17259. config = append(config, &diagnosisConfig)
  17260. }
  17261. sickConfig, _ := service.FindSickById(sick_type)
  17262. //if tempOrder.ID == 0 {
  17263. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  17264. //}
  17265. if tempOrder.ID == 0 {
  17266. var result string
  17267. var requestLog string
  17268. var res2 ResultSix
  17269. var res3 GZResultSix
  17270. var ressix10265 ResultSix10265
  17271. if miConfig.MdtrtareaAdmvs == "421300" {
  17272. data := make(map[string]interface{})
  17273. client := &http.Client{}
  17274. data["psn_no"] = his.PsnNo
  17275. data["mdtrt_id"] = his.Number
  17276. data["opter"] = roles.UserName
  17277. data["org_name"] = miConfig.OrgName
  17278. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17279. data["doctor_id"] = doctor_info.DoctorNumber
  17280. data["doctor_name"] = doctor_info.UserName
  17281. data["department"] = department.Name
  17282. data["fixmedins_code"] = miConfig.Code
  17283. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17284. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17285. data["secret_key"] = miConfig.SecretKey
  17286. data["sick_code"] = sickConfig.CountryCode
  17287. data["sick_name"] = sickConfig.ClassName
  17288. data["dept"] = strconv.FormatInt(department.ID, 10)
  17289. data["config"] = config
  17290. data["begin_time"] = begin_time
  17291. bytesData, _ := json.Marshal(data)
  17292. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  17293. resp, _ := client.Do(req)
  17294. defer resp.Body.Close()
  17295. body, ioErr := ioutil.ReadAll(resp.Body)
  17296. if ioErr != nil {
  17297. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17299. return
  17300. }
  17301. var respJSON map[string]interface{}
  17302. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17305. return
  17306. }
  17307. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17308. userJSONBytes, _ := json.Marshal(respJSON)
  17309. fmt.Println("log")
  17310. fmt.Println(string(userJSONBytes))
  17311. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17312. utils.ErrorLog("解析失败:%v", err)
  17313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17314. return
  17315. }
  17316. } else if miConfig.MdtrtareaAdmvs == "420200" {
  17317. data := make(map[string]interface{})
  17318. client := &http.Client{}
  17319. data["psn_no"] = his.PsnNo
  17320. data["mdtrt_id"] = his.Number
  17321. data["opter"] = roles.UserName
  17322. data["org_name"] = miConfig.OrgName
  17323. if reg_type == 11 && his.Insutype == "390"{
  17324. data["med_type"] = "110104"
  17325. } else {
  17326. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17327. }
  17328. data["doctor_id"] = doctor_info.DoctorNumber
  17329. data["doctor_name"] = doctor_info.UserName
  17330. data["department"] = department.Name
  17331. data["fixmedins_code"] = miConfig.Code
  17332. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17333. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17334. data["secret_key"] = miConfig.SecretKey
  17335. data["sick_code"] = sickConfig.CountryCode
  17336. data["sick_name"] = sickConfig.ClassName
  17337. data["dept"] = strconv.FormatInt(department.ID, 10)
  17338. data["config"] = config
  17339. data["begin_time"] = begin_time
  17340. bytesData, _ := json.Marshal(data)
  17341. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  17342. resp, _ := client.Do(req)
  17343. defer resp.Body.Close()
  17344. body, ioErr := ioutil.ReadAll(resp.Body)
  17345. if ioErr != nil {
  17346. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17348. return
  17349. }
  17350. var respJSON map[string]interface{}
  17351. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17352. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17354. return
  17355. }
  17356. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17357. userJSONBytes, _ := json.Marshal(respJSON)
  17358. fmt.Println("log")
  17359. fmt.Println(string(userJSONBytes))
  17360. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17361. utils.ErrorLog("解析失败:%v", err)
  17362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17363. return
  17364. }
  17365. }else if miConfig.MdtrtareaAdmvs == "421182" {
  17366. data := make(map[string]interface{})
  17367. client := &http.Client{}
  17368. data["psn_no"] = his.PsnNo
  17369. data["mdtrt_id"] = his.Number
  17370. data["opter"] = roles.UserName
  17371. data["org_name"] = miConfig.OrgName
  17372. if reg_type == 11 && his.Insutype == "390"{
  17373. data["med_type"] = "110104"
  17374. } else {
  17375. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17376. }
  17377. data["doctor_id"] = doctor_info.DoctorNumber
  17378. data["doctor_name"] = doctor_info.UserName
  17379. data["department"] = department.Name
  17380. data["fixmedins_code"] = miConfig.Code
  17381. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17382. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17383. data["secret_key"] = miConfig.SecretKey
  17384. data["sick_code"] = sickConfig.CountryCode
  17385. data["sick_name"] = sickConfig.ClassName
  17386. data["dept"] = strconv.FormatInt(department.ID, 10)
  17387. data["config"] = config
  17388. data["begin_time"] = begin_time
  17389. bytesData, _ := json.Marshal(data)
  17390. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  17391. resp, _ := client.Do(req)
  17392. defer resp.Body.Close()
  17393. body, ioErr := ioutil.ReadAll(resp.Body)
  17394. if ioErr != nil {
  17395. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17397. return
  17398. }
  17399. var respJSON map[string]interface{}
  17400. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17401. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17403. return
  17404. }
  17405. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17406. userJSONBytes, _ := json.Marshal(respJSON)
  17407. fmt.Println("log")
  17408. fmt.Println(string(userJSONBytes))
  17409. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17410. utils.ErrorLog("解析失败:%v", err)
  17411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17412. return
  17413. }
  17414. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17415. data := make(map[string]interface{})
  17416. client := &http.Client{}
  17417. data["psn_no"] = his.PsnNo
  17418. data["mdtrt_id"] = his.Number
  17419. data["doctor"] = roles.UserName
  17420. data["department"] = department.Name
  17421. data["org_name"] = miConfig.OrgName
  17422. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17423. data["doctor_id"] = doctor_info.DoctorNumber
  17424. data["new_doctor_name"] = doctor_info.UserName
  17425. data["fixmedins_code"] = miConfig.Code
  17426. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17427. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17428. data["secret_key"] = miConfig.SecretKey
  17429. data["sick_code"] = sickConfig.CountryCode
  17430. data["sick_name"] = sickConfig.ClassName
  17431. data["url"] = miConfig.Url
  17432. data["ak"] = miConfig.AccessKey
  17433. data["begin_time"] = begin_time
  17434. data["cainfo"] = miConfig.Cainfo
  17435. data["dept"] = strconv.FormatInt(department.ID, 10)
  17436. data["config"] = config
  17437. bytesData, _ := json.Marshal(data)
  17438. var req *http.Request
  17439. if miConfig.MdtrtareaAdmvs == "320921" {
  17440. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  17441. //api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  17442. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  17443. } else {
  17444. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  17445. }
  17446. resp, _ := client.Do(req)
  17447. defer resp.Body.Close()
  17448. body, ioErr := ioutil.ReadAll(resp.Body)
  17449. if ioErr != nil {
  17450. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17452. return
  17453. }
  17454. var respJSON map[string]interface{}
  17455. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17456. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17458. return
  17459. }
  17460. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17461. userJSONBytes, _ := json.Marshal(respJSON)
  17462. fmt.Println("log")
  17463. fmt.Println(string(userJSONBytes))
  17464. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  17465. utils.ErrorLog("解析失败:%v", err)
  17466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17467. return
  17468. }
  17469. res2.InfRefmsgid = ressix10265.InfRefmsgid
  17470. res2.Output = ressix10265.Output
  17471. res2.ErrMsg = ressix10265.ErrMsg
  17472. res2.Cainfo = ressix10265.Cainfo
  17473. res2.WarnMsg = ressix10265.WarnMsg
  17474. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  17475. res2.Infcode = infocode
  17476. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17477. data := make(map[string]interface{})
  17478. client := &http.Client{}
  17479. data["psn_no"] = his.PsnNo
  17480. data["mdtrt_id"] = his.Number
  17481. data["doctor"] = roles.UserName
  17482. data["department"] = department.Name
  17483. data["org_name"] = miConfig.OrgName
  17484. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17485. data["doctor_id"] = doctor_info.DoctorNumber
  17486. data["new_doctor_name"] = doctor_info.UserName
  17487. data["fixmedins_code"] = miConfig.Code
  17488. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17489. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17490. data["secret_key"] = miConfig.SecretKey
  17491. data["sick_code"] = sickConfig.CountryCode
  17492. data["sick_name"] = sickConfig.ClassName
  17493. data["url"] = miConfig.Url
  17494. data["ak"] = miConfig.AccessKey
  17495. data["begin_time"] = begin_time
  17496. data["cainfo"] = miConfig.Cainfo
  17497. data["dept"] = strconv.FormatInt(department.ID, 10)
  17498. data["config"] = config
  17499. bytesData, _ := json.Marshal(data)
  17500. var req *http.Request
  17501. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  17502. resp, _ := client.Do(req)
  17503. defer resp.Body.Close()
  17504. body, ioErr := ioutil.ReadAll(resp.Body)
  17505. if ioErr != nil {
  17506. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17508. return
  17509. }
  17510. var respJSON map[string]interface{}
  17511. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17512. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17514. return
  17515. }
  17516. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17517. userJSONBytes, _ := json.Marshal(respJSON)
  17518. fmt.Println("log")
  17519. fmt.Println(string(userJSONBytes))
  17520. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  17521. utils.ErrorLog("解析失败:%v", err)
  17522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17523. return
  17524. }
  17525. res2.InfRefmsgid = ressix10265.InfRefmsgid
  17526. res2.Output = ressix10265.Output
  17527. res2.ErrMsg = ressix10265.ErrMsg
  17528. res2.Cainfo = ressix10265.Cainfo
  17529. res2.WarnMsg = ressix10265.WarnMsg
  17530. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  17531. res2.Infcode = infocode
  17532. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17533. result, requestLog, _ = service.FJyb2203(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, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  17534. saveLog(result, requestLog, "2203", "上传就诊信息")
  17535. var respJSON2 map[string]interface{}
  17536. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  17537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17539. return
  17540. }
  17541. userJSONBytes2, _ := json.Marshal(respJSON2)
  17542. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  17543. utils.ErrorLog("解析失败:%v", err)
  17544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17545. return
  17546. }
  17547. result2, src_request, _ := service.FJyb2205(his.PsnNo, his.Number, "0000", miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  17548. fmt.Println(result2)
  17549. fmt.Println(src_request)
  17550. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17551. data := make(map[string]interface{})
  17552. client := &http.Client{}
  17553. data["psn_no"] = his.PsnNo
  17554. data["mdtrt_id"] = his.Number
  17555. data["doctor"] = roles.UserName
  17556. data["department"] = department.Name
  17557. data["org_name"] = miConfig.OrgName
  17558. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17559. data["doctor_id"] = doctor_info.DoctorNumber
  17560. data["new_doctor_name"] = doctor_info.UserName
  17561. data["fixmedins_code"] = miConfig.Code
  17562. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17563. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17564. data["secret_key"] = miConfig.SecretKey
  17565. data["sick_code"] = sickConfig.CountryCode
  17566. data["sick_name"] = sickConfig.ClassName
  17567. data["url"] = miConfig.Url
  17568. data["ak"] = miConfig.AccessKey
  17569. data["begin_time"] = begin_time
  17570. data["cainfo"] = miConfig.Cainfo
  17571. data["dept"] = strconv.FormatInt(department.ID, 10)
  17572. data["config"] = config
  17573. bytesData, _ := json.Marshal(data)
  17574. var req *http.Request
  17575. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  17576. resp, _ := client.Do(req)
  17577. defer resp.Body.Close()
  17578. body, ioErr := ioutil.ReadAll(resp.Body)
  17579. if ioErr != nil {
  17580. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17582. return
  17583. }
  17584. var respJSON map[string]interface{}
  17585. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17586. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17588. return
  17589. }
  17590. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17591. userJSONBytes, _ := json.Marshal(respJSON)
  17592. fmt.Println("log")
  17593. fmt.Println(string(userJSONBytes))
  17594. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17595. utils.ErrorLog("解析失败:%v", err)
  17596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17597. return
  17598. }
  17599. } else {
  17600. if miConfig.MdtrtareaAdmvs == "440781" { //
  17601. 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)
  17602. } else {
  17603. if miConfig.Code == "H15049901371" {
  17604. //赤峰地区国家医保医疗类别
  17605. //职工透析:医疗类别选特殊情况门诊990502
  17606. //居民定额血透门慢: 医疗类别选门诊慢病140104
  17607. var med_type string
  17608. if his.Insutype == "390" {
  17609. if reg_type == 14 {
  17610. med_type = "9933"
  17611. } else if reg_type == 11 {
  17612. med_type = "11"
  17613. }
  17614. } else if his.Insutype == "310" {
  17615. if reg_type == 14 {
  17616. med_type = "990502"
  17617. } else if reg_type == 11 {
  17618. med_type = "11"
  17619. }
  17620. }
  17621. 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)
  17622. } else {
  17623. 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, doctor_info.UserName, admin_user_id, roles.UserName)
  17624. }
  17625. }
  17626. saveLog(result, requestLog, "2203", "上传就诊信息")
  17627. var respJSON2 map[string]interface{}
  17628. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  17629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17631. return
  17632. }
  17633. userJSONBytes2, _ := json.Marshal(respJSON2)
  17634. if miConfig.Code == "H15049901371" {
  17635. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  17636. utils.ErrorLog("解析失败:%v", err)
  17637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17638. return
  17639. }
  17640. res2.InfRefmsgid = ressix10265.InfRefmsgid
  17641. res2.Output = ressix10265.Output
  17642. res2.ErrMsg = ressix10265.ErrMsg
  17643. res2.Cainfo = ressix10265.Cainfo
  17644. res2.WarnMsg = ressix10265.WarnMsg
  17645. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  17646. res2.Infcode = infocode
  17647. } else {
  17648. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  17649. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  17650. utils.ErrorLog("解析失败:%v", err)
  17651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17652. return
  17653. }
  17654. res2.Infcode = res3.Infcode
  17655. } else {
  17656. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  17657. utils.ErrorLog("解析失败:%v", err)
  17658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17659. return
  17660. }
  17661. }
  17662. }
  17663. }
  17664. if res2.Infcode != 0 {
  17665. adminUser := c.GetAdminUserInfo()
  17666. errlog := &models.HisOrderError{
  17667. UserOrgId: adminUser.CurrentOrgId,
  17668. Ctime: time.Now().Unix(),
  17669. Mtime: time.Now().Unix(),
  17670. ErrMsg: res2.ErrMsg,
  17671. Status: 1,
  17672. PatientId: id,
  17673. RecordTime: recordDateTime,
  17674. Stage: 3,
  17675. }
  17676. service.CreateErrMsgLog(errlog)
  17677. c.ServeSuccessJSON(map[string]interface{}{
  17678. "failed_code": -10,
  17679. "msg": res2.ErrMsg,
  17680. })
  17681. return
  17682. } else {
  17683. his.Diagnosis = diagnosis_id
  17684. his.SickType = sickConfig.ID
  17685. //var p_type int64
  17686. //if reg_type == 1111 || reg_type == 1112 {
  17687. // p_type = 11
  17688. //
  17689. //}
  17690. his.PType = fmt.Sprintf("%d", reg_type)
  17691. service.UpdateHisPatientThree(&his)
  17692. data := make(map[string]interface{})
  17693. if settle_accounts_type == 1 { //日结
  17694. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  17695. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  17696. } else {
  17697. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  17698. }
  17699. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  17700. data["pre"] = prescriptions
  17701. } else { //月结
  17702. start_time_str := c.GetString("start_time")
  17703. end_time_str := c.GetString("end_time")
  17704. timeLayout := "2006-01-02"
  17705. loc, _ := time.LoadLocation("Local")
  17706. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  17707. if err != nil {
  17708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17709. return
  17710. }
  17711. recordStartTime := theStartTime.Unix()
  17712. start_time = recordStartTime
  17713. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  17714. if err != nil {
  17715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17716. return
  17717. }
  17718. recordEndTime := theEndTime.Unix()
  17719. end_time = recordEndTime
  17720. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  17721. data["pre"] = prescriptions
  17722. }
  17723. timestamp := time.Now().Unix()
  17724. tempTime := time.Unix(timestamp, 0)
  17725. timeFormat := tempTime.Format("20060102150405")
  17726. chrgBchno := rand.Intn(100000) + 10000
  17727. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  17728. strconv.FormatInt(his.PatientId, 10)
  17729. client := &http.Client{}
  17730. data["psn_no"] = his.PsnNo
  17731. data["mdtrt_id"] = his.Number
  17732. data["chrg_bchno"] = chrg_bchno
  17733. data["org_name"] = miConfig.OrgName
  17734. data["doctor"] = doctor_info.UserName
  17735. data["doctor_id"] = doctor_info.DoctorNumber
  17736. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  17737. data["fixmedins_code"] = miConfig.Code
  17738. data["dept_code"] = department.Number
  17739. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17740. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17741. data["secret_key"] = miConfig.SecretKey
  17742. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  17743. data["url"] = miConfig.Url
  17744. data["ak"] = miConfig.AccessKey
  17745. data["new_doctor_name"] = patientPrescription.Doctor
  17746. data["diag_code"] = sickConfig.CountryCode
  17747. data["cainfo"] = miConfig.Cainfo
  17748. data["opter"] = roles.UserName
  17749. var ids []int64
  17750. for _, item := range prescriptions {
  17751. ids = append(ids, item.ID)
  17752. }
  17753. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  17754. if config.IsOpen == 1 { //对接了医保,走医保流程
  17755. var res ResultFour
  17756. var resFour10265 ResultFour10265
  17757. if miConfig.MdtrtareaAdmvs == "421300" {
  17758. bytesData, _ := json.Marshal(data)
  17759. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  17760. resp, _ := client.Do(req)
  17761. defer resp.Body.Close()
  17762. body, ioErr := ioutil.ReadAll(resp.Body)
  17763. if ioErr != nil {
  17764. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17766. return
  17767. }
  17768. var respJSON map[string]interface{}
  17769. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17770. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17772. return
  17773. }
  17774. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17775. userJSONBytes, _ := json.Marshal(respJSON)
  17776. fmt.Println("log")
  17777. fmt.Println(string(userJSONBytes))
  17778. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17779. utils.ErrorLog("解析失败:%v", err)
  17780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17781. return
  17782. }
  17783. } else if miConfig.MdtrtareaAdmvs == "420200" {
  17784. bytesData, _ := json.Marshal(data)
  17785. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  17786. resp, _ := client.Do(req)
  17787. defer resp.Body.Close()
  17788. body, ioErr := ioutil.ReadAll(resp.Body)
  17789. if ioErr != nil {
  17790. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17792. return
  17793. }
  17794. var respJSON map[string]interface{}
  17795. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17798. return
  17799. }
  17800. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17801. userJSONBytes, _ := json.Marshal(respJSON)
  17802. fmt.Println("log")
  17803. fmt.Println(string(userJSONBytes))
  17804. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17805. utils.ErrorLog("解析失败:%v", err)
  17806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17807. return
  17808. }
  17809. } else if miConfig.MdtrtareaAdmvs == "421182" {
  17810. bytesData, _ := json.Marshal(data)
  17811. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  17812. resp, _ := client.Do(req)
  17813. defer resp.Body.Close()
  17814. body, ioErr := ioutil.ReadAll(resp.Body)
  17815. if ioErr != nil {
  17816. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17818. return
  17819. }
  17820. var respJSON map[string]interface{}
  17821. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17822. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17824. return
  17825. }
  17826. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17827. userJSONBytes, _ := json.Marshal(respJSON)
  17828. fmt.Println("log")
  17829. fmt.Println(string(userJSONBytes))
  17830. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17831. utils.ErrorLog("解析失败:%v", err)
  17832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17833. return
  17834. }
  17835. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17836. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  17837. if result3101.Infcode == "0" {
  17838. if len(result3101.Output.Result) > 0 {
  17839. var errMsgs []string
  17840. for _, item := range result3101.Output.Result {
  17841. errMsgs = append(errMsgs, item.VolaCont)
  17842. }
  17843. c.ServeSuccessJSON(map[string]interface{}{
  17844. "failed_code": -10,
  17845. "msg": errMsgs,
  17846. })
  17847. return
  17848. }
  17849. }
  17850. bytesData, _ := json.Marshal(data)
  17851. var req *http.Request
  17852. if miConfig.MdtrtareaAdmvs == "320921" {
  17853. data["diag_code"] =sickConfig.CountryCode
  17854. fmt.Println(data)
  17855. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  17856. } else {
  17857. data["diag_code"] =sickConfig.CountryCode
  17858. fmt.Println(data)
  17859. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  17860. }
  17861. resp, _ := client.Do(req)
  17862. defer resp.Body.Close()
  17863. body, ioErr := ioutil.ReadAll(resp.Body)
  17864. if ioErr != nil {
  17865. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17867. return
  17868. }
  17869. var respJSON map[string]interface{}
  17870. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17873. return
  17874. }
  17875. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17876. userJSONBytes, _ := json.Marshal(respJSON)
  17877. fmt.Println("log")
  17878. fmt.Println(string(userJSONBytes))
  17879. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  17880. utils.ErrorLog("解析失败:%v", err)
  17881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17882. return
  17883. }
  17884. res.InfRefmsgid = resFour10265.InfRefmsgid
  17885. res.Output = resFour10265.Output
  17886. res.ErrMsg = resFour10265.ErrMsg
  17887. res.Cainfo = resFour10265.Cainfo
  17888. res.WarnMsg = resFour10265.WarnMsg
  17889. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  17890. res.Infcode = infocode
  17891. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17892. var pagesize int = 2
  17893. var start int = 1
  17894. var stop int
  17895. var pagecount int
  17896. var curpage int
  17897. var isSuccess bool = true
  17898. data["doctor_id"] = doctor_info.DoctorNumber
  17899. //总页数,向上取整,注意除之前要先转换类型为float64
  17900. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  17901. for curpage = 1; curpage <= pagecount; curpage++ {
  17902. if curpage == 1 {
  17903. start = 1
  17904. } else {
  17905. start = (curpage-1)*pagesize + 1
  17906. }
  17907. stop = curpage * pagesize
  17908. if stop > len(prescriptions) {
  17909. stop = len(prescriptions)
  17910. }
  17911. //var requestLog string
  17912. data["pre"] = prescriptions[start-1 : stop]
  17913. fmt.Println(data["pre"])
  17914. bytesData, _ := json.Marshal(data)
  17915. var req *http.Request
  17916. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  17917. resp, _ := client.Do(req)
  17918. defer resp.Body.Close()
  17919. body, ioErr := ioutil.ReadAll(resp.Body)
  17920. if ioErr != nil {
  17921. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17923. return
  17924. }
  17925. var respJSON map[string]interface{}
  17926. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17929. return
  17930. }
  17931. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17932. userJSONBytes, _ := json.Marshal(respJSON)
  17933. fmt.Println("log")
  17934. fmt.Println(string(userJSONBytes))
  17935. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  17936. utils.ErrorLog("解析失败:%v", err)
  17937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17938. return
  17939. }
  17940. res.InfRefmsgid = resFour10265.InfRefmsgid
  17941. res.Output = resFour10265.Output
  17942. res.ErrMsg = resFour10265.ErrMsg
  17943. res.Cainfo = resFour10265.Cainfo
  17944. res.WarnMsg = resFour10265.WarnMsg
  17945. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  17946. res.Infcode = infocode
  17947. if infocode == 0 {
  17948. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  17949. } else {
  17950. isSuccess = false
  17951. errlog := &models.HisOrderError{
  17952. UserOrgId: adminUser.CurrentOrgId,
  17953. Ctime: time.Now().Unix(),
  17954. Mtime: time.Now().Unix(),
  17955. Number: chrg_bchno,
  17956. ErrMsg: "",
  17957. Status: 1,
  17958. PatientId: id,
  17959. RecordTime: recordDateTime,
  17960. Stage: 4,
  17961. }
  17962. service.CreateErrMsgLog(errlog)
  17963. c.ServeSuccessJSON(map[string]interface{}{
  17964. "failed_code": -10,
  17965. "msg": res.ErrMsg,
  17966. })
  17967. return
  17968. }
  17969. }
  17970. if isSuccess {
  17971. res.Infcode = 0
  17972. }
  17973. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17974. result, request_log, _ := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, doctor_info.DoctorNumber, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode, doctor_info.DoctorNumber)
  17975. var dat map[string]interface{}
  17976. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17977. fmt.Println(dat)
  17978. } else {
  17979. fmt.Println(err)
  17980. }
  17981. saveLog(result, request_log, "2204", "上传费用明细")
  17982. userJSONBytes, _ := json.Marshal(dat)
  17983. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  17984. utils.ErrorLog("解析失败:%v", err)
  17985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17986. return
  17987. }
  17988. res.InfRefmsgid = resFour10265.InfRefmsgid
  17989. res.Output = resFour10265.Output
  17990. res.ErrMsg = resFour10265.ErrMsg
  17991. res.Cainfo = resFour10265.Cainfo
  17992. res.WarnMsg = resFour10265.WarnMsg
  17993. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  17994. res.Infcode = infocode
  17995. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17996. bytesData, _ := json.Marshal(data)
  17997. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  17998. resp, _ := client.Do(req)
  17999. defer resp.Body.Close()
  18000. body, ioErr := ioutil.ReadAll(resp.Body)
  18001. if ioErr != nil {
  18002. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18004. return
  18005. }
  18006. var respJSON map[string]interface{}
  18007. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18008. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18010. return
  18011. }
  18012. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18013. userJSONBytes, _ := json.Marshal(respJSON)
  18014. fmt.Println("log")
  18015. fmt.Println(string(userJSONBytes))
  18016. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18017. utils.ErrorLog("解析失败:%v", err)
  18018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18019. return
  18020. }
  18021. } else {
  18022. if miConfig.Code == "H15049901371" {
  18023. 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, doctor_info.DoctorNumber, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), patientPrescription.DoctorId, sickConfig.CountryCode, admin_user_id)
  18024. var dat map[string]interface{}
  18025. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18026. fmt.Println(dat)
  18027. } else {
  18028. fmt.Println(err)
  18029. }
  18030. saveLog(result, request_log, "2204", "上传费用明细")
  18031. userJSONBytes, _ := json.Marshal(dat)
  18032. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  18033. utils.ErrorLog("解析失败:%v", err)
  18034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18035. return
  18036. }
  18037. res.InfRefmsgid = resFour10265.InfRefmsgid
  18038. res.Output = resFour10265.Output
  18039. res.ErrMsg = resFour10265.ErrMsg
  18040. res.Cainfo = resFour10265.Cainfo
  18041. res.WarnMsg = resFour10265.WarnMsg
  18042. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  18043. res.Infcode = infocode
  18044. } else {
  18045. 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, admin_user_id)
  18046. var dat map[string]interface{}
  18047. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18048. fmt.Println(dat)
  18049. } else {
  18050. fmt.Println(err)
  18051. }
  18052. saveLog(result, request_log, "2204", "上传费用明细")
  18053. userJSONBytes, _ := json.Marshal(dat)
  18054. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18055. utils.ErrorLog("解析失败:%v", err)
  18056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18057. return
  18058. }
  18059. }
  18060. }
  18061. if res.Infcode == 0 {
  18062. order := &models.HisOrder{
  18063. UserOrgId: adminUser.CurrentOrgId,
  18064. HisPatientId: his.ID,
  18065. PatientId: his.PatientId,
  18066. SettleAccountsDate: recordDateTime,
  18067. MdtrtId: his.Number,
  18068. PsnNo: his.PsnNo,
  18069. MedType: strconv.FormatInt(reg_type, 10),
  18070. Ctime: time.Now().Unix(),
  18071. Mtime: time.Now().Unix(),
  18072. Status: 1,
  18073. Number: chrg_bchno,
  18074. Infcode: res.Infcode,
  18075. WarnMsg: res.WarnMsg,
  18076. Cainfo: res.Cainfo,
  18077. ErrMsg: res.ErrMsg,
  18078. RespondTime: res.RefmsgTime,
  18079. InfRefmsgid: res.InfRefmsgid,
  18080. OrderStatus: 1,
  18081. PayWay: pay_way,
  18082. PayWays: pay_ways,
  18083. OthDesc: oth_desc,
  18084. PayPrice: pay_price,
  18085. PayCardNo: pay_card_no,
  18086. DiscountPrice: discount_price,
  18087. PreferentialPrice: preferential_price,
  18088. RealityPrice: reality_price,
  18089. FoundPrice: found_price,
  18090. MedicalInsurancePrice: medical_insurance_price,
  18091. PrivatePrice: private_price,
  18092. IsMedicineInsurance: 1,
  18093. SettleType: settle_accounts_type,
  18094. SettleStartTime: start_time,
  18095. SettleEndTime: end_time,
  18096. Creator: roles.AdminUserId,
  18097. Modify: roles.AdminUserId,
  18098. FaPiaoNumber: fapiao_number,
  18099. FaPiaoCode: fapiao_code,
  18100. PType: 2,
  18101. Diagnosis: diagnosis_id,
  18102. CashPay: cash_pay,
  18103. WechatPay: wechat_pay,
  18104. AliPay: ali_pay,
  18105. JifenPay: jifen_pay,
  18106. BandCardPay: band_card_pay,
  18107. }
  18108. err = service.CreateOrder(order)
  18109. if err != nil {
  18110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  18111. return
  18112. }
  18113. for _, item := range res.Output.Result {
  18114. temp := strings.Split(item.FeedetlSn, "-")
  18115. var advice_id int64 = 0
  18116. var project_id int64 = 0
  18117. var types int64 = 0
  18118. id, _ := strconv.ParseInt(temp[2], 10, 64)
  18119. types, _ = strconv.ParseInt(temp[1], 10, 64)
  18120. if temp[1] == "1" {
  18121. advice_id = id
  18122. project_id = 0
  18123. } else if temp[1] == "2" {
  18124. advice_id = 0
  18125. project_id = id
  18126. }
  18127. if item.MedChrgitmType == "9" {
  18128. item.MedChrgitmType = "09"
  18129. }
  18130. info := &models.HisOrderInfo{
  18131. OrderNumber: order.Number,
  18132. FeedetlSn: item.FeedetlSn,
  18133. UploadDate: time.Now().Unix(),
  18134. AdviceId: advice_id,
  18135. DetItemFeeSumamt: item.DetItemFeeSumamt,
  18136. Cnt: item.Cnt,
  18137. Pric: float64(item.Pric),
  18138. PatientId: his.PatientId,
  18139. PricUplmtAmt: item.PricUplmtAmt,
  18140. SelfpayProp: item.SelfpayProp,
  18141. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  18142. OverlmtAmt: item.OverlmtAmt,
  18143. PreselfpayAmt: item.PreselfpayAmt,
  18144. BasMednFlag: item.BasMednFlag,
  18145. MedChrgitmType: item.MedChrgitmType,
  18146. HiNegoDrugFlag: item.HiNegoDrugFlag,
  18147. Status: 1,
  18148. Memo: item.Memo,
  18149. Mtime: time.Now().Unix(),
  18150. InscpScpAmt: item.InscpScpAmt,
  18151. DrtReimFlag: item.DrtReimFlag,
  18152. Ctime: time.Now().Unix(),
  18153. ListSpItemFlag: item.ListSpItemFlag,
  18154. ChldMedcFlag: item.ChldMedcFlag,
  18155. LmtUsedFlag: item.LmtUsedFlag,
  18156. ChrgitmLv: item.ChrgitmLv,
  18157. UserOrgId: adminUser.CurrentOrgId,
  18158. HisPatientId: his.ID,
  18159. OrderId: order.ID,
  18160. ProjectId: project_id,
  18161. Type: types,
  18162. }
  18163. service.CreateOrderInfo(info)
  18164. }
  18165. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  18166. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  18167. var total float64
  18168. for _, item := range prescriptions {
  18169. if item.Type == 1 { //药品
  18170. for _, subItem := range item.HisDoctorAdviceInfo {
  18171. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  18172. total_one := price * subItem.PrescribingNumber
  18173. total = total + total_one
  18174. }
  18175. }
  18176. if item.Type == 2 { //项目
  18177. for _, subItem := range item.HisPrescriptionProject {
  18178. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  18179. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  18180. total_one := price * cnt
  18181. total = total + total_one
  18182. }
  18183. }
  18184. }
  18185. allTotal := fmt.Sprintf("%.2f", total)
  18186. //if adminUser.CurrentOrgId == 9919 {
  18187. //
  18188. // allTotal = fmt.Sprintf("%.2f", total)
  18189. //
  18190. //} else {
  18191. //
  18192. // allTotal = fmt.Sprintf("%.2f", total)
  18193. //
  18194. //}
  18195. if res.Infcode == 0 {
  18196. var rf []*ResultFive
  18197. json.Unmarshal([]byte(his.Iinfo), &rf)
  18198. chrg_bchno := chrg_bchno
  18199. cert_no := his.Certno
  18200. var insutypes []string
  18201. var insutype string
  18202. var is390 int = 0
  18203. var is310 int = 0
  18204. for _, item := range rf {
  18205. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18206. insutypes = append(insutypes, item.Insutype)
  18207. }
  18208. }
  18209. if len(insutypes) == 1 {
  18210. insutype = insutypes[0]
  18211. } else {
  18212. for _, i := range insutypes {
  18213. if i == "390" {
  18214. is390 = 1
  18215. }
  18216. if i == "310" {
  18217. is310 = 1
  18218. }
  18219. }
  18220. }
  18221. if is390 == 1 {
  18222. insutype = "390"
  18223. }
  18224. if is310 == 1 {
  18225. insutype = "310"
  18226. }
  18227. if len(insutypes) == 0 {
  18228. insutype = "310"
  18229. }
  18230. if len(insutypes) == 2 {
  18231. insutype = strconv.FormatInt(his.SocialType, 10)
  18232. }
  18233. insutype = strconv.FormatInt(his.SocialType, 10)
  18234. //insutype = "390"
  18235. if his.IdCardType == 1 {
  18236. // cert_no = his.MedicalInsuranceNumber
  18237. cert_no = his.Certno
  18238. } else {
  18239. cert_no = his.Certno
  18240. }
  18241. var res ResultSeven
  18242. var resSeven10265 ResultSeven10265
  18243. var gzresSeven10265Two GZResultSeven10265Two
  18244. var src_resquest string
  18245. var result2 string
  18246. if miConfig.MdtrtareaAdmvs == "421300" {
  18247. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18248. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18249. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18250. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18251. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18252. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18253. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  18254. resp, requestErr := http.Get(api)
  18255. if requestErr != nil {
  18256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18257. return
  18258. }
  18259. body, ioErr := ioutil.ReadAll(resp.Body)
  18260. if ioErr != nil {
  18261. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18263. return
  18264. }
  18265. var respJSON map[string]interface{}
  18266. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18269. return
  18270. }
  18271. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18272. result, _ := json.Marshal(respJSON)
  18273. if miConfig.Code == "H15049901371" {
  18274. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  18275. utils.ErrorLog("解析失败:%v", err)
  18276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18277. return
  18278. }
  18279. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18280. res.Output = resSeven10265.Output
  18281. res.ErrMsg = resSeven10265.ErrMsg
  18282. res.Cainfo = resSeven10265.Cainfo
  18283. res.WarnMsg = resSeven10265.WarnMsg
  18284. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18285. res.Infcode = infocode
  18286. } else {
  18287. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18288. utils.ErrorLog("解析失败:%v", err)
  18289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18290. return
  18291. }
  18292. }
  18293. } else if miConfig.MdtrtareaAdmvs == "420200" {
  18294. if reg_type == 11 && his.Insutype == "390" {
  18295. reg_type = 110104
  18296. }
  18297. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18298. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18299. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18300. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18301. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18302. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18303. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  18304. resp, requestErr := http.Get(api)
  18305. if requestErr != nil {
  18306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18307. return
  18308. }
  18309. body, ioErr := ioutil.ReadAll(resp.Body)
  18310. if ioErr != nil {
  18311. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18313. return
  18314. }
  18315. var respJSON map[string]interface{}
  18316. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18317. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18319. return
  18320. }
  18321. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18322. result, _ := json.Marshal(respJSON)
  18323. if miConfig.Code == "H15049901371" {
  18324. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  18325. utils.ErrorLog("解析失败:%v", err)
  18326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18327. return
  18328. }
  18329. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18330. res.Output = resSeven10265.Output
  18331. res.ErrMsg = resSeven10265.ErrMsg
  18332. res.Cainfo = resSeven10265.Cainfo
  18333. res.WarnMsg = resSeven10265.WarnMsg
  18334. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18335. res.Infcode = infocode
  18336. } else {
  18337. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18338. utils.ErrorLog("解析失败:%v", err)
  18339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18340. return
  18341. }
  18342. }
  18343. } else if miConfig.MdtrtareaAdmvs == "421182" {
  18344. if reg_type == 11 && his.Insutype == "390" {
  18345. reg_type = 110104
  18346. }
  18347. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18348. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18349. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18350. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18351. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18352. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18353. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  18354. resp, requestErr := http.Get(api)
  18355. if requestErr != nil {
  18356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18357. return
  18358. }
  18359. body, ioErr := ioutil.ReadAll(resp.Body)
  18360. if ioErr != nil {
  18361. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18363. return
  18364. }
  18365. var respJSON map[string]interface{}
  18366. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18369. return
  18370. }
  18371. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18372. result, _ := json.Marshal(respJSON)
  18373. if miConfig.Code == "H15049901371" {
  18374. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  18375. utils.ErrorLog("解析失败:%v", err)
  18376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18377. return
  18378. }
  18379. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18380. res.Output = resSeven10265.Output
  18381. res.ErrMsg = resSeven10265.ErrMsg
  18382. res.Cainfo = resSeven10265.Cainfo
  18383. res.WarnMsg = resSeven10265.WarnMsg
  18384. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18385. res.Infcode = infocode
  18386. } else {
  18387. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18388. utils.ErrorLog("解析失败:%v", err)
  18389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18390. return
  18391. }
  18392. }
  18393. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18394. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  18395. if result3101.Infcode == "0" {
  18396. if len(result3101.Output.Result) > 0 {
  18397. var errMsgs []string
  18398. for _, item := range result3101.Output.Result {
  18399. errMsgs = append(errMsgs, item.VolaCont)
  18400. }
  18401. c.ServeSuccessJSON(map[string]interface{}{
  18402. "failed_code": -10,
  18403. "msg": errMsgs,
  18404. })
  18405. return
  18406. } else {
  18407. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  18408. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  18409. bas := strings.Split(psn_info.CardInfo, "|")
  18410. if his.IdCardType == 1 {
  18411. cert_no = bas[2]
  18412. } else if his.IdCardType == 3 {
  18413. cert_no = his.Certno
  18414. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  18415. } else if his.IdCardType == 4 {
  18416. cert_no = his.Certno
  18417. psn_info.VerifyNumber = psn_info.VerifyNumber
  18418. }
  18419. var api string
  18420. if miConfig.MdtrtareaAdmvs == "320921" {
  18421. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18422. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18423. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18424. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18425. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18426. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18427. "&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 + "&mdtrt_grp_type=" + his.MdtrtGrpType
  18428. } else {
  18429. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18430. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18431. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18432. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18433. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18434. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18435. "&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 + "&mdtrt_grp_type=" + his.MdtrtGrpType
  18436. }
  18437. resp, requestErr := http.Get(api)
  18438. if requestErr != nil {
  18439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18440. return
  18441. }
  18442. body, ioErr := ioutil.ReadAll(resp.Body)
  18443. if ioErr != nil {
  18444. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18446. return
  18447. }
  18448. var respJSON map[string]interface{}
  18449. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18450. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18452. return
  18453. }
  18454. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18455. result, _ := json.Marshal(respJSON)
  18456. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  18457. utils.ErrorLog("解析失败:%v", err)
  18458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18459. return
  18460. }
  18461. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18462. res.Output = resSeven10265.Output
  18463. res.ErrMsg = resSeven10265.ErrMsg
  18464. res.Cainfo = resSeven10265.Cainfo
  18465. res.WarnMsg = resSeven10265.WarnMsg
  18466. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18467. res.Infcode = infocode
  18468. }
  18469. }
  18470. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18471. psn_info, _ := service.GetPsnByPatientId(id)
  18472. var verify_number string
  18473. if psn_info.IdCardType == 4 {
  18474. verify_number = psn_info.VerifyNumber
  18475. } else if psn_info.IdCardType == 1 {
  18476. bas := strings.Split(psn_info.CardInfo, "|")
  18477. cardNumber := bas[2]
  18478. verify_number = cardNumber
  18479. } else {
  18480. psn_info.IdCardType = 2
  18481. verify_number = psn_info.Certno
  18482. }
  18483. var api string
  18484. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18485. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18486. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18487. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18488. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18489. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18490. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType + "&verify_number=" + verify_number
  18491. resp, requestErr := http.Get(api)
  18492. if requestErr != nil {
  18493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18494. return
  18495. }
  18496. body, ioErr := ioutil.ReadAll(resp.Body)
  18497. if ioErr != nil {
  18498. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18500. return
  18501. }
  18502. var respJSON map[string]interface{}
  18503. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18504. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18506. return
  18507. }
  18508. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18509. result, _ := json.Marshal(respJSON)
  18510. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  18511. utils.ErrorLog("解析失败:%v", err)
  18512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18513. return
  18514. }
  18515. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18516. res.Output = resSeven10265.Output
  18517. res.ErrMsg = resSeven10265.ErrMsg
  18518. res.Cainfo = resSeven10265.Cainfo
  18519. res.WarnMsg = resSeven10265.WarnMsg
  18520. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18521. res.Infcode = infocode
  18522. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18523. var cert_no string
  18524. if his.IdCardType == 4 {
  18525. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  18526. cert_no = psn_info.VerifyNumber
  18527. result2, src_resquest, _ = service.FJyb2207ForToken(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, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  18528. } else if his.IdCardType == 1 {
  18529. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  18530. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  18531. result2, src_resquest, _ = service.FJyb2207(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, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  18532. }
  18533. //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)
  18534. var dat map[string]interface{}
  18535. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  18536. fmt.Println(dat)
  18537. } else {
  18538. fmt.Println(err)
  18539. }
  18540. saveLog(result2, src_resquest, "2207", "结算")
  18541. userJSONBytes, _ := json.Marshal(dat)
  18542. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  18543. utils.ErrorLog("解析失败:%v", err)
  18544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18545. return
  18546. }
  18547. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18548. res.Output = resSeven10265.Output
  18549. res.ErrMsg = resSeven10265.ErrMsg
  18550. res.Cainfo = resSeven10265.Cainfo
  18551. res.WarnMsg = resSeven10265.WarnMsg
  18552. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18553. res.Infcode = infocode
  18554. } else if miConfig.MdtrtareaAdmvs == "450721" {
  18555. res2 := c.GetoleInfo()
  18556. if res2.Infcode == 0 {
  18557. var result string
  18558. var request_log string
  18559. var result_log string
  18560. if res2.Output.MdtrtCertType == "02" {
  18561. result, request_log, result_log = service.ZHGdyb1101(res2.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res2.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", 1, res2.Output.PsnName, admin_user_id)
  18562. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  18563. } else if res2.Output.MdtrtCertType == "01" {
  18564. result, request_log, result_log = service.ZHGdyb1101d(res2.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res2.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 4, "", 1, res2.Output.PsnName, admin_user_id, res2.Output.EcToken)
  18565. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  18566. } else {
  18567. result, request_log, result_log = service.ZHGdyb1101d(res2.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res2.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, res2.Output.CardSN, 1, res2.Output.PsnName, admin_user_id, res2.Output.CardNo)
  18568. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  18569. }
  18570. var dat map[string]interface{}
  18571. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18572. fmt.Println(dat)
  18573. } else {
  18574. fmt.Println(err)
  18575. }
  18576. userJSONBytes, _ := json.Marshal(dat)
  18577. var res5 ResultTwo
  18578. //var resTwo10265 ResultTwo10265
  18579. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  18580. utils.ErrorLog("解析失败:%v", err)
  18581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18582. return
  18583. }
  18584. if res5.Infcode == -1 {
  18585. c.ServeSuccessJSON(map[string]interface{}{
  18586. "failed_code": -10,
  18587. "msg": res5.ErrMsg,
  18588. })
  18589. return
  18590. }
  18591. var insutypes []string
  18592. var insutype string
  18593. var is390 int = 0
  18594. var is310 int = 0
  18595. for _, item := range res5.Output.Iinfo {
  18596. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18597. insutypes = append(insutypes, item.Insutype)
  18598. }
  18599. }
  18600. if len(insutypes) == 1 {
  18601. insutype = insutypes[0]
  18602. } else {
  18603. for _, i := range insutypes {
  18604. if i == "390" {
  18605. is390 = 1
  18606. }
  18607. if i == "310" {
  18608. is310 = 1
  18609. }
  18610. }
  18611. }
  18612. if is390 == 1 {
  18613. insutype = "390"
  18614. }
  18615. if is310 == 1 {
  18616. insutype = "310"
  18617. }
  18618. if len(insutypes) == 0 {
  18619. insutype = "310"
  18620. }
  18621. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  18622. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  18623. infoStr := string(Iinfos)
  18624. idetinfoStr := string(Idetinfos)
  18625. psn := &models.HisPsn{
  18626. PsnNo: res5.Output.Baseinfo.PsnNo,
  18627. PatientId: id,
  18628. Certno: res5.Output.Baseinfo.Certno,
  18629. Gend: res5.Output.Baseinfo.Gend,
  18630. Naty: res5.Output.Baseinfo.Naty,
  18631. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  18632. PsnName: res5.Output.Baseinfo.PsnName,
  18633. Idetinfo: idetinfoStr,
  18634. Insuinfo: infoStr,
  18635. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  18636. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18637. VerifyNumber: res2.Output.EcToken,
  18638. }
  18639. if res2.Output.MdtrtCertType == "01" {
  18640. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  18641. psn.VerifyNumber = res2.Output.EcToken
  18642. } else if res2.Output.MdtrtCertType == "02" {
  18643. psn.VerifyNumber = res2.Output.CardNo
  18644. } else {
  18645. psn.VerifyNumber = res2.Output.MdtrtCertNo
  18646. }
  18647. service.CreateHisPsn(psn)
  18648. if res2.Output.MdtrtCertType == "01" {
  18649. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  18650. token := res2.Output.EcToken
  18651. 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, 4, acct_used_flag, token, admin_user_id)
  18652. } else if res2.Output.MdtrtCertType == "02" {
  18653. 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, 2, acct_used_flag, "", admin_user_id)
  18654. } else {
  18655. 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, 1, acct_used_flag, "", admin_user_id)
  18656. }
  18657. var dat2 map[string]interface{}
  18658. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  18659. fmt.Println(dat2)
  18660. } else {
  18661. fmt.Println(err)
  18662. }
  18663. userJSONBytes3, _ := json.Marshal(dat2)
  18664. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  18665. utils.ErrorLog("解析失败:%v", err)
  18666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18667. return
  18668. }
  18669. saveLog(result2, src_resquest, "2207", "结算")
  18670. } else {
  18671. c.ServeSuccessJSON(map[string]interface{}{
  18672. "failed_code": -10,
  18673. "msg": res2.ErrMsg,
  18674. })
  18675. return
  18676. }
  18677. } else {
  18678. if miConfig.Code == "H15049901371" {
  18679. //赤峰地区国家医保医疗类别
  18680. //职工透析:医疗类别选特殊情况门诊990502
  18681. //居民定额血透门慢: 医疗类别选门诊慢病140104
  18682. var med_type string
  18683. if his.Insutype == "390" {
  18684. if reg_type == 14 {
  18685. med_type = "9933"
  18686. } else if reg_type == 11 {
  18687. med_type = "11"
  18688. }
  18689. } else if his.Insutype == "310" {
  18690. if reg_type == 14 {
  18691. med_type = "990502"
  18692. } else if reg_type == 11 {
  18693. med_type = "11"
  18694. }
  18695. }
  18696. 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, "", admin_user_id)
  18697. } else {
  18698. if his.IdCardType == 4 {
  18699. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  18700. var token string
  18701. token = psn_info.VerifyNumber
  18702. 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, token, admin_user_id)
  18703. } else {
  18704. if his.IdCardType == 1{
  18705. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  18706. bas := strings.Split(psn_info.CardInfo, "|")
  18707. basNumber := bas[2]
  18708. cert_no = basNumber
  18709. }
  18710. 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, "", admin_user_id)
  18711. }
  18712. }
  18713. //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)
  18714. var dat map[string]interface{}
  18715. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  18716. fmt.Println(dat)
  18717. } else {
  18718. fmt.Println(err)
  18719. }
  18720. saveLog(result2, src_resquest, "2207", "结算")
  18721. userJSONBytes, _ := json.Marshal(dat)
  18722. if miConfig.Code == "H15049901371" {
  18723. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  18724. utils.ErrorLog("解析失败:%v", err)
  18725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18726. return
  18727. }
  18728. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18729. res.Output = resSeven10265.Output
  18730. res.ErrMsg = resSeven10265.ErrMsg
  18731. res.Cainfo = resSeven10265.Cainfo
  18732. res.WarnMsg = resSeven10265.WarnMsg
  18733. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18734. res.Infcode = infocode
  18735. } else {
  18736. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  18737. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  18738. utils.ErrorLog("解析失败:%v", err)
  18739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18740. return
  18741. }
  18742. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  18743. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  18744. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  18745. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  18746. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  18747. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  18748. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  18749. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  18750. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  18751. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  18752. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  18753. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  18754. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  18755. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  18756. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  18757. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  18758. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  18759. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  18760. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  18761. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  18762. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  18763. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  18764. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  18765. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  18766. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  18767. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  18768. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  18769. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  18770. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  18771. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  18772. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  18773. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  18774. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  18775. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  18776. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  18777. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  18778. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  18779. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  18780. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  18781. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  18782. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  18783. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  18784. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  18785. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  18786. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  18787. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  18788. res.ErrMsg = gzresSeven10265Two.ErrMsg
  18789. res.Cainfo = gzresSeven10265Two.Cainfo
  18790. res.WarnMsg = gzresSeven10265Two.WarnMsg
  18791. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  18792. //res.Infcode = infocode
  18793. } else {
  18794. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18795. utils.ErrorLog("解析失败:%v", err)
  18796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18797. return
  18798. }
  18799. }
  18800. }
  18801. }
  18802. if res.Infcode == -1 {
  18803. errlog := &models.HisOrderError{
  18804. UserOrgId: adminUser.CurrentOrgId,
  18805. Ctime: time.Now().Unix(),
  18806. Mtime: time.Now().Unix(),
  18807. Number: chrg_bchno,
  18808. ErrMsg: res.ErrMsg,
  18809. Status: 1,
  18810. PatientId: id,
  18811. RecordTime: recordDateTime,
  18812. Stage: 6,
  18813. }
  18814. service.CreateErrMsgLog(errlog)
  18815. c.ServeSuccessJSON(map[string]interface{}{
  18816. "failed_code": -10,
  18817. "msg": res.ErrMsg,
  18818. })
  18819. return
  18820. } else {
  18821. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  18822. order.OrderStatus = 2
  18823. order.Status = 1
  18824. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  18825. order.SetlId = res.Output.Setlinfo.SetlID
  18826. order.PsnNo = res.Output.Setlinfo.PsnNo
  18827. order.PsnName = res.Output.Setlinfo.PsnName
  18828. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  18829. order.Certno = res.Output.Setlinfo.Certno
  18830. order.Gend = res.Output.Setlinfo.Gend
  18831. order.Naty = res.Output.Setlinfo.Naty
  18832. order.Age = res.Output.Setlinfo.Age
  18833. order.Insutype = res.Output.Setlinfo.Insutype
  18834. order.PsnType = res.Output.Setlinfo.PsnType
  18835. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  18836. order.SetlTime = res.Output.Setlinfo.SetlTime
  18837. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  18838. if res.Output.Setlinfo.MedType == "140101" {
  18839. order.MedType = "14"
  18840. } else {
  18841. if res.Output.Setlinfo.MedType == "110104" {
  18842. order.MedType = "11"
  18843. } else {
  18844. order.MedType = res.Output.Setlinfo.MedType
  18845. }
  18846. }
  18847. if reg_type == 1112 {
  18848. order.MedType = "1112"
  18849. }
  18850. if reg_type == 1111 {
  18851. order.MedType = "1111"
  18852. }
  18853. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  18854. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  18855. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  18856. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  18857. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  18858. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  18859. order.HifpPay = res.Output.Setlinfo.HifpPay
  18860. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  18861. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  18862. order.HifesPay = res.Output.Setlinfo.HifesPay
  18863. order.HifobPay = res.Output.Setlinfo.HifobPay
  18864. order.MafPay = res.Output.Setlinfo.MafPay
  18865. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  18866. order.OthPay = res.Output.Setlinfo.OthPay
  18867. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  18868. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  18869. order.AcctPay = res.Output.Setlinfo.AcctPay
  18870. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  18871. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  18872. order.Balc = res.Output.Setlinfo.Balc
  18873. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  18874. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  18875. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  18876. order.ClrType = res.Output.Setlinfo.ClrType
  18877. order.ClrWay = res.Output.Setlinfo.ClrWay
  18878. order.Creator = order.Creator
  18879. order.Modify = roles.AdminUserId
  18880. order.RequestLog = src_resquest
  18881. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  18882. //detailStr := string(setlDetail)
  18883. //order.SetlDetail = detailStr
  18884. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  18885. err = service.UpDateOrder(order)
  18886. if err == nil {
  18887. //判断是否使用了押金
  18888. if dec_way == "true" {
  18889. tmpstring := strconv.FormatInt(order.ID, 10)
  18890. order.Decimal = decimal
  18891. service.UpDateOrder(order)
  18892. //扣押金
  18893. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  18894. if errmsg != nil {
  18895. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  18896. return
  18897. }
  18898. }
  18899. c.ServeSuccessJSON(map[string]interface{}{
  18900. "msg": "结算成功",
  18901. })
  18902. } else {
  18903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  18904. return
  18905. }
  18906. }
  18907. } else {
  18908. adminUser := c.GetAdminUserInfo()
  18909. errlog := &models.HisOrderError{
  18910. UserOrgId: adminUser.CurrentOrgId,
  18911. Ctime: time.Now().Unix(),
  18912. Mtime: time.Now().Unix(),
  18913. ErrMsg: res.ErrMsg,
  18914. Status: 1,
  18915. PatientId: id,
  18916. RecordTime: recordDateTime,
  18917. Stage: 4,
  18918. }
  18919. service.CreateErrMsgLog(errlog)
  18920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  18921. return
  18922. }
  18923. } else {
  18924. adminUser := c.GetAdminUserInfo()
  18925. errlog := &models.HisOrderError{
  18926. UserOrgId: adminUser.CurrentOrgId,
  18927. Ctime: time.Now().Unix(),
  18928. Mtime: time.Now().Unix(),
  18929. ErrMsg: res.ErrMsg,
  18930. Status: 1,
  18931. PatientId: id,
  18932. RecordTime: recordDateTime,
  18933. Stage: 4,
  18934. }
  18935. service.CreateErrMsgLog(errlog)
  18936. c.ServeSuccessJSON(map[string]interface{}{
  18937. "failed_code": -10,
  18938. "msg": res.ErrMsg,
  18939. })
  18940. return
  18941. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  18942. //return
  18943. }
  18944. }
  18945. }
  18946. } else if tempOrder.ID > 0 {
  18947. if tempOrder.IsPre == 1 {
  18948. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  18949. var rf []*ResultFive
  18950. json.Unmarshal([]byte(his.Iinfo), &rf)
  18951. chrg_bchno := tempOrder.Number
  18952. cert_no := his.Certno
  18953. var insutypes []string
  18954. var insutype string
  18955. var is390 int = 0
  18956. var is310 int = 0
  18957. for _, item := range rf {
  18958. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18959. insutypes = append(insutypes, item.Insutype)
  18960. }
  18961. }
  18962. if len(insutypes) == 1 {
  18963. insutype = insutypes[0]
  18964. } else {
  18965. for _, i := range insutypes {
  18966. if i == "390" {
  18967. is390 = 1
  18968. }
  18969. if i == "310" {
  18970. is310 = 1
  18971. }
  18972. }
  18973. }
  18974. if is390 == 1 {
  18975. insutype = "390"
  18976. }
  18977. if is310 == 1 {
  18978. insutype = "310"
  18979. }
  18980. if len(insutypes) == 0 {
  18981. insutype = "310"
  18982. }
  18983. if len(insutypes) == 2 {
  18984. insutype = strconv.FormatInt(his.SocialType, 10)
  18985. }
  18986. //insutype = "390"
  18987. if his.IdCardType == 1 {
  18988. // cert_no = his.MedicalInsuranceNumber
  18989. cert_no = his.Certno
  18990. } else {
  18991. cert_no = his.Certno
  18992. }
  18993. var res ResultSeven
  18994. var ahres ResultSevenAH
  18995. var resSeven10265 ResultSeven10265
  18996. var gzresSeven10265Two GZResultSeven10265Two
  18997. var src_resquest string
  18998. var result2 string
  18999. if miConfig.MdtrtareaAdmvs == "450721" {
  19000. res2 := c.GetoleInfo()
  19001. if res2.Infcode == 0 {
  19002. var result string
  19003. var request_log string
  19004. var result_log string
  19005. if res2.Output.MdtrtCertType == "02" {
  19006. result, request_log, result_log = service.ZHGdyb1101(res2.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res2.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", 1, res2.Output.PsnName, admin_user_id)
  19007. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19008. } else if res2.Output.MdtrtCertType == "01" {
  19009. result, request_log, result_log = service.ZHGdyb1101d(res2.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res2.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 4, "", 1, res2.Output.PsnName, admin_user_id, res2.Output.EcToken)
  19010. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19011. } else {
  19012. result, request_log, result_log = service.ZHGdyb1101d(res2.Output.CertNo, miConfig.OrgName, roles.UserName, miConfig.Code, res2.Output.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, res2.Output.CardSN, 1, res2.Output.PsnName, admin_user_id, res2.Output.CardNo)
  19013. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19014. }
  19015. var dat map[string]interface{}
  19016. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19017. fmt.Println(dat)
  19018. } else {
  19019. fmt.Println(err)
  19020. }
  19021. userJSONBytes, _ := json.Marshal(dat)
  19022. var res5 ResultTwo
  19023. //var resTwo10265 ResultTwo10265
  19024. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  19025. utils.ErrorLog("解析失败:%v", err)
  19026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19027. return
  19028. }
  19029. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  19030. if res5.Infcode == -1 {
  19031. c.ServeSuccessJSON(map[string]interface{}{
  19032. "failed_code": -10,
  19033. "msg": res5.ErrMsg,
  19034. })
  19035. return
  19036. }
  19037. var insutypes []string
  19038. var insutype string
  19039. var is390 int = 0
  19040. var is310 int = 0
  19041. for _, item := range res5.Output.Iinfo {
  19042. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19043. insutypes = append(insutypes, item.Insutype)
  19044. }
  19045. }
  19046. if len(insutypes) == 1 {
  19047. insutype = insutypes[0]
  19048. } else {
  19049. for _, i := range insutypes {
  19050. if i == "390" {
  19051. is390 = 1
  19052. }
  19053. if i == "310" {
  19054. is310 = 1
  19055. }
  19056. }
  19057. }
  19058. if is390 == 1 {
  19059. insutype = "390"
  19060. }
  19061. if is310 == 1 {
  19062. insutype = "310"
  19063. }
  19064. if len(insutypes) == 0 {
  19065. insutype = "310"
  19066. }
  19067. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  19068. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  19069. infoStr := string(Iinfos)
  19070. idetinfoStr := string(Idetinfos)
  19071. psn := &models.HisPsn{
  19072. PsnNo: res5.Output.Baseinfo.PsnNo,
  19073. PatientId: id,
  19074. Certno: res5.Output.Baseinfo.Certno,
  19075. Gend: res5.Output.Baseinfo.Gend,
  19076. Naty: res5.Output.Baseinfo.Naty,
  19077. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  19078. PsnName: res5.Output.Baseinfo.PsnName,
  19079. Idetinfo: idetinfoStr,
  19080. Insuinfo: infoStr,
  19081. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  19082. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19083. VerifyNumber: res2.Output.EcToken,
  19084. }
  19085. service.CreateHisPsn(psn)
  19086. if res2.Output.MdtrtCertType == "01" {
  19087. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19088. token := res2.Output.EcToken
  19089. result2, src_resquest = service.Gxyb2207(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), 4, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 4, acct_used_flag, token, admin_user_id)
  19090. } else if res2.Output.MdtrtCertType == "02" {
  19091. result2, src_resquest = service.Gxyb2207(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), 2, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 2, acct_used_flag, "", admin_user_id)
  19092. } else {
  19093. result2, src_resquest = service.Gxyb2207(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), 1, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, 1, acct_used_flag, res2.Output.CardNo, admin_user_id)
  19094. }
  19095. var dat2 map[string]interface{}
  19096. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  19097. fmt.Println(dat2)
  19098. } else {
  19099. fmt.Println(err)
  19100. }
  19101. userJSONBytes3, _ := json.Marshal(dat2)
  19102. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  19103. utils.ErrorLog("解析失败:%v", err)
  19104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19105. return
  19106. }
  19107. saveLog(result2, src_resquest, "2207", "结算")
  19108. } else {
  19109. c.ServeSuccessJSON(map[string]interface{}{
  19110. "failed_code": -10,
  19111. "msg": res2.ErrMsg,
  19112. })
  19113. return
  19114. }
  19115. } else if miConfig.MdtrtareaAdmvs == "421300" {
  19116. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19117. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19118. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19119. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19120. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19121. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19122. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19123. resp, requestErr := http.Get(api)
  19124. if requestErr != nil {
  19125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19126. return
  19127. }
  19128. body, ioErr := ioutil.ReadAll(resp.Body)
  19129. if ioErr != nil {
  19130. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19132. return
  19133. }
  19134. var respJSON map[string]interface{}
  19135. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19136. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19138. return
  19139. }
  19140. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19141. result, _ := json.Marshal(respJSON)
  19142. fmt.Println("log")
  19143. fmt.Println(string(result))
  19144. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19145. utils.ErrorLog("解析失败:%v", err)
  19146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19147. return
  19148. }
  19149. } else if miConfig.MdtrtareaAdmvs == "420200" {
  19150. if reg_type == 11 && his.Insutype == "390"{
  19151. reg_type = 110104
  19152. }
  19153. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19154. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19155. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19156. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19157. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19158. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19159. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19160. resp, requestErr := http.Get(api)
  19161. if requestErr != nil {
  19162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19163. return
  19164. }
  19165. body, ioErr := ioutil.ReadAll(resp.Body)
  19166. if ioErr != nil {
  19167. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19169. return
  19170. }
  19171. var respJSON map[string]interface{}
  19172. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19173. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19175. return
  19176. }
  19177. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19178. result, _ := json.Marshal(respJSON)
  19179. fmt.Println("log")
  19180. fmt.Println(string(result))
  19181. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19182. utils.ErrorLog("解析失败:%v", err)
  19183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19184. return
  19185. }
  19186. } else if miConfig.MdtrtareaAdmvs == "421182" {
  19187. if reg_type == 11 && his.Insutype == "390"{
  19188. reg_type = 110104
  19189. }
  19190. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19191. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19192. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19193. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19194. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19195. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19196. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19197. resp, requestErr := http.Get(api)
  19198. if requestErr != nil {
  19199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19200. return
  19201. }
  19202. body, ioErr := ioutil.ReadAll(resp.Body)
  19203. if ioErr != nil {
  19204. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19206. return
  19207. }
  19208. var respJSON map[string]interface{}
  19209. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19210. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19212. return
  19213. }
  19214. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19215. result, _ := json.Marshal(respJSON)
  19216. fmt.Println("log")
  19217. fmt.Println(string(result))
  19218. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19219. utils.ErrorLog("解析失败:%v", err)
  19220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19221. return
  19222. }
  19223. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19224. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  19225. if result3101.Infcode == "0" {
  19226. if len(result3101.Output.Result) > 0 {
  19227. var errMsgs []string
  19228. for _, item := range result3101.Output.Result {
  19229. errMsgs = append(errMsgs, item.VolaCont)
  19230. }
  19231. c.ServeSuccessJSON(map[string]interface{}{
  19232. "failed_code": -10,
  19233. "msg": errMsgs,
  19234. })
  19235. return
  19236. } else {
  19237. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19238. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  19239. bas := strings.Split(psn_info.CardInfo, "|")
  19240. if his.IdCardType == 1 {
  19241. cert_no = bas[2]
  19242. } else if his.IdCardType == 3 {
  19243. cert_no = his.Certno
  19244. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  19245. } else if his.IdCardType == 4 {
  19246. cert_no = his.Certno
  19247. psn_info.VerifyNumber = psn_info.VerifyNumber
  19248. }
  19249. //江苏地区国家医保医疗类别
  19250. //职工透析:医疗类别选特殊情况门诊9933
  19251. //居民血透门慢: 医疗类别选门诊慢病1402
  19252. //var med_type string
  19253. //if his.Insutype == "310" {
  19254. // if reg_type == 14 {
  19255. // med_type = "9933"
  19256. // } else if reg_type == 11 {
  19257. // med_type = "11"
  19258. //
  19259. // }
  19260. //} else if his.Insutype == "390" {
  19261. // if reg_type == 14 {
  19262. // med_type = "1402"
  19263. // } else if reg_type == 11 {
  19264. // med_type = "11"
  19265. // }
  19266. //}
  19267. var api string
  19268. if miConfig.MdtrtareaAdmvs == "320921" {
  19269. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19270. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19271. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19272. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19273. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19274. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19275. "&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 + "&mdtrt_grp_type=" + his.MdtrtGrpType
  19276. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19277. } else {
  19278. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19279. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19280. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19281. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19282. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19283. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19284. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19285. "&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 + "&mdtrt_grp_type=" + his.MdtrtGrpType
  19286. }
  19287. resp, requestErr := http.Get(api)
  19288. if requestErr != nil {
  19289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19290. return
  19291. }
  19292. body, ioErr := ioutil.ReadAll(resp.Body)
  19293. if ioErr != nil {
  19294. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19296. return
  19297. }
  19298. var respJSON map[string]interface{}
  19299. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19300. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19302. return
  19303. }
  19304. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19305. result, _ := json.Marshal(respJSON)
  19306. fmt.Println("log")
  19307. fmt.Println(string(result))
  19308. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19309. utils.ErrorLog("解析失败:%v", err)
  19310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19311. return
  19312. }
  19313. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19314. res.Output = resSeven10265.Output
  19315. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19316. res.ErrMsg = resSeven10265.ErrMsg
  19317. res.Cainfo = resSeven10265.Cainfo
  19318. res.WarnMsg = resSeven10265.WarnMsg
  19319. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19320. res.Infcode = infocode
  19321. }
  19322. }
  19323. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19324. psn_info, _ := service.GetPsnByPatientId(id)
  19325. var verify_number string
  19326. if psn_info.IdCardType == 4 {
  19327. verify_number = psn_info.VerifyNumber
  19328. } else if psn_info.IdCardType == 1 {
  19329. bas := strings.Split(psn_info.CardInfo, "|")
  19330. cardNumber := bas[2]
  19331. verify_number = cardNumber
  19332. } else {
  19333. verify_number = psn_info.Certno
  19334. psn_info.IdCardType = 2
  19335. }
  19336. var api string
  19337. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19338. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19339. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19340. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19341. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  19342. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19343. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType + "&verify_number=" + verify_number
  19344. resp, requestErr := http.Get(api)
  19345. if requestErr != nil {
  19346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19347. return
  19348. }
  19349. body, ioErr := ioutil.ReadAll(resp.Body)
  19350. if ioErr != nil {
  19351. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19353. return
  19354. }
  19355. var respJSON map[string]interface{}
  19356. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19357. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19359. return
  19360. }
  19361. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19362. result, _ := json.Marshal(respJSON)
  19363. fmt.Println("log")
  19364. fmt.Println(string(result))
  19365. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19366. utils.ErrorLog("解析失败:%v", err)
  19367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19368. return
  19369. }
  19370. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19371. res.Output = resSeven10265.Output
  19372. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19373. res.ErrMsg = resSeven10265.ErrMsg
  19374. res.Cainfo = resSeven10265.Cainfo
  19375. res.WarnMsg = resSeven10265.WarnMsg
  19376. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19377. res.Infcode = infocode
  19378. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19379. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19380. var cert_no string
  19381. if his.IdCardType == 1 {
  19382. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  19383. } else {
  19384. cert_no = psn_info.VerifyNumber
  19385. }
  19386. result2, src_resquest, _ = service.FJyb2207(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, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  19387. var dat map[string]interface{}
  19388. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19389. fmt.Println(dat)
  19390. } else {
  19391. fmt.Println(err)
  19392. }
  19393. saveLog(result2, src_resquest, "2207", "结算")
  19394. userJSONBytes, _ := json.Marshal(dat)
  19395. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19396. utils.ErrorLog("解析失败:%v", err)
  19397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19398. return
  19399. }
  19400. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19401. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19402. var cert_no string
  19403. var card_sn string
  19404. if his.IdCardType == 1 {
  19405. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  19406. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19407. bas := strings.Split(psn_info.CardInfo, "|")
  19408. card_sn = bas[3]
  19409. } else if his.IdCardType == 2 {
  19410. cert_no = his.IdCardNo
  19411. } else {
  19412. cert_no = psn_info.VerifyNumber
  19413. }
  19414. var rf []*ResultFive
  19415. json.Unmarshal([]byte(his.Iinfo), &rf)
  19416. var psn_type string
  19417. for _, item := range rf {
  19418. if item.InsuplcAdmdvs == his.InsuplcAdmdvs{
  19419. psn_type =item.PsnType
  19420. }
  19421. }
  19422. result2, src_resquest := service.Jxyb2207(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.IdCardType, acct_used_flag, miConfig.Url, miConfig.AccessKey, cert_no, "",card_sn,his.PsnCertType,his.Certno,psn_type,his.PsnName)
  19423. var dat map[string]interface{}
  19424. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19425. fmt.Println(dat)
  19426. } else {
  19427. fmt.Println(err)
  19428. }
  19429. saveLog(result2, src_resquest, "2207", "结算")
  19430. userJSONBytes, _ := json.Marshal(dat)
  19431. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19432. utils.ErrorLog("解析失败:%v", err)
  19433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19434. return
  19435. }
  19436. } else if miConfig.MdtrtareaAdmvs == "341203" {
  19437. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19438. if his.IdCardType == 1 {
  19439. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  19440. bas := strings.Split(psn_info.CardInfo, "|")
  19441. cert_no = bas[2]
  19442. } else if his.IdCardType == 3 {
  19443. cert_no = his.Certno
  19444. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  19445. } else if his.IdCardType == 4 {
  19446. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  19447. cert_no = his.Certno
  19448. psn_info.VerifyNumber = psn_info.VerifyNumber
  19449. }else{
  19450. cert_no = his.Certno
  19451. psn_info.VerifyNumber = his.Certno
  19452. }
  19453. var api string
  19454. var med_type string
  19455. if his.Insutype == "390" {
  19456. if reg_type == 992102 {
  19457. med_type = "992102"
  19458. }
  19459. if reg_type == 140104 {
  19460. med_type = "140104"
  19461. }
  19462. if reg_type == 14 {
  19463. med_type = "14"
  19464. }
  19465. } else if his.Insutype == "310" {
  19466. if reg_type == 992102 {
  19467. med_type = "992102"
  19468. }
  19469. if reg_type == 14 {
  19470. med_type = "14"
  19471. }
  19472. }
  19473. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19474. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19475. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19476. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19477. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19478. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19479. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + med_type + "&acct_used_flag=" + acct_used_flag + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  19480. resp, requestErr := http.Get(api)
  19481. if requestErr != nil {
  19482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19483. return
  19484. }
  19485. body, ioErr := ioutil.ReadAll(resp.Body)
  19486. if ioErr != nil {
  19487. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19489. return
  19490. }
  19491. var respJSON map[string]interface{}
  19492. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19493. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19495. return
  19496. }
  19497. status := respJSON["data"].(map[string]interface{})["status"].(string)
  19498. if status == "0"{
  19499. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  19500. c.ServeSuccessJSON(map[string]interface{}{
  19501. "failed_code": -10,
  19502. "msg": err_msg,
  19503. })
  19504. return
  19505. }
  19506. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19507. result, _ := json.Marshal(respJSON)
  19508. fmt.Println("log")
  19509. fmt.Println(string(result))
  19510. if err := json.Unmarshal(result, &ahres); err != nil {
  19511. utils.ErrorLog("解析失败:%v", err)
  19512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19513. return
  19514. }
  19515. res.InfRefmsgid = ahres.InfRefmsgid
  19516. timestamp := int64( ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  19517. // 创建对应的Time类型
  19518. t := time.UnixMilli(timestamp)
  19519. // 格式化成指定的日期字符串
  19520. str := t.Format("2006-01-02 15:04:05")
  19521. res.Output.Setlinfo.SetlTime = str
  19522. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  19523. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  19524. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  19525. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  19526. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  19527. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  19528. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  19529. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  19530. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  19531. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  19532. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  19533. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  19534. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  19535. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  19536. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  19537. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  19538. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  19539. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  19540. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  19541. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  19542. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  19543. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  19544. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  19545. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  19546. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  19547. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  19548. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  19549. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  19550. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  19551. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  19552. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  19553. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  19554. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  19555. res.Output.Setlinfo.PoolPropSelfpay= ahres.Output.Setlinfo.PoolPropSelfpay
  19556. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  19557. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  19558. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  19559. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  19560. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  19561. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  19562. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  19563. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  19564. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  19565. res.Output.Setldetail = ahres.Output.Setldetail
  19566. res.ErrMsg = ahres.ErrMsg
  19567. res.Cainfo = ahres.Cainfo
  19568. res.WarnMsg = ahres.WarnMsg
  19569. res.Infcode = ahres.Infcode
  19570. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19571. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19572. var cert_no string
  19573. if his.IdCardType == 1 {
  19574. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  19575. } else if his.IdCardType == 2 {
  19576. cert_no = his.IdCardNo
  19577. } else {
  19578. cert_no = psn_info.VerifyNumber
  19579. }
  19580. result2, src_resquest := service.Hnyb2207(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.IdCardType, acct_used_flag, miConfig.Url, miConfig.AccessKey, cert_no, "")
  19581. var dat map[string]interface{}
  19582. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19583. fmt.Println(dat)
  19584. } else {
  19585. fmt.Println(err)
  19586. }
  19587. saveLog(result2, src_resquest, "2207", "结算")
  19588. userJSONBytes, _ := json.Marshal(dat)
  19589. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19590. utils.ErrorLog("解析失败:%v", err)
  19591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19592. return
  19593. }
  19594. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19595. psn_info, _ := service.GetPsnByPatientId(id)
  19596. var verify_number string
  19597. if psn_info.IdCardType == 4 {
  19598. verify_number = psn_info.VerifyNumber
  19599. } else if psn_info.IdCardType == 1 {
  19600. bas := strings.Split(psn_info.CardInfo, "|")
  19601. cardNumber := bas[2]
  19602. verify_number = cardNumber
  19603. } else {
  19604. verify_number = psn_info.Certno
  19605. psn_info.IdCardType = 2
  19606. }
  19607. var api string
  19608. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19609. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19610. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19611. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19612. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  19613. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19614. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  19615. resp, requestErr := http.Get(api)
  19616. if requestErr != nil {
  19617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19618. return
  19619. }
  19620. body, ioErr := ioutil.ReadAll(resp.Body)
  19621. if ioErr != nil {
  19622. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19624. return
  19625. }
  19626. var respJSON map[string]interface{}
  19627. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19630. return
  19631. }
  19632. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19633. result, _ := json.Marshal(respJSON)
  19634. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19635. utils.ErrorLog("解析失败:%v", err)
  19636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19637. return
  19638. }
  19639. } else {
  19640. var src_resquest string
  19641. if miConfig.Code == "H15049901371" {
  19642. //赤峰地区国家医保医疗类别
  19643. //职工透析:医疗类别选特殊情况门诊990502
  19644. //居民定额血透门慢: 医疗类别选门诊慢病140104
  19645. var med_type string
  19646. if his.Insutype == "390" {
  19647. if reg_type == 14 {
  19648. med_type = "9933"
  19649. } else if reg_type == 11 {
  19650. med_type = "11"
  19651. }
  19652. } else if his.Insutype == "310" {
  19653. if reg_type == 14 {
  19654. med_type = "990502"
  19655. } else if reg_type == 11 {
  19656. med_type = "11"
  19657. }
  19658. }
  19659. 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, "", admin_user_id)
  19660. } else {
  19661. if his.IdCardType == 4 {
  19662. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19663. token := psn_info.VerifyNumber
  19664. 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, token, admin_user_id)
  19665. } else {
  19666. 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, "", admin_user_id)
  19667. }
  19668. }
  19669. var dat map[string]interface{}
  19670. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19671. fmt.Println(dat)
  19672. } else {
  19673. fmt.Println(err)
  19674. }
  19675. saveLog(result2, src_resquest, "2207", "结算")
  19676. userJSONBytes, _ := json.Marshal(dat)
  19677. if miConfig.Code == "H15049901371" {
  19678. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  19679. utils.ErrorLog("解析失败:%v", err)
  19680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19681. return
  19682. }
  19683. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19684. res.Output = resSeven10265.Output
  19685. res.ErrMsg = resSeven10265.ErrMsg
  19686. res.Cainfo = resSeven10265.Cainfo
  19687. res.WarnMsg = resSeven10265.WarnMsg
  19688. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19689. res.Infcode = infocode
  19690. } else {
  19691. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  19692. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  19693. utils.ErrorLog("解析失败:%v", err)
  19694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19695. return
  19696. }
  19697. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  19698. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  19699. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  19700. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  19701. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  19702. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  19703. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  19704. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  19705. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  19706. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19707. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19708. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19709. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19710. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  19711. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  19712. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  19713. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  19714. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  19715. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  19716. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  19717. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  19718. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  19719. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  19720. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  19721. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  19722. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  19723. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  19724. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  19725. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  19726. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  19727. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  19728. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  19729. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  19730. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  19731. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  19732. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  19733. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  19734. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  19735. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19736. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  19737. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  19738. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  19739. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  19740. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  19741. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  19742. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  19743. res.ErrMsg = gzresSeven10265Two.ErrMsg
  19744. res.Cainfo = gzresSeven10265Two.Cainfo
  19745. res.WarnMsg = gzresSeven10265Two.WarnMsg
  19746. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  19747. //res.Infcode = infocode
  19748. } else {
  19749. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19750. utils.ErrorLog("解析失败:%v", err)
  19751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19752. return
  19753. }
  19754. }
  19755. }
  19756. }
  19757. if res.Infcode != 0 {
  19758. errlog := &models.HisOrderError{
  19759. UserOrgId: adminUser.CurrentOrgId,
  19760. Ctime: time.Now().Unix(),
  19761. Mtime: time.Now().Unix(),
  19762. Number: chrg_bchno,
  19763. ErrMsg: res.ErrMsg,
  19764. Status: 1,
  19765. PatientId: id,
  19766. RecordTime: recordDateTime,
  19767. Stage: 6,
  19768. }
  19769. service.CreateErrMsgLog(errlog)
  19770. c.ServeSuccessJSON(map[string]interface{}{
  19771. "failed_code": -10,
  19772. "msg": res.ErrMsg,
  19773. })
  19774. return
  19775. } else {
  19776. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  19777. order.OrderStatus = 2
  19778. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  19779. order.SetlId = res.Output.Setlinfo.SetlID
  19780. order.PsnNo = res.Output.Setlinfo.PsnNo
  19781. order.PsnName = res.Output.Setlinfo.PsnName
  19782. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  19783. order.Certno = res.Output.Setlinfo.Certno
  19784. order.Gend = res.Output.Setlinfo.Gend
  19785. order.Naty = res.Output.Setlinfo.Naty
  19786. order.Age = res.Output.Setlinfo.Age
  19787. order.Insutype = res.Output.Setlinfo.Insutype
  19788. order.PsnType = res.Output.Setlinfo.PsnType
  19789. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  19790. order.SetlTime = res.Output.Setlinfo.SetlTime
  19791. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  19792. order.PayWays = pay_ways
  19793. order.AcctUsedFlag = acct_used_flag
  19794. order.WechatPay = wechat_pay
  19795. order.AliPay = ali_pay
  19796. order.JifenPay = jifen_pay
  19797. order.BandCardPay = band_card_pay
  19798. order.CashPay = cash_pay
  19799. order.OthDesc = oth_desc
  19800. //order.MedType = res.Output.Setlinfo.MedType
  19801. if reg_type == 1112 {
  19802. order.MedType = "1112"
  19803. }
  19804. if reg_type == 1111 {
  19805. order.MedType = "1111"
  19806. }
  19807. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  19808. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  19809. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  19810. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  19811. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  19812. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  19813. order.HifpPay = res.Output.Setlinfo.HifpPay
  19814. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  19815. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  19816. order.HifesPay = res.Output.Setlinfo.HifesPay
  19817. order.HifobPay = res.Output.Setlinfo.HifobPay
  19818. order.MafPay = res.Output.Setlinfo.MafPay
  19819. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  19820. order.OthPay = res.Output.Setlinfo.OthPay
  19821. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  19822. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  19823. order.AcctPay = res.Output.Setlinfo.AcctPay
  19824. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  19825. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  19826. order.Balc = res.Output.Setlinfo.Balc
  19827. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  19828. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  19829. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  19830. order.ClrWay = res.Output.Setlinfo.ClrWay
  19831. order.Creator = order.Creator
  19832. order.ClrType = res.Output.Setlinfo.ClrType
  19833. order.Modify = roles.AdminUserId
  19834. order.RequestLog = src_resquest
  19835. order.Diagnosis = diagnosis_id
  19836. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  19837. detailStr := string(setlDetail)
  19838. order.SetlDetail = detailStr
  19839. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  19840. err = service.UpDateOrder(order)
  19841. if err == nil {
  19842. //判断是否使用了押金
  19843. if dec_way == "true" {
  19844. tmpstring := strconv.FormatInt(order.ID, 10)
  19845. //扣押金
  19846. order.Decimal = decimal
  19847. service.UpDateOrder(order)
  19848. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  19849. if errmsg != nil {
  19850. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  19851. return
  19852. }
  19853. }
  19854. c.ServeSuccessJSON(map[string]interface{}{
  19855. "msg": "结算成功",
  19856. })
  19857. } else {
  19858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  19859. return
  19860. }
  19861. }
  19862. }
  19863. }
  19864. }
  19865. // 上传明细-预结算-
  19866. func (c *HisApiController) GetPreUploadInfo() {
  19867. id, _ := c.GetInt64("id")
  19868. record_time := c.GetString("record_time")
  19869. his_patient_id, _ := c.GetInt64("his_patient_id")
  19870. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  19871. admin_user_id, _ := c.GetInt64("admin_user_id")
  19872. diagnosis_id := c.GetString("diagnosis")
  19873. sick_type, _ := c.GetInt64("sick_type")
  19874. reg_type, _ := c.GetInt64("p_type")
  19875. begin_time := c.GetString("begin_time")
  19876. acct_used_flag := c.GetString("acct_used_flag")
  19877. id_str := c.GetString("ids")
  19878. ids_arr := strings.Split(id_str, ",")
  19879. timeLayout := "2006-01-02"
  19880. loc, _ := time.LoadLocation("Local")
  19881. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  19882. if err != nil {
  19883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  19884. return
  19885. }
  19886. recordDateTime := theTime.Unix()
  19887. adminUser := c.GetAdminUserInfo()
  19888. diagnosis_ids := strings.Split(diagnosis_id, ",")
  19889. var config []*models.HisXtDiagnoseConfig
  19890. for _, item := range diagnosis_ids {
  19891. id, _ := strconv.ParseInt(item, 10, 64)
  19892. diagnosisConfig, _ := service.FindDiagnoseById(id)
  19893. config = append(config, &diagnosisConfig)
  19894. }
  19895. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  19896. sickConfig, _ := service.FindSickById(sick_type)
  19897. var prescriptions []*models.HisPrescription
  19898. var start_time int64
  19899. var end_time int64
  19900. var isSuccess bool = true
  19901. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  19902. fmt.Println(his_patient_id)
  19903. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  19904. timestamp := time.Now().Unix()
  19905. tempTime := time.Unix(timestamp, 0)
  19906. timeFormat := tempTime.Format("20060102150405")
  19907. chrgBchno := rand.Intn(100000) + 10000
  19908. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  19909. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  19910. var patientPrescription models.HisPrescriptionInfo
  19911. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  19912. if patientPrescription.ID == 0 {
  19913. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  19914. }
  19915. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  19916. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  19917. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  19918. strconv.FormatInt(his.PatientId, 10)
  19919. var res2406 Result2406
  19920. //安徽单病种处理
  19921. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  19922. data := make(map[string]interface{})
  19923. client := &http.Client{}
  19924. data["psn_no"] = his.PsnNo
  19925. data["mdtrt_id"] = his.Number
  19926. data["operator"] = roles.UserName
  19927. data["cert_no"] = his.IdCardNo
  19928. data["org_name"] = miConfig.OrgName
  19929. data["psn_name"] = his.Name
  19930. data["ipt_otp_no"] = his.IptOtpNo
  19931. data["ipt_psn_sp_flag_type"] = "0901"
  19932. data["ipt_psn_sp_flag"] ="1"
  19933. data["fixmedins_code"] = miConfig.Code
  19934. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  19935. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  19936. data["url"] = miConfig.Url
  19937. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  19938. bytesData, _ := json.Marshal(data)
  19939. var req *http.Request
  19940. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  19941. req, _ = http.NewRequest("POST", miConfig.SecretKey +"ahyb/2406", bytes.NewReader(bytesData))
  19942. resp, _ := client.Do(req)
  19943. defer resp.Body.Close()
  19944. body, ioErr := ioutil.ReadAll(resp.Body)
  19945. if ioErr != nil {
  19946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19948. return
  19949. }
  19950. var respJSON map[string]interface{}
  19951. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19954. return
  19955. }
  19956. status := respJSON["data"].(map[string]interface{})["status"].(string)
  19957. if status == "0"{
  19958. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  19959. c.ServeSuccessJSON(map[string]interface{}{
  19960. "failed_code": -10,
  19961. "msg": err_msg,
  19962. })
  19963. return
  19964. }
  19965. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19966. userJSONBytes, _ := json.Marshal(respJSON)
  19967. fmt.Println("log")
  19968. fmt.Println(string(userJSONBytes))
  19969. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  19970. utils.ErrorLog("解析失败:%v", err)
  19971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19972. return
  19973. }
  19974. }
  19975. if res2406.Infcode != 0 {
  19976. adminUser := c.GetAdminUserInfo()
  19977. errlog := &models.HisOrderError{
  19978. UserOrgId: adminUser.CurrentOrgId,
  19979. Ctime: time.Now().Unix(),
  19980. Mtime: time.Now().Unix(),
  19981. ErrMsg: res2406.ErrMsg,
  19982. Status: 1,
  19983. PatientId: id,
  19984. RecordTime: recordDateTime,
  19985. Stage: 3,
  19986. }
  19987. service.CreateErrMsgLog(errlog)
  19988. c.ServeSuccessJSON(map[string]interface{}{
  19989. "failed_code": -10,
  19990. "msg": res2406.ErrMsg,
  19991. })
  19992. return
  19993. }
  19994. var res2 ResultSix
  19995. var res3 GZResultSix
  19996. var resSix10265 ResultSix10265
  19997. //var time_stamp string
  19998. if miConfig.MdtrtareaAdmvs == "421300" {
  19999. data := make(map[string]interface{})
  20000. client := &http.Client{}
  20001. data["psn_no"] = his.PsnNo
  20002. data["mdtrt_id"] = his.Number
  20003. data["department"] = department.Name
  20004. data["org_name"] = miConfig.OrgName
  20005. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20006. data["doctor_id"] = doctor_info.DoctorNumber
  20007. data["doctor_name"] = roles.UserName
  20008. data["fixmedins_code"] = miConfig.Code
  20009. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20010. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20011. data["secret_key"] = miConfig.SecretKey
  20012. data["sick_code"] = sickConfig.CountryCode
  20013. data["sick_name"] = sickConfig.ClassName
  20014. data["begin_time"] = begin_time
  20015. data["dept"] = strconv.FormatInt(department.ID, 10)
  20016. data["config"] = config
  20017. data["opter"] = roles.UserName
  20018. fmt.Println(data)
  20019. bytesData, _ := json.Marshal(data)
  20020. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  20021. resp, _ := client.Do(req)
  20022. defer resp.Body.Close()
  20023. body, ioErr := ioutil.ReadAll(resp.Body)
  20024. if ioErr != nil {
  20025. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20027. return
  20028. }
  20029. var respJSON map[string]interface{}
  20030. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20031. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20033. return
  20034. }
  20035. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20036. userJSONBytes, _ := json.Marshal(respJSON)
  20037. fmt.Println("log")
  20038. fmt.Println(string(userJSONBytes))
  20039. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20040. utils.ErrorLog("解析失败:%v", err)
  20041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20042. return
  20043. }
  20044. } else if miConfig.MdtrtareaAdmvs == "420200" {
  20045. data := make(map[string]interface{})
  20046. client := &http.Client{}
  20047. data["psn_no"] = his.PsnNo
  20048. data["mdtrt_id"] = his.Number
  20049. data["department"] = department.Name
  20050. data["org_name"] = miConfig.OrgName
  20051. if reg_type == 11 && his.Insutype == "390" {
  20052. data["med_type"] = "110104"
  20053. } else {
  20054. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20055. }
  20056. data["doctor_id"] = doctor_info.DoctorNumber
  20057. data["doctor_name"] = roles.UserName
  20058. data["fixmedins_code"] = miConfig.Code
  20059. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20060. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20061. data["secret_key"] = miConfig.SecretKey
  20062. data["sick_code"] = sickConfig.CountryCode
  20063. data["sick_name"] = sickConfig.ClassName
  20064. data["begin_time"] = begin_time
  20065. data["dept"] = strconv.FormatInt(department.ID, 10)
  20066. data["config"] = config
  20067. data["opter"] = roles.UserName
  20068. fmt.Println(data)
  20069. bytesData, _ := json.Marshal(data)
  20070. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  20071. resp, _ := client.Do(req)
  20072. defer resp.Body.Close()
  20073. body, ioErr := ioutil.ReadAll(resp.Body)
  20074. if ioErr != nil {
  20075. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20077. return
  20078. }
  20079. var respJSON map[string]interface{}
  20080. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20081. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20083. return
  20084. }
  20085. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20086. userJSONBytes, _ := json.Marshal(respJSON)
  20087. fmt.Println("log")
  20088. fmt.Println(string(userJSONBytes))
  20089. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20090. utils.ErrorLog("解析失败:%v", err)
  20091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20092. return
  20093. }
  20094. } else if miConfig.MdtrtareaAdmvs == "421182" {
  20095. data := make(map[string]interface{})
  20096. client := &http.Client{}
  20097. data["psn_no"] = his.PsnNo
  20098. data["mdtrt_id"] = his.Number
  20099. data["department"] = department.Name
  20100. data["org_name"] = miConfig.OrgName
  20101. if reg_type == 11 && his.Insutype == "390" {
  20102. data["med_type"] = "110104"
  20103. } else {
  20104. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20105. }
  20106. data["doctor_id"] = doctor_info.DoctorNumber
  20107. data["doctor_name"] = roles.UserName
  20108. data["fixmedins_code"] = miConfig.Code
  20109. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20110. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20111. data["secret_key"] = miConfig.SecretKey
  20112. data["sick_code"] = sickConfig.CountryCode
  20113. data["sick_name"] = sickConfig.ClassName
  20114. data["begin_time"] = begin_time
  20115. data["dept"] = strconv.FormatInt(department.ID, 10)
  20116. data["config"] = config
  20117. data["opter"] = roles.UserName
  20118. fmt.Println(data)
  20119. bytesData, _ := json.Marshal(data)
  20120. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  20121. resp, _ := client.Do(req)
  20122. defer resp.Body.Close()
  20123. body, ioErr := ioutil.ReadAll(resp.Body)
  20124. if ioErr != nil {
  20125. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20127. return
  20128. }
  20129. var respJSON map[string]interface{}
  20130. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20131. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20133. return
  20134. }
  20135. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20136. userJSONBytes, _ := json.Marshal(respJSON)
  20137. fmt.Println("log")
  20138. fmt.Println(string(userJSONBytes))
  20139. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20140. utils.ErrorLog("解析失败:%v", err)
  20141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20142. return
  20143. }
  20144. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20145. data := make(map[string]interface{})
  20146. client := &http.Client{}
  20147. data["psn_no"] = his.PsnNo
  20148. data["mdtrt_id"] = his.Number
  20149. data["doctor"] = roles.UserName
  20150. data["department"] = department.Name
  20151. data["org_name"] = miConfig.OrgName
  20152. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20153. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  20154. data["fixmedins_code"] = miConfig.Code
  20155. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20156. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20157. data["secret_key"] = miConfig.SecretKey
  20158. data["sick_code"] = sickConfig.CountryCode
  20159. data["sick_name"] = sickConfig.ClassName
  20160. data["begin_time"] = begin_time
  20161. data["dept"] = strconv.FormatInt(department.ID, 10)
  20162. data["config"] = config
  20163. data["url"] = miConfig.Url
  20164. data["ak"] = miConfig.AccessKey
  20165. data["cainfo"] = miConfig.Cainfo
  20166. bytesData, _ := json.Marshal(data)
  20167. var req *http.Request
  20168. if miConfig.MdtrtareaAdmvs == "320921" {
  20169. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  20170. } else {
  20171. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  20172. }
  20173. resp, _ := client.Do(req)
  20174. defer resp.Body.Close()
  20175. body, ioErr := ioutil.ReadAll(resp.Body)
  20176. if ioErr != nil {
  20177. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20179. return
  20180. }
  20181. var respJSON map[string]interface{}
  20182. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20183. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20185. return
  20186. }
  20187. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  20188. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  20189. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  20190. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20191. userJSONBytes, _ := json.Marshal(respJSON)
  20192. fmt.Println("log")
  20193. fmt.Println(string(userJSONBytes))
  20194. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  20195. utils.ErrorLog("解析失败:%v", err)
  20196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20197. return
  20198. }
  20199. res2.InfRefmsgid = resSix10265.InfRefmsgid
  20200. res2.Output = resSix10265.Output
  20201. res2.ErrMsg = resSix10265.ErrMsg
  20202. res2.Cainfo = resSix10265.Cainfo
  20203. res2.WarnMsg = resSix10265.WarnMsg
  20204. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  20205. res2.Infcode = infocode
  20206. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20207. data := make(map[string]interface{})
  20208. client := &http.Client{}
  20209. data["psn_no"] = his.PsnNo
  20210. data["mdtrt_id"] = his.Number
  20211. data["doctor"] = roles.UserName
  20212. data["department"] = department.Name
  20213. data["org_name"] = miConfig.OrgName
  20214. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20215. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  20216. data["fixmedins_code"] = miConfig.Code
  20217. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20218. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20219. data["secret_key"] = miConfig.SecretKey
  20220. data["sick_code"] = sickConfig.CountryCode
  20221. data["sick_name"] = sickConfig.ClassName
  20222. data["begin_time"] = begin_time
  20223. data["dept"] = strconv.FormatInt(department.ID, 10)
  20224. data["config"] = config
  20225. //data["url"] = miConfig.Url
  20226. //data["ak"] = miConfig.AccessKey
  20227. data["cainfo"] = miConfig.Cainfo
  20228. fmt.Println(data)
  20229. bytesData, _ := json.Marshal(data)
  20230. var req *http.Request
  20231. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  20232. resp, _ := client.Do(req)
  20233. defer resp.Body.Close()
  20234. body, ioErr := ioutil.ReadAll(resp.Body)
  20235. if ioErr != nil {
  20236. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20238. return
  20239. }
  20240. var respJSON map[string]interface{}
  20241. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20242. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20244. return
  20245. }
  20246. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  20247. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  20248. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  20249. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20250. userJSONBytes, _ := json.Marshal(respJSON)
  20251. fmt.Println("log")
  20252. fmt.Println(string(userJSONBytes))
  20253. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  20254. utils.ErrorLog("解析失败:%v", err)
  20255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20256. return
  20257. }
  20258. res2.InfRefmsgid = resSix10265.InfRefmsgid
  20259. res2.Output = resSix10265.Output
  20260. res2.ErrMsg = resSix10265.ErrMsg
  20261. res2.Cainfo = resSix10265.Cainfo
  20262. res2.WarnMsg = resSix10265.WarnMsg
  20263. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  20264. res2.Infcode = infocode
  20265. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20266. result, requestLog, _ := service.FJyb2203(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, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  20267. saveLog(result, requestLog, "2203", "上传就诊信息")
  20268. var respJSON2 map[string]interface{}
  20269. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  20270. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20272. return
  20273. }
  20274. userJSONBytes2, _ := json.Marshal(respJSON2)
  20275. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  20276. utils.ErrorLog("解析失败:%v", err)
  20277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20278. return
  20279. }
  20280. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20281. var result string
  20282. var requestLog string
  20283. result, requestLog = service.Jxyb2203A(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, miConfig.Url, miConfig.AccessKey, "")
  20284. saveLog(result, requestLog, "2203", "上传就诊信息")
  20285. var respJSON2 map[string]interface{}
  20286. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  20287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20289. return
  20290. }
  20291. userJSONBytes2, _ := json.Marshal(respJSON2)
  20292. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  20293. utils.ErrorLog("解析失败:%v", err)
  20294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20295. return
  20296. }
  20297. } else if miConfig.MdtrtareaAdmvs == "341203" {
  20298. data := make(map[string]interface{})
  20299. client := &http.Client{}
  20300. data["psn_no"] = his.PsnNo
  20301. data["mdtrt_id"] = his.Number
  20302. data["operator"] = roles.UserName
  20303. data["department"] = department.Name
  20304. data["org_name"] = miConfig.OrgName
  20305. var med_type string
  20306. if his.Insutype == "390" {
  20307. if reg_type == 992102 {
  20308. med_type = "992102"
  20309. data["sick_code"] = "ZDZ940"
  20310. data["sick_name"] = "慢性肾衰竭"
  20311. }
  20312. if reg_type == 140104 {
  20313. med_type = "140104"
  20314. data["sick_code"] = sickConfig.CountryCode
  20315. data["sick_name"] = sickConfig.ClassName
  20316. }
  20317. if reg_type == 14 {
  20318. med_type = "140104"
  20319. data["sick_code"] = sickConfig.CountryCode
  20320. data["sick_name"] = sickConfig.ClassName
  20321. }
  20322. } else if his.Insutype == "310" {
  20323. if reg_type == 992102 {
  20324. med_type = "992102"
  20325. data["sick_code"] = "ZDZ940"
  20326. data["sick_name"] = "慢性肾衰竭"
  20327. }
  20328. if reg_type == 140104 {
  20329. med_type = "140104"
  20330. data["sick_code"] = sickConfig.CountryCode
  20331. data["sick_name"] = sickConfig.ClassName
  20332. }
  20333. if reg_type == 14 {
  20334. med_type = "14"
  20335. data["sick_code"] = sickConfig.CountryCode
  20336. data["sick_name"] = sickConfig.ClassName
  20337. }
  20338. }
  20339. data["med_type"] = med_type
  20340. data["doctor_number"] = doctor_info.DoctorNumber
  20341. data["doctor_name"] = doctor_info.UserName
  20342. data["fixmedins_code"] = miConfig.Code
  20343. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20344. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20345. data["secret_key"] = miConfig.SecretKey
  20346. data["begin_time"] = begin_time
  20347. data["dept"] = strconv.FormatInt(department.ID, 10)
  20348. data["config"] = config
  20349. data["url"] = miConfig.Url
  20350. data["ak"] = miConfig.AccessKey
  20351. data["cainfo"] = miConfig.Cainfo
  20352. bytesData, _ := json.Marshal(data)
  20353. var req *http.Request
  20354. req, _ = http.NewRequest("POST", miConfig.SecretKey +"ahyb/2203", bytes.NewReader(bytesData))
  20355. resp, _ := client.Do(req)
  20356. defer resp.Body.Close()
  20357. body, ioErr := ioutil.ReadAll(resp.Body)
  20358. if ioErr != nil {
  20359. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20361. return
  20362. }
  20363. var respJSON map[string]interface{}
  20364. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20367. return
  20368. }
  20369. status := respJSON["data"].(map[string]interface{})["status"].(string)
  20370. if status == "0"{
  20371. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  20372. c.ServeSuccessJSON(map[string]interface{}{
  20373. "failed_code": -10,
  20374. "msg": err_msg,
  20375. })
  20376. return
  20377. }
  20378. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20379. userJSONBytes, _ := json.Marshal(respJSON)
  20380. fmt.Println("log")
  20381. fmt.Println(string(userJSONBytes))
  20382. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20383. utils.ErrorLog("解析失败:%v", err)
  20384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20385. return
  20386. }
  20387. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20388. var result string
  20389. var requestLog string
  20390. result, requestLog = service.Hnyb2203A(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, miConfig.Url, miConfig.AccessKey, "")
  20391. saveLog(result, requestLog, "2203", "上传就诊信息")
  20392. var respJSON2 map[string]interface{}
  20393. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  20394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20396. return
  20397. }
  20398. userJSONBytes2, _ := json.Marshal(respJSON2)
  20399. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  20400. utils.ErrorLog("解析失败:%v", err)
  20401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20402. return
  20403. }
  20404. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20405. data := make(map[string]interface{})
  20406. client := &http.Client{}
  20407. data["psn_no"] = his.PsnNo
  20408. data["mdtrt_id"] = his.Number
  20409. data["doctor"] = roles.UserName
  20410. data["department"] = department.Name
  20411. data["org_name"] = miConfig.OrgName
  20412. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20413. data["doctor_id"] = doctor_info.DoctorNumber
  20414. data["fixmedins_code"] = miConfig.Code
  20415. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20416. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20417. data["secret_key"] = miConfig.SecretKey
  20418. data["sick_code"] = sickConfig.CountryCode
  20419. data["sick_name"] = sickConfig.ClassName
  20420. data["begin_time"] = begin_time
  20421. data["new_doctor_name"] = doctor_info.UserName
  20422. data["dept"] = strconv.FormatInt(department.ID, 10)
  20423. data["config"] = config
  20424. bytesData, _ := json.Marshal(data)
  20425. var req *http.Request
  20426. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  20427. resp, _ := client.Do(req)
  20428. defer resp.Body.Close()
  20429. body, ioErr := ioutil.ReadAll(resp.Body)
  20430. if ioErr != nil {
  20431. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20433. return
  20434. }
  20435. var respJSON map[string]interface{}
  20436. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20437. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20439. return
  20440. }
  20441. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20442. userJSONBytes, _ := json.Marshal(respJSON)
  20443. fmt.Println("log")
  20444. fmt.Println(string(userJSONBytes))
  20445. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20446. utils.ErrorLog("解析失败:%v", err)
  20447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20448. return
  20449. }
  20450. } else {
  20451. var result string
  20452. var requestLog string
  20453. if miConfig.MdtrtareaAdmvs == "440781" { //
  20454. 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)
  20455. } else {
  20456. if miConfig.Code == "H15049901371" {
  20457. //赤峰地区国家医保医疗类别
  20458. //职工透析:医疗类别选特殊情况门诊990502
  20459. //居民定额血透门慢: 医疗类别选门诊慢病140104
  20460. var med_type string
  20461. if his.Insutype == "390" {
  20462. if reg_type == 14 {
  20463. med_type = "9933"
  20464. } else if reg_type == 11 {
  20465. med_type = "11"
  20466. }
  20467. } else if his.Insutype == "310" {
  20468. if reg_type == 14 {
  20469. med_type = "990502"
  20470. } else if reg_type == 11 {
  20471. med_type = "11"
  20472. }
  20473. }
  20474. 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)
  20475. } else {
  20476. 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, doctor_info.UserName, admin_user_id, roles.UserName)
  20477. }
  20478. saveLog(result, requestLog, "2203", "上传就诊信息")
  20479. var respJSON2 map[string]interface{}
  20480. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  20481. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20483. return
  20484. }
  20485. userJSONBytes2, _ := json.Marshal(respJSON2)
  20486. if miConfig.Code == "H15049901371" {
  20487. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  20488. utils.ErrorLog("解析失败:%v", err)
  20489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20490. return
  20491. }
  20492. res2.InfRefmsgid = resSix10265.InfRefmsgid
  20493. res2.Output = resSix10265.Output
  20494. res2.ErrMsg = resSix10265.ErrMsg
  20495. res2.Cainfo = resSix10265.Cainfo
  20496. res2.WarnMsg = resSix10265.WarnMsg
  20497. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  20498. res2.Infcode = infocode
  20499. } else {
  20500. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  20501. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  20502. utils.ErrorLog("解析失败:%v", err)
  20503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20504. return
  20505. }
  20506. res2.Infcode = res3.Infcode
  20507. } else {
  20508. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  20509. utils.ErrorLog("解析失败:%v", err)
  20510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20511. return
  20512. }
  20513. }
  20514. }
  20515. }
  20516. }
  20517. if res2.Infcode == -1 {
  20518. adminUser := c.GetAdminUserInfo()
  20519. errlog := &models.HisOrderError{
  20520. UserOrgId: adminUser.CurrentOrgId,
  20521. Ctime: time.Now().Unix(),
  20522. Mtime: time.Now().Unix(),
  20523. ErrMsg: res2.ErrMsg,
  20524. Status: 1,
  20525. PatientId: id,
  20526. RecordTime: recordDateTime,
  20527. Stage: 3,
  20528. }
  20529. service.CreateErrMsgLog(errlog)
  20530. c.ServeSuccessJSON(map[string]interface{}{
  20531. "failed_code": -10,
  20532. "msg": res2.ErrMsg,
  20533. })
  20534. return
  20535. }
  20536. if res2.Infcode != 0 {
  20537. adminUser := c.GetAdminUserInfo()
  20538. errlog := &models.HisOrderError{
  20539. UserOrgId: adminUser.CurrentOrgId,
  20540. Ctime: time.Now().Unix(),
  20541. Mtime: time.Now().Unix(),
  20542. ErrMsg: res2.ErrMsg,
  20543. Status: 1,
  20544. PatientId: id,
  20545. RecordTime: recordDateTime,
  20546. Stage: 3,
  20547. }
  20548. service.CreateErrMsgLog(errlog)
  20549. c.ServeSuccessJSON(map[string]interface{}{
  20550. "failed_code": -10,
  20551. "msg": res2.ErrMsg,
  20552. })
  20553. return
  20554. } else {
  20555. his.Diagnosis = diagnosis_id
  20556. his.SickType = sickConfig.ID
  20557. his.PType = fmt.Sprintf("%d", reg_type)
  20558. service.UpdateHisPatientThree(&his)
  20559. data := make(map[string]interface{})
  20560. if settle_accounts_type == 1 { //日结
  20561. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  20562. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  20563. } else {
  20564. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  20565. }
  20566. data["pre"] = prescriptions
  20567. } else { //月结
  20568. start_time_str := c.GetString("start_time")
  20569. end_time_str := c.GetString("end_time")
  20570. timeLayout := "2006-01-02"
  20571. loc, _ := time.LoadLocation("Local")
  20572. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  20573. if err != nil {
  20574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  20575. return
  20576. }
  20577. recordStartTime := theStartTime.Unix()
  20578. start_time = recordStartTime
  20579. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  20580. if err != nil {
  20581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  20582. return
  20583. }
  20584. recordEndTime := theEndTime.Unix()
  20585. end_time = recordEndTime
  20586. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  20587. data["pre"] = prescriptions
  20588. }
  20589. client := &http.Client{}
  20590. data["psn_no"] = his.PsnNo
  20591. data["mdtrt_id"] = his.Number
  20592. data["chrg_bchno"] = chrg_bchno
  20593. data["org_name"] = miConfig.OrgName
  20594. data["doctor"] = doctor_info.UserName
  20595. data["doctor_id"] = doctor_info.DoctorNumber
  20596. data["dept"] = department.Name
  20597. data["fixmedins_code"] = miConfig.Code
  20598. data["opter"] = roles.UserName
  20599. data["dept_code"] = department.Number
  20600. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20601. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20602. data["secret_key"] = miConfig.SecretKey
  20603. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  20604. data["url"] = miConfig.Url
  20605. data["ak"] = miConfig.AccessKey
  20606. data["new_doctor_name"] = patientPrescription.Doctor
  20607. if his.Insutype == "390" {
  20608. if reg_type == 992102 {
  20609. data["diag_code"] = "ZDZ940"
  20610. }
  20611. if reg_type == 140104 {
  20612. data["diag_code"] =sickConfig.CountryCode
  20613. }
  20614. if reg_type == 14 {
  20615. data["diag_code"] =sickConfig.CountryCode
  20616. }
  20617. } else if his.Insutype == "310" {
  20618. if reg_type == 992102 {
  20619. data["diag_code"] = "ZDZ940"
  20620. }
  20621. if reg_type == 14 {
  20622. data["diag_code"] =sickConfig.CountryCode
  20623. }
  20624. }
  20625. data["cainfo"] = miConfig.Cainfo
  20626. data["opter"] = roles.UserName
  20627. var ids []int64
  20628. for _, item := range prescriptions {
  20629. ids = append(ids, item.ID)
  20630. }
  20631. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  20632. if config.IsOpen == 1 { //对接了医保,走医保流程
  20633. var res ResultFour
  20634. var resFour10265 ResultFour10265
  20635. if miConfig.MdtrtareaAdmvs == "421300" {
  20636. bytesData, _ := json.Marshal(data)
  20637. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  20638. resp, _ := client.Do(req)
  20639. defer resp.Body.Close()
  20640. body, ioErr := ioutil.ReadAll(resp.Body)
  20641. if ioErr != nil {
  20642. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20644. return
  20645. }
  20646. var respJSON map[string]interface{}
  20647. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20648. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20650. return
  20651. }
  20652. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20653. userJSONBytes, _ := json.Marshal(respJSON)
  20654. fmt.Println("log")
  20655. fmt.Println(string(userJSONBytes))
  20656. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20657. utils.ErrorLog("解析失败:%v", err)
  20658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20659. return
  20660. }
  20661. } else if miConfig.MdtrtareaAdmvs == "420200" {
  20662. bytesData, _ := json.Marshal(data)
  20663. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  20664. resp, _ := client.Do(req)
  20665. defer resp.Body.Close()
  20666. body, ioErr := ioutil.ReadAll(resp.Body)
  20667. if ioErr != nil {
  20668. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20670. return
  20671. }
  20672. var respJSON map[string]interface{}
  20673. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20674. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20676. return
  20677. }
  20678. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20679. userJSONBytes, _ := json.Marshal(respJSON)
  20680. fmt.Println("log")
  20681. fmt.Println(string(userJSONBytes))
  20682. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20683. utils.ErrorLog("解析失败:%v", err)
  20684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20685. return
  20686. }
  20687. } else if miConfig.MdtrtareaAdmvs == "421182" {
  20688. bytesData, _ := json.Marshal(data)
  20689. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  20690. resp, _ := client.Do(req)
  20691. defer resp.Body.Close()
  20692. body, ioErr := ioutil.ReadAll(resp.Body)
  20693. if ioErr != nil {
  20694. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20696. return
  20697. }
  20698. var respJSON map[string]interface{}
  20699. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20700. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20702. return
  20703. }
  20704. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20705. userJSONBytes, _ := json.Marshal(respJSON)
  20706. fmt.Println("log")
  20707. fmt.Println(string(userJSONBytes))
  20708. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20709. utils.ErrorLog("解析失败:%v", err)
  20710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20711. return
  20712. }
  20713. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20714. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  20715. if result3101.Infcode == "0" {
  20716. if len(result3101.Output.Result) > 0 {
  20717. var errMsgs []string
  20718. for _, item := range result3101.Output.Result {
  20719. errMsgs = append(errMsgs, item.VolaCont)
  20720. }
  20721. c.ServeSuccessJSON(map[string]interface{}{
  20722. "failed_code": -10,
  20723. "msg": errMsgs,
  20724. })
  20725. return
  20726. } else {
  20727. if miConfig.MdtrtareaAdmvs == "320921" {
  20728. data["doctor_id"] = "D320923012139"
  20729. } else {
  20730. data["doctor_id"] = "D371621008686"
  20731. }
  20732. bytesData, _ := json.Marshal(data)
  20733. var req *http.Request
  20734. if miConfig.MdtrtareaAdmvs == "320921" {
  20735. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20736. } else {
  20737. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20738. }
  20739. resp, _ := client.Do(req)
  20740. defer resp.Body.Close()
  20741. body, ioErr := ioutil.ReadAll(resp.Body)
  20742. if ioErr != nil {
  20743. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20745. return
  20746. }
  20747. var respJSON map[string]interface{}
  20748. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20749. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20751. return
  20752. }
  20753. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20754. userJSONBytes, _ := json.Marshal(respJSON)
  20755. fmt.Println("log")
  20756. fmt.Println(string(userJSONBytes))
  20757. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  20758. utils.ErrorLog("解析失败:%v", err)
  20759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20760. return
  20761. }
  20762. res.InfRefmsgid = resFour10265.InfRefmsgid
  20763. res.Output = resFour10265.Output
  20764. res.ErrMsg = resFour10265.ErrMsg
  20765. res.Cainfo = resFour10265.Cainfo
  20766. res.WarnMsg = resFour10265.WarnMsg
  20767. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  20768. res.Infcode = infocode
  20769. }
  20770. }
  20771. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20772. var pagesize int = 5
  20773. var start int = 1
  20774. var stop int
  20775. var pagecount int
  20776. var curpage int
  20777. data["doctor_id"] = doctor_info.DoctorNumber
  20778. var res2 ResultFour
  20779. //var result res.
  20780. //总页数,向上取整,注意除之前要先转换类型为float64
  20781. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  20782. for curpage = 1; curpage <= pagecount; curpage++ {
  20783. if curpage == 1 {
  20784. start = 1
  20785. } else {
  20786. start = (curpage-1)*pagesize + 1
  20787. }
  20788. stop = curpage * pagesize
  20789. if stop > len(prescriptions) {
  20790. stop = len(prescriptions)
  20791. }
  20792. //var requestLog string
  20793. data["pre"] = prescriptions[start-1 : stop]
  20794. fmt.Println(data["pre"])
  20795. bytesData, _ := json.Marshal(data)
  20796. var req *http.Request
  20797. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  20798. resp, _ := client.Do(req)
  20799. defer resp.Body.Close()
  20800. body, ioErr := ioutil.ReadAll(resp.Body)
  20801. if ioErr != nil {
  20802. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20804. return
  20805. }
  20806. var respJSON map[string]interface{}
  20807. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20810. return
  20811. }
  20812. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20813. userJSONBytes, _ := json.Marshal(respJSON)
  20814. fmt.Println("log")
  20815. fmt.Println(string(userJSONBytes))
  20816. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  20817. utils.ErrorLog("解析失败:%v", err)
  20818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20819. return
  20820. }
  20821. res.InfRefmsgid = resFour10265.InfRefmsgid
  20822. res.Output = resFour10265.Output
  20823. res.ErrMsg = resFour10265.ErrMsg
  20824. res.Cainfo = resFour10265.Cainfo
  20825. res.WarnMsg = resFour10265.WarnMsg
  20826. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  20827. res.Infcode = infocode
  20828. if infocode == 0 {
  20829. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  20830. } else {
  20831. isSuccess = false
  20832. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  20833. res.Infcode = -1
  20834. res.ErrMsg = resFour10265.ErrMsg
  20835. errlog := &models.HisOrderError{
  20836. UserOrgId: adminUser.CurrentOrgId,
  20837. Ctime: time.Now().Unix(),
  20838. Mtime: time.Now().Unix(),
  20839. Number: chrg_bchno,
  20840. ErrMsg: "",
  20841. Status: 1,
  20842. PatientId: id,
  20843. RecordTime: recordDateTime,
  20844. Stage: 4,
  20845. }
  20846. service.CreateErrMsgLog(errlog)
  20847. }
  20848. }
  20849. if isSuccess {
  20850. res.Infcode = 0
  20851. res.Output.Result = res2.Output.Result
  20852. } else {
  20853. order := &models.HisOrder{
  20854. UserOrgId: adminUser.CurrentOrgId,
  20855. HisPatientId: his.ID,
  20856. PatientId: his.PatientId,
  20857. SettleAccountsDate: recordDateTime,
  20858. Ctime: time.Now().Unix(),
  20859. Mtime: time.Now().Unix(),
  20860. MdtrtId: his.Number,
  20861. PsnNo: his.PsnNo,
  20862. MedType: strconv.FormatInt(reg_type, 10),
  20863. Status: 1,
  20864. Number: chrg_bchno,
  20865. Infcode: res.Infcode,
  20866. WarnMsg: res.WarnMsg,
  20867. Cainfo: res.Cainfo,
  20868. ErrMsg: res.ErrMsg,
  20869. RespondTime: res.RefmsgTime,
  20870. InfRefmsgid: res.InfRefmsgid,
  20871. OrderStatus: 1,
  20872. IsMedicineInsurance: 1,
  20873. SettleType: settle_accounts_type,
  20874. SettleStartTime: start_time,
  20875. SettleEndTime: end_time,
  20876. Creator: roles.AdminUserId,
  20877. Modify: roles.AdminUserId,
  20878. PType: 2,
  20879. Diagnosis: diagnosis_id,
  20880. }
  20881. err = service.CreateOrder(order)
  20882. if err != nil {
  20883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  20884. return
  20885. }
  20886. c.ServeSuccessJSON(map[string]interface{}{
  20887. "failed_code": -10,
  20888. "msg": res2.ErrMsg,
  20889. })
  20890. return
  20891. }
  20892. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20893. result, request_log, _ := service.FJyb2204(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), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode, doctor_info.DoctorNumber)
  20894. var dat map[string]interface{}
  20895. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20896. fmt.Println(dat)
  20897. } else {
  20898. fmt.Println(err)
  20899. }
  20900. saveLog(result, request_log, "2204", "上传费用明细")
  20901. userJSONBytes, _ := json.Marshal(dat)
  20902. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20903. utils.ErrorLog("解析失败:%v", err)
  20904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20905. return
  20906. }
  20907. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20908. result, request_log := service.Jxyb2204(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), sickConfig.CountryCode, miConfig.Url, miConfig.AccessKey, doctor_info.UserName, "", "")
  20909. var dat map[string]interface{}
  20910. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20911. fmt.Println(dat)
  20912. } else {
  20913. fmt.Println(err)
  20914. }
  20915. saveLog(result, request_log, "2204", "上传费用明细")
  20916. userJSONBytes, _ := json.Marshal(dat)
  20917. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20918. utils.ErrorLog("解析失败:%v", err)
  20919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20920. return
  20921. }
  20922. } else if miConfig.MdtrtareaAdmvs == "341203" {
  20923. bytesData, _ := json.Marshal(data)
  20924. var req *http.Request
  20925. req, _ = http.NewRequest("POST", miConfig.SecretKey +"ahyb/2204", bytes.NewReader(bytesData))
  20926. resp, _ := client.Do(req)
  20927. defer resp.Body.Close()
  20928. body, ioErr := ioutil.ReadAll(resp.Body)
  20929. if ioErr != nil {
  20930. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20932. return
  20933. }
  20934. var respJSON map[string]interface{}
  20935. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20936. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20938. return
  20939. }
  20940. status := respJSON["data"].(map[string]interface{})["status"].(string)
  20941. if status == "0"{
  20942. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  20943. c.ServeSuccessJSON(map[string]interface{}{
  20944. "failed_code": -10,
  20945. "msg": err_msg,
  20946. })
  20947. return
  20948. }
  20949. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20950. userJSONBytes, _ := json.Marshal(respJSON)
  20951. fmt.Println("log")
  20952. fmt.Println(string(userJSONBytes))
  20953. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20954. utils.ErrorLog("解析失败:%v", err)
  20955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20956. return
  20957. }
  20958. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20959. result, request_log := service.Hnyb2204(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), sickConfig.CountryCode, miConfig.Url, miConfig.AccessKey, doctor_info.UserName, "", "")
  20960. var dat map[string]interface{}
  20961. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20962. fmt.Println(dat)
  20963. } else {
  20964. fmt.Println(err)
  20965. }
  20966. saveLog(result, request_log, "2204", "上传费用明细")
  20967. userJSONBytes, _ := json.Marshal(dat)
  20968. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20969. utils.ErrorLog("解析失败:%v", err)
  20970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20971. return
  20972. }
  20973. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20974. bytesData, _ := json.Marshal(data)
  20975. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  20976. resp, _ := client.Do(req)
  20977. defer resp.Body.Close()
  20978. body, ioErr := ioutil.ReadAll(resp.Body)
  20979. if ioErr != nil {
  20980. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20982. return
  20983. }
  20984. var respJSON map[string]interface{}
  20985. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20986. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20988. return
  20989. }
  20990. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20991. userJSONBytes, _ := json.Marshal(respJSON)
  20992. fmt.Println("log")
  20993. fmt.Println(string(userJSONBytes))
  20994. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20995. utils.ErrorLog("解析失败:%v", err)
  20996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20997. return
  20998. }
  20999. } else {
  21000. if miConfig.MdtrtareaAdmvs == "441202" {
  21001. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  21002. if result3101.Infcode == 0 {
  21003. if len(result3101.Output.Result) > 0 {
  21004. var errMsgs []string
  21005. for _, item := range result3101.Output.Result {
  21006. errMsgs = append(errMsgs, item.VolaCont)
  21007. }
  21008. c.ServeSuccessJSON(map[string]interface{}{
  21009. "failed_code": -10,
  21010. "msg": errMsgs,
  21011. })
  21012. return
  21013. } else {
  21014. 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, admin_user_id)
  21015. var dat map[string]interface{}
  21016. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21017. fmt.Println(dat)
  21018. } else {
  21019. fmt.Println(err)
  21020. }
  21021. saveLog(result, request_log, "2204", "上传费用明细")
  21022. userJSONBytes, _ := json.Marshal(dat)
  21023. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21024. utils.ErrorLog("解析失败:%v", err)
  21025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21026. return
  21027. }
  21028. }
  21029. } else {
  21030. c.ServeSuccessJSON(map[string]interface{}{
  21031. "failed_code": -10,
  21032. "msg": result3101.ErrMsg,
  21033. })
  21034. return
  21035. }
  21036. } else {
  21037. if miConfig.Code == "H15049901371" {
  21038. 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, admin_user_id)
  21039. var dat map[string]interface{}
  21040. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21041. fmt.Println(dat)
  21042. } else {
  21043. fmt.Println(err)
  21044. }
  21045. saveLog(result, request_log, "2204", "上传费用明细")
  21046. userJSONBytes, _ := json.Marshal(dat)
  21047. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  21048. utils.ErrorLog("解析失败:%v", err)
  21049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21050. return
  21051. }
  21052. res.InfRefmsgid = resFour10265.InfRefmsgid
  21053. res.Output = resFour10265.Output
  21054. res.ErrMsg = resFour10265.ErrMsg
  21055. res.Cainfo = resFour10265.Cainfo
  21056. res.WarnMsg = resFour10265.WarnMsg
  21057. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  21058. res.Infcode = infocode
  21059. } else {
  21060. 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, admin_user_id)
  21061. var dat map[string]interface{}
  21062. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21063. fmt.Println(dat)
  21064. } else {
  21065. fmt.Println(err)
  21066. }
  21067. saveLog(result, request_log, "2204", "上传费用明细")
  21068. userJSONBytes, _ := json.Marshal(dat)
  21069. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21070. utils.ErrorLog("解析失败:%v", err)
  21071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21072. return
  21073. }
  21074. }
  21075. }
  21076. }
  21077. var total_two float64
  21078. if res.Infcode == 0 {
  21079. order := &models.HisOrder{
  21080. UserOrgId: adminUser.CurrentOrgId,
  21081. HisPatientId: his.ID,
  21082. PatientId: his.PatientId,
  21083. SettleAccountsDate: recordDateTime,
  21084. Ctime: time.Now().Unix(),
  21085. Mtime: time.Now().Unix(),
  21086. MdtrtId: his.Number,
  21087. PsnNo: his.PsnNo,
  21088. MedType: strconv.FormatInt(reg_type, 10),
  21089. Status: 1,
  21090. Number: chrg_bchno,
  21091. Infcode: res.Infcode,
  21092. WarnMsg: res.WarnMsg,
  21093. Cainfo: res.Cainfo,
  21094. ErrMsg: res.ErrMsg,
  21095. RespondTime: res.RefmsgTime,
  21096. InfRefmsgid: res.InfRefmsgid,
  21097. OrderStatus: 1,
  21098. IsMedicineInsurance: 1,
  21099. SettleType: settle_accounts_type,
  21100. SettleStartTime: start_time,
  21101. SettleEndTime: end_time,
  21102. Creator: roles.AdminUserId,
  21103. Modify: roles.AdminUserId,
  21104. PType: 2,
  21105. Diagnosis: diagnosis_id,
  21106. }
  21107. err = service.CreateOrder(order)
  21108. if err != nil {
  21109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  21110. return
  21111. }
  21112. for _, item := range res.Output.Result {
  21113. temp := strings.Split(item.FeedetlSn, "-")
  21114. var advice_id int64 = 0
  21115. var project_id int64 = 0
  21116. var types int64 = 0
  21117. id, _ := strconv.ParseInt(temp[2], 10, 64)
  21118. types, _ = strconv.ParseInt(temp[1], 10, 64)
  21119. if temp[1] == "1" {
  21120. advice_id = id
  21121. project_id = 0
  21122. } else if temp[1] == "2" {
  21123. advice_id = 0
  21124. project_id = id
  21125. }
  21126. total_two = total_two + item.DetItemFeeSumamt
  21127. info := &models.HisOrderInfo{
  21128. OrderNumber: order.Number,
  21129. FeedetlSn: item.FeedetlSn,
  21130. UploadDate: time.Now().Unix(),
  21131. AdviceId: advice_id,
  21132. DetItemFeeSumamt: item.DetItemFeeSumamt,
  21133. Cnt: item.Cnt,
  21134. Pric: float64(item.Pric),
  21135. PatientId: his.PatientId,
  21136. PricUplmtAmt: item.PricUplmtAmt,
  21137. SelfpayProp: item.SelfpayProp,
  21138. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  21139. OverlmtAmt: item.OverlmtAmt,
  21140. PreselfpayAmt: item.PreselfpayAmt,
  21141. BasMednFlag: item.BasMednFlag,
  21142. MedChrgitmType: item.MedChrgitmType,
  21143. HiNegoDrugFlag: item.HiNegoDrugFlag,
  21144. Status: 1,
  21145. Memo: item.Memo,
  21146. Mtime: time.Now().Unix(),
  21147. InscpScpAmt: item.InscpScpAmt,
  21148. DrtReimFlag: item.DrtReimFlag,
  21149. Ctime: time.Now().Unix(),
  21150. ListSpItemFlag: item.ListSpItemFlag,
  21151. ChldMedcFlag: item.ChldMedcFlag,
  21152. LmtUsedFlag: item.LmtUsedFlag,
  21153. ChrgitmLv: item.ChrgitmLv,
  21154. UserOrgId: adminUser.CurrentOrgId,
  21155. HisPatientId: his.ID,
  21156. OrderId: order.ID,
  21157. ProjectId: project_id,
  21158. Type: types,
  21159. }
  21160. service.CreateOrderInfo(info)
  21161. }
  21162. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  21163. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  21164. var total float64
  21165. for _, item := range prescriptions {
  21166. if item.Type == 1 { //药品
  21167. for _, subItem := range item.HisDoctorAdviceInfo {
  21168. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  21169. total_one := price * subItem.PrescribingNumber
  21170. fmt.Println("subItem")
  21171. fmt.Println(subItem.Price)
  21172. fmt.Println("price")
  21173. fmt.Println(price)
  21174. fmt.Println("total_one")
  21175. fmt.Println(total_one)
  21176. total = total + total_one
  21177. fmt.Println(total)
  21178. }
  21179. }
  21180. if item.Type == 2 { //项目
  21181. for _, subItem := range item.HisPrescriptionProject {
  21182. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  21183. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  21184. total_one := price * cnt
  21185. total = total + total_one
  21186. }
  21187. }
  21188. }
  21189. allTotal := fmt.Sprintf("%.2f", total)
  21190. if res.Infcode == 0 {
  21191. var rf []*ResultFive
  21192. json.Unmarshal([]byte(his.Iinfo), &rf)
  21193. chrg_bchno := chrg_bchno
  21194. cert_no := his.Certno
  21195. var insutypes []string
  21196. var insutype string
  21197. var is390 int = 0
  21198. var is310 int = 0
  21199. for _, item := range rf {
  21200. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  21201. insutypes = append(insutypes, item.Insutype)
  21202. }
  21203. }
  21204. if len(insutypes) == 1 {
  21205. insutype = insutypes[0]
  21206. } else {
  21207. for _, i := range insutypes {
  21208. if i == "390" {
  21209. is390 = 1
  21210. }
  21211. if i == "310" {
  21212. is310 = 1
  21213. }
  21214. }
  21215. }
  21216. if is390 == 1 {
  21217. insutype = "390"
  21218. }
  21219. if is310 == 1 {
  21220. insutype = "310"
  21221. }
  21222. if len(insutypes) == 0 {
  21223. insutype = "390"
  21224. }
  21225. if len(insutypes) == 2 {
  21226. insutype = strconv.FormatInt(his.SocialType, 10)
  21227. }
  21228. //insutype = "390"
  21229. if his.IdCardType == 1 {
  21230. cert_no = his.MedicalInsuranceNumber
  21231. } else {
  21232. cert_no = his.Certno
  21233. }
  21234. var res ResultSeven
  21235. var ahres ResultSevenAH
  21236. var resSeven10265 ResultSeven10265
  21237. var resSeven10265Two ResultSeven10265Two
  21238. var gzresSeven10265Two GZResultSeven10265Two
  21239. if miConfig.MdtrtareaAdmvs == "421300" {
  21240. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  21241. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21242. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21243. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21244. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21245. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21246. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21247. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  21248. resp, requestErr := http.Get(api)
  21249. if requestErr != nil {
  21250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21251. return
  21252. }
  21253. body, ioErr := ioutil.ReadAll(resp.Body)
  21254. if ioErr != nil {
  21255. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21257. return
  21258. }
  21259. var respJSON map[string]interface{}
  21260. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21261. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21263. return
  21264. }
  21265. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21266. result, _ := json.Marshal(respJSON)
  21267. fmt.Println("log")
  21268. fmt.Println(string(result))
  21269. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21270. utils.ErrorLog("解析失败:%v", err)
  21271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21272. return
  21273. }
  21274. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21275. if reg_type == 11 && his.Insutype == "390" {
  21276. reg_type = 110104
  21277. }
  21278. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21279. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21280. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21281. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21282. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21283. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21284. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  21285. resp, requestErr := http.Get(api)
  21286. if requestErr != nil {
  21287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21288. return
  21289. }
  21290. body, ioErr := ioutil.ReadAll(resp.Body)
  21291. if ioErr != nil {
  21292. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21294. return
  21295. }
  21296. var respJSON map[string]interface{}
  21297. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21300. return
  21301. }
  21302. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21303. result, _ := json.Marshal(respJSON)
  21304. fmt.Println("log")
  21305. fmt.Println(string(result))
  21306. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21307. utils.ErrorLog("解析失败:%v", err)
  21308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21309. return
  21310. }
  21311. } else if miConfig.MdtrtareaAdmvs == "421182" {
  21312. if reg_type == 11 && his.Insutype == "390" {
  21313. reg_type = 110104
  21314. }
  21315. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21316. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21317. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21318. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21319. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21320. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21321. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  21322. resp, requestErr := http.Get(api)
  21323. if requestErr != nil {
  21324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21325. return
  21326. }
  21327. body, ioErr := ioutil.ReadAll(resp.Body)
  21328. if ioErr != nil {
  21329. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21331. return
  21332. }
  21333. var respJSON map[string]interface{}
  21334. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21335. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21337. return
  21338. }
  21339. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21340. result, _ := json.Marshal(respJSON)
  21341. fmt.Println("log")
  21342. fmt.Println(string(result))
  21343. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21344. utils.ErrorLog("解析失败:%v", err)
  21345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21346. return
  21347. }
  21348. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21349. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  21350. if result3101.Infcode == "0" {
  21351. if len(result3101.Output.Result) > 0 {
  21352. var errMsgs []string
  21353. for _, item := range result3101.Output.Result {
  21354. errMsgs = append(errMsgs, item.VolaCont)
  21355. }
  21356. c.ServeSuccessJSON(map[string]interface{}{
  21357. "failed_code": -10,
  21358. "msg": errMsgs,
  21359. })
  21360. return
  21361. } else {
  21362. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21363. if his.IdCardType != 4 {
  21364. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  21365. bas := strings.Split(psn_info.CardInfo, "|")
  21366. if his.IdCardType == 1 {
  21367. cert_no = bas[2]
  21368. } else {
  21369. cert_no = bas[1]
  21370. }
  21371. } else {
  21372. cert_no = his.Certno
  21373. }
  21374. //江苏地区国家医保医疗类别
  21375. //职工透析:医疗类别选特殊情况门诊9933
  21376. //居民血透门慢: 医疗类别选门诊慢病1402
  21377. //var med_type string
  21378. //if his.Insutype == "310" {
  21379. // if reg_type == 14 {
  21380. // med_type = "9933"
  21381. // } else if reg_type == 11 {
  21382. // med_type = "11"
  21383. //
  21384. // }
  21385. //} else if his.Insutype == "390" {
  21386. // if reg_type == 14 {
  21387. // med_type = "1402"
  21388. // } else if reg_type == 11 {
  21389. // med_type = "11"
  21390. // }
  21391. //}
  21392. var api string
  21393. if miConfig.MdtrtareaAdmvs == "320921" {
  21394. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21395. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21396. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21397. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21398. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21399. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21400. "&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 + "&mdtrt_grp_type=" + his.MdtrtGrpType
  21401. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  21402. } else {
  21403. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  21404. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21405. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21406. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21407. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21408. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21409. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21410. "&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 + "&mdtrt_grp_type=" + his.MdtrtGrpType
  21411. }
  21412. resp, requestErr := http.Get(api)
  21413. if requestErr != nil {
  21414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21415. return
  21416. }
  21417. body, ioErr := ioutil.ReadAll(resp.Body)
  21418. if ioErr != nil {
  21419. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21421. return
  21422. }
  21423. var respJSON map[string]interface{}
  21424. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21425. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21427. return
  21428. }
  21429. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21430. result, _ := json.Marshal(respJSON)
  21431. fmt.Println("log")
  21432. fmt.Println(string(result))
  21433. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  21434. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  21435. utils.ErrorLog("解析失败:%v", err)
  21436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21437. return
  21438. }
  21439. res.InfRefmsgid = resSeven10265.InfRefmsgid
  21440. res.Output = resSeven10265.Output
  21441. res.ErrMsg = resSeven10265.ErrMsg
  21442. res.Cainfo = resSeven10265.Cainfo
  21443. res.WarnMsg = resSeven10265.WarnMsg
  21444. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  21445. res.Infcode = infocode
  21446. } else {
  21447. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  21448. utils.ErrorLog("解析失败:%v", err)
  21449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21450. return
  21451. }
  21452. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  21453. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  21454. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  21455. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  21456. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  21457. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  21458. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  21459. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  21460. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  21461. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  21462. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  21463. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  21464. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  21465. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  21466. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  21467. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  21468. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  21469. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  21470. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  21471. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  21472. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  21473. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  21474. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  21475. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  21476. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  21477. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  21478. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  21479. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  21480. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  21481. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  21482. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  21483. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  21484. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  21485. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  21486. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  21487. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  21488. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  21489. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  21490. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  21491. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  21492. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  21493. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  21494. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  21495. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  21496. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  21497. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  21498. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  21499. res.ErrMsg = resSeven10265Two.ErrMsg
  21500. res.Cainfo = resSeven10265Two.Cainfo
  21501. res.WarnMsg = resSeven10265Two.WarnMsg
  21502. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  21503. res.Infcode = infocode
  21504. }
  21505. }
  21506. }
  21507. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21508. psn_info, _ := service.GetPsnByPatientId(id)
  21509. var verify_number string
  21510. if psn_info.IdCardType == 4 {
  21511. verify_number = psn_info.VerifyNumber
  21512. } else if psn_info.IdCardType == 1 {
  21513. bas := strings.Split(psn_info.CardInfo, "|")
  21514. cardNumber := bas[2]
  21515. verify_number = cardNumber
  21516. } else {
  21517. psn_info.IdCardType = 2
  21518. verify_number = psn_info.Certno
  21519. }
  21520. var api string
  21521. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21522. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21523. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21524. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21525. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  21526. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21527. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&verify_number=" + verify_number + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  21528. resp, requestErr := http.Get(api)
  21529. if requestErr != nil {
  21530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21531. return
  21532. }
  21533. body, ioErr := ioutil.ReadAll(resp.Body)
  21534. if ioErr != nil {
  21535. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21537. return
  21538. }
  21539. var respJSON map[string]interface{}
  21540. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21541. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21543. return
  21544. }
  21545. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21546. result, _ := json.Marshal(respJSON)
  21547. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  21548. utils.ErrorLog("解析失败:%v", err)
  21549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21550. return
  21551. }
  21552. res.InfRefmsgid = resSeven10265.InfRefmsgid
  21553. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  21554. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  21555. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  21556. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  21557. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  21558. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  21559. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  21560. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  21561. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  21562. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  21563. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  21564. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  21565. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  21566. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  21567. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  21568. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  21569. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  21570. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  21571. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  21572. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  21573. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  21574. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  21575. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  21576. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  21577. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  21578. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  21579. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  21580. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  21581. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  21582. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  21583. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  21584. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  21585. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  21586. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  21587. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  21588. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  21589. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  21590. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  21591. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  21592. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  21593. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  21594. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  21595. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  21596. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  21597. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  21598. res.ErrMsg = resSeven10265.ErrMsg
  21599. res.Cainfo = resSeven10265.Cainfo
  21600. res.WarnMsg = resSeven10265.WarnMsg
  21601. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  21602. res.Infcode = infocode
  21603. } else if miConfig.MdtrtareaAdmvs == "350500" {
  21604. acct_used_flag := "1"
  21605. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  21606. var result string
  21607. var request_log string
  21608. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  21609. result, request_log, _ = service.FJyb2206ForToken(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, 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, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, acct_used_flag)
  21610. } else {
  21611. result, request_log, _ = service.FJyb2206(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, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, acct_used_flag)
  21612. }
  21613. var dat map[string]interface{}
  21614. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21615. fmt.Println(dat)
  21616. } else {
  21617. fmt.Println(err)
  21618. }
  21619. saveLog(result, request_log, "2206", "预结算")
  21620. userJSONBytes, _ := json.Marshal(dat)
  21621. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21622. utils.ErrorLog("解析失败:%v", err)
  21623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21624. return
  21625. }
  21626. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21627. var result string
  21628. var request_log string
  21629. if his.IdCardType == 2 {
  21630. result, request_log = service.Jxyb2206(his.PsnNo, his.Number, chrg_bchno, his.IdCardNo, 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, miConfig.Url, miConfig.AccessKey, his.IdCardNo, "")
  21631. } else if his.IdCardType == 1 {
  21632. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21633. bas := strings.Split(psn_info.CardInfo, "|")
  21634. basNumber := bas[2]
  21635. card_sn := bas[3]
  21636. var rf []*ResultFive
  21637. json.Unmarshal([]byte(his.Iinfo), &rf)
  21638. var psn_type string
  21639. for _, item := range rf {
  21640. if item.InsuplcAdmdvs == his.InsuplcAdmdvs{
  21641. psn_type =item.PsnType
  21642. }
  21643. }
  21644. result, request_log = service.Jxyb2206Two(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, 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, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn,his.PsnCertType,his.Certno,psn_type,his.PsnName)
  21645. } else {
  21646. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21647. result, request_log = service.Jxyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, 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, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "")
  21648. }
  21649. var dat map[string]interface{}
  21650. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21651. fmt.Println(dat)
  21652. } else {
  21653. fmt.Println(err)
  21654. }
  21655. saveLog(result, request_log, "2206", "预结算")
  21656. userJSONBytes, _ := json.Marshal(dat)
  21657. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21658. utils.ErrorLog("解析失败:%v", err)
  21659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21660. return
  21661. }
  21662. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21663. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21664. if his.IdCardType == 4 {
  21665. psn_info.VerifyNumber = psn_info.VerifyNumber
  21666. cert_no = psn_info.Certno
  21667. } else if his.IdCardType == 2 {
  21668. cert_no = psn_info.Certno
  21669. psn_info.VerifyNumber = psn_info.Certno
  21670. }else {
  21671. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  21672. bas := strings.Split(psn_info.CardInfo, "|")
  21673. if his.IdCardType == 1 {
  21674. cert_no = bas[2]
  21675. } else {
  21676. cert_no = bas[1]
  21677. }
  21678. }
  21679. var api string
  21680. var med_type string
  21681. if his.Insutype == "390" {
  21682. if reg_type == 992102 {
  21683. med_type = "992102"
  21684. }
  21685. if reg_type == 140104 {
  21686. med_type = "140104"
  21687. }
  21688. if reg_type == 14 {
  21689. med_type = "140104"
  21690. }
  21691. } else if his.Insutype == "310" {
  21692. if reg_type == 992102 {
  21693. med_type = "992102"
  21694. }
  21695. if reg_type == 14 {
  21696. med_type = "14"
  21697. }
  21698. }
  21699. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21700. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21701. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21702. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21703. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21704. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21705. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + med_type + "&verify_number=" + psn_info.VerifyNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  21706. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  21707. resp, requestErr := http.Get(api)
  21708. if requestErr != nil {
  21709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21710. return
  21711. }
  21712. body, ioErr := ioutil.ReadAll(resp.Body)
  21713. if ioErr != nil {
  21714. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21716. return
  21717. }
  21718. var respJSON map[string]interface{}
  21719. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21722. return
  21723. }
  21724. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21725. if status == "0"{
  21726. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21727. c.ServeSuccessJSON(map[string]interface{}{
  21728. "failed_code": -10,
  21729. "msg": err_msg,
  21730. })
  21731. return
  21732. }
  21733. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21734. result, _ := json.Marshal(respJSON)
  21735. fmt.Println("log")
  21736. fmt.Println(string(result))
  21737. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  21738. utils.ErrorLog("解析失败:%v", err)
  21739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21740. return
  21741. }
  21742. res.InfRefmsgid = ahres.InfRefmsgid
  21743. timestamp := int64( ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  21744. // 创建对应的Time类型
  21745. t := time.UnixMilli(timestamp)
  21746. // 格式化成指定的日期字符串
  21747. str := t.Format("2006-01-02 15:04:05")
  21748. res.Output.Setlinfo.SetlTime = str
  21749. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  21750. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  21751. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  21752. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  21753. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  21754. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  21755. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  21756. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  21757. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  21758. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  21759. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  21760. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  21761. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  21762. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  21763. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  21764. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  21765. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  21766. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  21767. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  21768. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  21769. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  21770. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  21771. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  21772. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  21773. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  21774. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  21775. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  21776. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  21777. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  21778. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  21779. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  21780. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  21781. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  21782. res.Output.Setlinfo.PoolPropSelfpay= ahres.Output.Setlinfo.PoolPropSelfpay
  21783. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  21784. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  21785. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  21786. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  21787. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  21788. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  21789. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  21790. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  21791. //res.Output.Setldetail = ahres.Output.Setldetail
  21792. res.ErrMsg = ahres.ErrMsg
  21793. res.Cainfo = ahres.Cainfo
  21794. res.WarnMsg = ahres.WarnMsg
  21795. res.Infcode = ahres.Infcode
  21796. } else if miConfig.MdtrtareaAdmvs == "430800" {
  21797. var result string
  21798. var request_log string
  21799. if his.IdCardType == 2 {
  21800. result, request_log = service.Hnyb2206(his.PsnNo, his.Number, chrg_bchno, his.IdCardNo, 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, miConfig.Url, miConfig.AccessKey, his.IdCardNo, "", "1")
  21801. } else if his.IdCardType == 1 {
  21802. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21803. bas := strings.Split(psn_info.CardInfo, "|")
  21804. basNumber := bas[2]
  21805. card_sn := bas[3]
  21806. result, request_log = service.Hnyb2206Two(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, 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, miConfig.Url, miConfig.AccessKey, basNumber, "", card_sn, "1")
  21807. } else {
  21808. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21809. result, request_log = service.Hnyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, 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, miConfig.Url, miConfig.AccessKey, psn_info.VerifyNumber, "", "1")
  21810. }
  21811. var dat map[string]interface{}
  21812. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21813. fmt.Println(dat)
  21814. } else {
  21815. fmt.Println(err)
  21816. }
  21817. saveLog(result, request_log, "2206", "预结算")
  21818. userJSONBytes, _ := json.Marshal(dat)
  21819. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21820. utils.ErrorLog("解析失败:%v", err)
  21821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21822. return
  21823. }
  21824. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21825. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21826. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21827. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21828. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21829. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21830. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21831. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  21832. resp, requestErr := http.Get(api)
  21833. if requestErr != nil {
  21834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21835. return
  21836. }
  21837. body, ioErr := ioutil.ReadAll(resp.Body)
  21838. if ioErr != nil {
  21839. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21841. return
  21842. }
  21843. var respJSON map[string]interface{}
  21844. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21845. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21847. return
  21848. }
  21849. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21850. result, _ := json.Marshal(respJSON)
  21851. fmt.Println("log")
  21852. fmt.Println(string(result))
  21853. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21854. utils.ErrorLog("解析失败:%v", err)
  21855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21856. return
  21857. }
  21858. } else {
  21859. if miConfig.MdtrtareaAdmvs == "441202" {
  21860. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  21861. if result3101.Infcode == 0 {
  21862. if len(result3101.Output.Result) > 0 {
  21863. var errMsgs []string
  21864. for _, item := range result3101.Output.Result {
  21865. errMsgs = append(errMsgs, item.VolaCont)
  21866. }
  21867. c.ServeSuccessJSON(map[string]interface{}{
  21868. "failed_code": -10,
  21869. "msg": errMsgs,
  21870. })
  21871. return
  21872. } else {
  21873. var result string
  21874. var request_log string
  21875. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21876. allTotal = fmt.Sprintf("%.2f", total_two)
  21877. if his.IdCardType == 4 {
  21878. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, 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, admin_user_id)
  21879. } else {
  21880. 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, admin_user_id)
  21881. }
  21882. var dat map[string]interface{}
  21883. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21884. fmt.Println(dat)
  21885. } else {
  21886. fmt.Println(err)
  21887. }
  21888. saveLog(result, request_log, "2206", "预结算")
  21889. //userJSONBytes, _ := json.Marshal(dat)
  21890. //
  21891. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21892. // utils.ErrorLog("解析失败:%v", err)
  21893. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21894. // return
  21895. //}
  21896. userJSONBytes, _ := json.Marshal(dat)
  21897. if miConfig.Code == "H15049901371" {
  21898. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  21899. utils.ErrorLog("解析失败:%v", err)
  21900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21901. return
  21902. }
  21903. res.InfRefmsgid = resSeven10265.InfRefmsgid
  21904. res.Output = resSeven10265.Output
  21905. res.ErrMsg = resSeven10265.ErrMsg
  21906. res.Cainfo = resSeven10265.Cainfo
  21907. res.WarnMsg = resSeven10265.WarnMsg
  21908. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  21909. res.Infcode = infocode
  21910. } else {
  21911. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21912. utils.ErrorLog("解析失败:%v", err)
  21913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21914. return
  21915. }
  21916. }
  21917. }
  21918. } else {
  21919. c.ServeSuccessJSON(map[string]interface{}{
  21920. "failed_code": -10,
  21921. "msg": result3101.ErrMsg,
  21922. })
  21923. return
  21924. }
  21925. } else {
  21926. var result string
  21927. var request_log string
  21928. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21929. allTotal = fmt.Sprintf("%.2f", total_two)
  21930. if his.IdCardType == 4 {
  21931. result, request_log = service.Gdyb2206(his.PsnNo, his.Number, chrg_bchno, psn_info.VerifyNumber, 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, admin_user_id)
  21932. } else {
  21933. 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, admin_user_id)
  21934. }
  21935. var dat map[string]interface{}
  21936. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21937. fmt.Println(dat)
  21938. } else {
  21939. fmt.Println(err)
  21940. }
  21941. saveLog(result, request_log, "2206", "预结算")
  21942. //userJSONBytes, _ := json.Marshal(dat)
  21943. //
  21944. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21945. // utils.ErrorLog("解析失败:%v", err)
  21946. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21947. // return
  21948. //}
  21949. userJSONBytes, _ := json.Marshal(dat)
  21950. if miConfig.Code == "H15049901371" {
  21951. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  21952. utils.ErrorLog("解析失败:%v", err)
  21953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21954. return
  21955. }
  21956. res.InfRefmsgid = resSeven10265.InfRefmsgid
  21957. res.Output = resSeven10265.Output
  21958. res.ErrMsg = resSeven10265.ErrMsg
  21959. res.Cainfo = resSeven10265.Cainfo
  21960. res.WarnMsg = resSeven10265.WarnMsg
  21961. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  21962. res.Infcode = infocode
  21963. } else {
  21964. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  21965. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  21966. utils.ErrorLog("解析失败:%v", err)
  21967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21968. return
  21969. }
  21970. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  21971. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  21972. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  21973. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  21974. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  21975. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  21976. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  21977. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  21978. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  21979. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21980. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21981. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21982. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  21983. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  21984. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  21985. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  21986. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  21987. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  21988. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  21989. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  21990. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  21991. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  21992. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  21993. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  21994. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  21995. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  21996. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  21997. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  21998. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  21999. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  22000. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  22001. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  22002. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  22003. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  22004. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  22005. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  22006. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  22007. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  22008. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22009. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  22010. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  22011. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  22012. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  22013. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  22014. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  22015. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  22016. res.ErrMsg = gzresSeven10265Two.ErrMsg
  22017. res.Cainfo = gzresSeven10265Two.Cainfo
  22018. res.WarnMsg = gzresSeven10265Two.WarnMsg
  22019. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  22020. //res.Infcode = infocode
  22021. } else {
  22022. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22023. utils.ErrorLog("解析失败:%v", err)
  22024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22025. return
  22026. }
  22027. }
  22028. }
  22029. }
  22030. }
  22031. utils.ErrorLog("解析失败:%v", res.Infcode)
  22032. if res.Infcode == -1 {
  22033. errlog := &models.HisOrderError{
  22034. UserOrgId: adminUser.CurrentOrgId,
  22035. Ctime: time.Now().Unix(),
  22036. Mtime: time.Now().Unix(),
  22037. Number: chrg_bchno,
  22038. ErrMsg: res.ErrMsg,
  22039. Status: 1,
  22040. PatientId: id,
  22041. RecordTime: recordDateTime,
  22042. Stage: 20,
  22043. }
  22044. service.CreateErrMsgLog(errlog)
  22045. c.ServeSuccessJSON(map[string]interface{}{
  22046. "failed_code": -10,
  22047. "msg": res.ErrMsg,
  22048. })
  22049. return
  22050. }
  22051. if res.Infcode != 0 {
  22052. errlog := &models.HisOrderError{
  22053. UserOrgId: adminUser.CurrentOrgId,
  22054. Ctime: time.Now().Unix(),
  22055. Mtime: time.Now().Unix(),
  22056. Number: chrg_bchno,
  22057. ErrMsg: res.ErrMsg,
  22058. Status: 1,
  22059. PatientId: id,
  22060. RecordTime: recordDateTime,
  22061. Stage: 20,
  22062. }
  22063. service.CreateErrMsgLog(errlog)
  22064. c.ServeSuccessJSON(map[string]interface{}{
  22065. "failed_code": -10,
  22066. "msg": res.ErrMsg,
  22067. })
  22068. return
  22069. } else {
  22070. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  22071. order.OrderStatus = 1
  22072. order.IsPre = 1
  22073. order.Status = 1
  22074. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  22075. order.SetlId = res.Output.Setlinfo.SetlID
  22076. order.PsnNo = res.Output.Setlinfo.PsnNo
  22077. order.PsnName = res.Output.Setlinfo.PsnName
  22078. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  22079. order.Certno = res.Output.Setlinfo.Certno
  22080. order.Gend = res.Output.Setlinfo.Gend
  22081. order.Naty = res.Output.Setlinfo.Naty
  22082. order.Age = res.Output.Setlinfo.Age
  22083. order.Insutype = res.Output.Setlinfo.Insutype
  22084. order.PsnType = res.Output.Setlinfo.PsnType
  22085. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  22086. order.SetlTime = res.Output.Setlinfo.SetlTime
  22087. order.AcctUsedFlag = acct_used_flag
  22088. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  22089. if res.Output.Setlinfo.MedType == "140101" {
  22090. order.MedType = "14"
  22091. } else {
  22092. if res.Output.Setlinfo.MedType == "110104" {
  22093. order.MedType = "11"
  22094. } else {
  22095. order.MedType = res.Output.Setlinfo.MedType
  22096. }
  22097. }
  22098. if res.Output.Setlinfo.MedType == "992102" {
  22099. order.MedType = "992102"
  22100. }
  22101. if res.Output.Setlinfo.MedType == "140104" {
  22102. order.MedType = "140104"
  22103. }
  22104. if res.Output.Setlinfo.MedType == "14" {
  22105. order.MedType = "14"
  22106. }
  22107. if reg_type == 1112 {
  22108. order.MedType = "1112"
  22109. }
  22110. if reg_type == 1111 {
  22111. order.MedType = "1111"
  22112. }
  22113. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  22114. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  22115. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  22116. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  22117. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  22118. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  22119. order.HifpPay = res.Output.Setlinfo.HifpPay
  22120. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  22121. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  22122. order.HifesPay = res.Output.Setlinfo.HifesPay
  22123. order.HifobPay = res.Output.Setlinfo.HifobPay
  22124. order.MafPay = res.Output.Setlinfo.MafPay
  22125. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  22126. order.OthPay = res.Output.Setlinfo.OthPay
  22127. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  22128. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  22129. order.AcctPay = res.Output.Setlinfo.AcctPay
  22130. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  22131. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  22132. order.Balc = res.Output.Setlinfo.Balc
  22133. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  22134. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  22135. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  22136. order.ClrWay = res.Output.Setlinfo.ClrWay
  22137. order.Creator = order.Creator
  22138. order.Modify = roles.AdminUserId
  22139. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  22140. //detailStr := string(setlDetail)
  22141. //order.SetlDetail = detailStr
  22142. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  22143. err = service.UpDateOrder(order)
  22144. if err == nil {
  22145. c.ServeSuccessJSON(map[string]interface{}{
  22146. "msg": "预结算成功",
  22147. })
  22148. } else {
  22149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  22150. return
  22151. }
  22152. }
  22153. } else {
  22154. adminUser := c.GetAdminUserInfo()
  22155. errlog := &models.HisOrderError{
  22156. UserOrgId: adminUser.CurrentOrgId,
  22157. Ctime: time.Now().Unix(),
  22158. Mtime: time.Now().Unix(),
  22159. ErrMsg: res.ErrMsg,
  22160. Status: 1,
  22161. PatientId: id,
  22162. RecordTime: recordDateTime,
  22163. Stage: 4,
  22164. }
  22165. service.CreateErrMsgLog(errlog)
  22166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  22167. return
  22168. }
  22169. } else {
  22170. if miConfig.MdtrtareaAdmvs == "150499" {
  22171. order := &models.HisOrder{
  22172. UserOrgId: adminUser.CurrentOrgId,
  22173. HisPatientId: his.ID,
  22174. PatientId: his.PatientId,
  22175. SettleAccountsDate: recordDateTime,
  22176. Ctime: time.Now().Unix(),
  22177. Mtime: time.Now().Unix(),
  22178. MdtrtId: his.Number,
  22179. PsnNo: his.PsnNo,
  22180. MedType: strconv.FormatInt(reg_type, 10),
  22181. Status: 1,
  22182. Number: chrg_bchno,
  22183. Infcode: res.Infcode,
  22184. WarnMsg: res.WarnMsg,
  22185. Cainfo: res.Cainfo,
  22186. ErrMsg: res.ErrMsg,
  22187. RespondTime: res.RefmsgTime,
  22188. InfRefmsgid: res.InfRefmsgid,
  22189. OrderStatus: 1,
  22190. IsMedicineInsurance: 1,
  22191. SettleType: settle_accounts_type,
  22192. SettleStartTime: start_time,
  22193. SettleEndTime: end_time,
  22194. Creator: roles.AdminUserId,
  22195. Modify: roles.AdminUserId,
  22196. PType: 2,
  22197. Diagnosis: diagnosis_id,
  22198. }
  22199. err = service.CreateOrder(order)
  22200. if err != nil {
  22201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  22202. return
  22203. }
  22204. }
  22205. adminUser := c.GetAdminUserInfo()
  22206. errlog := &models.HisOrderError{
  22207. UserOrgId: adminUser.CurrentOrgId,
  22208. Ctime: time.Now().Unix(),
  22209. Mtime: time.Now().Unix(),
  22210. ErrMsg: res.ErrMsg,
  22211. Status: 1,
  22212. PatientId: id,
  22213. RecordTime: recordDateTime,
  22214. Stage: 4,
  22215. }
  22216. service.CreateErrMsgLog(errlog)
  22217. c.ServeSuccessJSON(map[string]interface{}{
  22218. "failed_code": -10,
  22219. "msg": res.ErrMsg,
  22220. })
  22221. return
  22222. }
  22223. }
  22224. }
  22225. }
  22226. // 退款
  22227. func (c *HisApiController) Refund() {
  22228. order_id, _ := c.GetInt64("order_id")
  22229. admin_user_id, _ := c.GetInt64("admin_user_id")
  22230. adminUser := c.GetAdminUserInfo()
  22231. var order models.HisOrder
  22232. order, _ = service.GetHisOrderByID(order_id)
  22233. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  22234. if order.ID == 0 {
  22235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22236. return
  22237. }
  22238. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  22239. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  22240. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  22241. if config.IsOpen == 1 { //对接了医保,走医保流程
  22242. var res ResultSixteen
  22243. var ahres ResultSevenAH
  22244. var resSixteen10265 ResultSixteen10265
  22245. var resSixteen10265Two ResultSixteen10265Two
  22246. var gz ResultgzSixteen10265Two
  22247. var src_resquest string
  22248. var result string
  22249. if miConfig.MdtrtareaAdmvs == "421300" {
  22250. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  22251. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22252. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22253. resp3, requestErr3 := http.Get(api3)
  22254. if requestErr3 != nil {
  22255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22256. return
  22257. }
  22258. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22259. if ioErr3 != nil {
  22260. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22262. return
  22263. }
  22264. var respJSON3 map[string]interface{}
  22265. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22266. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22268. return
  22269. }
  22270. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22271. userJSONBytes3, _ := json.Marshal(respJSON3)
  22272. fmt.Println("log")
  22273. fmt.Println(string(userJSONBytes3))
  22274. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  22275. utils.ErrorLog("解析失败:%v", err)
  22276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22277. return
  22278. }
  22279. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22280. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  22281. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22282. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22283. resp3, requestErr3 := http.Get(api3)
  22284. if requestErr3 != nil {
  22285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22286. return
  22287. }
  22288. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22289. if ioErr3 != nil {
  22290. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22292. return
  22293. }
  22294. var respJSON3 map[string]interface{}
  22295. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22298. return
  22299. }
  22300. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22301. userJSONBytes3, _ := json.Marshal(respJSON3)
  22302. fmt.Println("log")
  22303. fmt.Println(string(userJSONBytes3))
  22304. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  22305. utils.ErrorLog("解析失败:%v", err)
  22306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22307. return
  22308. }
  22309. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22310. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  22311. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22312. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22313. resp3, requestErr3 := http.Get(api3)
  22314. if requestErr3 != nil {
  22315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22316. return
  22317. }
  22318. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22319. if ioErr3 != nil {
  22320. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22322. return
  22323. }
  22324. var respJSON3 map[string]interface{}
  22325. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22326. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22328. return
  22329. }
  22330. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22331. userJSONBytes3, _ := json.Marshal(respJSON3)
  22332. fmt.Println("log")
  22333. fmt.Println(string(userJSONBytes3))
  22334. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  22335. utils.ErrorLog("解析失败:%v", err)
  22336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22337. return
  22338. }
  22339. }else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22340. var api3 string
  22341. if miConfig.MdtrtareaAdmvs == "320921" {
  22342. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  22343. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22344. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22345. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22346. } else {
  22347. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22348. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  22349. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22350. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22351. }
  22352. resp3, requestErr3 := http.Get(api3)
  22353. if requestErr3 != nil {
  22354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22355. return
  22356. }
  22357. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22358. if ioErr3 != nil {
  22359. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22361. return
  22362. }
  22363. var respJSON3 map[string]interface{}
  22364. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22367. return
  22368. }
  22369. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22370. userJSONBytes3, _ := json.Marshal(respJSON3)
  22371. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  22372. utils.ErrorLog("解析失败:%v", err)
  22373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22374. return
  22375. }
  22376. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  22377. res.Output = resSixteen10265.Output
  22378. res.ErrMsg = resSixteen10265.ErrMsg
  22379. res.Cainfo = resSixteen10265.Cainfo
  22380. res.WarnMsg = resSixteen10265.WarnMsg
  22381. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  22382. res.Infcode = infocode
  22383. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22384. var api3 string
  22385. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  22386. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22387. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22388. resp3, requestErr3 := http.Get(api3)
  22389. if requestErr3 != nil {
  22390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22391. return
  22392. }
  22393. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22394. if ioErr3 != nil {
  22395. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22397. return
  22398. }
  22399. var respJSON3 map[string]interface{}
  22400. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22401. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22403. return
  22404. }
  22405. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22406. userJSONBytes3, _ := json.Marshal(respJSON3)
  22407. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  22408. utils.ErrorLog("解析失败:%v", err)
  22409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22410. return
  22411. }
  22412. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  22413. res.Output = resSixteen10265.Output
  22414. res.ErrMsg = resSixteen10265.ErrMsg
  22415. res.Cainfo = resSixteen10265.Cainfo
  22416. res.WarnMsg = resSixteen10265.WarnMsg
  22417. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  22418. res.Infcode = infocode
  22419. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22420. result, src_resquest, _ = service.FJyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  22421. var dat map[string]interface{}
  22422. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22423. fmt.Println(dat)
  22424. } else {
  22425. fmt.Println(err)
  22426. }
  22427. saveLog(result, src_resquest, "2208", "退费")
  22428. userJSONBytes, _ := json.Marshal(dat)
  22429. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22430. utils.ErrorLog("解析失败:%v", err)
  22431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22432. return
  22433. }
  22434. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22435. result, src_resquest = service.Jxyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, miConfig.AccessKey, "")
  22436. var dat map[string]interface{}
  22437. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22438. fmt.Println(dat)
  22439. } else {
  22440. fmt.Println(err)
  22441. }
  22442. saveLog(result, src_resquest, "2208", "退费")
  22443. userJSONBytes, _ := json.Marshal(dat)
  22444. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22445. utils.ErrorLog("解析失败:%v", err)
  22446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22447. return
  22448. }
  22449. } else if miConfig.MdtrtareaAdmvs == "341203" {
  22450. var api3 string
  22451. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  22452. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22453. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22454. resp3, requestErr3 := http.Get(api3)
  22455. if requestErr3 != nil {
  22456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22457. return
  22458. }
  22459. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22460. if ioErr3 != nil {
  22461. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22463. return
  22464. }
  22465. var respJSON3 map[string]interface{}
  22466. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22469. return
  22470. }
  22471. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  22472. if status == "0"{
  22473. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  22474. c.ServeSuccessJSON(map[string]interface{}{
  22475. "failed_code": -10,
  22476. "msg": err_msg,
  22477. })
  22478. return
  22479. }
  22480. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22481. userJSONBytes3, _ := json.Marshal(respJSON3)
  22482. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  22483. // utils.ErrorLog("解析失败:%v", err)
  22484. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22485. // return
  22486. //}
  22487. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  22488. utils.ErrorLog("解析失败:%v", err)
  22489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22490. return
  22491. }
  22492. res.InfRefmsgid = ahres.InfRefmsgid
  22493. timestamp := int64( ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  22494. // 创建对应的Time类型
  22495. t := time.UnixMilli(timestamp)
  22496. // 格式化成指定的日期字符串
  22497. str := t.Format("2006-01-02 15:04:05")
  22498. res.Output.Setlinfo.SetlTime = str
  22499. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  22500. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  22501. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  22502. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  22503. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  22504. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  22505. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  22506. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  22507. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  22508. //
  22509. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  22510. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  22511. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  22512. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  22513. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  22514. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  22515. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  22516. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  22517. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  22518. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  22519. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22520. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  22521. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  22522. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  22523. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  22524. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  22525. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  22526. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  22527. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  22528. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  22529. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  22530. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  22531. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  22532. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  22533. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  22534. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  22535. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  22536. //res.Output.Setldetail = ahres.Output.Setldetail
  22537. res.ErrMsg = ahres.ErrMsg
  22538. res.Cainfo = ahres.Cainfo
  22539. res.WarnMsg = ahres.WarnMsg
  22540. res.Infcode = ahres.Infcode
  22541. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22542. result, src_resquest = service.Hnyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, miConfig.AccessKey, "")
  22543. var dat map[string]interface{}
  22544. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22545. fmt.Println(dat)
  22546. } else {
  22547. fmt.Println(err)
  22548. }
  22549. saveLog(result, src_resquest, "2208", "退费")
  22550. userJSONBytes, _ := json.Marshal(dat)
  22551. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22552. utils.ErrorLog("解析失败:%v", err)
  22553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22554. return
  22555. }
  22556. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22557. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  22558. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22559. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22560. resp3, requestErr3 := http.Get(api3)
  22561. if requestErr3 != nil {
  22562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22563. return
  22564. }
  22565. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22566. if ioErr3 != nil {
  22567. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22569. return
  22570. }
  22571. var respJSON3 map[string]interface{}
  22572. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22573. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22575. return
  22576. }
  22577. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22578. userJSONBytes3, _ := json.Marshal(respJSON3)
  22579. fmt.Println("log")
  22580. fmt.Println(string(userJSONBytes3))
  22581. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  22582. utils.ErrorLog("解析失败:%v", err)
  22583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22584. return
  22585. }
  22586. } else {
  22587. if miConfig.Code == "H15049901371" {
  22588. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id)
  22589. var dat map[string]interface{}
  22590. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22591. fmt.Println(dat)
  22592. } else {
  22593. fmt.Println(err)
  22594. }
  22595. saveLog(result, src_resquest, "2208", "退费")
  22596. userJSONBytes, _ := json.Marshal(dat)
  22597. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  22598. utils.ErrorLog("解析失败:%v", err)
  22599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22600. return
  22601. }
  22602. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  22603. res.Output = resSixteen10265.Output
  22604. res.ErrMsg = resSixteen10265.ErrMsg
  22605. res.Cainfo = resSixteen10265.Cainfo
  22606. res.WarnMsg = resSixteen10265.WarnMsg
  22607. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  22608. res.Infcode = infocode
  22609. } else {
  22610. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id)
  22611. var dat map[string]interface{}
  22612. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22613. fmt.Println(dat)
  22614. } else {
  22615. fmt.Println(err)
  22616. }
  22617. saveLog(result, src_resquest, "2208", "退费")
  22618. userJSONBytes, _ := json.Marshal(dat)
  22619. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  22620. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  22621. utils.ErrorLog("解析失败:%v", err)
  22622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22623. return
  22624. }
  22625. res.Infcode = gz.Infcode
  22626. } else {
  22627. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22628. utils.ErrorLog("解析失败:%v", err)
  22629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22630. return
  22631. }
  22632. }
  22633. }
  22634. }
  22635. if res.Infcode == 0 {
  22636. var res2 ResultSix
  22637. var resSix10265 ResultSix10265
  22638. if miConfig.MdtrtareaAdmvs == "421300" {
  22639. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  22640. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22641. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22642. resp3, requestErr3 := http.Get(api3)
  22643. if requestErr3 != nil {
  22644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22645. return
  22646. }
  22647. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22648. if ioErr3 != nil {
  22649. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22651. return
  22652. }
  22653. var respJSON3 map[string]interface{}
  22654. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22655. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22657. return
  22658. }
  22659. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22660. userJSONBytes3, _ := json.Marshal(respJSON3)
  22661. fmt.Println("log")
  22662. fmt.Println(string(userJSONBytes3))
  22663. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  22664. utils.ErrorLog("解析失败:%v", err)
  22665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22666. return
  22667. }
  22668. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22669. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  22670. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22671. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22672. resp3, requestErr3 := http.Get(api3)
  22673. if requestErr3 != nil {
  22674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22675. return
  22676. }
  22677. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22678. if ioErr3 != nil {
  22679. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22681. return
  22682. }
  22683. var respJSON3 map[string]interface{}
  22684. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22685. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22687. return
  22688. }
  22689. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22690. userJSONBytes3, _ := json.Marshal(respJSON3)
  22691. fmt.Println("log")
  22692. fmt.Println(string(userJSONBytes3))
  22693. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  22694. utils.ErrorLog("解析失败:%v", err)
  22695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22696. return
  22697. }
  22698. }else if miConfig.MdtrtareaAdmvs == "421182" {
  22699. api3 :=miConfig.Url+ "hbyb/2205?psn_no=" + order.PsnNo +
  22700. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22701. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22702. resp3, requestErr3 := http.Get(api3)
  22703. if requestErr3 != nil {
  22704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22705. return
  22706. }
  22707. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22708. if ioErr3 != nil {
  22709. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22711. return
  22712. }
  22713. var respJSON3 map[string]interface{}
  22714. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22715. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22717. return
  22718. }
  22719. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22720. userJSONBytes3, _ := json.Marshal(respJSON3)
  22721. fmt.Println("log")
  22722. fmt.Println(string(userJSONBytes3))
  22723. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  22724. utils.ErrorLog("解析失败:%v", err)
  22725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22726. return
  22727. }
  22728. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22729. var api3 string
  22730. if miConfig.MdtrtareaAdmvs == "320921" {
  22731. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  22732. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22733. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22734. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22735. } else {
  22736. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22737. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  22738. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22739. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22740. }
  22741. resp3, requestErr3 := http.Get(api3)
  22742. if requestErr3 != nil {
  22743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22744. return
  22745. }
  22746. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22747. if ioErr3 != nil {
  22748. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22750. return
  22751. }
  22752. var respJSON3 map[string]interface{}
  22753. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22756. return
  22757. }
  22758. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22759. userJSONBytes3, _ := json.Marshal(respJSON3)
  22760. fmt.Println("log")
  22761. fmt.Println(string(userJSONBytes3))
  22762. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  22763. utils.ErrorLog("解析失败:%v", err)
  22764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22765. return
  22766. }
  22767. res2.InfRefmsgid = resSix10265.InfRefmsgid
  22768. res2.Output = resSix10265.Output
  22769. res2.ErrMsg = resSix10265.ErrMsg
  22770. res2.Cainfo = resSix10265.Cainfo
  22771. res2.WarnMsg = resSix10265.WarnMsg
  22772. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  22773. res2.Infcode = infocode
  22774. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22775. var api3 string
  22776. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  22777. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22778. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22779. resp3, requestErr3 := http.Get(api3)
  22780. if requestErr3 != nil {
  22781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22782. return
  22783. }
  22784. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22785. if ioErr3 != nil {
  22786. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22788. return
  22789. }
  22790. var respJSON3 map[string]interface{}
  22791. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22792. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22794. return
  22795. }
  22796. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22797. userJSONBytes3, _ := json.Marshal(respJSON3)
  22798. fmt.Println("log")
  22799. fmt.Println(string(userJSONBytes3))
  22800. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  22801. utils.ErrorLog("解析失败:%v", err)
  22802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22803. return
  22804. }
  22805. res2.InfRefmsgid = resSix10265.InfRefmsgid
  22806. res2.Output = resSix10265.Output
  22807. res2.ErrMsg = resSix10265.ErrMsg
  22808. res2.Cainfo = resSix10265.Cainfo
  22809. res2.WarnMsg = resSix10265.WarnMsg
  22810. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  22811. res2.Infcode = infocode
  22812. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22813. result2, src_request, _ := service.FJyb2205(order.PsnNo, order.MdtrtId, "0000", miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  22814. var dat map[string]interface{}
  22815. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  22816. fmt.Println(dat)
  22817. } else {
  22818. fmt.Println(err)
  22819. }
  22820. saveLog(result2, src_request, "2205", "撤销明细")
  22821. userJSONBytes, _ := json.Marshal(dat)
  22822. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22823. utils.ErrorLog("解析失败:%v", err)
  22824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22825. return
  22826. }
  22827. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22828. result2, src_request := service.Jxyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  22829. var dat map[string]interface{}
  22830. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  22831. fmt.Println(dat)
  22832. } else {
  22833. fmt.Println(err)
  22834. }
  22835. saveLog(result2, src_request, "2205", "撤销明细")
  22836. userJSONBytes, _ := json.Marshal(dat)
  22837. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22838. utils.ErrorLog("解析失败:%v", err)
  22839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22840. return
  22841. }
  22842. } else if miConfig.MdtrtareaAdmvs == "341203" {
  22843. var api3 string
  22844. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  22845. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22846. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22847. resp3, requestErr3 := http.Get(api3)
  22848. if requestErr3 != nil {
  22849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22850. return
  22851. }
  22852. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22853. if ioErr3 != nil {
  22854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22856. return
  22857. }
  22858. var respJSON3 map[string]interface{}
  22859. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22862. return
  22863. }
  22864. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  22865. if status == "0"{
  22866. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  22867. c.ServeSuccessJSON(map[string]interface{}{
  22868. "failed_code": -10,
  22869. "msg": err_msg,
  22870. })
  22871. return
  22872. }
  22873. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22874. userJSONBytes3, _ := json.Marshal(respJSON3)
  22875. fmt.Println("log")
  22876. fmt.Println(string(userJSONBytes3))
  22877. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  22878. utils.ErrorLog("解析失败:%v", err)
  22879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22880. return
  22881. }
  22882. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22883. result2, src_request := service.Hnyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  22884. var dat map[string]interface{}
  22885. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  22886. fmt.Println(dat)
  22887. } else {
  22888. fmt.Println(err)
  22889. }
  22890. saveLog(result2, src_request, "2205", "撤销明细")
  22891. userJSONBytes, _ := json.Marshal(dat)
  22892. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22893. utils.ErrorLog("解析失败:%v", err)
  22894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22895. return
  22896. }
  22897. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22898. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  22899. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22900. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22901. resp3, requestErr3 := http.Get(api3)
  22902. if requestErr3 != nil {
  22903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22904. return
  22905. }
  22906. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22907. if ioErr3 != nil {
  22908. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22910. return
  22911. }
  22912. var respJSON3 map[string]interface{}
  22913. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22914. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22916. return
  22917. }
  22918. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22919. userJSONBytes3, _ := json.Marshal(respJSON3)
  22920. fmt.Println("log")
  22921. fmt.Println(string(userJSONBytes3))
  22922. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  22923. utils.ErrorLog("解析失败:%v", err)
  22924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22925. return
  22926. }
  22927. } else {
  22928. if miConfig.Code == "H15049901371" {
  22929. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, admin_user_id)
  22930. var dat map[string]interface{}
  22931. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  22932. fmt.Println(dat)
  22933. } else {
  22934. fmt.Println(err)
  22935. }
  22936. saveLog(result2, src_request, "2205", "撤销明细")
  22937. userJSONBytes, _ := json.Marshal(dat)
  22938. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  22939. utils.ErrorLog("解析失败:%v", err)
  22940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22941. return
  22942. }
  22943. res2.InfRefmsgid = resSix10265.InfRefmsgid
  22944. res2.Output = resSix10265.Output
  22945. res2.ErrMsg = resSix10265.ErrMsg
  22946. res2.Cainfo = resSix10265.Cainfo
  22947. res2.WarnMsg = resSix10265.WarnMsg
  22948. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  22949. res2.Infcode = infocode
  22950. } else {
  22951. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  22952. res2.Infcode = 0
  22953. } else {
  22954. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, admin_user_id)
  22955. var dat map[string]interface{}
  22956. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  22957. fmt.Println(dat)
  22958. } else {
  22959. fmt.Println(err)
  22960. }
  22961. saveLog(result2, src_request, "2205", "撤销明细")
  22962. userJSONBytes, _ := json.Marshal(dat)
  22963. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  22964. utils.ErrorLog("解析失败:%v", err)
  22965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22966. return
  22967. }
  22968. }
  22969. }
  22970. }
  22971. if res2.Infcode == -1 {
  22972. c.ServeSuccessJSON(map[string]interface{}{
  22973. "failed_code": -10,
  22974. "msg": res2.ErrMsg,
  22975. })
  22976. return
  22977. }
  22978. if res2.Infcode == 0 {
  22979. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  22980. if err == nil {
  22981. //当押金不为零时产生退费记录
  22982. if order.Decimal != 0 {
  22983. tmp := strconv.FormatInt(order.ID, 10)
  22984. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  22985. if err != nil {
  22986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22987. return
  22988. }
  22989. }
  22990. c.ServeSuccessJSON(map[string]interface{}{
  22991. "msg": "退费成功",
  22992. })
  22993. } else {
  22994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22995. return
  22996. }
  22997. } else {
  22998. c.ServeSuccessJSON(map[string]interface{}{
  22999. "failed_code": -10,
  23000. "msg": res2.ErrMsg,
  23001. })
  23002. }
  23003. } else {
  23004. c.ServeSuccessJSON(map[string]interface{}{
  23005. "failed_code": -10,
  23006. "msg": res.ErrMsg,
  23007. })
  23008. }
  23009. }
  23010. }
  23011. func (c *HisApiController) RefundNumber() {
  23012. record_time := c.GetString("record_time")
  23013. //patient_id, _ := c.GetInt64("patient_id")
  23014. admin_user_id, _ := c.GetInt64("admin_user_id")
  23015. his_patient_id, _ := c.GetInt64("id")
  23016. timeLayout := "2006-01-02"
  23017. loc, _ := time.LoadLocation("Local")
  23018. adminUser := c.GetAdminUserInfo()
  23019. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23020. fmt.Println(err)
  23021. if err != nil {
  23022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23023. return
  23024. }
  23025. recordDateTime := theTime.Unix()
  23026. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  23027. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  23028. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  23029. //order, _ := service.GetHisOrderByID(order_id)
  23030. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  23031. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23032. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  23033. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  23034. if count > 0 {
  23035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  23036. return
  23037. }
  23038. if config.IsOpen == 1 { //对接了医保,走医保流程
  23039. var res2 ResultSix
  23040. var res3 GZResultSix
  23041. var resSix10265 ResultSix10265
  23042. if miConfig.MdtrtareaAdmvs == "421300" {
  23043. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  23044. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23045. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23046. resp3, requestErr3 := http.Get(api3)
  23047. if requestErr3 != nil {
  23048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23049. return
  23050. }
  23051. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23052. if ioErr3 != nil {
  23053. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23055. return
  23056. }
  23057. var respJSON3 map[string]interface{}
  23058. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23059. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23061. return
  23062. }
  23063. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23064. userJSONBytes3, _ := json.Marshal(respJSON3)
  23065. fmt.Println("log")
  23066. fmt.Println(string(userJSONBytes3))
  23067. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23068. utils.ErrorLog("解析失败:%v", err)
  23069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23070. return
  23071. }
  23072. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23073. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  23074. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23075. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23076. resp3, requestErr3 := http.Get(api3)
  23077. if requestErr3 != nil {
  23078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23079. return
  23080. }
  23081. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23082. if ioErr3 != nil {
  23083. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23085. return
  23086. }
  23087. var respJSON3 map[string]interface{}
  23088. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23089. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23091. return
  23092. }
  23093. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23094. userJSONBytes3, _ := json.Marshal(respJSON3)
  23095. fmt.Println("log")
  23096. fmt.Println(string(userJSONBytes3))
  23097. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23098. utils.ErrorLog("解析失败:%v", err)
  23099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23100. return
  23101. }
  23102. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23103. api3 :=miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  23104. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23105. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23106. resp3, requestErr3 := http.Get(api3)
  23107. if requestErr3 != nil {
  23108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23109. return
  23110. }
  23111. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23112. if ioErr3 != nil {
  23113. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23115. return
  23116. }
  23117. var respJSON3 map[string]interface{}
  23118. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23119. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23121. return
  23122. }
  23123. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23124. userJSONBytes3, _ := json.Marshal(respJSON3)
  23125. fmt.Println("log")
  23126. fmt.Println(string(userJSONBytes3))
  23127. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23128. utils.ErrorLog("解析失败:%v", err)
  23129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23130. return
  23131. }
  23132. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23133. var api3 string
  23134. if miConfig.MdtrtareaAdmvs == "320921" {
  23135. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  23136. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23137. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23138. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23139. } else {
  23140. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23141. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  23142. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23143. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23144. }
  23145. resp3, requestErr3 := http.Get(api3)
  23146. if requestErr3 != nil {
  23147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23148. return
  23149. }
  23150. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23151. if ioErr3 != nil {
  23152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23154. return
  23155. }
  23156. var respJSON3 map[string]interface{}
  23157. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23160. return
  23161. }
  23162. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23163. userJSONBytes3, _ := json.Marshal(respJSON3)
  23164. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23165. utils.ErrorLog("解析失败:%v", err)
  23166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23167. return
  23168. }
  23169. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23170. res2.Output = resSix10265.Output
  23171. res2.ErrMsg = resSix10265.ErrMsg
  23172. res2.Cainfo = resSix10265.Cainfo
  23173. res2.WarnMsg = resSix10265.WarnMsg
  23174. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23175. res2.Infcode = infocode
  23176. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23177. var api3 string
  23178. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  23179. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23180. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23181. resp3, requestErr3 := http.Get(api3)
  23182. if requestErr3 != nil {
  23183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23184. return
  23185. }
  23186. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23187. if ioErr3 != nil {
  23188. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23190. return
  23191. }
  23192. var respJSON3 map[string]interface{}
  23193. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23194. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23196. return
  23197. }
  23198. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23199. userJSONBytes3, _ := json.Marshal(respJSON3)
  23200. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23201. utils.ErrorLog("解析失败:%v", err)
  23202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23203. return
  23204. }
  23205. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23206. res2.Output = resSix10265.Output
  23207. res2.ErrMsg = resSix10265.ErrMsg
  23208. res2.Cainfo = resSix10265.Cainfo
  23209. res2.WarnMsg = resSix10265.WarnMsg
  23210. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23211. res2.Infcode = infocode
  23212. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23213. result, request, _ := service.FJyb2202(his.PsnNo, his.Number, his.IptOtpNo, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  23214. var dat map[string]interface{}
  23215. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23216. fmt.Println(dat)
  23217. } else {
  23218. fmt.Println(err)
  23219. }
  23220. saveLog(result, request, "2202", "退号")
  23221. userJSONBytes, _ := json.Marshal(dat)
  23222. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23223. utils.ErrorLog("解析失败:%v", err)
  23224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23225. return
  23226. }
  23227. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23228. result, request := service.Jxyb2202(his.PsnNo, his.Number, his.IptOtpNo, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  23229. var dat map[string]interface{}
  23230. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23231. fmt.Println(dat)
  23232. } else {
  23233. fmt.Println(err)
  23234. }
  23235. saveLog(result, request, "2202", "退号")
  23236. userJSONBytes, _ := json.Marshal(dat)
  23237. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23238. utils.ErrorLog("解析失败:%v", err)
  23239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23240. return
  23241. }
  23242. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23243. var api3 string
  23244. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  23245. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23246. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23247. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23248. resp3, requestErr3 := http.Get(api3)
  23249. if requestErr3 != nil {
  23250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23251. return
  23252. }
  23253. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23254. if ioErr3 != nil {
  23255. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23257. return
  23258. }
  23259. var respJSON3 map[string]interface{}
  23260. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23261. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23263. return
  23264. }
  23265. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  23266. if status == "0"{
  23267. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  23268. c.ServeSuccessJSON(map[string]interface{}{
  23269. "failed_code": -10,
  23270. "msg": err_msg,
  23271. })
  23272. return
  23273. }
  23274. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23275. userJSONBytes3, _ := json.Marshal(respJSON3)
  23276. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23277. utils.ErrorLog("解析失败:%v", err)
  23278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23279. return
  23280. }
  23281. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  23282. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23283. result, request := service.Hnyb2202(his.PsnNo, his.Number, his.IptOtpNo, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  23284. var dat map[string]interface{}
  23285. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23286. fmt.Println(dat)
  23287. } else {
  23288. fmt.Println(err)
  23289. }
  23290. saveLog(result, request, "2202", "退号")
  23291. userJSONBytes, _ := json.Marshal(dat)
  23292. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23293. utils.ErrorLog("解析失败:%v", err)
  23294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23295. return
  23296. }
  23297. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23298. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  23299. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23300. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  23301. resp3, requestErr3 := http.Get(api3)
  23302. if requestErr3 != nil {
  23303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23304. return
  23305. }
  23306. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23307. if ioErr3 != nil {
  23308. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23310. return
  23311. }
  23312. var respJSON3 map[string]interface{}
  23313. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23314. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23316. return
  23317. }
  23318. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23319. userJSONBytes3, _ := json.Marshal(respJSON3)
  23320. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23321. utils.ErrorLog("解析失败:%v", err)
  23322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23323. return
  23324. }
  23325. } else {
  23326. var api3 string
  23327. if miConfig.Code == "H15049901371" {
  23328. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  23329. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23330. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23331. } else {
  23332. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  23333. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23334. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  23335. }
  23336. resp3, requestErr3 := http.Get(api3)
  23337. if requestErr3 != nil {
  23338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23339. return
  23340. }
  23341. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23342. if ioErr3 != nil {
  23343. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23345. return
  23346. }
  23347. var respJSON3 map[string]interface{}
  23348. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23349. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23351. return
  23352. }
  23353. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23354. userJSONBytes3, _ := json.Marshal(respJSON3)
  23355. if miConfig.Code == "H15049901371" {
  23356. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23357. utils.ErrorLog("解析失败:%v", err)
  23358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23359. return
  23360. }
  23361. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23362. res2.Output = resSix10265.Output
  23363. res2.ErrMsg = resSix10265.ErrMsg
  23364. res2.Cainfo = resSix10265.Cainfo
  23365. res2.WarnMsg = resSix10265.WarnMsg
  23366. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23367. res2.Infcode = infocode
  23368. } else {
  23369. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23370. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  23371. utils.ErrorLog("解析失败:%v", err)
  23372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23373. return
  23374. }
  23375. res2.Infcode = res3.Infcode
  23376. } else {
  23377. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23378. utils.ErrorLog("解析失败:%v", err)
  23379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23380. return
  23381. }
  23382. }
  23383. }
  23384. }
  23385. if res2.Infcode == -1{
  23386. utils.ErrorLog("解析失败:%v", res2.Infcode)
  23387. c.ServeSuccessJSON(map[string]interface{}{
  23388. "failed_code": -10,
  23389. "msg": res2.ErrMsg,
  23390. })
  23391. return
  23392. }
  23393. if res2.Infcode == 0 {
  23394. if err == nil {
  23395. c.ServeSuccessJSON(map[string]interface{}{
  23396. "msg": "退号成功",
  23397. })
  23398. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  23399. } else {
  23400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23401. return
  23402. }
  23403. }
  23404. } else {
  23405. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  23406. //if err == nil {
  23407. // c.ServeSuccessJSON(map[string]interface{}{
  23408. // "msg": "退费成功",
  23409. // })
  23410. //} else {
  23411. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23412. // return
  23413. //}
  23414. }
  23415. }
  23416. func (c *HisApiController) RefundDetail() {
  23417. order_id, _ := c.GetInt64("order_id")
  23418. admin_user_id, _ := c.GetInt64("admin_user_id")
  23419. //his_patient_id, _ := c.GetInt64("his_patient_id")
  23420. number := c.GetString("number")
  23421. record_time := c.GetString("record_time")
  23422. patient_id, _ := c.GetInt64("patient_id")
  23423. //med_type, _ := c.GetInt64("med_type")
  23424. timeLayout := "2006-01-02"
  23425. loc, _ := time.LoadLocation("Local")
  23426. adminUser := c.GetAdminUserInfo()
  23427. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  23428. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23429. fmt.Println(err)
  23430. if err != nil {
  23431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23432. return
  23433. }
  23434. recordDateTime := theTime.Unix()
  23435. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  23436. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  23437. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  23438. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23439. var order models.HisOrder
  23440. order, _ = service.GetHisOrderByID(order_id)
  23441. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  23442. if config.IsOpen == 1 { //对接了医保,走医保流程
  23443. var res2 ResultSix
  23444. if miConfig.MdtrtareaAdmvs == "421300" {
  23445. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  23446. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23447. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23448. resp3, requestErr3 := http.Get(api3)
  23449. if requestErr3 != nil {
  23450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23451. return
  23452. }
  23453. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23454. if ioErr3 != nil {
  23455. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23457. return
  23458. }
  23459. var respJSON3 map[string]interface{}
  23460. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23461. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23463. return
  23464. }
  23465. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23466. userJSONBytes3, _ := json.Marshal(respJSON3)
  23467. fmt.Println("log")
  23468. fmt.Println(string(userJSONBytes3))
  23469. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23470. utils.ErrorLog("解析失败:%v", err)
  23471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23472. return
  23473. }
  23474. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23475. if err == nil {
  23476. c.ServeSuccessJSON(map[string]interface{}{
  23477. "msg": "撤销明细成功",
  23478. })
  23479. return
  23480. } else {
  23481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23482. return
  23483. }
  23484. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23485. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  23486. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23487. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23488. resp3, requestErr3 := http.Get(api3)
  23489. if requestErr3 != nil {
  23490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23491. return
  23492. }
  23493. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23494. if ioErr3 != nil {
  23495. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23497. return
  23498. }
  23499. var respJSON3 map[string]interface{}
  23500. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23503. return
  23504. }
  23505. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23506. userJSONBytes3, _ := json.Marshal(respJSON3)
  23507. fmt.Println("log")
  23508. fmt.Println(string(userJSONBytes3))
  23509. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23510. utils.ErrorLog("解析失败:%v", err)
  23511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23512. return
  23513. }
  23514. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23515. if err == nil {
  23516. c.ServeSuccessJSON(map[string]interface{}{
  23517. "msg": "撤销明细成功",
  23518. })
  23519. return
  23520. } else {
  23521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23522. return
  23523. }
  23524. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23525. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  23526. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23527. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23528. resp3, requestErr3 := http.Get(api3)
  23529. if requestErr3 != nil {
  23530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23531. return
  23532. }
  23533. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23534. if ioErr3 != nil {
  23535. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23537. return
  23538. }
  23539. var respJSON3 map[string]interface{}
  23540. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23541. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23543. return
  23544. }
  23545. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23546. userJSONBytes3, _ := json.Marshal(respJSON3)
  23547. fmt.Println("log")
  23548. fmt.Println(string(userJSONBytes3))
  23549. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23550. utils.ErrorLog("解析失败:%v", err)
  23551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23552. return
  23553. }
  23554. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23555. if err == nil {
  23556. c.ServeSuccessJSON(map[string]interface{}{
  23557. "msg": "撤销明细成功",
  23558. })
  23559. return
  23560. } else {
  23561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23562. return
  23563. }
  23564. }else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23565. var resSix10265 ResultSix10265
  23566. var api3 string
  23567. if miConfig.MdtrtareaAdmvs == "320921" {
  23568. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  23569. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23570. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23571. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23572. } else {
  23573. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23574. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  23575. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23576. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23577. }
  23578. resp3, requestErr3 := http.Get(api3)
  23579. utils.ErrorLog("接口: %v", requestErr3)
  23580. if requestErr3 != nil {
  23581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23582. return
  23583. }
  23584. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23585. if ioErr3 != nil {
  23586. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23588. return
  23589. }
  23590. var respJSON3 map[string]interface{}
  23591. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23592. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23594. return
  23595. }
  23596. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23597. userJSONBytes3, _ := json.Marshal(respJSON3)
  23598. fmt.Println("log")
  23599. fmt.Println(string(userJSONBytes3))
  23600. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23601. utils.ErrorLog("解析失败:%v", err)
  23602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23603. return
  23604. }
  23605. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23606. res2.Output = resSix10265.Output
  23607. res2.ErrMsg = resSix10265.ErrMsg
  23608. res2.Cainfo = resSix10265.Cainfo
  23609. res2.WarnMsg = resSix10265.WarnMsg
  23610. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23611. res2.Infcode = infocode
  23612. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23613. if err == nil {
  23614. c.ServeSuccessJSON(map[string]interface{}{
  23615. "msg": "撤销明细成功",
  23616. })
  23617. return
  23618. } else {
  23619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23620. return
  23621. }
  23622. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23623. var api3 string
  23624. api3 = miConfig.SecretKey+ "ahyb/2205?psn_no=" + order.PsnNo +
  23625. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23626. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23627. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23628. resp3, requestErr3 := http.Get(api3)
  23629. utils.ErrorLog("接口: %v", requestErr3)
  23630. if requestErr3 != nil {
  23631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23632. return
  23633. }
  23634. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23635. if ioErr3 != nil {
  23636. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23638. return
  23639. }
  23640. var respJSON3 map[string]interface{}
  23641. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23642. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23644. return
  23645. }
  23646. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  23647. if status == "0"{
  23648. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  23649. c.ServeSuccessJSON(map[string]interface{}{
  23650. "failed_code": -10,
  23651. "msg": err_msg,
  23652. })
  23653. return
  23654. }
  23655. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23656. userJSONBytes3, _ := json.Marshal(respJSON3)
  23657. fmt.Println("log")
  23658. fmt.Println(string(userJSONBytes3))
  23659. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23660. utils.ErrorLog("解析失败:%v", err)
  23661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23662. return
  23663. }
  23664. fmt.Println(res2.Infcode)
  23665. if res2.Infcode == -1{
  23666. c.ServeSuccessJSON(map[string]interface{}{
  23667. "failed_code": -10,
  23668. "msg": res2.ErrMsg,
  23669. })
  23670. return
  23671. }
  23672. if res2.Infcode == 0 {
  23673. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23674. if err == nil {
  23675. c.ServeSuccessJSON(map[string]interface{}{
  23676. "msg": "撤销明细成功",
  23677. })
  23678. return
  23679. } else {
  23680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23681. return
  23682. }
  23683. } else {
  23684. c.ServeSuccessJSON(map[string]interface{}{
  23685. "failed_code": -10,
  23686. "msg": res2.ErrMsg,
  23687. })
  23688. }
  23689. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23690. if err == nil {
  23691. c.ServeSuccessJSON(map[string]interface{}{
  23692. "msg": "撤销明细成功",
  23693. })
  23694. return
  23695. } else {
  23696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23697. return
  23698. }
  23699. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23700. var resSix10265 ResultSix10265
  23701. var api3 string
  23702. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  23703. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23704. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23705. resp3, requestErr3 := http.Get(api3)
  23706. if requestErr3 != nil {
  23707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23708. return
  23709. }
  23710. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23711. if ioErr3 != nil {
  23712. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23714. return
  23715. }
  23716. var respJSON3 map[string]interface{}
  23717. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23718. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23720. return
  23721. }
  23722. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23723. userJSONBytes3, _ := json.Marshal(respJSON3)
  23724. fmt.Println("log")
  23725. fmt.Println(string(userJSONBytes3))
  23726. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23727. utils.ErrorLog("解析失败:%v", err)
  23728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23729. return
  23730. }
  23731. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23732. res2.Output = resSix10265.Output
  23733. res2.ErrMsg = resSix10265.ErrMsg
  23734. res2.Cainfo = resSix10265.Cainfo
  23735. res2.WarnMsg = resSix10265.WarnMsg
  23736. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23737. res2.Infcode = infocode
  23738. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23739. if err == nil {
  23740. c.ServeSuccessJSON(map[string]interface{}{
  23741. "msg": "撤销明细成功",
  23742. })
  23743. return
  23744. } else {
  23745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23746. return
  23747. }
  23748. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23749. result2, src_request, _ := service.FJyb2205(his.PsnNo, his.Number, "0000", miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  23750. var dat map[string]interface{}
  23751. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23752. fmt.Println(dat)
  23753. } else {
  23754. fmt.Println(err)
  23755. }
  23756. saveLog(result2, src_request, "2205", "撤销明细")
  23757. userJSONBytes, _ := json.Marshal(dat)
  23758. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23759. utils.ErrorLog("解析失败:%v", err)
  23760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23761. return
  23762. }
  23763. if res2.Infcode == 0 {
  23764. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23765. if err == nil {
  23766. c.ServeSuccessJSON(map[string]interface{}{
  23767. "msg": "撤销明细成功",
  23768. })
  23769. return
  23770. } else {
  23771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23772. return
  23773. }
  23774. } else {
  23775. c.ServeSuccessJSON(map[string]interface{}{
  23776. "failed_code": -10,
  23777. "msg": res2.ErrMsg,
  23778. })
  23779. }
  23780. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23781. result2, src_request := service.Jxyb2205(his.PsnNo, his.Number, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  23782. var dat map[string]interface{}
  23783. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23784. fmt.Println(dat)
  23785. } else {
  23786. fmt.Println(err)
  23787. }
  23788. saveLog(result2, src_request, "2205", "撤销明细")
  23789. userJSONBytes, _ := json.Marshal(dat)
  23790. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23791. utils.ErrorLog("解析失败:%v", err)
  23792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23793. return
  23794. }
  23795. if res2.Infcode == 0 {
  23796. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23797. if err == nil {
  23798. c.ServeSuccessJSON(map[string]interface{}{
  23799. "msg": "撤销明细成功",
  23800. })
  23801. return
  23802. } else {
  23803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23804. return
  23805. }
  23806. } else {
  23807. c.ServeSuccessJSON(map[string]interface{}{
  23808. "failed_code": -10,
  23809. "msg": res2.ErrMsg,
  23810. })
  23811. }
  23812. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23813. result2, src_request := service.Hnyb2205(his.PsnNo, his.Number, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.AccessKey, "")
  23814. var dat map[string]interface{}
  23815. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23816. fmt.Println(dat)
  23817. } else {
  23818. fmt.Println(err)
  23819. }
  23820. saveLog(result2, src_request, "2205", "撤销明细")
  23821. userJSONBytes, _ := json.Marshal(dat)
  23822. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23823. utils.ErrorLog("解析失败:%v", err)
  23824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23825. return
  23826. }
  23827. if res2.Infcode == 0 {
  23828. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23829. if err == nil {
  23830. c.ServeSuccessJSON(map[string]interface{}{
  23831. "msg": "撤销明细成功",
  23832. })
  23833. return
  23834. } else {
  23835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23836. return
  23837. }
  23838. } else {
  23839. c.ServeSuccessJSON(map[string]interface{}{
  23840. "failed_code": -10,
  23841. "msg": res2.ErrMsg,
  23842. })
  23843. }
  23844. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23845. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  23846. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23847. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23848. resp2, requestErr2 := http.Get(api2)
  23849. if requestErr2 != nil {
  23850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23851. return
  23852. }
  23853. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  23854. if ioErr2 != nil {
  23855. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  23856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23857. return
  23858. }
  23859. var respJSON2 map[string]interface{}
  23860. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  23861. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23863. return
  23864. }
  23865. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23866. userJSONBytes3, _ := json.Marshal(respJSON2)
  23867. fmt.Println("log")
  23868. fmt.Println(string(userJSONBytes3))
  23869. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23870. utils.ErrorLog("解析失败:%v", err)
  23871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23872. return
  23873. }
  23874. if res2.Infcode == 0 {
  23875. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23876. if err == nil {
  23877. c.ServeSuccessJSON(map[string]interface{}{
  23878. "msg": "撤销明细成功",
  23879. })
  23880. return
  23881. } else {
  23882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23883. return
  23884. }
  23885. } else {
  23886. c.ServeSuccessJSON(map[string]interface{}{
  23887. "failed_code": -10,
  23888. "msg": res2.ErrMsg,
  23889. })
  23890. }
  23891. } else {
  23892. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  23893. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23894. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  23895. resp2, requestErr2 := http.Get(api2)
  23896. if requestErr2 != nil {
  23897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23898. return
  23899. }
  23900. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  23901. if ioErr2 != nil {
  23902. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  23903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23904. return
  23905. }
  23906. var respJSON2 map[string]interface{}
  23907. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  23908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23910. return
  23911. }
  23912. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23913. if err == nil {
  23914. c.ServeSuccessJSON(map[string]interface{}{
  23915. "msg": "撤销明细成功",
  23916. })
  23917. return
  23918. } else {
  23919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23920. return
  23921. }
  23922. }
  23923. } else {
  23924. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23925. if err == nil {
  23926. c.ServeSuccessJSON(map[string]interface{}{
  23927. "msg": "退费成功",
  23928. })
  23929. } else {
  23930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23931. return
  23932. }
  23933. }
  23934. }
  23935. // 对账
  23936. func (c *HisApiController) GetCheckAccount() {
  23937. start_time := c.GetString("start_time")
  23938. end_time := c.GetString("end_time")
  23939. insutype := c.GetString("insutype")
  23940. clr_type := c.GetString("clr_type")
  23941. clr_org := c.GetString("clr_optins")
  23942. admin_user_id, _ := c.GetInt64("admin_user_id")
  23943. adminUser := c.GetAdminUserInfo()
  23944. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  23945. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23946. if len(clr_org) == 0 {
  23947. clr_org = miConfig.InsuplcAdmdvs
  23948. }
  23949. timeLayout := "2006-01-02"
  23950. loc, _ := time.LoadLocation("Local")
  23951. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  23952. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  23953. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  23954. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  23955. fixmedins_setl_cnt := int64(len(orders))
  23956. var medfee_sumamt float64
  23957. var acct_pay float64
  23958. var fund_pay_sumamt float64
  23959. for _, item := range orders {
  23960. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  23961. acct_pay = acct_pay + item.AcctPay
  23962. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  23963. }
  23964. var user_name string
  23965. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  23966. if role.ID == 0 {
  23967. user_name = "xxx"
  23968. } else {
  23969. user_name = role.UserName
  23970. }
  23971. var res ResultEight
  23972. var res10188 ResultEightFor10188
  23973. if config.IsOpen == 1 {
  23974. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23975. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  23976. "insutype=" + insutype +
  23977. "&clr_type=" + clr_type +
  23978. "&setl_optins=" + clr_org +
  23979. "&stmt_begndate=" + start_time +
  23980. "&stm_enddate=" + end_time +
  23981. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  23982. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  23983. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  23984. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  23985. "&fixmedins_code=" + miConfig.Code +
  23986. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  23987. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23988. "&secret_key=" + miConfig.SecretKey +
  23989. "&org_name=" + miConfig.OrgName +
  23990. "&doctor=" + user_name +
  23991. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23992. fmt.Println(api)
  23993. resp, requestErr := http.Get(api)
  23994. if requestErr != nil {
  23995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23996. return
  23997. }
  23998. body, ioErr := ioutil.ReadAll(resp.Body)
  23999. fmt.Println(body)
  24000. if ioErr != nil {
  24001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24003. return
  24004. }
  24005. var respJSON map[string]interface{}
  24006. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24009. return
  24010. }
  24011. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24012. userJSONBytes, _ := json.Marshal(respJSON)
  24013. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24014. utils.ErrorLog("解析失败:%v", err)
  24015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24016. return
  24017. }
  24018. res.InfRefmsgid = res10188.InfRefmsgid
  24019. res.Output = res10188.Output
  24020. res.ErrMsg = res10188.ErrMsg
  24021. res.Cainfo = res10188.Cainfo
  24022. res.WarnMsg = res10188.WarnMsg
  24023. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  24024. res.Infcode = infocode
  24025. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24026. if clr_type != "9903" {
  24027. clr_type = "99" // 就诊 ID(来自2201接口返回)
  24028. }
  24029. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  24030. "insutype=" + insutype +
  24031. "&clr_type=" + clr_type +
  24032. "&setl_optins=" + clr_org +
  24033. "&stmt_begndate=" + start_time +
  24034. "&stm_enddate=" + end_time +
  24035. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24036. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24037. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24038. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  24039. "&fixmedins_code=" + miConfig.Code +
  24040. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24041. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24042. "&secret_key=" + miConfig.SecretKey +
  24043. "&org_name=" + miConfig.OrgName +
  24044. "&doctor=" + user_name
  24045. resp, requestErr := http.Get(api)
  24046. if requestErr != nil {
  24047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24048. return
  24049. }
  24050. body, ioErr := ioutil.ReadAll(resp.Body)
  24051. if ioErr != nil {
  24052. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24054. return
  24055. }
  24056. var respJSON map[string]interface{}
  24057. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24058. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24060. return
  24061. }
  24062. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24063. result, _ := json.Marshal(respJSON)
  24064. fmt.Println("log")
  24065. fmt.Println(string(result))
  24066. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  24067. utils.ErrorLog("解析失败:%v", err)
  24068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24069. return
  24070. }
  24071. res.InfRefmsgid = res10188.InfRefmsgid
  24072. res.Output = res10188.Output
  24073. res.ErrMsg = res10188.ErrMsg
  24074. res.Cainfo = res10188.Cainfo
  24075. res.WarnMsg = res10188.WarnMsg
  24076. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  24077. res.Infcode = infocode
  24078. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24079. var baseParams models.BaseParams
  24080. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  24081. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  24082. baseParams.SecretKey = miConfig.SecretKey
  24083. baseParams.OrgName = miConfig.OrgName
  24084. baseParams.FixmedinsCode = miConfig.Code
  24085. baseParams.EncKey = miConfig.EncKey
  24086. baseParams.AppSecret = miConfig.AppSecret
  24087. baseParams.SignKey = miConfig.SignKey
  24088. baseParams.AppID = miConfig.Code
  24089. baseParams.Doctor = role.UserName
  24090. baseParams.RequestUrl = miConfig.Url
  24091. businessParams := models.BusinessParams{
  24092. Insutype: insutype,
  24093. ClrType: clr_type,
  24094. SetlOptins: clr_org,
  24095. StmtBegndate: start_time,
  24096. StmtEnddate: end_time,
  24097. MedfeeSumamt: medfee_sumamt,
  24098. FundPaySumamt: fund_pay_sumamt,
  24099. AcctPay: acct_pay,
  24100. FixmedinsSetlCnt: fixmedins_setl_cnt,
  24101. }
  24102. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  24103. fmt.Println(requestLog)
  24104. fmt.Println(result)
  24105. fmt.Println(err_msg)
  24106. var dat map[string]interface{}
  24107. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24108. fmt.Println(dat)
  24109. } else {
  24110. fmt.Println(err)
  24111. }
  24112. userJSONBytes, _ := json.Marshal(dat)
  24113. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24114. utils.ErrorLog("解析失败:%v", err)
  24115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24116. return
  24117. }
  24118. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24119. var baseParams models.BaseParams
  24120. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  24121. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  24122. baseParams.SecretKey = miConfig.SecretKey
  24123. baseParams.OrgName = miConfig.OrgName
  24124. baseParams.FixmedinsCode = miConfig.Code
  24125. baseParams.EncKey = miConfig.EncKey
  24126. baseParams.AppSecret = miConfig.AppSecret
  24127. baseParams.SignKey = miConfig.SignKey
  24128. baseParams.AppID = miConfig.Code
  24129. baseParams.Doctor = role.UserName
  24130. baseParams.RequestUrl = miConfig.Url
  24131. baseParams.AccessKey = miConfig.AccessKey
  24132. businessParams := models.BusinessParams{
  24133. Insutype: insutype,
  24134. ClrType: clr_type,
  24135. SetlOptins: "430822",
  24136. StmtBegndate: start_time,
  24137. StmtEnddate: end_time,
  24138. MedfeeSumamt: medfee_sumamt,
  24139. FundPaySumamt: fund_pay_sumamt,
  24140. AcctPay: acct_pay,
  24141. FixmedinsSetlCnt: fixmedins_setl_cnt,
  24142. }
  24143. result, requestLog := service.Hnyb3201(businessParams.FixmedinsSetlCnt, businessParams.AcctPay, businessParams.FundPaySumamt, businessParams.MedfeeSumamt, businessParams.StmtBegndate, businessParams.StmtEnddate, businessParams.SetlOptins, businessParams.ClrType, businessParams.Insutype, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.RequestUrl, baseParams.AccessKey, baseParams.SecretKey, baseParams.Cainfo)
  24144. fmt.Println(requestLog)
  24145. fmt.Println(result)
  24146. var dat map[string]interface{}
  24147. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24148. fmt.Println(dat)
  24149. } else {
  24150. fmt.Println(err)
  24151. }
  24152. userJSONBytes, _ := json.Marshal(dat)
  24153. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24154. utils.ErrorLog("解析失败:%v", err)
  24155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24156. return
  24157. }
  24158. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24159. var baseParams models.BaseParams
  24160. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  24161. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  24162. baseParams.SecretKey = miConfig.SecretKey
  24163. baseParams.OrgName = miConfig.OrgName
  24164. baseParams.FixmedinsCode = miConfig.Code
  24165. baseParams.EncKey = miConfig.EncKey
  24166. baseParams.AppSecret = miConfig.AppSecret
  24167. baseParams.SignKey = miConfig.SignKey
  24168. baseParams.AppID = miConfig.Code
  24169. baseParams.Doctor = role.UserName
  24170. baseParams.RequestUrl = miConfig.Url
  24171. businessParams := models.BusinessParams{
  24172. Insutype: insutype,
  24173. ClrType: clr_type,
  24174. SetlOptins: clr_org,
  24175. StmtBegndate: start_time,
  24176. StmtEnddate: end_time,
  24177. MedfeeSumamt: medfee_sumamt,
  24178. FundPaySumamt: fund_pay_sumamt,
  24179. AcctPay: acct_pay,
  24180. FixmedinsSetlCnt: fixmedins_setl_cnt,
  24181. }
  24182. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  24183. fmt.Println(requestLog)
  24184. fmt.Println(result)
  24185. fmt.Println(err_msg)
  24186. var dat map[string]interface{}
  24187. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24188. fmt.Println(dat)
  24189. } else {
  24190. fmt.Println(err)
  24191. }
  24192. userJSONBytes, _ := json.Marshal(dat)
  24193. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24194. utils.ErrorLog("解析失败:%v", err)
  24195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24196. return
  24197. }
  24198. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24199. if len(clr_type) == 0 {
  24200. clr_type = "11"
  24201. }
  24202. api := miConfig.Url + "gdyb/ten?" +
  24203. "insutype=" + insutype +
  24204. "&clr_type=" + clr_type +
  24205. "&setl_optins=" + clr_org +
  24206. "&stmt_begndate=" + start_time +
  24207. "&stm_enddate=" + end_time +
  24208. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24209. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24210. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24211. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  24212. "&fixmedins_code=" + miConfig.Code +
  24213. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24214. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24215. "&secret_key=" + miConfig.SecretKey +
  24216. "&org_name=" + miConfig.OrgName +
  24217. "&doctor=" + user_name
  24218. fmt.Println(api)
  24219. resp, requestErr := http.Get(api)
  24220. if requestErr != nil {
  24221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24222. return
  24223. }
  24224. body, ioErr := ioutil.ReadAll(resp.Body)
  24225. fmt.Println(body)
  24226. if ioErr != nil {
  24227. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24229. return
  24230. }
  24231. var respJSON map[string]interface{}
  24232. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24233. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24235. return
  24236. }
  24237. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24238. userJSONBytes, _ := json.Marshal(respJSON)
  24239. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24240. utils.ErrorLog("解析失败:%v", err)
  24241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24242. return
  24243. }
  24244. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24245. var baseParams models.BaseParams
  24246. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  24247. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  24248. baseParams.SecretKey = miConfig.SecretKey
  24249. baseParams.OrgName = miConfig.OrgName
  24250. baseParams.FixmedinsCode = miConfig.Code
  24251. baseParams.EncKey = miConfig.EncKey
  24252. baseParams.AppSecret = miConfig.AppSecret
  24253. baseParams.SignKey = miConfig.SignKey
  24254. baseParams.AppID = miConfig.Code
  24255. baseParams.Doctor = role.UserName
  24256. baseParams.RequestUrl = miConfig.Url
  24257. if clr_type == "9903" {
  24258. clr_type = "9901"
  24259. }
  24260. businessParams := models.BusinessParams{
  24261. Insutype: insutype,
  24262. ClrType: clr_type,
  24263. SetlOptins: "360302",
  24264. StmtBegndate: start_time,
  24265. StmtEnddate: end_time,
  24266. MedfeeSumamt: 0,
  24267. FundPaySumamt: 0,
  24268. AcctPay: 0,
  24269. FixmedinsSetlCnt: fixmedins_setl_cnt,
  24270. }
  24271. result, requestLog := service.Jxyb3201(businessParams.FixmedinsSetlCnt, businessParams.StmtBegndate, businessParams.StmtEnddate, businessParams.ClrType, businessParams.Insutype, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.RequestUrl, miConfig.AccessKey, miConfig.SecretKey, fmt.Sprintf("%.2f", medfee_sumamt), fmt.Sprintf("%.2f", fund_pay_sumamt), fmt.Sprintf("%.2f", acct_pay))
  24272. fmt.Println(requestLog)
  24273. fmt.Println(result)
  24274. var dat map[string]interface{}
  24275. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24276. fmt.Println(dat)
  24277. } else {
  24278. fmt.Println(err)
  24279. }
  24280. userJSONBytes, _ := json.Marshal(dat)
  24281. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24282. utils.ErrorLog("解析失败:%v", err)
  24283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24284. return
  24285. }
  24286. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24287. var api string
  24288. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  24289. "&clr_type=" + clr_type +
  24290. "&setl_optins=" + clr_org +
  24291. "&stmt_begndate=" + start_time +
  24292. "&stm_enddate=" + end_time +
  24293. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24294. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24295. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24296. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  24297. "&fixmedins_code=" + miConfig.Code +
  24298. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24299. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24300. "&secret_key=" + miConfig.SecretKey +
  24301. "&org_name=" + miConfig.OrgName +
  24302. "&doctor=" + user_name+"&url="+miConfig.Url
  24303. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24304. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24305. resp, requestErr := http.Get(api)
  24306. if requestErr != nil {
  24307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24308. return
  24309. }
  24310. body, ioErr := ioutil.ReadAll(resp.Body)
  24311. if ioErr != nil {
  24312. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24314. return
  24315. }
  24316. var respJSON map[string]interface{}
  24317. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24318. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24320. return
  24321. }
  24322. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24323. if status == "0"{
  24324. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24325. c.ServeSuccessJSON(map[string]interface{}{
  24326. "failed_code": -10,
  24327. "msg": err_msg,
  24328. })
  24329. return
  24330. }
  24331. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24332. userJSONBytes, _ := json.Marshal(respJSON)
  24333. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24334. utils.ErrorLog("解析失败:%v", err)
  24335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24336. return
  24337. }
  24338. } else {
  24339. if len(clr_type) == 0 {
  24340. clr_type = "11"
  24341. }
  24342. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  24343. "insutype=" + insutype +
  24344. "&clr_type=" + clr_type +
  24345. "&setl_optins=" + clr_org +
  24346. "&stmt_begndate=" + start_time +
  24347. "&stm_enddate=" + end_time +
  24348. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24349. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24350. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24351. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  24352. "&fixmedins_code=" + miConfig.Code +
  24353. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24354. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24355. "&secret_key=" + miConfig.SecretKey +
  24356. "&org_name=" + miConfig.OrgName +
  24357. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  24358. fmt.Println(api)
  24359. resp, requestErr := http.Get(api)
  24360. if requestErr != nil {
  24361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24362. return
  24363. }
  24364. body, ioErr := ioutil.ReadAll(resp.Body)
  24365. fmt.Println(body)
  24366. if ioErr != nil {
  24367. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24369. return
  24370. }
  24371. var respJSON map[string]interface{}
  24372. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24373. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24375. return
  24376. }
  24377. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24378. userJSONBytes, _ := json.Marshal(respJSON)
  24379. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24380. utils.ErrorLog("解析失败:%v", err)
  24381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24382. return
  24383. }
  24384. }
  24385. if res.Infcode == 0 {
  24386. if res.Output.Stmtinfo.StmtRslt == "0" {
  24387. micc := &models.MedicalInsuranceCostCompare{
  24388. StartTime: startime.Unix(),
  24389. EndTime: endtime.Unix(),
  24390. Insutype: insutype,
  24391. CheckType: 1,
  24392. Num: fixmedins_setl_cnt,
  24393. Mtime: time.Now().Unix(),
  24394. Status: 1,
  24395. UserOrgId: adminUser.CurrentOrgId,
  24396. CostTotal: medfee_sumamt,
  24397. FuncTotal: fund_pay_sumamt,
  24398. PsnPay: acct_pay,
  24399. Creator: admin_user_id,
  24400. Ctime: time.Now().Unix(),
  24401. ClrType: clr_type,
  24402. }
  24403. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  24404. if err == nil {
  24405. c.ServeSuccessJSON(map[string]interface{}{
  24406. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  24407. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  24408. })
  24409. } else {
  24410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24411. }
  24412. } else {
  24413. c.ServeSuccessJSON(map[string]interface{}{
  24414. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  24415. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  24416. })
  24417. }
  24418. } else {
  24419. c.ServeSuccessJSON(map[string]interface{}{
  24420. "failed_code": -10,
  24421. "msg": res.ErrMsg,
  24422. })
  24423. }
  24424. }
  24425. }
  24426. func (c *HisApiController) Check310() {
  24427. adminUser := c.GetAdminUserInfo()
  24428. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24429. var user_name string
  24430. user_name = "高慧裕"
  24431. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  24432. "insutype=" + "310" +
  24433. "&clr_type=" + "" +
  24434. "&setl_optins=" + "441202" +
  24435. "&stmt_begndate=" + "2022-03-01" +
  24436. "&stm_enddate=" + "2022-03-31" +
  24437. "&medfee_sumamt=" + "194930.12" +
  24438. "&fund_pay_sumamt=" + "188741.46" +
  24439. "&acct_pay=" + "0" +
  24440. "&fixmedins_setl_cnt=" + "452" +
  24441. "&fixmedins_code=" + miConfig.Code +
  24442. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24443. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24444. "&secret_key=" + miConfig.SecretKey +
  24445. "&org_name=" + miConfig.OrgName +
  24446. "&doctor=" + user_name
  24447. fmt.Println(api)
  24448. resp, requestErr := http.Get(api)
  24449. if requestErr != nil {
  24450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24451. return
  24452. }
  24453. body, ioErr := ioutil.ReadAll(resp.Body)
  24454. fmt.Println(body)
  24455. if ioErr != nil {
  24456. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24458. return
  24459. }
  24460. var respJSON map[string]interface{}
  24461. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24462. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24464. return
  24465. }
  24466. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24467. userJSONBytes, _ := json.Marshal(respJSON)
  24468. var res ResultEight
  24469. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24470. utils.ErrorLog("解析失败:%v", err)
  24471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24472. return
  24473. }
  24474. }
  24475. func (c *HisApiController) Check390() {
  24476. adminUser := c.GetAdminUserInfo()
  24477. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24478. var user_name string
  24479. user_name = "高慧裕"
  24480. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  24481. "insutype=" + "390" +
  24482. "&clr_type=" + "" +
  24483. "&setl_optins=" + "441202" +
  24484. "&stmt_begndate=" + "2022-03-01" +
  24485. "&stm_enddate=" + "2022-03-31" +
  24486. "&medfee_sumamt=" + "1068448.89" +
  24487. "&fund_pay_sumamt=" + "1014677.62" +
  24488. "&acct_pay=" + "0" +
  24489. "&fixmedins_setl_cnt=" + "1950" +
  24490. "&fixmedins_code=" + miConfig.Code +
  24491. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24492. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24493. "&secret_key=" + miConfig.SecretKey +
  24494. "&org_name=" + miConfig.OrgName +
  24495. "&doctor=" + user_name
  24496. fmt.Println(api)
  24497. resp, requestErr := http.Get(api)
  24498. if requestErr != nil {
  24499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24500. return
  24501. }
  24502. body, ioErr := ioutil.ReadAll(resp.Body)
  24503. fmt.Println(body)
  24504. if ioErr != nil {
  24505. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24507. return
  24508. }
  24509. var respJSON map[string]interface{}
  24510. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24511. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24513. return
  24514. }
  24515. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24516. userJSONBytes, _ := json.Marshal(respJSON)
  24517. var res ResultEight
  24518. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24519. utils.ErrorLog("解析失败:%v", err)
  24520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24521. return
  24522. }
  24523. }
  24524. // 对账明细
  24525. func (c *HisApiController) GetCheckDetailAccount() {
  24526. start_time := c.GetString("start_time")
  24527. end_time := c.GetString("end_time")
  24528. admin_user_id, _ := c.GetInt64("admin_user_id")
  24529. adminUser := c.GetAdminUserInfo()
  24530. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24531. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24532. timeLayout := "2006-01-02"
  24533. loc, _ := time.LoadLocation("Local")
  24534. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  24535. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  24536. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  24537. rand.Seed(time.Now().UnixNano())
  24538. num := rand.Intn(30000)
  24539. Mkdir(miConfig.OrgName)
  24540. file := strconv.FormatInt(int64(num), 10)
  24541. file_name := file + ".txt"
  24542. zip_name := file + ".zip"
  24543. zip_path := miConfig.OrgName + "/" + zip_name
  24544. file_path := miConfig.OrgName + "/" + file_name
  24545. decimal.DivisionPrecision = 2
  24546. var medfee_sumamt float64
  24547. var psn_cash_pay float64
  24548. var fund_pay_sumamt float64
  24549. fixmedins_setl_cnt := int64(len(orders))
  24550. for _, item := range orders {
  24551. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  24552. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  24553. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  24554. }
  24555. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  24556. defer f.Close()
  24557. if err != nil {
  24558. fmt.Println(err.Error())
  24559. } else {
  24560. for _, item := range orders {
  24561. var refd_setl_flag string
  24562. if item.OrderStatus == 2 {
  24563. refd_setl_flag = "0"
  24564. var str string
  24565. str = item.SetlId + " " +
  24566. item.MdtrtId + " " +
  24567. item.PsnNo + " " +
  24568. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  24569. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  24570. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  24571. _, err = f.Write([]byte(str))
  24572. }
  24573. if item.OrderStatus == 3 {
  24574. var str string
  24575. str = item.SetlId + " " +
  24576. item.MdtrtId + " " +
  24577. item.PsnNo + " " +
  24578. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  24579. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  24580. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  24581. _, err = f.Write([]byte(str))
  24582. var str2 string
  24583. str2 = item.SetlId + " " +
  24584. item.MdtrtId + " " +
  24585. item.PsnNo + " " +
  24586. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  24587. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  24588. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  24589. _, err = f.Write([]byte(str2))
  24590. }
  24591. }
  24592. }
  24593. Zip(file_path, zip_path)
  24594. fmt.Println(ReadFile(zip_path))
  24595. fmt.Println(string(ReadFile(zip_path)))
  24596. if config.IsOpen == 1 {
  24597. var user_name string
  24598. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24599. if role.ID == 0 {
  24600. user_name = "管理员"
  24601. } else {
  24602. user_name = role.UserName
  24603. }
  24604. baseParams := models.BaseParams{
  24605. SecretKey: miConfig.SecretKey,
  24606. FixmedinsCode: miConfig.Code,
  24607. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  24608. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  24609. OrgName: miConfig.OrgName,
  24610. Doctor: user_name,
  24611. }
  24612. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  24613. var dat map[string]interface{}
  24614. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24615. fmt.Println(dat)
  24616. } else {
  24617. fmt.Println(err)
  24618. }
  24619. userJSONBytes, _ := json.Marshal(dat)
  24620. var res ResultNine
  24621. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24622. utils.ErrorLog("解析失败:%v", err)
  24623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24624. return
  24625. }
  24626. if res.Infcode == 0 {
  24627. fileNo := res.Output.FileQuryNo
  24628. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  24629. "file_qury_no=" + fileNo +
  24630. "&setl_optins=" + "定点医保中心" +
  24631. "&stmt_begndate=" + start_time +
  24632. "&stm_enddate=" + end_time +
  24633. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24634. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24635. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  24636. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  24637. "&fixmedins_code=" + miConfig.Code +
  24638. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24639. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24640. "&secret_key=" + miConfig.SecretKey +
  24641. "&org_name=" + miConfig.OrgName +
  24642. "&doctor=" + user_name
  24643. resp, requestErr := http.Get(api)
  24644. if requestErr != nil {
  24645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24646. return
  24647. }
  24648. body, ioErr := ioutil.ReadAll(resp.Body)
  24649. if ioErr != nil {
  24650. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24652. return
  24653. }
  24654. var respJSON map[string]interface{}
  24655. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24658. return
  24659. }
  24660. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24661. userJSONBytes, _ := json.Marshal(respJSON)
  24662. var res ResultTen
  24663. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24664. utils.ErrorLog("解析失败:%v", err)
  24665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24666. return
  24667. }
  24668. if res.Infcode == 0 {
  24669. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  24670. micc := &models.MedicalInsuranceCostCompare{
  24671. StartTime: startime.Unix(),
  24672. EndTime: endtime.Unix(),
  24673. Insutype: "0",
  24674. CheckType: 2,
  24675. Num: fixmedins_setl_cnt,
  24676. Mtime: time.Now().Unix(),
  24677. Status: 1,
  24678. UserOrgId: adminUser.CurrentOrgId,
  24679. CostTotal: medfee_sumamt,
  24680. FuncTotal: fund_pay_sumamt,
  24681. PsnPay: psn_cash_pay,
  24682. Creator: admin_user_id,
  24683. Ctime: time.Now().Unix(),
  24684. }
  24685. service.CreateMedicalInsuranceCostCompareRecord(micc)
  24686. c.ServeSuccessJSON(map[string]interface{}{
  24687. "msg": "明细对账成功",
  24688. })
  24689. }
  24690. } else {
  24691. }
  24692. }
  24693. }
  24694. type CustomOrderInfo struct {
  24695. Name string
  24696. Spec string
  24697. Unit string
  24698. Count float64
  24699. Price float64
  24700. Total float64
  24701. }
  24702. func (c *HisApiController) GetBatchSettleAccounts() {
  24703. admin_user_id, _ := c.GetInt64("admin_user_id")
  24704. order_ids := c.GetString("order_ids")
  24705. order_ids_arr := strings.Split(order_ids, ",")
  24706. data3 := []map[string]interface{}{}
  24707. for _, item := range order_ids_arr {
  24708. id, _ := strconv.ParseInt(item, 10, 64)
  24709. order_id := id
  24710. adminUser := c.GetAdminUserInfo()
  24711. order, _ := service.GetHisOrderByID(order_id)
  24712. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  24713. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  24714. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  24715. orderInfos = append(orderInfos, orderInfos_two...)
  24716. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  24717. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  24718. var diagnosis_ids []string
  24719. if his.ID > 0 {
  24720. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  24721. } else {
  24722. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  24723. }
  24724. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  24725. var dia_config []*models.HisXtDiagnoseConfig
  24726. var name string
  24727. for _, item := range diagnosis_ids {
  24728. id, _ := strconv.ParseInt(item, 10, 64)
  24729. diagnosisConfig, _ := service.FindDiagnoseById(id)
  24730. dia_config = append(dia_config, &diagnosisConfig)
  24731. if len(name) == 0 {
  24732. name = diagnosisConfig.ClassName
  24733. }
  24734. //} else {
  24735. // name = name + "," + diagnosisConfig.ClassName
  24736. //}
  24737. }
  24738. var bedCostTotal float64 = 0 //床位总费
  24739. var bedCostSelfTotal float64 = 0 //床位自费
  24740. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  24741. var bedSelfTotal float64 = 0 //床位部分项目自费
  24742. var bedInscpTotal float64 = 0 //床位部分项目自费
  24743. var operationCostTotal float64 = 0 //手术费
  24744. var operationCostSelfTotal float64 = 0 //手术费
  24745. var operationCostPartSelfTotal float64 = 0 //手术费
  24746. var operationSelfTotal float64 = 0 //床位部分项目自费
  24747. var operationInscpTotal float64 = 0 //床位部分项目自费
  24748. var otherCostTotal float64 = 0 //其他费用
  24749. var otherCostSelfTotal float64 = 0 //其他费用
  24750. var otherCostPartSelfTotal float64 = 0 //其他费用
  24751. var otherSelfTotal float64 = 0 //床位部分项目自费
  24752. var otherInscpTotal float64 = 0 //床位部分项目自费
  24753. var materialCostTotal float64 = 0 //材料费
  24754. var materialCostSelfTotal float64 = 0 //材料费
  24755. var materialCostPartSelfTotal float64 = 0 //材料费
  24756. var materialSelfTotal float64 = 0 //床位部分项目自费
  24757. var materialInscpTotal float64 = 0 //床位部分项目自费
  24758. var westernMedicineCostTotal float64 = 0 //西药费
  24759. var westernMedicineCostSelfTotal float64 = 0 //西药费
  24760. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  24761. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  24762. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  24763. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  24764. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  24765. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  24766. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  24767. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  24768. var checkCostTotal float64 = 0 //检查费
  24769. var checkCostSelfTotal float64 = 0 //检查费
  24770. var checkCostPartSelfTotal float64 = 0 //检查费
  24771. var checkSelfTotal float64 = 0 //床位部分项目自费
  24772. var checkInscpTotal float64 = 0 //床位部分项目自费
  24773. var laboratoryCostTotal float64 = 0 //化验费
  24774. var laboratoryCostSelfTotal float64 = 0 //化验费
  24775. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  24776. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  24777. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  24778. var treatCostTotal float64 = 0 //治疗费用
  24779. var treatCostSelfTotal float64 = 0 //治疗费用
  24780. var treatCostPartSelfTotal float64 = 0 //治疗费用
  24781. var treatSelfTotal float64 = 0 //床位部分项目自费
  24782. var treatInscpTotal float64 = 0 //床位部分项目自费
  24783. decimal.DivisionPrecision = 2
  24784. for _, item := range orderInfos {
  24785. if item.MedChrgitmType == "01" { //床位费
  24786. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  24787. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  24788. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  24789. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  24790. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  24791. }
  24792. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  24793. if item.MedChrgitmType == "03" { //检查费
  24794. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  24795. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  24796. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  24797. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  24798. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  24799. }
  24800. } else {
  24801. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  24802. fmt.Println("------------")
  24803. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  24804. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  24805. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  24806. }
  24807. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  24808. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  24809. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  24810. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  24811. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  24812. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  24813. }
  24814. }
  24815. if item.MedChrgitmType == "04" { //化验费
  24816. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  24817. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  24818. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  24819. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  24820. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  24821. }
  24822. if item.MedChrgitmType == "05" { //治疗费
  24823. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  24824. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  24825. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  24826. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  24827. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  24828. }
  24829. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  24830. fmt.Println("------------")
  24831. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  24832. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  24833. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  24834. }
  24835. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  24836. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  24837. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  24838. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  24839. }
  24840. //if item.MedChrgitmType == "06" { //手术费
  24841. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  24842. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  24843. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  24844. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  24845. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  24846. //
  24847. //}
  24848. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  24849. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  24850. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  24851. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  24852. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  24853. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  24854. }
  24855. if item.MedChrgitmType == "09" { //西药费
  24856. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  24857. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  24858. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  24859. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  24860. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  24861. }
  24862. if item.MedChrgitmType == "11" { //中成费
  24863. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  24864. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  24865. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  24866. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  24867. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  24868. }
  24869. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  24870. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  24871. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  24872. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  24873. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  24874. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  24875. }
  24876. }
  24877. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24878. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24879. var user_name string
  24880. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24881. if role.ID == 0 {
  24882. user_name = "管理员"
  24883. } else {
  24884. user_name = role.UserName
  24885. }
  24886. baseParams := models.BaseParams{
  24887. SecretKey: miConfig.SecretKey,
  24888. FixmedinsCode: miConfig.Code,
  24889. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  24890. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  24891. OrgName: miConfig.OrgName,
  24892. Doctor: user_name,
  24893. RequestUrl: miConfig.Url,
  24894. AccessKey: miConfig.AccessKey,
  24895. }
  24896. businessParams := models.BusinessParams{
  24897. PsnNo: order.PsnNo,
  24898. MdtrtId: order.MdtrtId,
  24899. SetlId: order.SetlId,
  24900. }
  24901. var res ResultEleven
  24902. var resEleven10265 ResultEleven10265
  24903. if config.IsOpen == 1 {
  24904. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  24905. result := service.Gdyb5203(baseParams, businessParams)
  24906. service.Gdyb5204(baseParams, businessParams)
  24907. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  24908. var dat map[string]interface{}
  24909. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24910. fmt.Println(dat)
  24911. } else {
  24912. fmt.Println(err)
  24913. }
  24914. userJSONBytes, _ := json.Marshal(dat)
  24915. if miConfig.Code == "H15049901371" {
  24916. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  24917. utils.ErrorLog("解析失败:%v", err)
  24918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24919. return
  24920. }
  24921. res.InfRefmsgid = resEleven10265.InfRefmsgid
  24922. res.Output = resEleven10265.Output
  24923. res.ErrMsg = resEleven10265.ErrMsg
  24924. res.Cainfo = resEleven10265.Cainfo
  24925. res.WarnMsg = resEleven10265.WarnMsg
  24926. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  24927. res.Infcode = infocode
  24928. } else {
  24929. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24930. utils.ErrorLog("解析失败:%v", err)
  24931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24932. return
  24933. }
  24934. }
  24935. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24936. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  24937. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  24938. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  24939. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  24940. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24941. var doctor_name string
  24942. if roles.ID == 0 {
  24943. doctor_name = "管理员"
  24944. } else {
  24945. doctor_name = roles.UserName
  24946. }
  24947. yiliao_leibie := ""
  24948. switch order.MedType {
  24949. case "11":
  24950. yiliao_leibie = "普通门诊"
  24951. break
  24952. case "12":
  24953. yiliao_leibie = "门诊挂号"
  24954. break
  24955. case "13":
  24956. yiliao_leibie = "急诊"
  24957. break
  24958. case "14":
  24959. yiliao_leibie = "门诊特殊病"
  24960. break
  24961. case "15":
  24962. yiliao_leibie = "门诊统筹"
  24963. break
  24964. case "16":
  24965. yiliao_leibie = "门诊慢性病"
  24966. break
  24967. case "21":
  24968. yiliao_leibie = "普通住院"
  24969. break
  24970. }
  24971. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  24972. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  24973. if res.Infcode == 0 {
  24974. data2 := map[string]interface{}{
  24975. "diagnosis": name,
  24976. "order_infos": orderInfos,
  24977. "number": order.MdtrtId,
  24978. "date": order.SettleAccountsDate,
  24979. "charge_admin": charge_admin,
  24980. "printor_admin": printor_admin,
  24981. "info": res.Output.Setlinfo,
  24982. "order": order,
  24983. "bedCostTotal": bedCostTotal,
  24984. "bedCostSelfTotal": bedCostSelfTotal,
  24985. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  24986. "bedSelfTotal": bedSelfTotal,
  24987. "bedInscpTotal": bedInscpTotal,
  24988. "operationCostTotal": operationCostTotal,
  24989. "operationCostSelfTotal": operationCostSelfTotal,
  24990. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  24991. "operationSelfTotal": operationSelfTotal,
  24992. "operationInscpTotal": operationInscpTotal,
  24993. "otherCostTotal": otherCostTotal,
  24994. "otherCostSelfTotal": otherCostSelfTotal,
  24995. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  24996. "otherSelfTotal": otherSelfTotal,
  24997. "otherInscpTotal": otherInscpTotal,
  24998. "materialCostTotal": materialCostTotal,
  24999. "materialCostSelfTotal": materialCostSelfTotal,
  25000. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  25001. "materialSelfTotal": materialSelfTotal,
  25002. "materialInscpTotal": materialInscpTotal,
  25003. "westernMedicineCostTotal": westernMedicineCostTotal,
  25004. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  25005. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  25006. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  25007. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  25008. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  25009. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  25010. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  25011. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  25012. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  25013. "checkCostTotal": checkCostTotal,
  25014. "checkCostSelfTotal": checkCostSelfTotal,
  25015. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  25016. "checkSelfTotal": checkSelfTotal,
  25017. "checkInscpTotal": checkInscpTotal,
  25018. "laboratoryCostTotal": laboratoryCostTotal,
  25019. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  25020. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  25021. "laboratorySelfTotal": laboratorySelfTotal,
  25022. "laboratoryInscpTotal": laboratoryInscpTotal,
  25023. "treatCostTotal": treatCostTotal,
  25024. "treatCostSelfTotal": treatCostSelfTotal,
  25025. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  25026. "treatSelfTotal": treatSelfTotal,
  25027. "treatInscpTotal": treatInscpTotal,
  25028. "doctor_info": doctor_info,
  25029. "doctor_code": adminRole_two.DoctorCode,
  25030. "doctor_name": doctor_name,
  25031. "health_card_no": order.PsnNo,
  25032. "department": departments.Name,
  25033. "yiliao_leibie": yiliao_leibie,
  25034. "after_money": order.AccountPrice,
  25035. "patient": patient,
  25036. "org_name": miConfig.OrgName,
  25037. "org_code": miConfig.Code,
  25038. "order_number": order.Number,
  25039. "his_hospital": his_hospital,
  25040. "his": his,
  25041. "dia_config": dia_config,
  25042. "psn_cash_pay": order.PsnCashPay,
  25043. //"check_order_info": cus_slice,
  25044. }
  25045. data3 = append(data3, data2)
  25046. }
  25047. }
  25048. }
  25049. c.ServeSuccessJSON(map[string]interface{}{
  25050. "infos": data3,
  25051. })
  25052. }
  25053. func (c *HisApiController) GetSettleAccounts() {
  25054. //id, _ := c.GetInt64("id")
  25055. //record_time := c.GetString("record_time")
  25056. order_id, _ := c.GetInt64("order_id")
  25057. admin_user_id, _ := c.GetInt64("admin_user_id")
  25058. //timeLayout := "2006-01-02"
  25059. //loc, _ := time.LoadLocation("Local")
  25060. //
  25061. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  25062. //if err != nil {
  25063. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25064. // return
  25065. //}Hbyb5203
  25066. //recordDateTime := theTime.Unix()
  25067. adminUser := c.GetAdminUserInfo()
  25068. order, _ := service.GetHisOrderByID(order_id)
  25069. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  25070. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  25071. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  25072. orderInfos = append(orderInfos, orderInfos_two...)
  25073. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  25074. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  25075. var diagnosis_ids []string
  25076. if his.ID > 0 {
  25077. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  25078. } else {
  25079. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  25080. }
  25081. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  25082. var dia_config []*models.HisXtDiagnoseConfig
  25083. var name string
  25084. for _, item := range diagnosis_ids {
  25085. id, _ := strconv.ParseInt(item, 10, 64)
  25086. diagnosisConfig, _ := service.FindDiagnoseById(id)
  25087. dia_config = append(dia_config, &diagnosisConfig)
  25088. if len(name) == 0 {
  25089. name = diagnosisConfig.ClassName
  25090. } else {
  25091. name = name + "," + diagnosisConfig.ClassName
  25092. }
  25093. }
  25094. if patient.UserOrgId == 10215 {
  25095. name = "慢性肾功能不全(血透治疗)"
  25096. }
  25097. var bedCostTotal float64 = 0 //床位总费
  25098. var bedCostSelfTotal float64 = 0 //床位自费
  25099. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  25100. var bedSelfTotal float64 = 0 //床位部分项目自费
  25101. var bedInscpTotal float64 = 0 //床位部分项目自费
  25102. var operationCostTotal float64 = 0 //手术费
  25103. var operationCostSelfTotal float64 = 0 //手术费
  25104. var operationCostPartSelfTotal float64 = 0 //手术费
  25105. var operationSelfTotal float64 = 0 //床位部分项目自费
  25106. var operationInscpTotal float64 = 0 //床位部分项目自费
  25107. var otherCostTotal float64 = 0 //其他费用
  25108. var otherCostSelfTotal float64 = 0 //其他费用
  25109. var otherCostPartSelfTotal float64 = 0 //其他费用
  25110. var otherSelfTotal float64 = 0 //床位部分项目自费
  25111. var otherInscpTotal float64 = 0 //床位部分项目自费
  25112. var materialCostTotal float64 = 0 //材料费
  25113. var materialCostSelfTotal float64 = 0 //材料费
  25114. var materialCostPartSelfTotal float64 = 0 //材料费
  25115. var materialSelfTotal float64 = 0 //床位部分项目自费
  25116. var materialInscpTotal float64 = 0 //床位部分项目自费
  25117. var westernMedicineCostTotal float64 = 0 //西药费
  25118. var westernMedicineCostSelfTotal float64 = 0 //西药费
  25119. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  25120. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  25121. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  25122. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  25123. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  25124. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  25125. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  25126. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  25127. var checkCostTotal float64 = 0 //检查费
  25128. var checkCostSelfTotal float64 = 0 //检查费
  25129. var checkCostPartSelfTotal float64 = 0 //检查费
  25130. var checkSelfTotal float64 = 0 //床位部分项目自费
  25131. var checkInscpTotal float64 = 0 //床位部分项目自费
  25132. var laboratoryCostTotal float64 = 0 //化验费
  25133. var laboratoryCostSelfTotal float64 = 0 //化验费
  25134. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  25135. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  25136. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  25137. var treatCostTotal float64 = 0 //治疗费用
  25138. var treatCostSelfTotal float64 = 0 //治疗费用
  25139. var treatCostPartSelfTotal float64 = 0 //治疗费用
  25140. var treatSelfTotal float64 = 0 //床位部分项目自费
  25141. var treatInscpTotal float64 = 0 //床位部分项目自费
  25142. decimal.DivisionPrecision = 2
  25143. for _, item := range orderInfos {
  25144. if item.MedChrgitmType == "01" { //床位费
  25145. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25146. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25147. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25148. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25149. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25150. }
  25151. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  25152. if item.MedChrgitmType == "03" { //检查费
  25153. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25154. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25155. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25156. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25157. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25158. }
  25159. } else {
  25160. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  25161. fmt.Println("------------")
  25162. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25163. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25164. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25165. }
  25166. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  25167. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25168. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25169. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25170. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25171. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25172. }
  25173. }
  25174. if item.MedChrgitmType == "04" { //化验费
  25175. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25176. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25177. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25178. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25179. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25180. }
  25181. if item.MedChrgitmType == "05" { //治疗费
  25182. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25183. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25184. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25185. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25186. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25187. }
  25188. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  25189. fmt.Println("------------")
  25190. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25191. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25192. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25193. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25194. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25195. }
  25196. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  25197. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25198. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25199. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25200. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25201. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25202. }
  25203. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  25204. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25205. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25206. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25207. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25208. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25209. }
  25210. if item.MedChrgitmType == "09" { //西药费
  25211. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25212. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25213. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25214. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25215. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25216. }
  25217. if item.MedChrgitmType == "11" { //中成费
  25218. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25219. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25220. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25221. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25222. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25223. }
  25224. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  25225. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25226. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25227. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25228. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25229. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25230. }
  25231. }
  25232. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25233. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25234. var user_name string
  25235. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25236. if role.ID == 0 {
  25237. user_name = "管理员"
  25238. } else {
  25239. user_name = role.UserName
  25240. }
  25241. baseParams := models.BaseParams{
  25242. SecretKey: miConfig.SecretKey,
  25243. FixmedinsCode: miConfig.Code,
  25244. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  25245. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  25246. OrgName: miConfig.OrgName,
  25247. Doctor: user_name,
  25248. RequestUrl: miConfig.Url,
  25249. AccessKey: miConfig.AccessKey,
  25250. }
  25251. businessParams := models.BusinessParams{
  25252. PsnNo: order.PsnNo,
  25253. MdtrtId: order.MdtrtId,
  25254. SetlId: order.SetlId,
  25255. }
  25256. var res ResultEleven
  25257. var resah ResultElevenah
  25258. var resEleven10265 ResultEleven10265
  25259. if config.IsOpen == 1 {
  25260. if miConfig.MdtrtareaAdmvs == "421300" {
  25261. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25262. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25263. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25264. resp, requestErr := http.Get(api)
  25265. if requestErr != nil {
  25266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25267. return
  25268. }
  25269. body, ioErr := ioutil.ReadAll(resp.Body)
  25270. if ioErr != nil {
  25271. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25273. return
  25274. }
  25275. var respJSON map[string]interface{}
  25276. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25277. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25279. return
  25280. }
  25281. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25282. result, _ := json.Marshal(respJSON)
  25283. fmt.Println("log")
  25284. fmt.Println(string(result))
  25285. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25286. utils.ErrorLog("解析失败:%v", err)
  25287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25288. return
  25289. }
  25290. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25291. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25292. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25293. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25294. resp, requestErr := http.Get(api)
  25295. if requestErr != nil {
  25296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25297. return
  25298. }
  25299. body, ioErr := ioutil.ReadAll(resp.Body)
  25300. if ioErr != nil {
  25301. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25303. return
  25304. }
  25305. var respJSON map[string]interface{}
  25306. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25307. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25309. return
  25310. }
  25311. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25312. result, _ := json.Marshal(respJSON)
  25313. fmt.Println("log")
  25314. fmt.Println(string(result))
  25315. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25316. utils.ErrorLog("解析失败:%v", err)
  25317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25318. return
  25319. }
  25320. }else if miConfig.MdtrtareaAdmvs == "421182" {
  25321. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25322. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25323. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey+"&med_type="+order.MedType
  25324. resp, requestErr := http.Get(api)
  25325. if requestErr != nil {
  25326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25327. return
  25328. }
  25329. body, ioErr := ioutil.ReadAll(resp.Body)
  25330. if ioErr != nil {
  25331. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25333. return
  25334. }
  25335. var respJSON map[string]interface{}
  25336. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25337. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25339. return
  25340. }
  25341. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25342. result, _ := json.Marshal(respJSON)
  25343. fmt.Println("log")
  25344. fmt.Println(string(result))
  25345. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25346. utils.ErrorLog("解析失败:%v", err)
  25347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25348. return
  25349. }
  25350. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25351. var api string
  25352. if miConfig.MdtrtareaAdmvs == "320921" {
  25353. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25354. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25355. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25356. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25357. } else {
  25358. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25359. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25360. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25361. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25362. }
  25363. resp, requestErr := http.Get(api)
  25364. if requestErr != nil {
  25365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25366. return
  25367. }
  25368. body, ioErr := ioutil.ReadAll(resp.Body)
  25369. if ioErr != nil {
  25370. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25372. return
  25373. }
  25374. var respJSON map[string]interface{}
  25375. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25376. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25378. return
  25379. }
  25380. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25381. result, _ := json.Marshal(respJSON)
  25382. fmt.Println("log")
  25383. fmt.Println(string(result))
  25384. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  25385. utils.ErrorLog("解析失败:%v", err)
  25386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25387. return
  25388. }
  25389. res.InfRefmsgid = resEleven10265.InfRefmsgid
  25390. res.Output = resEleven10265.Output
  25391. res.ErrMsg = resEleven10265.ErrMsg
  25392. res.Cainfo = resEleven10265.Cainfo
  25393. res.WarnMsg = resEleven10265.WarnMsg
  25394. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  25395. res.Infcode = infocode
  25396. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25397. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  25398. saveLog(result, requestLog, "5203", "结算单")
  25399. var dat map[string]interface{}
  25400. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25401. fmt.Println(dat)
  25402. } else {
  25403. fmt.Println(err)
  25404. }
  25405. userJSONBytes, _ := json.Marshal(dat)
  25406. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25407. utils.ErrorLog("解析失败:%v", err)
  25408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25409. return
  25410. }
  25411. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25412. baseParams.InsuplcAdmdvs = his_hospital.InsuplcAdmdvs
  25413. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  25414. fmt.Println(result3)
  25415. fmt.Println(requestLog3)
  25416. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  25417. fmt.Println(result2)
  25418. fmt.Println(requestLog2)
  25419. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  25420. saveLog(result, requestLog, "5203", "结算单")
  25421. var dat map[string]interface{}
  25422. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25423. fmt.Println(dat)
  25424. } else {
  25425. fmt.Println(err)
  25426. }
  25427. userJSONBytes, _ := json.Marshal(dat)
  25428. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25429. utils.ErrorLog("解析失败:%v", err)
  25430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25431. return
  25432. }
  25433. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25434. var api string
  25435. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25436. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25437. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25438. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25439. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25440. resp, requestErr := http.Get(api)
  25441. if requestErr != nil {
  25442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25443. return
  25444. }
  25445. body, ioErr := ioutil.ReadAll(resp.Body)
  25446. if ioErr != nil {
  25447. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25449. return
  25450. }
  25451. var respJSON map[string]interface{}
  25452. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25453. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25455. return
  25456. }
  25457. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25458. if status == "0"{
  25459. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25460. c.ServeSuccessJSON(map[string]interface{}{
  25461. "failed_code": -10,
  25462. "msg": err_msg,
  25463. })
  25464. return
  25465. }
  25466. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25467. result, _ := json.Marshal(respJSON)
  25468. fmt.Println("log")
  25469. fmt.Println(string(result))
  25470. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  25471. utils.ErrorLog("解析失败:%v", err)
  25472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25473. return
  25474. }
  25475. res.InfRefmsgid = resah.InfRefmsgid
  25476. timestamp := int64( resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  25477. // 创建对应的Time类型
  25478. t := time.UnixMilli(timestamp)
  25479. // 格式化成指定的日期字符串
  25480. str := t.Format("2006-01-02 15:04:05")
  25481. timestamp2 := int64( resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  25482. // 创建对应的Time类型
  25483. t3 := time.UnixMilli(timestamp2)
  25484. // 格式化成指定的日期字符串
  25485. str2 := t3.Format("2006-01-02 15:04:05")
  25486. timestamp3 := int64( resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  25487. // 创建对应的Time类型
  25488. t4 := time.UnixMilli(timestamp3)
  25489. // 格式化成指定的日期字符串
  25490. str3 := t4.Format("2006-01-02 15:04:05")
  25491. timestamp4 := int64( resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  25492. // 创建对应的Time类型
  25493. t5 := time.UnixMilli(timestamp4)
  25494. // 格式化成指定的日期字符串
  25495. str5 := t5.Format("2006-01-02 15:04:05")
  25496. res.Output.Setlinfo.Brdy = str2
  25497. res.Output.Setlinfo.SetlTime = str
  25498. res.Output.Setlinfo.Begndate = str3
  25499. res.Output.Setlinfo.Enddate = str5
  25500. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  25501. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  25502. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  25503. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  25504. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  25505. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  25506. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  25507. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  25508. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  25509. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  25510. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  25511. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  25512. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  25513. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  25514. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  25515. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  25516. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  25517. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  25518. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  25519. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  25520. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  25521. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  25522. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  25523. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  25524. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  25525. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  25526. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  25527. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  25528. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  25529. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  25530. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  25531. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  25532. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  25533. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  25534. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  25535. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  25536. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  25537. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  25538. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  25539. res.Output.Setlinfo.PoolPropSelfpay= resah.Output.Setlinfo.PoolPropSelfpay
  25540. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  25541. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  25542. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  25543. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  25544. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  25545. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  25546. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  25547. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  25548. //res.Output.Setldetail = resah.Output.Setldetail
  25549. res.ErrMsg = resah.ErrMsg
  25550. res.Cainfo = resah.Cainfo
  25551. res.WarnMsg = resah.WarnMsg
  25552. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25553. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  25554. saveLog(result, requestLog, "5203", "结算单")
  25555. var dat map[string]interface{}
  25556. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25557. fmt.Println(dat)
  25558. } else {
  25559. fmt.Println(err)
  25560. }
  25561. userJSONBytes, _ := json.Marshal(dat)
  25562. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25563. utils.ErrorLog("解析失败:%v", err)
  25564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25565. return
  25566. }
  25567. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25568. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25569. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25570. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25571. resp, requestErr := http.Get(api)
  25572. if requestErr != nil {
  25573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25574. return
  25575. }
  25576. body, ioErr := ioutil.ReadAll(resp.Body)
  25577. if ioErr != nil {
  25578. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25580. return
  25581. }
  25582. var respJSON map[string]interface{}
  25583. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25586. return
  25587. }
  25588. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25589. result, _ := json.Marshal(respJSON)
  25590. fmt.Println("log")
  25591. fmt.Println(string(result))
  25592. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  25593. utils.ErrorLog("解析失败:%v", err)
  25594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25595. return
  25596. }
  25597. res.InfRefmsgid = resEleven10265.InfRefmsgid
  25598. res.Output = resEleven10265.Output
  25599. res.ErrMsg = resEleven10265.ErrMsg
  25600. res.Cainfo = resEleven10265.Cainfo
  25601. res.WarnMsg = resEleven10265.WarnMsg
  25602. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  25603. res.Infcode = infocode
  25604. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25605. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25606. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25607. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25608. resp, requestErr := http.Get(api)
  25609. if requestErr != nil {
  25610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25611. return
  25612. }
  25613. body, ioErr := ioutil.ReadAll(resp.Body)
  25614. if ioErr != nil {
  25615. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25617. return
  25618. }
  25619. var respJSON map[string]interface{}
  25620. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25621. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25623. return
  25624. }
  25625. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25626. result, _ := json.Marshal(respJSON)
  25627. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25628. utils.ErrorLog("解析失败:%v", err)
  25629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25630. return
  25631. }
  25632. } else if miConfig.MdtrtareaAdmvs == "450721" {
  25633. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  25634. //return
  25635. } else {
  25636. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  25637. if len(his.InsuplcAdmdvs) == 0 {
  25638. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25639. } else {
  25640. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  25641. }
  25642. result := service.Gdyb5203(baseParams, businessParams)
  25643. //service.Gdyb5204(baseParams, businessParams)
  25644. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  25645. var dat map[string]interface{}
  25646. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25647. fmt.Println(dat)
  25648. } else {
  25649. fmt.Println(err)
  25650. }
  25651. userJSONBytes, _ := json.Marshal(dat)
  25652. if miConfig.Code == "H15049901371" {
  25653. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  25654. utils.ErrorLog("解析失败:%v", err)
  25655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25656. return
  25657. }
  25658. res.InfRefmsgid = resEleven10265.InfRefmsgid
  25659. res.Output = resEleven10265.Output
  25660. res.ErrMsg = resEleven10265.ErrMsg
  25661. res.Cainfo = resEleven10265.Cainfo
  25662. res.WarnMsg = resEleven10265.WarnMsg
  25663. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  25664. res.Infcode = infocode
  25665. } else {
  25666. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25667. utils.ErrorLog("解析失败:%v", err)
  25668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25669. return
  25670. }
  25671. }
  25672. }
  25673. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25674. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  25675. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  25676. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  25677. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  25678. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25679. var doctor_name string
  25680. if roles.ID == 0 {
  25681. doctor_name = "管理员"
  25682. } else {
  25683. doctor_name = roles.UserName
  25684. }
  25685. yiliao_leibie := ""
  25686. switch order.MedType {
  25687. case "11":
  25688. yiliao_leibie = "普通门诊"
  25689. break
  25690. case "12":
  25691. yiliao_leibie = "门诊挂号"
  25692. break
  25693. case "13":
  25694. yiliao_leibie = "急诊"
  25695. break
  25696. case "14":
  25697. yiliao_leibie = "门诊特殊病"
  25698. break
  25699. case "15":
  25700. yiliao_leibie = "门诊统筹"
  25701. break
  25702. case "16":
  25703. yiliao_leibie = "门诊慢性病"
  25704. break
  25705. case "21":
  25706. yiliao_leibie = "普通住院"
  25707. break
  25708. }
  25709. //var rf []CustomFundPay
  25710. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  25711. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  25712. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  25713. if res.Infcode == 0 {
  25714. if adminUser.CurrentOrgId == 10215 || adminUser.CurrentOrgId == 10387 || adminUser.CurrentOrgId == 9919 || adminUser.CurrentOrgId == 10088 || adminUser.CurrentOrgId == 10150 || adminUser.CurrentOrgId == 10510 {
  25715. c.ServeSuccessJSON(map[string]interface{}{
  25716. "diagnosis": name,
  25717. "order_infos": orderInfos,
  25718. "number": order.MdtrtId,
  25719. "date": order.SettleAccountsDate,
  25720. "charge_admin": charge_admin,
  25721. "printor_admin": printor_admin,
  25722. "info": res.Output.Setlinfo,
  25723. "order": order,
  25724. "bedCostTotal": bedCostTotal,
  25725. "bedCostSelfTotal": bedCostSelfTotal,
  25726. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  25727. "bedSelfTotal": bedSelfTotal,
  25728. "bedInscpTotal": bedInscpTotal,
  25729. "operationCostTotal": operationCostTotal,
  25730. "operationCostSelfTotal": operationCostSelfTotal,
  25731. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  25732. "operationSelfTotal": operationSelfTotal,
  25733. "operationInscpTotal": operationInscpTotal,
  25734. "otherCostTotal": otherCostTotal,
  25735. "otherCostSelfTotal": otherCostSelfTotal,
  25736. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  25737. "otherSelfTotal": otherSelfTotal,
  25738. "otherInscpTotal": otherInscpTotal,
  25739. "materialCostTotal": materialCostTotal,
  25740. "materialCostSelfTotal": materialCostSelfTotal,
  25741. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  25742. "materialSelfTotal": materialSelfTotal,
  25743. "materialInscpTotal": materialInscpTotal,
  25744. "westernMedicineCostTotal": westernMedicineCostTotal,
  25745. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  25746. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  25747. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  25748. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  25749. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  25750. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  25751. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  25752. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  25753. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  25754. "checkCostTotal": checkCostTotal,
  25755. "checkCostSelfTotal": checkCostSelfTotal,
  25756. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  25757. "checkSelfTotal": checkSelfTotal,
  25758. "checkInscpTotal": checkInscpTotal,
  25759. "laboratoryCostTotal": laboratoryCostTotal,
  25760. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  25761. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  25762. "laboratorySelfTotal": laboratorySelfTotal,
  25763. "laboratoryInscpTotal": laboratoryInscpTotal,
  25764. "treatCostTotal": treatCostTotal,
  25765. "treatCostSelfTotal": treatCostSelfTotal,
  25766. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  25767. "treatSelfTotal": treatSelfTotal,
  25768. "treatInscpTotal": treatInscpTotal,
  25769. "doctor_info": doctor_info,
  25770. "doctor_code": adminRole_two.DoctorCode,
  25771. "doctor_name": doctor_name,
  25772. "health_card_no": order.PsnNo,
  25773. "department": departments.Name,
  25774. "yiliao_leibie": yiliao_leibie,
  25775. "after_money": order.AccountPrice,
  25776. "patient": patient,
  25777. "org_name": miConfig.OrgName,
  25778. "org_code": miConfig.Code,
  25779. "order_number": order.Number,
  25780. "his_hospital": his_hospital,
  25781. "his": his,
  25782. "dia_config": dia_config,
  25783. "psn_cash_pay": order.PsnCashPay,
  25784. //"funds": rf,
  25785. //"check_order_info": cus_slice,
  25786. })
  25787. }else{
  25788. c.ServeSuccessJSON(map[string]interface{}{
  25789. "diagnosis": name,
  25790. "order_infos": orderInfos,
  25791. "number": order.MdtrtId,
  25792. "date": order.SettleAccountsDate,
  25793. "charge_admin": charge_admin,
  25794. "printor_admin": printor_admin,
  25795. "info": order,
  25796. "order": order,
  25797. "bedCostTotal": bedCostTotal,
  25798. "bedCostSelfTotal": bedCostSelfTotal,
  25799. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  25800. "bedSelfTotal": bedSelfTotal,
  25801. "bedInscpTotal": bedInscpTotal,
  25802. "operationCostTotal": operationCostTotal,
  25803. "operationCostSelfTotal": operationCostSelfTotal,
  25804. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  25805. "operationSelfTotal": operationSelfTotal,
  25806. "operationInscpTotal": operationInscpTotal,
  25807. "otherCostTotal": otherCostTotal,
  25808. "otherCostSelfTotal": otherCostSelfTotal,
  25809. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  25810. "otherSelfTotal": otherSelfTotal,
  25811. "otherInscpTotal": otherInscpTotal,
  25812. "materialCostTotal": materialCostTotal,
  25813. "materialCostSelfTotal": materialCostSelfTotal,
  25814. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  25815. "materialSelfTotal": materialSelfTotal,
  25816. "materialInscpTotal": materialInscpTotal,
  25817. "westernMedicineCostTotal": westernMedicineCostTotal,
  25818. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  25819. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  25820. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  25821. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  25822. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  25823. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  25824. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  25825. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  25826. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  25827. "checkCostTotal": checkCostTotal,
  25828. "checkCostSelfTotal": checkCostSelfTotal,
  25829. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  25830. "checkSelfTotal": checkSelfTotal,
  25831. "checkInscpTotal": checkInscpTotal,
  25832. "laboratoryCostTotal": laboratoryCostTotal,
  25833. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  25834. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  25835. "laboratorySelfTotal": laboratorySelfTotal,
  25836. "laboratoryInscpTotal": laboratoryInscpTotal,
  25837. "treatCostTotal": treatCostTotal,
  25838. "treatCostSelfTotal": treatCostSelfTotal,
  25839. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  25840. "treatSelfTotal": treatSelfTotal,
  25841. "treatInscpTotal": treatInscpTotal,
  25842. "doctor_info": doctor_info,
  25843. "doctor_code": adminRole_two.DoctorCode,
  25844. "doctor_name": doctor_name,
  25845. "health_card_no": order.PsnNo,
  25846. "department": departments.Name,
  25847. "yiliao_leibie": yiliao_leibie,
  25848. "after_money": order.AccountPrice,
  25849. "patient": patient,
  25850. "org_name": miConfig.OrgName,
  25851. "org_code": miConfig.Code,
  25852. "order_number": order.Number,
  25853. "his_hospital": his_hospital,
  25854. "his": his,
  25855. "dia_config": dia_config,
  25856. "psn_cash_pay": order.PsnCashPay,
  25857. //"funds": rf,
  25858. //"check_order_info": cus_slice,
  25859. })
  25860. }
  25861. }
  25862. }
  25863. }
  25864. //func (c *HisApiController) CheckTreatment() {
  25865. // patient_id, _ := c.GetInt64("patient_id")
  25866. // id_card_no := c.GetString("id_card_no")
  25867. // insutype := c.GetString("insutype")
  25868. // med_type := c.GetString("med_type")
  25869. // admin_user_id, _ := c.GetInt64("admin_user_id")
  25870. //
  25871. // adminUser := c.GetAdminUserInfo()
  25872. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  25873. //
  25874. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25875. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25876. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25877. //
  25878. // if miConfig.MdtrtareaAdmvs == "421300" {
  25879. // var res ResultTwo
  25880. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  25881. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25882. // "&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)
  25883. // resp, requestErr := http.Get(api)
  25884. // if requestErr != nil {
  25885. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25886. // return
  25887. // }
  25888. //
  25889. // body, ioErr := ioutil.ReadAll(resp.Body)
  25890. // if ioErr != nil {
  25891. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25892. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25893. // return
  25894. // }
  25895. // var respJSON map[string]interface{}
  25896. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25897. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25898. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25899. // return
  25900. // }
  25901. //
  25902. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25903. // result, _ := json.Marshal(respJSON)
  25904. //
  25905. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  25906. // utils.ErrorLog("解析失败:%v", err)
  25907. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25908. // return
  25909. // }
  25910. //
  25911. // if res.Infcode == 0 {
  25912. //
  25913. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  25914. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  25915. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  25916. // resp, requestErr := http.Get(api)
  25917. // if requestErr != nil {
  25918. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25919. // return
  25920. // }
  25921. //
  25922. // body, ioErr := ioutil.ReadAll(resp.Body)
  25923. // if ioErr != nil {
  25924. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25925. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25926. // return
  25927. // }
  25928. // var respJSON map[string]interface{}
  25929. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25930. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25931. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25932. // return
  25933. // }
  25934. // var res Result2001
  25935. //
  25936. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25937. // result2, _ := json.Marshal(respJSON)
  25938. //
  25939. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  25940. // utils.ErrorLog("解析失败:%v", err)
  25941. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25942. // return
  25943. // }
  25944. //
  25945. // if res.Infcode == 0 {
  25946. // c.ServeSuccessJSON(map[string]interface{}{
  25947. // "msg": res.Output.Trtinfo,
  25948. // })
  25949. // }
  25950. //
  25951. // } else {
  25952. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  25953. // return
  25954. // }
  25955. //
  25956. // } else {
  25957. //
  25958. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  25959. // var dat map[string]interface{}
  25960. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25961. // fmt.Println(dat)
  25962. // } else {
  25963. // fmt.Println(err)
  25964. // }
  25965. // userJSONBytes, _ := json.Marshal(dat)
  25966. // var res ResultTwo
  25967. // var res10265 ResultTwo10265
  25968. // if miConfig.Code == "H15049901371" {
  25969. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  25970. // utils.ErrorLog("解析失败:%v", err)
  25971. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25972. // return
  25973. // }
  25974. // res.ErrMsg = res10265.ErrMsg
  25975. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  25976. // res.Infcode = infocode
  25977. // res.Output = res10265.Output
  25978. // res.InfRefmsgid = res10265.InfRefmsgid
  25979. // } else {
  25980. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25981. // utils.ErrorLog("解析失败:%v", err)
  25982. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25983. // return
  25984. // }
  25985. // }
  25986. //
  25987. // var user_name string
  25988. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  25989. // if role.ID == 0 {
  25990. // user_name = "xxx"
  25991. // } else {
  25992. // user_name = role.UserName
  25993. // }
  25994. //
  25995. // baseParams := models.BaseParams{
  25996. // SecretKey: miConfig.SecretKey,
  25997. // FixmedinsCode: miConfig.Code,
  25998. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  25999. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26000. // OrgName: miConfig.OrgName,
  26001. // Doctor: user_name,
  26002. // }
  26003. //
  26004. // if config.IsOpen == 1 {
  26005. // if miConfig.Code == "H15049901371" {
  26006. // if med_type == "14" {
  26007. // if insutype == "390" {
  26008. // med_type = "9933"
  26009. // } else if insutype == "310" {
  26010. // med_type = "990502"
  26011. // }
  26012. // } else if med_type == "11" {
  26013. // med_type = "11"
  26014. // }
  26015. // }
  26016. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  26017. // var dat map[string]interface{}
  26018. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26019. // fmt.Println(dat)
  26020. // } else {
  26021. // fmt.Println(err)
  26022. // }
  26023. // var res Result2001
  26024. // var res10265 Result2001Org10265
  26025. // if miConfig.Code == "H15049901371" {
  26026. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  26027. // utils.ErrorLog("解析失败:%v", err)
  26028. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26029. // return
  26030. // }
  26031. // res.ErrMsg = res10265.ErrMsg
  26032. // res.Output = res10265.Output
  26033. // res.InfRefmsgid = res10265.InfRefmsgid
  26034. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  26035. // res.Infcode = infocode
  26036. // } else {
  26037. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  26038. // utils.ErrorLog("解析失败:%v", err)
  26039. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26040. // return
  26041. // }
  26042. // }
  26043. // if res.Infcode == 0 {
  26044. // c.ServeSuccessJSON(map[string]interface{}{
  26045. // "msg": res.Output.Trtinfo,
  26046. // })
  26047. // }
  26048. // }
  26049. // }
  26050. //}
  26051. //func (c *HisApiController) PutRecord() {
  26052. // id, _ := c.GetInt64("id")
  26053. // record_time := c.GetString("record_time")
  26054. // timeLayout := "2006-01-02"
  26055. // loc, _ := time.LoadLocation("Local")
  26056. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26057. // if err != nil {
  26058. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26059. // return
  26060. // }
  26061. // recordDateTime := theTime.Unix()
  26062. //
  26063. // adminInfo := c.GetAdminUserInfo()
  26064. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  26065. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  26066. //
  26067. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  26068. //
  26069. // fmt.Println(miConfig.SecretKey)
  26070. //
  26071. // if patient == nil {
  26072. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  26073. // return
  26074. // }
  26075. // if len(patient.IdCardNo) == 0 {
  26076. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  26077. // return
  26078. // }
  26079. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  26080. // if config.IsOpen == 1 {
  26081. // 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
  26082. // resp, requestErr := http.Get(api)
  26083. // if requestErr != nil {
  26084. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26085. // return
  26086. // }
  26087. // defer resp.Body.Close()
  26088. // body, ioErr := ioutil.ReadAll(resp.Body)
  26089. // if ioErr != nil {
  26090. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26091. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26092. // return
  26093. // }
  26094. // var respJSON map[string]interface{}
  26095. //
  26096. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26097. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26098. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26099. // return
  26100. // }
  26101. //
  26102. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26103. // userJSONBytes, _ := json.Marshal(userJSON)
  26104. // var res ResultTwo
  26105. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26106. // utils.ErrorLog("解析失败:%v", err)
  26107. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26108. // return
  26109. // }
  26110. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  26111. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  26112. // infoStr := string(Iinfos)
  26113. // idetinfoStr := string(Idetinfos)
  26114. //
  26115. // if res.Infcode == 0 {
  26116. // his := models.VMHisPatient{
  26117. // Status: 1,
  26118. // Ctime: time.Now().Unix(),
  26119. // Mtime: time.Now().Unix(),
  26120. // PsnNo: res.Output.Baseinfo.PsnNo,
  26121. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  26122. // Certno: res.Output.Baseinfo.Certno,
  26123. // PsnName: res.Output.Baseinfo.PsnName,
  26124. // Gend: res.Output.Baseinfo.Gend,
  26125. // Naty: res.Output.Baseinfo.Naty,
  26126. // Brdy: res.Output.Baseinfo.Brdy,
  26127. // Age: res.Output.Baseinfo.Age,
  26128. // Iinfo: infoStr,
  26129. // Idetinfo: idetinfoStr,
  26130. // PatientId: patient.ID,
  26131. // RecordDate: theTime.Unix(),
  26132. // UserOrgId: adminInfo.CurrentOrgId,
  26133. // AdminUserId: adminInfo.AdminUser.Id,
  26134. // IsReturn: 1,
  26135. // }
  26136. //
  26137. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  26138. // //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")
  26139. // //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")
  26140. //
  26141. // //var dat map[string]interface{}
  26142. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26143. // // fmt.Println(dat)
  26144. // //} else {
  26145. // // fmt.Println(err)
  26146. // //}
  26147. //
  26148. // var dat2 map[string]interface{}
  26149. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26150. // fmt.Println(dat2)
  26151. // } else {
  26152. // fmt.Println(err)
  26153. // }
  26154. //
  26155. // } else {
  26156. // adminUser := c.GetAdminUserInfo()
  26157. // errlog := &models.HisOrderError{
  26158. // UserOrgId: adminUser.CurrentOrgId,
  26159. // Ctime: time.Now().Unix(),
  26160. // Mtime: time.Now().Unix(),
  26161. // ErrMsg: res.ErrMsg,
  26162. // Status: 1,
  26163. // PatientId: id,
  26164. // RecordTime: recordDateTime,
  26165. // Stage: 1,
  26166. // }
  26167. // service.CreateErrMsgLog(errlog)
  26168. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  26169. // return
  26170. // }
  26171. // }
  26172. //
  26173. //}
  26174. //func (c *HisApiController) GetUploadDiag() {
  26175. // id, _ := c.GetInt64("id")
  26176. // record_time := c.GetString("record_time")
  26177. //
  26178. // diagnosis_id, _ := c.GetInt64("diagnosis")
  26179. // sick_type, _ := c.GetInt64("sick_type")
  26180. // reg_type, _ := c.GetInt64("reg_type")
  26181. //
  26182. // timeLayout := "2006-01-02"
  26183. // loc, _ := time.LoadLocation("Local")
  26184. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26185. // if err != nil {
  26186. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26187. // return
  26188. // }
  26189. //
  26190. // var patientPrescription models.HisPrescriptionInfo
  26191. // recordDateTime := theTime.Unix()
  26192. // adminInfo := c.GetAdminUserInfo()
  26193. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  26194. //
  26195. // if patientPrescription.ID == 0 {
  26196. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  26197. // }
  26198. //
  26199. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  26200. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  26201. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  26202. // sickConfig, _ := service.FindSickById(sick_type)
  26203. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26204. //
  26205. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  26206. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  26207. // "&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 +
  26208. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  26209. // resp2, requestErr2 := http.Get(api2)
  26210. // if requestErr2 != nil {
  26211. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26212. // return
  26213. // }
  26214. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  26215. // if ioErr2 != nil {
  26216. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  26217. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26218. // return
  26219. // }
  26220. // var respJSON2 map[string]interface{}
  26221. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  26222. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26223. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26224. // return
  26225. // }
  26226. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26227. // userJSONBytes2, _ := json.Marshal(respJSON2)
  26228. //
  26229. // var res2 ResultSix
  26230. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26231. // utils.ErrorLog("解析失败:%v", err)
  26232. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26233. // return
  26234. // }
  26235. // if res2.Infcode != 0 {
  26236. // adminUser := c.GetAdminUserInfo()
  26237. // errlog := &models.HisOrderError{
  26238. // UserOrgId: adminUser.CurrentOrgId,
  26239. // Ctime: time.Now().Unix(),
  26240. // Mtime: time.Now().Unix(),
  26241. // ErrMsg: res2.ErrMsg,
  26242. // Status: 1,
  26243. // PatientId: id,
  26244. // RecordTime: recordDateTime,
  26245. // Stage: 3,
  26246. // }
  26247. // service.CreateErrMsgLog(errlog)
  26248. //
  26249. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  26250. // return
  26251. // }
  26252. //
  26253. // c.ServeSuccessJSON(map[string]interface{}{
  26254. // "msg": "上传成功",
  26255. // })
  26256. //
  26257. //}
  26258. type QueryResult struct {
  26259. ID int64
  26260. Name string
  26261. Code string
  26262. List_type_code string
  26263. }
  26264. func (c *HisApiController) GetCheckCode() {
  26265. ids_str := c.GetString("ids")
  26266. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  26267. ids_arr := strings.Split(ids_str, ",")
  26268. var queryResult []QueryResult
  26269. ids := make([]int64, 0)
  26270. for _, item := range ids_arr {
  26271. id, _ := strconv.ParseInt(item, 10, 64)
  26272. ids = append(ids, id)
  26273. }
  26274. if record_type == 1 {
  26275. drugs, _ := service.GetBatchDrugList(ids)
  26276. for _, item := range drugs {
  26277. result := QueryResult{
  26278. ID: item.ID,
  26279. Name: item.DrugName,
  26280. Code: item.MedicalInsuranceNumber,
  26281. List_type_code: "101",
  26282. }
  26283. queryResult = append(queryResult, result)
  26284. }
  26285. } else if record_type == 2 {
  26286. goods, _ := service.GetBatchGoodInformationList(ids)
  26287. fmt.Println(goods)
  26288. for _, item := range goods {
  26289. result := QueryResult{
  26290. ID: item.ID,
  26291. Name: item.GoodName,
  26292. Code: item.SocialSecurityDirectoryCode,
  26293. List_type_code: "301",
  26294. }
  26295. queryResult = append(queryResult, result)
  26296. }
  26297. } else if record_type == 3 {
  26298. projects, _ := service.GetBathchMyPorjecgList(ids)
  26299. for _, item := range projects {
  26300. result := QueryResult{
  26301. ID: item.ID,
  26302. Name: item.ProjectName,
  26303. Code: item.MedicalCode,
  26304. List_type_code: "201",
  26305. }
  26306. queryResult = append(queryResult, result)
  26307. }
  26308. }
  26309. admin_user_id, _ := c.GetInt64("admin_user_id")
  26310. adminUser := c.GetAdminUserInfo()
  26311. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26312. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26313. var user_name string
  26314. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26315. if role.ID == 0 {
  26316. user_name = "管理员"
  26317. } else {
  26318. user_name = role.UserName
  26319. }
  26320. baseParams := models.BaseParams{
  26321. SecretKey: miConfig.SecretKey,
  26322. FixmedinsCode: miConfig.Code,
  26323. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26324. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26325. OrgName: miConfig.OrgName,
  26326. Doctor: user_name,
  26327. }
  26328. var result string
  26329. if miConfig.MdtrtareaAdmvs == "430800" {
  26330. for _, item := range queryResult {
  26331. if record_type == 1 {
  26332. result, _ = service.Hnyb3301(miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2021-01-26", "2099-12-31", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey)
  26333. } else if record_type == 2 {
  26334. fmt.Println(item.Code)
  26335. result, _ = service.Hnyb3301(miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2021-01-26", "2099-12-31", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey)
  26336. } else if record_type == 3 {
  26337. result, _ = service.Hnyb3301(miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2021-01-26", "2099-12-31", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey)
  26338. }
  26339. var dat map[string]interface{}
  26340. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26341. fmt.Println(dat)
  26342. } else {
  26343. fmt.Println(err)
  26344. }
  26345. userJSONBytes, _ := json.Marshal(dat)
  26346. var res ResultSix
  26347. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26348. utils.ErrorLog("解析失败:%v", err)
  26349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26350. return
  26351. }
  26352. if res.Infcode == 0 {
  26353. if record_type == 1 {
  26354. service.UpdateBaseDrugById(item.ID)
  26355. } else if record_type == 2 {
  26356. service.UpdateGoodInformaitonByDetail(item.ID)
  26357. } else if record_type == 3 {
  26358. service.UpdateProjectById(item.ID)
  26359. }
  26360. c.ServeSuccessJSON(map[string]interface{}{
  26361. "failed_code": 0,
  26362. "msg": "目录对照成功",
  26363. })
  26364. } else {
  26365. c.ServeSuccessJSON(map[string]interface{}{
  26366. "failed_code": -10,
  26367. "msg": res.ErrMsg,
  26368. })
  26369. }
  26370. }
  26371. } else {
  26372. for _, item := range queryResult {
  26373. var result string
  26374. if record_type == 1 {
  26375. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  26376. } else if record_type == 2 {
  26377. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  26378. } else if record_type == 3 {
  26379. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  26380. }
  26381. var dat map[string]interface{}
  26382. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26383. fmt.Println(dat)
  26384. } else {
  26385. fmt.Println(err)
  26386. }
  26387. userJSONBytes, _ := json.Marshal(dat)
  26388. var res ResultSix
  26389. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26390. utils.ErrorLog("解析失败:%v", err)
  26391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26392. return
  26393. }
  26394. if res.Infcode == 0 {
  26395. if record_type == 1 {
  26396. service.UpdateBaseDrugById(item.ID)
  26397. } else if record_type == 2 {
  26398. service.UpdateGoodInformaitonByDetail(item.ID)
  26399. } else if record_type == 3 {
  26400. service.UpdateProjectById(item.ID)
  26401. }
  26402. c.ServeSuccessJSON(map[string]interface{}{
  26403. "failed_code": 0,
  26404. "msg": "目录对照成功",
  26405. })
  26406. } else {
  26407. c.ServeSuccessJSON(map[string]interface{}{
  26408. "failed_code": -10,
  26409. "msg": res.ErrMsg,
  26410. })
  26411. }
  26412. }
  26413. }
  26414. }
  26415. func (c *HisApiController) UnCheckCode() {
  26416. ids_str := c.GetString("ids")
  26417. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  26418. admin_user_id, _ := c.GetInt64("admin_user_id")
  26419. ids_arr := strings.Split(ids_str, ",")
  26420. var queryResult []QueryResult
  26421. ids := make([]int64, 0)
  26422. for _, item := range ids_arr {
  26423. id, _ := strconv.ParseInt(item, 10, 64)
  26424. ids = append(ids, id)
  26425. }
  26426. if record_type == 1 {
  26427. drugs, _ := service.GetBatchDrugList(ids)
  26428. for _, item := range drugs {
  26429. result := QueryResult{
  26430. ID: item.ID,
  26431. Name: item.DrugName,
  26432. Code: item.MedicalInsuranceNumber,
  26433. List_type_code: "101",
  26434. }
  26435. queryResult = append(queryResult, result)
  26436. }
  26437. } else if record_type == 2 {
  26438. goods, _ := service.GetBatchGoodInformationList(ids)
  26439. for _, item := range goods {
  26440. result := QueryResult{
  26441. ID: item.ID,
  26442. Name: item.GoodName,
  26443. Code: item.SocialSecurityDirectoryCode,
  26444. List_type_code: "301",
  26445. }
  26446. queryResult = append(queryResult, result)
  26447. }
  26448. } else if record_type == 3 {
  26449. projects, _ := service.GetBathchMyPorjecgList(ids)
  26450. for _, item := range projects {
  26451. result := QueryResult{
  26452. ID: item.ID,
  26453. Name: item.ProjectName,
  26454. Code: item.MedicalCode,
  26455. List_type_code: "201",
  26456. }
  26457. queryResult = append(queryResult, result)
  26458. }
  26459. }
  26460. adminUser := c.GetAdminUserInfo()
  26461. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26462. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26463. var user_name string
  26464. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26465. if role.ID == 0 {
  26466. user_name = "xxx"
  26467. } else {
  26468. user_name = role.UserName
  26469. }
  26470. baseParams := &models.BaseParams{
  26471. SecretKey: miConfig.SecretKey,
  26472. FixmedinsCode: miConfig.Code,
  26473. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26474. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26475. OrgName: miConfig.OrgName,
  26476. Doctor: user_name,
  26477. }
  26478. if config.IsOpen == 1 {
  26479. if miConfig.MdtrtareaAdmvs == "430800" {
  26480. for _, item := range queryResult {
  26481. var result string
  26482. if record_type == 1 {
  26483. result, _ = service.Hnyb3302(miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2023-08-26", "2099-12-31", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey)
  26484. } else if record_type == 2 {
  26485. fmt.Println(item.Code)
  26486. result, _ = service.Hnyb3302(miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2023-08-26", "2099-12-31", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey)
  26487. } else if record_type == 3 {
  26488. result, _ = service.Hnyb3302(miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Cainfo, item.Name, item.Code, item.List_type_code, "2023-08-26", "2099-12-31", miConfig.Url, miConfig.AccessKey, miConfig.SecretKey)
  26489. }
  26490. var dat map[string]interface{}
  26491. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26492. fmt.Println(dat)
  26493. } else {
  26494. fmt.Println(err)
  26495. }
  26496. userJSONBytes, _ := json.Marshal(dat)
  26497. var res ResultSix
  26498. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26499. utils.ErrorLog("解析失败:%v", err)
  26500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26501. return
  26502. }
  26503. if res.Infcode == 0 {
  26504. if record_type == 1 {
  26505. service.UpdateBaseDrugById(item.ID)
  26506. } else if record_type == 2 {
  26507. service.UpdateGoodInformaitonByDetail(item.ID)
  26508. } else if record_type == 3 {
  26509. service.UpdateProjectById(item.ID)
  26510. }
  26511. c.ServeSuccessJSON(map[string]interface{}{
  26512. "failed_code": 0,
  26513. "msg": "目录对照成功",
  26514. })
  26515. } else {
  26516. c.ServeSuccessJSON(map[string]interface{}{
  26517. "failed_code": -10,
  26518. "msg": res.ErrMsg,
  26519. })
  26520. }
  26521. }
  26522. } else {
  26523. for _, item := range queryResult {
  26524. var result string
  26525. if record_type == 1 {
  26526. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  26527. } else if record_type == 2 {
  26528. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  26529. } else if record_type == 3 {
  26530. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  26531. }
  26532. var dat2 map[string]interface{}
  26533. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  26534. fmt.Println(dat2)
  26535. } else {
  26536. fmt.Println(err)
  26537. }
  26538. userJSONBytes, _ := json.Marshal(dat2)
  26539. var res ResultSix
  26540. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26541. utils.ErrorLog("解析失败:%v", err)
  26542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26543. return
  26544. }
  26545. if res.Infcode == 0 {
  26546. if record_type == 1 {
  26547. service.UpdateDrugByIdDetail(item.ID)
  26548. } else if record_type == 2 {
  26549. service.UpdateGoodInfoById(item.ID)
  26550. } else if record_type == 3 {
  26551. service.UpdateMyProjectById(item.ID)
  26552. }
  26553. c.ServeSuccessJSON(map[string]interface{}{
  26554. "failed_code": 0,
  26555. "msg": "撤销目录对照成功",
  26556. })
  26557. } else {
  26558. c.ServeSuccessJSON(map[string]interface{}{
  26559. "failed_code": -10,
  26560. "msg": res.ErrMsg,
  26561. })
  26562. }
  26563. }
  26564. }
  26565. }
  26566. }
  26567. func (c *HisApiController) GetPatientInfo() {
  26568. id_card_no := c.GetString("id_card_no")
  26569. admin_user_id, _ := c.GetInt64("admin_user_id")
  26570. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  26571. if patient.ID == 0 {
  26572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  26573. return
  26574. }
  26575. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  26576. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  26577. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  26578. var res ResultTwo
  26579. var res10265 ResultTwo10265
  26580. if config.IsOpen == 1 {
  26581. if miConfig.MdtrtareaAdmvs == "150499" {
  26582. //请求内网数据
  26583. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  26584. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  26585. "&insuplc_admdvs=" + "" + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(2, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(1, 10) + "&name=" + patient.Name
  26586. resp, requestErr := http.Get(api)
  26587. if requestErr != nil {
  26588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26589. return
  26590. }
  26591. body, ioErr := ioutil.ReadAll(resp.Body)
  26592. if ioErr != nil {
  26593. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26595. return
  26596. }
  26597. var respJSON map[string]interface{}
  26598. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26599. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26601. return
  26602. }
  26603. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26604. result_byte, _ := json.Marshal(respJSON)
  26605. result := string(result_byte)
  26606. var dat map[string]interface{}
  26607. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26608. fmt.Println(dat)
  26609. } else {
  26610. fmt.Println(err)
  26611. }
  26612. userJSONBytes, _ := json.Marshal(dat)
  26613. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  26614. utils.ErrorLog("解析失败:%v", err)
  26615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26616. return
  26617. }
  26618. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  26619. res.Infcode = Infcode
  26620. res.ErrMsg = res10265.ErrMsg
  26621. res.Output = res10265.Output
  26622. res.InfRefmsgid = res10265.InfRefmsgid
  26623. res.RespondTime = res10265.RespondTime
  26624. res.WarnInfo = res10265.WarnInfo
  26625. } else {
  26626. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  26627. var dat map[string]interface{}
  26628. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26629. fmt.Println(dat)
  26630. } else {
  26631. fmt.Println(err)
  26632. }
  26633. userJSONBytes, _ := json.Marshal(dat)
  26634. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26635. utils.ErrorLog("解析失败:%v", err)
  26636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26637. return
  26638. }
  26639. }
  26640. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26641. // utils.ErrorLog("解析失败:%v", err)
  26642. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26643. // return
  26644. //}
  26645. for index, item := range res.Output.Iinfo {
  26646. if item.PsnInsuStas == "2" {
  26647. fmt.Println("--------")
  26648. res.Output.Iinfo[index].Insutype = "300"
  26649. res.Output.Iinfo[index].PsnInsuStas = "1"
  26650. }
  26651. }
  26652. fmt.Println(res.Output.Iinfo)
  26653. if res.Infcode != 0 {
  26654. c.ServeSuccessJSON(map[string]interface{}{
  26655. "failed_code": -10,
  26656. "msg": res.ErrMsg,
  26657. })
  26658. } else {
  26659. c.ServeSuccessJSON(map[string]interface{}{
  26660. "failed_code": 0,
  26661. "info": res,
  26662. })
  26663. }
  26664. }
  26665. }
  26666. func (c *HisApiController) PsnPutOnRecord() {
  26667. record_type, _ := c.GetInt64("type")
  26668. patient_id, _ := c.GetInt64("patient_id")
  26669. admin_user_id, _ := c.GetInt64("admin_user_id")
  26670. start_time := c.GetString("start_time")
  26671. end_time := c.GetString("end_time")
  26672. adminUser := c.GetAdminUserInfo()
  26673. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26674. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26675. var patients []*models.Patients
  26676. if record_type == 1 { //全部备案
  26677. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  26678. patients = append(patients, patient...)
  26679. } else { //单个备案
  26680. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  26681. patients = append(patients, patient)
  26682. }
  26683. var user_name string
  26684. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26685. if role.ID == 0 {
  26686. user_name = "xxx"
  26687. } else {
  26688. user_name = role.UserName
  26689. }
  26690. if config.IsOpen == 1 {
  26691. for _, item := range patients {
  26692. 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
  26693. resp, requestErr := http.Get(api)
  26694. if requestErr != nil {
  26695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26696. return
  26697. }
  26698. defer resp.Body.Close()
  26699. body, ioErr := ioutil.ReadAll(resp.Body)
  26700. if ioErr != nil {
  26701. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26703. return
  26704. }
  26705. var respJSON map[string]interface{}
  26706. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26707. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26709. return
  26710. }
  26711. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26712. userJSONBytes, _ := json.Marshal(userJSON)
  26713. var res ResultTwo
  26714. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26715. utils.ErrorLog("解析失败:%v", err)
  26716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26717. return
  26718. }
  26719. if res.Infcode == 0 {
  26720. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time, admin_user_id)
  26721. var dat map[string]interface{}
  26722. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26723. fmt.Println(dat)
  26724. } else {
  26725. fmt.Println(err)
  26726. }
  26727. userJSONBytes, _ := json.Marshal(dat)
  26728. var res2 ResultThirteen
  26729. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26730. utils.ErrorLog("解析失败:%v", err)
  26731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26732. return
  26733. }
  26734. if res2.Infcode == 0 {
  26735. psnResult := &models.GdybPsnRecord{
  26736. UserOrgId: adminUser.CurrentOrgId,
  26737. PatientId: item.ID,
  26738. PsnNo: res.Output.Baseinfo.PsnNo,
  26739. Ctime: time.Now().Unix(),
  26740. Mtime: time.Now().Unix(),
  26741. Status: 1,
  26742. IsCancel: 1,
  26743. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  26744. }
  26745. service.CreatePsnRecord(psnResult)
  26746. } else {
  26747. c.ServeSuccessJSON(map[string]interface{}{
  26748. "failed_code": -10,
  26749. "msg": res2.ErrMsg,
  26750. })
  26751. return
  26752. }
  26753. }
  26754. }
  26755. }
  26756. }
  26757. func (c *HisApiController) PsnUnPutOnRecord() {
  26758. id, _ := c.GetInt64("id")
  26759. //record_type, _ := c.GetInt64("type")
  26760. admin_user_id, _ := c.GetInt64("admin_user_id")
  26761. adminUser := c.GetAdminUserInfo()
  26762. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26763. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26764. var user_name string
  26765. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26766. if role.ID == 0 {
  26767. user_name = "xxx"
  26768. } else {
  26769. user_name = role.UserName
  26770. }
  26771. psn_record, _ := service.GetPsnRecordById(id)
  26772. if psn_record.ID == 0 {
  26773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  26774. return
  26775. }
  26776. if config.IsOpen == 1 {
  26777. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  26778. var dat map[string]interface{}
  26779. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26780. fmt.Println(dat)
  26781. } else {
  26782. fmt.Println(err)
  26783. }
  26784. userJSONBytes, _ := json.Marshal(dat)
  26785. var res ResultFourteen
  26786. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26787. utils.ErrorLog("解析失败:%v", err)
  26788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26789. return
  26790. }
  26791. if res.Infcode == 0 {
  26792. psn_record.IsCancel = 2
  26793. service.CreatePsnRecord(&psn_record)
  26794. } else {
  26795. c.ServeSuccessJSON(map[string]interface{}{
  26796. "failed_code": -10,
  26797. "msg": res.ErrMsg,
  26798. })
  26799. return
  26800. }
  26801. }
  26802. }
  26803. func (c *HisApiController) PsnPutNCDSOnRecord() {
  26804. patient_id, _ := c.GetInt64("patient_id")
  26805. insutype_two := c.GetString("insutype")
  26806. psn_no := c.GetString("psn_no")
  26807. doctor_id, _ := c.GetInt64("doctor_id")
  26808. sick_id, _ := c.GetInt64("sick_id")
  26809. department_id, _ := c.GetInt64("department_id")
  26810. start_time := c.GetString("start_time")
  26811. end_time := c.GetString("end_time")
  26812. check_time := c.GetString("check_time")
  26813. hospital_code := c.GetString("hospital_code")
  26814. hospital_name := c.GetString("hospital_name")
  26815. adminUser := c.GetAdminUserInfo()
  26816. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  26817. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26818. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26819. sick, _ := service.FindSickById(sick_id)
  26820. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  26821. if len(hospital_code) == 0 {
  26822. hospital_code = miConfig.Code
  26823. }
  26824. if len(hospital_name) == 0 {
  26825. hospital_name = miConfig.OrgName
  26826. }
  26827. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  26828. var res ResultTwo
  26829. var res10265 ResultTwo10265
  26830. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26831. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  26832. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  26833. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  26834. "&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
  26835. resp, requestErr := http.Get(api)
  26836. if requestErr != nil {
  26837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26838. return
  26839. }
  26840. body, ioErr := ioutil.ReadAll(resp.Body)
  26841. if ioErr != nil {
  26842. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26844. return
  26845. }
  26846. var respJSON map[string]interface{}
  26847. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26848. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26850. return
  26851. }
  26852. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26853. result, _ := json.Marshal(respJSON)
  26854. fmt.Println("log")
  26855. fmt.Println(string(result))
  26856. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  26857. utils.ErrorLog("解析失败:%v", err)
  26858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26859. return
  26860. }
  26861. res.ErrMsg = res10265.ErrMsg
  26862. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  26863. res.Infcode = infocode
  26864. res.Output = res10265.Output
  26865. res.InfRefmsgid = res10265.InfRefmsgid
  26866. } else {
  26867. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  26868. if miConfig.Code == "H15049901371" {
  26869. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  26870. utils.ErrorLog("解析失败:%v", err)
  26871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26872. return
  26873. }
  26874. res.ErrMsg = res10265.ErrMsg
  26875. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  26876. res.Infcode = infocode
  26877. res.Output = res10265.Output
  26878. res.InfRefmsgid = res10265.InfRefmsgid
  26879. } else {
  26880. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26881. utils.ErrorLog("解析失败:%v", err)
  26882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26883. return
  26884. }
  26885. }
  26886. }
  26887. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  26888. infoStr := string(Iinfos)
  26889. var rf []*ResultFive
  26890. json.Unmarshal([]byte(infoStr), &rf)
  26891. var insuplc_admdvs string
  26892. var insutype string
  26893. var is390 int = 0
  26894. var is310 int = 0
  26895. var insutypes []*ResultFive
  26896. for _, item := range rf {
  26897. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  26898. insutypes = append(insutypes, item)
  26899. }
  26900. }
  26901. if len(insutypes) == 1 {
  26902. insutype = insutypes[0].Insutype
  26903. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  26904. } else {
  26905. for _, i := range insutypes {
  26906. if i.Insutype == "390" {
  26907. is390 = 1
  26908. }
  26909. if i.Insutype == "310" {
  26910. is310 = 1
  26911. }
  26912. }
  26913. }
  26914. if is390 == 1 {
  26915. insutype = "390"
  26916. }
  26917. if is310 == 1 {
  26918. insutype = "310"
  26919. }
  26920. if len(insutypes) == 2 {
  26921. insutype = insutype_two
  26922. }
  26923. if len(insutypes) == 0 {
  26924. insutype = "310"
  26925. }
  26926. insutype = insutype_two
  26927. fmt.Println(insutype)
  26928. for _, item := range rf {
  26929. fmt.Println(item.Insutype)
  26930. fmt.Println(insutype)
  26931. if item.Insutype == insutype {
  26932. fmt.Println(item.Insutype)
  26933. fmt.Println(insutype)
  26934. insuplc_admdvs = item.InsuplcAdmdvs
  26935. }
  26936. }
  26937. fmt.Println(insuplc_admdvs)
  26938. var res2 ResultThirteen
  26939. var res10265_2 ResultThirteen10265
  26940. if config.IsOpen == 1 {
  26941. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26942. } else {
  26943. if miConfig.MdtrtareaAdmvs == "150499" {
  26944. //
  26945. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  26946. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  26947. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + hb_doctor_info.DoctorNumber + "&doctor_name=" + hb_doctor_info.UserName + "&opter=" + roles.UserName
  26948. //resp, requestErr := http.Get(api)
  26949. //if requestErr != nil {
  26950. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26951. // return
  26952. //}
  26953. //
  26954. //body, ioErr := ioutil.ReadAll(resp.Body)
  26955. //if ioErr != nil {
  26956. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26957. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26958. // return
  26959. //}
  26960. //var respJSON map[string]interface{}
  26961. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26962. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26963. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26964. // return
  26965. //}
  26966. //
  26967. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26968. //result, _ := json.Marshal(respJSON)
  26969. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  26970. // utils.ErrorLog("解析失败:%v", err)
  26971. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26972. // return
  26973. //}
  26974. //infocode = resThree.Infcode
  26975. //result, _ := json.Marshal(respJSON)
  26976. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  26977. // utils.ErrorLog("解析失败:%v", err)
  26978. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26979. // return
  26980. //}
  26981. //
  26982. //resThree.ErrMsg = resThree10265.ErrMsg
  26983. //
  26984. //resThree.Output = resThree10265.Output
  26985. //
  26986. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  26987. //
  26988. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  26989. //
  26990. } else {
  26991. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time, hospital_code, hospital_name)
  26992. var dat map[string]interface{}
  26993. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26994. fmt.Println(dat)
  26995. } else {
  26996. fmt.Println(err)
  26997. }
  26998. userJSONBytes, _ := json.Marshal(dat)
  26999. if miConfig.Code == "H15049901371" {
  27000. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  27001. utils.ErrorLog("解析失败:%v", err)
  27002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27003. return
  27004. }
  27005. res2.ErrMsg = res10265_2.ErrMsg
  27006. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  27007. res2.Infcode = infocode
  27008. res2.Output = res10265_2.Output
  27009. res2.InfRefmsgid = res10265_2.InfRefmsgid
  27010. } else {
  27011. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27012. utils.ErrorLog("解析失败:%v", err)
  27013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27014. return
  27015. }
  27016. }
  27017. }
  27018. }
  27019. if res2.Infcode == 0 {
  27020. psnResult := &models.GdybPsnNcdsRecord{
  27021. UserOrgId: adminUser.CurrentOrgId,
  27022. PatientId: patient.ID,
  27023. PsnNo: psn_no,
  27024. DoctorId: doctor.AdminUserId,
  27025. DepartmentId: department_id,
  27026. SickType: sick_id,
  27027. Insutype: insutype,
  27028. Ctime: time.Now().Unix(),
  27029. Mtime: time.Now().Unix(),
  27030. Status: 1,
  27031. IsCancel: 1,
  27032. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  27033. }
  27034. service.CreatePsnNCDSRecord(psnResult)
  27035. c.ServeSuccessJSON(map[string]interface{}{
  27036. "failed_code": 0,
  27037. "msg": "备案成功",
  27038. "result": psnResult,
  27039. })
  27040. } else {
  27041. c.ServeSuccessJSON(map[string]interface{}{
  27042. "failed_code": -10,
  27043. "msg": res2.ErrMsg,
  27044. })
  27045. return
  27046. }
  27047. }
  27048. }
  27049. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  27050. id, _ := c.GetInt64("id")
  27051. admin_user_id, _ := c.GetInt64("admin_user_id")
  27052. adminUser := c.GetAdminUserInfo()
  27053. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27054. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27055. //config, _ := service.Ge(adminUser.CurrentOrgId)
  27056. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  27057. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27058. //var user_name string
  27059. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27060. //if role.ID == 0 {
  27061. // user_name = "xxx"
  27062. //} else {
  27063. // user_name = role.UserName
  27064. //}
  27065. psn_record, _ := service.GetPsnNCDSRecordById(id)
  27066. if psn_record.ID == 0 {
  27067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  27068. return
  27069. }
  27070. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  27071. var res ResultTwo
  27072. var res10265 ResultTwo10265
  27073. if miConfig.Code == "H15049901371" {
  27074. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27075. utils.ErrorLog("解析失败:%v", err)
  27076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27077. return
  27078. }
  27079. res.ErrMsg = res10265.ErrMsg
  27080. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27081. res.Infcode = infocode
  27082. res.Output = res10265.Output
  27083. res.InfRefmsgid = res10265.InfRefmsgid
  27084. } else {
  27085. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27086. utils.ErrorLog("解析失败:%v", err)
  27087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27088. return
  27089. }
  27090. }
  27091. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  27092. infoStr := string(Iinfos)
  27093. var rf []*ResultFive
  27094. json.Unmarshal([]byte(infoStr), &rf)
  27095. var insuplc_admdvs string
  27096. var insutype string
  27097. var is390 int = 0
  27098. var is310 int = 0
  27099. var insutypes []*ResultFive
  27100. for _, item := range rf {
  27101. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27102. insutypes = append(insutypes, item)
  27103. }
  27104. }
  27105. if len(insutypes) == 1 {
  27106. insutype = insutypes[0].Insutype
  27107. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  27108. } else {
  27109. for _, i := range insutypes {
  27110. if i.Insutype == "390" {
  27111. is390 = 1
  27112. }
  27113. if i.Insutype == "310" {
  27114. is310 = 1
  27115. }
  27116. }
  27117. }
  27118. if is390 == 1 {
  27119. insutype = "390"
  27120. }
  27121. if is310 == 1 {
  27122. insutype = "310"
  27123. }
  27124. if len(insutypes) == 0 {
  27125. insutype = "310"
  27126. }
  27127. insutype = psn_record.Insutype
  27128. for _, item := range rf {
  27129. if item.Insutype == insutype {
  27130. insuplc_admdvs = item.InsuplcAdmdvs
  27131. }
  27132. }
  27133. if config.IsOpen == 1 {
  27134. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  27135. var dat map[string]interface{}
  27136. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27137. fmt.Println(dat)
  27138. } else {
  27139. fmt.Println(err)
  27140. }
  27141. userJSONBytes, _ := json.Marshal(dat)
  27142. var res ResultFourteen
  27143. var res10265 ResultFourteen10265
  27144. if miConfig.Code == "H15049901371" {
  27145. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  27146. utils.ErrorLog("解析失败:%v", err)
  27147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27148. return
  27149. }
  27150. res.ErrMsg = res10265.ErrMsg
  27151. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27152. res.Infcode = infocode
  27153. res.Output = res10265.Output
  27154. res.InfRefmsgid = res10265.InfRefmsgid
  27155. } else {
  27156. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27157. utils.ErrorLog("解析失败:%v", err)
  27158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27159. return
  27160. }
  27161. }
  27162. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27163. // utils.ErrorLog("解析失败:%v", err)
  27164. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27165. // return
  27166. //}
  27167. if res.Infcode == 0 {
  27168. psn_record.IsCancel = 2
  27169. service.CreatePsnNCDSRecord(&psn_record)
  27170. c.ServeSuccessJSON(map[string]interface{}{
  27171. "failed_code": 0,
  27172. "msg": "撤销备案成功",
  27173. })
  27174. } else {
  27175. c.ServeSuccessJSON(map[string]interface{}{
  27176. "failed_code": -10,
  27177. "msg": res.ErrMsg,
  27178. })
  27179. return
  27180. }
  27181. }
  27182. }
  27183. func (c *HisApiController) TestTest() {
  27184. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  27185. fmt.Println(patient.Iinfo)
  27186. }
  27187. type CustomData struct {
  27188. MsgId string
  27189. PsnNo string
  27190. Info string
  27191. }
  27192. func (c *HisApiController) ReversalData() {
  27193. var customData []*CustomData
  27194. custom := &CustomData{
  27195. MsgId: "H44022900158202103301714472004",
  27196. PsnNo: "44020000001101329945",
  27197. Info: "2207",
  27198. }
  27199. customData = append(customData, custom)
  27200. custom1 := &CustomData{
  27201. MsgId: "H4402290015820210330172057803",
  27202. PsnNo: "44020000001101161813",
  27203. Info: "2207",
  27204. }
  27205. customData = append(customData, custom1)
  27206. custom2 := &CustomData{
  27207. MsgId: "H44022900158202103301705198813",
  27208. PsnNo: "44190000133097375417",
  27209. Info: "2207",
  27210. }
  27211. customData = append(customData, custom2)
  27212. custom3 := &CustomData{
  27213. MsgId: "H44022900158202103301715524756",
  27214. PsnNo: "44020000001100187221",
  27215. Info: "2207",
  27216. }
  27217. customData = append(customData, custom3)
  27218. custom4 := &CustomData{
  27219. MsgId: "H44022900158202103301730376224",
  27220. PsnNo: "44020000001101959155",
  27221. Info: "2207",
  27222. }
  27223. customData = append(customData, custom4)
  27224. custom5 := &CustomData{
  27225. MsgId: "H44022900158202103301748008725",
  27226. PsnNo: "44020000001104246641",
  27227. Info: "2207",
  27228. }
  27229. customData = append(customData, custom5)
  27230. custom6 := &CustomData{
  27231. MsgId: "H44022900158202103301718096755",
  27232. PsnNo: "44020000001102211860",
  27233. Info: "2207",
  27234. }
  27235. customData = append(customData, custom6)
  27236. custom7 := &CustomData{
  27237. MsgId: "H44022900158202103301736551640",
  27238. PsnNo: "44020000001102687718",
  27239. Info: "2207",
  27240. }
  27241. customData = append(customData, custom7)
  27242. custom8 := &CustomData{
  27243. MsgId: "H44022900158202103301743097676",
  27244. PsnNo: "44020000001102127785",
  27245. Info: "2207",
  27246. }
  27247. customData = append(customData, custom8)
  27248. custom9 := &CustomData{
  27249. MsgId: "H44022900158202103301712304203",
  27250. PsnNo: "44020000001101518097",
  27251. Info: "2207",
  27252. }
  27253. customData = append(customData, custom9)
  27254. custom10 := &CustomData{
  27255. MsgId: "H44022900158202103301738448785",
  27256. PsnNo: "44020000001100500813",
  27257. Info: "2207",
  27258. }
  27259. customData = append(customData, custom10)
  27260. custom11 := &CustomData{
  27261. MsgId: "H44022900158202103301732455843",
  27262. PsnNo: "44020000001102690557",
  27263. Info: "2207",
  27264. }
  27265. customData = append(customData, custom11)
  27266. custom12 := &CustomData{
  27267. MsgId: "H44022900158202103301745421708",
  27268. PsnNo: "44020000001102211928",
  27269. Info: "2207",
  27270. }
  27271. customData = append(customData, custom12)
  27272. custom1212 := &CustomData{
  27273. MsgId: "H440229001582021033017351627",
  27274. PsnNo: "44020000001102481733",
  27275. Info: "2207",
  27276. }
  27277. customData = append(customData, custom1212)
  27278. custom13 := &CustomData{
  27279. MsgId: "H44022900158202103301740327951",
  27280. PsnNo: "44020000001103174866",
  27281. Info: "2207",
  27282. }
  27283. customData = append(customData, custom13)
  27284. custom14 := &CustomData{
  27285. MsgId: "H4402290015820210330174922668",
  27286. PsnNo: "44020000001102927272",
  27287. Info: "2207",
  27288. }
  27289. customData = append(customData, custom14)
  27290. custom15 := &CustomData{
  27291. MsgId: "H44022900158202103301752362273",
  27292. PsnNo: "44020000001102942890",
  27293. Info: "2207",
  27294. }
  27295. customData = append(customData, custom15)
  27296. custom16 := &CustomData{
  27297. MsgId: "H44022900158202103301751082917",
  27298. PsnNo: "44020000001101662162",
  27299. Info: "2207",
  27300. }
  27301. customData = append(customData, custom16)
  27302. custom17 := &CustomData{
  27303. MsgId: "H44022900158202103301754147728",
  27304. PsnNo: "44020000000229014511",
  27305. Info: "2207",
  27306. }
  27307. customData = append(customData, custom17)
  27308. adminUser := c.GetAdminUserInfo()
  27309. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27310. for _, item := range customData {
  27311. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  27312. fmt.Println(result)
  27313. }
  27314. }
  27315. func (c *HisApiController) GetAllopatry() {
  27316. year := c.GetString("year")
  27317. month := c.GetString("month")
  27318. admin_user_id, _ := c.GetInt64("admin_user_id")
  27319. adminUser := c.GetAdminUserInfo()
  27320. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27321. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27322. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  27323. var dat map[string]interface{}
  27324. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27325. fmt.Println(dat)
  27326. } else {
  27327. fmt.Println(err)
  27328. }
  27329. userJSONBytes, _ := json.Marshal(dat)
  27330. var res models.Result9001
  27331. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27332. utils.ErrorLog("解析失败:%v", err)
  27333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27334. return
  27335. }
  27336. fmt.Println(res.Output.Signinoutb)
  27337. fmt.Println(res.Output.Signinoutb.SignNo)
  27338. fmt.Println(string(userJSONBytes))
  27339. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  27340. var dat3 map[string]interface{}
  27341. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  27342. fmt.Println(dat3)
  27343. } else {
  27344. fmt.Println(err)
  27345. }
  27346. userJSONBytes3, _ := json.Marshal(dat3)
  27347. var res3 models.Result3260
  27348. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  27349. utils.ErrorLog("解析失败:%v", err)
  27350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27351. return
  27352. }
  27353. var curpage int
  27354. var pagesize int = 100
  27355. var start int = 1
  27356. //var stop int
  27357. //pagecount := 10
  27358. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  27359. var res22 []models.Result3260
  27360. for curpage = 1; curpage <= pagecount; curpage++ {
  27361. if curpage == 1 {
  27362. start = 0
  27363. } else {
  27364. start = (curpage-1)*pagesize + 1
  27365. }
  27366. fmt.Println(start)
  27367. //stop = curpage * pagesize
  27368. //if stop > int(res3.Output.Totalrow) {
  27369. // stop =int(res3.Output.Totalrow)
  27370. //}
  27371. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  27372. var dat2 map[string]interface{}
  27373. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27374. fmt.Println(dat)
  27375. } else {
  27376. fmt.Println(err)
  27377. }
  27378. userJSONBytes2, _ := json.Marshal(dat2)
  27379. var res2 models.Result3260
  27380. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27381. utils.ErrorLog("解析失败:%v", err)
  27382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27383. return
  27384. }
  27385. if res2.Infcode == 0 {
  27386. res22 = append(res22,res2)
  27387. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  27388. //var dat2 map[string]interface{}
  27389. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  27390. // fmt.Println(dat)
  27391. //} else {
  27392. // fmt.Println(err)
  27393. //}
  27394. //c.ServeSuccessJSON(map[string]interface{}{
  27395. // "list": res2.Output.Data,
  27396. //})
  27397. //continue
  27398. }
  27399. }
  27400. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  27401. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  27402. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  27403. //var dat2 map[string]interface{}
  27404. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27405. // fmt.Println(dat)
  27406. //} else {
  27407. // fmt.Println(err)
  27408. //}
  27409. //userJSONBytes2, _ := json.Marshal(dat2)
  27410. //var res2 models.Result3260
  27411. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27412. // utils.ErrorLog("解析失败:%v", err)
  27413. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27414. // return
  27415. //}
  27416. //if res2.Infcode == 0 {
  27417. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  27418. // var dat2 map[string]interface{}
  27419. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  27420. // fmt.Println(dat)
  27421. // } else {
  27422. // fmt.Println(err)
  27423. // }
  27424. // c.ServeSuccessJSON(map[string]interface{}{
  27425. // "list": res2.Output.Data,
  27426. // })
  27427. //}
  27428. }
  27429. func (c *HisApiController) ComfirmAllopatry() {
  27430. year := c.GetString("year")
  27431. month := c.GetString("month")
  27432. admin_user_id, _ := c.GetInt64("admin_user_id")
  27433. adminUser := c.GetAdminUserInfo()
  27434. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27435. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27436. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  27437. var dat map[string]interface{}
  27438. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27439. fmt.Println(dat)
  27440. } else {
  27441. fmt.Println(err)
  27442. }
  27443. userJSONBytes, _ := json.Marshal(dat)
  27444. var res models.Result9001
  27445. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27446. utils.ErrorLog("解析失败:%v", err)
  27447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27448. return
  27449. }
  27450. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  27451. var dat2 map[string]interface{}
  27452. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27453. fmt.Println(dat)
  27454. } else {
  27455. fmt.Println(err)
  27456. }
  27457. userJSONBytes2, _ := json.Marshal(dat2)
  27458. var res2 models.Result3260
  27459. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27460. utils.ErrorLog("解析失败:%v", err)
  27461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27462. return
  27463. }
  27464. //if res2.Infcode == 0 {
  27465. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  27466. // var dat map[string]interface{}
  27467. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27468. // fmt.Println(dat)
  27469. // } else {
  27470. // fmt.Println(err)
  27471. // }
  27472. // userJSONBytes, _ := json.Marshal(dat)
  27473. // var res3 models.Result3261
  27474. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  27475. // utils.ErrorLog("解析失败:%v", err)
  27476. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27477. // return
  27478. // }
  27479. //
  27480. // if res3.Infcode == 0 {
  27481. // record := &models.HisYidiClearRecord{
  27482. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  27483. // Ctime: time.Now().Unix(),
  27484. // Mtime: time.Now().Unix(),
  27485. // Status: 1,
  27486. // MsgId: msgId,
  27487. // }
  27488. // service.SaveClearRecord(record)
  27489. // c.ServeSuccessJSON(map[string]interface{}{
  27490. // "msg": "提取成功",
  27491. // })
  27492. // }
  27493. //}
  27494. }
  27495. func (c *HisApiController) RefundAllopatry() {
  27496. year := c.GetString("year")
  27497. month := c.GetString("month")
  27498. //id, _ := c.GetInt64("id")
  27499. admin_user_id, _ := c.GetInt64("admin_user_id")
  27500. adminUser := c.GetAdminUserInfo()
  27501. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27502. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27503. //record, _ := service.GetClearRecordById(id)
  27504. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  27505. var dat map[string]interface{}
  27506. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27507. fmt.Println(dat)
  27508. } else {
  27509. fmt.Println(err)
  27510. }
  27511. userJSONBytes, _ := json.Marshal(dat)
  27512. var res models.Result9001
  27513. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27514. utils.ErrorLog("解析失败:%v", err)
  27515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27516. return
  27517. }
  27518. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  27519. var dat2 map[string]interface{}
  27520. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  27521. fmt.Println(dat)
  27522. } else {
  27523. fmt.Println(err)
  27524. }
  27525. userJSONBytes2, _ := json.Marshal(dat2)
  27526. var empty ResultFourteen
  27527. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  27528. utils.ErrorLog("解析失败:%v", err)
  27529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27530. return
  27531. }
  27532. if empty.Infcode == 0 {
  27533. c.ServeSuccessJSON(map[string]interface{}{
  27534. "msg": "撤销成功",
  27535. })
  27536. return
  27537. }
  27538. }
  27539. func (c *HisApiController) ReversalOtherData() {
  27540. var customData []*CustomData
  27541. custom := &CustomData{
  27542. MsgId: "H44022900158202103301714472004",
  27543. PsnNo: "44020000001101329945",
  27544. Info: "2208",
  27545. }
  27546. customData = append(customData, custom)
  27547. custom1 := &CustomData{
  27548. MsgId: "H4402290015820210330172057803",
  27549. PsnNo: "44020000001101161813",
  27550. Info: "2208",
  27551. }
  27552. customData = append(customData, custom1)
  27553. custom2 := &CustomData{
  27554. MsgId: "H44022900158202103301705198813",
  27555. PsnNo: "44190000133097375417",
  27556. Info: "2208",
  27557. }
  27558. customData = append(customData, custom2)
  27559. custom3 := &CustomData{
  27560. MsgId: "H44022900158202103301715524756",
  27561. PsnNo: "44020000001100187221",
  27562. Info: "2208",
  27563. }
  27564. customData = append(customData, custom3)
  27565. custom4 := &CustomData{
  27566. MsgId: "H44022900158202103301730376224",
  27567. PsnNo: "44020000001101959155",
  27568. Info: "2208",
  27569. }
  27570. customData = append(customData, custom4)
  27571. custom5 := &CustomData{
  27572. MsgId: "H44022900158202103301748008725",
  27573. PsnNo: "44020000001104246641",
  27574. Info: "2208",
  27575. }
  27576. customData = append(customData, custom5)
  27577. custom6 := &CustomData{
  27578. MsgId: "H44022900158202103301718096755",
  27579. PsnNo: "44020000001102211860",
  27580. Info: "2208",
  27581. }
  27582. customData = append(customData, custom6)
  27583. custom7 := &CustomData{
  27584. MsgId: "H44022900158202103301736551640",
  27585. PsnNo: "44020000001102687718",
  27586. Info: "2208",
  27587. }
  27588. customData = append(customData, custom7)
  27589. custom8 := &CustomData{
  27590. MsgId: "H44022900158202103301743097676",
  27591. PsnNo: "44020000001102127785",
  27592. Info: "2208",
  27593. }
  27594. customData = append(customData, custom8)
  27595. custom9 := &CustomData{
  27596. MsgId: "H44022900158202103301712304203",
  27597. PsnNo: "44020000001101518097",
  27598. Info: "2208",
  27599. }
  27600. customData = append(customData, custom9)
  27601. custom10 := &CustomData{
  27602. MsgId: "H44022900158202103301738448785",
  27603. PsnNo: "44020000001100500813",
  27604. Info: "2208",
  27605. }
  27606. customData = append(customData, custom10)
  27607. custom11 := &CustomData{
  27608. MsgId: "H44022900158202103301732455843",
  27609. PsnNo: "44020000001102690557",
  27610. Info: "2208",
  27611. }
  27612. customData = append(customData, custom11)
  27613. custom12 := &CustomData{
  27614. MsgId: "H44022900158202103301745421708",
  27615. PsnNo: "44020000001102211928",
  27616. Info: "2208",
  27617. }
  27618. customData = append(customData, custom12)
  27619. custom1212 := &CustomData{
  27620. MsgId: "H440229001582021033017351627",
  27621. PsnNo: "44020000001102481733",
  27622. Info: "2208",
  27623. }
  27624. customData = append(customData, custom1212)
  27625. custom13 := &CustomData{
  27626. MsgId: "H44022900158202103301740327951",
  27627. PsnNo: "44020000001103174866",
  27628. Info: "2208",
  27629. }
  27630. customData = append(customData, custom13)
  27631. custom14 := &CustomData{
  27632. MsgId: "H4402290015820210330174922668",
  27633. PsnNo: "44020000001102927272",
  27634. Info: "2208",
  27635. }
  27636. customData = append(customData, custom14)
  27637. custom15 := &CustomData{
  27638. MsgId: "H44022900158202103301752362273",
  27639. PsnNo: "44020000001102942890",
  27640. Info: "2208",
  27641. }
  27642. customData = append(customData, custom15)
  27643. custom16 := &CustomData{
  27644. MsgId: "H44022900158202103301751082917",
  27645. PsnNo: "44020000001101662162",
  27646. Info: "2208",
  27647. }
  27648. customData = append(customData, custom16)
  27649. custom17 := &CustomData{
  27650. MsgId: "H44022900158202103301754147728",
  27651. PsnNo: "44020000000229014511",
  27652. Info: "2208",
  27653. }
  27654. customData = append(customData, custom17)
  27655. adminUser := c.GetAdminUserInfo()
  27656. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27657. for _, item := range customData {
  27658. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  27659. fmt.Println(result)
  27660. }
  27661. }
  27662. func PathExists(path string) (bool, error) {
  27663. _, err := os.Stat(path)
  27664. if err == nil {
  27665. return true, nil
  27666. }
  27667. if os.IsNotExist(err) {
  27668. return false, nil
  27669. }
  27670. return false, err
  27671. }
  27672. // 创建文件夹
  27673. func Mkdir(dir string) {
  27674. // 创建文件夹
  27675. exist, err := PathExists(dir)
  27676. if err != nil {
  27677. fmt.Println(err.Error())
  27678. } else {
  27679. if exist {
  27680. fmt.Println(dir + "文件夹已存在!")
  27681. } else {
  27682. // 文件夹名称,权限
  27683. err := os.Mkdir(dir, os.ModePerm)
  27684. if err != nil {
  27685. fmt.Println(dir+"文件夹创建失败:", err.Error())
  27686. } else {
  27687. fmt.Println(dir + "文件夹创建成功!")
  27688. }
  27689. }
  27690. }
  27691. }
  27692. // 压缩文件
  27693. func Zip(srcFile string, destZip string) error {
  27694. zipfile, err := os.Create(destZip)
  27695. if err != nil {
  27696. return err
  27697. }
  27698. defer zipfile.Close()
  27699. archive := zip.NewWriter(zipfile)
  27700. defer archive.Close()
  27701. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  27702. if err != nil {
  27703. return err
  27704. }
  27705. header, err := zip.FileInfoHeader(info)
  27706. if err != nil {
  27707. return err
  27708. }
  27709. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  27710. // header.Name = path
  27711. if info.IsDir() {
  27712. header.Name += "/"
  27713. } else {
  27714. header.Method = zip.Deflate
  27715. }
  27716. writer, err := archive.CreateHeader(header)
  27717. if err != nil {
  27718. return err
  27719. }
  27720. if !info.IsDir() {
  27721. file, err := os.Open(path)
  27722. if err != nil {
  27723. return err
  27724. }
  27725. defer file.Close()
  27726. _, err = io.Copy(writer, file)
  27727. }
  27728. return err
  27729. })
  27730. return err
  27731. }
  27732. func ReadFile(filePath string) []byte {
  27733. f, err := os.Open(filePath)
  27734. if err != nil {
  27735. fmt.Println("read file fail", err)
  27736. return nil
  27737. }
  27738. defer f.Close()
  27739. fd, err := ioutil.ReadAll(f)
  27740. if err != nil {
  27741. fmt.Println("read to fd fail", err)
  27742. return nil
  27743. }
  27744. return fd
  27745. }
  27746. func saveLogq(result string, request string, infno string, desc string) {
  27747. dir := "日志"
  27748. utils.Mkdir(dir)
  27749. month := time.Unix(1557042972, 0).Format("1")
  27750. year := time.Now().Format("2006")
  27751. month = time.Now().Format("01")
  27752. day := time.Now().Format("02")
  27753. hour := time.Now().Format("15")
  27754. min := time.Now().Format("04")
  27755. sec := time.Now().Format("05")
  27756. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  27757. file := year + month + day + "_log"
  27758. file_name := file + ".txt"
  27759. file_path := "日志" + "/" + file_name
  27760. exist, _ := utils.PathExists(file_path)
  27761. if exist { //存在
  27762. fmt.Println("存在")
  27763. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  27764. if err != nil {
  27765. fmt.Println("read fail")
  27766. }
  27767. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  27768. n, _ := f.Seek(0, 2)
  27769. _, err = f.WriteAt([]byte(content), n)
  27770. } else { //不存在
  27771. fmt.Println("文件不存在,创建文件")
  27772. f, err := os.Create("日志" + "/" + file_name)
  27773. defer f.Close()
  27774. if err != nil {
  27775. } else {
  27776. _, err = f.Write([]byte("记录日志"))
  27777. }
  27778. }
  27779. }
  27780. func saveLog(result string, request string, infno string, desc string) {
  27781. org_id, _ := beego.AppConfig.Int64("org_id")
  27782. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  27783. dir := miConfig.OrgName + "日志"
  27784. utils.Mkdir(dir)
  27785. month := time.Unix(1557042972, 0).Format("1")
  27786. year := time.Now().Format("2006")
  27787. month = time.Now().Format("01")
  27788. day := time.Now().Format("02")
  27789. hour := time.Now().Format("15")
  27790. min := time.Now().Format("04")
  27791. sec := time.Now().Format("05")
  27792. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  27793. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  27794. file_name := file + ".txt"
  27795. file_path := miConfig.OrgName + "日志" + "/" + file_name
  27796. exist, _ := utils.PathExists(file_path)
  27797. if exist { //存在
  27798. fmt.Println("存在")
  27799. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  27800. if err != nil {
  27801. fmt.Println("read fail")
  27802. }
  27803. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  27804. n, _ := f.Seek(0, 2)
  27805. _, err = f.WriteAt([]byte(content), n)
  27806. } else { //不存在
  27807. fmt.Println("文件不存在,创建文件")
  27808. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  27809. defer f.Close()
  27810. if err != nil {
  27811. } else {
  27812. _, err = f.Write([]byte("记录日志"))
  27813. }
  27814. }
  27815. }
  27816. type Charset string
  27817. const (
  27818. UTF8 = Charset("UTF-8")
  27819. GB18030 = Charset("GB18030")
  27820. )
  27821. func ConvertToString(src string, srcCode string, tagCode string) string {
  27822. srcCoder := mahonia.NewDecoder(srcCode)
  27823. srcResult := srcCoder.ConvertString(src)
  27824. tagCoder := mahonia.NewDecoder(tagCode)
  27825. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  27826. result := string(cdata)
  27827. return result
  27828. }
  27829. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  27830. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  27831. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  27832. var token string
  27833. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27834. var api string
  27835. if miConfig.MdtrtareaAdmvs == "320921" {
  27836. api = "http://192.168.2.3:9532/" + "jsyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  27837. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  27838. fmt.Println(api)
  27839. } else {
  27840. api = "http://192.168.5.251:9532/" + "jsyb/readcardchargeother?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  27841. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  27842. }
  27843. resp, requestErr := http.Get(api)
  27844. if requestErr != nil {
  27845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27846. return ""
  27847. }
  27848. body, ioErr := ioutil.ReadAll(resp.Body)
  27849. if ioErr != nil {
  27850. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27852. return ""
  27853. }
  27854. var respJSON map[string]interface{}
  27855. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27856. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27858. return ""
  27859. }
  27860. var status string
  27861. status = respJSON["data"].(map[string]interface{})["status"].(string)
  27862. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  27863. var res ResultTwo //1101结果
  27864. var res10265 ResultTwo10265 //1101结果
  27865. if status == "0" { //读卡成功
  27866. var card_info string //卡信息
  27867. var busi_card_info string
  27868. token = respJSON["data"].(map[string]interface{})["token"].(string)
  27869. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  27870. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  27871. fmt.Println(card_info)
  27872. fmt.Println(busi_card_info)
  27873. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  27874. result, _ := json.Marshal(respJSON)
  27875. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27876. utils.ErrorLog("解析失败:%v", err)
  27877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27878. return ""
  27879. }
  27880. res.ErrMsg = res10265.ErrMsg
  27881. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27882. res.Infcode = infocode
  27883. res.Output = res10265.Output
  27884. res.InfRefmsgid = res10265.InfRefmsgid
  27885. if res.Infcode == 0 {
  27886. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  27887. if err == gorm.ErrRecordNotFound {
  27888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  27889. return ""
  27890. } else if err != nil {
  27891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  27892. return ""
  27893. } else {
  27894. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  27895. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  27896. infoStr := string(Iinfos)
  27897. idetinfoStr := string(Idetinfos)
  27898. psn := &models.HisPsn{
  27899. PsnNo: res.Output.Baseinfo.PsnNo,
  27900. PatientId: patient.ID,
  27901. Certno: res.Output.Baseinfo.Certno,
  27902. Gend: res.Output.Baseinfo.Gend,
  27903. Naty: res.Output.Baseinfo.Naty,
  27904. PsnCertType: res.Output.Baseinfo.PsnCertType,
  27905. PsnName: res.Output.Baseinfo.PsnName,
  27906. Idetinfo: idetinfoStr,
  27907. Insuinfo: infoStr,
  27908. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  27909. CardInfo: card_info,
  27910. VerifyNumber: token,
  27911. }
  27912. service.CreateHisPsn(psn)
  27913. return token
  27914. }
  27915. }
  27916. } else {
  27917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  27918. return ""
  27919. }
  27920. } else { //读卡失败
  27921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  27922. return ""
  27923. }
  27924. return token
  27925. }
  27926. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  27927. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  27928. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  27929. var token string
  27930. var api string
  27931. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  27932. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  27933. fmt.Println(api)
  27934. resp, requestErr := http.Get(api)
  27935. if requestErr != nil {
  27936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27937. return ""
  27938. }
  27939. body, ioErr := ioutil.ReadAll(resp.Body)
  27940. if ioErr != nil {
  27941. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27943. return ""
  27944. }
  27945. var respJSON map[string]interface{}
  27946. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27947. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27949. return ""
  27950. }
  27951. var status string
  27952. status = respJSON["data"].(map[string]interface{})["status"].(string)
  27953. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  27954. var res ResultTwo //1101结果
  27955. if status == "1" { //读卡成功
  27956. var card_info string //卡信息
  27957. var busi_card_info string
  27958. token = respJSON["data"].(map[string]interface{})["token"].(string)
  27959. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  27960. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  27961. fmt.Println(card_info)
  27962. fmt.Println(busi_card_info)
  27963. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  27964. result, _ := json.Marshal(respJSON)
  27965. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27966. utils.ErrorLog("解析失败:%v", err)
  27967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27968. return ""
  27969. }
  27970. if res.Infcode == 0 {
  27971. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  27972. if err == gorm.ErrRecordNotFound {
  27973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  27974. return ""
  27975. } else if err != nil {
  27976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  27977. return ""
  27978. } else {
  27979. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  27980. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  27981. infoStr := string(Iinfos)
  27982. idetinfoStr := string(Idetinfos)
  27983. psn := &models.HisPsn{
  27984. PsnNo: res.Output.Baseinfo.PsnNo,
  27985. PatientId: patient.ID,
  27986. Certno: res.Output.Baseinfo.Certno,
  27987. Gend: res.Output.Baseinfo.Gend,
  27988. Naty: res.Output.Baseinfo.Naty,
  27989. PsnCertType: res.Output.Baseinfo.PsnCertType,
  27990. PsnName: res.Output.Baseinfo.PsnName,
  27991. Idetinfo: idetinfoStr,
  27992. Insuinfo: infoStr,
  27993. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  27994. CardInfo: card_info,
  27995. VerifyNumber: token,
  27996. }
  27997. service.CreateHisPsn(psn)
  27998. return token
  27999. }
  28000. }
  28001. } else {
  28002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28003. return ""
  28004. }
  28005. return token
  28006. }
  28007. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  28008. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  28009. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  28010. var token string
  28011. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28012. var api string
  28013. if miConfig.MdtrtareaAdmvs == "320921" {
  28014. api = "http://192.168.2.3:9532/" + "jsyb/readcardface?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  28015. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  28016. fmt.Println(api)
  28017. } else {
  28018. api = "http://192.168.5.251:9532/" + "jsyb/readcardface?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  28019. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(4, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  28020. }
  28021. resp, requestErr := http.Get(api)
  28022. if requestErr != nil {
  28023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28024. return ""
  28025. }
  28026. body, ioErr := ioutil.ReadAll(resp.Body)
  28027. if ioErr != nil {
  28028. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28030. return ""
  28031. }
  28032. var respJSON map[string]interface{}
  28033. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28036. return ""
  28037. }
  28038. var status string
  28039. status = respJSON["data"].(map[string]interface{})["status"].(string)
  28040. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  28041. var res ResultTwo //1101结果
  28042. var res10265 ResultTwo10265 //1101结果
  28043. if status == "0" { //读卡成功
  28044. var card_info string //卡信息
  28045. var busi_card_info string
  28046. token = respJSON["data"].(map[string]interface{})["token"].(string)
  28047. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  28048. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  28049. fmt.Println(card_info)
  28050. fmt.Println(busi_card_info)
  28051. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  28052. result, _ := json.Marshal(respJSON)
  28053. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28054. utils.ErrorLog("解析失败:%v", err)
  28055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28056. return ""
  28057. }
  28058. res.ErrMsg = res10265.ErrMsg
  28059. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28060. res.Infcode = infocode
  28061. res.Output = res10265.Output
  28062. res.InfRefmsgid = res10265.InfRefmsgid
  28063. if res.Infcode == 0 {
  28064. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  28065. if err == gorm.ErrRecordNotFound {
  28066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  28067. return ""
  28068. } else if err != nil {
  28069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  28070. return ""
  28071. } else {
  28072. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28073. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  28074. infoStr := string(Iinfos)
  28075. idetinfoStr := string(Idetinfos)
  28076. psn := &models.HisPsn{
  28077. PsnNo: res.Output.Baseinfo.PsnNo,
  28078. PatientId: patient.ID,
  28079. Certno: res.Output.Baseinfo.Certno,
  28080. Gend: res.Output.Baseinfo.Gend,
  28081. Naty: res.Output.Baseinfo.Naty,
  28082. PsnCertType: res.Output.Baseinfo.PsnCertType,
  28083. PsnName: res.Output.Baseinfo.PsnName,
  28084. Idetinfo: idetinfoStr,
  28085. Insuinfo: infoStr,
  28086. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28087. CardInfo: card_info,
  28088. VerifyNumber: token,
  28089. }
  28090. service.CreateHisPsn(psn)
  28091. return token
  28092. }
  28093. }
  28094. } else {
  28095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28096. return ""
  28097. }
  28098. } else { //读卡失败
  28099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28100. return ""
  28101. }
  28102. return token
  28103. }
  28104. func DeleteExtraSpaceTwo(s string) string {
  28105. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  28106. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  28107. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  28108. reg, _ := regexp.Compile(regstr) //编译正则表达式
  28109. s2 := make([]byte, len(s1)) //定义字符数组切片
  28110. copy(s2, s1) //将字符串复制到切片
  28111. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  28112. for len(spc_index) > 0 { //找到适配项
  28113. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  28114. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  28115. }
  28116. return string(s2)
  28117. }
  28118. func Remove0000(s string) string {
  28119. str := make([]rune, 0, len(s))
  28120. for _, v := range []rune(s) {
  28121. if v == 0 {
  28122. continue
  28123. }
  28124. str = append(str, v)
  28125. }
  28126. return string(str)
  28127. }
  28128. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  28129. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  28130. readCard := DllDef.MustFindProc("EcQuery")
  28131. pCardInfo := make([]byte, 8192)
  28132. pBusiCardInfo := make([]byte, 8192)
  28133. data := make(map[string]interface{})
  28134. //pData := make(map[string]interface{})
  28135. inputData := make(map[string]interface{})
  28136. inputData["orgId"] = code
  28137. inputData["businessType"] = "01101"
  28138. inputData["operatorId"] = operator_id
  28139. inputData["operatorName"] = operator_name
  28140. inputData["officeId"] = "001"
  28141. inputData["officeName"] = "血透室"
  28142. //
  28143. data["data"] = inputData
  28144. data["transType"] = "ec.query"
  28145. data["orgId"] = code
  28146. bytesData, _ := json.Marshal(data)
  28147. pCardInfo = bytesData
  28148. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  28149. fmt.Println(ret2)
  28150. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  28151. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  28152. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  28153. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  28154. if ret2 != 0 {
  28155. return "", ""
  28156. }
  28157. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  28158. }
  28159. func DeleteExtraSpace(s string) string {
  28160. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  28161. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  28162. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  28163. reg, _ := regexp.Compile(regstr) //编译正则表达式
  28164. s2 := make([]byte, len(s1)) //定义字符数组切片
  28165. copy(s2, s1) //将字符串复制到切片
  28166. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  28167. for len(spc_index) > 0 { //找到适配项
  28168. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  28169. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  28170. }
  28171. return string(s2)
  28172. }
  28173. // 对账
  28174. func (c *HisApiController) Post3202() {
  28175. start_time := c.GetString("start_time")
  28176. end_time := c.GetString("end_time")
  28177. //insutype := c.GetString("insutype")
  28178. clr_type := c.GetString("clr_type")
  28179. clr_org := c.GetString("clr_optins")
  28180. admin_user_id, _ := c.GetInt64("admin_user_id")
  28181. adminUser := c.GetAdminUserInfo()
  28182. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28183. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28184. if len(clr_org) == 0 {
  28185. clr_org = miConfig.MdtrtareaAdmvs
  28186. }
  28187. timeLayout := "2006-01-02"
  28188. loc, _ := time.LoadLocation("Local")
  28189. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  28190. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  28191. var orders []*models.HisOrder
  28192. if clr_org == "421300" {
  28193. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  28194. } else {
  28195. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  28196. }
  28197. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  28198. //fixmedins_setl_cnt := int64(len(orders))
  28199. var medfee_sumamt float64
  28200. var acct_pay float64
  28201. var fund_pay_sumamt float64
  28202. for _, item := range orders {
  28203. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  28204. acct_pay = acct_pay + item.AcctPay
  28205. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  28206. }
  28207. //var medfee_sumamt_two float64
  28208. //var acct_pay_two float64
  28209. //var fund_pay_sumamt_two float64
  28210. //for _, item := range orders_two {
  28211. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  28212. // acct_pay_two = acct_pay_two + item.AcctPay
  28213. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  28214. //}
  28215. //var user_name string
  28216. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28217. //if role.ID == 0 {
  28218. // user_name = "xxx"
  28219. //} else {
  28220. // user_name = role.UserName
  28221. //}
  28222. var res ResultSix
  28223. if config.IsOpen == 1 {
  28224. var bps []*models.BusinessParamsTwo
  28225. var bp models.BusinessParamsTwo
  28226. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  28227. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  28228. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  28229. bp.MedfeeSumamt = medfee_sumamt_str
  28230. bp.AcctPay = acct_pay_str
  28231. bp.FundPaySumamt = fund_pay_sumamt_str
  28232. bp.Insutype = ""
  28233. bp.StmtBegndate = start_time
  28234. bp.ClrType = clr_type
  28235. bp.SetlOptins = clr_org
  28236. bp.StmtEnddate = end_time
  28237. bps = append(bps, &bp)
  28238. data := make(map[string]interface{})
  28239. data["bps"] = bps
  28240. data["org_name"] = miConfig.OrgName
  28241. data["doctor"] = role.UserName
  28242. data["fixmedins_code"] = miConfig.Code
  28243. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28244. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28245. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28246. if miConfig.MdtrtareaAdmvs == "421300" {
  28247. client := &http.Client{}
  28248. bytesData, _ := json.Marshal(data)
  28249. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  28250. resp, _ := client.Do(req)
  28251. defer resp.Body.Close()
  28252. body, ioErr := ioutil.ReadAll(resp.Body)
  28253. if ioErr != nil {
  28254. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28256. return
  28257. }
  28258. var respJSON map[string]interface{}
  28259. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28260. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28262. return
  28263. }
  28264. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28265. userJSONBytes, _ := json.Marshal(respJSON)
  28266. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28267. utils.ErrorLog("解析失败:%v", err)
  28268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28269. return
  28270. }
  28271. }
  28272. if miConfig.MdtrtareaAdmvs == "420200" {
  28273. client := &http.Client{}
  28274. bytesData, _ := json.Marshal(data)
  28275. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  28276. resp, _ := client.Do(req)
  28277. defer resp.Body.Close()
  28278. body, ioErr := ioutil.ReadAll(resp.Body)
  28279. if ioErr != nil {
  28280. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28282. return
  28283. }
  28284. var respJSON map[string]interface{}
  28285. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28286. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28288. return
  28289. }
  28290. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28291. userJSONBytes, _ := json.Marshal(respJSON)
  28292. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28293. utils.ErrorLog("解析失败:%v", err)
  28294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28295. return
  28296. }
  28297. }
  28298. if miConfig.MdtrtareaAdmvs == "421182" {
  28299. client := &http.Client{}
  28300. bytesData, _ := json.Marshal(data)
  28301. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  28302. resp, _ := client.Do(req)
  28303. defer resp.Body.Close()
  28304. body, ioErr := ioutil.ReadAll(resp.Body)
  28305. if ioErr != nil {
  28306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28308. return
  28309. }
  28310. var respJSON map[string]interface{}
  28311. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28314. return
  28315. }
  28316. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28317. userJSONBytes, _ := json.Marshal(respJSON)
  28318. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28319. utils.ErrorLog("解析失败:%v", err)
  28320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28321. return
  28322. }
  28323. }
  28324. if res.Infcode == 0 {
  28325. c.ServeSuccessJSON(map[string]interface{}{
  28326. "msg": "发起成功",
  28327. })
  28328. } else {
  28329. c.ServeSuccessJSON(map[string]interface{}{
  28330. "failed_code": -10,
  28331. "msg": res.ErrMsg,
  28332. })
  28333. }
  28334. }
  28335. }
  28336. func (c *HisApiController) Post3202b() {
  28337. start_time := c.GetString("start_time")
  28338. end_time := c.GetString("end_time")
  28339. //insutype := c.GetString("insutype")
  28340. clr_type := c.GetString("clr_type")
  28341. clr_org := c.GetString("clr_optins")
  28342. admin_user_id, _ := c.GetInt64("admin_user_id")
  28343. adminUser := c.GetAdminUserInfo()
  28344. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28345. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28346. if len(clr_org) == 0 {
  28347. clr_org = miConfig.MdtrtareaAdmvs
  28348. }
  28349. timeLayout := "2006-01-02"
  28350. loc, _ := time.LoadLocation("Local")
  28351. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  28352. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  28353. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  28354. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  28355. //fixmedins_setl_cnt := int64(len(orders))
  28356. var medfee_sumamt float64
  28357. var acct_pay float64
  28358. var fund_pay_sumamt float64
  28359. for _, item := range orders {
  28360. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  28361. acct_pay = acct_pay + item.AcctPay
  28362. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  28363. }
  28364. //var medfee_sumamt_two float64
  28365. //var acct_pay_two float64
  28366. //var fund_pay_sumamt_two float64
  28367. //for _, item := range orders_two {
  28368. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  28369. // acct_pay_two = acct_pay_two + item.AcctPay
  28370. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  28371. //}
  28372. //var user_name string
  28373. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28374. //if role.ID == 0 {
  28375. // user_name = "xxx"
  28376. //} else {
  28377. // user_name = role.UserName
  28378. //}
  28379. var res ResultSix
  28380. if config.IsOpen == 1 {
  28381. var bps []*models.BusinessParamsTwo
  28382. var bp models.BusinessParamsTwo
  28383. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  28384. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  28385. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  28386. bp.MedfeeSumamt = medfee_sumamt_str
  28387. bp.AcctPay = acct_pay_str
  28388. bp.FundPaySumamt = fund_pay_sumamt_str
  28389. bp.Insutype = "390"
  28390. bp.StmtBegndate = start_time
  28391. bp.ClrType = clr_type
  28392. bp.SetlOptins = clr_org
  28393. bp.StmtEnddate = end_time
  28394. bps = append(bps, &bp)
  28395. data := make(map[string]interface{})
  28396. data["bps"] = bps
  28397. data["org_name"] = miConfig.OrgName
  28398. data["doctor"] = role.UserName
  28399. data["fixmedins_code"] = miConfig.Code
  28400. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28401. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28402. if miConfig.MdtrtareaAdmvs == "421300" {
  28403. client := &http.Client{}
  28404. bytesData, _ := json.Marshal(data)
  28405. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  28406. resp, _ := client.Do(req)
  28407. defer resp.Body.Close()
  28408. body, ioErr := ioutil.ReadAll(resp.Body)
  28409. if ioErr != nil {
  28410. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28412. return
  28413. }
  28414. var respJSON map[string]interface{}
  28415. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28416. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28418. return
  28419. }
  28420. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28421. userJSONBytes, _ := json.Marshal(respJSON)
  28422. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28423. utils.ErrorLog("解析失败:%v", err)
  28424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28425. return
  28426. }
  28427. }
  28428. if miConfig.MdtrtareaAdmvs == "420200" {
  28429. client := &http.Client{}
  28430. bytesData, _ := json.Marshal(data)
  28431. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  28432. resp, _ := client.Do(req)
  28433. defer resp.Body.Close()
  28434. body, ioErr := ioutil.ReadAll(resp.Body)
  28435. if ioErr != nil {
  28436. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28438. return
  28439. }
  28440. var respJSON map[string]interface{}
  28441. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28442. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28444. return
  28445. }
  28446. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28447. userJSONBytes, _ := json.Marshal(respJSON)
  28448. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28449. utils.ErrorLog("解析失败:%v", err)
  28450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28451. return
  28452. }
  28453. }
  28454. if miConfig.MdtrtareaAdmvs == "421182" {
  28455. client := &http.Client{}
  28456. bytesData, _ := json.Marshal(data)
  28457. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  28458. resp, _ := client.Do(req)
  28459. defer resp.Body.Close()
  28460. body, ioErr := ioutil.ReadAll(resp.Body)
  28461. if ioErr != nil {
  28462. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28464. return
  28465. }
  28466. var respJSON map[string]interface{}
  28467. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28470. return
  28471. }
  28472. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28473. userJSONBytes, _ := json.Marshal(respJSON)
  28474. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28475. utils.ErrorLog("解析失败:%v", err)
  28476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28477. return
  28478. }
  28479. }
  28480. if res.Infcode == 0 {
  28481. c.ServeSuccessJSON(map[string]interface{}{
  28482. "msg": "发起成功",
  28483. })
  28484. } else {
  28485. c.ServeSuccessJSON(map[string]interface{}{
  28486. "failed_code": -10,
  28487. "msg": res.ErrMsg,
  28488. })
  28489. }
  28490. }
  28491. }
  28492. func (c *HisApiController) Post1608() {
  28493. start_time := c.GetString("start_time")
  28494. end_time := c.GetString("end_time")
  28495. admin_user_id, _ := c.GetInt64("admin_user_id")
  28496. adminUser := c.GetAdminUserInfo()
  28497. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28498. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28499. timeLayout := "2006-01-02"
  28500. loc, _ := time.LoadLocation("Local")
  28501. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  28502. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  28503. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  28504. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  28505. fixmedins_setl_cnt := int64(len(orders))
  28506. var medfee_sumamt float64
  28507. var func_smamt float64
  28508. for _, item := range orders {
  28509. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  28510. func_smamt= func_smamt + item.FundPaySumamt + item.AcctPay
  28511. }
  28512. times := strings.Split(start_time, "-")
  28513. time_tows := strings.Split(end_time, "-")
  28514. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28515. var res ResultSix
  28516. if config.IsOpen == 1 {
  28517. //var bps []*models.BusinessParamsTwo
  28518. //var bp models.BusinessParamsTwo
  28519. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  28520. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  28521. data := make(map[string]interface{})
  28522. data["org_name"] = miConfig.OrgName
  28523. data["doctor"] = role.UserName
  28524. data["func_smamt"] = func_smamt_str
  28525. data["fixmedins_code"] = miConfig.Code
  28526. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28527. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28528. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  28529. data["medfee_sumamt"] = medfee_sumamt_str
  28530. data["start_time"] = times[0] + times[1] + times[2]
  28531. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  28532. if miConfig.MdtrtareaAdmvs == "421300" {
  28533. client := &http.Client{}
  28534. bytesData, _ := json.Marshal(data)
  28535. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  28536. resp, _ := client.Do(req)
  28537. defer resp.Body.Close()
  28538. body, ioErr := ioutil.ReadAll(resp.Body)
  28539. if ioErr != nil {
  28540. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28542. return
  28543. }
  28544. var respJSON map[string]interface{}
  28545. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28548. return
  28549. }
  28550. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28551. userJSONBytes, _ := json.Marshal(respJSON)
  28552. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28553. utils.ErrorLog("解析失败:%v", err)
  28554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28555. return
  28556. }
  28557. }
  28558. if miConfig.MdtrtareaAdmvs == "420200" {
  28559. client := &http.Client{}
  28560. bytesData, _ := json.Marshal(data)
  28561. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  28562. resp, _ := client.Do(req)
  28563. defer resp.Body.Close()
  28564. body, ioErr := ioutil.ReadAll(resp.Body)
  28565. if ioErr != nil {
  28566. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28568. return
  28569. }
  28570. var respJSON map[string]interface{}
  28571. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28572. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28574. return
  28575. }
  28576. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28577. userJSONBytes, _ := json.Marshal(respJSON)
  28578. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28579. utils.ErrorLog("解析失败:%v", err)
  28580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28581. return
  28582. }
  28583. }
  28584. if miConfig.MdtrtareaAdmvs == "421182" {
  28585. client := &http.Client{}
  28586. bytesData, _ := json.Marshal(data)
  28587. req, _ := http.NewRequest("POST",miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  28588. resp, _ := client.Do(req)
  28589. defer resp.Body.Close()
  28590. body, ioErr := ioutil.ReadAll(resp.Body)
  28591. if ioErr != nil {
  28592. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28594. return
  28595. }
  28596. var respJSON map[string]interface{}
  28597. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28598. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28600. return
  28601. }
  28602. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28603. userJSONBytes, _ := json.Marshal(respJSON)
  28604. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28605. utils.ErrorLog("解析失败:%v", err)
  28606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28607. return
  28608. }
  28609. }
  28610. if res.Infcode == 0 {
  28611. c.ServeSuccessJSON(map[string]interface{}{
  28612. "msg": "发起成功",
  28613. })
  28614. } else {
  28615. c.ServeSuccessJSON(map[string]interface{}{
  28616. "failed_code": -10,
  28617. "msg": res.ErrMsg,
  28618. })
  28619. }
  28620. }
  28621. }
  28622. // 5.11.1.1【5262】结算信息按时间段查询
  28623. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  28624. admin_user_id, _ := c.GetInt64("admin_user_id")
  28625. adminUser := c.GetAdminUserInfo()
  28626. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28627. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28628. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28629. var res Result5262
  28630. if config.IsOpen == 1 {
  28631. if miConfig.MdtrtareaAdmvs == "421300" {
  28632. data := make(map[string]interface{})
  28633. data["bps"] = bp
  28634. data["org_name"] = miConfig.OrgName
  28635. data["doctor"] = role.UserName
  28636. data["fixmedins_code"] = miConfig.Code
  28637. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28638. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28639. data["page"] = strconv.FormatInt(page, 10)
  28640. data["limit"] = strconv.FormatInt(limit, 10)
  28641. fmt.Println(data)
  28642. client := &http.Client{}
  28643. bytesData, _ := json.Marshal(data)
  28644. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  28645. resp, _ := client.Do(req)
  28646. defer resp.Body.Close()
  28647. body, ioErr := ioutil.ReadAll(resp.Body)
  28648. if ioErr != nil {
  28649. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28651. return
  28652. }
  28653. var respJSON map[string]interface{}
  28654. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28655. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28657. return
  28658. }
  28659. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28660. userJSONBytes, _ := json.Marshal(respJSON)
  28661. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28662. utils.ErrorLog("解析失败:%v", err)
  28663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28664. return
  28665. }
  28666. }
  28667. if miConfig.MdtrtareaAdmvs == "420200" {
  28668. data := make(map[string]interface{})
  28669. data["bps"] = bp
  28670. data["org_name"] = miConfig.OrgName
  28671. data["doctor"] = role.UserName
  28672. data["fixmedins_code"] = miConfig.Code
  28673. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28674. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28675. data["page"] = strconv.FormatInt(page, 10)
  28676. data["limit"] = strconv.FormatInt(limit, 10)
  28677. fmt.Println(data)
  28678. client := &http.Client{}
  28679. bytesData, _ := json.Marshal(data)
  28680. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  28681. resp, _ := client.Do(req)
  28682. defer resp.Body.Close()
  28683. body, ioErr := ioutil.ReadAll(resp.Body)
  28684. if ioErr != nil {
  28685. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28687. return
  28688. }
  28689. var respJSON map[string]interface{}
  28690. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28691. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28693. return
  28694. }
  28695. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28696. userJSONBytes, _ := json.Marshal(respJSON)
  28697. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28698. utils.ErrorLog("解析失败:%v", err)
  28699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28700. return
  28701. }
  28702. }
  28703. if miConfig.MdtrtareaAdmvs == "421182" {
  28704. data := make(map[string]interface{})
  28705. data["bps"] = bp
  28706. data["org_name"] = miConfig.OrgName
  28707. data["doctor"] = role.UserName
  28708. data["fixmedins_code"] = miConfig.Code
  28709. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28710. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28711. data["page"] = strconv.FormatInt(page, 10)
  28712. data["limit"] = strconv.FormatInt(limit, 10)
  28713. fmt.Println(data)
  28714. client := &http.Client{}
  28715. bytesData, _ := json.Marshal(data)
  28716. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  28717. resp, _ := client.Do(req)
  28718. defer resp.Body.Close()
  28719. body, ioErr := ioutil.ReadAll(resp.Body)
  28720. if ioErr != nil {
  28721. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28723. return
  28724. }
  28725. var respJSON map[string]interface{}
  28726. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28727. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28729. return
  28730. }
  28731. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28732. userJSONBytes, _ := json.Marshal(respJSON)
  28733. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28734. utils.ErrorLog("解析失败:%v", err)
  28735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28736. return
  28737. }
  28738. }
  28739. if res.Infcode == 0 {
  28740. c.ServeSuccessJSON(map[string]interface{}{
  28741. "order": res.Output.Result,
  28742. "total": res.Output.PageInfo.RecordCounts,
  28743. })
  28744. } else {
  28745. c.ServeSuccessJSON(map[string]interface{}{
  28746. "failed_code": -10,
  28747. "msg": res.ErrMsg,
  28748. })
  28749. }
  28750. }
  28751. }
  28752. // 5.11.1.2【5267】异地结算信息时间段查询
  28753. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  28754. admin_user_id, _ := c.GetInt64("admin_user_id")
  28755. adminUser := c.GetAdminUserInfo()
  28756. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28757. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28758. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28759. var res Result5267
  28760. if config.IsOpen == 1 {
  28761. if miConfig.MdtrtareaAdmvs == "421300" {
  28762. data := make(map[string]interface{})
  28763. data["bps"] = bp
  28764. data["org_name"] = miConfig.OrgName
  28765. data["doctor"] = role.UserName
  28766. data["fixmedins_code"] = miConfig.Code
  28767. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28768. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28769. data["page"] = page
  28770. data["limit"] = limit
  28771. fmt.Println(data)
  28772. client := &http.Client{}
  28773. bytesData, _ := json.Marshal(data)
  28774. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  28775. resp, _ := client.Do(req)
  28776. defer resp.Body.Close()
  28777. body, ioErr := ioutil.ReadAll(resp.Body)
  28778. if ioErr != nil {
  28779. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28781. return
  28782. }
  28783. var respJSON map[string]interface{}
  28784. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28785. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28787. return
  28788. }
  28789. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28790. userJSONBytes, _ := json.Marshal(respJSON)
  28791. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28792. utils.ErrorLog("解析失败:%v", err)
  28793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28794. return
  28795. }
  28796. }
  28797. if miConfig.MdtrtareaAdmvs == "420200" {
  28798. data := make(map[string]interface{})
  28799. data["bps"] = bp
  28800. data["org_name"] = miConfig.OrgName
  28801. data["doctor"] = role.UserName
  28802. data["fixmedins_code"] = miConfig.Code
  28803. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28804. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28805. data["page"] = page
  28806. data["limit"] = limit
  28807. fmt.Println(data)
  28808. client := &http.Client{}
  28809. bytesData, _ := json.Marshal(data)
  28810. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  28811. resp, _ := client.Do(req)
  28812. defer resp.Body.Close()
  28813. body, ioErr := ioutil.ReadAll(resp.Body)
  28814. if ioErr != nil {
  28815. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28817. return
  28818. }
  28819. var respJSON map[string]interface{}
  28820. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28823. return
  28824. }
  28825. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28826. userJSONBytes, _ := json.Marshal(respJSON)
  28827. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28828. utils.ErrorLog("解析失败:%v", err)
  28829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28830. return
  28831. }
  28832. }
  28833. if miConfig.MdtrtareaAdmvs == "421182" {
  28834. data := make(map[string]interface{})
  28835. data["bps"] = bp
  28836. data["org_name"] = miConfig.OrgName
  28837. data["doctor"] = role.UserName
  28838. data["fixmedins_code"] = miConfig.Code
  28839. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28840. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28841. data["page"] = page
  28842. data["limit"] = limit
  28843. fmt.Println(data)
  28844. client := &http.Client{}
  28845. bytesData, _ := json.Marshal(data)
  28846. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  28847. resp, _ := client.Do(req)
  28848. defer resp.Body.Close()
  28849. body, ioErr := ioutil.ReadAll(resp.Body)
  28850. if ioErr != nil {
  28851. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28853. return
  28854. }
  28855. var respJSON map[string]interface{}
  28856. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28857. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28859. return
  28860. }
  28861. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28862. userJSONBytes, _ := json.Marshal(respJSON)
  28863. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28864. utils.ErrorLog("解析失败:%v", err)
  28865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28866. return
  28867. }
  28868. }
  28869. if res.Infcode == 0 {
  28870. c.ServeSuccessJSON(map[string]interface{}{
  28871. "order": res.Output.Result,
  28872. "total": res.Output.PageInfo.RecordCounts,
  28873. })
  28874. } else {
  28875. c.ServeSuccessJSON(map[string]interface{}{
  28876. "failed_code": -10,
  28877. "msg": res.ErrMsg,
  28878. })
  28879. }
  28880. }
  28881. }
  28882. func (c *HisApiController) Post3501() {
  28883. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  28884. data := make(map[string]interface{})
  28885. var struct3501s []models.Struct3501
  28886. var struct3501 models.Struct3501
  28887. struct3501.OrgName = miConfig.OrgName
  28888. struct3501.AccessKey = miConfig.AccessKey
  28889. struct3501.RequestUrl = miConfig.Url
  28890. struct3501.SecretKey = miConfig.SecretKey
  28891. struct3501.ManuDate = "2022-08-17"
  28892. struct3501.FixmedinsBchno = ""
  28893. struct3501.ManuLotnum = ""
  28894. struct3501.RxFlag = "0"
  28895. struct3501.ExpyEnd = "2022-08-17"
  28896. struct3501.Invdate = "2022-08-17"
  28897. struct3501.InvCnt = "20.25"
  28898. struct3501.Memo = ""
  28899. struct3501.MedListCodg = "XB01ABD056B002020200517"
  28900. struct3501.FixmedinsHilistId = miConfig.Code
  28901. struct3501.FixmedinsHilistName = miConfig.OrgName
  28902. struct3501s = append(struct3501s, struct3501)
  28903. data["struct_3501s"] = struct3501s
  28904. client := &http.Client{}
  28905. bytesData, _ := json.Marshal(data)
  28906. var req *http.Request
  28907. if miConfig.MdtrtareaAdmvs == "320921" {
  28908. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  28909. } else {
  28910. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  28911. }
  28912. resp, _ := client.Do(req)
  28913. defer resp.Body.Close()
  28914. body, ioErr := ioutil.ReadAll(resp.Body)
  28915. if ioErr != nil {
  28916. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28918. return
  28919. }
  28920. var respJSON map[string]interface{}
  28921. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28922. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28924. return
  28925. }
  28926. var res ResultSix
  28927. var resSix10265 ResultSix10265 //1101结果
  28928. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  28929. result, _ := json.Marshal(respJSON)
  28930. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  28931. utils.ErrorLog("解析失败:%v", err)
  28932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28933. return
  28934. }
  28935. res.InfRefmsgid = resSix10265.InfRefmsgid
  28936. res.Output = resSix10265.Output
  28937. res.ErrMsg = resSix10265.ErrMsg
  28938. res.Cainfo = resSix10265.Cainfo
  28939. res.WarnMsg = resSix10265.WarnMsg
  28940. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  28941. res.Infcode = infocode
  28942. if infocode == 0 {
  28943. c.ServeSuccessJSON(map[string]interface{}{
  28944. "msg": "上传成功",
  28945. })
  28946. return
  28947. } else {
  28948. c.ServeSuccessJSON(map[string]interface{}{
  28949. "failed_code": -10,
  28950. "msg": res.ErrMsg,
  28951. })
  28952. return
  28953. }
  28954. }
  28955. func (c *HisApiController) Post3502() {
  28956. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  28957. data := make(map[string]interface{})
  28958. var struct3502s []models.Struct3502
  28959. var struct3502 models.Struct3502
  28960. struct3502.OrgName = miConfig.OrgName
  28961. struct3502.AccessKey = miConfig.AccessKey
  28962. struct3502.RequestUrl = miConfig.Url
  28963. struct3502.SecretKey = miConfig.SecretKey
  28964. struct3502.ManuDate = "2022-08-15"
  28965. struct3502.FixmedinsBchno = ""
  28966. struct3502.ManuLotnum = ""
  28967. struct3502.RxFlag = "0"
  28968. struct3502.ExpyEnd = "2022-08-15"
  28969. struct3502.Invdate = "2022-08-15"
  28970. struct3502.InvCnt = "20.25"
  28971. struct3502.Memo = ""
  28972. struct3502.MedListCodg = "XB01ABD056B002020200517"
  28973. struct3502.FixmedinsHilistId = miConfig.Code
  28974. struct3502.FixmedinsHilistName = miConfig.OrgName
  28975. struct3502s = append(struct3502s, struct3502)
  28976. data["struct_3502s"] = struct3502s
  28977. client := &http.Client{}
  28978. bytesData, _ := json.Marshal(data)
  28979. var req *http.Request
  28980. if miConfig.MdtrtareaAdmvs == "320921" {
  28981. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  28982. } else {
  28983. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  28984. }
  28985. resp, _ := client.Do(req)
  28986. defer resp.Body.Close()
  28987. body, ioErr := ioutil.ReadAll(resp.Body)
  28988. if ioErr != nil {
  28989. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28991. return
  28992. }
  28993. var respJSON map[string]interface{}
  28994. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28995. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28997. return
  28998. }
  28999. var res ResultSix
  29000. var resSix10265 ResultSix10265 //1101结果
  29001. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29002. result, _ := json.Marshal(respJSON)
  29003. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29004. utils.ErrorLog("解析失败:%v", err)
  29005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29006. return
  29007. }
  29008. res.InfRefmsgid = resSix10265.InfRefmsgid
  29009. res.Output = resSix10265.Output
  29010. res.ErrMsg = resSix10265.ErrMsg
  29011. res.Cainfo = resSix10265.Cainfo
  29012. res.WarnMsg = resSix10265.WarnMsg
  29013. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29014. res.Infcode = infocode
  29015. if infocode == 0 {
  29016. c.ServeSuccessJSON(map[string]interface{}{
  29017. "msg": "上传成功",
  29018. })
  29019. return
  29020. } else {
  29021. c.ServeSuccessJSON(map[string]interface{}{
  29022. "failed_code": -10,
  29023. "msg": res.ErrMsg,
  29024. })
  29025. return
  29026. }
  29027. }
  29028. func (c *HisApiController) Post3503() {
  29029. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29030. data := make(map[string]interface{})
  29031. var struct3501s []models.Struct3501
  29032. var struct3501 models.Struct3501
  29033. struct3501.OrgName = miConfig.OrgName
  29034. struct3501.AccessKey = miConfig.AccessKey
  29035. struct3501.RequestUrl = miConfig.Url
  29036. struct3501.SecretKey = miConfig.SecretKey
  29037. struct3501.ManuDate = "2022-08-15"
  29038. struct3501.FixmedinsBchno = ""
  29039. struct3501.ManuLotnum = ""
  29040. struct3501.RxFlag = "0"
  29041. struct3501.ExpyEnd = "2022-08-15"
  29042. struct3501.Invdate = "2022-08-15"
  29043. struct3501.InvCnt = "20.25"
  29044. struct3501.Memo = ""
  29045. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29046. struct3501.FixmedinsHilistId = miConfig.Code
  29047. struct3501.FixmedinsHilistName = miConfig.OrgName
  29048. struct3501s = append(struct3501s, struct3501)
  29049. data["struct_3501s"] = struct3501s
  29050. client := &http.Client{}
  29051. bytesData, _ := json.Marshal(data)
  29052. var req *http.Request
  29053. if miConfig.MdtrtareaAdmvs == "320921" {
  29054. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29055. } else {
  29056. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29057. }
  29058. resp, _ := client.Do(req)
  29059. defer resp.Body.Close()
  29060. body, ioErr := ioutil.ReadAll(resp.Body)
  29061. if ioErr != nil {
  29062. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29064. return
  29065. }
  29066. var respJSON map[string]interface{}
  29067. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29068. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29070. return
  29071. }
  29072. var res ResultSix
  29073. var resSix10265 ResultSix10265 //1101结果
  29074. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29075. result, _ := json.Marshal(respJSON)
  29076. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29077. utils.ErrorLog("解析失败:%v", err)
  29078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29079. return
  29080. }
  29081. res.InfRefmsgid = resSix10265.InfRefmsgid
  29082. res.Output = resSix10265.Output
  29083. res.ErrMsg = resSix10265.ErrMsg
  29084. res.Cainfo = resSix10265.Cainfo
  29085. res.WarnMsg = resSix10265.WarnMsg
  29086. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29087. res.Infcode = infocode
  29088. if infocode == 0 {
  29089. c.ServeSuccessJSON(map[string]interface{}{
  29090. "msg": "上传成功",
  29091. })
  29092. return
  29093. } else {
  29094. c.ServeSuccessJSON(map[string]interface{}{
  29095. "failed_code": -10,
  29096. "msg": res.ErrMsg,
  29097. })
  29098. return
  29099. }
  29100. }
  29101. func (c *HisApiController) Post3504() {
  29102. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29103. data := make(map[string]interface{})
  29104. var struct3501s []models.Struct3501
  29105. var struct3501 models.Struct3501
  29106. struct3501.OrgName = miConfig.OrgName
  29107. struct3501.AccessKey = miConfig.AccessKey
  29108. struct3501.RequestUrl = miConfig.Url
  29109. struct3501.SecretKey = miConfig.SecretKey
  29110. struct3501.ManuDate = "2022-08-15"
  29111. struct3501.FixmedinsBchno = ""
  29112. struct3501.ManuLotnum = ""
  29113. struct3501.RxFlag = "0"
  29114. struct3501.ExpyEnd = "2022-08-15"
  29115. struct3501.Invdate = "2022-08-15"
  29116. struct3501.InvCnt = "20.25"
  29117. struct3501.Memo = ""
  29118. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29119. struct3501.FixmedinsHilistId = miConfig.Code
  29120. struct3501.FixmedinsHilistName = miConfig.OrgName
  29121. struct3501s = append(struct3501s, struct3501)
  29122. data["struct_3501s"] = struct3501s
  29123. client := &http.Client{}
  29124. bytesData, _ := json.Marshal(data)
  29125. var req *http.Request
  29126. if miConfig.MdtrtareaAdmvs == "320921" {
  29127. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29128. } else {
  29129. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29130. }
  29131. resp, _ := client.Do(req)
  29132. defer resp.Body.Close()
  29133. body, ioErr := ioutil.ReadAll(resp.Body)
  29134. if ioErr != nil {
  29135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29137. return
  29138. }
  29139. var respJSON map[string]interface{}
  29140. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29143. return
  29144. }
  29145. var res ResultSix
  29146. var resSix10265 ResultSix10265 //1101结果
  29147. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29148. result, _ := json.Marshal(respJSON)
  29149. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29150. utils.ErrorLog("解析失败:%v", err)
  29151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29152. return
  29153. }
  29154. res.InfRefmsgid = resSix10265.InfRefmsgid
  29155. res.Output = resSix10265.Output
  29156. res.ErrMsg = resSix10265.ErrMsg
  29157. res.Cainfo = resSix10265.Cainfo
  29158. res.WarnMsg = resSix10265.WarnMsg
  29159. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29160. res.Infcode = infocode
  29161. if infocode == 0 {
  29162. c.ServeSuccessJSON(map[string]interface{}{
  29163. "msg": "上传成功",
  29164. })
  29165. return
  29166. } else {
  29167. c.ServeSuccessJSON(map[string]interface{}{
  29168. "failed_code": -10,
  29169. "msg": res.ErrMsg,
  29170. })
  29171. return
  29172. }
  29173. }
  29174. func (c *HisApiController) Post3505() {
  29175. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29176. data := make(map[string]interface{})
  29177. var struct3501s []models.Struct3501
  29178. var struct3501 models.Struct3501
  29179. struct3501.OrgName = miConfig.OrgName
  29180. struct3501.AccessKey = miConfig.AccessKey
  29181. struct3501.RequestUrl = miConfig.Url
  29182. struct3501.SecretKey = miConfig.SecretKey
  29183. struct3501.ManuDate = "2022-08-15"
  29184. struct3501.FixmedinsBchno = ""
  29185. struct3501.ManuLotnum = ""
  29186. struct3501.RxFlag = "0"
  29187. struct3501.ExpyEnd = "2022-08-15"
  29188. struct3501.Invdate = "2022-08-15"
  29189. struct3501.InvCnt = "20.25"
  29190. struct3501.Memo = ""
  29191. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29192. struct3501.FixmedinsHilistId = miConfig.Code
  29193. struct3501.FixmedinsHilistName = miConfig.OrgName
  29194. struct3501s = append(struct3501s, struct3501)
  29195. data["struct_3501s"] = struct3501s
  29196. client := &http.Client{}
  29197. bytesData, _ := json.Marshal(data)
  29198. var req *http.Request
  29199. if miConfig.MdtrtareaAdmvs == "320921" {
  29200. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29201. } else {
  29202. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29203. }
  29204. resp, _ := client.Do(req)
  29205. defer resp.Body.Close()
  29206. body, ioErr := ioutil.ReadAll(resp.Body)
  29207. if ioErr != nil {
  29208. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29210. return
  29211. }
  29212. var respJSON map[string]interface{}
  29213. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29214. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29216. return
  29217. }
  29218. var res ResultSix
  29219. var resSix10265 ResultSix10265 //1101结果
  29220. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29221. result, _ := json.Marshal(respJSON)
  29222. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29223. utils.ErrorLog("解析失败:%v", err)
  29224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29225. return
  29226. }
  29227. res.InfRefmsgid = resSix10265.InfRefmsgid
  29228. res.Output = resSix10265.Output
  29229. res.ErrMsg = resSix10265.ErrMsg
  29230. res.Cainfo = resSix10265.Cainfo
  29231. res.WarnMsg = resSix10265.WarnMsg
  29232. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29233. res.Infcode = infocode
  29234. if infocode == 0 {
  29235. c.ServeSuccessJSON(map[string]interface{}{
  29236. "msg": "上传成功",
  29237. })
  29238. return
  29239. } else {
  29240. c.ServeSuccessJSON(map[string]interface{}{
  29241. "failed_code": -10,
  29242. "msg": res.ErrMsg,
  29243. })
  29244. return
  29245. }
  29246. }
  29247. func (c *HisApiController) Post3506() {
  29248. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29249. data := make(map[string]interface{})
  29250. var struct3501s []models.Struct3501
  29251. var struct3501 models.Struct3501
  29252. struct3501.OrgName = miConfig.OrgName
  29253. struct3501.AccessKey = miConfig.AccessKey
  29254. struct3501.RequestUrl = miConfig.Url
  29255. struct3501.SecretKey = miConfig.SecretKey
  29256. struct3501.ManuDate = "2022-08-15"
  29257. struct3501.FixmedinsBchno = ""
  29258. struct3501.ManuLotnum = ""
  29259. struct3501.RxFlag = "0"
  29260. struct3501.ExpyEnd = "2022-08-15"
  29261. struct3501.Invdate = "2022-08-15"
  29262. struct3501.InvCnt = "20.25"
  29263. struct3501.Memo = ""
  29264. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29265. struct3501.FixmedinsHilistId = miConfig.Code
  29266. struct3501.FixmedinsHilistName = miConfig.OrgName
  29267. struct3501s = append(struct3501s, struct3501)
  29268. data["struct_3501s"] = struct3501s
  29269. client := &http.Client{}
  29270. bytesData, _ := json.Marshal(data)
  29271. var req *http.Request
  29272. if miConfig.MdtrtareaAdmvs == "320921" {
  29273. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29274. } else {
  29275. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29276. }
  29277. resp, _ := client.Do(req)
  29278. defer resp.Body.Close()
  29279. body, ioErr := ioutil.ReadAll(resp.Body)
  29280. if ioErr != nil {
  29281. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29283. return
  29284. }
  29285. var respJSON map[string]interface{}
  29286. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29289. return
  29290. }
  29291. var res ResultSix
  29292. var resSix10265 ResultSix10265 //1101结果
  29293. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29294. result, _ := json.Marshal(respJSON)
  29295. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29296. utils.ErrorLog("解析失败:%v", err)
  29297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29298. return
  29299. }
  29300. res.InfRefmsgid = resSix10265.InfRefmsgid
  29301. res.Output = resSix10265.Output
  29302. res.ErrMsg = resSix10265.ErrMsg
  29303. res.Cainfo = resSix10265.Cainfo
  29304. res.WarnMsg = resSix10265.WarnMsg
  29305. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29306. res.Infcode = infocode
  29307. if infocode == 0 {
  29308. c.ServeSuccessJSON(map[string]interface{}{
  29309. "msg": "上传成功",
  29310. })
  29311. return
  29312. } else {
  29313. c.ServeSuccessJSON(map[string]interface{}{
  29314. "failed_code": -10,
  29315. "msg": res.ErrMsg,
  29316. })
  29317. return
  29318. }
  29319. }
  29320. func (c *HisApiController) Post3507() {
  29321. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29322. data := make(map[string]interface{})
  29323. var struct3501s []models.Struct3501
  29324. var struct3501 models.Struct3501
  29325. struct3501.OrgName = miConfig.OrgName
  29326. struct3501.AccessKey = miConfig.AccessKey
  29327. struct3501.RequestUrl = miConfig.Url
  29328. struct3501.SecretKey = miConfig.SecretKey
  29329. struct3501.ManuDate = "2022-08-15"
  29330. struct3501.FixmedinsBchno = ""
  29331. struct3501.ManuLotnum = ""
  29332. struct3501.RxFlag = "0"
  29333. struct3501.ExpyEnd = "2022-08-15"
  29334. struct3501.Invdate = "2022-08-15"
  29335. struct3501.InvCnt = "20.25"
  29336. struct3501.Memo = ""
  29337. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29338. struct3501.FixmedinsHilistId = miConfig.Code
  29339. struct3501.FixmedinsHilistName = miConfig.OrgName
  29340. struct3501s = append(struct3501s, struct3501)
  29341. data["struct_3501s"] = struct3501s
  29342. client := &http.Client{}
  29343. bytesData, _ := json.Marshal(data)
  29344. var req *http.Request
  29345. if miConfig.MdtrtareaAdmvs == "320921" {
  29346. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29347. } else {
  29348. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29349. }
  29350. resp, _ := client.Do(req)
  29351. defer resp.Body.Close()
  29352. body, ioErr := ioutil.ReadAll(resp.Body)
  29353. if ioErr != nil {
  29354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29356. return
  29357. }
  29358. var respJSON map[string]interface{}
  29359. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29362. return
  29363. }
  29364. var res ResultSix
  29365. var resSix10265 ResultSix10265 //1101结果
  29366. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29367. result, _ := json.Marshal(respJSON)
  29368. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29369. utils.ErrorLog("解析失败:%v", err)
  29370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29371. return
  29372. }
  29373. res.InfRefmsgid = resSix10265.InfRefmsgid
  29374. res.Output = resSix10265.Output
  29375. res.ErrMsg = resSix10265.ErrMsg
  29376. res.Cainfo = resSix10265.Cainfo
  29377. res.WarnMsg = resSix10265.WarnMsg
  29378. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29379. res.Infcode = infocode
  29380. if infocode == 0 {
  29381. c.ServeSuccessJSON(map[string]interface{}{
  29382. "msg": "上传成功",
  29383. })
  29384. return
  29385. } else {
  29386. c.ServeSuccessJSON(map[string]interface{}{
  29387. "failed_code": -10,
  29388. "msg": res.ErrMsg,
  29389. })
  29390. return
  29391. }
  29392. }
  29393. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  29394. // WebSocket服务器地址
  29395. serverURL := "ws://127.0.0.1:8899"
  29396. // 解析WebSocket服务器地址
  29397. u, err := url.Parse(serverURL)
  29398. if err != nil {
  29399. }
  29400. // 建立WebSocket连接
  29401. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  29402. if err != nil {
  29403. }
  29404. defer conn.Close()
  29405. input2 := make(map[string]interface{})
  29406. input := make(map[string]interface{})
  29407. inputData := make(map[string]interface{})
  29408. inputData["orgId"] = code
  29409. inputData["businessType"] = "01101"
  29410. inputData["operatorId"] = operator_id
  29411. inputData["operatorName"] = operator_name
  29412. inputData["officeId"] = "001"
  29413. inputData["officeName"] = "血透室"
  29414. inputData["deviceType"] = ""
  29415. input["data"] = inputData
  29416. input["orgId"] = code
  29417. input["transType"] = "ec.query"
  29418. //if md == ""
  29419. if md[:4] == "4403" {
  29420. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  29421. } else if md[:4] == "4401" {
  29422. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  29423. } else {
  29424. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  29425. }
  29426. input2["indata"] = input
  29427. fmt.Println(input2)
  29428. bytesData, _ := json.Marshal(input2)
  29429. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  29430. if err != nil {
  29431. fmt.Println(err)
  29432. }
  29433. // 接收消息
  29434. _, receivedMessage, err := conn.ReadMessage()
  29435. if err != nil {
  29436. fmt.Println(err)
  29437. }
  29438. return "", string(receivedMessage)
  29439. }
  29440. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  29441. // WebSocket服务器地址
  29442. serverURL := "ws://127.0.0.1:8899"
  29443. // 解析WebSocket服务器地址
  29444. u, err := url.Parse(serverURL)
  29445. if err != nil {
  29446. }
  29447. // 建立WebSocket连接
  29448. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  29449. if err != nil {
  29450. }
  29451. defer conn.Close()
  29452. input2 := make(map[string]interface{})
  29453. input := make(map[string]interface{})
  29454. inputData := make(map[string]interface{})
  29455. inputData["orgId"] = code
  29456. inputData["businessType"] = "01103"
  29457. inputData["operatorId"] = operator_id
  29458. inputData["operatorName"] = operator_name
  29459. inputData["officeId"] = "001"
  29460. inputData["officeName"] = "血透室"
  29461. inputData["deviceType"] = ""
  29462. input["data"] = inputData
  29463. input["orgId"] = code
  29464. input["transType"] = "ec.query"
  29465. //if md ==
  29466. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  29467. input2["indata"] = input
  29468. fmt.Println(input2)
  29469. bytesData, _ := json.Marshal(input2)
  29470. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  29471. if err != nil {
  29472. fmt.Println(err)
  29473. }
  29474. // 接收消息
  29475. _, receivedMessage, err := conn.ReadMessage()
  29476. if err != nil {
  29477. fmt.Println(err)
  29478. }
  29479. return "", string(receivedMessage)
  29480. }
  29481. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  29482. // WebSocket服务器地址
  29483. serverURL := "ws://127.0.0.1:8899"
  29484. // 解析WebSocket服务器地址
  29485. u, err := url.Parse(serverURL)
  29486. if err != nil {
  29487. }
  29488. // 建立WebSocket连接
  29489. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  29490. if err != nil {
  29491. }
  29492. defer conn.Close()
  29493. input2 := make(map[string]interface{})
  29494. input := make(map[string]interface{})
  29495. inputData := make(map[string]interface{})
  29496. inputData["orgId"] = code
  29497. inputData["businessType"] = "01101"
  29498. inputData["operatorId"] = operator_id
  29499. inputData["operatorName"] = operator_name
  29500. inputData["officeId"] = "001"
  29501. inputData["officeName"] = "血透室"
  29502. inputData["deviceType"] = ""
  29503. input["data"] = inputData
  29504. input["orgId"] = code
  29505. input["transType"] = "ec.query"
  29506. //if md == ""
  29507. if md[:4] == "4403" {
  29508. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  29509. } else if md[:4] == "4401" {
  29510. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  29511. } else {
  29512. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  29513. }
  29514. input2["indata"] = input
  29515. fmt.Println(input2)
  29516. bytesData, _ := json.Marshal(input2)
  29517. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  29518. if err != nil {
  29519. fmt.Println(err)
  29520. }
  29521. // 接收消息
  29522. _, receivedMessage, err := conn.ReadMessage()
  29523. if err != nil {
  29524. fmt.Println(err)
  29525. }
  29526. return "", string(receivedMessage)
  29527. }
  29528. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  29529. // WebSocket服务器地址
  29530. serverURL := "ws://127.0.0.1:8899"
  29531. // 解析WebSocket服务器地址
  29532. u, err := url.Parse(serverURL)
  29533. if err != nil {
  29534. }
  29535. // 建立WebSocket连接
  29536. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  29537. if err != nil {
  29538. }
  29539. defer conn.Close()
  29540. input2 := make(map[string]interface{})
  29541. input := make(map[string]interface{})
  29542. inputData := make(map[string]interface{})
  29543. inputData["orgId"] = code
  29544. inputData["businessType"] = "01301"
  29545. inputData["operatorId"] = operator_id
  29546. inputData["operatorName"] = operator_name
  29547. inputData["officeId"] = "001"
  29548. inputData["officeName"] = "血透室"
  29549. inputData["deviceType"] = ""
  29550. input["data"] = inputData
  29551. input["orgId"] = code
  29552. input["transType"] = "ec.query"
  29553. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  29554. input2["indata"] = input
  29555. bytesData, _ := json.Marshal(input2)
  29556. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  29557. if err != nil {
  29558. fmt.Println(err)
  29559. }
  29560. // 接收消息
  29561. _, receivedMessage, err := conn.ReadMessage()
  29562. if err != nil {
  29563. fmt.Println(err)
  29564. }
  29565. return "", string(receivedMessage)
  29566. }
  29567. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  29568. newArr = make([]string, 0)
  29569. for i := 0; i < len(arr); i++ {
  29570. repeat := false
  29571. for j := i + 1; j < len(arr); j++ {
  29572. if arr[i] == arr[j] {
  29573. repeat = true
  29574. break
  29575. }
  29576. }
  29577. if !repeat {
  29578. newArr = append(newArr, arr[i])
  29579. }
  29580. }
  29581. return
  29582. }